コード例 #1
0
ファイル: app_factory.py プロジェクト: webiumsk/WOT-0.9.12
 def __init__(self):
     super(AS3_AS2_AppFactory, self).__init__()
     self.__apps = {_SPACE.SF_LOBBY: None,
      _SPACE.SF_BATTLE: None,
      _SPACE.SF_LOGITECH: None}
     self.__importer = PackageImporter()
     return
コード例 #2
0
 def __init__(self):
     super(AS3_AppFactory, self).__init__()
     self.__apps = dict.fromkeys(_SPACE.RANGE)
     self.__packages = dict.fromkeys(_SPACE.RANGE)
     self.__importer = PackageImporter()
コード例 #3
0
ファイル: app_factory.py プロジェクト: webiumsk/WOT-0.9.12
class AS3_AS2_AppFactory(IAppFactory):
    __slots__ = ('__apps', '__importer')

    def __init__(self):
        super(AS3_AS2_AppFactory, self).__init__()
        self.__apps = {_SPACE.SF_LOBBY: None,
         _SPACE.SF_BATTLE: None,
         _SPACE.SF_LOGITECH: None}
        self.__importer = PackageImporter()
        return

    def getPackageImporter(self):
        return self.__importer

    def hasApp(self, appNS):
        return appNS in self.__apps.keys()

    def getApp(self, appNS = None):
        app = None
        if appNS is not None:
            if appNS in self.__apps:
                app = self.__apps[appNS]
        else:
            app = self.__apps[_SPACE.SF_LOBBY]
            if not app:
                app = self.__apps[_SPACE.SF_BATTLE]
        return app

    def getDefLobbyApp(self):
        return self.__apps[_SPACE.SF_LOBBY]

    def getDefBattleApp(self):
        return self.__apps[_SPACE.SF_BATTLE]

    def createLobby(self):
        LOG_DEBUG('Creating app', _SPACE.SF_LOBBY)
        lobby = self.__apps[_SPACE.SF_LOBBY]
        if not lobby:
            lobby = LobbyEntry(_SPACE.SF_LOBBY)
            self.__importer.load(lobby.proxy, sf_config.COMMON_PACKAGES + sf_config.LOBBY_PACKAGES)
            self.__apps[_SPACE.SF_LOBBY] = lobby
        lobby.active(True)
        g_windowsStoredData.start()
        BattleReplay.g_replayCtrl.onCommonSwfLoaded()

    def destroyLobby(self):
        LOG_DEBUG('Destroying app', _SPACE.SF_LOBBY)
        if _SPACE.SF_LOBBY in self.__apps:
            lobby = self.__apps[_SPACE.SF_LOBBY]
            if lobby:
                lobby.close()
                self.__importer.unload(sf_config.LOBBY_PACKAGES)
                self.__apps[_SPACE.SF_LOBBY] = None
        g_windowsStoredData.stop()
        BattleReplay.g_replayCtrl.onCommonSwfUnloaded()
        return

    def showLobby(self):
        LOG_DEBUG('Shows lobby')
        self._setActive(_SPACE.SF_LOBBY, True)
        BattleReplay.g_replayCtrl.onCommonSwfLoaded()

    def hideLobby(self):
        LOG_DEBUG('Hides lobby')
        self._setActive(_SPACE.SF_LOBBY, False)
        BattleReplay.g_replayCtrl.onCommonSwfUnloaded()

    def createBattle(self):
        LOG_DEBUG('Creating app', _SPACE.SF_BATTLE)
        LogitechMonitor.onScreenChange('battle')
        battle = self.__apps[_SPACE.SF_BATTLE]
        if not battle:
            battle = self._getBattleAppInstance()
            self.__importer.load(battle.proxy, sf_config.COMMON_PACKAGES + sf_config.BATTLE_PACKAGES)
            self.__apps[_SPACE.SF_BATTLE] = battle
        BattleReplay.g_replayCtrl.onBattleSwfLoaded()
        battle.active(True)
        battle.component.visible = False

    def destroyBattle(self):
        LOG_DEBUG('Destroying app', _SPACE.SF_BATTLE)
        if _SPACE.SF_BATTLE in self.__apps:
            battle = self.__apps[_SPACE.SF_BATTLE]
            if battle:
                battle.close()
            self.__importer.unload(sf_config.BATTLE_PACKAGES)
            self.__apps[_SPACE.SF_BATTLE] = None
        return

    def attachCursor(self, appNS):
        if appNS not in self.__apps:
            return
        LOG_DEBUG('Attach cursor', appNS)
        app = self.__apps[appNS]
        if app and app.cursorMgr:
            app.cursorMgr.attachCursor(True)
        else:
            Cursor.setAutoShow(True)

    def detachCursor(self, appNS):
        if appNS not in self.__apps:
            return
        LOG_DEBUG('Detach cursor', appNS)
        app = self.__apps[appNS]
        if app and app.cursorMgr:
            app.cursorMgr.detachCursor(True)

    def destroy(self):
        for appNS in self.__apps.iterkeys():
            LOG_DEBUG('Destroying app', appNS)
            entry = self.__apps[appNS]
            if entry:
                entry.close()
            self.__apps[appNS] = None

        g_windowsStoredData.stop()
        if self.__importer is not None:
            self.__importer.unload()
            self.__importer = None
        return

    def goToIntroVideo(self, appNS):
        if appNS != _SPACE.SF_LOBBY:
            return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.INTRO_VIDEO), EVENT_BUS_SCOPE.LOBBY)

    def goToLogin(self, appNS):
        if appNS != _SPACE.SF_LOBBY:
            return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.LOGIN), EVENT_BUS_SCOPE.LOBBY)

    def goToLobby(self, appNS):
        if appNS != _SPACE.SF_LOBBY:
            return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.LOBBY), EVENT_BUS_SCOPE.LOBBY)

    def goToBattleLoading(self, appNS):
        if appNS != _SPACE.SF_LOBBY:
            return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.BATTLE_LOADING), EVENT_BUS_SCOPE.LOBBY)

    def goToTutorialLoading(self, appNS):
        if appNS != _SPACE.SF_LOBBY:
            return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.TUTORIAL_LOADING), scope=EVENT_BUS_SCOPE.LOBBY)

    def goToFalloutMultiTeamLoading(self, appNS):
        if appNS != _SPACE.SF_LOBBY:
            return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.FALLOUT_MULTI_TEAM_BATTLE_LOADING), scope=EVENT_BUS_SCOPE.LOBBY)

    def goToBattle(self, appNS):
        if appNS != _SPACE.SF_BATTLE:
            return
        battle = self.__apps[_SPACE.SF_BATTLE]
        if battle:
            self._loadBattlePage()
            battle.component.visible = True

    def showDisconnectDialog(self, appNS, description):
        if appNS == _SPACE.SF_LOBBY:
            DialogsInterface.showDisconnect(*description)

    def _getBattleAppInstance(self):
        return Battle(_SPACE.SF_BATTLE)

    def _loadBattlePage(self):
        pass

    def _setActive(self, appNS, isActive):
        app = self.__apps[appNS]
        if app:
            app.active(isActive)
