Beispiel #1
0
 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))
Beispiel #2
0
 def __getResearchPageBlueprintLabel(rootNode):
     bpfProps = rootNode.getBpfProps()
     label = ''
     if bpfProps is not None:
         if bpfProps.filledCount != bpfProps.totalCount:
             values = text_styles.main(
                 backport.text(R.strings.blueprints.blueprintProgressBar.
                               inProgress.values()).format(
                                   current=text_styles.credits(
                                       str(bpfProps.filledCount)),
                                   total=str(bpfProps.totalCount)))
             label = text_styles.credits(
                 backport.text(R.strings.blueprints.blueprintProgressBar.
                               inProgress()).format(values=values))
         else:
             label = text_styles.concatStylesWithSpace(
                 icons.makeImageTag(backport.image(
                     R.images.gui.maps.icons.blueprints.blueCheck()),
                                    width=16,
                                    height=16,
                                    vSpace=-1),
                 text_styles.credits(
                     backport.text(R.strings.blueprints.
                                   blueprintProgressBar.complete())))
     return label
Beispiel #3
0
 def __formatFragmentProgress(self, current, total, discount):
     return text_styles.alignText(
         ''.join((text_styles.credits(backport.getIntegralFormat(current)),
                  text_styles.main(''.join(
                      (' / ', backport.getIntegralFormat(total)))),
                  text_styles.credits(''.join(
                      ('   ', backport.getIntegralFormat(discount),
                       '%'))) if discount > 0 else '')), 'right')
Beispiel #4
0
 def getAdditionalText(self):
     if self.__nextXp is not None:
         expCount = '%s<nobr>%s' % (BigWorld.wg_getIntegralFormat(self.__nextXp), icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICON, 18, 18, -8, 0))
         additionalText = _ms(MENU.AWARDWINDOW_REFERRAL_NEXTTANKMAN, expCount=text_styles.credits(expCount))
     else:
         additionalText = ''
     return text_styles.main(additionalText)
Beispiel #5
0
 def construct(self):
     module = self.module
     block = []
     title = module.userName
     imgPaddingLeft = 27
     imgPaddingTop = 0
     txtOffset = 130 - self.leftPadding
     desc = ''
     if module.itemTypeName in VEHICLE_COMPONENT_TYPE_NAMES:
         desc = text_styles.concatStylesWithSpace(text_styles.stats(_ms(TOOLTIPS.level(str(module.level)))), text_styles.standard(_ms(TOOLTIPS.VEHICLE_LEVEL)))
         imgPaddingLeft = 22
     elif module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS:
         imgPaddingLeft = 7
         imgPaddingTop = 5
         txtOffset = 90 - self.leftPadding
         moduleParams = params_helper.getParameters(module)
         weightUnits = text_styles.standard(TOOLTIPS.PARAMETER_WEIGHTUNITS)
         paramName = ModuleTooltipBlockConstructor.WEIGHT_MODULE_PARAM
         paramValue = params_formatters.formatParameter(paramName, moduleParams[paramName]) if paramName in moduleParams else None
         if paramValue is not None:
             desc = text_styles.main(TOOLTIPS.PARAMETER_WEIGHT) + text_styles.credits(paramValue) + weightUnits
     else:
         desc = text_styles.standard(desc)
     overlayPath, overlayPadding, blockPadding = self.__getOverlayData()
     block.append(formatters.packItemTitleDescBlockData(title=text_styles.highTitle(title), desc=desc, img=module.icon, imgPadding=formatters.packPadding(left=imgPaddingLeft, top=imgPaddingTop), txtGap=-3, txtOffset=txtOffset, padding=blockPadding, overlayPath=overlayPath, overlayPadding=overlayPadding))
     if module.itemTypeID == GUI_ITEM_TYPE.GUN:
         vehicle = self.configuration.vehicle
         vDescr = vehicle.descriptor if vehicle is not None else None
         if module.isClipGun(vDescr):
             block.append(formatters.packImageTextBlockData(title=text_styles.standard(MENU.MODULEINFO_CLIPGUNLABEL), desc='', img=RES_ICONS.MAPS_ICONS_MODULES_MAGAZINEGUNICON, imgPadding=formatters.packPadding(top=3), padding=formatters.packPadding(left=108, top=9)))
     elif module.itemTypeID == GUI_ITEM_TYPE.CHASSIS:
         if module.isHydraulicChassis():
             block.append(formatters.packImageTextBlockData(title=text_styles.standard(MENU.MODULEINFO_HYDRAULICCHASSISLABEL), desc='', img=RES_ICONS.MAPS_ICONS_MODULES_HYDRAULICCHASSISICON, imgPadding=formatters.packPadding(top=3), padding=formatters.packPadding(left=108, top=9)))
     return block
