Exemplo n.º 1
0
 def __setCredits(self, accCredits):
     btnType = LobbyHeader.BUTTONS.CREDITS
     isActionActive = self.itemsCache.items.shop.isCreditsConversionActionActive
     btnData = self._getWalletBtnData(btnType, accCredits,
                                      getBWFormatter(Currency.CREDITS),
                                      isActionActive)
     self.as_updateWalletBtnS(btnType, btnData)
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)
Exemplo n.º 3
0
 def _successHandler(self, code, ctx=None):
     slot = self.__getSlot(self.__slotID)
     if self.__isPaidVehicleSet:
         price = getVehicleChangePrice()
         currency = price.getCurrency()
         amount = int(price.get(currency))
         return self.__makeSuccess(currency, slot, money=getBWFormatter(currency)(amount))
     else:
         return self.__makeSuccess(None, slot) if slot.getVehicle() is not None else super(SetVehicleBranchProcessor, self)._successHandler(code, ctx)
 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()))}
Exemplo n.º 5
0
def formatPrice(price, reverse = False):
    outPrice = []
    currencies = price.getSetCurrencies(byWeight=False)
    if not currencies:
        currencies = [Currency.CREDITS]
    for currency in currencies:
        formatter = getBWFormatter(currency)
        cname = makeString('#menu:price/{}'.format(currency)) + ': '
        cformatted = formatter(price.get(currency)) if formatter else price.get(currency)
        outPrice.append(''.join((cformatted, ' ', cname) if reverse else (cname, ' ', cformatted)))

    return ', '.join(outPrice)
Exemplo n.º 6
0
def moneyWithIcon(money, currType=None):
    if currType is None:
        currType = money.getCurrency()
    style = getattr(text_styles, currType)
    icon = getattr(icons, currType)
    value = money.get(currType)
    formatter = getBWFormatter(currType)
    if style is not None and icon is not None and value is not None:
        return style(formatter(value)) + icon()
    else:
        LOG_ERROR('Unsupported currency for displaying with icon:', currType)
        return formatter(value)
Exemplo n.º 7
0
def formatPrice(price, reverse = False):
    outPrice = []
    currencies = price.getSetCurrencies(byWeight=False)
    if not currencies:
        currencies = [Currency.CREDITS]
    for currency in currencies:
        formatter = getBWFormatter(currency)
        cname = makeString('#menu:price/{}'.format(currency)) + ': '
        cformatted = formatter(price.get(currency)) if formatter else price.get(currency)
        outPrice.append(''.join((cformatted, ' ', cname) if reverse else (cname, ' ', cformatted)))

    return ', '.join(outPrice)
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
     }
Exemplo n.º 10
0
def moneyWithIcon(money, currType=None, statsMoney=None):
    from gui.Scaleform.daapi.view.lobby.store.browser.ingameshop_helpers import isIngameShopEnabled
    if currType is None:
        currType = money.getCurrency()
    if statsMoney and not isIngameShopEnabled() and statsMoney.get(currType) < money.get(currType):
        style = getattr(text_styles, 'error')
    else:
        style = getattr(text_styles, currType)
    icon = getattr(icons, currType)
    value = money.get(currType)
    formatter = getBWFormatter(currType)
    if style is not None and icon is not None and value is not None:
        return style(formatter(value)) + icon()
    else:
        _logger.error('Unsupported currency for displaying with icon: %s', currType)
        return formatter(value)
Exemplo n.º 11
0
def formatPrice(price, reverse=False, currency=Currency.CREDITS, useIcon=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:
        formatter = getBWFormatter(c)
        value = price.get(c, 0)
        cFormatted = formatter(value) if formatter else value
        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)
