def __makeVO(self, style): styleParams = self.__makeParamsVO(style) styleName = style.userName styleInfoText = style.longDescriptionSpecial styleInfo = text_styles.mainBig( styleInfoText % { 'insertion_open': _INSERTION_OPEN_TAG, 'insertion_close': _INSERTION_CLOSE_TAG }) styleInfoBig = text_styles.mainBig( styleInfoText % { 'insertion_open': _INSERTION_OPEN_TAG_BIG, 'insertion_close': _INSERTION_CLOSE_TAG }) suitableText = getSuitableText(style, g_currentVehicle.item) if suitableText: suitableBlock = text_styles.mainBig( backport.text( R.strings.vehicle_customization.styleInfo.suitable())) suitableBlock += suitableText else: suitableBlock = text_styles.mainBig( backport.text( R.strings.vehicle_customization.styleInfo.suitableAll())) return StyleInfoVO(styleName=styleName, styleInfo=styleInfo, styleInfoBig=styleInfoBig, suitableBlock=suitableBlock, styleParams=styleParams)._asdict()
def _packSuitableBlock(self): customizationTypes = (GUI_ITEM_TYPE.PAINT, GUI_ITEM_TYPE.CAMOUFLAGE, GUI_ITEM_TYPE.MODIFICATION) isItemInStyle = self._item.isStyleOnly or self._item.intCD in getBaseStyleItems( ) isItemHidden = self._item.isHidden mustNotHave = self._item.itemTypeID in customizationTypes mayHave = self._item.itemTypeID in GUI_ITEM_TYPE.CUSTOMIZATIONS and self._item.itemTypeID not in customizationTypes if mustNotHave and (isItemHidden or isItemInStyle ) or mayHave and isItemHidden and isItemInStyle: return None elif self._item.isProgressive and self._item.isProgressionAutoBound or ItemTags.NATIONAL_EMBLEM in self._item.tags: return formatters.packTitleDescBlock( title=text_styles.middleTitle( VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_SUITABLE_TITLE ), desc=text_styles.main(self.__vehicle.shortUserName), padding=formatters.packPadding(top=-2)) elif self._item.isVehicleBound and not self._item.mayApply: return formatters.packTitleDescBlock( title=text_styles.middleTitle( VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_SUITABLE_TITLE ), desc=text_styles.main( makeVehiclesShortNamesString( self.boundVehs | self.installedVehs, self.__vehicle)), padding=formatters.packPadding(top=-2)) elif not self._item.descriptor.filter or not self._item.descriptor.filter.include: return formatters.packTitleDescBlock( title=text_styles.middleTitle( VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_SUITABLE_TITLE ), desc=text_styles.main( backport.text( R.strings.vehicle_customization.customization.tooltip. suitable.text.allVehicle())), padding=formatters.packPadding(top=-2)) else: blocks = [] icn = getSuitableText(self._item, self.__vehicle) blocks.append( formatters.packTextBlockData( text=icn, padding=formatters.packPadding(top=-2))) blocks.insert( 0, formatters.packTitleDescBlock(title=text_styles.middleTitle( VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_SUITABLE_TITLE) )) return formatters.packBuildUpBlockData( blocks=blocks, padding=formatters.packPadding(top=-3))
def getTooltip(self): styleA = getStyleInfo(self._optionA) styleB = getStyleInfo(self._optionB) return None if styleA is None or styleB is None else UndefinedStyleTooltipData(styleA.userName, styleA.texture, getSuitableText(styleA, formatVehicle=False), styleB.userName, styleB.texture, getSuitableText(styleB, formatVehicle=False))
def _getVO(self, item, vehicleCD=None): priceVO = getItemPricesVO(item.getSellPrice())[0] title = item.userName tooltipKey = TOOLTIPS.getItemBoxTooltip(item.itemTypeName) if tooltipKey: title = _ms(tooltipKey, group=item.userType, value=item.userName) if item.itemTypeID == GUI_ITEM_TYPE.PROJECTION_DECAL: formfactor = item.formfactor else: formfactor = '' icon = item.icon levelIcon = '' customizationSuitableText = backport.text( R.strings.storage.customizationSuitable.label()) if vehicleCD is None: if not item.descriptor.filter or not item.descriptor.filter.include: customizationSuitableText = backport.text( R.strings.storage.customizationSuitableForAll.label()) else: customizationSuitableText += getSuitableText(item) count = item.inventoryCount vehicle = None else: vehicle = self._itemsCache.items.getItemByCD(vehicleCD) customizationSuitableText += vehicle.shortUserName count = item.boundInventoryCount(vehicleCD) if item.isProgressive: level = item.getProgressionLevel(vehicle) if level > 0: if item.itemTypeID == GUI_ITEM_TYPE.STYLE: levelIconPath = R.images.gui.maps.icons.customization.progression_styles.icons else: levelIconPath = R.images.gui.maps.icons.customization.progression_icons levelIcon = backport.image( levelIconPath.dyn('level_{}'.format(level))()) if item.itemTypeID == GUI_ITEM_TYPE.PROJECTION_DECAL: icon = item.previewIconUrlByProgressionLevel(level) else: icon = item.iconUrlByProgressionLevel(level) isAvailableForSell = isCustomizationAvailableForSell(item, vehicleCD) isPreviewAvailable = item.itemTypeID == GUI_ITEM_TYPE.STYLE vo = createStorageDefVO(itemID=item.intCD, title=title, description=customizationSuitableText, count=count, price=priceVO if isAvailableForSell else None, image=icon, imageAlt='altimage', contextMenuId=CONTEXT_MENU_HANDLER_TYPE. STORAGE_CUSTOMZIZATION_ITEM, enabled=isAvailableForSell) vo.update({ 'previewAvailable': isPreviewAvailable, 'previewTooltip': backport.text(R.strings.storage.stylePreview.tooltip()), 'progressiveLevelIcon': levelIcon, 'formfactor': formfactor, 'vehicleCD': vehicleCD, 'isWideImage': item.isWide(), 'isRentable': item.isRentable }) return vo