def __prepareOutfit(self, outfitCD): if self.__outfit: return outfit = Outfit(outfitCD) player = BigWorld.player() forceHistorical = player.isHistoricallyAccurate and player.playerVehicleID != self.__vID and not outfit.isHistorical() self.__outfit = Outfit() if forceHistorical else outfit
def new_cacheAppearance(base, self, vId, info, *args, **kwargs): if g_config.data['enabled'] and getattr(info.typeDescr, 'modelDesc', None) is None: outfitComponent = camouflages.getOutfitComponent(info.outfitCD) outfit = Outfit(component=outfitComponent) player = BigWorld.player() forceHistorical = player.isHistoricallyAccurate and player.playerVehicleID != vId and not outfit.isHistorical() outfit = Outfit() if forceHistorical else outfit vDesc_process(vId, info.typeDescr, 'battle', outfit.modelsSet or 'default') return base(self, vId, info, *args, **kwargs)
def applyOutfitInfo(outfit, seasonName, vDesc, randomCache, vID=None, isPlayerVehicle=True): nationName, vehicleName = vDesc.name.split(':') isTurretCustomisable = isTurretCustom(vDesc) if isPlayerVehicle: vehCache = g_config.outfitCache.get(nationName, {}).get(vehicleName, {}) styleCache = vehCache.get('style', {'intCD': None, 'applied': False}) if styleCache['applied']: styleCD = styleCache['intCD'] if styleCD is not None: itemsCache = dependency.instance(IItemsCache) style = ( itemsCache.items.getItemByCD if itemsCache.items.isSynced() else itemsCache.items.itemsFactory.createCustomization)(styleCD) if not style: print g_config.ID + ': style', styleCD, 'for', vehicleName, 'deleted from game client.' styleCache.update(intCD=None, applied=False) else: outfit = style.getOutfit( SEASON_NAME_TO_TYPE[seasonName]).copy() else: outfit = Outfit() outfit._id = 20000 else: if outfit.modelsSet and any( v for k, v in vehCache.iteritems() if k != 'style'): outfit = Outfit() applyOutfitCache(outfit, vehCache.get(seasonName, {})) deleteEmpty(vehCache, isTurretCustomisable) loadJson(g_config.ID, 'outfitCache', g_config.outfitCache, g_config.configPath, True) if outfit.modelsSet or outfit.id == 20000: randomCache.clear() elif g_config.data['doRandom'] and (g_config.data['fillEmptySlots'] or hasNoCamo(outfit)): processRandomCamouflages(outfit, seasonName, randomCache, isTurretCustomisable, vID) applyOutfitCache(outfit, randomCache) return outfit
def createOutfit(self, strCompactDescr=None, isEnabled=False, proxy=None): """ Creates an outfit item by the given arguments. :param strCompactDescr: cmSet's string compact descriptor :parma isEnabled: determines whether outfit can be used in battle :param proxy: instance of ItemsRequester :return: an instance of Outfit """ return Outfit(strCompactDescr, isEnabled, proxy)
def __init__(self, vehicleDesc, insigniaRank=0, outfit=None): self.__showEmblemsOnGun = vehicleDesc.turret.showEmblemsOnGun self.__defaultAlpha = vehicleDesc.type.emblemsAlpha self.__show = True self.__animateGunInsignia = vehicleDesc.gun.animateEmblemSlots self.__currentInsigniaRank = insigniaRank if outfit is None: outfit = Outfit() componentSlots = ((TankPartNames.HULL, vehicleDesc.hull.emblemSlots), (TankPartNames.GUN if self.__showEmblemsOnGun else TankPartNames.TURRET, vehicleDesc.turret.emblemSlots), (TankPartNames.TURRET if self.__showEmblemsOnGun else TankPartNames.GUN, []), ('gunInsignia', vehicleDesc.gun.emblemSlots)) self.__stickers = {} for componentName, emblemSlots in componentSlots: try: componentIdx = TankPartNames.getIdx(componentName) except Exception: componentIdx = -1 container = outfit.getContainer(componentIdx) emblems = None inscriptions = None if container: emblems = container.slotFor(GUI_ITEM_TYPE.EMBLEM) inscriptions = container.slotFor(GUI_ITEM_TYPE.INSCRIPTION) decals = { SlotTypes.PLAYER: emblems, SlotTypes.INSCRIPTION: inscriptions } modelStickers = ModelStickers(vehicleDesc, emblemSlots, decals, componentName == TankPartNames.HULL, self.__currentInsigniaRank) self.__stickers[componentName] = ComponentStickers( modelStickers, {}, 1.0) return
def __getVehicleOutfit(self): if not self.__vehicle: return Outfit() outfitCD = self.__vehicle.publicInfo['outfit'] outfit = Outfit(outfitCD) if not (self.__vehicle.isPlayerVehicle or outfit.isHistorical()): if BigWorld.player().isC11nHistorical: outfit = Outfit() return outfit
def prerequisites(self, typeDescriptor, vID, health, isCrewActive, isTurretDetached, outfitCD): self.__currentDamageState.update(health, isCrewActive, False) outfit = Outfit(outfitCD) out = camouflages.getCamoPrereqs(outfit, typeDescriptor) splineDesc = typeDescriptor.chassis.splineDesc if splineDesc is not None: out.append(splineDesc.segmentModelLeft) out.append(splineDesc.segmentModelRight) if splineDesc.segment2ModelLeft is not None: out.append(splineDesc.segment2ModelLeft) if splineDesc.segment2ModelRight is not None: out.append(splineDesc.segment2ModelRight) self.__vID = vID self.__typeDesc = typeDescriptor self.__isTurretDetached = isTurretDetached return out
def new_prepareOutfit(base, self, *a, **kw): outfit = base(self, *a, **kw).copy() vDesc = self.typeDescriptor if not vDesc: return if g_config.data['enabled'] and vDesc.name not in g_config.disable and not ( vDesc.type.hasCustomDefaultCamouflage and g_config.data['disableWithDefault']): if not g_config.data['useBought']: outfit = Outfit() seasonName = SEASON_TYPE_TO_NAME[SeasonType.fromArenaKind( BigWorld.player().arena.arenaType.vehicleCamouflageKind)] outfit = applyOutfitInfo( outfit, seasonName, vDesc, g_config.arenaCamoCache.setdefault(self.id, {}), self.id, self.id == BigWorld.player().playerVehicleID) return outfit
def createOutfit(self, strCompactDescr=None, component=None, isEnabled=False, isInstalled=False, proxy=None): if strCompactDescr is not None and component is not None: _logger.error( "'strCompactDescr' and 'component' arguments are mutually exclusive!" ) return else: return Outfit(strCompactDescr=strCompactDescr, component=component, isEnabled=isEnabled, isInstalled=isInstalled, proxy=proxy)
def new_reload(base, self, vDesc, vState, outfit): if vState != 'undamaged': return base(self, vDesc, vState, outfit) manager = ServicesLocator.appLoader.getDefLobbyApp().containerManager if manager is not None: container = manager.getContainer(ViewTypes.LOBBY_SUB) if container is not None: c11nView = container.getView() if c11nView is not None and hasattr(c11nView, 'service'): outfit = c11nView.service.getCtx().currentOutfit return base(self, vDesc, vState, outfit) if (not g_config.data['enabled'] or vDesc.name in g_config.disable or (vDesc.type.hasCustomDefaultCamouflage and g_config.data['disableWithDefault'])): return base(self, vDesc, vState, outfit) for descr in g_currentPreviewVehicle, g_currentVehicle: if descr.isPresent() and descr.item.descriptor.name == vDesc.name: vehicle = descr.item break else: vehicle = None nation, vehicleName = vDesc.name.split(':') intCD = vDesc.type.compactDescr season = g_tankActiveCamouflage.get(intCD, SeasonType.EVENT) if g_config.data['hangarCamoKind'] < 3: g_tankActiveCamouflage[intCD] = SeasonType.fromArenaKind( g_config.data['hangarCamoKind']) elif season in (SeasonType.UNDEFINED, SeasonType.EVENT): active = [ s for s in SeasonType.SEASONS if vehicle and vehicle.hasOutfitWithItems(s) ] g_tankActiveCamouflage[intCD] = random.choice( active) if active else SeasonType.SUMMER if season not in (g_tankActiveCamouflage[intCD], SeasonType.UNDEFINED, SeasonType.EVENT): season = g_tankActiveCamouflage[intCD] if vehicle: outfit = vehicle.getOutfit(season) outfit = outfit.copy() if outfit else Outfit() seasonName = SEASON_TYPE_TO_NAME[g_tankActiveCamouflage[intCD]] seasonCache = g_config.hangarCamoCache.setdefault(nation, {}).setdefault( vehicleName, {}).setdefault(seasonName, {}) outfit = applyOutfitInfo(outfit, seasonName, vDesc, seasonCache) return base(self, vDesc, vState, outfit)
def new_applyVehicleOutfit(base, self, *a, **kw): result = self._CompoundAppearance__outfit.copy() vID = self._CompoundAppearance__vID vDesc = self._CompoundAppearance__typeDesc if not vDesc: return base(self, *a, **kw) if g_config.data['enabled'] and vDesc.name not in g_config.disable and not ( vDesc.type.hasCustomDefaultCamouflage and g_config.data['disableWithDefault']): if not g_config.data['useBought']: result = Outfit() seasonName = SEASON_TYPE_TO_NAME[SeasonType.fromArenaKind( BigWorld.player().arena.arenaType.vehicleCamouflageKind)] nationName, vehicleName = vDesc.name.split(':') applied = False cleaned = False if self._CompoundAppearance__vID == BigWorld.player().playerVehicleID: vehCache = g_config.outfitCache.get(nationName, {}).get(vehicleName, {}) applyPlayerCache(result, vehicleName, vehCache.get(seasonName, {})) applied, cleaned = applyCamoCache( result, vehicleName, vehCache.get(seasonName, {}).get('camo', {})) if cleaned: vehCache.get(seasonName, {}).pop('camo', None) if not vehCache.get(seasonName, None): vehCache.pop(seasonName, None) if g_config.data['doRandom'] and (not applied or cleaned or g_config.data['fillEmptySlots']): seasonCache = g_config.arenaCamoCache.setdefault(vID, {}) processRandomCamouflages(result, seasonName, seasonCache, vID, isGunCarriage=vDesc.turret.isGunCarriage) applyCamoCache(result, vehicleName, seasonCache) self._CompoundAppearance__outfit = result base(self, *a, **kw)
def createOutfit(self, strCompactDescr=None, isEnabled=False, isInstalled=False, proxy=None): return Outfit(strCompactDescr, isEnabled, isInstalled, proxy)
def invalidateCache(self, diff=None): invalidate = defaultdict(set) if diff is None: LOG_DEBUG('Gui items cache full invalidation') for itemTypeID, cache in self.__itemsCache.iteritems(): if itemTypeID not in (GUI_ITEM_TYPE.ACCOUNT_DOSSIER, GUI_ITEM_TYPE.VEHICLE_DOSSIER, GUI_ITEM_TYPE.BATTLE_ABILITY): cache.clear() else: for statName, data in diff.get('stats', {}).iteritems(): if statName in ('unlocks', ('unlocks', '_r')): self._invalidateUnlocks(data, invalidate) if statName == 'eliteVehicles': invalidate[GUI_ITEM_TYPE.VEHICLE].update(data) if statName in ('vehTypeXP', 'vehTypeLocks'): invalidate[GUI_ITEM_TYPE.VEHICLE].update(data.keys()) if statName in (('multipliedXPVehs', '_r'),): getter = vehicles.getVehicleTypeCompactDescr inventoryVehiclesCDs = [ getter(v['compDescr']) for v in self.__inventory.getItems(GUI_ITEM_TYPE.VEHICLE).itervalues() ] invalidate[GUI_ITEM_TYPE.VEHICLE].update(inventoryVehiclesCDs) if statName in ('oldVehInvIDs',): invalidate[GUI_ITEM_TYPE.VEHICLE].update(data) for cacheType, data in diff.get('cache', {}).iteritems(): if cacheType == 'vehsLock': for itemID in data.keys(): vehData = self.__inventory.getVehicleData(_getDiffID(itemID)) if vehData is not None: invalidate[GUI_ITEM_TYPE.VEHICLE].add(vehData.descriptor.type.compactDescr) for cacheType, data in diff.get('groupLocks', {}).iteritems(): if cacheType in ('isGroupLocked', 'groupBattles'): getter = vehicles.getVehicleTypeCompactDescr inventoryVehiclesCDs = [ getter(v['compDescr']) for v in self.inventory.getItems(GUI_ITEM_TYPE.VEHICLE).itervalues() ] invalidate[GUI_ITEM_TYPE.VEHICLE].update(inventoryVehiclesCDs) for itemTypeID, itemsDiff in diff.get('inventory', {}).iteritems(): if itemTypeID == GUI_ITEM_TYPE.VEHICLE: if 'compDescr' in itemsDiff: for strCD in itemsDiff['compDescr'].itervalues(): if strCD is not None: invalidate[itemTypeID].add(vehicles.getVehicleTypeCompactDescr(strCD)) for data in itemsDiff.itervalues(): for itemID in data.iterkeys(): vehData = self.__inventory.getVehicleData(_getDiffID(itemID)) if vehData is not None: invalidate[itemTypeID].add(vehData.descriptor.type.compactDescr) invalidate[GUI_ITEM_TYPE.TANKMAN].update(self.__getTankmenIDsForVehicle(vehData)) if itemTypeID == GUI_ITEM_TYPE.TANKMAN: for data in itemsDiff.itervalues(): invalidate[itemTypeID].update(data.keys()) for itemID in data.keys(): tmanInvID = _getDiffID(itemID) tmanData = self.__inventory.getTankmanData(tmanInvID) if tmanData is not None and tmanData.vehicle != -1: invalidate[GUI_ITEM_TYPE.VEHICLE].update(self.__getVehicleCDForTankman(tmanData)) invalidate[GUI_ITEM_TYPE.TANKMAN].update(self.__getTankmenIDsForTankman(tmanData)) if itemTypeID == GUI_ITEM_TYPE.SHELL: invalidate[itemTypeID].update(itemsDiff.keys()) vehicleItems = self.__inventory.getItems(GUI_ITEM_TYPE.VEHICLE) if vehicleItems: for shellIntCD in itemsDiff.iterkeys(): for vehicle in vehicleItems.itervalues(): shells = vehicle['shells'] for intCD, _, _ in LayoutIterator(shells): if shellIntCD == intCD: vehicleIntCD = vehicles.getVehicleTypeCompactDescr(vehicle['compDescr']) invalidate[GUI_ITEM_TYPE.VEHICLE].add(vehicleIntCD) vehicleData = self.__inventory.getItemData(vehicleIntCD) if vehicleData is not None: gunIntCD = vehicleData.descriptor.gun.compactDescr invalidate[GUI_ITEM_TYPE.GUN].add(gunIntCD) if itemTypeID == GUI_ITEM_TYPE.CUSTOMIZATION: for vehicleIntCD, outfitsData in itemsDiff.get(CustomizationInvData.OUTFITS, {}).iteritems(): invalidate[GUI_ITEM_TYPE.VEHICLE].add(vehicleIntCD) seasons = (outfitsData or {}).keys() or SeasonType.RANGE vehicle = self.getItemByCD(vehicleIntCD) for season in seasons: outfitCompactDescr = None if outfitsData: outfitData = outfitsData.get(season) if outfitData: outfitCompactDescr, _ = outfitData newOutfit = Outfit(outfitCompactDescr) if season == SeasonType.ALL: prevOutfit = vehicle.getOutfit(SeasonType.SUMMER) or Outfit() prevStyleId = prevOutfit.id newStyleId = newOutfit.id if prevStyleId != newStyleId: invalidStyles = set() invalidStyles.add(self.__updateStyleAppliedCount(prevStyleId, vehicleIntCD, 0)) invalidStyles.add(self.__updateStyleAppliedCount(newStyleId, vehicleIntCD, 1)) for styleIntCD in invalidStyles: if styleIntCD is not None: invalidate[GUI_ITEM_TYPE.CUSTOMIZATION].add(styleIntCD) else: prevOutfit = vehicle.getCustomOutfit(season) or Outfit() prevItemsCounter = prevOutfit.itemsCounter newItemsCounter = newOutfit.itemsCounter newItemsCounter.subtract(prevItemsCounter) for itemCD, count in newItemsCounter.iteritems(): self.__inventory.updateC11nItemAppliedCount(itemCD, vehicleIntCD, count) invalidate[GUI_ITEM_TYPE.CUSTOMIZATION].add(itemCD) invalidate[GUI_ITEM_TYPE.OUTFIT].add((vehicleIntCD, season)) for cType, items in itemsDiff.get(CustomizationInvData.ITEMS, {}).iteritems(): for idx in items.iterkeys(): intCD = vehicles.makeIntCompactDescrByID('customizationItem', cType, idx) invalidate[GUI_ITEM_TYPE.CUSTOMIZATION].add(intCD) invalidate[itemTypeID].update(itemsDiff.keys()) for itemType, itemsDiff in diff.get('recycleBin', {}).iteritems(): deletedItems = itemsDiff.get('buffer', {}) for itemID in deletedItems.iterkeys(): if itemType == 'tankmen': invalidate[GUI_ITEM_TYPE.TANKMAN].add(itemID * -1) invalidate[GUI_ITEM_TYPE.VEHICLE].add(itemID) if 'goodies' in diff: vehicleDiscounts = self.__shop.getVehicleDiscountDescriptions() for goodieID in diff['goodies'].iterkeys(): if goodieID in vehicleDiscounts: vehicleDiscount = vehicleDiscounts[goodieID] invalidate[GUI_ITEM_TYPE.VEHICLE].add(vehicleDiscount.target.targetValue) for itemTypeID, uniqueIDs in invalidate.iteritems(): self._invalidateItems(itemTypeID, uniqueIDs) return invalidate