comparison charactercreationview.py @ 0:7a89ea5404b1

Initial commit of parpg-core.
author M. George Hansen <technopolitica@gmail.com>
date Sat, 14 May 2011 01:12:35 -0700
parents
children 06145a6ee387
comparison
equal deleted inserted replaced
-1:000000000000 0:7a89ea5404b1
1 # This file is part of PARPG.
2 #
3 # PARPG is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # PARPG is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
15 """Provides the view for displaying the character creation screen."""
16
17 import os
18
19 from fife.extensions import pychan
20
21 from viewbase import ViewBase
22
23 class CharacterCreationView(ViewBase):
24 """View used to display the character creation screen.
25 @ivar background: Widget displayed as the background.
26 @type background: L{pychan.Widget}
27 @ivar start_new_game_callback: Callback attached to the startButton.
28 @type start_new_game_callback: callable
29 @ivar cancel_new_game_callback: Callback attached to the cancelButton.
30 @type cancel_new_game_callback: callable
31 @ivar character_screen: Widget used to display the character creation
32 screen.
33 @type character_screen: L{pychan.Widget}"""
34
35 def __init__(self, engine, model, settings):
36 """Construct a new L{CharacterCreationView} instance.
37 @param engine: Rendering engine used to display the view.
38 @type engine: L{fife.Engine}
39 @param model: Model of the game state.
40 @type model: L{GameState}"""
41 ViewBase.__init__(self, engine, model)
42 self.settings = settings
43 gui_path = os.path.join(self.settings.system_path,
44 self.settings.parpg.GuiPath)
45 self.background = pychan.loadXML(os.path.join(gui_path,
46 'main_menu_background.xml'))
47 screen_mode = self.engine.getRenderBackend().getCurrentScreenMode()
48 self.background.width = screen_mode.getWidth()
49 self.background.height = screen_mode.getHeight()
50 self.start_new_game_callback = None
51 self.cancel_new_game_callback = None
52 self.character_screen = pychan.loadXML(os.path.join(gui_path,
53 'character_screen.xml'))
54 self.character_screen.adaptLayout()
55 character_screen_events = {}
56 character_screen_events['startButton'] = self.startNewGame
57 character_screen_events['cancelButton'] = self.cancelNewGame
58 self.character_screen.mapEvents(character_screen_events)
59
60 def show(self):
61 """Display the view.
62 @return: None"""
63 self.background.show()
64 self.character_screen.show()
65
66 def hide(self):
67 """Hide the view.
68 @return: None"""
69 self.background.hide()
70 self.character_screen.hide()
71
72 def startNewGame(self):
73 """Callback tied to the startButton.
74 @return: None"""
75 self.start_new_game_callback()
76
77 def cancelNewGame(self):
78 """Callback tied to the cancelButton.
79 @return: None"""
80 self.cancel_new_game_callback()