def viewLoadCanceled(self, alias, name): viewKey = ViewKey(alias, name) if viewKey in self.__loadingItems: _logger.warning( 'View loading for key %r has been canceled on FE side: %r.', viewKey, self.__loadingItems[viewKey]) self.cancelLoading(viewKey)
def _getParent(self, parent): if parent: return parent else: app = self.__appLoader.getApp() view = app.containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOBBY)) return view.getParentWindow() if view is not None else None
def viewLoadCanceled(self, alias, name): viewKey = ViewKey(alias, name) if viewKey in self.__loadingItems: LOG_UNEXPECTED( 'View loading for key {} has been canceled on FE side.'.format( viewKey), self.__loadingItems[viewKey]) self.cancelLoading(viewKey)
def showEventsWindow(self, eID, eventType): if self.__canNavigate(): if eventType == constants.EVENT_TYPE.C11N_PROGRESSION: _, vehicleIntCD = parseEventID(eID) vehicle = self.__itemsCache.items.getVehicleCopyByCD( vehicleIntCD) if not vehicle.isCustomizationEnabled(): _logger.warning( 'Trying to open customization from PBS for incompatible vehicle.' ) return app = self.__appLoader.getApp() view = app.containerManager.getViewByKey( ViewKey(VIEW_ALIAS.LOBBY_CUSTOMIZATION)) if view is None: lobbyHeaderNavigationPossible = yield self.__lobbyContext.isHeaderNavigationPossible( ) if not lobbyHeaderNavigationPossible: return self.soundManager.playInstantSound(SOUNDS.SELECT) else: lobbyHeaderNavigationPossible = yield self.__lobbyContext.isHeaderNavigationPossible( ) if not lobbyHeaderNavigationPossible: return if isCelebrityQuest(eID): _nyController = dependency.instance(INewYearController) if not _nyController.isEnabled(): _nyController.showStateMessage() return quests_events.showMission(eID, eventType) self.destroy() return
def viewLoaded(self, alias, name, gfxEntity): viewKey = ViewKey(alias, name) if viewKey in self.__loadingItems: item = self.__loadingItems.pop(viewKey) if item.isCancelled or item.pyEntity.isDisposed(): self.onViewLoadCanceled(viewKey, item) else: pyEntity = g_entitiesFactories.initialize( item.pyEntity, gfxEntity, item.factoryIdx, extra={'name': item.name}) item.pyEntity.onDispose -= self.__handleViewDispose if pyEntity is not None: pyEntity.getParentWindow().setViewLoaded() self.onViewLoaded(pyEntity, item.loadParams) else: msg = 'An error occurred before view initialization. View {} will be destroyed.'.format( item.pyEntity) _logger.error(msg) if not item.pyEntity.isDisposed(): item.pyEntity.destroy() self.onViewLoadError(viewKey, msg, item) else: _logger.error('View loading for key has no associated data: %r', viewKey) return
def buildInLobby(self, parent=None): if parent is None: app = self.__appLoader.getApp() view = app.containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOBBY)) if view is not None: parent = view return self.build(parent)
def viewLoadError(self, alias, name, errorTxt): """ Callback to be invoked by AS when an error occurs during view loading. :param alias: value of view alias. :param name: name of view. :param errorTxt: error text represented by string. """ viewKey = ViewKey(alias, name) msg = 'Error occurred during view {0} loading. Error:{1}'.format( viewKey, errorTxt) LOG_ERROR(msg) if viewKey in self.__loadingItems: item = self.__loadingItems.pop(viewKey) if item.isCancelled: self.onViewLoadCanceled(viewKey, item) else: self.onViewLoadError(viewKey, msg, item) if item is not None: settings = item.pyEntity.settings if constants.IS_DEVELOPMENT and settings.url != NO_IMPL_URL: g_entitiesFactories.addSettings( ViewSettings(NO_IMPL_ALIAS, View, NO_IMPL_URL, settings.type, None, ScopeTemplates.DEFAULT_SCOPE, False)) LOG_WARNING('Try to load noImpl swf...') self.__doLoadView( ViewLoadParams(NO_IMPL_ALIAS, item.name)) else: LOG_WARNING('View loading for name has no associated data', name) return
def viewLoadError(self, alias, name, errorTxt): viewKey = ViewKey(alias, name) msg = 'Error occurred during view {0} loading. Error:{1}'.format( viewKey, errorTxt) _logger.error(msg) if viewKey in self.__loadingItems: item = self.__loadingItems.pop(viewKey) if item.isCancelled: self.onViewLoadCanceled(viewKey, item) else: self.onViewLoadError(viewKey, msg, item) if item is not None: settings = item.pyEntity.settings if constants.IS_DEVELOPMENT and settings.url != NO_IMPL_URL: g_entitiesFactories.addSettings( ViewSettings(NO_IMPL_ALIAS, View, NO_IMPL_URL, settings.layer, None, ScopeTemplates.DEFAULT_SCOPE, False)) _logger.warning('Try to load noImpl swf...') self.__doLoadSFView( SFViewLoadParams(NO_IMPL_ALIAS, item.name)) else: _logger.warning('View loading for name has no associated data: %s', name) return
def viewLoaded(self, alias, name, gfxEntity): """ Callback to be invoked by AS when a view is loaded. :param alias: value of view alias. :param name: name of view. :param gfxEntity: GFXEntity (AS entity) instance. """ viewKey = ViewKey(alias, name) if viewKey in self.__loadingItems: item = self.__loadingItems.pop(viewKey) if item.isCancelled: self.onViewLoadCanceled(viewKey, item) else: pyEntity = g_entitiesFactories.initialize( item.pyEntity, gfxEntity, item.factoryIdx, extra={'name': item.name}) item.pyEntity.onDispose -= self.__handleViewDispose if pyEntity is not None: self.onViewLoaded(pyEntity, item.loadParams) else: msg = 'An error occurred before DAAPI initialization. View {} will be destroyed.'.format( item.pyEntity) LOG_ERROR(msg) if not item.pyEntity.isDisposed(): item.pyEntity.destroy() self.onViewLoadError(viewKey, msg, item) else: LOG_ERROR('View loading for key has no associated data', viewKey) return
def __init__(self, layoutID, viewClass, scope, parent=None): super(GuiImplViewLoadParams, self).__init__(ViewKey(layoutID, None), ViewLoadMode.DEFAULT, parent) self.__viewClass = viewClass self.__scope = scope return
def __init__(self, parent, content): if parent is None: app = g_appLoader.getApp() view = app.containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOBBY)) if view is not None: parent = view.getParentWindow() super(RewardWindowBase, self).__init__(parent=parent, content=content) return
def setView(self, view, parent=None): settings = WindowSettings() settings.content = view settings.parent = parent settings.layer = view.layer self.__key = ViewKey(view.layoutID, view.uniqueID) self.__window = Window(settings) self.__window.onStatusChanged += self.__onStatusChanged
def __getBattleTopHint(self): topHint = self.__topHintRef() if topHint is None and self._avatar is not None: app = self._avatar.appLoader.getApp() bcPageContainer = app.containerManager.getContainer(ViewTypes.DEFAULT) bcPage = bcPageContainer.findView(ViewKey(VIEW_ALIAS.BOOTCAMP_BATTLE_PAGE)) topHint = bcPage.topHint self.__topHintRef = weakref.ref(topHint) return topHint
def __init__(self, alias, name=None, loadMode=ViewLoadMode.DEFAULT, parent=None): super(SFViewLoadParams, self).__init__(ViewKey(alias, name), loadMode, parent) self.window = None return
def start(self): appLoader = dependency.instance(IAppLoader) app = appLoader.getDefLobbyApp() if not app: return app.loadView(SFViewLoadParams(SELECTOR_VIEW_ALIAS)) pyEntity = app.containerManager.getViewByKey( ViewKey(SELECTOR_VIEW_ALIAS)) self.__pyEntity = weakref.proxy(pyEntity) _logger.debug('Selector.start: pyEntity: %s', pyEntity)
def _getBattleTopHint(): avatar = BigWorld.player() if avatar is not None: app = avatar.appLoader.getApp() bcPageContainer = app.containerManager.getContainer( WindowLayer.VIEW) bcPage = bcPageContainer.findView( ViewKey(VIEW_ALIAS.BOOTCAMP_BATTLE_PAGE)) return bcPage.topHint else: return
def doLogin(): # noinspection PyArgumentList loginView = g_appLoader.getDefLobbyApp().containerManager.getViewByKey( ViewKey(VIEW_ALIAS.LOGIN)) if loginView and loginView.loginManager.getPreference('remember_user'): password = '******' * loginView.loginManager.getPreference( 'password_length') login = loginView.loginManager.getPreference('login') loginView.onLogin(login, password, loginView._servers.selectedServer['data'], '@' not in login)
def viewInitializationError(self, alias, name): viewKey = ViewKey(alias, name) msg = "View '{0}' does not implement net.wg.infrastructure.interfaces.IView".format(viewKey) _logger.error(msg) item = None if viewKey in self.__loadingItems: item = self.__loadingItems.pop(viewKey) pyEntity = item.pyEntity pyEntity.destroy() self.onViewLoadError(viewKey, msg, item) return
def onAppInitialized(self, event): if event.ns != APP_NAME_SPACE.SF_BATTLE: return BigWorld.logInfo(MOD_NAME, 'AppLifeCycleEvent.INITIALIZED', None) appLoader = dependency.instance(IAppLoader) battleEntry = appLoader.getDefBattleApp() if not battleEntry: return battleEntry.loadView(SFViewLoadParams(VIEW_ALIAS)) pyEntity = battleEntry.containerManager.getViewByKey(ViewKey(VIEW_ALIAS)) self.__pyEntity = weakref.proxy(pyEntity) BigWorld.logInfo(MOD_NAME, 'pyEntity: {}'.format(pyEntity), None)
def __init__(self, parent, content): if parent is None: app = self.appLoader.getApp() view = app.containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOBBY)) if view is not None: parent = view.getParentWindow() super(RewardWindowBase, self).__init__(WindowFlags.WINDOW, decorator=WindowView(), parent=parent, content=content, areaID=R.areas.default()) return
def _killHelpView(appLoader=None): battleApp = appLoader.getDefBattleApp() if battleApp is None: return False else: for alias in (VIEW_ALIAS.INGAME_HELP, VIEW_ALIAS.INGAME_DETAILS_HELP): view = battleApp.containerManager.getViewByKey(ViewKey(alias)) if view is not None: view.destroy() return True return False
def __init__(self, layoutID, visibility=HeaderMenuVisibilityState.ALL): settings = ViewSettings(layoutID) settings.flags = ViewFlags.LOBBY_TOP_SUB_VIEW settings.model = CrystalsPromoViewModel() super(CrystalsPromoView, self).__init__(settings) self.__visibility = visibility self.__isMarkerDisabled = False app = self._appLoader.getApp(APP_NAME_SPACE.SF_LOBBY) if app and app.containerManager: markerView = app.containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOBBY_VEHICLE_MARKER_VIEW)) if markerView: self.__isMarkerDisabled = markerView.getIsMarkerDisabled()
def __init__(self, trophyBasicModule, parent): if parent is None: app = self.__appLoader.getApp() view = app.containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOBBY)) if view is not None: parent = view.getParentWindow() else: parent = None super(TrophyDeviceUpgradeConfirmView, self).__init__(content=TrophyDeviceUpgradeConfirmDialogContent(trophyBasicModule), balanceContent=CommonBalanceContent(currencies=(Currency.GOLD, Currency.CREDITS)), bottomContent=DialogPricesContent(), parent=parent) self.__trophyBasicModule = trophyBasicModule self.__upgradePrice = trophyBasicModule.getUpgradePrice(self.__itemsCache.items).price self.__goldOperationsEnabled = self.__wallet.isAvailable return
def __init__(self, wndFlags, decorator, content=None, parent=None): if parent is None: app = self.__appLoader.getApp() view = app.containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOBBY)) if view is not None: parent = view.getParentWindow() settings = WindowSettings() settings.flags = wndFlags settings.decorator = decorator settings.content = content settings.parent = parent super(LobbyWindow, self).__init__(settings) return
def doLogin(app): # noinspection PyArgumentList loginView = app.containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOGIN)) if not loginView: return if loginView.loginManager.wgcAvailable: loginView.loginManager.tryWgcLogin() elif loginView.loginManager.getPreference('remember_user'): password = '******' * loginView.loginManager.getPreference( 'password_length') login = loginView.loginManager.getPreference('login') loginView.onLogin(login, password, loginView._servers.selectedServer['data'], '@' not in login)
def showWebShop(url=None, customPath=None): app = g_appLoader.getApp() if url is None: url = getWebShopURL() if customPath is not None: url = urlparse.urljoin(url, customPath) if app is not None and app.containerManager is not None: viewKey = ViewKey(VIEW_ALIAS.LOBBY_STORE) browserWindow = app.containerManager.getViewByKey(viewKey) if browserWindow is not None: browserWindow.destroy() g_eventBus.handleEvent(events.LoadViewEvent(VIEW_ALIAS.LOBBY_STORE, ctx={'url': url}), scope=EVENT_BUS_SCOPE.LOBBY) return
def __init__(self, content=None, bottomContent=None, parent=None, balanceContent=None, enableBlur=True, flags=DialogFlags.TOP_WINDOW, layer=None): if parent is None: app = self.__appLoader.getApp() view = app.containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOBBY)) if view is not None: parent = view.getParentWindow() super(LobbyDialogWindow, self).__init__(content, bottomContent, parent, balanceContent, enableBlur, flags, layer) return
def viewInitializationError(self, alias, name): """ Callback to be invoked by AS when initialization error occurs during view loading. :param alias: value of view alias. :param name: name of view. """ viewKey = ViewKey(alias, name) msg = "View '{0}' does not implement net.wg.infrastructure.interfaces.IView".format( viewKey) LOG_ERROR(msg) item = None if viewKey in self.__loadingItems: item = self.__loadingItems.pop(viewKey) pyEntity = item.pyEntity pyEntity.destroy() self.onViewLoadError(viewKey, msg, item) return
def new_startBuild(base, self, vDesc, vState): if g_config.data['enabled']: modelDesc, playerName = getModelDescInfo(self.id, vDesc, 'hangar') view = SL.appLoader.getDefLobbyApp().containerManager.getViewByKey( ViewKey(VIEW_ALIAS.LOBBY_CUSTOMIZATION)) if view is not None: if modelDesc is not None and getattr(vDesc, 'modelDesc', None) is not None: SystemMessages.pushMessage( g_config.i18n['UI_install_customization'], SystemMessages.SM_TYPE.Warning) vDesc.modelDesc = None else: applyModelDesc( vDesc, modelDesc, self._HangarVehicleAppearance__outfit.modelsSet or 'default', playerName) return base(self, vDesc, vState)
def onWindowClose(self): g_config.loadingProxy = None self.destroy() if needToReReadSkinsModels: from gui import DialogsInterface from gui.Scaleform.daapi.view.dialogs import SimpleDialogMeta, ConfirmDialogButtons, DIALOG_BUTTON_ID class RestartButtons(ConfirmDialogButtons): def getLabels(self): return [{ 'id': DIALOG_BUTTON_ID.SUBMIT, 'label': self._submit, 'focused': True }, { 'id': DIALOG_BUTTON_ID.CLOSE, 'label': self._close, 'focused': False }] DialogsInterface.showDialog( SimpleDialogMeta( g_config.i18n['UI_restart_header'], g_config.i18n['UI_restart_text'], RestartButtons( g_config.i18n['UI_restart_button_restart'], g_config.i18n['UI_restart_button_shutdown']), None), lambda restart: (BigWorld.savePreferences(), (BigWorld.restartGame() if restart else BigWorld.quit()))) elif self.doLogin: loginView = g_appLoader.getDefLobbyApp( ).containerManager.getViewByKey(ViewKey(VIEW_ALIAS.LOGIN)) if loginView and loginView.loginManager.getPreference( 'remember_user'): password = '******' * loginView.loginManager.getPreference( 'password_length') login = loginView.loginManager.getPreference('login') loginView.onLogin(login, password, loginView._servers.selectedServer['data'], '@' not in login)