Beispiel #6
0
    def __getPurchaseItemVO(self, items):
        purchaseItems = []
        for item in items:
            if item['currencyIcon'] == RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2:
                price = text_styles.credits(item['price'])
            else:
                price = text_styles.gold(item['price'])
            data = {
                'name': text_styles.main(item['name']),
                'idx': item['idx'],
                'type': item['type'],
                'isTitle': False,
                'currencyIcon': item['currencyIcon'],
                'itemID': item['itemID'],
                'price': price,
                'removeItemIcon': RES_ICONS.MAPS_ICONS_LIBRARY_CROSS
            }
            if shared.isSale(item['type'], item['duration']):
                isGold = item[
                    'currencyIcon'] != RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2
                data['salePrice'] = shared.getSalePriceString(
                    isGold, item['price'])
            purchaseItems.append(data)

        return {
            'title':
            text_styles.highTitle(
                _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATIONPURCHASESPOPOVER_TITLE,
                    count=len(purchaseItems))),
            'popoverRenderers':
            purchaseItems
        }
 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}})
Beispiel #8
0
 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 = self.itemsCache.items.stats.gold >= totalGold
     enoughCredits = self.itemsCache.items.stats.credits >= totalCredits
     if not enoughGold:
         diff = text_styles.gold(totalGold - 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(totalCredits - 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())))
     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}})
Beispiel #9
0
 def getAdditionalText(self):
     if self.__nextXp is not None:
         expCount = '%s<nobr>%s' % (BigWorld.wg_getIntegralFormat(self.__nextXp), icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICON, 18, 18, -8, 0))
         additionalText = _ms(MENU.AWARDWINDOW_REFERRAL_NEXTTANKMAN, expCount=text_styles.credits(expCount))
     else:
         additionalText = ''
     return text_styles.main(additionalText)
    def __makeTableData(self):
        ms = i18n.makeString
        result = []
        refSystem = game_control.g_instance.refSystem
        referrals = refSystem.getReferrals()
        numOfReferrals = len(referrals)
        for i, item in enumerate(referrals):
            referralNumber = text_styles.stats(ms('%d.' % (i + 1)))
            dbID = item.getAccountDBID()
            user = self.usersStorage.getUser(dbID)
            if not user:
                raise AssertionError('User must be defined')
                contactConverter = ContactConverter()
                contactData = contactConverter.makeVO(user)
                xpIcon = RES_ICONS.MAPS_ICONS_LIBRARY_NORMALXPICON
                icon = icons.makeImageTag(xpIcon, 16, 16, -3, 0)
                bonus, timeLeft = item.getBonus()
                if bonus == 1:
                    multiplier = '-'
                    multiplierTooltip = TOOLTIPS.REFERRALMANAGEMENTWINDOW_MULTIPLIER_X1
                    icon = ''
                else:
                    multiplier = 'x%s' % BigWorld.wg_getNiceNumberFormat(bonus)
                    multiplierTooltip = ''
                if timeLeft:
                    multiplierTime = text_styles.main(ms(item.getBonusTimeLeftStr()))
                    expMultiplierText = text_styles.standard(ms(MENU.REFERRALMANAGEMENTWINDOW_REFERRALSTABLE_LEFTTIME, time=multiplierTime))
                else:
                    expMultiplierText = ''
                multiplierFactor = text_styles.credits(multiplier)
                multiplierStr = ms(icon + '<nobr>' + multiplierFactor + ' ' + expMultiplierText)
                referralData = {'accID': dbID,
                 'fullName': user.getFullName(),
                 'userName': user.getName(),
                 'clanAbbrev': user.getClanAbbrev()}
                canInviteToSquad = self.prbFunctional.getEntityType() in (PREBATTLE_TYPE.NONE, PREBATTLE_TYPE.TRAINING) or self.prbFunctional.getEntityType() == PREBATTLE_TYPE.SQUAD and self.prbFunctional.getPermissions().canSendInvite()
                btnEnabled = canInviteToSquad or False
                btnTooltip = TOOLTIPS.REFERRALMANAGEMENTWINDOW_CREATESQUADBTN_DISABLED_SQUADISFULL
            else:
                btnEnabled = True
                btnTooltip = TOOLTIPS.REFERRALMANAGEMENTWINDOW_CREATESQUADBTN_ENABLED
            result.append({'isEmpty': False,
             'contactData': contactData,
             'referralNo': referralNumber,
             'referralVO': referralData,
             'exp': BigWorld.wg_getNiceNumberFormat(item.getXPPool()),
             'multiplier': multiplierStr,
             'multiplierTooltip': multiplierTooltip,
             'btnEnabled': btnEnabled,
             'btnTooltip': btnTooltip})

        if numOfReferrals < self.MIN_REF_NUMBER:
            for i in xrange(numOfReferrals, self.MIN_REF_NUMBER):
                referralNumber = text_styles.disabled(ms(MENU.REFERRALMANAGEMENTWINDOW_REFERRALSTABLE_EMPTYLINE, lineNo=str(i + 1)))
                result.append({'isEmpty': True,
                 'referralNo': referralNumber})

        self.as_setTableDataS(result)
