# HG changeset patch # User Neil Muller # Date 1336598864 -7200 # Node ID a79bba0dfcd8e0efb55f97748bf8e80004bbe305 # Parent 9a30162f2a9c89c2323eed62bb18a691db2491a3 Use TextBoxes for some stuff diff -r 9a30162f2a9c -r a79bba0dfcd8 gamelib/gamegui.py --- a/gamelib/gamegui.py Wed May 09 23:27:10 2012 +0200 +++ b/gamelib/gamegui.py Wed May 09 23:27:44 2012 +0200 @@ -13,8 +13,8 @@ from gamelib.data import filepath from gamelib.game_base import get_save_filename -from gamelib.gui_base import (Window, TextLabel, font_small, font_medium, - font_large) +from gamelib.gui_base import (Window, TextLabel, TextBox, font_small, + font_medium, font_large) from gamelib.gui import BigButton, ImageDrawable from gamelib.engine import PopWindow, AddWindow, GameOver from gamelib.constants import (WIDTH, FAILURE, SUCCESS, NEW_SCIENCE, @@ -221,12 +221,12 @@ title = TextLabel((200, 20, 400, 50), "Choose equipment for %s" % mission.NAME, font_medium, (255, 255, 255)) self.add_child(title) - description = TextLabel((10, 70, 790, 20), mission.LONG_DESCRIPTION, + description = TextBox((10, 70, 790, 20), mission.LONG_DESCRIPTION, font_medium, (255, 255, 255)) self.add_child(description) self.parent = parent self.game = game - self.money = ValueLabel((10, 75), 'Money') + self.money = ValueLabel((10, description.rect.height + 75), 'Money') self.money.set_value(self.game.money) self.add_child(self.money) self._equip = [] @@ -278,7 +278,7 @@ self.add_child(title) self.is_game_over = False if not messages: - results = TextLabel((200, 200, 400, 50), + results = TextBox((200, 200, 400, 50), "Nothing of interest happened", font_medium, (255, 255, 255)) self.add_child(results) @@ -287,22 +287,22 @@ for msg_type, msg in messages: # FIXME: Better widgets if msg_type in [NEW_SCHEMATIC, NEW_SCIENCE]: - text = TextLabel((50, y, 750, 25), + text = TextBox((50, y, 750, 25), msg, font_medium, (60, 60, 255)) elif msg_type == FAILURE: - text = TextLabel((50, y, 750, 25), + text = TextBox((50, y, 750, 25), msg, font_medium, (255, 60, 60)) elif msg_type == SUCCESS: - text = TextLabel((50, y, 750, 25), + text = TextBox((50, y, 750, 25), msg, font_medium, (60, 255, 60)) elif msg_type == GAME_WIN: self._make_win_screen(turn, msg) self.is_game_over = True break else: - text = TextLabel((50, y, 750, 25), + text = TextBox((50, y, 750, 25), msg, font_medium, (255, 255, 0)) - y += 50 + y += text.rect.height + 10 self.add_child(text) def _make_win_screen(self, turn, msg): @@ -314,10 +314,10 @@ title = TextLabel((200, 20, 400, 50), "Results for turn %d" % turn, font_medium, (255, 255, 255)) self.add_child(title) - won = TextLabel((200, 200, 400, 50), "You've succeeded in your quest", + won = TextBox((200, 200, 400, 50), "You've succeeded in your quest", font_large, (255, 255, 255)) self.add_child(won) - won = TextLabel((200, 250, 400, 50), msg, font_large, + won = TextBox((200, 250, 400, 50), msg, font_large, (255, 255, 255)) self.add_child(won)