def getHelpTextAsDicts(arenaType): costKill, costFlags = getCosts(arenaType) flagsHead = __getText(TEXT_MANAGER_STYLES.NEUTRAL_TEXT, FALLOUT.INFOPANEL_GETFLAGS_HEAD) flagsDescr = __getText(TEXT_MANAGER_STYLES.MAIN_TEXT, FALLOUT.INFOPANEL_GETFLAGS_DESCR) secretsWinHead = __getText(TEXT_MANAGER_STYLES.NEUTRAL_TEXT, FALLOUT.INFOPANEL_SECRETWIN_HEAD) formatter = BigWorld.wg_getNiceNumberFormat scorePatterns = [] if costKill > 0: costKillText = makeString(FALLOUT.INFOPANEL_SECRETWIN_DESCR_COST, cost=formatter(costKill)) secretsWinDescrFirstPrefixStr = TextManager.getText(TEXT_MANAGER_STYLES.STATUS_WARNING_TEXT, costKillText) secretsWinDescrFirstStr = __getText(TEXT_MANAGER_STYLES.MAIN_TEXT, FALLOUT.INFOPANEL_SECRETWIN_DESCR_FIRSTSTR) scorePatterns.append(secretsWinDescrFirstPrefixStr + secretsWinDescrFirstStr) if costFlags: costFlagTextPatterns = [] for c in costFlags: costFlagTextPatterns.append(TextManager.getText(TEXT_MANAGER_STYLES.STATUS_WARNING_TEXT, makeString(FALLOUT.INFOPANEL_SECRETWIN_DESCR_COST, cost=formatter(c)))) secretsWinJoinPattern = TextManager.getText(TEXT_MANAGER_STYLES.MAIN_TEXT, ', ') secretsWinDescrSecondPrefixStr = secretsWinJoinPattern.join(costFlagTextPatterns) secretsWinDescrSecondStr = __getText(TEXT_MANAGER_STYLES.MAIN_TEXT, FALLOUT.INFOPANEL_SECRETWIN_DESCR_SECONDSTR) scorePatterns.append(secretsWinDescrSecondPrefixStr + secretsWinDescrSecondStr) joinPattern = TextManager.getText(TEXT_MANAGER_STYLES.MAIN_TEXT, ';\n') secretsWinDescr = __getText(TEXT_MANAGER_STYLES.MAIN_TEXT, FALLOUT.INFOPANEL_SECRETWIN_DESCR) % {'scorePattern': joinPattern.join(scorePatterns)} repairHead = __getText(TEXT_MANAGER_STYLES.NEUTRAL_TEXT, FALLOUT.INFOPANEL_REPAIR_HEAD) repairDescr = __getText(TEXT_MANAGER_STYLES.MAIN_TEXT, FALLOUT.INFOPANEL_REPAIR_DESCR) garageHead = __getText(TEXT_MANAGER_STYLES.NEUTRAL_TEXT, FALLOUT.INFOPANEL_GARAGE_HEAD) garageDescr = __getText(TEXT_MANAGER_STYLES.MAIN_TEXT, FALLOUT.INFOPANEL_GARAGE_DESCR) return [{'head': flagsHead, 'descr': flagsDescr}, {'head': secretsWinHead, 'descr': secretsWinDescr}, {'head': repairHead, 'descr': repairDescr}, {'head': garageHead, 'descr': garageDescr}]
def _makeMeta(self): item = g_itemsCache.items.getItemByCD(self._unlockCtx.unlockCD) xpCost = BigWorld.wg_getIntegralFormat(self._costCtx['xpCost']) freeXp = BigWorld.wg_getIntegralFormat(self._costCtx['freeXP']) ctx = {'xpCost': TextManager.getText(TextType.EXP_TEXT, xpCost), 'freeXP': TextManager.getText(TextType.EXP_TEXT, freeXp), 'typeString': item.userType, 'userString': item.userName} if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE: key = 'confirmUnlockVehicle' else: key = 'confirmUnlockItem' return dialogs.I18nConfirmDialogMeta('confirmUnlock', meta=dialogs.HtmlMessageLocalDialogMeta('html_templates:lobby/dialogs', key, ctx=ctx))
def getRentLeftTimeStr(localization, rentLeftTime, timeStyle = None, ctx = None): if ctx is None: ctx = {} if rentLeftTime > 0: if rentLeftTime > time_utils.ONE_DAY: timeLeft = str(int(math.ceil(float(rentLeftTime) / time_utils.ONE_DAY))) if timeStyle: timeLeft = TextManager.getText(timeStyle, timeLeft) return i18n.makeString((localization % 'days'), days=timeLeft, **ctx) else: timeLeft = str(int(math.ceil(float(rentLeftTime) / time_utils.ONE_HOUR))) if timeStyle: timeLeft = TextManager.getText(timeStyle, timeLeft) return i18n.makeString((localization % 'hours'), hours=timeLeft, **ctx) return ''
def __getActionButtonStateVO(self): stateString = '' unitFunctional = self.unitFunctional pInfo = unitFunctional.getPlayerInfo() isInQueue = unitFunctional.getFlags().isInIdle() isEnabled = g_currentVehicle.isReadyToPrebattle() and not isInQueue playerReady = pInfo.isReady if not g_currentVehicle.isPresent(): stateString = i18n.makeString('#cybersport:window/unit/message/vehicleNotSelected') elif not g_currentVehicle.isReadyToPrebattle(): stateString = i18n.makeString('#cybersport:window/unit/message/vehicleNotValid') elif not playerReady: stateString = i18n.makeString(MESSENGER.DIALOGS_SQUAD_MESSAGE_GETREADY) elif g_eventsCache.isEventEnabled() and self.__isFallout is not None and self.__isFallout != g_currentVehicle.item.isEvent: stateString = error(MENU.CURRENTVEHICLESTATUS_NOTVALIDVEHICLE) elif playerReady and not isInQueue: stateString = i18n.makeString(MESSENGER.DIALOGS_SQUAD_MESSAGE_GETNOTREADY) stateString = TextManager.getText(TEXT_MANAGER_STYLES.MAIN_TEXT if isEnabled else TEXT_MANAGER_STYLES.ERROR_TEXT, stateString) if playerReady: label = CYBERSPORT.WINDOW_UNIT_NOTREADY else: label = CYBERSPORT.WINDOW_UNIT_READY return {'stateString': stateString, 'label': label, 'isEnabled': isEnabled, 'isReady': playerReady}
def __checkMoney(self): changeRoleCost = self.__items.shop.changeRoleCost formattedPrice = BigWorld.wg_getIntegralFormat(changeRoleCost) actualGold = self.__items.stats.gold enoughGold = actualGold - changeRoleCost >= 0 textType = TextType.GOLD_TEXT if enoughGold else TextType.ERROR_TEXT priceString = TextManager.getText(textType, formattedPrice) priceString += TextManager.getIcon(TextIcons.GOLD) self.as_setPriceS(priceString, enoughGold)
def getList(self): result = [] for item in self.getCustomizations(): itemType = item.get('custType') itemId = item.get('id', (-1, -1)) boundVehicle = item.get('vehTypeCompDescr', None) boundToCurrentVehicle = item.get('boundToCurrentVehicle', False) nationId = 0 texture = '' res = '' if itemType == CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE_TYPE: customization = vehicles.g_cache.customization(itemId[0]) camouflages = customization.get('camouflages', {}) camouflage = camouflages.get(itemId[1], None) if camouflage: armorColor = customization.get('armorColor', 0) texture = self._makeTextureUrl(67, 67, camouflage.get('texture'), camouflage.get('colors', (0, 0, 0, 0)), armorColor) nationId, itemId = itemId elif itemType == CUSTOMIZATION_ITEM_TYPE.EMBLEM_TYPE: _, emblems, _ = vehicles.g_cache.playerEmblems() emblem = emblems.get(itemId, None) if emblem: texture = emblem[2] res = {'id': itemId, 'type': CUSTOMIZATION_ITEM_TYPE.EMBLEM, 'nationId': 0, 'texture': texture} elif itemType == CUSTOMIZATION_ITEM_TYPE.INSCRIPTION_TYPE: customization = vehicles.g_cache.customization(itemId[0]) inscriptions = customization.get(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION_TYPE, {}) inscription = inscriptions.get(itemId[1], None) if inscription: texture = inscription[2] nationId, itemId = itemId if texture.startswith('gui'): texture = texture.replace('gui', '..', 1) isPermanent = item.get('isPermanent', False) value = item.get('value', 0) valueStr = None if not isPermanent: value *= 86400 elif value > 1: valueStr = TextManager.getText(message=i18n.makeString(QUESTS.BONUSES_CUSTOMIZATION_VALUE, count=value)) res = {'id': itemId, 'type': CUSTOMIZATION_ITEM_TYPE.CI_TYPES.index(itemType), 'nationId': nationId, 'texture': texture, 'isPermanent': isPermanent, 'value': value, 'valueStr': valueStr, 'boundVehicle': boundVehicle, 'boundToCurrentVehicle': boundToCurrentVehicle} result.append(res) return result
def __updateHeader(self): isCreator = self.unitFunctional.getPlayerInfo().isCreator() if self.unitFunctional is not None else False club = self.clubsCtrl.getClub(self.__clubDBID) hasRankForModeChange = club is not None and club.getPermissions().canSetRanked() seasonActive = isSeasonInProgress() modeLabel = '' modeTooltip = '' modeTextStyle = TEXT_MANAGER_STYLES.STANDARD_TEXT if not seasonActive: modeLabel = CYBERSPORT.STATICFORMATION_UNITVIEW_MODECHANGEWARNING_NOSEASON modeTooltip = CYBERSPORT.STATICFORMATION_UNITVIEW_MODECHANGEWARNING_NOSEASONTOOLTIP elif isCreator: if not hasRankForModeChange: modeLabel = CYBERSPORT.STATICFORMATION_UNITVIEW_MODECHANGEWARNING_LOWRANK modeTooltip = CYBERSPORT.STATICFORMATION_UNITVIEW_MODECHANGEWARNING_LOWRANKTOOLTIP elif self.__extra.isRatedBattle: modeLabel = CYBERSPORT.STATICFORMATION_UNITVIEW_SETUNRANKEDMODE else: modeLabel = CYBERSPORT.STATICFORMATION_UNITVIEW_SETRANKEDMODE elif self.__extra.isRatedBattle: modeLabel = CYBERSPORT.STATICFORMATION_UNITVIEW_RANKEDMODE modeTextStyle = TEXT_MANAGER_STYLES.NEUTRAL_TEXT else: modeLabel = CYBERSPORT.STATICFORMATION_UNITVIEW_MODECHANGEWARNING_WRONGROLE modeTooltip = CYBERSPORT.STATICFORMATION_UNITVIEW_MODECHANGEWARNING_WRONGROLETOOLTIP bgSource = RES_ICONS.MAPS_ICONS_LIBRARY_CYBERSPORT_LEAGUERIBBONS_UNRANKED battles = self.ABSENT_VALUES winRate = self.ABSENT_VALUES leagueIcon = getLadderChevron64x64() enableWinRateTF = False if club is not None: clubTotalStats = club.getTotalDossier().getTotalStats() battles = BigWorld.wg_getNiceNumberFormat(clubTotalStats.getBattlesCount()) division = club.getLadderInfo().division leagueIcon = getLadderChevron64x64(division) winRateValue = ProfileUtils.getValueOrUnavailable(clubTotalStats.getWinsEfficiency()) if winRateValue != ProfileUtils.UNAVAILABLE_VALUE: enableWinRateTF = True winRate = ProfileUtils.formatFloatPercent(winRateValue) else: winRate = self.ABSENT_VALUES if self.__extra.isRatedBattle: bgSource = getLadderBackground(division) self.requestClubEmblem64x64(club.getClubDbID(), club.getEmblem64x64()) self.as_setHeaderDataS({'teamName': self.__extra.clubName, 'isRankedMode': bool(self.__extra.isRatedBattle), 'battles': battles, 'winRate': winRate, 'enableWinRateTF': enableWinRateTF, 'leagueIcon': leagueIcon, 'isFixedMode': not seasonActive or not isCreator, 'modeLabel': TextManager.getText(modeTextStyle, _ms(modeLabel)), 'modeTooltip': modeTooltip, 'bgSource': bgSource}) return
def __getExchangeBlockData(self, resToExchange): goldStepperTitleStr = i18n.makeString(DIALOGS.CONFIRMEXCHANGEDIALOG_GOLDITEMSSTEPPERTITLE) goldStepperTitleFmt = TextManager.getText(TEXT_MANAGER_STYLES.MAIN_TEXT, goldStepperTitleStr) return {'exchangeRateItemsIcon': self._getExchangeRateItemsIcon(), 'goldStepperTitle': goldStepperTitleFmt, 'needItemsIcon': self._getCurrencyIconPath(), 'needItemsStepperTitle': self._getResourceStepperTxt(), 'goldIcon': RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2, 'defaultExchangeRate': self._getDefaultExchangeRate(), 'exchangeRate': self.getExchangeRate(), 'defaultGoldValue': self.__getGoldToExchange(resToExchange), 'goldStepSize': self._getStepSize(), 'maxGoldValue': self._getMaxExchangeValue(), 'goldTextColorId': TEXT_MANAGER_STYLES.GOLD_TEXT, 'itemsTextColorId': self._getColorScheme()}
def makeVO(self): item = self._items.getItemByCD(self.getTypeCompDescr()) resToExchange = self._getResourceToExchange() extraData = None if item.itemTypeID == GUI_ITEM_TYPE.GUN and item.isClipGun(): extraData = CLIP_ICON_PATH state, stateMsg = self.__getState(resToExchange) return {'title': self.getTitle(), 'exchangeBtnText': self.getButtonLabels()[0]['label'], 'cancelBtnText': self.getButtonLabels()[1]['label'], 'state': state, 'lockExchangeMessage': stateMsg, 'iconExtraInfo': extraData, 'iconModuleType': item.itemTypeName, 'icon': self.__getIcon(item) if self.__getIconType(item) == CONFIRM_EXCHANGE_DIALOG_TYPES.VEHICLE_ICON else item.getGUIEmblemID(), 'iconType': self.__getIconType(item), 'itemName': TextManager.getText(TEXT_MANAGER_STYLES.MIDDLE_TITLE, item.userName), 'needItemsText': self.__getResourceToExchangeTxt(resToExchange), 'needGoldText': self.__getGoldToExchangeTxt(resToExchange), 'exchangeBlockData': self.__getExchangeBlockData(resToExchange)}
def _getNotEnoughGoldStateTxt(self, strGold): return TextManager.getText(TEXT_MANAGER_STYLES.ERROR_TEXT, self._makeString(I18N_GOLDNOTENOUGHTEXT_KEY.format(self._key), {'gold': strGold}))
def _getNoNeedExchangeStateTxt(self): return TextManager.getText(TEXT_MANAGER_STYLES.SUCCESS_TEXT, self._makeString(I18N_EXCHANGENONEEDTEXT_KEY.format(self._key), {}))
def _getResourceStepperTxt(self): return TextManager.getText(TEXT_MANAGER_STYLES.MAIN_TEXT, self._makeString(I18N_NEEDITEMSSTEPPERTITLE_KEY.format(self._key), {}))
def _getExchangeTxt(self, strGold): return TextManager.getText(TEXT_MANAGER_STYLES.MAIN_TEXT, self._makeString(I18N_NEEDGOLDTEXT_KEY.format(self._key), {'gold': strGold}))
def _getCurrencyTxt(self, strResource): return TextManager.getText(TEXT_MANAGER_STYLES.ERROR_TEXT, self._makeString(I18N_NEEDITEMSTEXT_KEY.format(self._key), {'value': strResource}))
def __getGoldValueWithIcon(self, gold): formattedGold = BigWorld.wg_getGoldFormat(gold) return TextManager.getText(TEXT_MANAGER_STYLES.GOLD_TEXT, formattedGold) + TextManager.getIcon(TextIcons.GOLD)
def __getResourceToExchangeTxt(self, resToExchange): if resToExchange > 0: resource = BigWorld.wg_getIntegralFormat(resToExchange) resStr = TextManager.getText(self._getCurrencyFormat(), resource) + self._getCurrencyIconStr() return self._getCurrencyTxt(resStr) return ''
def __makeMainVO(self): result = {} extra = self.unitFunctional.getExtra() (_, _, arenaTypeID), _ = self.__currentBuilding _getText = self.app.utilsManager.textManager.getText unitPermissions = self.unitFunctional.getPermissions() activeConsumes = extra.getConsumables() result['mapID'] = arenaTypeID arenaType = ArenaType.g_cache.get(arenaTypeID) canUseEquipments = self.__battle.itemData.canUseEquipments if arenaType is not None: mapName = _getText(TEXT_MANAGER_STYLES.MAIN_TEXT, arenaType.name) else: mapName = '' infoIcon = self.app.utilsManager.textManager.getIcon(TextIcons.INFO_ICON) result['headerDescr'] = _getText(TEXT_MANAGER_STYLES.STANDARD_TEXT, i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_MAPTITLE, mapName=mapName) + ' ' + infoIcon) result['isOrdersBgVisible'] = bool(not unitPermissions.canChangeConsumables() and len(activeConsumes) and not canUseEquipments) result['mineClanName'] = g_clanCache.clanTag _, enemyClanAbbev, _ = self.__battle.getOpponentClanInfo() result['enemyClanName'] = '[%s]' % enemyClanAbbev if not canUseEquipments and unitPermissions.canChangeConsumables(): result['ordersDisabledMessage'] = TextManager.getIcon(TextIcons.ALERT_ICON) + ' ' + TextManager.getText(TEXT_MANAGER_STYLES.ALERT_TEXT, i18n.makeString(FORTIFICATIONS.FORTCLANBATTLEROOM_HEADER_ORDERSDISABLED)) result['ordersDisabledTooltip'] = TOOLTIPS.FORTIFICATION_FORTCLANBATTLEROOM_ORDERSDISABLED_DIVISIONMISMATCH self.as_setBattleRoomDataS(result) return
def __getText(style, textId): return TextManager.getText(style, makeString(textId))