Beispiel #11
0
 def __makeModulePurchaseVO(self, item, unlockProps, creditPrice):
     formattedPrice = BigWorld.wg_getIntegralFormat(creditPrice) + icons.credits()
     return {'title': _ms(BATTLE_RESULTS.COMMON_FITTING_PURCHASE),
      'description': text_styles.main(item.userName),
      'fittingType': item.itemTypeName,
      'lvlIcon': getLevelIconPath(item.level),
      'price': text_styles.credits(formattedPrice),
      'linkEvent': PROGRESS_ACTION.PURCHASE_UNLOCK_TYPE,
      'linkId': unlockProps.parentID}
Beispiel #12
0
 def __makeVehiclePurchaseVO(self, item, unlockProps, creditPrice):
     formattedPrice = BigWorld.wg_getIntegralFormat(creditPrice) + icons.credits()
     return {'title': _ms(BATTLE_RESULTS.COMMON_VEHICLE_PURCHASE),
      'description': self.__makeVehicleDescription(item),
      'vehicleIcon': item.iconSmall,
      'lvlIcon': getLevelIconPath(item.level),
      'price': text_styles.credits(formattedPrice),
      'linkEvent': PROGRESS_ACTION.PURCHASE_UNLOCK_TYPE,
      'linkId': unlockProps.parentID}
