示例#1
0
    def __precacheGuns(self, vehiclesCache):
        descriptors = []
        curVehicleTurretsCDs = []
        getter = vehicles.g_cache.guns
        for nationIdx in nations.INDICES.itervalues():
            self.__cache.setdefault(nationIdx, {})[ITEM_TYPES.vehicleGun] = {}
            for g in getter(nationIdx).itervalues():
                del descriptors[:]
                turretsIntCDs = {}
                clipVehiclesList = set()
                autoReloadVehsList = set()
                dualGunVehsList = set()
                for vDescr in vehiclesCache.generator(nationIdx):
                    del curVehicleTurretsCDs[:]
                    vehCD = vDescr.type.compactDescr
                    for vTurrets in vDescr.type.turrets:
                        for turret in vTurrets:
                            for gun in turret.guns:
                                if gun.id[1] == g.id[1]:
                                    descriptors.append(gun)
                                    if len(vDescr.hull.fakeTurrets['lobby']) != len(vDescr.turrets):
                                        curVehicleTurretsCDs.append(turret.compactDescr)
                                    if gun.clip[0] > 1:
                                        clipVehiclesList.add(vehCD)
                                    if isAutoReloadGun(gun):
                                        autoReloadVehsList.add(vehCD)
                                    if isDualGun(gun):
                                        dualGunVehsList.add(vehCD)

                    if curVehicleTurretsCDs:
                        turretsIntCDs[vDescr.type.compactDescr] = tuple(curVehicleTurretsCDs)

                self.__cache[nationIdx][ITEM_TYPES.vehicleGun][g.compactDescr] = PrecachedGun(clipVehicles=clipVehiclesList if clipVehiclesList else None, autoReloadVehicles=frozenset(autoReloadVehsList) if autoReloadVehsList else None, dualGunVehicles=frozenset(dualGunVehsList) if dualGunVehsList else None, params=calcGunParams(g, descriptors), turretsByVehicles=turretsIntCDs)

        return
    def populateTechnicalMaintenance(self):
        money = self.itemsCache.items.stats.money
        data = {Currency.CREDITS: money.getSignValue(Currency.CREDITS),
         Currency.GOLD: money.getSignValue(Currency.GOLD)}
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            gun = vehicle.descriptor.gun
            cassetteText = ''
            if not isAutoReloadGun(gun):
                cassetteCount = vehicle.descriptor.gun.clip[0]
                if cassetteCount > 1:
                    cassetteText = makeString('#menu:technicalMaintenance/ammoTitleEx') % cassetteCount
            else:
                cassetteCount = 1
            data.update({'vehicleId': str(vehicle.intCD),
             'repairCost': vehicle.repairCost,
             'maxRepairCost': vehicle.descriptor.getMaxRepairCost(),
             'autoRepair': vehicle.isAutoRepair,
             'autoShells': vehicle.isAutoLoad,
             'autoEqip': vehicle.isAutoEquip,
             'maxAmmo': vehicle.gun.maxAmmo,
             'gunIntCD': vehicle.gun.intCD,
             'casseteFieldText': cassetteText,
             'shells': [],
             'infoAfterShellBlock': ''})
            sellGoldShellsForCredits = self.itemsCache.items.shop.isEnabledBuyingGoldShellsForCredits
            shells = data['shells']
            for shell in vehicle.shells:
                if shell.isHidden:
                    continue
                if sellGoldShellsForCredits:
                    prices = shell.buyPrices.getSum().price
                else:
                    prices = shell.buyPrices.itemPrice.price
                currency = shell.buyPrices.itemPrice.price.getCurrency(byWeight=True)
                action = None
                buyPrice = shell.getBuyPrice()
                if buyPrice.isActionPrice():
                    action = packItemActionTooltipData(shell)
                shells.append({'id': str(shell.intCD),
                 'type': shell.type,
                 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor.icon[0],
                 'count': shell.count,
                 'userCount': shell.defaultCount,
                 'step': cassetteCount,
                 'inventoryCount': shell.inventoryCount,
                 'prices': prices.toMoneyTuple(),
                 'currency': currency,
                 'ammoName': shell.longUserNameAbbr,
                 'tableName': shell.getShortInfo(vehicle, True),
                 'maxAmmo': vehicle.gun.maxAmmo,
                 'userCredits': money.toDict(),
                 'actionPriceData': action,
                 'desc': MENU.SHELLLISTITEMRENDERER_REPLACE})

        self.as_setDataS(data)
        return
示例#3
0
 def __updatePanelPosition(self):
     vehicle = BigWorld.entity(self.__vehicleID) if self.__vehicleID is not None else None
     if vehicle is None or vehicle.typeDescriptor is None:
         self.__setVerticalOffset(0)
         return
     else:
         verticalOffset = 0
         vTypeDescr = vehicle.typeDescriptor
         hasAutoloaderInterface = vTypeDescr.isDualgunVehicle or isAutoReloadGun(vTypeDescr.gun)
         if self.__viewID is CROSSHAIR_VIEW_ID.SNIPER and hasAutoloaderInterface:
             verticalOffset = self._VERTICAL_SHIFT_WITH_AUTOLOADER_IN_SNIPER_MODE
         self.__setVerticalOffset(verticalOffset)
         return
 def __hasAutoReload(self):
     return isAutoReloadGun(self._itemDescr.gun)
示例#5
0
 def updateSlots(self, slotID, fullUpdate=True):
     gun = self._interactor.getItem().descriptor.gun
     self._viewModel.setClipCount(
         1 if isAutoReloadGun(gun) else gun.clip[0])
     super(ShellSetupSubView, self).updateSlots(slotID, fullUpdate)