comparison gamelib/gamescreen.py @ 100:b5b6cbf556e6

Make start new game start a new game. Add Resume to main menu
author Neil Muller <neil@dip.sun.ac.za>
date Tue, 24 Aug 2010 08:48:50 +0200
parents 367b1c9c3c6d
children 65976205fc2d
comparison
equal deleted inserted replaced
99:367b1c9c3c6d 100:b5b6cbf556e6
124 124
125 125
126 class GameScreen(Screen): 126 class GameScreen(Screen):
127 def __init__(self, shell): 127 def __init__(self, shell):
128 Screen.__init__(self, shell) 128 Screen.__init__(self, shell)
129 self.running = False
129 130
131 def _clear_all(self):
132 for widget in self.subwidgets[:]:
133 self.remove(widget)
134
135 def start_game(self):
136 self._clear_all()
130 # TODO: Randomly plonk the state here for now 137 # TODO: Randomly plonk the state here for now
131 self.state = initial_state() 138 self.state = initial_state()
132 self.state_widget = StateWidget(self.state) 139 self.state_widget = StateWidget(self.state)
133 self.add(self.state_widget) 140 self.add(self.state_widget)
134 141
135 self.popup_menu = PopupMenu(shell) 142 self.popup_menu = PopupMenu(self.shell)
136 self.menubutton = PopupMenuButton('Menu', 143 self.menubutton = PopupMenuButton('Menu',
137 action=self.popup_menu.show_menu) 144 action=self.popup_menu.show_menu)
138 145
139 self.handbutton = HandButton(action=self.hand_pressed) 146 self.handbutton = HandButton(action=self.hand_pressed)
140 147
151 self.toolbar.bottomleft = self.bottomleft 158 self.toolbar.bottomleft = self.bottomleft
152 self.add(self.toolbar) 159 self.add(self.toolbar)
153 160
154 self.detail = DetailWindow(self.state) 161 self.detail = DetailWindow(self.state)
155 162
156 # Test items 163 self.running = True
157 self.state.add_inventory_item('triangle')
158 164
159 def show_detail(self): 165 def show_detail(self):
160 self.state_widget.add_centered(self.detail) 166 self.state_widget.add_centered(self.detail)
161 167
162 # Albow uses magic method names (command + '_cmd'). Yay. 168 # Albow uses magic method names (command + '_cmd'). Yay.