Beispiel #13
0
 def getDescription(self):
     creditsCount = '%s<nobr>%s' % (
         text_styles.credits(
             BigWorld.wg_getIntegralFormat(self.__creditsValue)),
         icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2, 16,
                            16, -4, 0))
     return text_styles.main(
         _ms(MENU.AWARDWINDOW_REFERRAL_CREDITS_DESCRIPTION,
             credits=creditsCount))
 def __makeModulePurchaseVO(self, item, unlockProps, creditPrice):
     formattedPrice = BigWorld.wg_getIntegralFormat(creditPrice) + icons.credits()
     return {'title': _ms(BATTLE_RESULTS.COMMON_FITTING_PURCHASE),
      'description': text_styles.main(item.userName),
      'fittingType': item.itemTypeName,
      'lvlIcon': getLevelIconPath(item.level),
      'price': text_styles.credits(formattedPrice),
      'linkEvent': PROGRESS_ACTION.PURCHASE_UNLOCK_TYPE,
      'linkId': unlockProps.parentID}
 def __makeVehiclePurchaseVO(self, item, unlockProps, creditPrice):
     formattedPrice = BigWorld.wg_getIntegralFormat(creditPrice) + icons.credits()
     return {'title': _ms(BATTLE_RESULTS.COMMON_VEHICLE_PURCHASE),
      'description': self.__makeVehicleDescription(item),
      'vehicleIcon': item.iconSmall,
      'lvlIcon': getLevelIconPath(item.level),
      'price': text_styles.credits(formattedPrice),
      'linkEvent': PROGRESS_ACTION.PURCHASE_UNLOCK_TYPE,
      'linkId': unlockProps.parentID}
    def __makeTableData(self):
        ms = i18n.makeString
        result = []
        refSystem = game_control.g_instance.refSystem
        referrals = refSystem.getReferrals()
        numOfReferrals = len(referrals)
        for i, item in enumerate(referrals):
            referralNumber = text_styles.stats(ms('%d.' % (i + 1)))
            dbID = item.getAccountDBID()
            user = self.usersStorage.getUser(dbID)
            if not user:
                raise AssertionError('User must be defined')
                isOnline = user.isOnline()
                xpIcon = RES_ICONS.MAPS_ICONS_LIBRARY_NORMALXPICON
                icon = icons.makeImageTag(xpIcon, 16, 16, -3, 0)
                bonus, timeLeft = item.getBonus()
                if bonus == 1:
                    multiplier = '-'
                    multiplierTooltip = TOOLTIPS.REFERRALMANAGEMENTWINDOW_MULTIPLIER_X1
                    icon = ''
                else:
                    multiplier = 'x%s' % BigWorld.wg_getNiceNumberFormat(bonus)
                    multiplierTooltip = ''
                if timeLeft:
                    multiplierTime = text_styles.main(ms(item.getBonusTimeLeftStr()))
                    expMultiplierText = text_styles.standard(ms(MENU.REFERRALMANAGEMENTWINDOW_REFERRALSTABLE_LEFTTIME, time=multiplierTime))
                else:
                    expMultiplierText = ''
                multiplierFactor = text_styles.credits(multiplier)
                multiplierStr = ms(icon + '<nobr>' + multiplierFactor + ' ' + expMultiplierText)
                referralData = {'accID': dbID,
                 'fullName': user.getFullName(),
                 'userName': user.getName(),
                 'clanAbbrev': user.getClanAbbrev()}
                canInviteToSquad = self.prbFunctional.getEntityType() in (PREBATTLE_TYPE.NONE, PREBATTLE_TYPE.TRAINING) or self.prbFunctional.getEntityType() == PREBATTLE_TYPE.SQUAD and self.prbFunctional.getPermissions().canSendInvite()
                btnEnabled = canInviteToSquad or False
                btnTooltip = TOOLTIPS.REFERRALMANAGEMENTWINDOW_CREATESQUADBTN_DISABLED_SQUADISFULL
            else:
                btnEnabled = True
                btnTooltip = TOOLTIPS.REFERRALMANAGEMENTWINDOW_CREATESQUADBTN_ENABLED
            result.append({'isEmpty': False,
             'isOnline': isOnline,
             'referralNo': referralNumber,
             'referralVO': referralData,
             'exp': BigWorld.wg_getNiceNumberFormat(item.getXPPool()),
             'multiplier': multiplierStr,
             'multiplierTooltip': multiplierTooltip,
             'btnEnabled': btnEnabled,
             'btnTooltip': btnTooltip})

        if numOfReferrals < self.MIN_REF_NUMBER:
            for i in xrange(numOfReferrals, self.MIN_REF_NUMBER):
                referralNumber = text_styles.disabled(ms(MENU.REFERRALMANAGEMENTWINDOW_REFERRALSTABLE_EMPTYLINE, lineNo=str(i + 1)))
                result.append({'isEmpty': True,
                 'referralNo': referralNumber})

        self.as_setTableDataS(result)
Beispiel #17
0
 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)
Beispiel #18
0
    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 __pushSuccessMessage(self):
     if self.__hasActiveChapter:
         textRes = R.strings.system_messages.battlePass.switchChapter.success(
         )
         messageType = SM_TYPE.BattlePassSwitchChapter
     else:
         textRes = R.strings.system_messages.battlePass.activateChapter.success(
         )
         messageType = SM_TYPE.BattlePassActivateChapter
     chapterName = backport.text(
         R.strings.battle_pass.chapter.dyn(
             self.__battlePassController.getRewardType(
                 self.__chapterID).value).fullName.num(self.__chapterID)())
     SystemMessages.pushMessage(backport.text(
         textRes, chapter=text_styles.credits(chapterName)),
                                type=messageType)
Beispiel #20
0
 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
     })
Beispiel #21
0
 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})
Beispiel #22
0
 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
