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 _getDurationTypeVO(): durationTypeVOs = [] for duration, (tooltipText, tooltipLowercaseText) in _DURATION_TOOLTIPS.items(): if duration == DURATION.PERMANENT: icon = icons.gold() else: icon = icons.credits() label = '{0}{1}'.format(_ms(tooltipText), icon) tooltip = makeTooltip( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(tooltipText)), _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_BODY, time=_ms(tooltipLowercaseText))) tooltipDisabled = makeTooltip( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(tooltipText)), VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_DISABLED) durationTypeVOs.append({ 'label': label, 'tooltip': tooltip, 'tooltipDisabled': tooltipDisabled }) return durationTypeVOs
def __getGoldToExchangeTxt(self, resToExchange): if resToExchange > 0: goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = ''.join( (text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return text_styles.main( self._makeString(I18N_NEEDGOLDTEXT_KEY, {'gold': fmtGold}))
def __setTotalData(self, *args): if self.__controller.cart.processingMultiplePurchase: return priceGold = self.__controller.cart.totalPriceGold priceCredits = self.__controller.cart.totalPriceCredits notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = self.itemsCache.items.stats.gold >= priceGold enoughCredits = self.itemsCache.items.stats.credits >= priceCredits state = g_currentVehicle.getViewState() canBuy = bool( priceGold or priceCredits ) and enoughGold and enoughCredits and state.isCustomizationEnabled() if not enoughGold: diff = text_styles.gold(priceGold - self.itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(priceCredits - self.itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) inFormationAlert = text_styles.concatStylesWithSpace( icons.markerBlocked(), text_styles.error( VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_FORMATION_ALERT) ) if not state.isCustomizationEnabled() else '' self.as_setTotalDataS({ 'credits': formatPriceCredits(priceCredits), 'gold': formatPriceGold(priceGold), 'totalLabel': text_styles.highTitle( _ms(VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_TOTALCOST, selected=len(self.__searchDP.selectedItems), total=len(self.__searchDP.items))), 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip, 'inFormationAlert': inFormationAlert }) self.as_setBuyBtnEnabledS(canBuy)
def __checkMoney(self): changeRoleCost = self.__items.shop.changeRoleCost formattedPrice = BigWorld.wg_getIntegralFormat(changeRoleCost) actualGold = self.__items.stats.gold enoughGold = actualGold - changeRoleCost >= 0 if enoughGold: priceString = text_styles.gold(formattedPrice) else: priceString = text_styles.error(formattedPrice) priceString += icons.gold() self.as_setPriceS(priceString, enoughGold)
def __checkMoney(self): changeRoleCost = self.__items.shop.changeRoleCost formattedPrice = BigWorld.wg_getIntegralFormat(changeRoleCost) actualGold = self.__items.stats.gold enoughGold = actualGold - changeRoleCost >= 0 if enoughGold: priceString = text_styles.gold(formattedPrice) else: priceString = text_styles.error(formattedPrice) priceString += icons.gold() self.as_setPriceS(priceString, enoughGold)
def __getGoldToExchangeTxt(self, resToExchange): """ :param resToExchange: <int> resource for exchange :return: formatted needed gold to exchange text """ if resToExchange > 0: goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = ''.join( (text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return text_styles.main( self._makeString(I18N_NEEDGOLDTEXT_KEY, {'gold': fmtGold})) return ''
def __setCarouselData(self, blData): itemVOs = [] selectedIndex = -1 for item in blData['items']: element = item['element'] isInQuest = checkInQuest(element, self.__controller.filter.purchaseType) if item['installedInCurrentSlot']: label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_APPLIED) elif element.isInDossier: label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED) elif element.getIgrType() != IGR_TYPE.NONE: if element.getIgrType() == self.igrCtrl.getRoomType(): label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED) else: label = icons.premiumIgrSmall() elif isInQuest: label = icons.quest() else: if item['duration'] == DURATION.PERMANENT: priceFormatter = text_styles.gold priceIcon = icons.gold() else: priceFormatter = text_styles.credits priceIcon = icons.credits() label = priceFormatter('{0}{1}'.format(element.getPrice(item['duration']), priceIcon)) data = {'id': element.getID(), 'icon': element.getTexturePath(), 'label': label, 'selected': item['appliedToCurrentSlot'] or item['installedInCurrentSlot'] and not blData['hasAppliedItem'], 'goToTaskBtnVisible': isInQuest, 'goToTaskBtnText': _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_ITEMCAROUSEL_RENDERER_GOTOTASK), 'newElementIndicatorVisible': item['isNewElement']} if element.qualifier.getValue() > 0: data['bonusType'] = element.qualifier.getIcon16x16() data['bonusPower'] = text_styles.stats('+{0}%{1}'.format(element.qualifier.getValue(), '*' if element.qualifier.getDescription() is not None else '')) if data['selected']: selectedIndex = blData['items'].index(item) if element.isOnSale(item['duration']) and not element.isInDossier and not item['installedInCurrentSlot'] and not isInQuest: data['salePrice'] = getSalePriceString(self.__controller.slots.currentType, element, item['duration']) itemVOs.append(data) carouselLength = len(itemVOs) self.as_setCarouselDataS({'rendererList': itemVOs, 'rendererWidth': blData['rendererWidth'], 'filterCounter': '{0}{1}'.format(text_styles.stats(carouselLength) if carouselLength > 0 else text_styles.error(carouselLength), text_styles.main(_ms(VEHICLE_CUSTOMIZATION.CAROUSEL_FILTER_COUNTER, all=blData['unfilteredLength']))), 'messageVisible': carouselLength == 0, 'counterVisible': True, 'goToIndex': blData['goToIndex'], 'selectedIndex': selectedIndex}) return
def __setCarouselData(self, blData): itemVOs = [] selectedIndex = -1 for item in blData['items']: element = item['element'] isInQuest = checkInQuest(element, self.__controller.filter.purchaseType) if item['installedInCurrentSlot']: label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_APPLIED) elif element.isInDossier: label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED) elif element.getIgrType() != IGR_TYPE.NONE: if element.getIgrType() == getIGRCtrl().getRoomType(): label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED) else: label = icons.premiumIgrSmall() elif isInQuest: label = icons.quest() else: if item['duration'] == DURATION.PERMANENT: priceFormatter = text_styles.gold priceIcon = icons.gold() else: priceFormatter = text_styles.credits priceIcon = icons.credits() label = priceFormatter('{0}{1}'.format(element.getPrice(item['duration']), priceIcon)) data = {'id': element.getID(), 'icon': element.getTexturePath(), 'bonusType': element.qualifier.getIcon16x16(), 'bonusPower': text_styles.stats('+{0}%{1}'.format(element.qualifier.getValue(), '*' if element.qualifier.getDescription() is not None else '')), 'label': label, 'selected': item['appliedToCurrentSlot'] or item['installedInCurrentSlot'] and not blData['hasAppliedItem'], 'goToTaskBtnVisible': isInQuest, 'goToTaskBtnText': _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_ITEMCAROUSEL_RENDERER_GOTOTASK), 'newElementIndicatorVisible': item['isNewElement']} if data['selected']: selectedIndex = blData['items'].index(item) if element.isOnSale(item['duration']) and not element.isInDossier and not item['installedInCurrentSlot'] and not isInQuest: data['salePrice'] = getSalePriceString(self.__controller.slots.currentType, element, item['duration']) itemVOs.append(data) carouselLength = len(itemVOs) self.as_setCarouselDataS({'rendererList': itemVOs, 'rendererWidth': blData['rendererWidth'], 'filterCounter': '{0}{1}'.format(text_styles.stats(carouselLength) if carouselLength > 0 else text_styles.error(carouselLength), text_styles.main(_ms(VEHICLE_CUSTOMIZATION.CAROUSEL_FILTER_COUNTER, all=blData['unfilteredLength']))), 'messageVisible': carouselLength == 0, 'counterVisible': True, 'goToIndex': blData['goToIndex'], 'selectedIndex': selectedIndex}) return
def __setCarouselData(self, blData): itemVOs = [] for item in blData['items']: enable = True if item['installedInSlot']: label = text_styles.main(CUSTOMIZATION.CAROUSEL_ITEMLABEL_APPLIED) elif item['isInDossier']: label = text_styles.main(CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED) elif item['object'].getIgrType() != IGR_TYPE.NONE: if item['object'].getIgrType() == getIGRCtrl().getRoomType(): label = text_styles.main(CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED) else: label = icons.premiumIgrSmall() enable = False else: if item['priceIsGold']: priceFormatter = text_styles.gold priceIcon = icons.gold() else: priceFormatter = text_styles.credits priceIcon = icons.credits() label = priceFormatter('{0}{1}'.format(item['price'], priceIcon)) data = {'id': item['id'], 'icon': item['object'].getTexturePath(), 'bonusType': item['object'].qualifier.getIcon16x16(), 'bonusPower': text_styles.stats('+{0}%{1}'.format(item['object'].qualifier.getValue(), '*' if item['object'].qualifier.getDescription() is not None else '')), 'label': label, 'installed': item['appliedToCurrentSlot'], 'btnSelect': self.__getLabelOfSelectBtn(item), 'btnShoot': VEHICLE_CUSTOMIZATION.CUSTOMIZATIONITEMCAROUSEL_RENDERER_SHOOT, 'btnTooltip': item['buttonTooltip'], 'btnSelectEnable': enable, 'doubleclickEnable': enable, 'btnShootEnable': True} cType = g_customizationController.carousel.currentType if isSale(cType, item['duration']) and not item['isInDossier'] and not item['installedInSlot']: isGold = item['priceIsGold'] data['salePrice'] = getSalePriceString(isGold, item['price']) itemVOs.append(data) carouselLength = len(itemVOs) self.as_setCarouselDataS({'rendererList': itemVOs, 'rendererWidth': blData['rendererWidth'], 'filterCounter': '{0}{1}'.format(text_styles.stats(carouselLength) if carouselLength > 0 else text_styles.error(carouselLength), text_styles.main(_ms(VEHICLE_CUSTOMIZATION.CAROUSEL_FILTER_COUNTER, all=blData['unfilteredLength']))), 'messageVisible': carouselLength == 0, 'counterVisible': True, 'goToIndex': blData['goToIndex'], 'selectedIndex': blData['selectedIndex']}) return
def __setBottomPanelData(self, *args): if self.__isCarouselHidden: occupiedSlotsNum, totalSlotsNum = self.__controller.slots.getSummary( ) label = text_styles.highTitle( _ms(VEHICLE_CUSTOMIZATION.TYPESWITCHSCREEN_SLOTSUMMARY, occupiedSlotsNum=occupiedSlotsNum, totalSlotsNum=totalSlotsNum)) else: label = text_styles.middleTitle( _ms('#vehicle_customization:typeSwitchScreen/typeName/plural/{0}' .format(self.__controller.slots.currentType))) totalGold = self.__controller.cart.totalPriceGold totalCredits = self.__controller.cart.totalPriceCredits notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = g_itemsCache.items.stats.gold >= totalGold enoughCredits = g_itemsCache.items.stats.credits >= totalCredits if not enoughGold: diff = text_styles.gold(totalGold - g_itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(totalCredits - g_itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) self.as_setBottomPanelHeaderS({ 'newHeaderText': label, 'buyBtnLabel': _ms(MENU.CUSTOMIZATION_BUTTONS_APPLY, count=len(self.__controller.cart.items)), 'pricePanel': { 'totalPriceCredits': formatPriceCredits(totalCredits), 'totalPriceGold': formatPriceGold(totalGold), 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip } })
def __getState(self, resToExchange): if resToExchange <= 0: return (CONFIRM_EXCHANGE_DIALOG_TYPES.EXCHANGE_NOT_NEEED_STATE, text_styles.success( self._makeString(I18N_EXCHANGENONEEDTEXT_KEY))) if not self.__isEnoughGold(resToExchange): goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = ''.join( (text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return (CONFIRM_EXCHANGE_DIALOG_TYPES.NOT_ENOUGH_GOLD_STATE, text_styles.error( self._makeString(I18N_GOLDNOTENOUGHTEXT_KEY, {'gold': fmtGold}))) return (CONFIRM_EXCHANGE_DIALOG_TYPES.NORMAL_STATE, '')
def _getDurationTypeVO(): durationTypeVOs = [] for duration, (tooltipText, tooltipLowercaseText) in _DURATION_TOOLTIPS.items(): if duration == DURATION.PERMANENT: icon = icons.gold() else: icon = icons.credits() label = '{0}{1}'.format(_ms(tooltipText), icon) tooltip = makeTooltip(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(tooltipText)), _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_BODY, time=_ms(tooltipLowercaseText))) tooltipDisabled = makeTooltip(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(tooltipText)), VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_DISABLED) durationTypeVOs.append({'label': label, 'tooltip': tooltip, 'tooltipDisabled': tooltipDisabled}) return durationTypeVOs
def __setTotalData(self, *args): priceGold = self.__controller.cart.totalPriceGold priceCredits = self.__controller.cart.totalPriceCredits notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = g_itemsCache.items.stats.gold >= priceGold enoughCredits = g_itemsCache.items.stats.credits >= priceCredits canBuy = bool(priceGold or priceCredits) and enoughGold and enoughCredits if not enoughGold: diff = text_styles.gold(priceGold - g_itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(priceCredits - g_itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) self.as_setTotalDataS({ 'credits': formatPriceCredits(priceCredits), 'gold': formatPriceGold(priceGold), 'totalLabel': text_styles.highTitle( _ms(VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_TOTALCOST, selected=len(self.__searchDP.selectedItems), total=len(self.__searchDP.items))), 'buyEnabled': canBuy, 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip })
def __getRentButtonLabel(rootNode): btnLabel = '' if NODE_STATE.isRentAvailable(rootNode.getState()): minRentPrice, currency = rootNode.getRentInfo() if currency == Currency.CREDITS: btnLabel = text_styles.concatStylesWithSpace( backport.text( R.strings.menu.research.labels.button.rent()), text_styles.credits( backport.getIntegralFormat(minRentPrice.credits)), icons.credits()) elif currency == Currency.GOLD: btnLabel = text_styles.concatStylesWithSpace( backport.text( R.strings.menu.research.labels.button.rent()), text_styles.gold(backport.getGoldFormat( minRentPrice.gold)), icons.gold()) return btnLabel
def __checkMoney(self): changeRoleCost = self.itemsCache.items.shop.changeRoleCost defaultChangeRoleCost = self.itemsCache.items.shop.defaults.changeRoleCost if changeRoleCost != defaultChangeRoleCost: discount = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'changeRoleCost', True, Money(gold=changeRoleCost), Money(gold=defaultChangeRoleCost)) else: discount = None formattedPrice = backport.getIntegralFormat(changeRoleCost) actualGold = self.itemsCache.items.stats.gold enoughGold = actualGold - changeRoleCost >= 0 style = text_styles.gold if enoughGold else text_styles.error self.as_setPriceS(priceString='{}{}'.format(style(formattedPrice), icons.gold()), actionChangeRole=discount) return
def __setTotalData(self): notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = g_itemsCache.items.stats.gold >= self.__totalPrice['gold'] enoughCredits = g_itemsCache.items.stats.credits >= self.__totalPrice[ 'credits'] buyEnabled = bool( self.__totalPrice['credits'] + self.__totalPrice['gold']) and enoughGold and enoughCredits if not enoughGold: diff = text_styles.gold(self.__totalPrice['gold'] - g_itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip( _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(self.__totalPrice['credits'] - g_itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip( _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) self.as_setTotalDataS({ 'credits': formatPriceCredits(self.__totalPrice['credits']), 'gold': formatPriceGold(self.__totalPrice['gold']), 'totalLabel': text_styles.highTitle( _ms(CUSTOMIZATION.WINDOW_PURCHASE_TOTALCOST, selected=len(self.__searchDP.getSelected()), total=len(self.__searchDP.getTotal()))), 'buyEnabled': buyEnabled, 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip })
def __getState(self, resToExchange): """ Gets state and reason for exchange possibility :param resToExchange: <int> resource for exchange :return: <tuple(state:<int>, reason<str>)> """ if resToExchange <= 0: return (CONFIRM_EXCHANGE_DIALOG_TYPES.EXCHANGE_NOT_NEEED_STATE, text_styles.success( self._makeString(I18N_EXCHANGENONEEDTEXT_KEY))) if not self.__isEnoughGold(resToExchange): goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = ''.join( (text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return (CONFIRM_EXCHANGE_DIALOG_TYPES.NOT_ENOUGH_GOLD_STATE, text_styles.error( self._makeString(I18N_GOLDNOTENOUGHTEXT_KEY, {'gold': fmtGold}))) return (CONFIRM_EXCHANGE_DIALOG_TYPES.NORMAL_STATE, '')
def __checkMoney(self): changeRoleCost = self.itemsCache.items.shop.changeRoleCost defaultChangeRoleCost = self.itemsCache.items.shop.defaults.changeRoleCost if changeRoleCost != defaultChangeRoleCost: discount = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'changeRoleCost', True, Money(gold=changeRoleCost), Money(gold=defaultChangeRoleCost)) else: discount = None formattedPrice = BigWorld.wg_getIntegralFormat(changeRoleCost) actualGold = self.itemsCache.items.stats.gold enoughGold = actualGold - changeRoleCost >= 0 if enoughGold: priceString = text_styles.gold(formattedPrice) else: priceString = text_styles.error(formattedPrice) priceString += icons.gold() self.as_setPriceS(priceString, enoughGold, discount) return
def setProxy(self, proxy, clanDossier): proxy.showWaiting() provinces = yield clanDossier.requestProvinces() showTreasury = clanDossier.isMyClan() and self.clanCtrl.getLimits( ).canSeeTreasury(clanDossier).success hasProvinces = len(provinces) > 0 if self.isDisposed(): return headers = self._prepareHeaders(showTreasury, hasProvinces) if showTreasury: listItemRendererLinkage = CLANS_ALIASES.CLAN_PROFILE_SELF_PROVINCE_RENDERER else: listItemRendererLinkage = CLANS_ALIASES.CLAN_PROFILE_PROVINCE_RENDERER data = { 'rendererLinkage': listItemRendererLinkage, 'headers': headers, 'isListVisible': hasProvinces, 'noDataText': text_styles.highTitle(_ms(CLANS.GLOBALMAPVIEW_NOPROVINCE)), 'isNoDataTextVisible': not hasProvinces } if hasProvinces: data['defaultSortField'] = _SORT_IDS.PROVINCE data['defaultSortDirection'] = 'ascending' self.as_setDataS(data) self.__provincesDP = _ClanProfileProvinceDataProvider(showTreasury) self.__provincesDP.setFlashObject(self.as_getDPS()) self.__provincesDP.buildList(provinces) self.as_setAdditionalTextS( hasProvinces and showTreasury, text_styles.standard( _ms(CLANS.GLOBALMAPVIEW_TOTALINCOME, icon=icons.gold(), value=text_styles.gold( backport.getIntegralFormat( self.__provincesDP.getCommonRevenue()))))) proxy.hideWaiting()
def __setBottomPanelData(self): if self.__carouselHidden: label = g_customizationController.carousel.slots.getSummaryString() else: label = g_customizationController.carousel.slots.getCurrentTypeLabel( ) totalGold = g_customizationController.carousel.slots.cart.totalPriceGold totalCredits = g_customizationController.carousel.slots.cart.totalPriceCredits notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = g_itemsCache.items.stats.gold >= totalGold enoughCredits = g_itemsCache.items.stats.credits >= totalCredits if not enoughGold: diff = text_styles.gold(totalGold - g_itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip( _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(totalCredits - g_itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip( _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) self.as_setBottomPanelHeaderS({ 'newHeaderText': label, 'buyBtnLabel': _ms(MENU.CUSTOMIZATION_BUTTONS_APPLY, count=len( g_customizationController.carousel.slots.cart.items)), 'pricePanel': { 'totalPriceCredits': formatPriceCredits(totalCredits), 'totalPriceGold': formatPriceGold(totalGold), 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip } })
def setProxy(self, proxy, clanDossier): proxy.showWaiting() provinces = yield clanDossier.requestProvinces() showTreasury = clanDossier.isMyClan() and g_clanCtrl.getLimits().canSeeTreasury(clanDossier).success hasProvinces = len(provinces) > 0 if self.isDisposed(): return headers = self._prepareHeaders(showTreasury, hasProvinces) if showTreasury: listItemRendererLinkage = CLANS_ALIASES.CLAN_PROFILE_SELF_PROVINCE_RENDERER else: listItemRendererLinkage = CLANS_ALIASES.CLAN_PROFILE_PROVINCE_RENDERER data = { "rendererLinkage": listItemRendererLinkage, "headers": headers, "isListVisible": hasProvinces, "noDataText": text_styles.highTitle(_ms(CLANS.GLOBALMAPVIEW_NOPROVINCE)), "isNoDataTextVisible": not hasProvinces, } if hasProvinces: data["defaultSortField"] = _SORT_IDS.PROVINCE data["defaultSortDirection"] = "ascending" self.as_setDataS(data) self.__provincesDP = _ClanProfileProvinceDataProvider(showTreasury) self.__provincesDP.setFlashObject(self.as_getDPS()) self.__provincesDP.buildList(provinces) self.as_setAdditionalTextS( hasProvinces and showTreasury, text_styles.standard( _ms( CLANS.GLOBALMAPVIEW_TOTALINCOME, icon=icons.gold(), value=text_styles.gold(BigWorld.wg_getIntegralFormat(self.__provincesDP.getCommonRevenue())), ) ), ) proxy.hideWaiting()
def _packWayToBuyBlock(self, item): subBlocks = [formatters.packTextBlockData(text=text_styles.middleTitle(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_TOOLTIP_WAYTOBUY_TITLE)), padding={'bottom': 6})] padding = {'left': 0} for buyItem in item['buyItems']: buyItemDesc = text_styles.main(buyItem['desc']) if buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_FOREVER: if buyItem['isSale']: subBlocks.append(formatters.packSaleTextParameterBlockData(name=buyItemDesc, saleData={'newPrice': (0, buyItem['value'])}, padding=padding)) else: price = text_styles.concatStylesWithSpace(text_styles.gold(BigWorld.wg_getIntegralFormat(long(buyItem['value']))), icons.gold()) subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_TEMP: if buyItem['isSale']: subBlocks.append(formatters.packSaleTextParameterBlockData(name=buyItemDesc, saleData={'newPrice': (buyItem['value'], 0)}, padding=padding)) else: price = text_styles.concatStylesWithSpace(text_styles.credits(BigWorld.wg_getIntegralFormat(long(buyItem['value']))), icons.credits()) subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_IGR: subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=icons.premiumIgrSmall(), padding=padding)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_MISSION: subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=icons.quest(), padding=padding)) return formatters.packBuildUpBlockData(subBlocks, 0, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_LINKAGE, {'left': 3})
def __getGoldToExchangeTxt(self, resToExchange): """ :param resToExchange: <int> resource for exchange :return: formatted needed gold to exchange text """ if resToExchange > 0: goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = "".join((text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return text_styles.main(self._makeString(I18N_NEEDGOLDTEXT_KEY, {"gold": fmtGold})) return ""
def __getGoldValueWithIcon(self, gold): return ''.join( text_styles.gold(BigWorld.wg_getGoldFormat(gold)) + icons.gold())
def _packWayToBuyBlock(self, data): subBlocks = [formatters.packTextBlockData(text=text_styles.middleTitle(_ms('#vehicle_customization:customization/tooltip/wayToBuy/title')), padding={'bottom': 6})] for buyItem in data['buyItems']: buyItemDesc = text_styles.main(buyItem['desc']) if buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_MISSION: subBlocks.append(formatters.packImageTextBlockData(desc=buyItemDesc, img=RES_ICONS.MAPS_ICONS_LIBRARY_QUEST_ICON, imgPadding={'left': 53, 'top': 3}, txtGap=-4, txtOffset=73)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_FOREVER: if buyItem['isSale']: subBlocks.append(formatters.packSaleTextParameterBlockData(name=buyItemDesc, saleData={'newPrice': (0, buyItem['value'])}, padding={'left': 0})) else: price = text_styles.concatStylesWithSpace(text_styles.gold(BigWorld.wg_getIntegralFormat(long(buyItem['value']))), icons.gold()) subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_TEMP: if buyItem['isSale']: subBlocks.append(formatters.packSaleTextParameterBlockData(name=buyItemDesc, saleData={'newPrice': (buyItem['value'], 0)}, padding={'left': 0})) else: price = text_styles.concatStylesWithSpace(text_styles.credits(BigWorld.wg_getIntegralFormat(long(buyItem['value']))), icons.credits()) subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_IGR: subBlocks.append(formatters.packTextParameterBlockData(name=buyItemDesc, value=icons.premiumIgrSmall(), padding={'left': 0})) return formatters.packBuildUpBlockData(subBlocks, 0, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_LINKAGE, {'left': 3})
def __setCarouselInitData(self): self.as_setCarouselInitS({ 'icoFilter': RES_ICONS.MAPS_ICONS_BUTTONS_FILTER, 'durationType': [ self.__getDurationTypeVO( '{0}{1}'.format( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_ALWAYS), icons.gold()), makeTooltip( _ms(TOOLTIPS. CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_ALWAYS)), _ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_BODY, time=_ms( VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_LOWERCASE_ALWAYS) )), makeTooltip( _ms(TOOLTIPS. CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_ALWAYS)), VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_DISABLED)), self.__getDurationTypeVO( '{0}{1}'.format( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_MONTH), icons.credits()), makeTooltip( _ms(TOOLTIPS. CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_MONTH)), _ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_BODY, time=_ms( VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_LOWERCASE_MONTH)) ), makeTooltip( _ms(TOOLTIPS. CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_MONTH)), VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_DISABLED)), self.__getDurationTypeVO( '{0}{1}'.format( _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_WEEK), icons.credits()), makeTooltip( _ms(TOOLTIPS. CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_WEEK)), _ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_BODY, time=_ms( VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_LOWERCASE_WEEK)) ), makeTooltip( _ms(TOOLTIPS. CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_WEEK)), VEHICLE_CUSTOMIZATION. CUSTOMIZATION_FILTER_DURATION_DISABLED)) ], 'durationSelectIndex': 0, 'onlyPurchased': True, 'icoPurchased': RES_ICONS.MAPS_ICONS_FILTERS_PRESENCE, 'message': '{2}{0}\n{1}'.format( text_styles.neutral( VEHICLE_CUSTOMIZATION.CAROUSEL_MESSAGE_HEADER), text_styles.main( VEHICLE_CUSTOMIZATION.CAROUSEL_MESSAGE_DESCRIPTION), icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED, 16, 16, -3, 0)), 'fitterTooltip': makeTooltip(TOOLTIPS.CUSTOMIZATION_CAROUSEL_FILTER_HEADER, TOOLTIPS.CUSTOMIZATION_CAROUSEL_FILTER_BODY), 'chbPurchasedTooltip': makeTooltip(TOOLTIPS.CUSTOMIZATION_CAROUSEL_CHBPURCHASED_HEADER, TOOLTIPS.CUSTOMIZATION_CAROUSEL_CHBPURCHASED_BODY) })
def __setBottomPanelData(self): if self.__carouselHidden: label = g_customizationController.carousel.slots.getSummaryString() else: label = g_customizationController.carousel.slots.getCurrentTypeLabel() totalGold = g_customizationController.carousel.slots.cart.totalPriceGold totalCredits = g_customizationController.carousel.slots.cart.totalPriceCredits notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = g_itemsCache.items.stats.gold >= totalGold enoughCredits = g_itemsCache.items.stats.credits >= totalCredits if not enoughGold: diff = text_styles.gold(totalGold - g_itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(totalCredits - g_itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) self.as_setBottomPanelHeaderS({'newHeaderText': label, 'buyBtnLabel': _ms(MENU.CUSTOMIZATION_BUTTONS_APPLY, count=len(g_customizationController.carousel.slots.cart.items)), 'pricePanel': {'totalPriceCredits': formatPriceCredits(totalCredits), 'totalPriceGold': formatPriceGold(totalGold), 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip}})
def __setCarouselData(self, blData): itemVOs = [] for item in blData['items']: if item['installedInSlot']: label = text_styles.main( CUSTOMIZATION.CAROUSEL_ITEMLABEL_APPLIED) elif item['isInDossier']: label = text_styles.main( CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED) elif item['object'].getIgrType() != IGR_TYPE.NONE: if item['object'].getIgrType() == getIGRCtrl().getRoomType(): label = text_styles.main( CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED) else: label = icons.premiumIgrSmall() elif item['isInQuests']: label = icons.quest() else: if item['priceIsGold']: priceFormatter = text_styles.gold priceIcon = icons.gold() else: priceFormatter = text_styles.credits priceIcon = icons.credits() label = priceFormatter('{0}{1}'.format(item['price'], priceIcon)) data = { 'id': item['id'], 'icon': item['object'].getTexturePath(), 'bonusType': item['object'].qualifier.getIcon16x16(), 'bonusPower': text_styles.stats('+{0}%{1}'.format( item['object'].qualifier.getValue(), '*' if item['object'].qualifier.getDescription() is not None else '')), 'label': label, 'selected': item['appliedToCurrentSlot'], 'goToTaskBtnVisible': item['isInQuests'], 'goToTaskBtnText': _ms(VEHICLE_CUSTOMIZATION. CUSTOMIZATION_ITEMCAROUSEL_RENDERER_GOTOTASK), 'newElementIndicatorVisible': False } cType = g_customizationController.carousel.currentType if item['object'].isSale( item['duration']) and not item['isInDossier'] and not item[ 'installedInSlot'] and not item['isInQuests']: data['salePrice'] = getSalePriceString(cType, item['object'], item['duration']) itemVOs.append(data) carouselLength = len(itemVOs) self.as_setCarouselDataS({ 'rendererList': itemVOs, 'rendererWidth': blData['rendererWidth'], 'filterCounter': '{0}{1}'.format( text_styles.stats(carouselLength) if carouselLength > 0 else text_styles.error(carouselLength), text_styles.main( _ms(VEHICLE_CUSTOMIZATION.CAROUSEL_FILTER_COUNTER, all=blData['unfilteredLength']))), 'messageVisible': carouselLength == 0, 'counterVisible': True, 'goToIndex': blData['goToIndex'], 'selectedIndex': blData['selectedIndex'] }) return
def __setBottomPanelData(self, *args): if self.__isCarouselHidden: occupiedSlotsNum, totalSlotsNum = self.__controller.slots.getSummary() label = text_styles.highTitle(_ms(VEHICLE_CUSTOMIZATION.TYPESWITCHSCREEN_SLOTSUMMARY, occupiedSlotsNum=occupiedSlotsNum, totalSlotsNum=totalSlotsNum)) else: label = text_styles.middleTitle(_ms('#vehicle_customization:typeSwitchScreen/typeName/plural/{0}'.format(self.__controller.slots.currentType))) totalGold = self.__controller.cart.totalPriceGold totalCredits = self.__controller.cart.totalPriceCredits notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = g_itemsCache.items.stats.gold >= totalGold enoughCredits = g_itemsCache.items.stats.credits >= totalCredits if not enoughGold: diff = text_styles.gold(totalGold - g_itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(totalCredits - g_itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) self.as_setBottomPanelHeaderS({'newHeaderText': label, 'buyBtnLabel': _ms(MENU.CUSTOMIZATION_BUTTONS_APPLY, count=len(self.__controller.cart.items)), 'pricePanel': {'totalPriceCredits': formatPriceCredits(totalCredits), 'totalPriceGold': formatPriceGold(totalGold), 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip}})
def __setCarouselInitData(self): self.as_setCarouselInitS({'icoFilter': RES_ICONS.MAPS_ICONS_BUTTONS_FILTER, 'durationType': [self.__getDurationTypeVO('{0}{1}'.format(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_ALWAYS), icons.gold()), makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_ALWAYS)), _ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_BODY, time=_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_LOWERCASE_ALWAYS))), makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_ALWAYS)), VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_DISABLED)), self.__getDurationTypeVO('{0}{1}'.format(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_MONTH), icons.credits()), makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_MONTH)), _ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_BODY, time=_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_LOWERCASE_MONTH))), makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_MONTH)), VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_DISABLED)), self.__getDurationTypeVO('{0}{1}'.format(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_WEEK), icons.credits()), makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_WEEK)), _ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_BODY, time=_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_LOWERCASE_WEEK))), makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_CAROUSEL_DURATIONTYPE_HEADER, time=_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_WEEK)), VEHICLE_CUSTOMIZATION.CUSTOMIZATION_FILTER_DURATION_DISABLED))], 'durationSelectIndex': 0, 'onlyPurchased': True, 'icoPurchased': RES_ICONS.MAPS_ICONS_FILTERS_PRESENCE, 'message': '{2}{0}\n{1}'.format(text_styles.neutral(VEHICLE_CUSTOMIZATION.CAROUSEL_MESSAGE_HEADER), text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_MESSAGE_DESCRIPTION), icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED, 16, 16, -3, 0)), 'fitterTooltip': makeTooltip(TOOLTIPS.CUSTOMIZATION_CAROUSEL_FILTER_HEADER, TOOLTIPS.CUSTOMIZATION_CAROUSEL_FILTER_BODY), 'chbPurchasedTooltip': makeTooltip(TOOLTIPS.CUSTOMIZATION_CAROUSEL_CHBPURCHASED_HEADER, TOOLTIPS.CUSTOMIZATION_CAROUSEL_CHBPURCHASED_BODY)})
def __setTotalData(self, *args): priceGold = self.__controller.cart.totalPriceGold priceCredits = self.__controller.cart.totalPriceCredits notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = g_itemsCache.items.stats.gold >= priceGold enoughCredits = g_itemsCache.items.stats.credits >= priceCredits canBuy = bool(priceGold or priceCredits) and enoughGold and enoughCredits if not enoughGold: diff = text_styles.gold(priceGold - g_itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(priceCredits - g_itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) self.as_setTotalDataS({'credits': formatPriceCredits(priceCredits), 'gold': formatPriceGold(priceGold), 'totalLabel': text_styles.highTitle(_ms(VEHICLE_CUSTOMIZATION.WINDOW_PURCHASE_TOTALCOST, selected=len(self.__searchDP.selectedItems), total=len(self.__searchDP.items))), 'buyEnabled': canBuy, 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip})
def __getGoldValueWithIcon(self, gold): return "".join(text_styles.gold(BigWorld.wg_getGoldFormat(gold)) + icons.gold())
def __getState(self, resToExchange): """ Gets state and reason for exchange possibility :param resToExchange: <int> resource for exchange :return: <tuple(state:<int>, reason<str>)> """ if resToExchange <= 0: return ( CONFIRM_EXCHANGE_DIALOG_TYPES.EXCHANGE_NOT_NEEED_STATE, text_styles.success(self._makeString(I18N_EXCHANGENONEEDTEXT_KEY)), ) elif not self.__isEnoughGold(resToExchange): goldToExchange = self.__getGoldToExchange(resToExchange) fmtGold = "".join((text_styles.gold(BigWorld.wg_getGoldFormat(goldToExchange)), icons.gold())) return ( CONFIRM_EXCHANGE_DIALOG_TYPES.NOT_ENOUGH_GOLD_STATE, text_styles.error(self._makeString(I18N_GOLDNOTENOUGHTEXT_KEY, {"gold": fmtGold})), ) else: return (CONFIRM_EXCHANGE_DIALOG_TYPES.NORMAL_STATE, "")
def __setBuyingPanelData(self): totalGold = g_customizationController.carousel.slots.cart.totalPriceGold totalCredits = g_customizationController.carousel.slots.cart.totalPriceCredits notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = g_itemsCache.items.stats.gold >= totalGold enoughCredits = g_itemsCache.items.stats.credits >= totalCredits if not enoughGold: diff = text_styles.gold(totalGold - g_itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(totalCredits - g_itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) self.as_setBuyingPanelDataS({'totalPriceCredits': formatPriceCredits(totalCredits), 'totalPriceGold': formatPriceGold(totalGold), 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip})
def __setTotalData(self): notEnoughGoldTooltip = notEnoughCreditsTooltip = '' enoughGold = g_itemsCache.items.stats.gold >= self.__totalPrice['gold'] enoughCredits = g_itemsCache.items.stats.credits >= self.__totalPrice['credits'] buyEnabled = bool(self.__totalPrice['credits'] + self.__totalPrice['gold']) and enoughGold and enoughCredits if not enoughGold: diff = text_styles.gold(self.__totalPrice['gold'] - g_itemsCache.items.stats.gold) notEnoughGoldTooltip = makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.gold()))) if not enoughCredits: diff = text_styles.credits(self.__totalPrice['credits'] - g_itemsCache.items.stats.credits) notEnoughCreditsTooltip = makeTooltip(_ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_HEADER), _ms(TOOLTIPS.CUSTOMIZATION_NOTENOUGHRESOURCES_BODY, count='{0}{1}'.format(diff, icons.credits()))) self.as_setTotalDataS({'credits': formatPriceCredits(self.__totalPrice['credits']), 'gold': formatPriceGold(self.__totalPrice['gold']), 'totalLabel': text_styles.highTitle(_ms(CUSTOMIZATION.WINDOW_PURCHASE_TOTALCOST, selected=len(self.__searchDP.getSelected()), total=len(self.__searchDP.getTotal()))), 'buyEnabled': buyEnabled, 'enoughGold': enoughGold, 'enoughCredits': enoughCredits, 'notEnoughGoldTooltip': notEnoughGoldTooltip, 'notEnoughCreditsTooltip': notEnoughCreditsTooltip})
def _packWayToBuyBlock(self, data): subBlocks = [ formatters.packTextBlockData(text=text_styles.middleTitle( _ms('#vehicle_customization:customization/tooltip/wayToBuy/title' )), padding={'bottom': 6}) ] for buyItem in data['buyItems']: buyItemDesc = text_styles.main(buyItem['desc']) if buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_MISSION: subBlocks.append( formatters.packImageTextBlockData( desc=buyItemDesc, img=RES_ICONS.MAPS_ICONS_LIBRARY_QUEST_ICON, imgPadding={ 'left': 53, 'top': 3 }, txtGap=-4, txtOffset=73)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_FOREVER: if buyItem['isSale']: subBlocks.append( formatters.packSaleTextParameterBlockData( name=buyItemDesc, saleData={'newPrice': (0, buyItem['value'])}, padding={'left': 0})) else: price = text_styles.concatStylesWithSpace( text_styles.gold( BigWorld.wg_getIntegralFormat( long(buyItem['value']))), icons.gold()) subBlocks.append( formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_TEMP: if buyItem['isSale']: subBlocks.append( formatters.packSaleTextParameterBlockData( name=buyItemDesc, saleData={'newPrice': (buyItem['value'], 0)}, padding={'left': 0})) else: price = text_styles.concatStylesWithSpace( text_styles.credits( BigWorld.wg_getIntegralFormat( long(buyItem['value']))), icons.credits()) subBlocks.append( formatters.packTextParameterBlockData(name=buyItemDesc, value=price, valueWidth=70)) elif buyItem['type'] == BUY_ITEM_TYPE.WAYS_TO_BUY_IGR: subBlocks.append( formatters.packTextParameterBlockData( name=buyItemDesc, value=icons.premiumIgrSmall(), padding={'left': 0})) return formatters.packBuildUpBlockData( subBlocks, 0, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_LINKAGE, {'left': 3})
def setProxy(self, proxy, clanDossier): proxy.showWaiting() provinces = yield clanDossier.requestProvinces() isMyClan = clanDossier.isMyClan() hasProvinces = len(provinces) > 0 if self.isDisposed(): return headers = self._prepareHeaders(clanDossier.isMyClan(), hasProvinces) if isMyClan: listItemRendererLinkage = CLANS_ALIASES.CLAN_PROFILE_SELF_PROVINCE_RENDERER else: listItemRendererLinkage = CLANS_ALIASES.CLAN_PROFILE_PROVINCE_RENDERER data = {'rendererLinkage': listItemRendererLinkage, 'headers': headers, 'isListVisible': hasProvinces, 'additionalText': text_styles.standard(_ms(CLANS.GLOBALMAPVIEW_TOTALINCOME, icon=icons.gold(), value=text_styles.gold(BigWorld.wg_getIntegralFormat(sum(map(operator.methodcaller('getRevenue'), provinces)))))), 'isAdditionalTextVisible': hasProvinces and isMyClan, 'noDataText': text_styles.highTitle(_ms(CLANS.GLOBALMAPVIEW_NOPROVINCE)), 'isNoDataTextVisible': not hasProvinces} if hasProvinces: data['defaultSortField'] = _SORT_IDS.PROVINCE data['defaultSortDirection'] = 'ascending' self.as_setDataS(data) self.__provincesDP = _ClanProfileProvinceDataProvider(isMyClan) self.__provincesDP.setFlashObject(self.as_getDPS()) self.__provincesDP.buildList(provinces) proxy.hideWaiting()