Mercurial > fife-parpg
changeset 465:4e58dab2fcdc
Added the high score dialog to ask for players name (with no validation yet)
Enabled modal execution.
Fixed a small bug where the scene tries to remove a projectile that it already removed from the scene.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 13 Apr 2010 20:23:13 +0000 |
parents | be035dff788a |
children | 716d44ba42df |
files | demos/shooter/gui/highscoredialog.xml demos/shooter/run.py demos/shooter/scripts/gui/guis.py demos/shooter/scripts/scene.py demos/shooter/scripts/world.py |
diffstat | 5 files changed, 25 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/shooter/gui/highscoredialog.xml Tue Apr 13 20:23:13 2010 +0000 @@ -0,0 +1,12 @@ +<Window title="High Score" size="500,500"> + <VBox hexpand="1"> + <HBox> + <Label text="Name:" min_size="100, 10" /> + <TextField name="name" text="" min_size="100, 10" /> + </HBox> + </VBox> + <Spacer /> + <HBox> + <Button name="okay" text="Okay"/> + </HBox> +</Window>
--- a/demos/shooter/run.py Tue Apr 13 19:43:31 2010 +0000 +++ b/demos/shooter/run.py Tue Apr 13 20:23:13 2010 +0000 @@ -49,7 +49,7 @@ fife.Key.ESCAPE,]) self.quit = False - + def keyPressed(self, evt): keyval = evt.getKey().getValue() keystr = evt.getKey().getAsString().lower() @@ -68,6 +68,7 @@ def __init__(self): super(Shooter,self).__init__() pychan.init(self.engine, debug=False) + pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) self.world = world.World(self, self.engine) self.listener = ApplicationListener(self.engine, self.world)
--- a/demos/shooter/scripts/gui/guis.py Tue Apr 13 19:43:31 2010 +0000 +++ b/demos/shooter/scripts/gui/guis.py Tue Apr 13 20:23:13 2010 +0000 @@ -162,6 +162,7 @@ for highscore in self._scores: if score._score > highscore._score: element = i + print element break i += 1 @@ -331,7 +332,10 @@ self.endElement('Button') self.endElement('VBox') - self.endElement('Container') + self.endElement('Container') + + self._xmlout.endDocument() + self._file.close() def show(self): self._widget.show()
--- a/demos/shooter/scripts/scene.py Tue Apr 13 19:43:31 2010 +0000 +++ b/demos/shooter/scripts/scene.py Tue Apr 13 20:23:13 2010 +0000 @@ -275,7 +275,8 @@ #remove any expired projectiles for p in projtodelete: - self._projectiles.remove(p) + if p in self._projectiles: + self._projectiles.remove(p) def _getPlayer(self):
--- a/demos/shooter/scripts/world.py Tue Apr 13 19:43:31 2010 +0000 +++ b/demos/shooter/scripts/world.py Tue Apr 13 20:23:13 2010 +0000 @@ -190,11 +190,13 @@ self._gameover.show() if self._highscores.isHighScore(self.scene.player.score): - self._highscores.addHighScore(HighScore("player", self.scene.player.score)) + dlg = pychan.loadXML('gui/highscoredialog.xml') + dlg.execute({ 'okay' : "Yay!" }) + name = dlg.findChild(name='name').text + self._highscores.addHighScore(HighScore(name, self.scene.player.score)) self._highscores.show() - def newGame(self): self.loadLevel("maps/shooter_map1.xml") self._mainmenu.hide()