def _buildVO(self):
     deletedTankmen = self.restore.getTankmenBeingDeleted()
     alertImgSrc = ''
     alertText = ''
     alertTooltip = ''
     if not self._tankman.isRestorable():
         alertText = text_styles.alert(
             icons.alert() + _ms(DIALOGS.PROTECTEDDISMISSTANKMAN_ALERT))
         alertTooltip = TOOLTIPS.DISMISSTANKMANDIALOG_CANTRESTORALERT
     elif deletedTankmen:
         alertImgSrc = RES_ICONS.MAPS_ICONS_LIBRARY_ALERTICON
         alertTooltip = makeTooltip(
             TOOLTIPS.DISMISSTANKMANDIALOG_BUFFERISFULL_HEADER,
             _ms(TOOLTIPS.DISMISSTANKMANDIALOG_BUFFERISFULL_BODY,
                 placeCount=self.restore.getMaxTankmenBufferLength(),
                 currCount=len(self.restore.getDismissedTankmen()),
                 tankmanNew=self._tankman.fullUserName,
                 tankmanOld=formatDeletedTankmanStr(deletedTankmen[0])))
     return {
         'alertText': alertText,
         'alertTooltip': alertTooltip,
         'alertImgSrc': alertImgSrc,
         'questionText':
         text_styles.main(_ms(DIALOGS.DISMISSTANKMAN_MESSAGE))
     }
Example #2
0
 def _makeMeta(self):
     msgContext = {
         'dismissedName': self.ctx['dismissed'].fullUserName,
         'deletedStr': formatDeletedTankmanStr(self.ctx['deleted'])
     }
     if self.ctx.get('multiple'):
         msgContext['extraCount'] = self.ctx['extraCount']
     return I18nConfirmDialogMeta(self.localeKey,
                                  messageCtx=msgContext,
                                  focusedID=DIALOG_BUTTON_ID.SUBMIT)
Example #3
0
 def __getCrewData(self):
     tankmenGoingToBuffer, deletedTankmen = self.__restore.getTankmenDeletedBySelling(
         *self.__nationGroupVehicles)
     deletedCount = len(deletedTankmen)
     if deletedCount > 0:
         deletedStr = formatDeletedTankmanStr(deletedTankmen[0])
         maxCount = self.__restore.getMaxTankmenBufferLength()
         currCount = len(self.__restore.getDismissedTankmen())
         header = backport.text(R.strings.tooltips.vehicleSellDialog.crew.
                                alertIcon.recovery.header())
         if deletedCount == 1:
             crewTooltip = text_styles.concatStylesToMultiLine(
                 text_styles.middleTitle(header),
                 text_styles.main(
                     backport.text(
                         R.strings.tooltips.vehicleSellDialog.crew.
                         alertIcon.recovery.body(),
                         maxVal=maxCount,
                         curVal=currCount,
                         sourceName=tankmenGoingToBuffer[-1].fullUserName,
                         targetInfo=deletedStr)))
         else:
             crewTooltip = text_styles.concatStylesToMultiLine(
                 text_styles.middleTitle(header),
                 text_styles.main(
                     backport.text(R.strings.tooltips.dismissTankmanDialog.
                                   bufferIsFullMultiple.body(),
                                   deletedStr=deletedStr,
                                   extraCount=deletedCount - 1,
                                   maxCount=maxCount,
                                   currCount=currCount)))
     else:
         crewTooltip = None
     if self.__vehicle.isCrewLocked:
         hasCrew = False
     else:
         hasCrew = any([veh.hasCrew for veh in self.__nationGroupVehicles])
     return (hasCrew, crewTooltip)
