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)
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)
class AS3_AppFactory(IAppFactory): __slots__ = ('__apps', '__packages', '__importer') bootcampCtrl = dependency.descriptor(IBootcampController) 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) 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() return def reloadLobbyPackages(self): LOG_DEBUG('Reload app', _SPACE.SF_LOBBY) lobby = self.__apps[_SPACE.SF_LOBBY] if lobby is not None: self.__importer.load( lobby.proxy, sf_config.COMMON_PACKAGES + sf_config.LOBBY_PACKAGES) return def destroyLobby(self): if _SPACE.SF_LOBBY in self.__apps: lobby = self.__apps[_SPACE.SF_LOBBY] if lobby: LOG_DEBUG('Destroying app', _SPACE.SF_LOBBY) lobby.close() self.__importer.unload(self.__packages[_SPACE.SF_LOBBY]) self.__apps[_SPACE.SF_LOBBY] = None g_windowsStoredData.stop() return def showLobby(self): LOG_DEBUG('Shows lobby application') self._setActive(_SPACE.SF_LOBBY, True) BattleReplay.g_replayCtrl.onCommonSwfLoaded() def hideLobby(self): LOG_DEBUG('Hides lobby application') self._setActive(_SPACE.SF_LOBBY, False) def showBattle(self): LOG_DEBUG('Shows battle application') self._setActive(_SPACE.SF_BATTLE, True) def hideBattle(self): LOG_DEBUG('Hides battle application') self._setActive(_SPACE.SF_BATTLE, False) def createBattle(self, arenaGuiType): LOG_DEBUG('Creating app', _SPACE.SF_BATTLE) 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 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 app = self.getApp(appNS=appNS) libs = [ 'guiControlsLobbyBattleDynamic.swf', 'guiControlsLobbyDynamic.swf', 'popovers.swf', 'IconLibrary.swf', 'nyCmptsDynamic.swf' ] if self.bootcampCtrl.isInBootcamp(): libs.extend( ['BCGuiControlsLobbyBattle.swf', 'BCGuiControlsLobby.swf']) app.as_loadLibrariesS(libs) g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.LOBBY), EVENT_BUS_SCOPE.LOBBY) def loadBattlePage(self, appNS, arenaGuiType=ARENA_GUI_TYPE.UNKNOWN): if appNS != _SPACE.SF_BATTLE: return else: battle = self.__apps[_SPACE.SF_BATTLE] if battle is not None: self._loadBattlePage(arenaGuiType) return def goToBattleLoading(self, appNS): if appNS != _SPACE.SF_BATTLE: return else: battle = self.__apps[_SPACE.SF_BATTLE] if battle is not None: self._toggleBattleLoading(True) return def goToBattlePage(self, appNS): if appNS != _SPACE.SF_BATTLE: return battle = self.__apps[_SPACE.SF_BATTLE] if battle: self._toggleBattleLoading(False) 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 def _setActive(self, appNS, isActive): app = self.__apps[appNS] if app: app.component.visible = isActive app.active(isActive) @staticmethod def _loadBattlePage(arenaGuiType): 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 in (ARENA_GUI_TYPE.EPIC_RANDOM, ARENA_GUI_TYPE.EPIC_RANDOM_TRAINING): event = events.LoadViewEvent(VIEW_ALIAS.EPIC_RANDOM_PAGE) elif arenaGuiType == ARENA_GUI_TYPE.FALLOUT_MULTITEAM: event = events.LoadViewEvent(VIEW_ALIAS.FALLOUT_MULTITEAM_PAGE) elif arenaGuiType == ARENA_GUI_TYPE.RANKED: event = events.LoadViewEvent(VIEW_ALIAS.RANKED_BATTLE_PAGE) elif arenaGuiType == ARENA_GUI_TYPE.BOOTCAMP: event = events.LoadViewEvent(VIEW_ALIAS.BOOTCAMP_BATTLE_PAGE) else: event = events.LoadViewEvent(VIEW_ALIAS.CLASSIC_BATTLE_PAGE) g_eventBus.handleEvent(event, EVENT_BUS_SCOPE.BATTLE) @staticmethod def _toggleBattleLoading(toggle): event = events.GameEvent(events.GameEvent.BATTLE_LOADING, ctx={'isShown': toggle}) g_eventBus.handleEvent(event, EVENT_BUS_SCOPE.BATTLE)
class AS3_AppFactory(IAppFactory): __slots__ = ('__apps', '__packages', '__importer', '__waiting', '__ctrlModeFlags', '__weakref__') bootcampCtrl = dependency.descriptor(IBootcampController) def __init__(self): super(AS3_AppFactory, self).__init__() self.__apps = dict.fromkeys(_SPACE.RANGE) self.__packages = dict.fromkeys(_SPACE.RANGE) self.__importer = PackageImporter() self.__waiting = WaitingWorker() self.__waiting.start(weakref.proxy(self)) self.__ctrlModeFlags = dict.fromkeys(_SPACE.RANGE, _CTRL_FLAG.CURSOR_DETACHED) 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 getWaitingWorker(self): return self.__waiting def createLobby(self): _logger.info('Creating app: %s', _SPACE.SF_LOBBY) lobby = self.__apps[_SPACE.SF_LOBBY] if lobby is None: lobby = LobbyEntry(_SPACE.SF_LOBBY, self.__ctrlModeFlags[_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() return def reloadLobbyPackages(self): _logger.info('Reload app: %s', _SPACE.SF_LOBBY) lobby = self.__apps[_SPACE.SF_LOBBY] if lobby is not None: self.__importer.load( lobby.proxy, sf_config.COMMON_PACKAGES + sf_config.LOBBY_PACKAGES) return def destroyLobby(self): if _SPACE.SF_LOBBY in self.__apps: lobby = self.__apps[_SPACE.SF_LOBBY] if lobby: _logger.info('Destroying app: %s', _SPACE.SF_LOBBY) lobby.close() self.__importer.unload(self.__packages[_SPACE.SF_LOBBY]) self.__apps[_SPACE.SF_LOBBY] = None self.__ctrlModeFlags[ _SPACE.SF_LOBBY] = _CTRL_FLAG.CURSOR_DETACHED g_windowsStoredData.stop() return def showLobby(self): _logger.debug('Shows lobby application') self._setActive(_SPACE.SF_LOBBY, True) BattleReplay.g_replayCtrl.disableTimeWrap() def hideLobby(self): _logger.debug('Hides lobby application') self._setActive(_SPACE.SF_LOBBY, False) def showBattle(self): _logger.debug('Shows battle application') self._setActive(_SPACE.SF_BATTLE, True) def hideBattle(self): _logger.debug('Hides battle application') self._setActive(_SPACE.SF_BATTLE, False) def createBattle(self, arenaGuiType): _logger.info('Creating app: %s', _SPACE.SF_BATTLE) battle = self.__apps[_SPACE.SF_BATTLE] if not battle: battle = BattleEntry(_SPACE.SF_BATTLE, self.__ctrlModeFlags[_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.enableTimeWrap() BattleReplay.g_replayCtrl.loadServerSettings() battle.active(True) battle.setVisible(False) battle.detachCursor() def destroyBattle(self): _logger.info('Destroying app: %s', _SPACE.SF_BATTLE) if _SPACE.SF_BATTLE in self.__apps: battle = self.__apps[_SPACE.SF_BATTLE] if battle: battle.close() seq = self.__packages[_SPACE.SF_BATTLE] if seq is not None: self.__importer.unload(seq) self.__apps[_SPACE.SF_BATTLE] = None self.__ctrlModeFlags[_SPACE.SF_BATTLE] = _CTRL_FLAG.CURSOR_DETACHED return def attachCursor(self, appNS, flags=_CTRL_FLAG.GUI_ENABLED): if appNS not in self.__apps: return else: _logger.debug('Attach cursor: %s', appNS) self.__ctrlModeFlags[appNS] = flags app = self.__apps[appNS] if app is not None: app.attachCursor(flags=flags) else: _logger.debug( 'Can not attach cursor because of app is not found: %s', appNS) return def detachCursor(self, appNS): if appNS not in self.__apps: return else: _logger.debug('Detach cursor: %s', appNS) self.__ctrlModeFlags[appNS] = _CTRL_FLAG.CURSOR_DETACHED app = self.__apps[appNS] if app is not None: app.detachCursor() else: _logger.debug( 'Can not detach cursor because of app is not found: %s', appNS) return def syncCursor(self, appNS, flags=_CTRL_FLAG.GUI_ENABLED): if appNS not in self.__apps: return else: _logger.debug('Sync cursor: %s', appNS) self.__ctrlModeFlags[appNS] = flags app = self.__apps[appNS] if app is not None: app.syncCursor(flags=flags) else: _logger.debug( 'Can not attach cursor because of app is not found: %s', appNS) return def destroy(self): for appNS in self.__apps.iterkeys(): _logger.info('Destroying app: %s', appNS) entry = self.__apps[appNS] if entry: entry.close() self.__apps[appNS] = None if self.__waiting is not None: self.__waiting.stop() self.__waiting = 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 app = self.getApp(appNS=appNS) libs = [ 'guiControlsLobbyBattleDynamic.swf', 'guiControlsLobbyDynamic.swf', 'popovers.swf', 'IconLibrary.swf' ] if self.bootcampCtrl.isInBootcamp(): libs.extend( ['BCGuiControlsLobbyBattle.swf', 'BCGuiControlsLobby.swf']) app.as_loadLibrariesS(libs) g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.LOBBY), EVENT_BUS_SCOPE.LOBBY) g_eventBus.handleEvent( events.LoadViewEvent(VIEW_ALIAS.LOBBY_VEHICLE_MARKER_VIEW), EVENT_BUS_SCOPE.LOBBY) def loadBattlePage(self, appNS, arenaGuiType=ARENA_GUI_TYPE.UNKNOWN): if appNS != _SPACE.SF_BATTLE: return else: battle = self.__apps[_SPACE.SF_BATTLE] if battle is not None: self._loadBattlePage(arenaGuiType) return def goToBattleLoading(self, appNS): if appNS != _SPACE.SF_BATTLE: return else: battle = self.__apps[_SPACE.SF_BATTLE] if battle is not None: self._toggleBattleLoading(True) return def goToBattlePage(self, appNS): if appNS != _SPACE.SF_BATTLE: return battle = self.__apps[_SPACE.SF_BATTLE] if battle: self._toggleBattleLoading(False) def handleKey(self, appNS, isDown, key, mods): app = self.getApp(appNS=appNS) return app.handleKey(isDown, key, mods) if app is not None else False def _setActive(self, appNS, isActive): app = self.__apps[appNS] if app: app.setVisible(isActive) app.active(isActive) @staticmethod def _loadBattlePage(arenaGuiType): if arenaGuiType == ARENA_GUI_TYPE.TUTORIAL: event = events.LoadViewEvent(VIEW_ALIAS.TUTORIAL_BATTLE_PAGE) elif arenaGuiType in (ARENA_GUI_TYPE.EPIC_RANDOM, ARENA_GUI_TYPE.EPIC_RANDOM_TRAINING): event = events.LoadViewEvent(VIEW_ALIAS.EPIC_RANDOM_PAGE) elif arenaGuiType == ARENA_GUI_TYPE.RANKED: event = events.LoadViewEvent(VIEW_ALIAS.RANKED_BATTLE_PAGE) elif arenaGuiType == ARENA_GUI_TYPE.BATTLE_ROYALE: event = events.LoadViewEvent(VIEW_ALIAS.BATTLE_ROYALE_PAGE) elif arenaGuiType == ARENA_GUI_TYPE.BOOTCAMP: event = events.LoadViewEvent(VIEW_ALIAS.BOOTCAMP_BATTLE_PAGE) elif arenaGuiType in ARENA_GUI_TYPE.EPIC_RANGE: event = events.LoadViewEvent(VIEW_ALIAS.EPIC_BATTLE_PAGE) elif arenaGuiType == ARENA_GUI_TYPE.EVENT_BATTLES: event = events.LoadViewEvent(VIEW_ALIAS.EVENT_BATTLE_PAGE) else: event = events.LoadViewEvent(VIEW_ALIAS.CLASSIC_BATTLE_PAGE) g_eventBus.handleEvent(event, EVENT_BUS_SCOPE.BATTLE) @staticmethod def _toggleBattleLoading(toggle): event = events.GameEvent(events.GameEvent.BATTLE_LOADING, ctx={'isShown': toggle}) g_eventBus.handleEvent(event, EVENT_BUS_SCOPE.BATTLE)
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() 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() 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 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() 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)
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)