def _packHiddenBlock(self): subBlocks = [] if not self._rented: subBlocks.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(TANK_CAROUSEL_FILTER.INFOTIP_RENT), value='', icon=ICON_TEXT_FRAMES.RENTALS, padding=formatters.packPadding(left=-50, top=-3, bottom=-18), nameOffset=20)) if not self._event: icon = icons.makeImageTag( RES_ICONS.MAPS_ICONS_BATTLETYPES_40X40_EVENT, width=22, height=22, vSpace=-8) text = text_styles.main(TANK_CAROUSEL_FILTER.INFOTIP_EVENT) subBlocks.append( formatters.packTextBlockData( text='{} {}'.format(icon, text), padding=formatters.packPadding(left=6, top=5, bottom=0))) return formatters.packBuildUpBlockData( subBlocks, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE )
def _makePriceBlock(self, price, currencySetting, percent=0, valueWidth=-1): _int = BigWorld.wg_getIntegralFormat hasAction = percent != 0 settings = _getCurrencySetting(currencySetting) if settings is None: return else: valueFormatted = settings.textStyle(_int(price)) if hasAction: settingsFrame = settings.frame if settingsFrame in Currency.ALL: newPrice = MONEY_UNDEFINED.replace(settingsFrame, price) else: newPrice = Money(credits=price) return formatters.packActionTextParameterBlockData( name=text_styles.main( _ms(TOOLTIPS.ACTIONPRICE_BUYPRICE_ACTIONPRICE, value=text_styles.expText(percent))), value=valueFormatted, icon=_getCurrencySetting(currencySetting).frame, padding=formatters.packPadding(left=20, bottom=-20), currency=newPrice.getCurrency(), valueWidth=valueWidth) return formatters.packTextParameterWithIconBlockData( name=text_styles.main(self._getDefaultPriceLabelConst()), value=valueFormatted, icon=settings.frame, valueWidth=valueWidth) return
def _packBlocks(self, *args, **kwargs): items = super(NotRecruitedTooltipData, self)._packBlocks() item = self.context.buildItem(*args) self.item = item blocks = list() blocks.append( formatters.packImageTextBlockData( title=text_styles.highTitle(item.getFullUserName()), desc=text_styles.main(item.getLabel()))) blocks.append( formatters.packImageBlockData( img=item.getBigIcon(), align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER)) blocks.append(formatters.packSeparatorBlockData()) blocks.append( formatters.packTextBlockData( text_styles.main(item.getDescription()), useHtml=True, padding=formatters.packPadding(top=20, bottom=7))) if item.getLearntSkills(): blocks.append( formatters.packTextBlockData(text_styles.middleTitle( TOOLTIPS.NOTRECRUITEDTANKMAN_SKILLSTITLE), useHtml=True, padding=formatters.packPadding( top=10, bottom=10))) skills = item.getLearntSkills() blocks.append( formatters.packImageListParameterBlockData( listIconSrc=[ Tankman.getSkillIconPath(skillName=skillName, size='big') for skillName in skills ], columnWidth=52, rowHeight=52, verticalGap=10, horizontalGap=10, padding=formatters.packPadding(bottom=10))) expiryTime = item.getExpiryTime() if expiryTime: blocks.append( formatters.packTextBlockData(text_styles.middleTitle( TOOLTIPS.NOTRECRUITEDTANKMAN_EXPIRETITLE), useHtml=True, padding=formatters.packPadding( top=10, bottom=2))) expireDateStr = makeString(TOOLTIPS.NOTRECRUITEDTANKMAN_USEBEFORE, date=expiryTime) blocks.append( formatters.packTextParameterWithIconBlockData( name=text_styles.premiumVehicleName(expireDateStr), value='', icon=ICON_TEXT_FRAMES.RENTALS, padding=formatters.packPadding(left=-60, bottom=-18), iconYOffset=3)) items.append( formatters.packBuildUpBlockData( blocks, padding=formatters.packPadding(bottom=-10))) return items
def construct(self): block = [] paddingTop = 8 block.append(formatters.packImageTextBlockData(title=text_styles.alert(TOOLTIPS.MODULEFITS_NOT_REMOVABLE_BODY), img=RES_ICONS.MAPS_ICONS_TOOLTIP_COMPLEX_EQUIPMENT, imgPadding=formatters.packPadding(left=2, top=3), txtOffset=20)) block.append(formatters.packTextBlockData(text=text_styles.main(TOOLTIPS.MODULEFITS_NOT_REMOVABLE_NOTE), padding=formatters.packPadding(top=paddingTop))) block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.MODULEFITS_NOT_REMOVABLE_DISMANTLING_PRICE), value=text_styles.gold(g_itemsCache.items.shop.paidRemovalCost), icon=ICON_TEXT_FRAMES.GOLD, valueWidth=60, padding=formatters.packPadding(left=43, top=paddingTop))) return block
def _packBlocks(self, invID, isLocked): items = super(NotRecruitedTooltipData, self)._packBlocks() item = self.context.buildItem(invID) self.item = item blocks = list() blocks.append(formatters.packImageTextBlockData(title=text_styles.highTitle(item.getFullUserName()), desc=text_styles.main(item.getLabel()))) specialIcon = item.getSpecialIcon() blocks.append(formatters.packImageBlockData(img=specialIcon if specialIcon is not None else item.getBigIcon(), align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER, width=350 if specialIcon is not None else -1, height=238 if specialIcon is not None else -1)) blocks.append(formatters.packSeparatorBlockData(paddings=formatters.packPadding(top=-40))) descrStr = i18n.makeString(item.getDescription()) hasDescr = descrStr != EMPTY_STRING if hasDescr: blocks.append(formatters.packTextBlockData(text_styles.main(descrStr), useHtml=True, padding=formatters.packPadding(top=18))) howToGetStr = i18n.makeString(item.getHowToGetInfo()) hasHowToGetStr = howToGetStr != EMPTY_STRING if hasHowToGetStr: blocks.append(formatters.packTextBlockData(text_styles.middleTitle(backport.text(R.strings.tooltips.notrecruitedtankman.howToGet())), useHtml=True, padding=formatters.packPadding(top=17 if hasDescr else 18, bottom=5))) blocks.append(formatters.packTextBlockData(text_styles.main(howToGetStr), useHtml=True, padding=formatters.packPadding())) skills = item.getLearntSkills(multiplyNew=True) if skills: tankmanSkill = item.getTankmanSkill() blocks.append(formatters.packTextBlockData(text_styles.middleTitle(TOOLTIPS.NOTRECRUITEDTANKMAN_SKILLSTITLE), useHtml=True, padding=formatters.packPadding(top=17 if hasDescr else 18, bottom=10))) blocks.append(formatters.packImageListParameterBlockData(listIconSrc=[ formatters.packImageListIconData(tankmanSkill(skillName=skillName).bigIconPath) for skillName in skills ], columnWidth=52, rowHeight=52, verticalGap=10, horizontalGap=10)) expiryTime = item.getExpiryTime() if expiryTime: blocks.append(formatters.packTextBlockData(text_styles.middleTitle(TOOLTIPS.NOTRECRUITEDTANKMAN_EXPIRETITLE), useHtml=True, padding=formatters.packPadding(top=20 if skills else (17 if hasDescr else 16), bottom=2))) expireDateStr = makeString(TOOLTIPS.NOTRECRUITEDTANKMAN_USEBEFORE, date=expiryTime) blocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.premiumVehicleName(expireDateStr), value='', icon=ICON_TEXT_FRAMES.RENTALS, padding=formatters.packPadding(left=-60, bottom=-18), iconYOffset=3)) if isLocked: alertStr = item.getAdditionalAlert() if alertStr: blocks.append(formatters.packTextBlockData(text_styles.alertBig(alertStr), padding=formatters.packPadding(top=20))) items.append(formatters.packBuildUpBlockData(blocks, padding=formatters.packPadding(bottom=-5))) return items
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 _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 _packHiddenBlock(self): subBlocks = [] if self._hideRented: subBlocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TANK_CAROUSEL_FILTER.INFOTIP_RENT), value='', icon=ICON_TEXT_FRAMES.RENTALS, padding=formatters.packPadding(left=-50, top=-3, bottom=-18), nameOffset=20)) if self._hideEvent: icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_BATTLETYPES_40X40_EVENT, width=22, height=22, vSpace=-8) text = text_styles.main(TANK_CAROUSEL_FILTER.INFOTIP_EVENT) subBlocks.append(formatters.packTextBlockData(text='{} {}'.format(icon, text), padding=formatters.packPadding(left=6, top=5, bottom=0))) return formatters.packBuildUpBlockData(subBlocks, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)
def _packRentBlock(self): subBlocks = (formatters.packTextParameterWithIconBlockData( name=text_styles.main(TANK_CAROUSEL_FILTER.FILTER_TOOLTIP_RENTAL), value='', icon=ICON_TEXT_FRAMES.RENTALS, padding=formatters.packPadding(left=-50, top=-3, bottom=-18), nameOffset=20), ) return formatters.packBuildUpBlockData( subBlocks, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE )
def _getDescriptionBlock(self): return (formatters.packBuildUpBlockData([ formatters.packTextParameterWithIconBlockData( text_styles.concatStylesToMultiLine( text_styles.middleTitle( TOOLTIPS.PERSONALMISSIONS_FREESHEET_USED_HEADER), text_styles.main( TOOLTIPS.PERSONALMISSIONS_FREESHEET_USED_TEXT)), '', ICON_TEXT_FRAMES.LOCK, padding=formatters.packPadding(left=-60, bottom=-2)) ]), )
def _getInfoBlock(self): return formatters.packBuildUpBlockData( [ formatters.packTextParameterWithIconBlockData( text_styles.alert( TOOLTIPS.PERSONALMISSIONS_FREESHEET_NOTENOUGH), '', ICON_TEXT_FRAMES.ALERT, padding=formatters.packPadding(left=-60, bottom=-2)) ], linkage=BLOCKS_TOOLTIP_TYPES. TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, padding=formatters.packPadding(top=-7, bottom=-3))
def __getValueBlocks(self): valueBlocks = list() if self._btnType == Currency.GOLD: valueBlocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_PURCHASEDVALUE), value=self.__getGoldString(wgm_balance_info_requester.GOLD_PURCHASED), icon=Currency.GOLD, valueWidth=84, iconYOffset=2)) valueBlocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_EARNEDVALUE), value=self.__getGoldString(wgm_balance_info_requester.GOLD_EARNED), icon=Currency.GOLD, padding=formatters.packPadding(bottom=10), valueWidth=84, iconYOffset=2)) valueBlocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_TOTALVALUE), value=text_styles.gold(self.__getGoldTotal()), icon=Currency.GOLD, padding=formatters.packPadding(bottom=15), valueWidth=84, iconYOffset=2)) else: valueBlocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_PURCHASEDVALUE), value=self.__getCreditsString(wgm_balance_info_requester.CREDITS_PURCHASED), icon=Currency.CREDITS, valueWidth=84, iconYOffset=2)) valueBlocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_EARNEDVALUE), value=self.__getCreditsString(wgm_balance_info_requester.CREDITS_EARNED), icon=Currency.CREDITS, padding=formatters.packPadding(bottom=10), valueWidth=84, iconYOffset=2)) valueBlocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_TOTALVALUE), value=text_styles.credits(self.__getCreditsTotal()), icon=Currency.CREDITS, padding=formatters.packPadding(bottom=15), valueWidth=84, iconYOffset=2)) return valueBlocks
def __packPointsBlock(self): valueBlock = formatters.packTextParameterWithIconBlockData( name=text_styles.main( backport.text(R.strings.ranked_battles.yearRewards.tooltip. needPoints())), value=text_styles.stats( str(self.__points) if self.__points else ''), icon=ICON_TEXT_FRAMES.RANKED_POINTS, padding=formatters.packPadding(left=76, top=-5, bottom=-6), valueWidth=20, nameOffset=15, iconYOffset=2, gap=5) return formatters.packBuildUpBlockData( [valueBlock], linkage=BLOCKS_TOOLTIP_TYPES. TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, align=BLOCKS_TOOLTIP_TYPES.ALIGN_RIGHT)
def _packInventoryBlock(self): container = self.app.containerManager.getContainer(ViewTypes.LOBBY_SUB) view = container.getView() if view.alias == VIEW_ALIAS.LOBBY_CUSTOMIZATION: getInventoryCount = view.getItemInventoryCount else: getInventoryCount = getItemInventoryCount subBlocks = [formatters.packTextBlockData(text=text_styles.middleTitle(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_INVENTORY_TITLE), padding={'bottom': 4})] money = self.itemsCache.items.stats.money if not self._item.isHidden: for itemPrice in self._item.buyPrices: currency = itemPrice.getCurrency() value = itemPrice.price.getSignValue(currency) defValue = itemPrice.defPrice.getSignValue(currency) needValue = value - money.getSignValue(currency) actionPercent = itemPrice.getActionPrc() if not self._item.isRentable: setting = CURRENCY_SETTINGS.getBuySetting forcedText = '' else: setting = CURRENCY_SETTINGS.getRentSetting forcedText = _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_INVENTORY_COST_RENT, battlesNum=self._item.rentCount) subBlocks.append(makePriceBlock(value, setting(currency), needValue if needValue > 0 else None, defValue if defValue > 0 else None, actionPercent, valueWidth=88, leftPadding=49, forcedText=forcedText)) if not self._item.isRentable: for itemPrice in self._item.sellPrices: currency = itemPrice.getCurrency() value = itemPrice.price.getSignValue(currency) defValue = itemPrice.defPrice.getSignValue(currency) actionPercent = itemPrice.getActionPrc() if actionPercent > 0: subBlocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.ACTIONPRICE_SELL_BODY_SIMPLE), value=text_styles.concatStylesToSingleLine(text_styles.credits(BigWorld.wg_getIntegralFormat(value)), ' ', icons.credits()), icon='alertMedium', valueWidth=88, padding=formatters.packPadding(left=-5))) subBlocks.append(makePriceBlock(value, CURRENCY_SETTINGS.SELL_PRICE, oldPrice=defValue if defValue > 0 else None, percent=actionPercent, valueWidth=88, leftPadding=49)) inventoryCount = getInventoryCount(self._item) info = text_styles.concatStylesWithSpace(text_styles.stats(inventoryCount)) if self._item.isRentable and inventoryCount > 0 or not self._item.isRentable: title = text_styles.main(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_INVENTORY_RENT_BATTLESLEFT if self._item.isRentable else VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_INVENTORY_AVAILABLE) icon = RES_ICONS.MAPS_ICONS_LIBRARY_CLOCKICON_1 if self._item.isRentable else RES_ICONS.MAPS_ICONS_CUSTOMIZATION_STORAGE_ICON padding = formatters.packPadding(left=83, bottom=-14 if self._item.isRentable else 0) titlePadding = formatters.packPadding(left=-8 if self._item.isRentable else -1) iconPadding = formatters.packPadding(top=-7 if self._item.isRentable else -2, left=-3 if self._item.isRentable else -2) subBlocks.append(formatters.packTitleDescParameterWithIconBlockData(title=title, value=info, icon=icon, padding=padding, titlePadding=titlePadding, iconPadding=iconPadding)) return formatters.packBuildUpBlockData(blocks=subBlocks, gap=-1)
def _packBlocks(self, *args, **kwargs): items = super(RentVehicleAwardTooltipData, self)._packBlocks() blocks = list() blocks.append(formatters.packTextBlockData(text_styles.middleTitle(TOOLTIPS.QUESTS_AWARDS_VEHICLERENT_HEADER), padding=formatters.packPadding(top=8))) blocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.premiumVehicleName(TOOLTIPS.QUESTS_AWARDS_VEHICLERENT_EXPIRE), value='', icon=ICON_TEXT_FRAMES.RENTALS, padding=formatters.packPadding(left=-60), iconYOffset=3)) items.append(formatters.packBuildUpBlockData(blocks, padding=formatters.packPadding(bottom=-19))) blocks = list() vehiclesCount = 0 for rentVehicleData in args: rentVehicleData = flashObject2Dict(rentVehicleData) vehicleName = rentVehicleData.get('vehicleName', '') vehicleType = rentVehicleData.get('vehicleType', '') isPremiumVehicle = rentVehicleData.get('isPremium', True) rentLeftCount = 0 rentTypeName = None for rentType in _RENT_TYPES: rentTypeValue = rentVehicleData.get(rentType, 0) if rentTypeValue > 0: rentTypeName = rentType rentLeftCount = rentTypeValue break if isPremiumVehicle: imgPaddings = formatters.packPadding(right=2) else: imgPaddings = formatters.packPadding(left=5, right=5, top=4) blocks.append(formatters.packImageTextBlockData(title=text_styles.highlightText(vehicleName), img=getTypeSmallIconPath(vehicleType, isPremiumVehicle), imgPadding=imgPaddings, txtPadding=formatters.packPadding(left=2))) if rentTypeName is not None and rentLeftCount > 0: rentCountStr = text_styles.premiumVehicleName(rentLeftCount) rentLeftStr = _ms(TOOLTIPS.getRentLeftTypeLabel(rentTypeName), count=rentCountStr) blocks.append(formatters.packTextBlockData(text_styles.main(rentLeftStr), padding=formatters.packPadding(left=28, top=-8, bottom=5))) vehiclesCount += 1 if vehiclesCount >= _MAX_AWARDS_PER_TOOLTIP: count = len(args) - vehiclesCount if count > 0: blocks.append(formatters.packTextBlockData(text_styles.main(backport.text(R.strings.tooltips.quests.awards.additional.bottom(), count=count)))) break items.append(formatters.packBuildUpBlockData(blocks, padding=formatters.packPadding(bottom=-12))) return items
def construct(self): xp = self.configuration.xp dailyXP = self.configuration.dailyXP buyPrice = self.configuration.buyPrice sellPrice = self.configuration.sellPrice unlockPrice = self.configuration.unlockPrice techTreeNode = self.configuration.node minRentPrice = self.configuration.minRentPrice rentals = self.configuration.rentals paddings = formatters.packPadding(left=-4) neededValue = 0 actionPrc = 0 if buyPrice and sellPrice: LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time') return else: block = [] isUnlocked = self.vehicle.isUnlocked isInInventory = self.vehicle.isInInventory isNextToUnlock = False parentCD = None if techTreeNode is not None: isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE.NEXT_2_UNLOCK) parentCD = techTreeNode.unlockProps.parentID if xp: xpValue = self.vehicle.xp if xpValue: xPText = text_styles.expText(_int(xpValue)) icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_XP), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=paddings)) if dailyXP: attrs = g_itemsCache.items.stats.attributes if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0: dailyXPText = text_styles.main(text_styles.expText('x' + _int(self.vehicle.dailyXPFactor))) block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_DAILYXPFACTOR), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=paddings)) if unlockPrice: isAvailable, cost, need = getUnlockPrice(self.vehicle.intCD, parentCD) if cost > 0: neededValue = None if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None: neededValue = need block.append(makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, valueWidth=self._valueWidth)) if buyPrice and not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom): price = self.vehicle.buyPrice money = g_itemsCache.items.stats.money actionPrc = self.vehicle.actionPrc defaultPrice = self.vehicle.defaultPrice currency = price.getCurrency() buyPriceText = price.get(currency) oldPrice = defaultPrice.get(currency) neededValue = price.get(currency) - money.get(currency) neededValue = neededValue if neededValue > 0 else None if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock: neededValue = None block.append(makePriceBlock(buyPriceText, CURRENCY_SETTINGS.getBuySetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth)) if sellPrice and not self.vehicle.isTelecom: sellPrice = self.vehicle.sellPrice if sellPrice.isSet(Currency.GOLD): sellPriceText = text_styles.gold(_int(sellPrice.gold)) sellPriceIcon = ICON_TEXT_FRAMES.GOLD else: sellPriceText = text_styles.credits(_int(sellPrice.credits)) sellPriceIcon = ICON_TEXT_FRAMES.CREDITS block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_SELL_PRICE), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=paddings)) if minRentPrice and not self.vehicle.isPremiumIGR: minRentPricePackage = self.vehicle.getRentPackage() if minRentPricePackage: minRentPriceValue = Money(*minRentPricePackage['rentPrice']) minDefaultRentPriceValue = Money(*minRentPricePackage['defaultRentPrice']) actionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage['days']) money = g_itemsCache.items.stats.money currency = minRentPriceValue.getCurrency() price = minRentPriceValue.get(currency) oldPrice = minDefaultRentPriceValue.get(currency) neededValue = minRentPriceValue.get(currency) - money.get(currency) neededValue = neededValue if neededValue > 0 else None block.append(makePriceBlock(price, CURRENCY_SETTINGS.getRentSetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth)) if rentals and not self.vehicle.isPremiumIGR: rentFormatter = RentLeftFormatter(self.vehicle.rentInfo) rentLeftInfo = rentFormatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: {'left': count, 'descr': i18n.makeString(key % countType)}) if rentLeftInfo: block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(rentLeftInfo['descr']), value=text_styles.main(rentLeftInfo['left']), icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-4, bottom=-16))) notEnoughMoney = neededValue > 0 hasAction = actionPrc > 0 return (block, notEnoughMoney or hasAction)
def construct(self): xp = self.configuration.xp dailyXP = self.configuration.dailyXP buyPrice = self.configuration.buyPrice sellPrice = self.configuration.sellPrice unlockPrice = self.configuration.unlockPrice techTreeNode = self.configuration.node minRentPrice = self.configuration.minRentPrice rentals = self.configuration.rentals if buyPrice and sellPrice: LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time') return else: priceBlock = [] isUnlocked = self.vehicle.isUnlocked isInInventory = self.vehicle.isInInventory isRented = self.vehicle.isRented isNextToUnlock = False parentCD = None if techTreeNode is not None: isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE.NEXT_2_UNLOCK) parentCD = techTreeNode.unlockProps.parentID if xp: xpValue = self.vehicle.xp if xpValue: xPText = text_styles.expText(_int(xpValue)) icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_XP)), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding))) if dailyXP: attrs = g_itemsCache.items.stats.attributes if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0: dailyXPText = text_styles.main(text_styles.expText('x' + _int(self.vehicle.dailyXPFactor))) priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_DAILYXPFACTOR)), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding))) if unlockPrice: isAvailable, cost, need = getUnlockPrice(self.vehicle.intCD, parentCD) if cost > 0: neededValue = None if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None: neededValue = need block = self._makePriceBlock(cost, _ms(TOOLTIPS.VEHICLE_UNLOCK_PRICE), ICON_TEXT_FRAMES.XP, neededValue) priceBlock.append(block) if buyPrice and not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom): price = self.vehicle.buyPrice credits, gold = g_itemsCache.items.stats.money creditsBuyPrice = price[0] goldBuyPrice = price[1] creditsNeeded = creditsBuyPrice - credits if creditsBuyPrice else 0 goldNeeded = goldBuyPrice - gold if goldBuyPrice else 0 neededValue = None actionPrc = self.vehicle.actionPrc defaultPrice = self.vehicle.defaultPrice if goldBuyPrice == 0: currencyType = ICON_TEXT_FRAMES.CREDITS buyPriceText = creditsBuyPrice oldPrice = defaultPrice[0] if creditsNeeded > 0: neededValue = creditsNeeded else: currencyType = ICON_TEXT_FRAMES.GOLD buyPriceText = goldBuyPrice oldPrice = defaultPrice[1] if goldNeeded > 0: neededValue = goldNeeded text = _ms(TOOLTIPS.VEHICLE_BUY_PRICE) if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock: neededValue = None block = self._makePriceBlock(buyPriceText, text, currencyType, neededValue, oldPrice, actionPrc) priceBlock.append(block) if sellPrice and not self.vehicle.isTelecom: creditsPrice = self.vehicle.sellPrice[0] goldPrice = self.vehicle.sellPrice[1] if goldPrice == 0: sellPriceText = text_styles.credits(_int(creditsPrice)) sellPriceIcon = ICON_TEXT_FRAMES.CREDITS else: sellPriceText = text_styles.gold(_int(goldPrice)) sellPriceIcon = ICON_TEXT_FRAMES.GOLD priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(_ms(TOOLTIPS.VEHICLE_SELL_PRICE)), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding))) if minRentPrice and not self.vehicle.isPremiumIGR: minRentPricePackage = self.vehicle.getRentPackage() if minRentPricePackage: minRentPriceValue = minRentPricePackage['rentPrice'] minDefaultRentPriceValue = minRentPricePackage['defaultRentPrice'] rentActionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage['days']) credits, gold = g_itemsCache.items.stats.money creditsPrice = minRentPriceValue[0] goldPrice = minRentPriceValue[1] enoughCreditsForRent = credits - creditsPrice >= 0 enoughGoldForRent = gold - goldPrice >= 0 neededValue = None if goldPrice == 0: price = creditsPrice oldPrice = minDefaultRentPriceValue[0] currencyType = ICON_TEXT_FRAMES.CREDITS if not enoughCreditsForRent: neededValue = credits - creditsPrice else: price = goldPrice oldPrice = minDefaultRentPriceValue[1] currencyType = ICON_TEXT_FRAMES.GOLD if not enoughGoldForRent: neededValue = gold - goldPrice text = _ms(TOOLTIPS.VEHICLE_MINRENTALSPRICE) block = self._makePriceBlock(price, text, currencyType, neededValue, oldPrice, rentActionPrc) priceBlock.append(block) if rentals and not self.vehicle.isPremiumIGR: rentFormatter = RentLeftFormatter(self.vehicle.rentInfo) rentLeftInfo = rentFormatter.getRentLeftStr('#tooltips:vehicle/rentLeft/%s', formatter=lambda key, countType, count, _ = None: {'left': count, 'descr': i18n.makeString(key % countType)}) if rentLeftInfo: priceBlock.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(rentLeftInfo['descr']), value=text_styles.main(rentLeftInfo['left']), icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=formatters.packPadding(left=self.leftPadding, right=self.rightPadding))) return priceBlock
def _packRentBlock(self): subBlocks = (formatters.packTextParameterWithIconBlockData(name=text_styles.main(TANK_CAROUSEL_FILTER.FILTER_TOOLTIP_RENTAL), value='', icon=ICON_TEXT_FRAMES.RENTALS, padding=formatters.packPadding(left=-50, top=-3, bottom=-18), nameOffset=20),) return formatters.packBuildUpBlockData(subBlocks, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)
def _packInventoryBlock(self, showBuyPrice, showSellPrice, showInventoryCount): subBlocks = [] money = self.itemsCache.items.stats.money if showBuyPrice and not self._item.isHidden: for itemPrice in self._item.buyPrices: currency = itemPrice.getCurrency() value = itemPrice.price.getSignValue(currency) defValue = itemPrice.defPrice.getSignValue(currency) needValue = value - money.getSignValue(currency) actionPercent = itemPrice.getActionPrc() if not self._item.isRentable: setting = CURRENCY_SETTINGS.getBuySetting forcedText = '' else: setting = CURRENCY_SETTINGS.getRentSetting forcedText = _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_TOOLTIP_INVENTORY_COST_RENT, battlesNum=self._item.rentCount) if self._item.buyCount > 0: subBlocks.append( makePriceBlock(value, setting(currency), needValue if needValue > 0 else None, defValue if defValue > 0 else None, actionPercent, valueWidth=88, leftPadding=49, forcedText=forcedText)) if showSellPrice and not (self._item.isHidden or self._item.isRentable): for itemPrice in self._item.sellPrices: currency = itemPrice.getCurrency() value = itemPrice.price.getSignValue(currency) defValue = itemPrice.defPrice.getSignValue(currency) actionPercent = itemPrice.getActionPrc() if actionPercent > 0: subBlocks.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main( TOOLTIPS.ACTIONPRICE_SELL_BODY_SIMPLE), value=text_styles.concatStylesToSingleLine( text_styles.credits( backport.getIntegralFormat(value)), ' ', icons.credits()), icon='alertMedium', valueWidth=88, padding=formatters.packPadding(left=-5))) subBlocks.append( makePriceBlock(value, CURRENCY_SETTINGS.SELL_PRICE, oldPrice=defValue if defValue > 0 else None, percent=actionPercent, valueWidth=88, leftPadding=49)) if self.__ctx is not None: inventoryCount = self.__ctx.mode.getItemInventoryCount(self._item) else: inventoryCount = getItemInventoryCount(self._item) info = text_styles.concatStylesWithSpace( text_styles.stats(inventoryCount)) padding = formatters.packPadding(left=83, bottom=0) titlePadding = formatters.packPadding(left=-1) if showInventoryCount and inventoryCount > 0: if self._item.isRentable: textKey = VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_INVENTORY_RENT_BATTLESLEFT icon = RES_ICONS.MAPS_ICONS_LIBRARY_CLOCKICON_1 autoRentEnabled = self.__ctx.mode.isAutoRentEnabled( ) if self.__ctx is not None else False if self._item.isRented and autoRentEnabled: textKey = VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_INVENTORY_RENT_BATTLESLEFT_AUTOPROLONGATIONON icon = RES_ICONS.MAPS_ICONS_CUSTOMIZATION_ICON_RENT title = text_styles.main( _ms(textKey, tankname=self.__vehicle.shortUserName)) padding = formatters.packPadding(left=83, bottom=-14) titlePadding = formatters.packPadding(left=-8) iconPadding = formatters.packPadding(top=-7, left=-3) else: title = text_styles.main( VEHICLE_CUSTOMIZATION. CUSTOMIZATION_TOOLTIP_INVENTORY_AVAILABLE) icon = RES_ICONS.MAPS_ICONS_CUSTOMIZATION_STORAGE_ICON padding = formatters.packPadding(left=83, bottom=0) titlePadding = formatters.packPadding(left=-1) iconPadding = formatters.packPadding(top=-2, left=-2) subBlocks.append( formatters.packTitleDescParameterWithIconBlockData( title=title, value=info, icon=icon, padding=padding, titlePadding=titlePadding, iconPadding=iconPadding)) boundCount = self._item.boundInventoryCount(self.__vehicle.intCD) commonCount = boundCount + self.installedCount isVehicleBound = self._item.isVehicleBound and not self._item.isProgressionAutoBound if showInventoryCount and commonCount > 0 and isVehicleBound and not self._item.isRentable: subBlocks.append( formatters.packTitleDescParameterWithIconBlockData( title=text_styles.main( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_BOUND_ON_VEHICLE, tankname=self.__vehicle.shortUserName)), value=text_styles.concatStylesWithSpace( text_styles.stats(commonCount)), icon=RES_ICONS.MAPS_ICONS_CUSTOMIZATION_TANK, padding=padding, titlePadding=titlePadding, iconPadding=formatters.packPadding(top=2))) return formatters.packBuildUpBlockData(blocks=subBlocks, gap=-1)
def construct(self): block = [] module = self.module slotIdx = self.configuration.slotIdx vehicle = self.configuration.vehicle sellPrice = self.configuration.sellPrice buyPrice = self.configuration.buyPrice unlockPrice = self.configuration.unlockPrice inventoryCount = self.configuration.inventoryCount vehiclesCount = self.configuration.vehiclesCount researchNode = self.configuration.node if buyPrice and sellPrice: LOG_ERROR('You are not allowed to use buyPrice and sellPrice at the same time') return else: def checkState(state): if researchNode is not None: return bool(int(researchNode.state) & state) else: return False isEqOrDev = module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS isNextToUnlock = checkState(NODE_STATE_FLAGS.NEXT_2_UNLOCK) isInstalled = checkState(NODE_STATE_FLAGS.INSTALLED) isInInventory = checkState(NODE_STATE_FLAGS.IN_INVENTORY) isUnlocked = checkState(NODE_STATE_FLAGS.UNLOCKED) isAutoUnlock = checkState(NODE_STATE_FLAGS.AUTO_UNLOCKED) items = self.itemsCache.items money = items.stats.money itemPrice = MONEY_UNDEFINED if module is not None: itemPrice = module.buyPrices.itemPrice.price isMoneyEnough = money >= itemPrice leftPadding = 92 if unlockPrice and not isEqOrDev: parentCD = vehicle.intCD if vehicle is not None else None isAvailable, cost, need = getUnlockPrice(module.intCD, parentCD) neededValue = None if not isUnlocked and isNextToUnlock and need > 0: neededValue = need if cost > 0: block.append(makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, leftPadding=leftPadding, valueWidth=self._valueWidth)) notEnoughMoney = False hasAction = False if buyPrice and not isAutoUnlock: shop = self.itemsCache.items.shop money = self.itemsCache.items.stats.money rootInInv = vehicle is not None and vehicle.isInInventory if researchNode: showNeeded = rootInInv and not isMoneyEnough and (isNextToUnlock or isUnlocked) and not (isInstalled or isInInventory) else: isModuleUnlocked = module.isUnlocked isModuleInInventory = module.isInInventory showNeeded = not isModuleInInventory and isModuleUnlocked showDelimiter = False leftPadding = 92 for itemPrice in module.buyPrices.iteritems(directOrder=False): if not isItemBuyPriceAvailable(module, itemPrice, shop): continue currency = itemPrice.getCurrency() value = itemPrice.price.getSignValue(currency) defValue = itemPrice.defPrice.getSignValue(currency) actionPercent = itemPrice.getActionPrc() if isEqOrDev or showNeeded: needValue = value - money.getSignValue(currency) if needValue > 0: notEnoughMoney = True else: needValue = None else: needValue = None if currency == Currency.GOLD and actionPercent > 0: leftActionPadding = 101 + self.leftPadding else: leftActionPadding = 81 + self.leftPadding if actionPercent > 0: hasAction = True if showDelimiter: block.append(formatters.packTextBlockData(text=text_styles.standard(TOOLTIPS.VEHICLE_TEXTDELIMITER_OR), padding=formatters.packPadding(left=leftActionPadding))) block.append(makePriceBlock(value, CURRENCY_SETTINGS.getBuySetting(currency), needValue, defValue if defValue > 0 else None, actionPercent, valueWidth=self._valueWidth, leftPadding=leftPadding)) showDelimiter = True if sellPrice and module.sellPrices: block.append(makePriceBlock(module.sellPrices.itemPrice.price.credits, CURRENCY_SETTINGS.SELL_PRICE, oldPrice=module.sellPrices.itemPrice.defPrice.credits, percent=module.sellPrices.itemPrice.getActionPrc(), valueWidth=self._valueWidth, leftPadding=leftPadding)) if inventoryCount: count = module.inventoryCount if count > 0: block.append(self._getInventoryBlock(count)) if vehiclesCount: inventoryVehicles = items.getVehicles(REQ_CRITERIA.INVENTORY) count = len(module.getInstalledVehicles(inventoryVehicles.itervalues())) if count > 0: block.append(formatters.packTextParameterBlockData(name=text_styles.main(TOOLTIPS.VEHICLE_VEHICLECOUNT), value=text_styles.stats(count), valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5))) isOptionalDevice = module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE if isOptionalDevice and not module.isRemovable and not self.configuration.isAwardWindow: removalPrice = module.getRemovalPrice(self.itemsCache.items) removalPriceCurrency = removalPrice.getCurrency() currencyTextFormatter = getattr(text_styles, removalPriceCurrency, text_styles.gold) block.append(formatters.packTextParameterWithIconBlockData(name=text_styles.main(TOOLTIPS.MODULEFITS_NOT_REMOVABLE_DISMANTLING_PRICE), value=currencyTextFormatter(removalPrice.price.get(removalPriceCurrency)), icon=removalPriceCurrency, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5))) hasAction |= module.sellPrices.itemPrice.isActionPrice() return (block, notEnoughMoney or hasAction)
def construct(self): xp = self.configuration.xp dailyXP = self.configuration.dailyXP buyPrice = self.configuration.buyPrice sellPrice = self.configuration.sellPrice unlockPrice = self.configuration.unlockPrice techTreeNode = self.configuration.node minRentPrice = self.configuration.minRentPrice rentals = self.configuration.rentals futureRentals = self.configuration.futureRentals paddings = formatters.packPadding(left=-4) neededValue = 0 actionPrc = 0 if buyPrice and sellPrice: LOG_ERROR( 'You are not allowed to use buyPrice and sellPrice at the same time' ) return else: block = [] isUnlocked = self.vehicle.isUnlocked isInInventory = self.vehicle.isInInventory isNextToUnlock = False parentCD = None if techTreeNode is not None: isNextToUnlock = bool( int(techTreeNode.state) & NODE_STATE_FLAGS.NEXT_2_UNLOCK) parentCD = techTreeNode.unlockProps.parentID if xp: xpValue = self.vehicle.xp if xpValue: xPText = text_styles.expText(_int(xpValue)) icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(TOOLTIPS.VEHICLE_XP), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=paddings)) if dailyXP: attrs = g_itemsCache.items.stats.attributes if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0: dailyXPText = text_styles.main( text_styles.expText('x' + _int(self.vehicle.dailyXPFactor))) block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main( TOOLTIPS.VEHICLE_DAILYXPFACTOR), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=paddings)) if unlockPrice: isAvailable, cost, need = getUnlockPrice( self.vehicle.intCD, parentCD) if cost > 0: neededValue = None if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None: neededValue = need block.append( makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, valueWidth=self._valueWidth)) if buyPrice: if self.vehicle.isRestorePossible(): price = self.vehicle.restorePrice defaultPrice = price currency = price.getCurrency() buyPriceText = price.get(currency) oldPrice = defaultPrice.get(currency) neededValue = _getNeedValue(price, currency) if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock: neededValue = None block.append( makePriceBlock(buyPriceText, CURRENCY_SETTINGS.RESTORE_PRICE, neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth)) if self.vehicle.hasLimitedRestore(): timeKey, formattedTime = getTimeLeftInfo( self.vehicle.restoreInfo.getRestoreTimeLeft(), None) block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main( '#tooltips:vehicle/restoreLeft/%s' % timeKey), value=text_styles.main(formattedTime), icon=ICON_TEXT_FRAMES.ALERT if timeKey == 'hours' else ICON_TEXT_FRAMES.EMPTY, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-4))) elif not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom): price = self.vehicle.buyPrice actionPrc = self.vehicle.actionPrc defaultPrice = self.vehicle.defaultPrice currency = price.getCurrency() buyPriceText = price.get(currency) oldPrice = defaultPrice.get(currency) neededValue = _getNeedValue(price, currency) if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock: neededValue = None block.append( makePriceBlock( buyPriceText, CURRENCY_SETTINGS.getBuySetting(currency), neededValue, oldPrice, 0, valueWidth=self._valueWidth)) if sellPrice and not self.vehicle.isTelecom: sellPrice = self.vehicle.sellPrice if sellPrice.isSet(Currency.GOLD): sellPriceText = text_styles.gold(_int(sellPrice.gold)) sellPriceIcon = ICON_TEXT_FRAMES.GOLD else: sellPriceText = text_styles.credits(_int( sellPrice.credits)) sellPriceIcon = ICON_TEXT_FRAMES.CREDITS block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(TOOLTIPS.VEHICLE_SELL_PRICE), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=paddings)) if minRentPrice and not self.vehicle.isPremiumIGR: minRentPricePackage = self.vehicle.getRentPackage() if minRentPricePackage: minRentPriceValue = Money( *minRentPricePackage['rentPrice']) minDefaultRentPriceValue = Money( *minRentPricePackage['defaultRentPrice']) actionPrc = self.vehicle.getRentPackageActionPrc( minRentPricePackage['days']) currency = minRentPriceValue.getCurrency() price = minRentPriceValue.get(currency) oldPrice = minDefaultRentPriceValue.get(currency) neededValue = _getNeedValue(minRentPriceValue, currency) block.append( makePriceBlock( price, CURRENCY_SETTINGS.getRentSetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth)) if not self.vehicle.isRented or self.vehicle.rentalIsOver: block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main( '#tooltips:vehicle/rentAvailable'), value='', icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=paddings)) if rentals and not self.vehicle.isPremiumIGR: if futureRentals: rentLeftKey = '#tooltips:vehicle/rentLeftFuture/%s' rentInfo = RentalInfoProvider(time=self._rentExpiryTime, isRented=True) else: rentLeftKey = '#tooltips:vehicle/rentLeft/%s' rentInfo = self.vehicle.rentInfo rentFormatter = RentLeftFormatter(rentInfo) rentLeftInfo = rentFormatter.getRentLeftStr( rentLeftKey, formatter=lambda key, countType, count, _=None: { 'left': count, 'descr': i18n.makeString(key % countType) }) if rentLeftInfo: block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(rentLeftInfo['descr']), value=text_styles.main(rentLeftInfo['left']), icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-4, bottom=-16))) notEnoughMoney = neededValue > 0 hasAction = actionPrc > 0 return (block, notEnoughMoney or hasAction)
def construct(self): xp = self.configuration.xp dailyXP = self.configuration.dailyXP buyPrice = self.configuration.buyPrice sellPrice = self.configuration.sellPrice unlockPrice = self.configuration.unlockPrice techTreeNode = self.configuration.node minRentPrice = self.configuration.minRentPrice rentals = self.configuration.rentals futureRentals = self.configuration.futureRentals paddings = formatters.packPadding(left=-4) neededValue = 0 actionPrc = 0 if buyPrice and sellPrice: LOG_ERROR("You are not allowed to use buyPrice and sellPrice at the same time") return else: block = [] isUnlocked = self.vehicle.isUnlocked isInInventory = self.vehicle.isInInventory isNextToUnlock = False parentCD = None if techTreeNode is not None: isNextToUnlock = bool(int(techTreeNode.state) & NODE_STATE_FLAGS.NEXT_2_UNLOCK) parentCD = techTreeNode.unlockProps.parentID if xp: xpValue = self.vehicle.xp if xpValue: xPText = text_styles.expText(_int(xpValue)) icon = ICON_TEXT_FRAMES.FREE_XP if self.vehicle.isPremium else ICON_TEXT_FRAMES.XP block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(TOOLTIPS.VEHICLE_XP), value=xPText, icon=icon, valueWidth=self._valueWidth, padding=paddings, ) ) if dailyXP: attrs = g_itemsCache.items.stats.attributes if attrs & constants.ACCOUNT_ATTR.DAILY_MULTIPLIED_XP and self.vehicle.dailyXPFactor > 0: dailyXPText = text_styles.main(text_styles.expText("x" + _int(self.vehicle.dailyXPFactor))) block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(TOOLTIPS.VEHICLE_DAILYXPFACTOR), value=dailyXPText, icon=ICON_TEXT_FRAMES.DOUBLE_XP_FACTOR, valueWidth=self._valueWidth, padding=paddings, ) ) if unlockPrice: isAvailable, cost, need = getUnlockPrice(self.vehicle.intCD, parentCD) if cost > 0: neededValue = None if isAvailable and not isUnlocked and need > 0 and techTreeNode is not None: neededValue = need block.append( makePriceBlock(cost, CURRENCY_SETTINGS.UNLOCK_PRICE, neededValue, valueWidth=self._valueWidth) ) if buyPrice: if self.vehicle.isRestorePossible(): price = self.vehicle.restorePrice defaultPrice = price currency = price.getCurrency() buyPriceText = price.get(currency) oldPrice = defaultPrice.get(currency) neededValue = _getNeedValue(price, currency) if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock: neededValue = None block.append( makePriceBlock( buyPriceText, CURRENCY_SETTINGS.RESTORE_PRICE, neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth, ) ) if self.vehicle.hasLimitedRestore(): timeKey, formattedTime = getTimeLeftInfo(self.vehicle.restoreInfo.getRestoreTimeLeft(), None) block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main("#tooltips:vehicle/restoreLeft/%s" % timeKey), value=text_styles.main(formattedTime), icon=ICON_TEXT_FRAMES.ALERT if timeKey == "hours" else ICON_TEXT_FRAMES.EMPTY, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-4), ) ) elif not (self.vehicle.isDisabledForBuy or self.vehicle.isPremiumIGR or self.vehicle.isTelecom): price = self.vehicle.buyPrice actionPrc = self.vehicle.actionPrc defaultPrice = self.vehicle.defaultPrice currency = price.getCurrency() buyPriceText = price.get(currency) oldPrice = defaultPrice.get(currency) neededValue = _getNeedValue(price, currency) if isInInventory or not isInInventory and not isUnlocked and not isNextToUnlock: neededValue = None block.append( makePriceBlock( buyPriceText, CURRENCY_SETTINGS.getBuySetting(currency), neededValue, oldPrice, 0, valueWidth=self._valueWidth, ) ) if sellPrice and not self.vehicle.isTelecom: sellPrice = self.vehicle.sellPrice if sellPrice.isSet(Currency.GOLD): sellPriceText = text_styles.gold(_int(sellPrice.gold)) sellPriceIcon = ICON_TEXT_FRAMES.GOLD else: sellPriceText = text_styles.credits(_int(sellPrice.credits)) sellPriceIcon = ICON_TEXT_FRAMES.CREDITS block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(TOOLTIPS.VEHICLE_SELL_PRICE), value=sellPriceText, icon=sellPriceIcon, valueWidth=self._valueWidth, padding=paddings, ) ) if minRentPrice and not self.vehicle.isPremiumIGR: minRentPricePackage = self.vehicle.getRentPackage() if minRentPricePackage: minRentPriceValue = Money(*minRentPricePackage["rentPrice"]) minDefaultRentPriceValue = Money(*minRentPricePackage["defaultRentPrice"]) actionPrc = self.vehicle.getRentPackageActionPrc(minRentPricePackage["days"]) currency = minRentPriceValue.getCurrency() price = minRentPriceValue.get(currency) oldPrice = minDefaultRentPriceValue.get(currency) neededValue = _getNeedValue(minRentPriceValue, currency) block.append( makePriceBlock( price, CURRENCY_SETTINGS.getRentSetting(currency), neededValue, oldPrice, actionPrc, valueWidth=self._valueWidth, ) ) if not self.vehicle.isRented or self.vehicle.rentalIsOver: block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main("#tooltips:vehicle/rentAvailable"), value="", icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=paddings, ) ) if rentals and not self.vehicle.isPremiumIGR: if futureRentals: rentLeftKey = "#tooltips:vehicle/rentLeftFuture/%s" rentInfo = RentalInfoProvider(time=self._rentExpiryTime, isRented=True) else: rentLeftKey = "#tooltips:vehicle/rentLeft/%s" rentInfo = self.vehicle.rentInfo rentFormatter = RentLeftFormatter(rentInfo) rentLeftInfo = rentFormatter.getRentLeftStr( rentLeftKey, formatter=lambda key, countType, count, _=None: { "left": count, "descr": i18n.makeString(key % countType), }, ) if rentLeftInfo: block.append( formatters.packTextParameterWithIconBlockData( name=text_styles.main(rentLeftInfo["descr"]), value=text_styles.main(rentLeftInfo["left"]), icon=ICON_TEXT_FRAMES.RENTALS, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-4, bottom=-16), ) ) notEnoughMoney = neededValue > 0 hasAction = actionPrc > 0 return (block, notEnoughMoney or hasAction)