Exemplo n.º 1
0
    def __init__(self, TDS):
        """Initialized the application

        Args:
            TDS: A fife_settings.Setting instance
        """
        ApplicationBase.__init__(self, TDS)
        FifeManager.__init__(self)
        self.name = self.settings.get("fife-rpg", "ProjectName")
        if self.name is None:
            raise AttributeError("The application name is not specified in"
                                 "the settings file")
        self._listener = None
        self.world = None
        self._maps = {}
        self._current_map = None
        self._languages = {}
        self._current_language = ""
        self._components = {}
        self._actions = {}
        self._systems = {}
        self._behaviours = {}
        self._map_switched_callbacks = []
        self._map_loaded_callbacks = []
        default_language = self.settings.get("i18n", "DefaultLanguage", "en")
        languages_dir = self.settings.get("i18n", "Directory", "__languages")
        for language in self.settings.get("i18n", "Languages", ("en",)):
            fallback = (language == default_language)
            self._languages[language] = gettext.translation(self.name,
                                                            languages_dir,
                                                            [language],
                                                            fallback=fallback)
        language = self.settings.get("i18n", "Language", default_language)
        self.switch_language(language)
Exemplo n.º 2
0
    def __init__(self, TDS):
        """Initialized the application

        Args:
            TDS: A fife_settings.Setting instance
        """
        ApplicationBase.__init__(self, TDS)
        FifeManager.__init__(self)
        self.name = self.settings.get("fife-rpg", "ProjectName")
        if self.name is None:
            raise AttributeError("The application name is not specified in"
                                 "the settings file")
        self._listener = None
        self.world = None
        self._maps = {}
        self._current_map = None
        self._languages = {}
        self._current_language = ""
        self._components = {}
        self._actions = {}
        self._systems = {}
        self._behaviours = {}
        self._map_switched_callbacks = []
        self._map_loaded_callbacks = []
        default_language = self.settings.get("i18n", "DefaultLanguage", "en")
        languages_dir = self.settings.get("i18n", "Directory", "__languages")
        for language in self.settings.get("i18n", "Languages", ("en", )):
            fallback = (language == default_language)
            self._languages[language] = gettext.translation(self.name,
                                                            languages_dir,
                                                            [language],
                                                            fallback=fallback)
        language = self.settings.get("i18n", "Language", default_language)
        self.switch_language(language)
Exemplo n.º 3
0
    def step(self, time_delta):
        """Performs actions every frame.

        Args:
            time_delta: Time elapsed since last call to pump
        """
        if self.current_map:
            self.check_agent_changes()
            self.current_map.update_entities_fife()
            self.current_map.update_entities()
            self.current_map.update_entitities_agent()
        if self.world:
            self.world.step(time_delta)
        FifeManager.step(self, time_delta)
Exemplo n.º 4
0
    def step(self, time_delta):
        """Performs actions every frame.

        Args:
            time_delta: Time elapsed since last call to pump
        """
        if self.current_map:
            self.check_agent_changes()
            self.current_map.update_entities_fife()
            self.current_map.update_entities()
            self.current_map.update_entitities_agent()
        if self.world:
            self.world.step(time_delta)
        FifeManager.step(self, time_delta)
Exemplo n.º 5
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)
Exemplo n.º 6
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()