Beispiel #1
0
    def __init__(self, setting):
        """Initialise the instance.
           @return: None"""
        ApplicationBase.__init__(self, setting)
        self.manager = FifeManager()
        # KLUDGE M. George Hansen 2011-06-04: See parpg/vfs.py.
        vfs.VFS = self.engine.getVFS()
        vfs.VFS.addNewSource(setting.get("parpg","DataPath"))

        self.quitRequested = False
        self.breakRequested = False
        self.returnValues = []
        #self.engine.getModel(self)
        self.model = GameModel(self.engine, setting)
        self.model.readMapFiles()
        self.model.readObjectDB()
        self.model.getAgentImportFiles()
        self.model.readAllAgents()
        self.model.getDialogues()
        # KLUDGE M. George Hansen 2011-06-04: Hack to allow loaded PyChan XML
        #     scripts to locate their resources.
        os.chdir(setting.get("parpg","DataPath"))
        self.view = MainMenuView(self.engine, self.model)
        self.loadFonts()
        self.event_listener = EventListener(self.engine)
        controller = MainMenuController(self.engine, self.view, self.model, 
                                        self)
        #controller.initHud()
        self.manager.push_mode(controller)
        self.listener = ApplicationListener(self.event_listener,
                                            self.engine, 
                                            self.view, 
                                            self.model)
Beispiel #2
0
class PARPGApplication(ApplicationBase):
    """Main Application class
       We use an MVC model model
       self.gamesceneview is our view,self.model is our model
       self.controller is the controller"""

    def __init__(self, setting):
        """Initialise the instance.
           @return: None"""
        ApplicationBase.__init__(self, setting)
        self.manager = FifeManager()
        # KLUDGE M. George Hansen 2011-06-04: See parpg/vfs.py.
        vfs.VFS = self.engine.getVFS()
        vfs.VFS.addNewSource(setting.get("parpg","DataPath"))

        self.quitRequested = False
        self.breakRequested = False
        self.returnValues = []
        #self.engine.getModel(self)
        self.model = GameModel(self.engine, setting)
        self.model.readMapFiles()
        self.model.readObjectDB()
        self.model.getAgentImportFiles()
        self.model.readAllAgents()
        self.model.getDialogues()
        # KLUDGE M. George Hansen 2011-06-04: Hack to allow loaded PyChan XML
        #     scripts to locate their resources.
        os.chdir(setting.get("parpg","DataPath"))
        self.view = MainMenuView(self.engine, self.model)
        self.loadFonts()
        self.event_listener = EventListener(self.engine)
        controller = MainMenuController(self.engine, self.view, self.model, 
                                        self)
        #controller.initHud()
        self.manager.push_mode(controller)
        self.listener = ApplicationListener(self.event_listener,
                                            self.engine, 
                                            self.view, 
                                            self.model)

    def loadFonts(self):
        # add the fonts path to the system path to import font definitons
        sys.path.insert(0, os.path.join(self._setting.get("parpg", "DataPath"), 'fonts'))
        from oldtypewriter import fontdefs

        for fontdef in fontdefs:
            pychan.internal.get_manager().addFont(PARPGFont(fontdef,
                                                            self._setting))


    def createListener(self):
        """ __init__ takes care of creating an event listener, so
            basicapplication's createListener is harmful. Without 
            overriding it, the program quit's on esc press, rather than
            invoking the main menu
        """
        pass

    def _pump(self):
        """Main game loop.
           There are 2 main loops, this one and the one in GameSceneView.
           @return: None"""
        if self.listener.quit:
            self.breakRequested = True #pylint: disable-msg=C0103
        else:
            self.manager._pump()