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

Revision 756, 3.8 KB checked in by aspidites, 8 years ago (diff)

Patch by Aspidites:

+ maps load properly once again
+ obsoleted get/set methods in settings.py

  • pc speed is no longer set, so walk speed is unbearably slow
  • Property svn:eol-style set to native
RevLine 
[653]1#!/usr/bin/env python
2
3#   This file is part of PARPG.
4
5#   PARPG is free software: you can redistribute it and/or modify
6#   it under the terms of the GNU General Public License as published by
7#   the Free Software Foundation, either version 3 of the License, or
8#   (at your option) any later version.
9
10#   PARPG is distributed in the hope that it will be useful,
11#   but WITHOUT ANY WARRANTY; without even the implied warranty of
12#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13#   GNU General Public License for more details.
14
15#   You should have received a copy of the GNU General Public License
16#   along with PARPG.  If not, see <http://www.gnu.org/licenses/
17
18from controllerbase import ControllerBase
[693]19from charactercreationview import CharacterCreationView
20from charactercreationcontroller import CharacterCreationController
[653]21from gamescenecontroller import GameSceneController
22from gamesceneview import GameSceneView
23
24#For debugging/code analysis
25if False:
[736]26    from parpg.mainmenuview import MainMenuView
[653]27    from fife import fife
28    from gamemodel import GameModel
29    from parpg import PARPGApplication
30
31class MainMenuController(ControllerBase):
32    """Controller for handling the main menu state"""
33
[693]34    def __init__(self, engine, view, model, application):
[653]35        """Constructor"""
[756]36        super(MainMenuController, self).__init__(engine, view, model, 
37                                                 application)
[653]38   
39        #this can be helpful for IDEs code analysis
40        if False:
41            assert(isinstance(self.engine, fife.Engine))
42            assert(isinstance(self.view, MainMenuView))
43            assert(isinstance(self.model, GameModel))
44            assert(isinstance(self.application, PARPGApplication))
45            assert(isinstance(self.event_manager, fife.EventManager))
46       
47        self.view.quit_callback = self.quitGame
48        self.view.new_game_callback = self.newGame
49        self.view.initalizeMainMenu(self.newGame, self.loadGame, self.quitGame)
50        self.view.showMenu()
51        self.resetMouseCursor()
[693]52   
[653]53    def newGame(self):
[693]54        """Start a new game and switch to the character creation controller."""
55        view = CharacterCreationView(self.engine, self.model)
56        controller = CharacterCreationController(self.engine, view, self.model,
57                                                 self.application)
[653]58        self.application.view = view
59        self.application.switchController(controller)
[693]60   
61#    def newGame(self):
62#        """Starts a new game"""
63#        view = GameSceneView(self.engine,
64#                             self.model)
65#        controller = GameSceneController(self.engine,
66#                                         view,
67#                                         self.model,
68#                                         self.application)       
69#        self.application.view = view
70#        self.application.switchController(controller)
71#        start_map = self.model.settings.get("PARPG", "Map")
72#        self.model.changeMap(start_map)
[653]73
74    def loadGame(self, *args, **kwargs):
75        """Loads the game state
76           @return: None"""
77
78        view = GameSceneView(self.engine,
79                             self.model)
80        controller = GameSceneController(self.engine,
81                                         view,
82                                         self.model,
83                                         self.application)       
84        self.application.view = view
85        self.application.switchController(controller)
[659]86        controller.loadGame(*args, **kwargs)
[653]87       
88    def onStop(self):
89        """Called when the controller is removed from the list"""
90        self.view.hideMenu()
91                                         
92   
93    def quitGame(self):
94        """Quits the game
95           @return: None"""
96        self.application.listener.quitGame()
Note: See TracBrowser for help on using the repository browser.