Mercurial > fife-parpg
comparison demos/shooter/scripts/gui/guis.py @ 456:41fd97da94d1
Moved guis to their own file.
Added a continue button to the main menu.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 07 Apr 2010 21:26:26 +0000 |
parents | |
children | 597b066d5ccb |
comparison
equal
deleted
inserted
replaced
455:e686b82d93d0 | 456:41fd97da94d1 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 # #################################################################### | |
4 # Copyright (C) 2005-2009 by the FIFE team | |
5 # http://www.fifengine.de | |
6 # This file is part of FIFE. | |
7 # | |
8 # FIFE is free software; you can redistribute it and/or | |
9 # modify it under the terms of the GNU Lesser General Public | |
10 # License as published by the Free Software Foundation; either | |
11 # version 2.1 of the License, or (at your option) any later version. | |
12 # | |
13 # This library is distributed in the hope that it will be useful, | |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 # Lesser General Public License for more details. | |
17 # | |
18 # You should have received a copy of the GNU Lesser General Public | |
19 # License along with this library; if not, write to the | |
20 # Free Software Foundation, Inc., | |
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
22 # #################################################################### | |
23 | |
24 from fife import fife | |
25 from fife.extensions import pychan | |
26 from fife.extensions.pychan import widgets | |
27 | |
28 class MainMenu(object): | |
29 def __init__(self, world): | |
30 self._world = world | |
31 self._widget = pychan.loadXML('gui/mainmenu.xml') | |
32 | |
33 self._continue = self._widget.findChild(name="continue") | |
34 self._newgame = self._widget.findChild(name="new_game") | |
35 self._credits = self._widget.findChild(name="credits") | |
36 self._highscores = self._widget.findChild(name="high_scores") | |
37 self._quit = self._widget.findChild(name="quit") | |
38 | |
39 self._widget.position = (0,0) | |
40 | |
41 eventMap = { | |
42 'continue': self._world.continueGame, | |
43 'new_game': self._world.newGame, | |
44 'credits': self._world.showCredits, | |
45 'high_scores': self._world.showHighScores, | |
46 'quit': self._world.quit, | |
47 } | |
48 | |
49 self._widget.mapEvents(eventMap) | |
50 | |
51 self._continueMinWidth = self._continue.min_width | |
52 self._continueMinHeight = self._continue.min_height | |
53 self._continueMaxWidth = self._continue.max_width | |
54 self._continueMaxHeight = self._continue.max_height | |
55 | |
56 | |
57 def show(self, cont=False): | |
58 if cont: | |
59 self._continue.min_width = self._continueMinWidth | |
60 self._continue.min_height = self._continueMinHeight | |
61 self._continue.max_width = self._continueMaxWidth | |
62 self._continue.max_height = self._continueMaxHeight | |
63 | |
64 else: | |
65 self._continue.min_width = 0 | |
66 self._continue.min_height = 0 | |
67 self._continue.max_width = 0 | |
68 self._continue.max_height = 0 | |
69 | |
70 self._continue.adaptLayout() | |
71 self._widget.show() | |
72 | |
73 def hide(self): | |
74 self._widget.hide() | |
75 | |
76 class HeadsUpDisplay(object): | |
77 def __init__(self, world): | |
78 self._world = world | |
79 self._widget = pychan.loadXML('gui/hud.xml') | |
80 | |
81 self._fpstext = self._widget.findChild(name="fps") | |
82 self._velocitytext = self._widget.findChild(name="velocity") | |
83 self._positiontext = self._widget.findChild(name="position") | |
84 self._scoretext = self._widget.findChild(name="score") | |
85 self._widget.position = (0,0) | |
86 | |
87 def show(self): | |
88 self._widget.show() | |
89 | |
90 def hide(self): | |
91 self._widget.hide() | |
92 | |
93 def setFPSText(self, text): | |
94 self._fpstext.text = text | |
95 | |
96 def setPositionText(self, text): | |
97 self._positiontext.text = text | |
98 | |
99 def setVelocityText(self, text): | |
100 self._velocitytext.text = text | |
101 | |
102 def setScoreText(self, text): | |
103 self._scoretext.text = text |