Example #4
0
    def _populate(self):
        super(VehicleSellDialog, self)._populate()
        g_clientUpdateManager.addCallbacks({'stats.gold': self.onSetGoldHndlr})
        g_itemsCache.onSyncCompleted += self.__shopResyncHandler
        items = g_itemsCache.items
        vehicle = items.getVehicle(self.vehInvID)
        sellPrice = vehicle.sellPrice
        sellForGold = sellPrice.gold > 0
        priceTextColor = CURRENCIES_CONSTANTS.GOLD_COLOR if sellForGold else CURRENCIES_CONSTANTS.CREDITS_COLOR
        priceTextValue = _ms(DIALOGS.VEHICLESELLDIALOG_PRICE_SIGN_ADD) + _ms(BigWorld.wg_getIntegralFormat(sellPrice.gold if sellForGold else sellPrice.credits))
        currencyIcon = CURRENCIES_CONSTANTS.GOLD if sellForGold else CURRENCIES_CONSTANTS.CREDITS
        invVehs = items.getVehicles(REQ_CRITERIA.INVENTORY)
        if vehicle.isPremium or vehicle.level >= 3:
            self.as_visibleControlBlockS(True)
            self.__initCtrlQuestion()
        else:
            self.as_visibleControlBlockS(False)
        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 sellPrice != vehicle.defaultSellPrice:
            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)))
        restoreController = getRestoreController()
        tankmenGoingToBuffer, deletedTankmen = restoreController.getTankmenDeletedBySelling(vehicle)
        deletedCount = len(deletedTankmen)
        if deletedCount > 0:
            recoveryBufferFull = True
            deletedStr = formatDeletedTankmanStr(deletedTankmen[0])
            maxCount = restoreController.getMaxTankmenBufferLength()
            currCount = len(restoreController.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
            recoveryBufferFull = False
        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,
         'priceTextValue': priceTextValue,
         'priceTextColor': priceTextColor,
         'currencyIcon': currencyIcon,
         'action': vehicleAction,
         'hasCrew': vehicle.hasCrew,
         'isRented': vehicle.isRented,
         'description': description,
         'levelStr': levelStr,
         'priceLabel': _ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_EMPTYSELLPRICE),
         'crewLabel': _ms(DIALOGS.VEHICLESELLDIALOG_CREW_LABEL),
         'crewTooltip': crewTooltip,
         'barracksDropDownData': barracksDropDownData,
         'crewRecoveryBufferFull': recoveryBufferFull}
        onVehicleOptionalDevices = []
        for o in vehicle.optDevices:
            if o is not None:
                action = None
                if o.sellPrice != o.defaultSellPrice:
                    action = packItemActionTooltipData(o, False)
                data = {'intCD': o.intCD,
                 'isRemovable': o.isRemovable,
                 'userName': o.userName,
                 'sellPrice': o.sellPrice,
                 'toInventory': True,
                 'action': action}
                onVehicleOptionalDevices.append(data)

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

        onVehicleEquipments = []
        for equipmnent in vehicle.eqs:
            if equipmnent is not None:
                action = None
                if equipmnent.sellPrice != equipmnent.defaultSellPrice:
                    action = packItemActionTooltipData(equipmnent, False)
                data = {'intCD': equipmnent.intCD,
                 'userName': equipmnent.userName,
                 'sellPrice': equipmnent.sellPrice,
                 'toInventory': True,
                 'action': action}
                onVehicleEquipments.append(data)

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

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

        removePrice = items.shop.paidRemovalCost
        removePrices = Money(gold=removePrice)
        defRemovePrice = Money(gold=items.shop.defaults.paidRemovalCost)
        removeAction = None
        if removePrices != defRemovePrice:
            removeAction = packActionTooltipData(ACTION_TOOLTIPS_TYPE.ECONOMICS, 'paidRemovalCost', True, removePrices, defRemovePrice)
        settings = self.getDialogSettings()
        isSlidingComponentOpened = settings['isOpened']
        self.as_setDataS({'accountGold': items.stats.gold,
         'sellVehicleVO': sellVehicleData,
         'optionalDevicesOnVehicle': onVehicleOptionalDevices,
         'shellsOnVehicle': onVehicleoShells,
         'equipmentsOnVehicle': onVehicleEquipments,
         'modulesInInventory': inInventoryModules,
         'shellsInInventory': inInventoryShells,
         'removeActionPrice': removeAction,
         'removePrice': removePrice,
         'isSlidingComponentOpened': isSlidingComponentOpened})
        return
Example #5
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
 def _buildVO(self):
     from gui.game_control import getRestoreController
     restoreController = getRestoreController()
     deletedTankmen = restoreController.getTankmenBeingDeleted()
     alertImgSrc = ''
     alertText = ''
     alertTooltip = ''
     if not self._tankman.isRestorable():
         alertText = text_styles.alert(icons.alert() + _ms(DIALOGS.PROTECTEDDISMISSTANKMAN_ALERT))
         alertTooltip = TOOLTIPS.DISMISSTANKMANDIALOG_CANTRESTORALERT
     elif len(deletedTankmen) > 0:
         alertImgSrc = RES_ICONS.MAPS_ICONS_LIBRARY_ALERTICON
         alertTooltip = makeTooltip(TOOLTIPS.DISMISSTANKMANDIALOG_BUFFERISFULL_HEADER, _ms(TOOLTIPS.DISMISSTANKMANDIALOG_BUFFERISFULL_BODY, placeCount=restoreController.getMaxTankmenBufferLength(), currCount=len(restoreController.getDismissedTankmen()), tankmanNew=self._tankman.fullUserName, tankmanOld=formatDeletedTankmanStr(deletedTankmen[0])))
     return {'alertText': alertText,
      'alertTooltip': alertTooltip,
      'alertImgSrc': alertImgSrc,
      'questionText': text_styles.main(_ms(DIALOGS.DISMISSTANKMAN_MESSAGE))}
