source: branches/active/character_customization/game/parpg/mainmenucontroller.py @ 833

Revision 774, 3.8 KB checked in by aspidites, 9 years ago (diff)

Patch by Aspidites

  • removed shebang from all python files except launcher scripts
  • added shebang to pychan_designer
  • Property svn:eol-style set to native
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
16from controllerbase import ControllerBase
17from charactercreationview import CharacterCreationView
18from charactercreationcontroller import CharacterCreationController
19from gamescenecontroller import GameSceneController
20from gamesceneview import GameSceneView
21
22#For debugging/code analysis
23if False:
24    from parpg.mainmenuview import MainMenuView
25    from fife import fife
26    from gamemodel import GameModel
27    from parpg import PARPGApplication
28
29class MainMenuController(ControllerBase):
30    """Controller for handling the main menu state"""
31
32    def __init__(self, engine, view, model, application):
33        """Constructor"""
34        super(MainMenuController, self).__init__(engine, view, model, 
35                                                 application)
36   
37        #this can be helpful for IDEs code analysis
38        if False:
39            assert(isinstance(self.engine, fife.Engine))
40            assert(isinstance(self.view, MainMenuView))
41            assert(isinstance(self.model, GameModel))
42            assert(isinstance(self.application, PARPGApplication))
43            assert(isinstance(self.event_manager, fife.EventManager))
44       
45        self.view.quit_callback = self.quitGame
46        self.view.new_game_callback = self.newGame
47        self.view.initalizeMainMenu(self.newGame, self.loadGame, self.quitGame)
48        self.view.showMenu()
49        self.resetMouseCursor()
50   
51    def newGame(self):
52        """Start a new game and switch to the character creation controller."""
53        view = CharacterCreationView(self.engine, self.model)
54        controller = CharacterCreationController(self.engine, view, self.model,
55                                                 self.application)
56        self.application.view = view
57        self.application.switchController(controller)
58   
59#    def newGame(self):
60#        """Starts a new game"""
61#        view = GameSceneView(self.engine,
62#                             self.model)
63#        controller = GameSceneController(self.engine,
64#                                         view,
65#                                         self.model,
66#                                         self.application)       
67#        self.application.view = view
68#        self.application.switchController(controller)
69#        start_map = self.model.settings.get("PARPG", "Map")
70#        self.model.changeMap(start_map)
71
72    def loadGame(self, *args, **kwargs):
73        """Loads the game state
74           @return: None"""
75
76        view = GameSceneView(self.engine,
77                             self.model)
78        controller = GameSceneController(self.engine,
79                                         view,
80                                         self.model,
81                                         self.application)       
82        self.application.view = view
83        self.application.switchController(controller)
84        controller.loadGame(*args, **kwargs)
85       
86    def onStop(self):
87        """Called when the controller is removed from the list"""
88        self.view.hideMenu()
89                                         
90   
91    def quitGame(self):
92        """Quits the game
93           @return: None"""
94        self.application.listener.quitGame()
Note: See TracBrowser for help on using the repository browser.