def __onInfoBtnClick(self): self.__flowLogger.logInfoClick( source=self.__currentView, albumTab=self._tabCache.getCurrentYear(), rewardTab=self._tabCache.getRewardsTab(), selectedObject=NewYearNavigation.getCurrentObject()) NewYearNavigation.showInfoView(showDefaultTabForced=True)
def __onPreviewStyleButton(self, *_): paramDict = { 'instantly': True, 'withFade': True, 'viewAlias': ViewAliases.REWARDS_VIEW, 'objectName': NewYearNavigation.getCurrentObject(), 'tabName': self.__yearName, 'collection': self.__collectionName, 'forceShowMainView': True } NewYearNavigation.switchTo(None, True) def _backCallback(): if not self.__nyController.isEnabled(): event_dispatcher.showHangar() else: NewYearNavigation.switchFromStyle(**paramDict) showStylePreview(getVehiclePreviewID(self.__currentStyle, self.__yearName, self.__collectionName), self.__currentStyle, self.__currentStyle.getDescription(), backCallback=_backCallback, backBtnDescrLabel=backport.text( R.strings.ny.collectionsReward.backLabel())) return
def onDeselect(self, newSelectedObject): self.setState(CameraMovementStates.FROM_OBJECT) if not newSelectedObject: return newSelectedObject.setState(CameraMovementStates.MOVING_TO_OBJECT) NewYearNavigation.switchFromHeroTank() newSelectedObject.setState(CameraMovementStates.ON_OBJECT)
def __onWidgetClick(self, *_): self.__uiLogger.logClick(self._lobbyMode) NewYearNavigation.switchTo(CustomizationObjects.FIR, True, withFade=True) if self._lobbyMode: self.__soundManager.playEvent(NewYearSoundEvents.ENTER_CUSTOME) self.__soundManager.playEvent(NewYearSoundEvents.TRANSITION_TREE)
def _switchToView(self, aliasName, *args, **kwargs): saveHistory = kwargs.pop('saveHistory', False) popHistory = kwargs.pop('popHistory', False) if popHistory: self._navigationHistory.pop() if saveHistory: self.__preserveHistory() NewYearNavigation.switchToView(aliasName, *args, **kwargs)
def __onSideBarSelected(self, event): ctx = event.ctx if ctx.menuName != NyWidgetTopMenu.GLADE: return tabName = ctx.tabName self.__currentObject = tabName NewYearNavigation.switchTo(tabName, True, withFade=True) with self.viewModel.transaction() as model: self.__updateSlots(fullUpdate=True, model=model) self.__clearPopovers()
def __onWindowClose(self): if self.__isWaitingToHide: return if not self.__stopVideo(): g_eventBus.handleEvent(events.LootboxesEvent( events.LootboxesEvent.ON_MAIN_VIEW_CLOSED), scope=EVENT_BUS_SCOPE.LOBBY) self.__flowlogger.logCloseClick( currentObject=NewYearNavigation.getCurrentObject(), currentView=NewYearNavigation.getCurrentViewName()) self.destroyWindow()
def onMouseClick(self): anchorName = self.anchorName if self.enabled and anchorName and anchorName != self.__customizableObjectsMgr.getCurrentCameraAnchor(): self.logClick(anchorName) NewYearSoundsManager.playEvent(NewYearSoundEvents.ENTER_CUSTOME) NewYearNavigation.switchByAnchorName(anchorName) for cameraObject in ClientSelectableCameraObject.allCameraObjects: if cameraObject.state != CameraMovementStates.FROM_OBJECT: cameraObject.onDeselect(None) return
def __onOpenIntro(self): if self.__nyController.isPostEvent(): self.viewModel.setIsIntroOpened(True) elif self.__isOwnView: self.__infoFlowLogger.logInfoClick() NewYearNavigation.showInfoView( previousViewAlias=ViewAliases.VEHICLES_VIEW) self.parentView.destroyWindow() else: self.__infoFlowLogger.logInfoClick() NewYearNavigation.showInfoView()
def __call__(self, *args, **kwargs): if not self.__nyController.isEnabled(): showHangar() return else: giftEventHub = self.__giftsController.getEventHub(GiftEventID.NY_HOLIDAYS) if giftEventHub is None or not giftEventHub.getSettings().isEnabled: NewYearNavigation.switchFromStyle(CustomizationObjects.FIR, viewAlias=ViewAliases.GLADE_VIEW, forceShowMainView=True) return NewYearNavigation.switchFromStyle(self.__objectName, viewAlias=ViewAliases.GIFT_SYSTEM_VIEW, forceShowMainView=True) return
def __onMenuItemSelected(self, args): menuName = args['view'] viewAlias = _NAVIGATION_ALIAS_VIEWS[menuName] self._navigationHistory.clear() self.__topMenuLogger.logClick(menuName) self.__flowLogger.logTabSelect( source=self.__currentView, view=menuName, albumTab=self._tabCache.getCurrentYear(), rewardTab=self._tabCache.getRewardsTab(), selectedObject=NewYearNavigation.getCurrentObject(), previousObject=NewYearNavigation.getPreviousObject()) with self.viewModel.transaction() as tx: tx.setStartIndexMenu(self.__tabsController.tabOrderKey(menuName)) self.__soundsManager.playEvent(NewYearSoundEvents.TAB_BAR_CLICK) self._goToByViewAlias(viewAlias, saveHistory=False)
def __updateData(self, model): model.setLobbyMode(self._lobbyMode) model.setUserLanguage(str(getLanguageCode()).upper()) model.setBonusValue(CreditsBonusHelper.getBonusInPercents()) model.setIsRomanNumbersAllowed(IS_ROMAN_NUMBERS_ALLOWED) model.setIsEnabled( NewYearNavigation.getCurrentObject() != CustomizationObjects.FIR)
def __onEventBtnClick(self, args): label = args.get('lootBoxType', None) shared_events.showLootBoxEntry(label) self.__flowLogger.logOpen( currentObject=NewYearNavigation.getCurrentObject()) self.destroyWindow() return
def onHighlightComponentAdded(self, highlightComponent): addedNavigationName = ANCHOR_TO_OBJECT.get( getattr(highlightComponent.owner, 'anchorName', None)) if addedNavigationName and addedNavigationName == NewYearNavigation.getCurrentObject( ): highlightComponent.owner.entityGameObject.createComponent( CurrentCameraObject) return
def externalSwitchToGiftSystemView(*args, **kwargs): ctx = { 'anchorName': NewYearNavigation.getCurrentObject() or CustomizationObjects.FIR, 'viewAlias': ViewAliases.GIFT_SYSTEM_VIEW } _externalSwitchToViewWithCtx(ctx, *args, **kwargs)
def externalSwitchToVehiclesView(*args, **kwargs): ctx = { 'anchorName': NewYearNavigation.getCurrentObject() or CustomizationObjects.FIR, 'viewAlias': ViewAliases.VEHICLES_VIEW } _externalSwitchToViewWithCtx(ctx, *args, **kwargs)
def __onUpdate(self, *_, **__): if self._getNavigationAlias() != NewYearNavigation.getCurrentViewName( ): return newObject = NewYearNavigation.getCurrentObject() if self.__currentObject == newObject: return self.__currentObject = newObject with self.viewModel.transaction() as model: self.__updateSlots(fullUpdate=True, model=model) self.__clearPopovers() g_eventBus.handleEvent(events.NewYearEvent( events.NewYearEvent.SELECT_SIDEBAR_TAB_OUTSIDE, ctx={ 'menuName': NyWidgetTopMenu.GLADE, 'tabName': newObject }), scope=EVENT_BUS_SCOPE.LOBBY)
def __onSwitchEvent(event): ctx = event.ctx anchorName = ctx.get('anchorName') aliasName = ctx.get('viewAlias') anchordAsObject = ctx.get('anchordAsObject', False) if anchorName: if anchordAsObject: instantly = ctx.get('instantly', False) args = ctx.get('args') kwargs = ctx.get('kwargs') NewYearNavigation.showMainView(anchorName, viewAlias=aliasName, instantly=instantly, withFade=True, *args, **kwargs) else: NewYearNavigation.switchByAnchorName(anchorName, aliasName)
def __onObjectStateChanged(self): currentObject = NewYearNavigation.getCurrentObject() self._lobbyMode = currentObject is None with self.viewModel.transaction() as model: self.__updateData(model) self.__updateLevel(model) self.__updateActiveState(model) self.__soundRTPCController.setCurrentLocation(currentObject) return
def __checkPresenters(self): if self.isGiftEventEnabled(): return else: subModelInfo = self.__contentPresentersMap[self.__ctx.menuName] if subModelInfo.canBeLoaded is not None and not subModelInfo.canBeLoaded( ): NewYearNavigation.switchToView(ViewAliases.GLADE_VIEW) if subModelInfo.ID == MainViews.INFO: subModelInfo.presenter.clearNavigationHistory() self.__backCallback = partial(NewYearNavigation.switchToView, ViewAliases.GLADE_VIEW) with self.viewModel.transaction() as tx: tx.backButton.setIsVisible(True) tx.backButton.setCaption( backport.text(R.strings.ny.backButton.label())) tx.backButton.setGoTo( backport.text(R.strings.ny.backButton.NyGladeView())) return
def _finalize(self): if dependency.instance(IHangarSpace).spaceInited: BigWorld.worldDrawEnabled(True) self.__flowLogger.logFinalize(self.__ctx.menuName, self.currentPresenter.currentTab) self.viewModel.onClose -= self.__onCloseClick self.viewModel.onFadeInDone -= self.__onFadeInDone self.viewModel.backButton.onBack -= self.__onBackClicked self.__nyController.onStateChanged -= self.__onStateChanged self.__settingsCore.onSettingsChanged -= self.__onSettingsChanged self.__hangarSpace.setVehicleSelectable(False) g_eventBus.removeListener(CameraRelatedEvents.CAMERA_ENTITY_UPDATED, self.__handleSelectedEntityUpdated, scope=EVENT_BUS_SCOPE.DEFAULT) g_eventBus.removeListener(events.NewYearEvent.ON_PRE_SWITCH_VIEW, self.__onPreSwitchViewEvent, scope=EVENT_BUS_SCOPE.LOBBY) g_eventBus.removeListener(events.NewYearEvent.UPDATE_BACK_BUTTON, self.__onBackButtonUpdated, scope=EVENT_BUS_SCOPE.LOBBY) self.releaseGiftEventHub() g_eventBus.handleEvent( events.LobbyHeaderMenuEvent( events.LobbyHeaderMenuEvent.TOGGLE_VISIBILITY, ctx={'state': HeaderMenuVisibilityState.ALL}), EVENT_BUS_SCOPE.LOBBY) for presenter in self.__componentPresenters: presenter.finalize() presenter.clear() self.__componentPresenters = [] self.currentPresenter.finalize() self.currentPresenter.clearTabCache() self.currentPresenter.clearNavigationHistory() if self.__regionName: uniprof.exitFromRegion(self.__regionName) for subModelInfo in self.__contentPresentersMap.itervalues(): subModelInfo.presenter.clear() self.__contentPresentersMap.clear() NewYearNavigation.clear() self.__backCallback = None return
def _goBack(self): if not self._navigationHistory.isEmpty: backPageAlias = self._navigationHistory.getLast() if backPageAlias: self.__flowLogger.logBackClick( view=VIEW_ALIAS_TO_MENU_NAME.get(backPageAlias), albumTab=self._tabCache.getCurrentYear(), rewardTab=self._tabCache.getRewardsTab(), selectedObject=NewYearNavigation.getCurrentObject()) super(NyInfoView, self)._goBack()
def __onSelectedDecoration(self): if not self.viewModel.getHasDecoration(): self.__craftCtrl.setSettings(isMegaOn=True) self.__flowLogger.logBigDecorationSlotClick( NewYearNavigation.getCurrentObject()) NewYearNavigation.switchToView(ViewAliases.CRAFT_VIEW) self.destroyWindow() return else: toyID = INVALID_TOY_ID if self.viewModel.getSelected( ) else self.viewModel.slot.getToyID() toy = self.__itemsCache.items.festivity.getToys().get(toyID) if toy is not None: isPureToy = toy.getPureCount() > 0 points = toy.getAtmosphere(isPureToy, self.__isPureSlot) toyUsage = TOY_SLOT_USAGE.PURE if isPureToy else TOY_SLOT_USAGE.USED else: points = 0 toyUsage = TOY_SLOT_USAGE.USED result = yield self._nyController.hangToy(toyID, self.__slotID, toyUsage) if result.success and self.viewStatus == ViewStatus.LOADED: g_eventBus.handleEvent(events.NewYearEvent( events.NewYearEvent.ON_TOY_INSTALLED, ctx={ 'toyID': toyID, 'slotID': self.__slotID, 'atmoshereBonus': points }), scope=EVENT_BUS_SCOPE.LOBBY) self.__isSelected = toyID != INVALID_TOY_ID with self.viewModel.transaction() as tx: tx.setSelected(self.__isSelected) self.__updateTitle(tx) if self.__isSelected: if self.__slotType in ToyTypes.MEGA: NewYearSoundsManager.playEvent( NewYearSoundEvents.ADD_TOY_MEGA) else: tx.slot.setIsNew(True) self.destroyWindow() return
def __onCameraEntityUpdated(self, event): ctx = event.ctx state = ctx['state'] entityId = ctx['entityId'] enabled = None if NewYearNavigation.getCurrentObject() is not None: enabled = True elif state == CameraMovementStates.FROM_OBJECT: enabled = not self.__isHangarVehicleEntity(entityId) elif state == CameraMovementStates.ON_OBJECT: enabled = self.__isHangarVehicleEntity(entityId) if enabled is not None and enabled != self.enabled: self.setEnable(enabled) return
def initialize(self, *args, **kwargs): super(NyGladeView, self).initialize(*args, **kwargs) self.__selectableLogic.init() self.__currentObject = NewYearNavigation.getCurrentObject() self._itemsCache.onSyncCompleted += self.__onSyncCompleted self.__settingsCore.onSettingsChanged += self.__onSettingsChanged g_eventBus.addListener(events.NewYearEvent.ON_SIDEBAR_SELECTED, self.__onSideBarSelected, scope=EVENT_BUS_SCOPE.LOBBY) g_eventBus.addListener(events.NewYearEvent.ON_TOY_INSTALLED, self.__onToyInstalled, scope=EVENT_BUS_SCOPE.LOBBY) with self.viewModel.transaction() as model: self.__updateSlots(fullUpdate=True, model=model) self.__updateIntro(force=kwargs.get('forceShowIntro', False), model=model) self.__updateLootboxEntryPoint() model.intro.region.setRealm(CURRENT_REALM) model.intro.region.setLanguage(getLanguageCode()) model.atmosphereAnimation.setIsReady(False)
def _initialize(self): super(NyMainWidget, self)._initialize() self.viewModel.onClick += self.__onWidgetClick self._nyController.onDataUpdated += self.__onDataUpdated g_eventBus.addListener(NewYearEvent.ON_SWITCH_VIEW, self.__onSwitchView, EVENT_BUS_SCOPE.LOBBY) NewYearNavigation.onObjectStateChanged += self.__onObjectStateChanged currentObject = NewYearNavigation.getCurrentObject() self._lobbyMode = currentObject is None self.__soundRTPCController = SoundRTPCController() self.__soundRTPCController.init(currentObject) self.__soundRTPCController.setLevelAtmosphere( self._itemsCache.items.festivity.getMaxLevel()) with self.viewModel.transaction() as model: self.__updateData(model) self.__updateLevel(model) self.__updateActiveState(model) model.setIsExtendedAnim(not isMemoryRiskySystem()) ClientSelectableCameraObject.switchCamera() self.viewModel.setIsInited(True) return
def onSelect(self): if NewYearNavigation.getCurrentObject() is not None: NewYearNavigation.closeMainView(False, False) else: super(HangarVehicle, self).onSelect() return
def logClick(self, anchorName): currentObject = NewYearNavigation.getCurrentObject() self.__selectableObjectLogger.logClick(anchorName, currentObject) self.__flowUILogger.logClick(anchorName, currentObject)
def onMouseClick(self): super(NewYearCelebrityEntryObject, self).onMouseClick() NewYearSoundsManager.playEvent(NewYearSoundEvents.ENTER_CUSTOME) self.logClick(AnchorNames.CELEBRITY) NewYearNavigation.switchByAnchorName(AnchorNames.CELEBRITY)
def __onClose(self): NewYearNavigation.closeMainView()