def formatPrice(price,
                reverse=False,
                currency=Currency.CREDITS,
                useIcon=False,
                useStyle=False,
                ignoreZeros=False):
    outPrice = []
    currencies = [c for c in Currency.ALL if price.get(c) is not None]
    if not currencies:
        currencies = [currency]
    for c in currencies:
        value = price.get(c, 0)
        if value == 0 and ignoreZeros and not (c == Currency.CREDITS and
                                               not price.getSetCurrencies()):
            continue
        formatter = getBWFormatter(c)
        cFormatted = formatter(value)
        if useStyle:
            styler = getStyle(c)
            cFormatted = styler(cFormatted) if styler else cFormatted
        if useIcon:
            cIdentifier = makeHtmlString('html_templates:lobby/iconText', c)
            cSpace = ' ' if reverse else ''
        else:
            cIdentifier = makeString('#menu:price/{}'.format(c))
            cSpace = ' ' if reverse else ': '
        outPrice.append(''.join((cFormatted, cSpace,
                                 cIdentifier) if reverse else (cIdentifier,
                                                               cSpace,
                                                               cFormatted)))

    return ', '.join(outPrice)
 def __packCompensation(value, currency):
     rBPstr = R.strings.vehicle_preview.buyingPanel
     rIcons = R.images.gui.maps.icons.library
     currencyStyle = getStyle(currency)
     currencyFormatter = getBWFormatter(currency)
     currencyIcon = icons.makeImageTag(backport.image(rIcons.dyn('{}{}'.format(currency.capitalize(), 'Icon_1'))()), vSpace=-2)
     return {'iconInfo': backport.image(rIcons.info_yellow() if currency == Currency.GOLD else rIcons.info()),
      'description': backport.text(rBPstr.compensation()),
      'value': '{} {}'.format(currencyStyle(currencyFormatter(value)), currencyIcon),
      'tooltip': makeTooltip(body=backport.text(rBPstr.compensation.body()))}
def formatExtendedCurrencyValue(currency, value, useStyle=True):
    if currency in _EXTENDED_CURRENCY_TO_BW_FORMATTER:
        bwFormatter = _EXTENDED_CURRENCY_TO_BW_FORMATTER[currency]
    else:
        bwFormatter = getBWFormatter(currency)
    fValue = bwFormatter(value)
    if useStyle:
        if currency in _EXTENDED_CURRENCY_TO_TEXT_STYLE:
            style = _EXTENDED_CURRENCY_TO_TEXT_STYLE[currency]
        else:
            style = getStyle(currency)
        fValue = style(fValue)
    return fValue
 def __packCompensation(value, currency):
     isGold = currency == Currency.GOLD
     currencyFormatter = getBWFormatter(currency)
     currencyStyle = getStyle(currency)
     iconInfo = RES_ICONS.MAPS_ICONS_LIBRARY_INFO_YELLOW if isGold else RES_ICONS.MAPS_ICONS_LIBRARY_INFO
     return {
         'value':
         currencyStyle('-{}'.format(currencyStyle(
             currencyFormatter(value)))),
         'tooltip':
         makeTooltip(body=VEHICLE_PREVIEW.BUYINGPANEL_COMPENSATION_BODY),
         'iconInfo':
         iconInfo
     }
