changeset 139:07be37129447

More message cleanup.
author Jeremy Thurgood <firxen@gmail.com>
date Thu, 10 May 2012 22:41:43 +0200
parents 14917385a0fd
children 8fbd0abb7744
files gamelib/gamegui.py
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/gamegui.py	Thu May 10 22:33:26 2012 +0200
+++ b/gamelib/gamegui.py	Thu May 10 22:41:43 2012 +0200
@@ -308,6 +308,11 @@
 
 
 class ResultsWindow(Window):
+    message_colours = {
+        INFO: (60, 60, 255),
+        FAILURE: (255, 60, 60),
+        SUCCESS: (60, 255, 60),
+        }
 
     def __init__(self, screen, messages, turn):
         super(ResultsWindow, self).__init__(screen)
@@ -326,18 +331,12 @@
             y = 200
             for msg_type, msg, loot in messages:
                 # FIXME: Better widgets
-                if msg_type == INFO:
-                    y = self.display_message(y, msg, loot, (60, 60, 255))
-                elif msg_type == FAILURE:
-                    y = self.display_message(y, msg, loot, (255, 60, 60))
-                elif msg_type == SUCCESS:
-                    y = self.display_message(y, msg, loot, (60, 255, 60))
-                elif msg_type == GAME_WIN:
+                if msg_type == GAME_WIN:
                     self._make_win_screen(turn, msg)
                     self.is_game_over = True
                     break
-                else:
-                    y = self.display_message(y, msg, loot, (255, 255, 0))
+                colour = self.message_colours.get(msg_type, (255, 255, 255))
+                y = self.display_message(y, msg, loot, colour)
 
     def display_message(self, y, msg, loot, colour, font=font_medium):
         text = TextBox((50, y, 700, 25), msg, font, colour)
@@ -351,7 +350,7 @@
         if hasattr(value, 'NAME'):
             value = value.NAME
         msg = "* %s: %s" % (kind, value)
-        text = TextBox((60, y, 690, 25), msg, font_medium, (255, 255, 60))
+        text = TextBox((80, y, 670, 25), msg, font_medium, (255, 255, 60))
         self.add_child(text)
         return text.rect.height + 5