예제 #1
0
 def _makePriceBlock(self,
                     price,
                     currencySetting,
                     percent=0,
                     valueWidth=-1):
     _int = BigWorld.wg_getIntegralFormat
     hasAction = percent != 0
     settings = _getCurrencySetting(currencySetting)
     if settings is None:
         return
     else:
         valueFormatted = settings.textStyle(_int(price))
         if hasAction:
             settingsFrame = settings.frame
             if settingsFrame in Currency.ALL:
                 newPrice = MONEY_UNDEFINED.replace(settingsFrame, price)
             else:
                 newPrice = Money(credits=price)
             return formatters.packActionTextParameterBlockData(
                 name=text_styles.main(
                     _ms(TOOLTIPS.ACTIONPRICE_BUYPRICE_ACTIONPRICE,
                         value=text_styles.expText(percent))),
                 value=valueFormatted,
                 icon=_getCurrencySetting(currencySetting).frame,
                 padding=formatters.packPadding(left=20, bottom=-20),
                 currency=newPrice.getCurrency(),
                 valueWidth=valueWidth)
         return formatters.packTextParameterWithIconBlockData(
             name=text_styles.main(self._getDefaultPriceLabelConst()),
             value=valueFormatted,
             icon=settings.frame,
             valueWidth=valueWidth)
         return
예제 #2
0
 def __makeRentBlock(self, price, currencySetting, days, percent=0):
     _int = BigWorld.wg_getIntegralFormat
     settings = _getCurrencySetting(currencySetting)
     if settings is None:
         return
     else:
         valueFormatted = settings.textStyle(_int(price))
         settingsFrame = settings.frame
         if settingsFrame in Currency.ALL:
             newPrice = MONEY_UNDEFINED.replace(settingsFrame, price)
         else:
             newPrice = Money(credits=price)
         if days == 1:
             text = text_styles.main(
                 _ms(TOOLTIPS.ACTIONPRICE_RENTPRICE_1DAY,
                     value=text_styles.expText(percent)))
         elif days == 3:
             text = text_styles.main(
                 _ms(TOOLTIPS.ACTIONPRICE_RENTPRICE_3DAY,
                     value=text_styles.expText(percent)))
         else:
             text = text_styles.main(
                 _ms(TOOLTIPS.ACTIONPRICE_RENTPRICE_DAYS,
                     days=days,
                     value=text_styles.expText(percent)))
         return formatters.packActionTextParameterBlockData(
             name=text,
             value=valueFormatted,
             icon=_getCurrencySetting(currencySetting).frame,
             padding=formatters.packPadding(left=20, bottom=-20),
             currency=newPrice.getCurrency())
