comparison demos/shooter/scripts/world.py @ 468:ebbb420a90b9

Fix the bug where the high score dialog box causes a crash after the player completes the level.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 14 Apr 2010 16:35:07 +0000
parents 4d0aa75a82f1
children 5994e61cdebd
comparison
equal deleted inserted replaced
467:4d0aa75a82f1 468:ebbb420a90b9
203 203
204 self._highscores.addHighScore(HighScore(name, self.scene.player.score)) 204 self._highscores.addHighScore(HighScore(name, self.scene.player.score))
205 self._highscores.show() 205 self._highscores.show()
206 206
207 def endLevel(self): 207 def endLevel(self):
208 #there is only one level so do the high score display
209 self._paused = True 208 self._paused = True
210 209 self._sceneended = True
210
211 def showHighScoreDialog(self):
212 self._sceneended = False
213
211 if self._highscores.isHighScore(self.scene.player.score): 214 if self._highscores.isHighScore(self.scene.player.score):
212 score = self.scene.player.score 215 score = self.scene.player.score
213 #self.reset()
214 216
215 dlg = pychan.loadXML('gui/highscoredialog.xml') 217 dlg = pychan.loadXML('gui/highscoredialog.xml')
216 dlg.execute({ 'okay' : "Yay!" }) 218 dlg.execute({ 'okay' : "Yay!" })
217 name = dlg.findChild(name='name').text 219 name = dlg.findChild(name='name').text
218 220
219 #self._highscores.addHighScore(HighScore(name, score)) 221 self._highscores.addHighScore(HighScore(name, score))
220 #self._highscores.show() 222 self._highscores.show()
221 223
222 self._sceneended = True
223
224
225 224
226 def newGame(self): 225 def newGame(self):
227 self.loadLevel("maps/shooter_map1.xml") 226 self.loadLevel("maps/shooter_map1.xml")
228 self._mainmenu.hide() 227 self._mainmenu.hide()
229 self._paused = False 228 self._paused = False
300 """ 299 """
301 Called every frame. 300 Called every frame.
302 """ 301 """
303 302
304 if self._sceneended: 303 if self._sceneended:
304 self.showHighScoreDialog()
305 self.reset() 305 self.reset()
306 self.showMainMenu()
307 306
308 if self._genericrenderer: 307 if self._genericrenderer:
309 self._genericrenderer.removeAll("quads") 308 self._genericrenderer.removeAll("quads")
310 309
311 310