Exemplo n.º 12
0
 def _buildVO(self):
     actionPriceVO = None
     restorePrice, lengthInHours = getTankmenRestoreInfo(self._tankman)
     warningTexts = []
     if restorePrice.credits == 0:
         restoreCurrency = ICON_TEXT_FRAMES.EMPTY
         restorePriceStr = text_styles.success(_ms(DIALOGS.RESTORETANKMAN_FORFREE))
     else:
         restoreCurrency = ICON_TEXT_FRAMES.CREDITS
         restorePriceStr = str(currency.getBWFormatter(Currency.CREDITS)(restorePrice.credits))
         if self._showPeriodEndWarning:
             daysCount = lengthInHours / time_utils.HOURS_IN_DAY
             warningTexts.append(text_styles.alert(_ms(DIALOGS.RESTORETANKMNAN_NEWPERIODWARNING, daysCount=daysCount)))
         if constants.IS_KOREA and restorePrice.gold > 0:
             warningTexts.append(text_styles.standard(DIALOGS.BUYVEHICLEDIALOG_WARNING))
     return {'questionText': text_styles.stats(_ms(DIALOGS.RESTORETANKMAN_PRICE)),
      'restoreCurrency': restoreCurrency,
      'restorePrice': restorePriceStr,
      'isEnoughMoneyForRestore': g_itemsCache.items.stats.money.credits >= restorePrice.credits,
      'actionPriceVO': actionPriceVO,
      'warningText': '\n\n'.join(warningTexts)}
Exemplo n.º 13
0
 def _buildVO(self):
     actionPriceVO = None
     restorePrice, lengthInHours = getTankmenRestoreInfo(self._tankman)
     warningTexts = []
     if restorePrice.credits == 0:
         restoreCurrency = ICON_TEXT_FRAMES.EMPTY
         restorePriceStr = text_styles.success(
             _ms(DIALOGS.RESTORETANKMAN_FORFREE))
     else:
         restoreCurrency = ICON_TEXT_FRAMES.CREDITS
         restorePriceStr = str(
             currency.getBWFormatter(Currency.CREDITS)(
                 restorePrice.credits))
         if self._showPeriodEndWarning:
             daysCount = lengthInHours / time_utils.HOURS_IN_DAY
             warningTexts.append(
                 text_styles.alert(
                     _ms(DIALOGS.RESTORETANKMAN_NEWPERIODWARNING,
                         daysCount=daysCount)))
         if constants.IS_KOREA and restorePrice.gold > 0:
             warningTexts.append(
                 text_styles.standard(DIALOGS.BUYVEHICLEDIALOG_WARNING))
     if isLongDisconnectedFromCenter():
         warningTexts.append(
             text_styles.error(
                 DIALOGS.RESTORETANKMAN_DISCONNECTEDFROMCENTER))
     return {
         'questionText':
         text_styles.stats(_ms(DIALOGS.RESTORETANKMAN_PRICE)),
         'restoreCurrency':
         restoreCurrency,
         'restorePrice':
         restorePriceStr,
         'isEnoughMoneyForRestore':
         g_itemsCache.items.stats.money.credits >= restorePrice.credits,
         'actionPriceVO':
         actionPriceVO,
         'warningText':
         '\n\n'.join(warningTexts)
     }
 def _buildVO(self):
     actionPriceVO = None
     restorePrice, lengthInHours = getTankmenRestoreInfo(self._tankman)
     warningTexts = []
     if not restorePrice:
         currencyTextFrame = ICON_TEXT_FRAMES.EMPTY
         restorePriceStr = text_styles.success(
             _ms(DIALOGS.RESTORETANKMAN_FORFREE))
         isEnoughMoney = True
     else:
         currencyName = restorePrice.getCurrency()
         currencyTextFrame = self._CURRENCY_TO_TEXT_FRAME[currencyName]
         restorePriceStr = str(
             currency.getBWFormatter(currencyName)(
                 restorePrice.getSignValue(currencyName)))
         isEnoughMoney = self.itemsCache.items.stats.money.get(
             currencyName, 0) >= restorePrice.get(currencyName, 0)
         if self._showPeriodEndWarning and restorePrice.isSet(
                 Currency.GOLD):
             daysCount = lengthInHours / time_utils.HOURS_IN_DAY
             warningTexts.append(
                 text_styles.alert(
                     _ms(DIALOGS.RESTORETANKMAN_NEWPERIODWARNING,
                         daysCount=daysCount)))
         if constants.IS_KOREA and restorePrice.isSet(Currency.GOLD):
             warningTexts.append(
                 text_styles.standard(DIALOGS.BUYVEHICLEDIALOG_WARNING))
     if isLongDisconnectedFromCenter():
         warningTexts.append(
             text_styles.error(
                 DIALOGS.RESTORETANKMAN_DISCONNECTEDFROMCENTER))
     return {
         'questionText':
         text_styles.stats(_ms(DIALOGS.RESTORETANKMAN_PRICE)),
         'restoreCurrency': currencyTextFrame,
         'restorePrice': restorePriceStr,
         'isEnoughMoneyForRestore': isEnoughMoney,
         'actionPriceVO': actionPriceVO,
         'warningText': '\n\n'.join(warningTexts)
     }
