# HG changeset patch # User Neil Muller # Date 1336503968 -7200 # Node ID 5c4c676731125e82c43688826c1fefea2f58cf37 # Parent 24f0707695b4e4ef0941c292da7267d18b4da091 Display available points diff -r 24f0707695b4 -r 5c4c67673112 gamelib/gamegui.py --- a/gamelib/gamegui.py Tue May 08 21:05:54 2012 +0200 +++ b/gamelib/gamegui.py Tue May 08 21:06:08 2012 +0200 @@ -6,7 +6,7 @@ from pygame import image from gamelib.data import filepath -from gamelib.gui_base import Window, font_small +from gamelib.gui_base import Window, TextLabel, font_small, font_medium from gamelib.gui import BigButton from gamelib.engine import PopWindow from gamelib.constants import WIDTH @@ -64,6 +64,7 @@ self.science.points, self.points) self._draw_text() self.parent.game.cur_allocation.append(self.science) + self.parent.update_points() def reset(self): while self.points > 0: @@ -71,6 +72,18 @@ self.points -= 1 self.text = '%s: %d' % (self.science.NAME, self.science.points) self._draw_text() + self.parent.update_points() + + +class PointsLabel(TextLabel): + + def __init__(self): + super(PointsLabel, self).__init__((10, 70, 300, 50), + 'Available Human Resources : 0', font_medium, (255, 255, 0)) + + def set_value(self, value): + self.text = 'Available Human Resource : %d' % value + self._draw_text() class LabWindow(Window): @@ -86,10 +99,13 @@ reset = ResetButton(self) self.add_child(reset) - self.game.start_turn() + self.points = PointsLabel() + self.add_child(self.points) self._sciences = [] - + # Setup for the first turn + self.game.start_turn() + self.update_points() self._make_science_widgets() def _make_science_widgets(self): @@ -113,6 +129,10 @@ self._sciences = [] self._make_science_widgets() self.game.start_turn() + self.update_points() + + def update_points(self): + self.points.set_value(self.game.get_available_points()) def reset(self): for widget in self._sciences: