1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 from controllerbase import ControllerBase
19 from charactercreationview import CharacterCreationView
20 from charactercreationcontroller import CharacterCreationController
21 from gamescenecontroller import GameSceneController
22 from gamesceneview import GameSceneView
23
24
25 if False:
26 from scripts.mainmenuview import MainMenuView
27 from fife import fife
28 from gamemodel import GameModel
29 from parpg import PARPGApplication
30
31 -class MainMenuController(ControllerBase):
32 """Controller for handling the main menu state"""
33
34 - def __init__(self, engine, view, model, application):
35 """Constructor"""
36 ControllerBase.__init__(self, engine, view, model, application)
37
38
39 if False:
40 assert(isinstance(self.engine, fife.Engine))
41 assert(isinstance(self.view, MainMenuView))
42 assert(isinstance(self.model, GameModel))
43 assert(isinstance(self.application, PARPGApplication))
44 assert(isinstance(self.event_manager, fife.EventManager))
45
46 self.view.quit_callback = self.quitGame
47 self.view.new_game_callback = self.newGame
48 self.view.initalizeMainMenu(self.newGame, self.loadGame, self.quitGame)
49 self.view.showMenu()
50 self.resetMouseCursor()
51
53 """Start a new game and switch to the character creation controller."""
54 view = CharacterCreationView(self.engine, self.model)
55 controller = CharacterCreationController(self.engine, view, self.model,
56 self.application)
57 self.application.view = view
58 self.application.switchController(controller)
59
60
61
62
63
64
65
66
67
68
69
70
71
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
88 """Called when the controller is removed from the list"""
89 self.view.hideMenu()
90
91
93 """Quits the game
94 @return: None"""
95 self.application.listener.quitGame()
96