Beispiel #23
0
 def update(self, *args):
     self._personalQuestID = None
     if self._currentVehicle.isPresent():
         vehicle = self._currentVehicle.item
         bonuses = self._newYearController.getBonusesForNation(
             vehicle.nationID)
         bonus = int(bonuses[0] * 100.0) if bonuses else 0
         setting = self._newYearController.getSettingForNation(
             vehicle.nationID)
         headerVO = {
             'tankType':
             '{}_elite'.format(vehicle.type)
             if vehicle.isElite else vehicle.type,
             'tankInfo':
             text_styles.concatStylesToMultiLine(
                 text_styles.promoSubTitle(vehicle.shortUserName),
                 text_styles.stats(MENU.levels_roman(vehicle.level))),
             'bonusName':
             '{} {}'.format(text_styles.credits(NY.HANGAR_BONUSINFO),
                            vehicle.shortUserName),
             'bonusCount':
             text_styles.bonusLocalText('+{}%'.format(bonus)),
             'bonusSetting':
             setting,
             'isPremIGR':
             vehicle.isPremiumIGR,
             'isBeginner':
             False,
             'isVehicle':
             True
         }
         headerVO.update(self.__getBattleQuestsVO(vehicle))
         headerVO.update(self.__getPersonalQuestsVO(vehicle))
         headerVO.update(self.__getElenQuestsVO(vehicle))
     else:
         headerVO = {'isVehicle': False}
     headerVO.update({
         'isNYEnabled': self._newYearController.isAvailable(),
         'isNyActive': self._newYearController.isAvailable(),
         'bonusLevel': self._newYearController.getProgress().level,
         'isVisible': True
     })
     self.as_setDataS(headerVO)
     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})
Beispiel #25
0
 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
     })
Beispiel #26
0
 def __setPremiumBonusData(self):
     value = ''
     icon = backport.image(
         R.images.gui.maps.icons.premacc.battleResult.premium())
     piggyBankConfig = self.__lobbyContext.getServerSettings(
     ).getPiggyBankConfig()
     piggyBankMaxAmount = piggyBankConfig.get('creditsThreshold', 0)
     period = piggyBankConfig.get('cycleLength', time_utils.ONE_DAY)
     periodInDays = ceil(period / time_utils.ONE_DAY)
     bonusConfig = self.__lobbyContext.getServerSettings(
     ).getAdditionalBonusConfig()
     multiplier = premacc_helpers.validateAdditionalBonusMultiplier(
         bonusConfig.get('bonusFactor', 1))
     if not self.__itemsCache.items.stats.isActivePremium(
             PREMIUM_TYPE.PLUS):
         if self.__itemsCache.items.stats.isActivePremium(
                 PREMIUM_TYPE.BASIC):
             value = backport.text(
                 R.strings.battle_results.common.details.premiumPlus.dyn(
                     self.__adsCase)(),
                 bonusCredits=text_styles.concatStylesToSingleLine(
                     text_styles.credits(
                         backport.getGoldFormat(piggyBankMaxAmount)),
                     icons.makeImageTag(backport.image(
                         R.images.gui.maps.icons.library.CreditsIcon_2()),
                                        vSpace=-5)),
                 durationInDays=periodInDays,
                 multiplier=multiplier)
             iconName = 'bonus_x{}'.format(
                 multiplier
             ) if self.__adsCase == 'bonus' else self.__adsCase
             icon = backport.image(
                 R.images.gui.maps.icons.premacc.battleResult.dyn(iconName)
                 ())
         elif self.__creditsDiff < 0 or self.__xpDiff < 0:
             value = backport.text(R.strings.battle_results.common.details.
                                   premiumPlus.premium())
         else:
             value = backport.text(
                 R.strings.battle_results.common.premiumBonus())
     self.premiumBonusStr = value
     self.backgroundIcon = icon
 def _successHandler(self, code, ctx=None):
     chapterName = backport.text(
         R.strings.battle_pass.chapter.dyn(
             self.__battlePassController.getRewardType(
                 self.__chapterID).value).fullName.num(self.__chapterID)())
     return makeSuccess(
         msgType=SM_TYPE.BattlePassBuy,
         userMsg='',
         auxData={
             'header':
             backport.text(R.strings.messenger.serviceChannelMessages.
                           battlePassReward.header.buyBP()),
             'description':
             backport.text(R.strings.messenger.serviceChannelMessages.
                           battlePassReward.buyWithoutRewards.text(),
                           chapter=text_styles.credits(chapterName)),
             'additionalText':
             self.__makeGoldString(
                 self.__battlePassController.getBattlePassCost(
                     self.__chapterID).get(Currency.GOLD, 0))
         })
 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})
