def __getCurrentMaxProgress(self, playerLevel, playerFamePts): items = [] famePtsToProgress = self.getPointsProgressForLevel(playerLevel) currentPoint = text_styles.stats(str(playerFamePts)) fameTo = text_styles.main(str(famePtsToProgress)) currentPointMaxPoint = text_styles.concatStylesWithSpace( currentPoint, text_styles.main('/'), fameTo) text = text_styles.main(currentPointMaxPoint) marginTop = 7 icon = None if self.isFrontLine: marginTop = 0 iconSrc = backport.image( R.images.gui.maps.icons.epicBattles.fame_point_tiny()) icon = icons.makeImageTag(source=iconSrc, width=24, height=24) elif self.isSteelHunter: marginTop = 6 iconSrc = backport.image( R.images.gui.maps.icons.battleRoyale.progression_point()) icon = icons.makeImageTag(source=iconSrc, width=16, height=16) if icon is not None: text = text_styles.concatStylesWithSpace(text, icon) items.append( formatters.packAlignedTextBlockData( text=text, align=BLOCKS_TOOLTIP_TYPES.ALIGN_RIGHT, padding=formatters.packPadding(left=20, right=20, top=-35))) return formatters.packBuildUpBlockData( items, padding=formatters.packPadding(top=marginTop))
def _getMissionsBlock(cls, operation): items = [] completedQuests = operation.getCompletedQuests() completedQuestsIDs = set(completedQuests.keys()) totalCount = operation.getQuestsCount() items.append( formatters.packTextBlockData( text=text_styles.concatStylesWithSpace( text_styles.middleTitle( TOOLTIPS.PERSONALMISSIONS_OPERATION_MISSIONS_TITLE), _formatCompleteCount(len(completedQuests), totalCount), text_styles.standard('/ %s' % totalCount)), padding=formatters.packPadding(top=8, left=17))) for classifierAttr in operation.getIterationChain(): chainID, quests = operation.getChainByClassifierAttr( classifierAttr) completedCount = len(completedQuestsIDs.intersection( quests.keys())) chainSize = operation.getChainSize() items.append( formatters.packTitleDescParameterWithIconBlockData( title=text_styles.concatStylesWithSpace( _formatCompleteCount(completedCount, chainSize), text_styles.standard('/ %s' % chainSize)), value=text_styles.main(operation.getChainName(chainID)), icon=operation.getSmallChainIcon(chainID), iconPadding=formatters.packPadding(top=3, left=10), titlePadding=formatters.packPadding(left=10), padding=formatters.packPadding(left=156, bottom=-9))) return formatters.packBuildUpBlockData(blocks=items, padding=formatters.packPadding( top=-14, bottom=30), gap=10)
def __getConfirmator(self, withoutBenefits, period, price): if withoutBenefits: return plugins.HtmlMessageConfirmator( 'buyPremWithoutBenefitsConfirmation', 'html_templates:lobby/dialogs', 'confirmBuyPremWithoutBenefeits', { 'days': text_styles.stats(period), Currency.GOLD: text_styles.concatStylesWithSpace( text_styles.gold(BigWorld.wg_getGoldFormat(price)), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)) }) localKey = 'premiumContinueConfirmation' if self.wasPremium else 'premiumBuyConfirmation' return plugins.MessageConfirmator( localKey, ctx={ 'days': text_styles.stats(period), Currency.GOLD: text_styles.concatStylesWithSpace( text_styles.gold(BigWorld.wg_getGoldFormat(price)), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)) })
def _getUnavailableStatusFields(self, errorMsg): """ Gets status fields data for unavailable mission state. Data used in mission card to display its unavailable state. """ if errorMsg == 'requirements': isVehAvailable = self.event.vehicleReqs.isAnyVehicleAcceptable( ) or len(self.event.vehicleReqs.getSuitableVehicles()) > 0 if not isVehAvailable: statusText = _ms(QUESTS.MISSIONDETAILS_STATUS_WRONGVEHICLE) else: statusText = _ms(QUESTS.MISSIONDETAILS_STATUS_NOTAVAILABLE) notAvailableIcon = icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_MARKER_BLOCKED, 14, 14, -2, 10) statusMsg = text_styles.concatStylesWithSpace( notAvailableIcon, text_styles.error(statusText)) tooltipData = getDisabledRequirementTooltip(self.event) else: clockIcon = icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_TIMERICON, 16, 16, -2, 8) statusMsg = text_styles.concatStylesWithSpace( clockIcon, text_styles.error(QUESTS.MISSIONDETAILS_STATUS_NOTAVAILABLE)) if errorMsg in ('invalid_weekday', 'invalid_time_interval'): tooltipData = getInvalidTimeIntervalsTooltip(self.event) else: tooltipData = self._getMissionDurationTooltipData() return { 'statusLabel': statusMsg, 'status': EVENT_STATUS.NOT_AVAILABLE, 'statusTooltipData': tooltipData }
def _packBlocks(self, *args, **kwargs): self.__isReceived = bool(args[1]) items = super(NyDecorationWithStatusTooltipData, self)._packBlocks(*args, **kwargs) if self.__isReceived: statusText = text_styles.concatStylesWithSpace( icons.makeImageTag(RES_ICONS.MAPS_ICONS_NY_ICONS_CHECK, width=24, height=24, vSpace=-6, hSpace=-2), text_styles.statInfo( NY.COLLECTIONS_TOOLTIP_DECORATION_OBTAINED)) statusPadding = formatters.packPadding(left=4, top=-12, bottom=-14) else: statusText = text_styles.concatStylesWithSpace( text_styles.critical( NY.COLLECTIONS_TOOLTIP_DECORATION_NOTOBTAINED)) statusPadding = formatters.packPadding(left=16, top=-8, bottom=-10) bottomBuildUpBlock = [ formatters.packAlignedTextBlockData( text=statusText, align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER, padding=statusPadding) ] items.append(formatters.packBuildUpBlockData(bottomBuildUpBlock)) return items
def _getMissionsBlock(cls, operation): items = [] completedQuests = operation.getCompletedQuests() completedQuestsIDs = set(completedQuests.keys()) totalCount = operation.getQuestsCount() items.append( formatters.packTextBlockData( text=text_styles.concatStylesWithSpace( text_styles.middleTitle( TOOLTIPS.PERSONALMISSIONS_OPERATION_MISSIONS_TITLE), _formatCompleteCount(len(completedQuests), totalCount), text_styles.standard('/ %s' % totalCount)), padding=formatters.packPadding(top=8, left=17))) for vehicleType in VEHICLE_TYPES_ORDER: _, quests = operation.getChainByVehicleType(vehicleType) completedCount = len(completedQuestsIDs.intersection( quests.keys())) chainSize = operation.getChainSize() items.append( formatters.packTitleDescParameterWithIconBlockData( title=text_styles.concatStylesWithSpace( _formatCompleteCount(completedCount, chainSize), text_styles.standard('/ %s' % chainSize)), value=text_styles.main(MENU.classesShort(vehicleType)), icon=getTypeSmallIconPath(vehicleType), iconPadding=formatters.packPadding(top=3, left=10), titlePadding=formatters.packPadding(left=10), padding=formatters.packPadding(left=156, bottom=-9))) return formatters.packBuildUpBlockData(blocks=items, padding=formatters.packPadding( top=-14, bottom=30), gap=10)
def __packTitle(self): name = text_styles.highTitle( _ms(TOOLTIPS.BATTLETYPES_RANKED_RANK_NAME, rank=self.item.getUserName())) shieldMaxHp = 0 if self.__shieldStatus is not None: _, _, shieldMaxHp, _, _ = self.__shieldStatus if shieldMaxHp > 0: comment = text_styles.standard( _ms(TOOLTIPS.BATTLETYPES_RANKED_HAVESHIELD, hp=text_styles.stats(shieldMaxHp))) elif self.item.canBeLost(): comment = text_styles.concatStylesWithSpace( icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICON, vSpace=-3), text_styles.neutral( TOOLTIPS.BATTLETYPES_RANKED_RANK_CANBELOST)) else: comment = text_styles.concatStylesWithSpace( icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_CYBERSPORT_LOCKICON, width=9, height=13, vSpace=-2), text_styles.main(TOOLTIPS.BATTLETYPES_RANKED_RANK_CANTBELOST)) return formatters.packTextBlockData( text_styles.concatStylesToMultiLine(name, comment))
def _getRegularStatusFields(self, isLimited, bonusCount, bonusLimit): scheduleOrResetLabel = '' scheduleTooltip = None if isLimited: isDaily = self.event.bonusCond.isDaily() statusLabel = text_styles.concatStylesWithSpace( icons.inProgress(), text_styles.standard( _ms(_getDailyLimitedStatusKey(isDaily), count=text_styles.stats(bonusCount), total=text_styles.standard(bonusLimit)))) statusTooltipData = getBonusLimitTooltip(bonusCount, bonusLimit, isDaily) else: statusTooltipData = getCompletetBonusLimitValueTooltip( self.event.getBonusCount()) statusLabel = text_styles.concatStylesWithSpace( icons.inProgress(), text_styles.standard( _ms(QUESTS.MISSIONDETAILS_MISSIONSCOMPLETECOUNTER, count=text_styles.stats(self.event.getBonusCount())))) if self.event.getWeekDays() or self.event.getActiveTimeIntervals(): scheduleOrResetLabel = getScheduleLabel() scheduleTooltip = getInvalidTimeIntervalsTooltip(self.event) elif self.event.bonusCond.isDaily(): scheduleOrResetLabel = self._getDailyResetStatusLabel() return { 'statusLabel': statusLabel, 'status': MISSIONS_STATES.NONE, 'statusTooltipData': statusTooltipData, 'dateLabel': self._getActiveTimeDateLabel(), 'scheduleOrResetLabel': scheduleOrResetLabel, 'scheduleTooltip': scheduleTooltip }
def __formatDescription(self, quests): season = self._eventProgression.getCurrentSeason( ) or self._eventProgression.getNextSeason() currentTime = time_utils.getCurrentLocalServerTimestamp() cycle = season.getCycleInfo() if not self._eventProgression.modeIsAvailable() or cycle is None: return '' elif self._eventProgression.isNeedAchieveMaxLevelForDailyQuest(): maxLevel = self._eventProgression.getMaxPlayerLevel() description = backport.text(_R_EPIC_BATTLE.unavailable(), reason=backport.text( _R_EPIC_BATTLE.restrict.level(), level=maxLevel)) return text_styles.concatStylesWithSpace( icons.markerBlocked(), text_styles.error(description)) elif cycle.endDate - currentTime < time_utils.ONE_DAY: icon = icons.inProgress(vspace=-3) messageID = _R_EPIC_BATTLE.timeLeft valueStyle = text_styles.stats timeStr = valueStyle( backport.text(R.strings.epic_battle.questsTooltip.epicBattle. lessThanDay())) textStyle = text_styles.main description = textStyle( backport.text(messageID(), cycle=int2roman(cycle.ordinalNumber), time=timeStr)) return text_styles.concatStylesWithSpace(icon, description) elif all( (q.isCompleted() for q in quests )) and self._eventProgression.isDailyQuestsRefreshAvailable(): data = time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay( ) valueStyle = text_styles.tutorial timeToStr = valueStyle( getTimeStr(data, R.strings.menu.Time.timeLeftShort)) icon = icons.clockGold() textStyle = text_styles.tutorial description = textStyle( backport.text(_R_EPIC_BATTLE.startIn(), time=timeToStr)) return text_styles.concatStylesWithSpace(icon, description) else: getDate = lambda c: c.endDate messageID = _R_EPIC_BATTLE.timeLeft icon = icons.inProgress(vspace=-3) textStyle = text_styles.main valueStyle = text_styles.stats timeToStr = valueStyle( getTimeStr( getDate(cycle) - currentTime, R.strings.menu.Time.timeLeftShort)) description = textStyle( backport.text(messageID(), cycle=int2roman(cycle.ordinalNumber), time=timeToStr)) return text_styles.concatStylesWithSpace(icon, description)
def __getCurrentMaxProgressBlock(playerFamePts, famePtsToProgress): items = [] currentPoint = text_styles.stats(str(playerFamePts)) fameTo = text_styles.main(str(famePtsToProgress)) currentPointMaxPoint = text_styles.concatStylesWithSpace(currentPoint, text_styles.main('/'), fameTo) marginTop = 0 iconSrc = backport.image(R.images.gui.maps.icons.epicBattles.fame_point_tiny()) text = text_styles.concatStylesWithSpace(text_styles.main(currentPointMaxPoint), icons.makeImageTag(source=iconSrc, width=24, height=24)) items.append(formatters.packAlignedTextBlockData(text=text, align=BLOCKS_TOOLTIP_TYPES.ALIGN_RIGHT, padding=formatters.packPadding(left=20, right=20, top=-35))) return formatters.packBuildUpBlockData(items, padding=formatters.packPadding(top=marginTop, right=20))
def _packWayToBuyBlock(self, item): subBlocks = [ formatters.packTextBlockData( text=text_styles.middleTitle(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_WAYTOBUY_TITLE)), padding={"bottom": 6}, ) ] padding = {"left": 0} for buyItem in item["buyItems"]: buyItemDesc = text_styles.main(buyItem["desc"]) if buyItem["type"] == BUY_ITEM_TYPE.WAYS_TO_BUY_FOREVER: if buyItem["isSale"]: subBlocks.append( formatters.packSaleTextParameterBlockData( name=buyItemDesc, saleData={"newPrice": (0, buyItem["value"])}, padding=padding ) ) else: price = text_styles.concatStylesWithSpace( text_styles.gold(BigWorld.wg_getIntegralFormat(long(buyItem["value"]))), icons.gold() ) subBlocks.append( formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70) ) elif buyItem["type"] == BUY_ITEM_TYPE.WAYS_TO_BUY_TEMP: if buyItem["isSale"]: subBlocks.append( formatters.packSaleTextParameterBlockData( name=buyItemDesc, saleData={"newPrice": (buyItem["value"], 0)}, padding=padding ) ) else: price = text_styles.concatStylesWithSpace( text_styles.credits(BigWorld.wg_getIntegralFormat(long(buyItem["value"]))), icons.credits() ) subBlocks.append( formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70) ) elif buyItem["type"] == BUY_ITEM_TYPE.WAYS_TO_BUY_IGR: subBlocks.append( formatters.packTextParameterBlockData( name=buyItemDesc, value=icons.premiumIgrSmall(), padding=padding ) ) elif buyItem["type"] == BUY_ITEM_TYPE.WAYS_TO_BUY_MISSION: subBlocks.append( formatters.packTextParameterBlockData(name=buyItemDesc, value=icons.quest(), padding=padding) ) return formatters.packBuildUpBlockData( subBlocks, 0, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_LINKAGE, {"left": 3} )
def _getCompleteStatusFields(self, isLimited, bonusCount, bonusLimit): """ Gets status fields data for completed mission state. Data used in detailed mission view to display its completed state. For completed daily quests return unavailable state fields. """ statusTooltipData = None dateLabel = self._getActiveTimeDateLabel() resetDateLabel = '' status = EVENT_STATUS.COMPLETED if isLimited and bonusLimit > 1: statusLabel = text_styles.bonusAppliedText( _ms(QUESTS.MISSIONDETAILS_MISSIONSCOMPLETE, count=text_styles.bonusAppliedText(bonusCount), total=text_styles.standard(bonusLimit))) statusTooltipData = getCompletetBonusLimitTooltip() else: progressDesc = text_styles.success(_ms(QUESTS.QUESTS_STATUS_DONE)) icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_OKICON, 16, 16, -2, 8) statusLabel = text_styles.concatStylesToSingleLine( icon, progressDesc) if self.event.bonusCond.isDaily(): status = EVENT_STATUS.NOT_AVAILABLE dateLabel = text_styles.concatStylesWithSpace( icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_TIMERICON, 16, 16, -2, 8), text_styles.error(QUESTS.MISSIONDETAILS_STATUS_NOTAVAILABLE), self._getCompleteDailyStatus( QUESTS.MISSIONDETAILS_STATUS_COMPLETED_DAILY)) resetDateLabel = self._getDailyResetStatusLabel() return { 'statusLabel': statusLabel, 'dateLabel': dateLabel, 'status': status, 'bottomStatusText': text_styles.concatStylesWithSpace( icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_DONE, 32, 32, -8), text_styles.missionStatusAvailable( QUESTS.MISSIONDETAILS_BOTTOMSTATUSCOMPLETE)), 'statusTooltipData': statusTooltipData, 'resetDateLabel': resetDateLabel }
def _makePriceBlock(self, price, currencySetting, neededValue = None, oldPrice = None, percent = 0): needFormatted = '' oldPriceText = '' hasAction = percent != 0 settings = getCurrencySetting(currencySetting) if settings is None: return else: valueFormatted = settings.textStyle(_int(price)) icon = settings.icon if neededValue is not None: needFormatted = settings.textStyle(_int(neededValue)) if hasAction: oldPriceText = text_styles.concatStylesToSingleLine(icon, settings.textStyle(_int(oldPrice))) neededText = '' if neededValue is not None: neededText = text_styles.concatStylesToSingleLine(text_styles.main('('), text_styles.error(TOOLTIPS.VEHICLE_GRAPH_BODY_NOTENOUGH), ' ', needFormatted, ' ', icon, text_styles.main(')')) text = text_styles.concatStylesWithSpace(text_styles.main(settings.text), neededText) if hasAction: actionText = text_styles.main(_ms(TOOLTIPS.VEHICLE_ACTION_PRC, actionPrc=text_styles.stats(str(percent) + '%'), oldPrice=oldPriceText)) text = text_styles.concatStylesToMultiLine(text, actionText) if settings.frame == ICON_TEXT_FRAMES.GOLD: newPrice = (0, price) else: newPrice = (price, 0) return formatters.packSaleTextParameterBlockData(name=text, saleData={'newPrice': newPrice, 'valuePadding': -8}, actionStyle='alignTop', padding=formatters.packPadding(left=92)) return formatters.packTextParameterWithIconBlockData(name=text, value=valueFormatted, icon=settings.frame, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)) return
def __packRewardsToChooseBlock(self, numRewards, style): iconSrc = backport.image(R.images.gui.maps.icons.epicBattles.rewards_to_choose()) icon = icons.makeImageTag(source=iconSrc, width=24, height=24, vSpace=-10) items = [] numRewardsText = text_styles.concatStylesWithSpace(icon, style(backport.text(R.strings.epic_battle.tooltips.chooseRewards.desc(), number=numRewards))) items.append(formatters.packTextBlockData(text=numRewardsText, padding=formatters.packPadding(left=20, right=20))) return formatters.packBuildUpBlockData(items)
def _makePriceBlock(self, price, text, currencyType, neededValue = None, oldPrice = None, percent = 0): needFormatted = '' oldPriceText = '' hasAction = percent != 0 if currencyType == ICON_TEXT_FRAMES.CREDITS: valueFormatted = text_styles.credits(_int(price)) icon = icons.credits() if neededValue is not None: needFormatted = text_styles.credits(_int(neededValue)) if hasAction: oldPriceText = text_styles.concatStylesToSingleLine(icons.credits(), text_styles.credits(_int(oldPrice))) elif currencyType == ICON_TEXT_FRAMES.GOLD: valueFormatted = text_styles.gold(_int(price)) icon = icons.gold() if neededValue is not None: needFormatted = text_styles.gold(_int(neededValue)) if hasAction: oldPriceText = text_styles.concatStylesToSingleLine(icons.gold(), text_styles.gold(_int(oldPrice))) elif currencyType == ICON_TEXT_FRAMES.XP: valueFormatted = text_styles.expText(_int(price)) icon = icons.xp() if neededValue is not None: needFormatted = text_styles.expText(_int(neededValue)) else: LOG_ERROR('Unsupported currency type "' + currencyType + '"!') return neededText = '' if neededValue is not None: neededText = text_styles.concatStylesToSingleLine(text_styles.main('( '), text_styles.error(TOOLTIPS.VEHICLE_GRAPH_BODY_NOTENOUGH), ' ', needFormatted, ' ', icon, text_styles.main(' )')) text = text_styles.concatStylesWithSpace(text_styles.main(text), neededText) if hasAction: actionText = text_styles.main(_ms(TOOLTIPS.VEHICLE_ACTION_PRC, actionPrc=text_styles.stats(str(percent) + '%'), oldPrice=oldPriceText)) text = text_styles.concatStylesToMultiLine(text, actionText) return formatters.packTextParameterWithIconBlockData(name=text, value=valueFormatted, icon=currencyType, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=20))
def _populate(self): super(UseAwardSheetWindow, self)._populate() self.as_setSettingsS({ 'title': self.meta.getTitle(), 'submitBtnLabel': self.meta.getSubmitButtonLabel(), 'cancelBtnLabel': self.meta.getCancelButtonLabel() }) icon = icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED, 16, 16, -3, 0) if self.meta.isAvailable() else icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_ALERTICON, 16, 16, -4, 0) text = text_styles.neutral(self.meta.getInfoText( )) if self.meta.isAvailable() else text_styles.alert( self.meta.getWarningText()) statusText = text_styles.concatStylesWithSpace(icon, text) self.as_setDataS({ 'neededLabel': text_styles.highlightText(self.meta.getNeededText()), 'neededValue': text_styles.highlightText(self.meta.getPawnCost()), 'totalLabel': text_styles.main(self.meta.getTotalText()), 'totalValue': text_styles.main(self.meta.getFreeSheets()), 'statusText': statusText, 'icon': self.meta.getIcon() })
def __getResearchPageBlueprintLabel(rootNode): bpfProps = rootNode.getBpfProps() label = '' if bpfProps is not None: if bpfProps.filledCount != bpfProps.totalCount: values = text_styles.main( backport.text(R.strings.blueprints.blueprintProgressBar. inProgress.values()).format( current=text_styles.credits( str(bpfProps.filledCount)), total=str(bpfProps.totalCount))) label = text_styles.credits( backport.text(R.strings.blueprints.blueprintProgressBar. inProgress()).format(values=values)) else: label = text_styles.concatStylesWithSpace( icons.makeImageTag(backport.image( R.images.gui.maps.icons.blueprints.blueCheck()), width=16, height=16, vSpace=-1), text_styles.credits( backport.text(R.strings.blueprints. blueprintProgressBar.complete()))) return label
def __packFragmentsInfoBlock(self): countBlock = formatters.packImageTextBlockData( title=text_styles.main( TOOLTIPS.BLUEPRINT_VEHICLEBLUEPRINTTOOLTIP_FRAGMENTSACQUIRED), desc=text_styles.concatStylesWithSpace( text_styles.bonusLocalText( str(self.__blueprintData.filledCount)), text_styles.main(' '.join( ('/', str(self.__blueprintData.totalCount))))), img=RES_ICONS.MAPS_ICONS_BLUEPRINTS_FRAGMENT_MEDIUM_VEHICLE, txtPadding=formatters.packPadding(left=11), txtGap=-6, padding=formatters.packPadding(top=4)) transitionBlock = formatters.packImageBlockData( img=RES_ICONS.MAPS_ICONS_BLUEPRINTS_TOOLTIP_POINTER, align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER, padding=formatters.packPadding(top=-3, left=24, right=24)) if self.__blueprintData.filledCount != self.__blueprintData.totalCount: discountBlock = self.__packDiscountBlock() else: discountBlock = self.__packFreeUnlockBlock() return formatters.packBuildUpBlockData( blocks=[countBlock, transitionBlock, discountBlock], linkage=BLOCKS_TOOLTIP_TYPES. TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, layout=BLOCKS_TOOLTIP_TYPES.LAYOUT_HORIZONTAL, padding=formatters.packPadding(bottom=-10), blockWidth=390)
def __getObtainedStatus(self, isAlliance): return text_styles.concatStylesWithSpace( icons.checkmark(-2), text_styles.statInfo( PERSONAL_MISSIONS.TANKMODULETOOLTIPDATA_STATUS_OBTAINED if not isAlliance else PERSONAL_MISSIONS. TANKMODULETOOLTIPDATA_STATUS_ALLIANCE_OBTAINED))
def __setTotalData(self, *_): cart = getTotalPurchaseInfo(self.__purchaseItems) totalPriceVO = getItemPricesVO(cart.totalPrice) state = g_currentVehicle.getViewState() inFormationAlert = '' if not state.isCustomizationEnabled(): inFormationAlert = text_styles.concatStylesWithSpace(icons.markerBlocked(), text_styles.error(VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_FORMATION_ALERT)) price = cart.totalPrice.price money = self.itemsCache.items.stats.money exchangeRate = self.itemsCache.items.shop.exchangeRate shortage = money.getShortage(price) if not shortage: self.__moneyState = _MoneyForPurchase.ENOUGH else: money = money - price + shortage price = shortage money = money.exchange(Currency.GOLD, Currency.CREDITS, exchangeRate, default=0) shortage = money.getShortage(price) if not shortage: self.__moneyState = _MoneyForPurchase.ENOUGH_WITH_EXCHANGE else: self.__moneyState = _MoneyForPurchase.NOT_ENOUGH validTransaction = self.__moneyState != _MoneyForPurchase.NOT_ENOUGH or Currency.GOLD in shortage.getCurrency() and isIngameShopEnabled() self.as_setTotalDataS({'totalLabel': text_styles.highTitle(_ms(VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_TOTALCOST, selected=cart.numSelected, total=cart.numApplying)), 'enoughMoney': validTransaction, 'inFormationAlert': inFormationAlert, 'totalPrice': totalPriceVO[0]}) self.__setBuyButtonState(validTransaction)
def __getMultiselectionInfoVO(self): allowedLevels = self.falloutCtrl.getConfig().allowedLevels showSlots, message = self.__getMultiselectionStatus() result = self.prbEntity.canPlayerDoAction() if result.isValid: statusString = text_styles.statInfo( '#fallout:multiselectionSlot/groupReady') else: statusString = text_styles.critical( '#fallout:multiselectionSlot/groupNotReady') return { 'formattedMessage': message, 'showSlots': showSlots, 'indicatorIsEnabled': result.isValid, 'vehicleTypes': text_styles.concatStylesWithSpace( text_styles.middleTitle( i18n.makeString( '#fallout:multiselectionSlot/selectionStatus')), text_styles.main( i18n.makeString( '#fallout:multiselectionSlot/selectionRequirements', level=toRomanRangeString(allowedLevels, step=1)))), 'statusSrt': statusString }
def _getStatusBlock(self, operation): _, postpone = missions_helper.getPostponedOperationState( operation.getID()) return formatters.packBuildUpBlockData([ formatters.packAlignedTextBlockData( text=text_styles.concatStylesWithSpace( icons.markerBlocked(-2), text_styles.error( TOOLTIPS. PERSONALMISSIONS_OPERATION_FOOTER_TITLE_NOTAVAILABLE)), align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER, padding=formatters.packPadding(top=-5)), formatters. packAlignedTextBlockData(text=text_styles.concatStylesToSingleLine( text_styles.main( TOOLTIPS.PERSONALMISSIONS_OPERATION_FOOTER_DESCR_POSTPONED ), icons.makeImageTag(RES_ICONS.getPersonalMissionOperationState( PERSONAL_MISSIONS_ALIASES.OPERATION_POSTPONED_STATE), width=24, height=24, vSpace=-9), text_styles.vehicleStatusCriticalText(postpone)), align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER, padding=formatters.packPadding(bottom=14)) ])
def __packBonusBlock(self): blocks = [] vehicle = cmp_helpers.getCmpConfiguratorMainView().getCurrentVehicle() camo = cmp_helpers.getSuitableCamouflage(vehicle) bonusTitleLocal = makeHtmlString( 'html_templates:lobby/textStyle', 'bonusLocalText', {'message': '+{}'.format(camo.bonus.getFormattedValue(vehicle))}) blocks.append( formatters.packImageTextBlockData( title=text_styles.concatStylesWithSpace(bonusTitleLocal), desc=text_styles.main(camo.bonus.description), img=camo.bonus.icon, imgPadding={ 'left': 11, 'top': 3 }, txtGap=-4, txtOffset=65, padding={ 'top': -1, 'left': 7 })) if not self._showTTC and vehicle is not None: stockVehicle = self.itemsCache.items.getStockVehicle(vehicle.intCD) comparator = params_helper.camouflageComparator(vehicle, camo) stockParams = params_helper.getParameters(stockVehicle) simplifiedBlocks = SimplifiedStatsBlockConstructor( stockParams, comparator).construct() if simplifiedBlocks: blocks.extend(simplifiedBlocks) return formatters.packBuildUpBlockData( blocks, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE )
def __packParameterBloc(self, name, value, measureUnits): return formatters.packTextParameterBlockData( name=text_styles.concatStylesWithSpace( text_styles.main(name), text_styles.standard(measureUnits)), value=text_styles.stats(value), valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5))
def _makeLockBlock(self): clanLockTime = self.vehicle.clanLock if clanLockTime and clanLockTime <= time_utils.getCurrentTimestamp(): LOG_DEBUG("clan lock time is less than current time: %s" % clanLockTime) clanLockTime = None isDisabledInRoaming = self.vehicle.isDisabledInRoaming if clanLockTime or isDisabledInRoaming: headerLock = text_styles.concatStylesToMultiLine(text_styles.warning(_ms(TOOLTIPS.TANKCARUSEL_LOCK_HEADER))) if isDisabledInRoaming: textLock = text_styles.main(_ms(TOOLTIPS.TANKCARUSEL_LOCK_ROAMING)) else: time = time_utils.getDateTimeFormat(clanLockTime) timeStr = text_styles.main(text_styles.concatStylesWithSpace(_ms(TOOLTIPS.TANKCARUSEL_LOCK_TO), time)) textLock = text_styles.concatStylesToMultiLine( timeStr, text_styles.main(_ms(TOOLTIPS.TANKCARUSEL_LOCK_CLAN)) ) lockHeaderBlock = formatters.packTextBlockData( headerLock, padding=formatters.packPadding(left=77 + self.leftPadding, top=5) ) lockTextBlock = formatters.packTextBlockData( textLock, padding=formatters.packPadding(left=77 + self.leftPadding) ) return formatters.packBuildUpBlockData( [lockHeaderBlock, lockTextBlock], stretchBg=False, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_LOCK_BG_LINKAGE, padding=formatters.packPadding(left=-17, top=20, bottom=0), ) else: return return
def __init__(self, tankman, firstNameID, firstNameGroup, lastNameID, lastNameGroup, iconID, iconGroup): hasUniqueData = self.__hasUniqueData(tankman, firstNameID, lastNameID, iconID) isFemale = tankman.descriptor.isFemale if isFemale: price = self.itemsCache.items.shop.passportFemaleChangeCost else: price = self.itemsCache.items.shop.passportChangeCost super(TankmanChangePassport, self).__init__( tankman, (plugins.TankmanChangePassportValidator(tankman), plugins.MessageConfirmator( 'replacePassport/unique' if hasUniqueData else 'replacePassportConfirmation', ctx={ Currency.GOLD: text_styles.concatStylesWithSpace( text_styles.gold(BigWorld.wg_getGoldFormat(price)), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)) }))) self.firstNameID = firstNameID self.firstNameGroup = firstNameGroup self.lastNameID = lastNameID self.lastNameGroup = lastNameGroup self.iconID = iconID self.iconGroup = iconGroup self.isFemale = isFemale self.isPremium = tankman.descriptor.isPremium self.price = price
def _getUnavailableStatusFields(self, errorMsg): """ Gets status fields data for unavailable mission state. Data used in detailed mission view to display its unavailable state. """ scheduleLabel = '' dateLabel = '' scheduleTooltip = None if errorMsg != 'requirement': clockIcon = icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_TIMERICON, 16, 16, -2, 8) timeLeft = self.event.getNearestActivityTimeLeft() if timeLeft is not None: startTimeLeft = timeLeft[0] timeStatusText = text_styles.standard( _ms('#quests:missionDetails/status/notAvailable/%s' % errorMsg, time=self._getTillTimeString(startTimeLeft))) dateLabel = text_styles.concatStylesWithSpace( clockIcon, text_styles.error(QUESTS.MISSIONDETAILS_STATUS_WRONGTIME), timeStatusText) if errorMsg in ('invalid_weekday', 'invalid_time_interval'): scheduleLabel = getScheduleLabel() scheduleTooltip = getInvalidTimeIntervalsTooltip(self.event) return { 'status': EVENT_STATUS.NOT_AVAILABLE, 'dateLabel': dateLabel, 'scheduleOrResetLabel': scheduleLabel, 'scheduleTooltip': scheduleTooltip }
def conclusion(self, group, event, requirements, passed, total): """ Format the requirement header. """ if group.isAvailable(): icon = '' style = text_styles.standard header = '#quests:missionDetails/requirements/header/available' else: icon = (icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_MARKER_BLOCKED, width=14, height=14, vSpace=-1, hSpace=-2), ) style = text_styles.error header = '#quests:missionDetails/requirements/header/unavailable' result = [] for condition in group.getSortedItems(): fmt = self.getConditionFormatter(condition.getName()) if fmt: branch = fmt.format(condition, event, self._styler) result.extend(branch) result = (branch.get('text') for branch in result) reason = text_styles.concatStylesToMultiLine(*result) return text_styles.concatStylesWithSpace(icon, style(header), reason)
def conclusion(self, group, event, requirements, passed, total): """ Format the requirement header. """ if not total: return '' if group.isAvailable(): icon = '' headerStyle = text_styles.standard reasonStyle = text_styles.standard header = '#quests:missionDetails/requirements/header/available' reason = '#quests:missionDetails/requirements/conclusion/available' count = total else: icon = (icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_MARKER_BLOCKED, width=14, height=14, vSpace=-1, hSpace=-2), ) headerStyle = text_styles.error reasonStyle = text_styles.main header = '#quests:missionDetails/requirements/header/unavailable' if len(requirements) == 1: reason = requirements[0]['text'] else: reason = '#quests:missionDetails/requirements/conclusion/unavailable' count = total - passed return text_styles.concatStylesWithSpace( icon, headerStyle(header), reasonStyle(ms(reason, count=count)))
def __init__(self, showConfirm=True, showWarning=True): self.__hasDiscounts = bool( self.itemsCache.items.shop.personalSlotDiscounts) self.__frozenSlotPrice = None slotCost = self.__getSlotPrice() if self.__hasDiscounts and not slotCost: confirmationType = 'freeSlotConfirmation' ctx = {} else: confirmationType = 'buySlotConfirmation' ctx = { 'goldCost': text_styles.concatStylesWithSpace( text_styles.gold(str(slotCost.gold)), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2)) } super(VehicleSlotBuyer, self).__init__( (proc_plugs.MessageInformator( 'buySlotNotEnoughCredits', activeHandler=lambda: not proc_plugs.MoneyValidator( slotCost).validate().success, isEnabled=showWarning), proc_plugs.MessageConfirmator(confirmationType, isEnabled=showConfirm, ctx=ctx), proc_plugs.MoneyValidator(slotCost))) return
def formatFloatPercent(value): if value != ProfileUtils.UNAVAILABLE_VALUE: value = value * 100 value = text_styles.concatStylesWithSpace( BigWorld.wg_getNiceNumberFormat(value), ProfileUtils.PERCENT_SYMBOL) return str(value)
def __formatFragmentsCost(self, intelligenceCost, intelligenceIcon, nationalsCost): intelligenceCostText = text_styles.concatStylesWithSpace( self.__formatFragment(intelligenceCost, intelligenceIcon, 19), text_styles.mainBig( backport.text(R.strings.storage.blueprints.card.plus())), text_styles.main( backport.text(R.strings.storage.blueprints.card.additional()))) nationalCostTexts = [] lastPriceIdx = len(nationalsCost) - 1 for index, (nId, cost) in enumerate(nationalsCost.iteritems()): nationName = nations.MAP[nId] nationalsCost = self.__gui.systemLocale.getNumberFormat(cost) nationalIcon = backport.image( R.images.gui.maps.icons.blueprints.fragment.special.dyn( nationName)()) nationalCostTexts.append({ 'costStr': self.__formatFragment(nationalsCost, nationalIcon), 'delimeterOffset': -5, 'hasDelimeter': index < lastPriceIdx }) return (intelligenceCostText, nationalCostTexts)
def changeRetrainType(self, operationId): operationId = int(operationId) items = g_itemsCache.items vehicle = g_currentVehicle.item shopPrices = items.shop.tankmanCost currentSelection = shopPrices[operationId] crewInfo = [] for idx, tMan in vehicle.crew: if tMan is not None: if tMan.vehicleNativeDescr.type.compactDescr != tMan.vehicleDescr.type.compactDescr: crewInfo.append(self.__getTankmanRoleInfo(tMan)) elif tMan.roleLevel != tankmen.MAX_SKILL_LEVEL and tMan.efficiencyRoleLevel < currentSelection[ 'roleLevel']: crewInfo.append(self.__getTankmanRoleInfo(tMan)) crewSize = len(crewInfo) price = crewSize * Money(**currentSelection) self.as_setCrewDataS({ 'price': price, 'crew': crewInfo, 'crewMembersText': text_styles.concatStylesWithSpace( _ms(RETRAIN_CREW.LABEL_CREWMEMBERS), text_styles.middleTitle(crewSize)) }) return
def construct(self): module = self.module block = [] title = module.userName imgPaddingLeft = 27 imgPaddingTop = 0 txtOffset = 130 - self.leftPadding desc = '' if module.itemTypeName in VEHICLE_COMPONENT_TYPE_NAMES: desc = text_styles.concatStylesWithSpace(text_styles.stats(_ms(TOOLTIPS.level(str(module.level)))), text_styles.standard(_ms(TOOLTIPS.VEHICLE_LEVEL))) imgPaddingLeft = 22 elif module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS: imgPaddingLeft = 7 imgPaddingTop = 5 txtOffset = 90 - self.leftPadding moduleParams = params_helper.getParameters(module) weightUnits = text_styles.standard(TOOLTIPS.PARAMETER_WEIGHTUNITS) paramName = ModuleTooltipBlockConstructor.WEIGHT_MODULE_PARAM paramValue = params_formatters.formatParameter(paramName, moduleParams[paramName]) if paramName in moduleParams else None if paramValue is not None: desc = text_styles.main(TOOLTIPS.PARAMETER_WEIGHT) + text_styles.credits(paramValue) + weightUnits else: desc = text_styles.standard(desc) overlayPath, overlayPadding, blockPadding = self.__getOverlayData() block.append(formatters.packItemTitleDescBlockData(title=text_styles.highTitle(title), desc=desc, img=module.icon, imgPadding=formatters.packPadding(left=imgPaddingLeft, top=imgPaddingTop), txtGap=-3, txtOffset=txtOffset, padding=blockPadding, overlayPath=overlayPath, overlayPadding=overlayPadding)) if module.itemTypeID == GUI_ITEM_TYPE.GUN: vehicle = self.configuration.vehicle vDescr = vehicle.descriptor if vehicle is not None else None if module.isClipGun(vDescr): block.append(formatters.packImageTextBlockData(title=text_styles.standard(MENU.MODULEINFO_CLIPGUNLABEL), desc='', img=RES_ICONS.MAPS_ICONS_MODULES_MAGAZINEGUNICON, imgPadding=formatters.packPadding(top=3), padding=formatters.packPadding(left=108, top=9))) elif module.itemTypeID == GUI_ITEM_TYPE.CHASSIS: if module.isHydraulicChassis(): block.append(formatters.packImageTextBlockData(title=text_styles.standard(MENU.MODULEINFO_HYDRAULICCHASSISLABEL), desc='', img=RES_ICONS.MAPS_ICONS_MODULES_HYDRAULICCHASSISICON, imgPadding=formatters.packPadding(top=3), padding=formatters.packPadding(left=108, top=9))) return block
def __updateTimer(self): self.__timerCallback = None self.__timerCallback = BigWorld.callback(1, self.__updateTimer) textLabel = makeString('#menu:prebattle/timerLabel') timeLabel = '%d:%02d' % divmod(self.__createTime, 60) result = text_styles.concatStylesWithSpace(text_styles.main(textLabel), timeLabel) if self.__provider.needAdditionalInfo(): result = text_styles.concatStylesToSingleLine(result, text_styles.main('*')) self.as_setTimerS(result) self.__createTime += 1 return
def __getMultiselectionInfoVO(self): allowedLevels = self._falloutCtrl.getConfig().allowedLevels showSlots, message = self.__getMultiselectionStatus() canDoAction, _ = self.prbDispatcher.canPlayerDoAction() if canDoAction: statusString = text_styles.statInfo('#fallout:multiselectionSlot/groupReady') else: statusString = text_styles.critical('#fallout:multiselectionSlot/groupNotReady') return {'formattedMessage': message, 'showSlots': showSlots, 'indicatorIsEnabled': canDoAction, 'vehicleTypes': text_styles.concatStylesWithSpace(text_styles.middleTitle(i18n.makeString('#fallout:multiselectionSlot/selectionStatus')), text_styles.main(i18n.makeString('#fallout:multiselectionSlot/selectionRequirements', level=toRomanRangeString(allowedLevels, step=1)))), 'statusSrt': statusString}
def _packWayToBuyBlock(self, data): subBlocks = [formatters.packTextBlockData(text=text_styles.middleTitle(_ms('#vehicle_customization:customization/tooltip/wayToBuy/title')), padding={'bottom': 6})] for buyItem in data['buyItems']: buyItemDesc = text_styles.main(buyItem['desc']) if buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_MISSION: subBlocks.append(formatters.packImageTextBlockData(desc=buyItemDesc, img=RES_ICONS.MAPS_ICONS_LIBRARY_QUEST_ICON, imgPadding={'left': 53, 'top': 3}, txtGap=-4, txtOffset=73)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_FOREVER: if buyItem['isSale']: subBlocks.append(formatters.packSaleTextParameterBlockData(name=buyItemDesc, saleData={'newPrice': (0, buyItem['value'])}, padding={'left': 0})) else: price = text_styles.concatStylesWithSpace(text_styles.gold(BigWorld.wg_getIntegralFormat(long(buyItem['value']))), icons.gold()) subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_TEMP: if buyItem['isSale']: subBlocks.append(formatters.packSaleTextParameterBlockData(name=buyItemDesc, saleData={'newPrice': (buyItem['value'], 0)}, padding={'left': 0})) else: price = text_styles.concatStylesWithSpace(text_styles.credits(BigWorld.wg_getIntegralFormat(long(buyItem['value']))), icons.credits()) subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_IGR: subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=icons.premiumIgrSmall(), padding={'left': 0})) return formatters.packBuildUpBlockData(subBlocks, 0, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_LINKAGE, {'left': 3})
def _packBonusBlock(self, data): vehicle = g_currentVehicle.item blocks = [] conditionBonus = data['condition'] is not None and data['type'] != CUSTOMIZATION_TYPE.CAMOUFLAGE bonusTitleLocal = makeHtmlString('html_templates:lobby/textStyle', 'bonusLocalText', {'message': '{0}{1}'.format(data['bonus_title_local'], '*' if conditionBonus else '')}) blocks.append(formatters.packImageTextBlockData(title=text_styles.concatStylesWithSpace(bonusTitleLocal), desc=text_styles.main(data['bonus_desc']), img=data['bonus_icon'], imgPadding={'left': 11, 'top': 3}, txtGap=-4, txtOffset=70, padding={'top': -1, 'left': 7})) if data['showTTC'] and vehicle is not None and self._cType == CUSTOMIZATION_TYPE.CAMOUFLAGE: stockVehicle = g_itemsCache.items.getStockVehicle(vehicle.intCD) comparator = params_helper.camouflageComparator(vehicle, self._item) stockParams = params_helper.getParameters(stockVehicle) simplifiedBlocks = SimplifiedStatsBlockConstructor(stockParams, comparator).construct() if len(simplifiedBlocks) > 0: blocks.extend(simplifiedBlocks) return formatters.packBuildUpBlockData(blocks, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)
def construct(self): block = [] headerBlocks = [] if self.vehicle.isElite: vehicleType = TOOLTIPS.tankcaruseltooltip_vehicletype_elite(self.vehicle.type) bgLinkage = BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_ELITE_VEHICLE_BG_LINKAGE else: vehicleType = TOOLTIPS.tankcaruseltooltip_vehicletype_normal(self.vehicle.type) bgLinkage = BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_NORMAL_VEHICLE_BG_LINKAGE nameStr = text_styles.highTitle(self.vehicle.userName) typeStr = text_styles.main(vehicleType) levelStr = text_styles.concatStylesWithSpace(text_styles.stats(int2roman(self.vehicle.level)), text_styles.standard(_ms(TOOLTIPS.VEHICLE_LEVEL))) icon = '../maps/icons/vehicleTypes/big/' + self.vehicle.type + ('_elite.png' if self.vehicle.isElite else '.png') headerBlocks.append(formatters.packImageTextBlockData(title=nameStr, desc=text_styles.concatStylesToMultiLine(levelStr + ' ' + typeStr, ''), img=icon, imgPadding=formatters.packPadding(left=10, top=-15), txtGap=-2, txtOffset=99, padding=formatters.packPadding(top=15, bottom=-15 if self.vehicle.isFavorite else -21))) if self.vehicle.isFavorite: headerBlocks.append(formatters.packImageTextBlockData(title=text_styles.neutral(TOOLTIPS.VEHICLE_FAVORITE), img=RES_ICONS.MAPS_ICONS_TOOLTIP_MAIN_TYPE, imgPadding=formatters.packPadding(top=-15), imgAtLeft=False, txtPadding=formatters.packPadding(left=10), txtAlign=BLOCKS_TOOLTIP_TYPES.ALIGN_RIGHT, padding=formatters.packPadding(top=-28, bottom=-27))) block.append(formatters.packBuildUpBlockData(headerBlocks, stretchBg=False, linkage=bgLinkage, padding=formatters.packPadding(left=-self.leftPadding))) return block
def changeRetrainType(self, operationId): operationId = int(operationId) items = g_itemsCache.items vehicle = g_currentVehicle.item shopPrices = items.shop.tankmanCost currentSelection = shopPrices[operationId] crewInfo = [] for idx, tMan in vehicle.crew: if tMan is not None: if tMan.vehicleNativeDescr.type.compactDescr != tMan.vehicleDescr.type.compactDescr: crewInfo.append(self.__getTankmanRoleInfo(tMan)) elif tMan.roleLevel != tankmen.MAX_SKILL_LEVEL and tMan.efficiencyRoleLevel < currentSelection['roleLevel']: crewInfo.append(self.__getTankmanRoleInfo(tMan)) crewSize = len(crewInfo) price = (crewSize * currentSelection['credits'], crewSize * currentSelection['gold']) self.as_setCrewDataS({'price': price, 'crew': crewInfo, 'crewMembersText': text_styles.concatStylesWithSpace(_ms(RETRAIN_CREW.LABEL_CREWMEMBERS), text_styles.middleTitle(crewSize))}) return
def construct(self): block = [] if self.vehicle.isElite: vehicleType = TOOLTIPS.tankcaruseltooltip_vehicletype_elite(self.vehicle.type) bgLinkage = BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_ELITE_VEHICLE_FAVORITE_BG_LINKAGE if self.vehicle.isFavorite else BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_ELITE_VEHICLE_BG_LINKAGE else: vehicleType = TOOLTIPS.tankcaruseltooltip_vehicletype_normal(self.vehicle.type) bgLinkage = BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_NORMAL_VEHICLE_FAVORITE_BG_LINKAGE if self.vehicle.isFavorite else BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_NORMAL_VEHICLE_BG_LINKAGE nameStr = text_styles.highTitle(self.vehicle.userName) typeStr = text_styles.main(vehicleType) levelStr = text_styles.concatStylesWithSpace(text_styles.stats(int2roman(self.vehicle.level)), text_styles.standard(_ms(TOOLTIPS.VEHICLE_LEVEL))) icon = '../maps/icons/vehicleTypes/big/' + self.vehicle.type + ('_elite.png' if self.vehicle.isElite else '.png') imgOffset = 4 textOffset = 82 if self.vehicle.type == 'heavyTank': imgOffset = 11 textOffset = 99 iconBlock = formatters.packImageTextBlockData(title=nameStr, desc=text_styles.concatStylesToMultiLine(typeStr, levelStr), img=icon, imgPadding={'left': imgOffset, 'top': -15}, txtGap=-2, txtOffset=textOffset, padding=formatters.packPadding(top=15, bottom=-15)) block.append(formatters.packBuildUpBlockData([iconBlock], stretchBg=False, linkage=bgLinkage, padding=formatters.packPadding(left=-19 + self.leftPadding, top=-1))) return block
def _packBonusBlock(self, item): bonusTitleLocal = makeHtmlString( "html_templates:lobby/textStyle", "bonusLocalText", {"message": "{0}{1}".format(item["bonus_title_local"], "" if item["conditional"] is None else "*")}, ) return formatters.packBuildUpBlockData( [ formatters.packImageTextBlockData( title=text_styles.concatStylesWithSpace( bonusTitleLocal, text_styles.stats(item["bonus_title_global"]) ), desc=text_styles.main(item["bonus_desc"]), img=item["bonus_icon"], imgPadding={"left": 11, "top": 3}, txtGap=-4, txtOffset=70, padding={"top": -1, "left": 7}, ) ], 0, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, )
def _packBonusBlock(self, item): bonusTitleLocal = makeHtmlString('html_templates:lobby/textStyle', 'bonusLocalText', {'message': '{0}{1}'.format(item['bonus_title_local'], '' if item['conditional'] is None else '*')}) return formatters.packBuildUpBlockData([formatters.packImageTextBlockData(title=text_styles.concatStylesWithSpace(bonusTitleLocal, text_styles.stats(item['bonus_title_global'])), desc=text_styles.main(item['bonus_desc']), img=item['bonus_icon'], imgPadding={'left': 11, 'top': 3}, txtGap=-4, txtOffset=70, padding={'top': -1, 'left': 7})], 0, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)
def _packBonusBlock(self, data): conditionBonus = data['condition'] is not None and data['type'] != CUSTOMIZATION_TYPE.CAMOUFLAGE bonusTitleLocal = makeHtmlString('html_templates:lobby/textStyle', 'bonusLocalText', {'message': '{0}{1}'.format(data['bonus_title_local'], '*' if conditionBonus else '')}) return formatters.packBuildUpBlockData([formatters.packImageTextBlockData(title=text_styles.concatStylesWithSpace(bonusTitleLocal), desc=text_styles.main(data['bonus_desc']), img=data['bonus_icon'], imgPadding={'left': 11, 'top': 3}, txtGap=-4, txtOffset=70, padding={'top': -1, 'left': 7})], 0, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)
def formatFloatPercent(value): if value != ProfileUtils.UNAVAILABLE_VALUE: value = value * 100 value = text_styles.concatStylesWithSpace(BigWorld.wg_getNiceNumberFormat(value), ProfileUtils.PERCENT_SYMBOL) return str(value)
def _populate(self): super(VehicleSellDialog, self)._populate() g_clientUpdateManager.addCallbacks({'stats.gold': self.onSetGoldHndlr}) g_itemsCache.onSyncCompleted += self.__shopResyncHandler items = g_itemsCache.items vehicle = items.getVehicle(self.vehInvID) sellPrice = vehicle.sellPrice sellForGold = sellPrice.gold > 0 priceTextColor = CURRENCIES_CONSTANTS.GOLD_COLOR if sellForGold else CURRENCIES_CONSTANTS.CREDITS_COLOR priceTextValue = _ms(DIALOGS.VEHICLESELLDIALOG_PRICE_SIGN_ADD) + _ms(BigWorld.wg_getIntegralFormat(sellPrice.gold if sellForGold else sellPrice.credits)) currencyIcon = CURRENCIES_CONSTANTS.GOLD if sellForGold else CURRENCIES_CONSTANTS.CREDITS invVehs = items.getVehicles(REQ_CRITERIA.INVENTORY) if vehicle.isPremium or vehicle.level >= 3: self.as_visibleControlBlockS(True) self.__initCtrlQuestion() else: self.as_visibleControlBlockS(False) modules = items.getItems(criteria=REQ_CRITERIA.VEHICLE.SUITABLE([vehicle]) | REQ_CRITERIA.INVENTORY).values() shells = items.getItems(criteria=REQ_CRITERIA.VEHICLE.SUITABLE([vehicle], [GUI_ITEM_TYPE.SHELL]) | REQ_CRITERIA.INVENTORY).values() otherVehsShells = set() for invVeh in invVehs.itervalues(): if invVeh.invID != self.vehInvID: for shot in invVeh.descriptor.gun['shots']: otherVehsShells.add(shot['shell']['compactDescr']) vehicleAction = None if sellPrice != vehicle.defaultSellPrice: vehicleAction = packItemActionTooltipData(vehicle, False) if vehicle.isElite: description = TOOLTIPS.tankcaruseltooltip_vehicletype_elite(vehicle.type) else: description = DIALOGS.vehicleselldialog_vehicletype(vehicle.type) levelStr = text_styles.concatStylesWithSpace(text_styles.stats(int2roman(vehicle.level)), text_styles.main(_ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_LEVEL))) restoreController = getRestoreController() tankmenGoingToBuffer, deletedTankmen = restoreController.getTankmenDeletedBySelling(vehicle) deletedCount = len(deletedTankmen) if deletedCount > 0: recoveryBufferFull = True deletedStr = formatDeletedTankmanStr(deletedTankmen[0]) maxCount = restoreController.getMaxTankmenBufferLength() currCount = len(restoreController.getDismissedTankmen()) if deletedCount == 1: crewTooltip = text_styles.concatStylesToMultiLine(text_styles.middleTitle(_ms(TOOLTIPS.VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)), text_styles.main(_ms(TOOLTIPS.VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_BODY, maxVal=maxCount, curVal=currCount, sourceName=tankmenGoingToBuffer[-1].fullUserName, targetInfo=deletedStr))) else: crewTooltip = text_styles.concatStylesToMultiLine(text_styles.middleTitle(_ms(TOOLTIPS.VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)), text_styles.main(_ms(TOOLTIPS.DISMISSTANKMANDIALOG_BUFFERISFULLMULTIPLE_BODY, deletedStr=deletedStr, extraCount=deletedCount - 1, maxCount=maxCount, currCount=currCount))) else: crewTooltip = None recoveryBufferFull = False barracksDropDownData = [{'label': _ms(MENU.BARRACKS_BTNUNLOAD)}, {'label': _ms(MENU.BARRACKS_BTNDISSMISS)}] sellVehicleData = {'intCD': vehicle.intCD, 'userName': vehicle.userName, 'icon': vehicle.icon, 'level': vehicle.level, 'isElite': vehicle.isElite, 'isPremium': vehicle.isPremium, 'type': vehicle.type, 'nationID': vehicle.nationID, 'sellPrice': sellPrice, 'priceTextValue': priceTextValue, 'priceTextColor': priceTextColor, 'currencyIcon': currencyIcon, 'action': vehicleAction, 'hasCrew': vehicle.hasCrew, 'isRented': vehicle.isRented, 'description': description, 'levelStr': levelStr, 'priceLabel': _ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_EMPTYSELLPRICE), 'crewLabel': _ms(DIALOGS.VEHICLESELLDIALOG_CREW_LABEL), 'crewTooltip': crewTooltip, 'barracksDropDownData': barracksDropDownData, 'crewRecoveryBufferFull': recoveryBufferFull} onVehicleOptionalDevices = [] for o in vehicle.optDevices: if o is not None: action = None if o.sellPrice != o.defaultSellPrice: action = packItemActionTooltipData(o, False) data = {'intCD': o.intCD, 'isRemovable': o.isRemovable, 'userName': o.userName, 'sellPrice': o.sellPrice, 'toInventory': True, 'action': action} onVehicleOptionalDevices.append(data) onVehicleoShells = [] for shell in vehicle.shells: if shell is not None: action = None if shell.sellPrice != shell.defaultSellPrice: action = packItemActionTooltipData(shell, False) data = {'intCD': shell.intCD, 'count': shell.count, 'sellPrice': shell.sellPrice, 'userName': shell.userName, 'kind': shell.type, 'toInventory': shell in otherVehsShells or shell.isPremium, 'action': action} onVehicleoShells.append(data) onVehicleEquipments = [] for equipmnent in vehicle.eqs: if equipmnent is not None: action = None if equipmnent.sellPrice != equipmnent.defaultSellPrice: action = packItemActionTooltipData(equipmnent, False) data = {'intCD': equipmnent.intCD, 'userName': equipmnent.userName, 'sellPrice': equipmnent.sellPrice, 'toInventory': True, 'action': action} onVehicleEquipments.append(data) inInventoryModules = [] for m in modules: inInventoryModules.append({'intCD': m.intCD, 'inventoryCount': m.inventoryCount, 'toInventory': True, 'sellPrice': m.sellPrice}) inInventoryShells = [] for s in shells: action = None if s.sellPrice != s.defaultSellPrice: action = packItemActionTooltipData(s, False) inInventoryShells.append({'intCD': s.intCD, 'count': s.inventoryCount, 'sellPrice': s.sellPrice, 'userName': s.userName, 'kind': s.type, 'toInventory': s in otherVehsShells or s.isPremium, 'action': action}) removePrice = items.shop.paidRemovalCost removePrices = Money(gold=removePrice) defRemovePrice = Money(gold=items.shop.defaults.paidRemovalCost) removeAction = None if removePrices != defRemovePrice: removeAction = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'paidRemovalCost', True, removePrices, defRemovePrice) settings = self.getDialogSettings() isSlidingComponentOpened = settings['isOpened'] self.as_setDataS({'accountGold': items.stats.gold, 'sellVehicleVO': sellVehicleData, 'optionalDevicesOnVehicle': onVehicleOptionalDevices, 'shellsOnVehicle': onVehicleoShells, 'equipmentsOnVehicle': onVehicleEquipments, 'modulesInInventory': inInventoryModules, 'shellsInInventory': inInventoryShells, 'removeActionPrice': removeAction, 'removePrice': removePrice, 'isSlidingComponentOpened': isSlidingComponentOpened}) return
def getMainStatusText(self): statusText = text_styles.success('#menu:awardWindow/mission/mainConditionComplete') if not self._isMainReward: return text_styles.concatStylesWithSpace(statusText, text_styles.standard('#menu:awardWindow/personalMission/alreadyCompleted')) else: return statusText