source: branches/active/character_customization/game/scripts/charactercreationcontroller.py @ 712

Revision 693, 3.1 KB checked in by technomage, 9 years ago (diff)

Patch Technomage

  • Added a placeholder character creation screen accessible from the

main menu via the "New Game" button and an in-game character screen
using the same Pychan XML script.

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 controller that defines the behavior of the character creation
16   screen."""
17from controllerbase import ControllerBase
18from gamescenecontroller import GameSceneController
19from gamesceneview import GameSceneView
20
21class CharacterCreationController(ControllerBase):
22    """Controller defining the behavior of the character creation screen."""
23    def __init__(self, engine, view, model, application):
24        """Construct a new L{CharacterCreationController} instance.
25           @param engine: Rendering engine used to display the associated view.
26           @type engine: L{fife.Engine}
27           @param view: View used to display the character creation screen.
28           @type view: L{ViewBase}
29           @param model: Model of the game state.
30           @type model: L{GameModel}
31           @param application: Application used to glue the various MVC
32               components together.
33           @type application:
34               L{fife.extensions.basicapplication.ApplicationBase}"""
35        ControllerBase.__init__(self, engine, view, model, application)
36        self.view.start_new_game_callback = self.startNewGame
37        self.view.cancel_new_game_callback = self.cancelNewGame
38        self.view.show()
39   
40    def startNewGame(self):
41        """Create the new character and start a new game.
42           @return: None"""
43        view = GameSceneView(self.engine, self.model)
44        controller = GameSceneController(self.engine, view, self.model,
45                                         self.application)
46        self.application.view = view
47        self.application.switchController(controller)
48        start_map = self.model.settings.get("PARPG", "Map")
49        self.model.changeMap(start_map)
50   
51    def cancelNewGame(self):
52        """Exit the character creation view and return the to main menu.
53           @return: None"""
54        # KLUDGE Technomage 2010-12-24: This is to prevent a circular import
55        #     but a better fix needs to be thought up.
56        from mainmenucontroller import MainMenuController
57        from mainmenuview import MainMenuView
58        view = MainMenuView(self.engine, self.model)
59        controller = MainMenuController(self.engine, view, self.model,
60                                        self.application)
61        self.application.view = view
62        self.application.switchController(controller)
63   
64    def onStop(self):
65        """Called when the controller is removed from the list.
66           @return: None"""
67        self.view.hide()
Note: See TracBrowser for help on using the repository browser.