Beispiel #29
0
 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 __getPurchaseItemVO(self, items):
        purchaseItems = []
        for item in items:
            if item['currencyIcon'] == RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2:
                price = text_styles.credits(item['price'])
            else:
                price = text_styles.gold(item['price'])
            data = {'name': text_styles.main(item['name']),
             'idx': item['idx'],
             'type': item['type'],
             'isTitle': False,
             'currencyIcon': item['currencyIcon'],
             'itemID': item['itemID'],
             'price': price,
             'removeItemIcon': RES_ICONS.MAPS_ICONS_LIBRARY_CROSS}
            if shared.isSale(item['type'], item['duration']):
                isGold = item['currencyIcon'] != RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2
                data['salePrice'] = shared.getSalePriceString(isGold, item['price'])
            purchaseItems.append(data)

        return {'title': text_styles.highTitle(_ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATIONPURCHASESPOPOVER_TITLE, count=len(purchaseItems))),
         'popoverRenderers': purchaseItems}
Beispiel #31
0
    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})
Beispiel #32
0
def _getValue(base, self):
    valueStr = '0'
    if self._btnType == CURRENCIES_CONSTANTS.GOLD:
        valueStr = text_styles.gold(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualGold, 0)))
    elif self._btnType == CURRENCIES_CONSTANTS.CREDITS:
        valueStr = text_styles.credits(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualCredits, 0)))
    elif self._btnType == CURRENCIES_CONSTANTS.CRYSTAL:
        valueStr = text_styles.crystal(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualCrystal, 0)))
    elif self._btnType == CURRENCIES_CONSTANTS.EVENT_COIN:
        valueStr = text_styles.eventCoin(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualEventCoin, 0)))
    elif self._btnType == CURRENCIES_CONSTANTS.FREE_XP:
        valueStr = text_styles.expText(
            backport.getIntegralFormat(
                max(self.itemsCache.items.stats.actualFreeXP, 0)))
    return valueStr
Beispiel #33
0
 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}})
Beispiel #34
0
 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
Beispiel #35
0
 def __getCreditsString(self, creditsType):
     result = self.getWGMCurrencyValue(creditsType)
     return text_styles.credits(
         result) if result != _WAITING_FOR_DATA else result
Beispiel #36
0
    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)
Beispiel #37
0
    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)
Beispiel #38
0
def _makeRecoveryPeriodText(restoreInfo):
    price, timeLeft = restoreInfo
    timeStr = formatRecoveryLeftValue(timeLeft)
    if price.credits == 0:
        return text_styles.main(timeStr)
    return text_styles.credits(timeStr)
Beispiel #39
0
 def getDescription(self):
     creditsCount = '%s<nobr>%s' % (text_styles.credits(BigWorld.wg_getIntegralFormat(self.__creditsValue)), icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2, 16, 16, -4, 0))
     return text_styles.main(_ms(MENU.AWARDWINDOW_REFERRAL_CREDITS_DESCRIPTION, credits=creditsCount))
