Mercurial > parpg-source
comparison mainmenucontroller.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 | 708a6f651c31 |
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 | |
16 from controllerbase import ControllerBase | |
17 from charactercreationview import CharacterCreationView | |
18 from charactercreationcontroller import CharacterCreationController | |
19 from gamescenecontroller import GameSceneController | |
20 from gamesceneview import GameSceneView | |
21 | |
22 #For debugging/code analysis | |
23 if False: | |
24 from parpg.mainmenuview import MainMenuView | |
25 from fife import fife | |
26 from gamemodel import GameModel | |
27 from parpg import PARPGApplication | |
28 | |
29 class 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 self.model.settings) | |
55 controller = CharacterCreationController(self.engine, view, self.model, | |
56 self.application) | |
57 self.application.view = view | |
58 self.application.switchController(controller) | |
59 | |
60 # def newGame(self): | |
61 # """Starts a new game""" | |
62 # view = GameSceneView(self.engine, | |
63 # self.model) | |
64 # controller = GameSceneController(self.engine, | |
65 # view, | |
66 # self.model, | |
67 # self.application) | |
68 # self.application.view = view | |
69 # self.application.switchController(controller) | |
70 # start_map = self.model.settings.get("PARPG", "Map") | |
71 # self.model.changeMap(start_map) | |
72 | |
73 def loadGame(self, *args, **kwargs): | |
74 """Loads the game state | |
75 @return: None""" | |
76 | |
77 view = GameSceneView(self.engine, | |
78 self.model) | |
79 controller = GameSceneController(self.engine, | |
80 view, | |
81 self.model, | |
82 self.application) | |
83 self.application.view = view | |
84 self.application.switchController(controller) | |
85 controller.loadGame(*args, **kwargs) | |
86 | |
87 def onStop(self): | |
88 """Called when the controller is removed from the list""" | |
89 self.view.hideMenu() | |
90 | |
91 | |
92 def quitGame(self): | |
93 """Quits the game | |
94 @return: None""" | |
95 self.application.listener.quitGame() |