예제 #3
0
    def _populate(self):
        super(VehicleSellDialog, self)._populate()
        g_clientUpdateManager.addCurrencyCallback(Currency.GOLD,
                                                  self.onSetGoldHndlr)
        self.itemsCache.onSyncCompleted += self.__shopResyncHandler
        items = self.itemsCache.items
        vehicle = items.getVehicle(self.__vehInvID)
        sellPrice = vehicle.sellPrices.itemPrice.price
        sellCurrency = sellPrice.getCurrency(byWeight=True)
        sellForGold = sellCurrency == Currency.GOLD
        priceTextColor = CURRENCIES_CONSTANTS.GOLD_COLOR if sellForGold else CURRENCIES_CONSTANTS.CREDITS_COLOR
        priceTextValue = _ms(DIALOGS.VEHICLESELLDIALOG_PRICE_SIGN_ADD) + _ms(
            BigWorld.wg_getIntegralFormat(
                sellPrice.getSignValue(sellCurrency)))
        currencyIcon = CURRENCIES_CONSTANTS.GOLD if sellForGold else CURRENCIES_CONSTANTS.CREDITS
        invVehs = items.getVehicles(REQ_CRITERIA.INVENTORY)
        self.checkControlQuestion(self.__checkUsefulTankman)
        modules = items.getItems(
            criteria=REQ_CRITERIA.VEHICLE.SUITABLE([vehicle])
            | REQ_CRITERIA.INVENTORY).values()
        shells = items.getItems(criteria=REQ_CRITERIA.VEHICLE.SUITABLE(
            [vehicle], [GUI_ITEM_TYPE.SHELL])
                                | REQ_CRITERIA.INVENTORY).values()
        otherVehsShells = set()
        for invVeh in invVehs.itervalues():
            if invVeh.invID != self.__vehInvID:
                for shot in invVeh.descriptor.gun.shots:
                    otherVehsShells.add(shot.shell.compactDescr)

        vehicleAction = None
        if vehicle.sellPrices.itemPrice.isActionPrice():
            vehicleAction = packItemActionTooltipData(vehicle, False)
        if vehicle.isElite:
            description = TOOLTIPS.tankcaruseltooltip_vehicletype_elite(
                vehicle.type)
        else:
            description = DIALOGS.vehicleselldialog_vehicletype(vehicle.type)
        levelStr = text_styles.concatStylesWithSpace(
            text_styles.stats(int2roman(vehicle.level)),
            text_styles.main(_ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_LEVEL)))
        tankmenGoingToBuffer, deletedTankmen = self.restore.getTankmenDeletedBySelling(
            vehicle)
        deletedCount = len(deletedTankmen)
        if deletedCount > 0:
            deletedStr = formatDeletedTankmanStr(deletedTankmen[0])
            maxCount = self.restore.getMaxTankmenBufferLength()
            currCount = len(self.restore.getDismissedTankmen())
            if deletedCount == 1:
                crewTooltip = text_styles.concatStylesToMultiLine(
                    text_styles.middleTitle(
                        _ms(TOOLTIPS.
                            VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)),
                    text_styles.main(
                        _ms(TOOLTIPS.
                            VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_BODY,
                            maxVal=maxCount,
                            curVal=currCount,
                            sourceName=tankmenGoingToBuffer[-1].fullUserName,
                            targetInfo=deletedStr)))
            else:
                crewTooltip = text_styles.concatStylesToMultiLine(
                    text_styles.middleTitle(
                        _ms(TOOLTIPS.
                            VEHICLESELLDIALOG_CREW_ALERTICON_RECOVERY_HEADER)),
                    text_styles.main(
                        _ms(TOOLTIPS.
                            DISMISSTANKMANDIALOG_BUFFERISFULLMULTIPLE_BODY,
                            deletedStr=deletedStr,
                            extraCount=deletedCount - 1,
                            maxCount=maxCount,
                            currCount=currCount)))
        else:
            crewTooltip = None
        if vehicle.isCrewLocked:
            hasCrew = False
        else:
            hasCrew = vehicle.hasCrew
        barracksDropDownData = [{
            'label': _ms(MENU.BARRACKS_BTNUNLOAD)
        }, {
            'label': _ms(MENU.BARRACKS_BTNDISSMISS)
        }]
        sellVehicleData = {
            'intCD': vehicle.intCD,
            'userName': vehicle.userName,
            'icon': vehicle.icon,
            'level': vehicle.level,
            'isElite': vehicle.isElite,
            'isPremium': vehicle.isPremium,
            'type': vehicle.type,
            'nationID': vehicle.nationID,
            'sellPrice': sellPrice.toMoneyTuple(),
            'priceTextValue': priceTextValue,
            'priceTextColor': priceTextColor,
            'currencyIcon': currencyIcon,
            'action': vehicleAction,
            'hasCrew': hasCrew,
            'isRented': vehicle.isRented,
            'description': description,
            'levelStr': levelStr,
            'priceLabel':
            _ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_EMPTYSELLPRICE),
            'crewLabel': _ms(DIALOGS.VEHICLESELLDIALOG_CREW_LABEL),
            'crewTooltip': crewTooltip,
            'barracksDropDownData': barracksDropDownData
        }
        currentGoldBalance = self.itemsCache.items.stats.money.get(
            Currency.GOLD, 0)
        onVehicleOptionalDevices = []
        for o in vehicle.optDevices:
            if o is not None:
                itemPrice = o.sellPrices.itemPrice
                action = None
                if itemPrice.isActionPrice():
                    action = packItemActionTooltipData(o, False)
                removalPrice = o.getRemovalPrice(items)
                removeAction = None
                if removalPrice.isActionPrice():
                    removeAction = packActionTooltipData(
                        ACTION_TOOLTIPS_TYPE.ECONOMICS, 'paidRemovalCost',
                        True, removalPrice.price, removalPrice.defPrice)
                removalPriceInGold = removalPrice.price.get(Currency.GOLD, 0)
                enoughGold = currentGoldBalance >= removalPriceInGold
                if enoughGold:
                    currentGoldBalance -= removalPriceInGold
                data = {
                    'intCD': o.intCD,
                    'isRemovable': o.isRemovable,
                    'userName': o.userName,
                    'sellPrice': itemPrice.price.toMoneyTuple(),
                    'toInventory': enoughGold,
                    'action': action,
                    'removePrice': removalPrice.price.toMoneyTuple(),
                    'removeActionPrice': removeAction
                }
                onVehicleOptionalDevices.append(data)

        onVehicleoShells = []
        for shell in vehicle.shells:
            if shell is not None:
                itemPrice = shell.sellPrices.itemPrice
                action = None
                if itemPrice.isActionPrice():
                    action = packItemActionTooltipData(shell, False)
                data = {
                    'intCD': shell.intCD,
                    'count': shell.count,
                    'sellPrice': itemPrice.price.toMoneyTuple(),
                    'userName': shell.userName,
                    'kind': shell.type,
                    'toInventory': shell in otherVehsShells or shell.isPremium,
                    'action': action
                }
                onVehicleoShells.append(data)

        onVehicleEquipments = []
        for equipmnent in vehicle.equipment.regularConsumables.getInstalledItems(
        ):
            action = None
            if equipmnent.sellPrices.itemPrice.isActionPrice():
                action = packItemActionTooltipData(equipmnent, False)
            data = {
                'intCD': equipmnent.intCD,
                'userName': equipmnent.userName,
                'sellPrice':
                equipmnent.sellPrices.itemPrice.price.toMoneyTuple(),
                'toInventory': True,
                'action': action
            }
            onVehicleEquipments.append(data)

        onVehicleBattleBoosters = []
        for booster in vehicle.equipment.battleBoosterConsumables.getInstalledItems(
        ):
            data = {
                'intCD': booster.intCD,
                'userName': booster.userName,
                'sellPrice': MONEY_UNDEFINED.toMoneyTuple(),
                'onlyToInventory': True
            }
            onVehicleBattleBoosters.append(data)

        inInventoryModules = []
        for m in modules:
            inInventoryModules.append({
                'intCD':
                m.intCD,
                'inventoryCount':
                m.inventoryCount,
                'toInventory':
                True,
                'sellPrice':
                m.sellPrices.itemPrice.price.toMoneyTuple()
            })

        inInventoryShells = []
        for s in shells:
            action = None
            itemPrice = s.sellPrices.itemPrice
            if itemPrice.isActionPrice():
                action = packItemActionTooltipData(s, False)
            inInventoryShells.append({
                'intCD':
                s.intCD,
                'count':
                s.inventoryCount,
                'sellPrice':
                itemPrice.price.toMoneyTuple(),
                'userName':
                s.userName,
                'kind':
                s.type,
                'toInventory':
                s in otherVehsShells or s.isPremium,
                'action':
                action
            })

        customizationOnVehicle = []
        settings = self.getDialogSettings()
        isSlidingComponentOpened = settings['isOpened']
        self.as_setDataS({
            'accountMoney': items.stats.money.toMoneyTuple(),
            'sellVehicleVO': sellVehicleData,
            'optionalDevicesOnVehicle': onVehicleOptionalDevices,
            'shellsOnVehicle': onVehicleoShells,
            'equipmentsOnVehicle': onVehicleEquipments,
            'modulesInInventory': inInventoryModules,
            'shellsInInventory': inInventoryShells,
            'isSlidingComponentOpened': isSlidingComponentOpened,
            'battleBoostersOnVehicle': onVehicleBattleBoosters,
            'customizationOnVehicle': customizationOnVehicle
        })
        return
예제 #4
0
 def __init__(self, booster):
     super(_BoosterData, self).__init__(booster, FITTING_TYPES.BOOSTER)
     if not booster.isForSale:
         self._flashData['sellPrice'] = MONEY_UNDEFINED.toMoneyTuple()
         self._flashData['onlyToInventory'] = True