def getShellsLayoutFormatedPrice(self, intCD, colorManager, checkMoney=True, joinString=False): userCredits = g_itemsCache.items.stats.credits userGold = g_itemsCache.items.stats.gold creditsColor = colorManager.getColorScheme("textColorCredits").get("rgb") goldColor = colorManager.getColorScheme("textColorGold").get("rgb") errorColor = colorManager.getColorScheme("textColorError").get("rgb") result = [] for c, g in self.getShellsLayoutPrice(intCD): priceLabel = "" if g: params = { "value": BigWorld.wg_getGoldFormat(g), "color": goldColor if not checkMoney or userGold >= g else errorColor, "icon": getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2), } priceLabel += makeHtmlString("html_templates:lobby/historicalBattles/ammoStatus", "priceLabel", params) if c: params = { "value": BigWorld.wg_getIntegralFormat(c), "color": creditsColor if not checkMoney or userCredits >= c else errorColor, "icon": getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2), } priceLabel += makeHtmlString("html_templates:lobby/historicalBattles/ammoStatus", "priceLabel", params) result.append(priceLabel) if joinString: return i18n.makeString("#historical_battles:ammoPreset/priceConcat").join(result) return result
def __getDropdownPriceVO(self, item): dropdownPriceVO = [] for duration, text in [ (DURATION.PERMANENT, CUSTOMIZATION.BUYWINDOW_BUYTIME_EVER), (DURATION.MONTH, CUSTOMIZATION.BUYWINDOW_BUYTIME_THIRTYDAYS), (DURATION.WEEK, CUSTOMIZATION.BUYWINDOW_BUYTIME_SEVENDAYS) ]: if duration == DURATION.PERMANENT: textStyle = text_styles.gold icon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2 else: textStyle = text_styles.credits icon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2 dropdownItem = { 'labelPrice': text_styles.main(_ms(text)), 'label': makeHtmlString( 'html_templates:lobby/customization', 'DDString', { 'text': textStyle(item['object'].getPrice(duration)), 'icon': getAbsoluteUrl(icon) }) } salePrice = self.__getSalePrice(item, duration) if salePrice is not None: dropdownItem['salePrice'] = salePrice dropdownItem['isSale'] = True dropdownPriceVO.append(dropdownItem) return dropdownPriceVO
def _getDropdownPriceVO(element): result = [] for duration, text in zip(DURATION.ALL, _DURATION_LABELS): if duration == DURATION.PERMANENT: textStyle = text_styles.gold icon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2 else: textStyle = text_styles.credits icon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2 dropdownItem = { 'labelPrice': text_styles.main(_ms(text)), 'label': makeHtmlString( 'html_templates:lobby/customization', 'DDString', { 'text': textStyle(element.getPrice(duration)), 'icon': getAbsoluteUrl(icon) }) } if element.isOnSale(duration): isGold = duration == DURATION.PERMANENT dropdownItem['salePrice'] = getSalePriceString( isGold, element, duration) dropdownItem['isSale'] = True result.append(dropdownItem) return result
def __setBonuses(self, viewModel): bonusesList = viewModel.getBonuses() bonusesList.clear() for index, bonus in enumerate(self.__bonuses): if bonus.get('imgSource') is not None: bonus['imgSource'] = getAbsoluteUrl(bonus['imgSource']) if bonus.get('label') is not None: bonus['label'] = stripHTMLTags(bonus['label']) presenters = DEF_MODEL_PRESENTERS.copy() presenters[BlueprintsBonusSubtypes. UNIVERSAL_FRAGMENT] = LootRewardDefModelPresenter() modelPresenter = getRewardRendererModelPresenter( bonus, presenters=presenters) rendererModel = modelPresenter.getModel(bonus, index) tooltipId = str(index) bonusModel = SeniorityAwardsBonusRendererModel() bonusModel.setLabelStr(rendererModel.getLabelStr()) bonusModel.setIcon(rendererModel.getIcon()) bonusModel.setTooltipId(tooltipId) bonusModel.setBonusName(rendererModel.getRewardName()) bonusesList.addViewModel(bonusModel) self.__tooltipData[tooltipId] = TooltipData( tooltip=bonus.get('tooltip', None), isSpecial=bonus.get('isSpecial', False), specialAlias=bonus.get('specialAlias', ''), specialArgs=bonus.get('specialArgs', None)) bonusesList.invalidate() return
def _requestClubInfo(self): if self.clubsCtrl.getState().isAvailable(): result = yield self.clubsCtrl.sendRequest(GetPlayerInfoCtx( self._userID), allowDelay=True) if result.isSuccess() and result.data: pInfo = result.data clubDbID = pInfo.getClubDbID() if pInfo.isInLadder(): leagueLabel = makeHtmlString( 'html_templates:lobby/cyberSport/league', 'leagueInfoWithIcon', ctx={ 'icon': getAbsoluteUrl(pInfo.getLadderChevron()), 'league': pInfo.getLeagueString(), 'division': pInfo.getDivisionString() }) else: leagueLabel = text_styles.main('--') clubDataVO = { 'id': clubDbID, 'header': pInfo.getClubUserName(), 'topLabel': _ms(PROFILE.PROFILE_SUMMARY_CLUB_POST), 'topValue': text_styles.main(pInfo.getRoleString()), 'bottomLabel': _ms(PROFILE.PROFILE_SUMMARY_CLUB_LADDER), 'bottomValue': leagueLabel } clubDataVO.update(self._getClubProfileButtonParams(True)) self.as_setClubDataS(clubDataVO) self.requestClubEmblem32x32(clubDbID, pInfo.getEmblem32x32())
def getGfImagePath(imgPath): if imgPath is None: return else: newPath = getAbsoluteUrl(imgPath) if not newPath.startswith(GF_RES_PROTOCOL.IMG): newPath = ''.join([GF_RES_PROTOCOL.IMG, newPath]) return newPath
def getShellsLayoutFormatedPrice(self, intCD, colorManager, checkMoney=True, joinString=False): userCredits = g_itemsCache.items.stats.credits userGold = g_itemsCache.items.stats.gold creditsColor = colorManager.getColorScheme('textColorCredits').get( 'rgb') goldColor = colorManager.getColorScheme('textColorGold').get('rgb') errorColor = colorManager.getColorScheme('textColorError').get('rgb') result = [] for c, g in self.getShellsLayoutPrice(intCD): priceLabel = '' if g: params = { 'value': BigWorld.wg_getGoldFormat(g), 'color': goldColor if not checkMoney or userGold >= g else errorColor, 'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2) } priceLabel += makeHtmlString( 'html_templates:lobby/historicalBattles/ammoStatus', 'priceLabel', params) if c: params = { 'value': BigWorld.wg_getIntegralFormat(c), 'color': creditsColor if not checkMoney or userCredits >= c else errorColor, 'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2) } priceLabel += makeHtmlString( 'html_templates:lobby/historicalBattles/ammoStatus', 'priceLabel', params) result.append(priceLabel) if joinString: return i18n.makeString( '#historical_battles:ammoPreset/priceConcat').join(result) return result
def _getSlotBonusString(qualifier, isInDossier): bonus = makeHtmlString( 'html_templates:lobby/customization', 'bonusString', { 'bonusIcon': getAbsoluteUrl(qualifier.getIcon16x16()), 'bonusValue': qualifier.getValue(), 'isConditional': '' if qualifier.getDescription() is None else '*' }) if not isInDossier: bonus = text_styles.bonusAppliedText(bonus) return bonus
def updatePriceBlock(self): battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID) if self.selectedVehicleID == -1 or not battle.canParticipateWith(self.selectedVehicleID): params = {'value': 0, 'color': self.app.colorManager.getColorScheme('textColorError').get('rgb'), 'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2)} data = (makeHtmlString('html_templates:lobby/historicalBattles/ammoStatus', 'priceLabel', params),) selected = 0 else: data = battle.getShellsLayoutFormatedPrice(self.selectedVehicleID, self.app.colorManager) price = battle.getShellsLayoutPrice(self.selectedVehicleID) selected = self._getSelectedPriceIndex(price) self.as_setPricesS(data, selected)
def _getDropdownPriceVO(element): result = [] for duration, text in zip(DURATION.ALL, _DURATION_LABELS): if duration == DURATION.PERMANENT: textStyle = text_styles.gold icon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2 else: textStyle = text_styles.credits icon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2 dropdownItem = {'labelPrice': text_styles.main(_ms(text)), 'label': makeHtmlString('html_templates:lobby/customization', 'DDString', {'text': textStyle(element.getPrice(duration)), 'icon': getAbsoluteUrl(icon)})} if element.isOnSale(duration): isGold = duration == DURATION.PERMANENT dropdownItem['salePrice'] = getSalePriceString(isGold, element, duration) dropdownItem['isSale'] = True result.append(dropdownItem) return result
def __getDropdownPriceVO(self, item): dropdownPriceVO = [] for duration, text in [(DURATION.PERMANENT, CUSTOMIZATION.BUYWINDOW_BUYTIME_EVER), (DURATION.MONTH, CUSTOMIZATION.BUYWINDOW_BUYTIME_THIRTYDAYS), (DURATION.WEEK, CUSTOMIZATION.BUYWINDOW_BUYTIME_SEVENDAYS)]: if duration == DURATION.PERMANENT: textStyle = text_styles.gold icon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2 else: textStyle = text_styles.credits icon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2 dropdownItem = {'labelPrice': text_styles.main(_ms(text)), 'label': makeHtmlString('html_templates:lobby/customization', 'DDString', {'text': textStyle(item['object'].getPrice(duration)), 'icon': getAbsoluteUrl(icon)})} salePrice = self.__getSalePrice(item, duration) if salePrice is not None: dropdownItem['salePrice'] = salePrice dropdownItem['isSale'] = True dropdownPriceVO.append(dropdownItem) return dropdownPriceVO
def getAbsoluteUrl(cls, value): return getAbsoluteUrl(value)
def makeImageTag(source, width=16, height=16, vSpace=-4, hSpace=0): return _IMG_TAG_TPL.format(getAbsoluteUrl(source), width, height, vSpace, hSpace)
def initBattleTimer(self): battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID) if battle.isFuture(): date = battle.getStartDate() timeRemaining = battle.getStartTimeLeft() ttHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_STARTDATE) ttBody = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_FUTURE, date=date) else: date = battle.getFinishDate() timeRemaining = battle.getFinishTimeLeft() ttHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_ENDDATE) ttBody = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_ACTIVE, date=date) dateString = makeHtmlString('html_templates:lobby/historicalBattles', 'dateLabel', {'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_BUTTONS_CALENDAR), 'text': date}) self.as_setDateS(dateString, ttHeader, ttBody) self._clearCallbacks() if not battle.isFuture() and timeRemaining > self.COOLDOWN_TRESHOLD: self.updateRemainimgTime() self.startCooldownCBID = BigWorld.callback(timeRemaining + 1 - self.COOLDOWN_TRESHOLD, self.updateCooldown) else: self.updateCooldown()
def _requestClubInfo(self): if g_clubsCtrl.getState().isAvailable(): result = yield g_clubsCtrl.sendRequest(GetPlayerInfoCtx(self._userID), allowDelay=True) if result.isSuccess() and result.data: pInfo = result.data clubDbID = pInfo.getClubDbID() if pInfo.isInLadder(): leagueLabel = makeHtmlString('html_templates:lobby/cyberSport/league', 'leagueInfoWithIcon', ctx={'icon': getAbsoluteUrl(pInfo.getLadderChevron()), 'league': pInfo.getLeagueString(), 'division': pInfo.getDivisionString()}) else: leagueLabel = text_styles.main('--') self.as_setClubDataS({'id': clubDbID, 'header': pInfo.getClubUserName(), 'topLabel': _ms(PROFILE.PROFILE_SUMMARY_CLUB_POST), 'topValue': text_styles.main(pInfo.getRoleString()), 'bottomLabel': _ms(PROFILE.PROFILE_SUMMARY_CLUB_LADDER), 'bottomValue': leagueLabel, 'btnLabel': _ms(PROFILE.PROFILE_SUMMARY_CLUB_BTNLABEL), 'btnEnabled': True, 'btnVisible': True}) self.requestClubEmblem32x32(clubDbID, pInfo.getEmblem32x32())
def _populate(self): super(View, self)._populate() module = self.itemsCache.items.getItemByCD(self.moduleCompactDescr) description = '' if module.itemTypeID in (GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.EQUIPMENT): description = stripColorTagDescrTags(module.fullDescription) if module.itemTypeID in (GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.SHELL, GUI_ITEM_TYPE.EQUIPMENT): icon = module.icon else: icon = module.level extraModuleInfo = '' moduleData = { 'name': module.longUserName, 'windowTitle': ' '.join( [module.longUserName, i18n.makeString(MENU.MODULEINFO_TITLE)]), 'type': module.itemTypeName, 'description': description, 'level': icon, 'params': [], 'compatible': [], 'effects': {}, 'moduleLabel': module.getGUIEmblemID(), 'moduleLevel': module.level } params = params_helper.get(module, self.__vehicleDescr) moduleParameters = params.get('parameters', {}) formattedModuleParameters = formatters.getFormattedParamsList( module.descriptor, moduleParameters) extraParamsInfo = params.get('extras', {}) isGun = module.itemTypeID == GUI_ITEM_TYPE.GUN isShell = module.itemTypeID == GUI_ITEM_TYPE.SHELL isChassis = module.itemTypeID == GUI_ITEM_TYPE.CHASSIS isOptionalDevice = module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE excludedParametersNames = extraParamsInfo.get('excludedParams', tuple()) highlightPossible = False if isGun: if 'maxShotDistance' in moduleParameters: if moduleParameters['maxShotDistance'] >= _DEF_SHOT_DISTANCE: excludedParametersNames += ('maxShotDistance', ) gunReloadingType = extraParamsInfo[GUN_RELOADING_TYPE] if gunReloadingType == GUN_CLIP: description = i18n.makeString(MENU.MODULEINFO_CLIPGUNLABEL) extraModuleInfo = RES_ICONS.MAPS_ICONS_MODULES_MAGAZINEGUNICON elif gunReloadingType == GUN_AUTO_RELOAD: description = i18n.makeString( MENU.MODULEINFO_AUTORELOADGUNLABEL) extraModuleInfo = RES_ICONS.MAPS_ICONS_MODULES_AUTOLOADERGUN self._settingsCore.serverSettings.saveInUIStorage( {UI_STORAGE_KEYS.AUTO_RELOAD_MARK_IS_SHOWN: True}) highlightPossible = self._settingsCore.serverSettings.checkAutoReloadHighlights( increase=True) elif gunReloadingType == GUN_CAN_BE_CLIP: otherParamsInfoList = [] for paramName, paramValue in formattedModuleParameters: if paramName in excludedParametersNames: otherParamsInfoList.append({ 'type': formatters.formatModuleParamName(paramName) + '\n', 'value': text_styles.stats(paramValue) }) moduleData['otherParameters'] = { 'headerText': i18n.makeString( MENU.MODULEINFO_PARAMETERSCLIPGUNLABEL, getAbsoluteUrl( RES_ICONS.MAPS_ICONS_MODULES_MAGAZINEGUNICON)), 'params': otherParamsInfoList } if isChassis: if moduleParameters['isHydraulic']: description = i18n.makeString( MENU.MODULEINFO_HYDRAULICCHASSISLABEL) extraModuleInfo = RES_ICONS.MAPS_ICONS_MODULES_HYDRAULICCHASSISICON moduleData['description'] = description paramsList = [] for paramName, paramValue in formattedModuleParameters: if paramName not in excludedParametersNames: paramRow = { 'type': formatters.formatModuleParamName(paramName) + '\n', 'value': text_styles.stats(paramValue) } if highlightPossible and paramName == AUTO_RELOAD_PROP_NAME: paramRow['highlight'] = True paramsList.append(paramRow) moduleData['parameters'] = { 'headerText': i18n.makeString(MENU.MODULEINFO_PARAMETERSLABEL) if paramsList else '', 'params': paramsList } moduleData[EXTRA_MODULE_INFO] = extraModuleInfo moduleCompatibles = params.get('compatible', tuple()) for paramType, paramValue in moduleCompatibles: compatible = moduleData.get('compatible') compatible.append({ 'type': i18n.makeString(MENU.moduleinfo_compatible(paramType)), 'value': paramValue }) if module.itemTypeID == GUI_ITEM_TYPE.EQUIPMENT: effectsNametemplate = '#artefacts:%s/%s' if self.lobbyContext.getServerSettings( ).spgRedesignFeatures.isStunEnabled(): isRemovingStun = module.isRemovingStun else: isRemovingStun = False onUseStr = 'removingStun/onUse' if isRemovingStun else 'onUse' moduleData['effects'] = { 'effectOnUse': i18n.makeString(effectsNametemplate % (module.name, onUseStr)), 'effectAlways': i18n.makeString(effectsNametemplate % (module.name, 'always')), 'effectRestriction': i18n.makeString(effectsNametemplate % (module.name, 'restriction')) } cooldownSeconds = module.descriptor.cooldownSeconds if cooldownSeconds > 0: moduleData['addParams'] = { 'type': formatters.formatModuleParamName('cooldownSeconds') + '\n', 'value': text_styles.stats(cooldownSeconds) + '\n' } if isShell and self.__isAdditionalInfoShow is not None: moduleData['additionalInfo'] = self.__isAdditionalInfoShow if isOptionalDevice: moduleData[ 'highlightType'] = SLOT_HIGHLIGHT_TYPES.EQUIPMENT_PLUS if module.isDeluxe( ) else SLOT_HIGHLIGHT_TYPES.NO_HIGHLIGHT self.as_setModuleInfoS(moduleData) self._updateActionButton() return
def makeImageTag(source, width = 16, height = 16, vSpace = -4, hSpace = 0): return _IMG_TAG_TPL.format(getAbsoluteUrl(source), width, height, vSpace, hSpace)
def __getSlotBonusString(self, qualifier, isInDossier): bonus = makeHtmlString('html_templates:lobby/customization', 'bonusString', {'bonusIcon': getAbsoluteUrl(qualifier.getIcon16x16()), 'bonusValue': qualifier.getValue(), 'isConditional': '' if qualifier.getDescription() is None else '*'}) if not isInDossier: bonus = text_styles.bonusAppliedText(bonus) return bonus