# HG changeset patch # User Jeremy Thurgood # Date 1336682503 -7200 # Node ID 07be37129447068459271a21b20a6ae5e9d840dd # Parent 14917385a0fd2a9c490e3a3094a599ae11906265 More message cleanup. diff -r 14917385a0fd -r 07be37129447 gamelib/gamegui.py --- 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