Exemplo n.º 15
0
 def __packAwardProgress(self, bonusName, stats, opName):
     acquired, total = stats['acquired'], stats['possible']
     if bonusName not in money.Currency.ALL:
         progressStr = ' / '.join((text_styles.stats(acquired), text_styles.main(total)))
     else:
         progressStr = currency.applyAll(bonusName, acquired)
     if bonusName == 'questsCompleted':
         tooltip = makeTooltip(header=TOOLTIPS.PERSONALMISSIONS_AWARDS_STATS_QUESTSCOMPLETED_HEADER, body=_ms(TOOLTIPS.PERSONALMISSIONS_AWARDS_STATS_QUESTSCOMPLETED_BODY, name=opName, acquired=acquired, excellentAcquired=len(self.getOperation().getFullCompletedQuests()), total=total))
     elif bonusName == 'completionTokens':
         tooltip = makeTooltip(header=TOOLTIPS.PERSONALMISSIONS_AWARDS_STATS_COMPLETIONTOKENS_HEADER, body=_ms(TOOLTIPS.PERSONALMISSIONS_AWARDS_STATS_COMPLETIONTOKENS_BODY, name=opName, acquired=acquired, total=total))
     elif bonusName == 'tankwomanBonus':
         tooltip = makeTooltip(header=TOOLTIPS.PERSONALMISSIONS_AWARDS_STATS_TANKWOMANBONUS_HEADER, body=_ms(TOOLTIPS.PERSONALMISSIONS_AWARDS_STATS_TANKWOMANBONUS_BODY, name=opName, acquired=acquired, total=total))
     else:
         currencyFormatter = currency.getBWFormatter(bonusName)
         tooltip = makeTooltip(header=TOOLTIPS.PERSONALMISSIONS_AWARDS_STATS_CREDITS_HEADER, body=_ms(TOOLTIPS.PERSONALMISSIONS_AWARDS_STATS_CREDITS_BODY, name=opName, acquired=currencyFormatter(acquired), total=currencyFormatter(total)))
     return {'operationId': self.getOperationID(),
      'title': text_styles.highlightText(PERSONAL_MISSIONS.awards_progress_label(bonusName)),
      'progress': progressStr,
      'awardSource': _STATS_ICONS[bonusName],
      'progressBarData': {'value': acquired,
                          'maxValue': total},
      'tooltip': tooltip}
Exemplo n.º 16
0
 def __setCrystal(self, crystals):
     btnType = LobbyHeader.BUTTONS.CRYSTAL
     btnData = self._getWalletBtnData(btnType, crystals,
                                      getBWFormatter(Currency.CRYSTAL),
                                      False, False, False)
     self.as_updateWalletBtnS(btnType, btnData)
Exemplo n.º 17
0
 def __setGold(self, gold):
     btnType = LobbyHeader.BUTTONS.GOLD
     btnData = self._getWalletBtnData(btnType, gold,
                                      getBWFormatter(Currency.GOLD),
                                      isGoldFishActionActive())
     self.as_updateWalletBtnS(btnType, btnData)