Example #7
0
    def _populate(self):
        super(VehicleSellDialog, self)._populate()
        g_clientUpdateManager.addCallbacks({'stats.gold': self.onSetGoldHndlr})
        g_itemsCache.onSyncCompleted += self.__shopResyncHandler
        items = g_itemsCache.items
        vehicle = items.getVehicle(self.vehInvID)
        sellPrice = vehicle.sellPrice
        sellForGold = sellPrice.gold > 0
        priceTextColor = CURRENCIES_CONSTANTS.GOLD_COLOR if sellForGold else CURRENCIES_CONSTANTS.CREDITS_COLOR
        priceTextValue = _ms(DIALOGS.VEHICLESELLDIALOG_PRICE_SIGN_ADD) + _ms(
            BigWorld.wg_getIntegralFormat(
                sellPrice.gold if sellForGold else sellPrice.credits))
        currencyIcon = CURRENCIES_CONSTANTS.GOLD if sellForGold else CURRENCIES_CONSTANTS.CREDITS
        invVehs = items.getVehicles(REQ_CRITERIA.INVENTORY)
        if vehicle.isPremium or vehicle.level >= 3:
            self.as_visibleControlBlockS(True)
            self.__initCtrlQuestion()
        else:
            self.as_visibleControlBlockS(False)
        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 sellPrice != vehicle.defaultSellPrice:
            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:
            recoveryBufferFull = True
            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
            recoveryBufferFull = False
        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,
            'priceTextValue': priceTextValue,
            'priceTextColor': priceTextColor,
            'currencyIcon': currencyIcon,
            'action': vehicleAction,
            'hasCrew': vehicle.hasCrew,
            'isRented': vehicle.isRented,
            'description': description,
            'levelStr': levelStr,
            'priceLabel':
            _ms(DIALOGS.VEHICLESELLDIALOG_VEHICLE_EMPTYSELLPRICE),
            'crewLabel': _ms(DIALOGS.VEHICLESELLDIALOG_CREW_LABEL),
            'crewTooltip': crewTooltip,
            'barracksDropDownData': barracksDropDownData,
            'crewRecoveryBufferFull': recoveryBufferFull
        }
        onVehicleOptionalDevices = []
        for o in vehicle.optDevices:
            if o is not None:
                action = None
                if o.sellPrice != o.defaultSellPrice:
                    action = packItemActionTooltipData(o, False)
                data = {
                    'intCD': o.intCD,
                    'isRemovable': o.isRemovable,
                    'userName': o.userName,
                    'sellPrice': o.sellPrice,
                    'toInventory': True,
                    'action': action
                }
                onVehicleOptionalDevices.append(data)

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

        onVehicleEquipments = []
        for equipmnent in vehicle.eqs:
            if equipmnent is not None:
                action = None
                if equipmnent.sellPrice != equipmnent.defaultSellPrice:
                    action = packItemActionTooltipData(equipmnent, False)
                data = {
                    'intCD': equipmnent.intCD,
                    'userName': equipmnent.userName,
                    'sellPrice': equipmnent.sellPrice,
                    'toInventory': True,
                    'action': action
                }
                onVehicleEquipments.append(data)

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

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

        removePrice = items.shop.paidRemovalCost
        removePrices = Money(gold=removePrice)
        defRemovePrice = Money(gold=items.shop.defaults.paidRemovalCost)
        removeAction = None
        if removePrices != defRemovePrice:
            removeAction = packActionTooltipData(
                ACTION_TOOLTIPS_TYPE.ECONOMICS, 'paidRemovalCost', True,
                removePrices, defRemovePrice)
        settings = self.getDialogSettings()
        isSlidingComponentOpened = settings['isOpened']
        self.as_setDataS({
            'accountGold': items.stats.gold,
            'sellVehicleVO': sellVehicleData,
            'optionalDevicesOnVehicle': onVehicleOptionalDevices,
            'shellsOnVehicle': onVehicleoShells,
            'equipmentsOnVehicle': onVehicleEquipments,
            'modulesInInventory': inInventoryModules,
            'shellsInInventory': inInventoryShells,
            'removeActionPrice': removeAction,
            'removePrice': removePrice,
            'isSlidingComponentOpened': isSlidingComponentOpened
        })
        return
Example #8
0
 def _makeMeta(self):
     msgContext = {'dismissedName': self.ctx['dismissed'].fullUserName,
      'deletedStr': formatDeletedTankmanStr(self.ctx['deleted'])}
     if self.ctx.get('multiple'):
         msgContext['extraCount'] = self.ctx['extraCount']
     return I18nConfirmDialogMeta(self.localeKey, messageCtx=msgContext, focusedID=DIALOG_BUTTON_ID.SUBMIT)