diff src/parpg/application.py @ 30:94cb5843dcbb

Modifications to use the grease manager and modes
author KarstenBock@gmx.net
date Tue, 12 Jul 2011 12:31:53 +0200
parents d60f1dab8469
children 8b3890f17f94
line wrap: on
line diff
--- a/src/parpg/application.py	Tue Jul 12 12:30:41 2011 +0200
+++ b/src/parpg/application.py	Tue Jul 12 12:31:53 2011 +0200
@@ -19,7 +19,6 @@
 from fife import fife
 from fife.extensions import pychan
 from fife.extensions.serializers.xmlanimation import XMLAnimationLoader
-from fife.extensions.basicapplication import ApplicationBase
 
 from parpg import console, vfs
 from parpg.font import PARPGFont
@@ -32,6 +31,7 @@
 from parpg.common.listeners.command_listener import CommandListener
 from parpg.common.listeners.console_executor import ConsoleExecuter
 from parpg.common.listeners.widget_listener import WidgetListener
+from parpg.mode import FifeManager
 
 class KeyFilter(fife.IKeyFilter):
     """
@@ -103,7 +103,7 @@
             self.quit = True
             command.consume()
 
-class PARPGApplication(ApplicationBase):
+class PARPGApplication(FifeManager):
     """Main Application class
        We use an MVC model model
        self.gamesceneview is our view,self.model is our model
@@ -112,7 +112,8 @@
     def __init__(self, setting):
         """Initialise the instance.
            @return: None"""
-        self._setting = setting
+	self.modes = []
+	self._setting = setting
         self.engine = fife.Engine()
         self.loadSettings()
         self.engine.init()
@@ -142,11 +143,10 @@
         self.view = MainMenuView(self.engine, self.model)
         self.loadFonts()
         self.event_listener = EventListener(self.engine)
-        self.controllers = []
         controller = MainMenuController(self.engine, self.view, self.model, 
                                         self)
         #controller.initHud()
-        self.controllers.append(controller)
+        self.push_mode(controller)
         self.listener = ApplicationListener(self.event_listener,
                                             self.engine, 
                                             self.view, 
@@ -204,27 +204,6 @@
         """
         pass
 
-    def pushController(self, controller):
-        """Adds a controller to the list to be the current active one."""
-        self.controllers[-1].pause(True)
-        self.controllers.append(controller)
-    
-    def popController(self):
-        """Removes and returns the current active controller, unless its the last one"""
-        ret_controller = None
-        if self.controllers.count > 1:
-            ret_controller = self.controllers.pop()
-            self.controllers[-1].pause(False)
-        ret_controller.onStop()
-        return ret_controller
-    
-    def switchController(self, controller):
-        """Clears the controller list and adds a controller to be the current active one"""
-        for old_controller in self.controllers:
-            old_controller.onStop()
-        self.controllers = []
-        self.controllers.append(controller)
-    
     def _pump(self):
         """Main game loop.
            There are in fact 2 main loops, this one and the one in GameSceneView.
@@ -232,5 +211,4 @@
         if self.listener.quit:
             self.breakRequested = True #pylint: disable-msg=C0103
         else:
-            for controller in self.controllers:
-                controller.pump()
+            FifeManager._pump(self)