Пример #5
0
 def __makeSetOnOtherSeasonsRendererVO(self):
     activeSeason = SEASON_TYPE_TO_NAME.get(self.__ctx.currentSeason)
     actionBtnLabel = VEHICLE_CUSTOMIZATION.PROPERTYSHEET_ACTIONBTN_APPLYTOALLMAPS
     actionBtnIconSrc = ''
     if self._isItemAppliedToAll:
         actionBtnLabel = VEHICLE_CUSTOMIZATION.PROPERTYSHEET_ACTIONBTN_REMOVE_SEASONS
         actionBtnIconSrc = RES_ICONS.MAPS_ICONS_LIBRARY_ASSET_1
         titleText = text_styles.neutral(
             VEHICLE_CUSTOMIZATION.PROPERTYSHEET_TITLE_ALLMAPS)
         extraPriceCurrency = ''
         extraPriceText = ''
         if self._extraMoney:
             extraPriceCurrency = self._extraMoney.getCurrency()
             if self._extraMoney.get(extraPriceCurrency):
                 extraPriceText = '{}{}'.format(
                     currency.getStyle(extraPriceCurrency)('+'),
                     currency.applyAll(
                         extraPriceCurrency,
                         self._extraMoney.get(extraPriceCurrency)))
     else:
         titleText = text_styles.standard(
             _ms(VEHICLE_CUSTOMIZATION.PROPERTYSHEET_TITLE_APPLIEDTOMAP,
                 mapType=text_styles.neutral(
                     VEHICLE_CUSTOMIZATION.getSheetSeasonName(
                         activeSeason))))
         extraPriceText = ''
         extraPriceCurrency = ''
     return {
         'titleText': titleText,
         'iconSrc': RES_ICONS.getSeasonIcon(activeSeason),
         'actionBtnLabel': actionBtnLabel,
         'actionBtnIconSrc': actionBtnIconSrc,
         'isAppliedToAll': self._isItemAppliedToAll,
         'actionType': CUSTOMIZATION_ALIASES.
         CUSTOMIZATION_SHEET_ACTION_APPLY_TO_ALL_SEASONS,
         'rendererLnk':
         CUSTOMIZATION_ALIASES.CUSTOMIZATION_SHEET_BTN_RENDERER_UI,
         'extraPriceText': extraPriceText,
         'extraPriceIcon': extraPriceCurrency
     }
Пример #6
0
 def __makeSetOnOtherTankPartsRendererVO(self):
     if not self._isItemAppliedToAll:
         currPartName = VEHICLE_CUSTOMIZATION.getSheetVehPartName(
             getCustomizationTankPartName(self._areaID, self._regionID))
         titleText = text_styles.standard(
             _ms(VEHICLE_CUSTOMIZATION.PROPERTYSHEET_TITLE_APPLIEDTO,
                 elementType=text_styles.neutral(currPartName)))
         actionBtnLabel = VEHICLE_CUSTOMIZATION.PROPERTYSHEET_ACTIONBTN_APPLYTOWHOLETANK
         actionBtnIconSrc = ''
         extraPriceText = ''
         extraPriceCurrency = ''
     else:
         titleText = text_styles.neutral(
             VEHICLE_CUSTOMIZATION.PROPERTYSHEET_TITLE_ALLTANKPAINTED)
         actionBtnLabel = VEHICLE_CUSTOMIZATION.PROPERTYSHEET_ACTIONBTN_CANCEL
         actionBtnIconSrc = RES_ICONS.MAPS_ICONS_LIBRARY_ASSET_1
         extraPriceCurrency = ''
         extraPriceText = ''
         if self._extraMoney:
             extraPriceCurrency = self._extraMoney.getCurrency()
             if self._extraMoney.get(extraPriceCurrency):
                 extraPriceText = '{}{}'.format(
                     currency.getStyle(extraPriceCurrency)('+'),
                     currency.applyAll(
                         extraPriceCurrency,
                         self._extraMoney.get(extraPriceCurrency)))
     return {
         'titleText': titleText,
         'iconSrc': RES_ICONS.MAPS_ICONS_CUSTOMIZATION_PROPERTY_SHEET_TANK,
         'actionBtnLabel': actionBtnLabel,
         'actionBtnIconSrc': actionBtnIconSrc,
         'isAppliedToAll': self._isItemAppliedToAll,
         'actionType': CUSTOMIZATION_ALIASES.
         CUSTOMIZATION_SHEET_ACTION_APPLY_TO_ALL_PARTS,
         'rendererLnk':
         CUSTOMIZATION_ALIASES.CUSTOMIZATION_SHEET_BTN_RENDERER_UI,
         'extraPriceText': extraPriceText,
         'extraPriceIcon': extraPriceCurrency
     }