Beispiel #40
0
 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 _packBlocks(self, *args, **kwargs):
     tooltipBlocks = super(WGMCreditsCurrencyTooltip, self)._packBlocks(*args, **kwargs)
     currencyBlocks = list()
     currencyBlocks.append(formatters.packTitleDescBlock(text_styles.middleTitle(TOOLTIPS.HEADER_BUTTONS_CREDITS_HEADER), text_styles.main(TOOLTIPS.HEADER_BUTTONS_CREDITS_BODY), padding=formatters.packPadding(bottom=21)))
     currencyBlocks.append(formatters.packTextBlockData(text_styles.middleTitle(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_CREDITSNAME), padding=formatters.packPadding(bottom=6)))
     currencyBlocks.append(formatters.packDashLineItemPriceBlockData(text_styles.main(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_PURCHASEDVALUE), self.__getCreditsString(wgm_balance_info_requester.CREDITS_PURCHASED), RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2, padding=formatters.packPadding(bottom=-1)))
     currencyBlocks.append(formatters.packDashLineItemPriceBlockData(text_styles.main(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_EARNEDVALUE), self.__getCreditsString(wgm_balance_info_requester.CREDITS_EARNED), RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2, padding=formatters.packPadding(bottom=16)))
     currencyBlocks.append(formatters.packDashLineItemPriceBlockData(text_styles.main(TOOLTIPS.HANGAR_HEADER_WGMONEYTOOLTIP_TOTALVALUE), text_styles.credits(self.__getCreditsTotal()), RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2))
     tooltipBlocks.append(formatters.packBuildUpBlockData(currencyBlocks))
     return tooltipBlocks
    def __makeProgresData(self):
        totalXP = self.refSystem.getTotalXP()
        currentXP = self.refSystem.getReferralsXPPool()
        progressText = '%(currentXP)s / %(totalXP)s %(icon)s' % {
            'currentXP':
            text_styles.credits(BigWorld.wg_getIntegralFormat(currentXP)),
            'totalXP':
            BigWorld.wg_getIntegralFormat(totalXP),
            'icon':
            icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_NORMALXPICON, 16,
                               16, -3, 0)
        }
        text = i18n.makeString(
            MENU.REFERRALMANAGEMENTWINDOW_PROGRESSINDICATOR_PROGRESS,
            progress=progressText)
        awardData = {}
        progresData = {'text': text_styles.main(text)}
        progressAlertText = ''
        if self.refSystem.isTotallyCompleted():
            completedText = i18n.makeString(
                MENU.REFERRALMANAGEMENTWINDOW_PROGRESSINDICATOR_COMPLETE)
            completedText = text_styles.middleTitle(completedText)
            awardData['completedText'] = completedText
            _, lastStepQuests = self.refSystem.getQuests()[-1]
            vehicleBonus = findFirst(lambda q: q.getBonuses('vehicles'),
                                     reversed(lastStepQuests))
            vehicleBonusIcon = ''
            if vehicleBonus is not None:
                vehicleBonusIcon = vehicleBonus.getBonuses(
                    'vehicles')[0].getTooltipIcon()
            awardData['completedImage'] = vehicleBonusIcon
        else:
            stepsData = []
            progress = 0.0
            quests = self.refSystem.getQuests()
            totalQuestsCount = len(
                tuple(itertools.chain(*dict(quests).values())))
            if quests and totalQuestsCount == self.TOTAL_QUESTS:
                currentCompletedStep = -1
                totalSteps = len(quests)
                lastStep = totalSteps - 1
                for i, (xp, events) in enumerate(quests):
                    notCompleted = filter(lambda q: not q.isCompleted(),
                                          reversed(events))
                    lastNotCompleted = findFirst(None, notCompleted)
                    if lastNotCompleted is not None:
                        questIDs = map(methodcaller('getID'), notCompleted)
                        icon = self.__getBonusIcon(lastNotCompleted)
                    else:
                        questIDs = map(methodcaller('getID'), events)
                        icon = RES_ICONS.MAPS_ICONS_LIBRARY_COMPLETE
                        currentCompletedStep = i
                    stepsData.append({
                        'id': pickle.dumps((xp, questIDs)),
                        'icon': icon
                    })

                nextStep = min(currentCompletedStep + 1, lastStep)
                nextStepXP, _ = quests[nextStep]
                if currentXP:
                    totalProgress = 0.0
                    currentCompletedStepXP = 0
                    oneStepWeight = 1.0 / totalSteps
                    if currentCompletedStep != -1:
                        currentCompletedStepXP, _ = quests[
                            currentCompletedStep]
                        totalProgress = (currentCompletedStep +
                                         1) * oneStepWeight
                    xpForNextStep = nextStepXP - currentCompletedStepXP
                    xpFromPrevStep = currentXP - currentCompletedStepXP
                    if xpForNextStep <= 0:
                        stepProgress = 1.0
                    elif xpFromPrevStep <= 0:
                        stepProgress = 0.0
                    else:
                        stepProgress = float(xpFromPrevStep) / xpForNextStep
                    totalStepProgress = stepProgress * oneStepWeight
                    progress = totalProgress + totalStepProgress
            else:
                LOG_WARNING('Referral quests is in invalid state: ', quests)
                progressAlertIcon = icons.alert()
                progressAlertText = text_styles.alert(
                    i18n.makeString(
                        MENU.REFERRALMANAGEMENTWINDOW_PROGRESSNOTAVAILABLE))
                progressAlertText = i18n.makeString(progressAlertIcon + ' ' +
                                                    progressAlertText)
            progresData.update({'steps': stepsData, 'progress': progress})
        if progressAlertText != '':
            self.as_showAlertS(progressAlertText)
        elif self.refSystem.isTotallyCompleted():
            self.as_setAwardDataDataS(awardData)
        else:
            self.as_setProgressDataS(progresData)
        return
Beispiel #43
0
 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
Beispiel #44
0
 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)
Beispiel #45
0
 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)
