def _packSingleBonus(cls, bonus): model = RewardItemModel() cls._packCommon(bonus, model) chapter = bonus.getChapter() level = bonus.getLevel() customizationItem = getStyleForChapter(chapter) model.setIcon(cls._ICON_NAME_TEMPLATE.format(level)) model.setOverlayType(ItemHighlightTypes.PROGRESSION_STYLE_UPGRADED + str(level)) if customizationItem is not None: if level == cls._STYLE_FIRST_LEVEL: userName = backport.text(cls._rStyleProgression.newStyle(), styleName=customizationItem.userName) elif level == cls._STYLE_MAX_LEVEL: userName = backport.text(cls._rStyleProgression.finalLevel(), styleName=customizationItem.userName) else: userName = backport.text(cls._rStyleProgression.newLevel(), styleName=customizationItem.userName) model.setUserName(userName) postfix = str(customizationItem.id) model.setBigIcon('_'.join( [cls._ICON_NAME_TEMPLATE.format(level), postfix])) else: postfix = 'undefined' cls._injectAwardID(model, postfix) return model
def getText(cls, item): from gui.battle_pass.battle_pass_helpers import getStyleForChapter chapter = item.getChapter() level = item.getLevel() style = getStyleForChapter(chapter) text = backport.text(R.strings.battle_pass.styleProgressBonus(), styleName=style.userName, level=level) return text
def _onEntered(self): machine = self.getMachine() if machine is None: return else: chapterID = machine.getChosenStyleChapter() _, level = getStyleInfoForChapter(chapterID) style = getStyleForChapter(chapterID) if style is not None and style.getProgressionLevel( ) == style.getMaxProgressionLevel(): machine.post(StateEvent()) return prevLevel, _ = self.__battlePass.getChapterLevelInterval(chapterID) data = { 'reason': BattlePassRewardReason.STYLE_UPGRADE, 'chapter': chapterID, 'prevLevel': prevLevel, 'callback': partial(machine.post, StateEvent()) } styleToken = get3DStyleProgressToken( self.__battlePass.getSeasonID(), chapterID, level) rewards = packToken(styleToken) machine.clearChapterStyle() showBattlePassAwardsWindow([rewards], data) return
def _onLoading(self, *args, **kwargs): super(ExtraIntroView, self)._onLoading(*args, **kwargs) style = getStyleForChapter(self.__chapterID) vehicleCD = getVehicleCDForStyle(style) vehicle = getVehicleByIntCD(vehicleCD) with self.viewModel.transaction() as tx: tx.setStyleName(style.userName) fillVehicleInfo(tx.vehicleInfo, vehicle)
def __onPreviewClick(self): styleInfo = getStyleForChapter(self.__chosenChapter, itemsCache=self.__itemsCache) vehicleCD = getVehicleCDForStyle(styleInfo, itemsCache=self.__itemsCache) showProgressionStylesStylePreview( vehicleCD, styleInfo, styleInfo.getDescription(), showMissionsBattlePassCommonProgression)
def __getTooltip(self, bonus): chapter = bonus.getChapter() style = getStyleForChapter(chapter) tooltip = '' if style is None: body = backport.text( R.strings.battle_pass.styleProgressBonus.notChosen.tooltip()) tooltip = makeTooltip(body=body) return tooltip
def __setStyleWidget(self, model): style = getStyleForChapter(self.__chapterID) model.widget3dStyle.setStyleName(style.userName if style else '') model.widget3dStyle.setStyleId(style.id if style else 0) if style is not None: vehicleCD = getVehicleCDForStyle(style, itemsCache=self.__itemsCache) vehicle = getVehicleByIntCD(vehicleCD) fillVehicleInfo(model.widget3dStyle.vehicleInfo, vehicle) return
def __showPreview(self, args): chapterID = args.get('chapterID') if chapterID is None: return else: hideVehiclePreview(back=False) style = getStyleForChapter(chapterID, battlePass=self.__battlePass) vehicleCD = getVehicleCDForStyle(style, itemsCache=self.__itemsCache) if self.__battlePass.isExtraChapter(chapterID): self.__showStylePreview(style, vehicleCD) else: self.__showProgressionStylePreview(style, vehicleCD) self.destroyWindow() return
def __onExtraPreviewClick(self): styleInfo = getStyleForChapter(self.__chapterID, battlePass=self.__battlePass) vehicleCD = getVehicleCDForStyle(styleInfo, itemsCache=self.__itemsCache) itemsPack = (ItemPackEntry(type=ItemPackType.CREW_100, groupID=1), ) showStylePreview(vehicleCD, style=styleInfo, topPanelData={ 'linkage': VEHPREVIEW_CONSTANTS.TOP_PANEL_TABS_LINKAGE, 'tabIDs': (TabID.VEHICLE, TabID.STYLE), 'currentTabID': TabID.STYLE }, itemsPack=itemsPack, backCallback=self.__getPreviewCallback())
def __onPreviewClick(self, args): level = args.get('level') if level is None: return else: styleInfo = getStyleForChapter(self.__chapterID, battlePass=self.__battlePass) vehicleCD = getVehicleCDForStyle(styleInfo, itemsCache=self.__itemsCache) showBattlePassStyleProgressionPreview(vehicleCD, styleInfo, styleInfo.getDescription(), self.__getPreviewCallback(), chapterId=self.__chapterID, styleLevel=int(level)) return
def __updateChapters(self, chapters): chapters.clear() for chapterID in sorted(self.__battlePass.getChapterIDs(), cmp=chaptersIDsComparator): model = ChapterModel() if self.__battlePass.getRewardType(chapterID) == FinalReward.STYLE: style = getStyleForChapter(chapterID) model.setStyleName(style.userName) self.__fillVehicle(style, model) model.setChapterID(chapterID) model.setFinalReward( self.__battlePass.getRewardType(chapterID).value) model.setIsBought(self.__battlePass.isBought(chapterID=chapterID)) model.setIsExtra(self.__battlePass.isExtraChapter(chapterID)) self.__fillProgression(chapterID, model) chapters.addViewModel(model) chapters.invalidate()
def __setStyleTaken(self, model): style = getStyleForChapter(self.__chapterID) vehicleCD = getVehicleCDForStyle(style, itemsCache=self.__itemsCache) vehicle = self.__itemsCache.items.getItemByCD(vehicleCD) model.setIsStyleTaken(style.isInInventory or bool(style.installedCount(vehicle.intCD)))