Commits

Andrew Peterson committed 3db931e

WIP provided error notification when login fails.

Comments (0)

Files changed (2)

pyshipcommand_gui/dialogs.py

 from djlib.logger import getLogger
 log = getLogger('pyshipcommand.gui.dialogs')
 
+class NotifyDialog(widgets.GenericDialog):
+
+    def __init__(self, title, msg, screen_width, screen_height):
+        widgets.GenericDialog(title, [widgets.Button("#OK")], [DLGRESULT_CLOSE])
+        lbl = Label (msg)
+        self.content.add_child (lbl)
+        self.connect_signal (SIG_DIALOGRESPONSE, self._close)
+
+        # Position dialog in middle/lower half of screen
+        self.topleft = ((screen_width-self.width)/2, screen_height/2)
+        dialog.depth = 2
+
+    def _close(self, result):
+        dialog.destroy()
+
 class ShipInfoWidget(widgets.Table):
     
     FRAME_WIDTH = 200

pyshipcommand_gui/states/login.py

 import pygame
 
 # LOCAL
-from pyshipcommand_gui.dialogs import LoginDialog
+from pyshipcommand_gui.dialogs import LoginDialog, NotifyDialog
 from pyshipcommand_gui.client import RegisterClient
 
 from djlib.game import GameState
         """Called during application shutdown."""
         self.loginWnd.destroy()
 
+    def _showErrorDialog(self, error_msg):
+        (w,h) = self.gc.rsurf.get_size()
+        error = NotifyDialog("Login Error", "Username or password is not valid! Please try again...", w, h)
+        self.gc.ui_render.add_widget(error)
+        error.set_focus()
+
 #end LoginState