コード例 #4
0
class AS3_AppFactory(IAppFactory):
    __slots__ = ('__apps', '__packages', '__importer')

    def __init__(self):
        super(AS3_AppFactory, self).__init__()
        self.__apps = dict.fromkeys(_SPACE.RANGE)
        self.__packages = dict.fromkeys(_SPACE.RANGE)
        self.__importer = PackageImporter()

    def getPackageImporter(self):
        return self.__importer

    def hasApp(self, appNS):
        return appNS in self.__apps.keys()

    def getApp(self, appNS = None):
        app = None
        if appNS is not None:
            if appNS in self.__apps:
                app = self.__apps[appNS]
        else:
            app = self.__apps[_SPACE.SF_LOBBY]
            if not app:
                app = self.__apps[_SPACE.SF_BATTLE]
        return app

    def getDefLobbyApp(self):
        return self.__apps[_SPACE.SF_LOBBY]

    def getDefBattleApp(self):
        return self.__apps[_SPACE.SF_BATTLE]

    def createLobby(self):
        LOG_DEBUG('Creating app', _SPACE.SF_LOBBY)
        self.createLogitech()
        lobby = self.__apps[_SPACE.SF_LOBBY]
        if lobby is None:
            lobby = LobbyEntry(_SPACE.SF_LOBBY)
            self.__packages[_SPACE.SF_LOBBY] = sf_config.LOBBY_PACKAGES
            self.__importer.load(lobby.proxy, sf_config.COMMON_PACKAGES + self.__packages[_SPACE.SF_LOBBY])
            self.__apps[_SPACE.SF_LOBBY] = lobby
        lobby.active(True)
        g_windowsStoredData.start()
        BattleReplay.g_replayCtrl.onCommonSwfLoaded()
        return

    def destroyLobby(self):
        LOG_DEBUG('Destroying app', _SPACE.SF_LOBBY)
        if _SPACE.SF_LOBBY in self.__apps:
            lobby = self.__apps[_SPACE.SF_LOBBY]
            if lobby:
                lobby.close()
                self.__importer.unload(self.__packages[_SPACE.SF_LOBBY])
                self.__apps[_SPACE.SF_LOBBY] = None
        g_windowsStoredData.stop()
        BattleReplay.g_replayCtrl.onCommonSwfUnloaded()
        return

    def showLobby(self):
        LOG_DEBUG('Shows lobby')
        self._setActive(_SPACE.SF_LOBBY, True)
        BattleReplay.g_replayCtrl.onCommonSwfLoaded()

    def hideLobby(self):
        LOG_DEBUG('Hides lobby')
        self._setActive(_SPACE.SF_LOBBY, False)
        BattleReplay.g_replayCtrl.onCommonSwfUnloaded()

    def createBattle(self, arenaGuiType):
        LOG_DEBUG('Creating app', _SPACE.SF_BATTLE)
        self.createLogitech()
        battle = self.__apps[_SPACE.SF_BATTLE]
        if not battle:
            battle = BattleEntry(_SPACE.SF_BATTLE)
            packages = sf_config.BATTLE_PACKAGES
            if arenaGuiType in sf_config.BATTLE_PACKAGES_BY_ARENA_TYPE:
                packages += sf_config.BATTLE_PACKAGES_BY_ARENA_TYPE[arenaGuiType]
            else:
                packages += sf_config.BATTLE_PACKAGES_BY_DEFAULT
            self.__packages[_SPACE.SF_BATTLE] = packages
            self.__importer.load(battle.proxy, sf_config.COMMON_PACKAGES + packages)
            self.__apps[_SPACE.SF_BATTLE] = battle
        BattleReplay.g_replayCtrl.onBattleSwfLoaded()
        battle.active(True)
        battle.component.visible = False
        battle.detachCursor()

    def destroyBattle(self):
        LOG_DEBUG('Destroying app', _SPACE.SF_BATTLE)
        if _SPACE.SF_BATTLE in self.__apps:
            battle = self.__apps[_SPACE.SF_BATTLE]
            if battle:
                battle.close()
            self.__importer.unload(self.__packages[_SPACE.SF_BATTLE])
            self.__apps[_SPACE.SF_BATTLE] = None
        return

    def createLogitech(self):
        logitech = self.__apps[_SPACE.SF_LOGITECH]
        if logitech is None:
            logitech = LogitechMonitorEntry()
            self.__apps[_SPACE.SF_LOGITECH] = logitech
        logitech.activate()
        return

    def attachCursor(self, appNS, flags = _CTRL_FLAG.GUI_ENABLED):
        if appNS not in self.__apps:
            return
        else:
            LOG_DEBUG('Attach cursor', appNS)
            app = self.__apps[appNS]
            if app is not None:
                app.attachCursor(flags=flags)
            else:
                LOG_DEBUG('Can not attach cursor because of app is not found', appNS)
            return

    def detachCursor(self, appNS):
        if appNS not in self.__apps:
            return
        else:
            LOG_DEBUG('Detach cursor', appNS)
            app = self.__apps[appNS]
            if app is not None:
                app.detachCursor()
            else:
                LOG_DEBUG('Can not detach cursor because of app is not found', appNS)
            return

    def syncCursor(self, appNS, flags = _CTRL_FLAG.GUI_ENABLED):
        if appNS not in self.__apps:
            return
        else:
            LOG_DEBUG('Attach cursor', appNS)
            app = self.__apps[appNS]
            if app is not None:
                app.syncCursor(flags=flags)
            else:
                LOG_DEBUG('Can not attach cursor because of app is not found', appNS)
            return

    def destroy(self):
        for appNS in self.__apps.iterkeys():
            LOG_DEBUG('Destroying app', appNS)
            entry = self.__apps[appNS]
            if entry:
                entry.close()
            self.__apps[appNS] = None

        self.__packages = dict.fromkeys(_SPACE.RANGE)
        g_windowsStoredData.stop()
        if self.__importer is not None:
            self.__importer.unload()
            self.__importer = None
        return

    def goToIntroVideo(self, appNS):
        if appNS != _SPACE.SF_LOBBY:
            return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.INTRO_VIDEO), EVENT_BUS_SCOPE.LOBBY)

    def goToLogin(self, appNS):
        if appNS != _SPACE.SF_LOBBY:
            return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.LOGIN), EVENT_BUS_SCOPE.LOBBY)

    def goToLobby(self, appNS):
        if appNS != _SPACE.SF_LOBBY:
            return
        g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.LOBBY), EVENT_BUS_SCOPE.LOBBY)

    def goToBattleLoading(self, appNS, arenaGuiType):
        if appNS != _SPACE.SF_LOBBY:
            return
        if arenaGuiType == ARENA_GUI_TYPE.TUTORIAL:
            event = events.LoadViewEvent(VIEW_ALIAS.TUTORIAL_LOADING)
        elif arenaGuiType == ARENA_GUI_TYPE.FALLOUT_MULTITEAM:
            event = events.LoadViewEvent(VIEW_ALIAS.FALLOUT_MULTI_TEAM_BATTLE_LOADING)
        else:
            event = events.LoadViewEvent(VIEW_ALIAS.BATTLE_LOADING)
        g_eventBus.handleEvent(event, EVENT_BUS_SCOPE.LOBBY)

    def goToBattle(self, appNS, arenaGuiType):
        if appNS != _SPACE.SF_BATTLE:
            return
        battle = self.__apps[_SPACE.SF_BATTLE]
        if battle:
            if arenaGuiType == ARENA_GUI_TYPE.TUTORIAL:
                event = events.LoadViewEvent(VIEW_ALIAS.TUTORIAL_BATTLE_PAGE)
            elif arenaGuiType == ARENA_GUI_TYPE.FALLOUT_CLASSIC:
                event = events.LoadViewEvent(VIEW_ALIAS.FALLOUT_CLASSIC_PAGE)
            elif arenaGuiType == ARENA_GUI_TYPE.FALLOUT_MULTITEAM:
                event = events.LoadViewEvent(VIEW_ALIAS.FALLOUT_MULTITEAM_PAGE)
            else:
                event = events.LoadViewEvent(VIEW_ALIAS.CLASSIC_BATTLE_PAGE)
            g_eventBus.handleEvent(event, EVENT_BUS_SCOPE.BATTLE)
            battle.component.visible = True

    def showDisconnectDialog(self, appNS, description):
        if appNS == _SPACE.SF_LOBBY:
            DialogsInterface.showDisconnect(*description)

    def handleKey(self, appNS, isDown, key, mods):
        app = self.getApp(appNS=appNS)
        if app is not None:
            return app.handleKey(isDown, key, mods)
        else:
            return False
            return

    def _setActive(self, appNS, isActive):
        app = self.__apps[appNS]
        if app:
            app.active(isActive)