Beispiel #46
0
def formatCreditPrice(value):
    value = BigWorld.wg_getIntegralFormat(value)
    icon = gui_icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2,
                                  vSpace=-4)
    return '{} {}'.format(text_styles.credits(value), icon)
Beispiel #47
0
def _makeRecoveryPeriodText(restoreInfo):
    price, timeLeft = restoreInfo
    timeStr = formatRecoveryLeftValue(timeLeft)
    if price.credits == 0:
        return text_styles.main(timeStr)
    return text_styles.credits(timeStr)
    def __makeProgresData(self):
        refSystem = game_control.g_instance.refSystem
        totalXP = refSystem.getTotalXP()
        currentXP = refSystem.getReferralsXPPool()
        progressText = '%(currentXP)s / %(totalXP)s %(icon)s' % {'currentXP': text_styles.credits(BigWorld.wg_getIntegralFormat(currentXP)),
         'totalXP': BigWorld.wg_getIntegralFormat(totalXP),
         'icon': icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_NORMALXPICON, 16, 16, -3, 0)}
        text = i18n.makeString(MENU.REFERRALMANAGEMENTWINDOW_PROGRESSINDICATOR_PROGRESS, progress=progressText)
        awardData = {}
        progresData = {'text': text_styles.main(text)}
        progressAlertText = ''
        if refSystem.isTotallyCompleted():
            completedText = i18n.makeString(MENU.REFERRALMANAGEMENTWINDOW_PROGRESSINDICATOR_COMPLETE)
            completedText = text_styles.middleTitle(completedText)
            awardData['completedText'] = completedText
            _, lastStepQuests = refSystem.getQuests()[-1]
            vehicleBonus = findFirst(lambda q: q.getBonuses('vehicles'), reversed(lastStepQuests))
            vehicleBonusIcon = ''
            if vehicleBonus is not None:
                vehicleBonusIcon = vehicleBonus.getBonuses('vehicles')[0].getTooltipIcon()
            awardData['completedImage'] = vehicleBonusIcon
        else:
            stepsData = []
            progress = 0.0
            quests = refSystem.getQuests()
            totalQuestsCount = len(tuple(itertools.chain(*dict(quests).values())))
            if quests and totalQuestsCount == self.TOTAL_QUESTS:
                currentCompletedStep = -1
                totalSteps = len(quests)
                lastStep = totalSteps - 1
                for i, (xp, events) in enumerate(quests):
                    notCompleted = filter(lambda q: not q.isCompleted(), reversed(events))
                    lastNotCompleted = findFirst(None, notCompleted)
                    if lastNotCompleted is not None:
                        questIDs = map(methodcaller('getID'), notCompleted)
                        icon = self.__getBonusIcon(lastNotCompleted)
                    else:
                        questIDs = map(methodcaller('getID'), events)
                        icon = RES_ICONS.MAPS_ICONS_LIBRARY_COMPLETE
                        currentCompletedStep = i
                    stepsData.append({'id': pickle.dumps((xp, questIDs)),
                     'icon': icon})

                nextStep = min(currentCompletedStep + 1, lastStep)
                nextStepXP, _ = quests[nextStep]
                if currentXP:
                    totalProgress = 0.0
                    currentCompletedStepXP = 0
                    oneStepWeight = 1.0 / totalSteps
                    if currentCompletedStep != -1:
                        currentCompletedStepXP, _ = quests[currentCompletedStep]
                        totalProgress = (currentCompletedStep + 1) * oneStepWeight
                    xpForNextStep = nextStepXP - currentCompletedStepXP
                    xpFromPrevStep = currentXP - currentCompletedStepXP
                    stepProgress = float(xpFromPrevStep) / xpForNextStep if xpFromPrevStep else 0.0
                    totalStepProgress = stepProgress * oneStepWeight
                    progress = totalProgress + totalStepProgress
            else:
                LOG_WARNING('Referral quests is in invalid state: ', quests)
                progressAlertIcon = icons.alert()
                progressAlertText = text_styles.alert(i18n.makeString(MENU.REFERRALMANAGEMENTWINDOW_PROGRESSNOTAVAILABLE))
                progressAlertText = i18n.makeString(progressAlertIcon + ' ' + progressAlertText)
            progresData.update({'steps': stepsData,
             'progress': progress})
        if progressAlertText != '':
            self.as_showAlertS(progressAlertText)
        elif refSystem.isTotallyCompleted():
            self.as_setAwardDataDataS(awardData)
        else:
            self.as_setProgressDataS(progresData)
        return