def _packBlocks(self, badgeID): blocks = super(BadgeTooltipData, self)._packBlocks() badge = self._context.buildItem(badgeID) paramsConfig = self._context.getParamsConfiguration(badge) if badge is None: _logger.warning( 'Missing tooltip text for %r, please check badge.po', int(badgeID)) return blocks else: tooltipData = [ formatters.packTextBlockData( text_styles.highTitle(badge.getUserName())), formatters.packImageBlockData( badge.getHugeIcon(), BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER, padding=formatters.packPadding(top=-5, bottom=11)) ] if g_currentVehicle.isPresent() and paramsConfig.showVehicle: vehicle = g_currentVehicle.item tooltipData.append( formatters.packBadgeInfoBlockData( badge.getThumbnailIcon(), vehicle.iconContour, text_styles.bonusPreviewText(getPlayerName()), text_styles.bonusPreviewText(vehicle.shortUserName))) blocks.append(formatters.packBuildUpBlockData(tooltipData)) blocks.append( formatters.packTextBlockData( text_styles.main(badge.getUserDescription()))) return blocks
def construct(self): module = self.module block = [] def checkLocalization(key): localization = _ms('#artefacts:%s' % key) return (key != localization, localization) if self.lobbyContext.getServerSettings().spgRedesignFeatures.isStunEnabled(): isRemovingStun = module.isRemovingStun else: isRemovingStun = False onUseStr = '%s/removingStun/onUse' if isRemovingStun else '%s/onUse' onUse = checkLocalization(onUseStr % module.descriptor.name) always = checkLocalization('%s/always' % module.descriptor.name) restriction = checkLocalization('%s/restriction' % module.descriptor.name) if bonus_helper.isSituationalBonus(module.name): effectDesc = text_styles.bonusPreviewText(_ms(module.shortDescription)) icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_TOOLTIP_ASTERISK_OPTIONAL, 16, 16, 0, 4) desc = params_formatters.packSituationalIcon(effectDesc, icon) else: desc = text_styles.bonusAppliedText(_ms(module.shortDescription)) if module.itemTypeID == ITEM_TYPES.optionalDevice: block.append(formatters.packTitleDescBlock(title='', desc=desc, padding=formatters.packPadding(top=-8))) else: topPadding = 0 if always[0] and always[1]: block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(TOOLTIPS.EQUIPMENT_ALWAYS), desc=text_styles.bonusAppliedText(always[1]))) topPadding = 5 if onUse[0] and onUse[1]: block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(TOOLTIPS.EQUIPMENT_ONUSE), desc=text_styles.main(onUse[1]), padding=formatters.packPadding(top=topPadding))) topPadding = 5 if restriction[0] and restriction[1]: block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(TOOLTIPS.EQUIPMENT_RESTRICTION), desc=text_styles.main(restriction[1]), padding=formatters.packPadding(top=topPadding))) return block
def getPrimeTableBlocks(primeTime, currentCycleEnd, resRoot): primeTableBlocks = [_packTimeTableHeaderBlock(resRoot)] todayStart, todayEnd = time_utils.getDayTimeBoundsForLocal() todayEnd += 1 tomorrowStart, tomorrowEnd = todayStart + time_utils.ONE_DAY, todayEnd + time_utils.ONE_DAY tomorrowEnd += 1 todayPeriods = () tomorrowPeriods = () if primeTime is not None: todayPeriods = primeTime.getPeriodsBetween( todayStart, min(todayEnd, currentCycleEnd)) if tomorrowStart < currentCycleEnd: tomorrowPeriods = primeTime.getPeriodsBetween( tomorrowStart, min(tomorrowEnd, currentCycleEnd)) todayStr = _packPeriods(todayPeriods, resRoot) primeTableBlocks.append( _packTimeBlock(message=text_styles.main( backport.text(resRoot.timeTable.today())), timeStr=text_styles.bonusPreviewText(todayStr))) tomorrowStr = _packPeriods(tomorrowPeriods, resRoot) primeTableBlocks.append( _packTimeBlock(message=text_styles.main( backport.text(resRoot.timeTable.tomorrow())), timeStr=text_styles.stats(tomorrowStr))) return primeTableBlocks
def __getData(self): vehicle = g_currentPreviewVehicle.item if vehicle.isElite: vehicleTitle = text_styles.bonusPreviewText( '%s %s, %s' % (_ms(MENU.header_vehicletype_elite(vehicle.type)), _ms(VEHICLE_PREVIEW.INFOPANEL_LEVEL, level=_ms(MENU.header_level(vehicle.level))), _ms(MENU.nations(vehicle.nationName)))) else: vehicleTitle = text_styles.playerOnline( '%s %s, %s' % (_ms(MENU.header_vehicletype(vehicle.type)), _ms(VEHICLE_PREVIEW.INFOPANEL_LEVEL, level=_ms(MENU.header_level(vehicle.level))), _ms(MENU.nations(vehicle.nationName)))) if vehicle.isPremiumIGR: vehicleTitle = makeHtmlString('html_templates:igr/premium-vehicle', 'name', {'vehicle': vehicleTitle}) compareBtnEnabled, compareBtnTooltip = resolveStateTooltip( self.comparisonBasket, vehicle, VEH_COMPARE.STORE_COMPAREVEHICLEBTN_TOOLTIPS_ADDTOCOMPARE, VEH_COMPARE.STORE_COMPAREVEHICLEBTN_TOOLTIPS_DISABLED) result = { 'closeBtnLabel': VEHICLE_PREVIEW.HEADER_CLOSEBTN_LABEL, 'backBtnLabel': VEHICLE_PREVIEW.HEADER_BACKBTN_LABEL, 'backBtnDescrLabel': self.__getBackBtnLabel(), 'vehicleTitle': vehicleTitle, 'vehicleName': vehicle.descriptor.type.shortUserString.upper(), 'showCloseBtn': self._showCloseBtn, 'compareBtnTooltip': compareBtnTooltip, 'showCompareBtn': compareBtnEnabled } return result
def getTimeTableBlock(modeCtrl, modeName, leftPadding=0, connectionMgr=None): timeTableBlocks = [packTimeTableHeaderBlock(modeName)] primeTime = modeCtrl.getPrimeTimes().get(connectionMgr.peripheryID) currentCycleEnd = modeCtrl.getCurrentSeason().getCycleEndDate() todayStart, todayEnd = time_utils.getDayTimeBoundsForLocal() todayEnd += 1 tomorrowStart, tomorrowEnd = todayStart + time_utils.ONE_DAY, todayEnd + time_utils.ONE_DAY tomorrowEnd += 1 todayPeriods = () tomorrowPeriods = () if primeTime is not None: todayPeriods = primeTime.getPeriodsBetween( todayStart, min(todayEnd, currentCycleEnd)) if tomorrowStart < currentCycleEnd: tomorrowPeriods = primeTime.getPeriodsBetween( tomorrowStart, min(tomorrowEnd, currentCycleEnd)) todayStr = _packPeriods(todayPeriods, modeName) timeTableBlocks.append( _packTimeBlock(message=text_styles.main( backport.text( R.strings.dyn(modeName).selectorTooltip.timeTable.today())), timeStr=text_styles.bonusPreviewText(todayStr))) tomorrowStr = _packPeriods(tomorrowPeriods, modeName) timeTableBlocks.append( _packTimeBlock(message=text_styles.main( backport.text( R.strings.dyn(modeName).selectorTooltip.timeTable.tomorrow())), timeStr=text_styles.stats(tomorrowStr))) return formatters.packBuildUpBlockData( timeTableBlocks, 7, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, padding=formatters.packPadding(left=leftPadding))
def __packMapsProgressionBlock(self, progressionData): items = [] iconsPath = R.images.gui.maps.icons.mapbox.progressionTooltip seasonNumber = self.__mapboxCtrl.getCurrentSeason().getNumber() nameMapping = {'all': 'all_{}'.format(seasonNumber)} mapVOs = [] sortedProgressionData = sorted( progressionData.surveys.items(), key=lambda item: (item[0].startswith(tuple(string.digits)), item[0])) passedSurveys = 0 for mapName, mapData in sortedProgressionData: counter = backport.text( R.strings.mapbox.questFlag.counter(), progress=text_styles.bonusPreviewText( min(mapData.progress, mapData.total)), total=mapData.total) if not mapData.passed else '' mapVOs.append({ 'icon': backport.image( iconsPath.dyn( self.__formatMapName(nameMapping.get(mapName, mapName)))()), 'count': counter, 'isCompleted': mapData.passed }) if mapData.passed: passedSurveys += 1 if passedSurveys == len(sortedProgressionData): progressStyle = text_styles.bonusAppliedText else: progressStyle = text_styles.bonusPreviewText countStr = backport.text(R.strings.mapbox.questFlag.counter(), progress=progressStyle(passedSurveys), total=text_styles.main( len(sortedProgressionData))) items.append( formatters.packTextBlockData( text_styles.stats( backport.text(R.strings.mapbox.questFlag.surveysTitle(), count=countStr)), padding=formatters.packPadding(left=17))) items.append( formatters.packMapBoxBlockData(mapVOs, 60, 60, padding=formatters.packPadding( left=42, top=8), horizontalGap=10)) return formatters.packBuildUpBlockData(items)
def _packBlocks(self, badgeID): blocks = super(BadgeTooltipData, self)._packBlocks() badge = self.__itemsCache.items.getBadges()[badgeID] tooltipData = [ formatters.packTextBlockData( text_styles.highTitle(badge.getUserName())), formatters.packImageBlockData(badge.getHugeIcon(), BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER, padding=formatters.packPadding( top=-5, bottom=11)) ] if g_currentVehicle.isPresent(): vehicle = g_currentVehicle.item tooltipData.append( formatters.packBadgeInfoBlockData( badge.getThumbnailIcon(), vehicle.iconContour, text_styles.bonusPreviewText(getPlayerName()), text_styles.bonusPreviewText(vehicle.shortUserName))) blocks.append(formatters.packBuildUpBlockData(tooltipData)) blocks.append( formatters.packTextBlockData( text_styles.main(TOOLTIPS.PERSONALMISSIONS_BADGE_DESCR))) return blocks
def _packBlocks(self, *args): items = super(EpicMetaGameUnavailableTooltip, self)._packBlocks() items.append(self._packHeaderBlock()) timeTableBlocks = [self._packTimeTableHeaderBlock()] primeTime = self.epicController.getPrimeTimes().get( self.connectionMgr.peripheryID, None) if primeTime is None or self.epicController.hasAnySeason() is None: return items else: todayStart, todayEnd = time_utils.getDayTimeBoundsForLocal() todayEnd += 1 tomorrowStart, tomorrowEnd = todayStart + time_utils.ONE_DAY, todayEnd + time_utils.ONE_DAY todayPeriods = () tomorrowPeriods = () time, status = self.epicController.getSeasonEndTime() if status: todayPeriods = primeTime.getPeriodsBetween( todayStart, min(todayEnd, time)) if tomorrowStart < time: tomorrowPeriods = primeTime.getPeriodsBetween( tomorrowStart, min(tomorrowEnd, time)) todayStr = self._packPeriods(todayPeriods) timeTableBlocks.append( self._packTimeBlock(message=text_styles.main( EPIC_BATTLE. SELECTORTOOLTIP_EPICBATTLE_DISABLED_TIMETABLE_TODAY), timeStr=text_styles.bonusPreviewText( todayStr))) tomorrowStr = self._packPeriods(tomorrowPeriods) timeTableBlocks.append( self._packTimeBlock(message=text_styles.main( EPIC_BATTLE. SELECTORTOOLTIP_EPICBATTLE_DISABLED_TIMETABLE_TOMORROW ), timeStr=text_styles.stats( tomorrowStr))) items.append( formatters.packBuildUpBlockData( timeTableBlocks, 7, BLOCKS_TOOLTIP_TYPES. TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)) items.append( self._getTillEndBlock( time_utils.getTimeDeltaFromNow( time_utils.makeLocalServerTime(time)))) return items
def new_construct(self): block = old_construct(self) from gui.Scaleform.locale.RES_ICONS import RES_ICONS from gui.shared.formatters import text_styles, icons from gui.shared.items_parameters import formatters as params_formatters, bonus_helper from gui.shared.utils.functions import stripColorTagDescrTags from helpers.i18n import makeString as _ms from items import ITEM_TYPES if self.module.itemTypeID == ITEM_TYPES.optionalDevice: if bonus_helper.isSituationalBonus(self.module.name): effectDesc = text_styles.bonusPreviewText(stripColorTagDescrTags(_ms(self.module.fullDescription))) # noinspection PyArgumentEqualDefault icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_TOOLTIP_ASTERISK_OPTIONAL, 16, 16, 0, 4) desc = params_formatters.packSituationalIcon(effectDesc, icon) else: desc = text_styles.bonusAppliedText(stripColorTagDescrTags(_ms(self.module.fullDescription))) block[0]['data']['blocksData'][1]['data']['text'] = desc return block
def __makeItemDataVO(self, itemData): item = itemData.item progressionLevel = item.getLatestOpenedProgressionLevel( g_currentVehicle.item) icon = item.icon if progressionLevel == -1 else item.iconByProgressionLevel( progressionLevel) name = text_styles.main(item.userName) if itemData.isRemoved or not itemData.isRemovable: countLabel = '' price = None elif itemData.isFromInventory: countLabel = text_styles.main('{} '.format(len(itemData.slotsIds))) price = None else: countLabel = text_styles.main('{} x '.format(len( itemData.slotsIds))) price = getItemPricesVO(item.buyPrices.itemPrice)[0] disabledLabel = backport.text( R.strings.vehicle_customization.popover.style.removed()) disabledLabel = text_styles.bonusPreviewText(disabledLabel) isApplied = itemData.isBase progressionLevel = 0 if item.itemTypeID == GUI_ITEM_TYPE.STYLE: progressionLevel = self.__ctx.mode.currentOutfit.progressionLevel itemDataVO = { 'id': item.intCD, 'icon': icon, 'userName': name, 'numItems': countLabel, 'customizationDisplayType': item.customizationDisplayType(), 'price': price, 'isApplied': isApplied, 'isWide': item.isWide(), 'itemsList': itemData.slotsIds, 'isDim': item.isDim(), 'isEdited': not itemData.isBase, 'isDisabled': itemData.isRemoved, 'disabledLabel': disabledLabel, 'isRemovable': itemData.isRemovable, 'seasonType': itemData.season, 'progressionLevel': progressionLevel } return itemDataVO
def _packBlocks(self, *args): items = super(RankedSelectorTooltip, self)._packBlocks() items.append(self._packHeaderBlock()) timeTableBlocks = [self._packTimeTableHeaderBlock()] primeTime = self.rankedController.getPrimeTimes().get( self.connectionMgr.peripheryID) currentCycleEnd = self.rankedController.getCurrentSeason( ).getCycleEndDate() todayStart, todayEnd = time_utils.getDayTimeBoundsForLocal() todayEnd += 1 tomorrowStart, tomorrowEnd = todayStart + time_utils.ONE_DAY, todayEnd + time_utils.ONE_DAY tomorrowEnd += 1 todayPeriods = () tomorrowPeriods = () if primeTime is not None: todayPeriods = primeTime.getPeriodsBetween( todayStart, min(todayEnd, currentCycleEnd)) if tomorrowStart < currentCycleEnd: tomorrowPeriods = primeTime.getPeriodsBetween( tomorrowStart, min(tomorrowEnd, currentCycleEnd)) todayStr = self._packPeriods(todayPeriods) timeTableBlocks.append( self._packTimeBlock( message=text_styles.main( backport.text(R.strings.ranked_battles.selectorTooltip. timeTable.today())), timeStr=text_styles.bonusPreviewText(todayStr))) tomorrowStr = self._packPeriods(tomorrowPeriods) timeTableBlocks.append( self._packTimeBlock(message=text_styles.main( backport.text(R.strings.ranked_battles.selectorTooltip. timeTable.tomorrow())), timeStr=text_styles.stats(tomorrowStr))) items.append( formatters.packBuildUpBlockData( timeTableBlocks, 7, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)) items.append( self._getTillEndBlock( time_utils.getTimeDeltaFromNow( time_utils.makeLocalServerTime(currentCycleEnd)))) return items
def _getBottom(self, state): vehicle = g_currentVehicle.item isObtained = self._marathonEvent.isVehicleObtained() if isObtained: statusLabel = text_styles.bonusAppliedText( icons.makeImageTag(self.__iconsData.libraryOkIcon, vSpace=-2) + ' ' + _ms(self.__tooltipData.extraStateCompleted)) return formatters.packTextBlockData( text=makeHtmlString('html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': statusLabel }), padding=formatters.packPadding(bottom=20)) if state == MARATHON_STATE.IN_PROGRESS: warning = self._marathonEvent.checkForWarnings(vehicle) if warning == MARATHON_WARNING.WRONG_BATTLE_TYPE: return formatters.packTextBlockData( text=makeHtmlString( 'html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': text_styles.critical( _ms(self.__tooltipData.errorBattleType)) }), padding=formatters.packPadding(bottom=20)) if warning == MARATHON_WARNING.WRONG_VEH_TYPE: return formatters.packTextBlockData( text=makeHtmlString( 'html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': text_styles.critical( _ms(self.__tooltipData.errorVehType)) }), padding=formatters.packPadding(bottom=20)) currentStep, allStep = self._marathonEvent.getMarathonProgress() if allStep: return formatters.packTextBlockData( text=makeHtmlString( 'html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': text_styles.middleTitle( _ms(self.__tooltipData.extraStateSteps, currentStep=currentStep, allStep=text_styles.main(allStep))) }), padding=formatters.packPadding(bottom=20)) else: discount = self._marathonEvent.getMarathonDiscount() return formatters.packTextBlockData( text=makeHtmlString( 'html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': text_styles.bonusPreviewText( _ms(self.__tooltipData.extraStateDiscount, discount=discount)) }), padding=formatters.packPadding(bottom=20))
def _getBottom(self, state): vehicle = g_currentVehicle.item isObtained = self._marathonCtrl.isVehicleObtained() if isObtained: statusLabel = text_styles.bonusAppliedText( icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_OKICON, vSpace=-2) + ' ' + _ms(TOOLTIPS.MARATHON_EXTRA_STATE_COMPLETED)) return formatters.packTextBlockData( text=makeHtmlString('html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': statusLabel }), padding=formatters.packPadding(bottom=20)) if state == MARATHON_STATE.IN_PROGRESS: warning = self._marathonCtrl.checkForWarnings(vehicle) if warning == MARATHON_WARNING.WRONG_BATTLE_TYPE: return formatters.packTextBlockData( text=makeHtmlString( 'html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': text_styles.critical( _ms(TOOLTIPS.MARATHON_ERROR_BATTLE_TYPE)) }), padding=formatters.packPadding(bottom=20)) if warning == MARATHON_WARNING.WRONG_VEH_TYPE: return formatters.packTextBlockData( text=makeHtmlString( 'html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': text_styles.critical( _ms(TOOLTIPS.MARATHON_ERROR_VEH_TYPE)) }), padding=formatters.packPadding(bottom=20)) currentStep, allStep = self._marathonCtrl.getMarathonProgress() if allStep: return formatters.packTextBlockData( text=makeHtmlString( 'html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': text_styles.middleTitle( _ms(TOOLTIPS.MARATHON_EXTRA_STATE_STEPS, currentStep=currentStep, allStep=text_styles.main(allStep))) }), padding=formatters.packPadding(bottom=20)) else: discount = self._marathonCtrl.getMarathonDiscount() return formatters.packTextBlockData( text=makeHtmlString( 'html_templates:lobby/textStyle', 'alignText', { 'align': 'center', 'message': text_styles.bonusPreviewText( _ms(TOOLTIPS.MARATHON_EXTRA_STATE_DISCOUNT, discount=discount)) }), padding=formatters.packPadding(bottom=20))
def _getHeaderBlockData(self): vehInfo = self.vehicle.name.split(':') tankImage = R.images.gui.maps.icons.vehicle.c_420x307.dyn(self._tankNameToRClassName(vehInfo[1]))() if tankImage == -1: _logger.error('no background image for tooltip for tank %s', str(self._tankNameToRClassName(vehInfo[1]))) tankImage = R.images.gui.maps.icons.vehicle.c_420x307.dyn('tank_empty')() return TankStatsHeaderVO(tankName=text_styles.grandTitle(self.vehicle.userName), isFavorite=self.vehicle.isFavorite, flagImage=backport.image(R.images.gui.maps.icons.flags.c_362x362.dyn(vehInfo[0])()), tankImage=backport.image(tankImage) if tankImage != -1 else '', tankParams=self._getTankParamsVO(True), favoriteText=text_styles.bonusPreviewText(backport.text(R.strings.session_stats.tankInfo.main())), smallSize=True, tankType='{}_elite'.format(self.vehicle.type) if self.vehicle.isElite else self.vehicle.type, tankTier=text_styles.grandTitle(str(int2roman(self.vehicle.level))), tankNameSmall=text_styles.grandTitle(self.vehicle.shortUserName), isElite=self.vehicle.isElite)