source: branches/active/character_customization/game/parpg/charactercreationview.py @ 753

Revision 736, 3.0 KB checked in by aspidites, 8 years ago (diff)

Patch by Aspidites:

  • renamed scripts package to parpg
  • renamed parpg module to application
  • removed packaging and other related files (kept locally for reference, will reintroduce similar scripts to resolve bug #275
  • updated all import statements to respect changes above
Line 
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."""
16from fife.extensions import pychan
17
18from viewbase import ViewBase
19
20class CharacterCreationView(ViewBase):
21    """View used to display the character creation screen.
22       @ivar background: Widget displayed as the background.
23       @type background: L{pychan.Widget}
24       @ivar start_new_game_callback: Callback attached to the startButton.
25       @type start_new_game_callback: callable
26       @ivar cancel_new_game_callback: Callback attached to the cancelButton.
27       @type cancel_new_game_callback: callable
28       @ivar character_screen: Widget used to display the character creation
29           screen.
30       @type character_screen: L{pychan.Widget}"""
31
32    def __init__(self, engine, model):
33        """Construct a new L{CharacterCreationView} instance.
34           @param engine: Rendering engine used to display the view.
35           @type engine: L{fife.Engine}
36           @param model: Model of the game state.
37           @type model: L{GameState}"""
38        ViewBase.__init__(self, engine, model)
39        self.background = pychan.loadXML('gui/main_menu_background.xml')
40        screen_mode = self.engine.getRenderBackend().getCurrentScreenMode()
41        self.background.width = screen_mode.getWidth()
42        self.background.height = screen_mode.getHeight()
43        self.start_new_game_callback = None
44        self.cancel_new_game_callback = None
45        self.character_screen = pychan.loadXML('gui/character_screen.xml')
46        self.character_screen.adaptLayout()
47        character_screen_events = {}
48        character_screen_events['startButton'] = self.startNewGame
49        character_screen_events['cancelButton'] = self.cancelNewGame
50        self.character_screen.mapEvents(character_screen_events)
51   
52    def show(self):
53        """Display the view.
54           @return: None"""
55        self.background.show()
56        self.character_screen.show()
57   
58    def hide(self):
59        """Hide the view.
60           @return: None"""
61        self.background.hide()
62        self.character_screen.hide()
63   
64    def startNewGame(self):
65        """Callback tied to the startButton.
66           @return: None"""
67        self.start_new_game_callback()
68   
69    def cancelNewGame(self):
70        """Callback tied to the cancelButton.
71           @return: None"""
72        self.cancel_new_game_callback()
Note: See TracBrowser for help on using the repository browser.