# HG changeset patch # User Neil Muller # Date 1336561419 -7200 # Node ID 59afe9f92383d8b76a689734e068f787c48550b3 # Parent a40a76012bd7b4ea1704f94ca4e21a2463c0292c Hook up basic results screen diff -r a40a76012bd7 -r 59afe9f92383 gamelib/gamegui.py --- a/gamelib/gamegui.py Wed May 09 12:08:44 2012 +0200 +++ b/gamelib/gamegui.py Wed May 09 13:03:39 2012 +0200 @@ -150,6 +150,40 @@ self._draw_text() +class ResultsWindow(Window): + + def __init__(self, screen, messages, turn): + super(ResultsWindow, self).__init__(screen) + exitbut = ExitGameButton() + self.add_child(exitbut) + title = TextLabel((200, 20, 400, 50), "Results for turn %d" % turn, + font_medium, (255, 255, 255)) + self.add_child(title) + if not messages: + results = TextLabel((200, 200, 400, 50), + "Nothing of interest happened", font_medium, + (255, 255, 255)) + self.add_child(results) + else: + y = 200 + for msg_type, msg in messages: + # FIXME: Better widgets + if msg_type in [NEW_SCHEMATIC, NEW_SCIENCE]: + text = TextLabel((50, y, 750, 25), + msg, font_medium, (60, 60, 255)) + elif msg_type == FAILURE: + text = TextLabel((50, y, 750, 25), + msg, font_medium, (255, 60, 60)) + elif msg_type == SUCCESS: + text = TextLabel((50, y, 750, 25), + msg, font_medium, (60, 255, 60)) + else: + text = TextLabel((50, y, 750, 25), + msg, font_medium, (255, 255, 0)) + y += 50 + self.add_child(text) + + class ActivityWindow(Window): def __init__(self, screen, lab, develop): @@ -315,6 +349,7 @@ def __init__(self, screen): super(LabWindow, self).__init__(screen) + self.screen = screen self.game = Game() exit = ExitGameButton() self.add_child(exit) @@ -367,21 +402,13 @@ def end_turn(self): self.game.cur_missions = self.activity.get_mission_list() messages = self.game.end_turn() - # FIXME: Hook this up to a report window or something - for msg_type, msg in messages: - if msg_type == NEW_SCIENCE or msg_type == NEW_SCHEMATIC: - print msg - elif msg_type == FAILURE: - print 'Mission failure: %s' % msg - elif msg_type == SUCCESS: - print 'Success: %s' % msg - else: - print 'Unhandled result %d: %s' % (msg_type, msg) + results = ResultsWindow(self.screen, messages, self.game.turn) self.game.start_turn() self.update_labels() self.update_widgets() self.develop.update_widgets() self.activity.update_widgets() + AddWindow.post(results) def update(self): self.update_labels() diff -r a40a76012bd7 -r 59afe9f92383 gamelib/gamestate.py --- a/gamelib/gamestate.py Wed May 09 12:08:44 2012 +0200 +++ b/gamelib/gamestate.py Wed May 09 13:03:39 2012 +0200 @@ -15,6 +15,7 @@ # Will be updated on the next turn self.points = 0 self.reputation = 0 + self.turn = 0 # Missions being attempted self.cur_missions = [] # Science allocation for the current turn @@ -32,6 +33,7 @@ def start_turn(self): # Make more flexible? self.points += 3 + self.turn += 1 self.cur_missions = [] self.cur_allocation = [] @@ -64,7 +66,7 @@ messages = [] for result in mission_results: result.apply(self) - messages.append((result.outcome, result.msg)) + messages.append((result.outcome, result.message)) for science in new_stuff: # FIXME: Update UI better. if science.SCIENCE_TYPE == 'research':