def getAvailableRegions(areaId, slotType, vehicleDescr=None):
    if vehicleDescr is None:
        if not g_currentVehicle.isPresent():
            return ()
        vehicleDescr = g_currentVehicle.item.descriptor
    outfit = Outfit(vehicleCD=vehicleDescr.makeCompactDescr())
    container = outfit.getContainer(areaId)
    if container is None:
        return ()
    else:
        slot = container.slotFor(slotType)
        if slot is None:
            return ()
        if slotType in (GUI_ITEM_TYPE.MODIFICATION, ):
            if areaId == Area.MISC:
                return (0, )
            return ()
        if slotType in (GUI_ITEM_TYPE.PROJECTION_DECAL,
                        GUI_ITEM_TYPE.ATTACHMENT, GUI_ITEM_TYPE.SEQUENCE):
            return tuple(range(len(slot.getRegions())))
        if slotType in (GUI_ITEM_TYPE.INSCRIPTION, GUI_ITEM_TYPE.EMBLEM):
            return __getAvailableDecalRegions(areaId, slotType, vehicleDescr)
        if slotType in (GUI_ITEM_TYPE.PAINT, GUI_ITEM_TYPE.CAMOUFLAGE):
            return __getAppliedToRegions(areaId, slotType, vehicleDescr)
        _logger.error('Wrong customization slotType: %s', slotType)
        return ()
Esempio n. 2
0
    def _fillOutfits(self):
        styleId = self._service.getStyledOutfit(self.season).id
        style = self._service.getItemByID(GUI_ITEM_TYPE.STYLE, styleId) if styleId else None
        isInstalled = self._service.isStyleInstalled()
        if not isInstalled:
            if style is not None and style.isHidden and style.fullInventoryCount(g_currentVehicle.item.intCD) == 0:
                style = None
        self.__originalStyle = style
        self.__modifiedStyle = style
        vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
        diffs = self._ctx.stylesDiffsCache.getDiffs(style) if style is not None else {}
        for season in SeasonType.COMMON_SEASONS:
            if style is None:
                outfit = self._service.getEmptyOutfit()
            else:
                diff = diffs.get(season)
                if not isInstalled and diff is not None:
                    diffOutfit = Outfit(strCompactDescr=diff, vehicleCD=vehicleCD)
                    self._removeHiddenFromOutfit(diffOutfit, g_currentVehicle.item.intCD)
                    diff = diffOutfit.pack().makeCompDescr()
                outfit = style.getOutfit(season, vehicleCD=vehicleCD, diff=diff)
            self._originalOutfits[season] = outfit.copy()
            self._modifiedOutfits[season] = outfit.copy()

        return
def prepareBattleOutfit(outfitCD, vehicleDescriptor, vehicleId):
    vehicleCD = vehicleDescriptor.makeCompactDescr()
    outfitComponent = getOutfitComponent(outfitCD, vehicleDescriptor)
    outfit = Outfit(component=outfitComponent, vehicleCD=vehicleCD)
    player = BigWorld.player()
    forceHistorical = player.isHistoricallyAccurate and player.playerVehicleID != vehicleId and not outfit.isHistorical()
    return Outfit(vehicleCD=vehicleCD) if forceHistorical else outfit
Esempio n. 4
0
def prepareBattleOutfit(outfitCD, vehicleDescriptor, vehicleId):
    vehicleCD = vehicleDescriptor.makeCompactDescr()
    outfitComponent = getOutfitComponent(outfitCD, vehicleDescriptor)
    outfit = Outfit(component=outfitComponent, vehicleCD=vehicleCD)
    player = BigWorld.player()
    forceHistorical = player.playerVehicleID != vehicleId and player.customizationDisplayType < outfit.customizationDisplayType(
    )
    if outfit.style and (outfit.style.isProgression or IS_EDITOR):
        progressionOutfit = getStyleProgressionOutfit(
            outfit, toLevel=outfit.progressionLevel)
        if progressionOutfit is not None:
            outfit = progressionOutfit
    return Outfit(vehicleCD=vehicleCD) if forceHistorical else outfit
Esempio n. 5
0
    def _fillOutfits(self):
        isInstalled = self._service.isStyleInstalled()
        vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
        for season in SeasonType.COMMON_SEASONS:
            diff = self._ctx.stylesDiffsCache.getDiff(self.__style, season)
            if not isInstalled and diff is not None:
                diffOutfit = Outfit(strCompactDescr=diff, vehicleCD=vehicleCD)
                self._removeHiddenFromOutfit(diffOutfit, g_currentVehicle.item.intCD)
                diff = diffOutfit.pack().makeCompDescr()
            outfit = self.__style.getOutfit(season, vehicleCD=vehicleCD, diff=diff)
            self._originalOutfits[season] = outfit.copy()
            self._modifiedOutfits[season] = outfit.copy()

        return
Esempio n. 6
0
    def _applyItems(self, purchaseItems, isModeChanged, callback):
        results = []
        vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
        modifiedOutfits = {season:outfit.copy() for season, outfit in self._modifiedOutfits.iteritems()}
        originalOutfits = self._ctx.startMode.getOriginalOutfits()
        removeUnselectedItemsFromEditableStyle(modifiedOutfits, self.__baseOutfits, purchaseItems)
        requestData = []
        for season in SeasonType.COMMON_SEASONS:
            outfit = modifiedOutfits[season]
            baseOutfit = self.__baseOutfits[season]
            if outfit.vehicleCD != baseOutfit.vehicleCD or not outfit.isEqual(baseOutfit):
                diff = getEditableStyleOutfitDiff(outfit, baseOutfit)
                outfit = self.__style.getOutfit(season, vehicleCD=vehicleCD, diff=diff)
                requestData.append((outfit, season))

        if not requestData:
            emptyComponent = CustomizationOutfit()
            outfit = self._modifiedOutfits[self.season]
            emptyComponent.styleId = outfit.id
            outfit = Outfit(component=emptyComponent)
            requestData.append((outfit, SeasonType.ALL))
        result = yield OutfitApplier(g_currentVehicle.item, requestData).request()
        results.append(result)
        if self.isInited:
            self._events.onItemsBought(originalOutfits, purchaseItems, results)
        callback(self)
Esempio n. 7
0
 def getAdditionalOutfit(self, level, season, vehicleCD):
     additionalOutfit = self.descriptor.styleProgressions.get(
         level, {}).get('additionalOutfit', {})
     return Outfit(
         strCompactDescr=additionalOutfit.get(season).makeCompDescr(),
         vehicleCD=vehicleCD
     ) if additionalOutfit and additionalOutfit.get(season) else None
    def __init__(self, spaceID, vehicleDesc, insigniaRank=0, outfit=None):
        self.__defaultAlpha = vehicleDesc.type.emblemsAlpha
        self.__show = True
        self.__animateGunInsignia = vehicleDesc.gun.animateEmblemSlots
        self.__currentInsigniaRank = insigniaRank
        self.__vDesc = vehicleDesc
        self.__componentNames = [(TankPartNames.HULL, TankPartNames.HULL), (TankPartNames.TURRET, TankPartNames.TURRET), (TankPartNames.GUN, TankNodeNames.GUN_INCLINATION)]
        if outfit is None:
            outfit = Outfit(vehicleCD=vehicleDesc.makeCompactDescr())
        componentSlots = self._createComponentSlots(vehicleDesc, vehicleDesc.turret.showEmblemsOnGun, outfit)
        if not isUseDebugStickers():
            self.__stickerPacks = self._createStickerPacks(vehicleDesc, outfit, insigniaRank)
        else:
            self.__stickerPacks = self._createDebugStickerPacks(vehicleDesc, outfit, insigniaRank)
        self.__stickers = {}
        for componentName, emblemSlots in componentSlots:
            if componentName == Insignia.Types.SINGLE:
                componentIdx = Insignia.Indexes.SINGLE
            elif componentName == Insignia.Types.DUAL_LEFT:
                componentIdx = Insignia.Indexes.DUAL_LEFT
            elif componentName == Insignia.Types.DUAL_RIGHT:
                componentIdx = Insignia.Indexes.DUAL_RIGHT
            else:
                componentIdx = TankPartNames.getIdx(componentName)
            modelStickers = ModelStickers(spaceID, componentIdx, self.__stickerPacks, vehicleDesc, emblemSlots)
            self.__stickers[componentName] = ComponentStickers(modelStickers, {}, 1.0)

        return
Esempio n. 9
0
 def _sellItem(self, item, count, callback):
     if item.fullInventoryCount(g_currentVehicle.item.intCD) < count:
         emptyComponent = CustomizationOutfit()
         vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
         outfit = Outfit(component=emptyComponent, vehicleCD=vehicleCD)
         yield OutfitApplier(g_currentVehicle.item, ((outfit, SeasonType.ALL),)).request()
     result = yield CustomizationsSeller(g_currentVehicle.item, item, count).request()
     callback(result)
def prepareBattleOutfit(outfitCD, vehicleDescriptor, vehicleId):
    vehicleCD = vehicleDescriptor.makeCompactDescr()
    outfitComponent = getOutfitComponent(outfitCD, vehicleDescriptor)
    outfit = Outfit(component=outfitComponent, vehicleCD=vehicleCD)
    player = BigWorld.player()
    if player is not None and hasattr(player, 'customizationDisplayType'):
        localPlayerWantsHistoricallyAccurate = player.customizationDisplayType < outfit.customizationDisplayType(
        )
        isLocalVehicle = player.playerVehicleID != vehicleId
    else:
        localPlayerWantsHistoricallyAccurate = False
        isLocalVehicle = False
    forceHistorical = isLocalVehicle and localPlayerWantsHistoricallyAccurate
    if outfit.style and (outfit.style.isProgression or IS_EDITOR):
        progressionOutfit = getStyleProgressionOutfit(
            outfit, toLevel=outfit.progressionLevel)
        if progressionOutfit is not None:
            outfit = progressionOutfit
    return Outfit(vehicleCD=vehicleCD) if forceHistorical else outfit
 def createOutfit(self, strCompactDescr=None, component=None, vehicleCD=''):
     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,
                       vehicleCD=vehicleCD)
def getStyleProgressionOutfit(outfit, toLevel=0, season=None):
    styleProgression = outfit.style.styleProgressions
    allLevels = styleProgression.keys()
    if not season:
        season = _currentMapSeason()
    style = outfit.style
    if toLevel == 0 and style.isProgressionRewindEnabled:
        _logger.info(
            'Get style progression level for the rewind style with id=%d',
            style.id)
        toLevel = getCurrentLevelForRewindStyle(outfit)
    if allLevels and toLevel not in allLevels:
        _logger.error(
            'Get style progression outfit: incorrect level given: %d', toLevel)
        toLevel = 1
    resOutfit = outfit.copy()
    for levelId, outfitConfig in styleProgression.iteritems():
        if 'additionalOutfit' not in outfitConfig.keys():
            continue
        if levelId != toLevel:
            additionalOutfit = outfitConfig['additionalOutfit'].get(season)
            if additionalOutfit:
                tmpOutfitCompDescr = additionalOutfit.makeCompDescr()
                tmpOutfit = Outfit(strCompactDescr=tmpOutfitCompDescr,
                                   vehicleCD=outfit.vehicleCD)
                resOutfit = resOutfit.discard(tmpOutfit)

    levelAdditionalOutfit = styleProgression.get(toLevel, {}).get(
        'additionalOutfit', {}).get(season)
    compDescr = None
    if levelAdditionalOutfit:
        compDescr = levelAdditionalOutfit.makeCompDescr()
    tmpOutfit = Outfit(strCompactDescr=compDescr, vehicleCD=outfit.vehicleCD)
    tmpDiff = resOutfit.diff(tmpOutfit).copy()
    resOutfit = resOutfit.adjust(tmpDiff)
    baseOutfit = outfit.style.outfits.get(season)
    if baseOutfit:
        baseOutfit = Outfit(strCompactDescr=baseOutfit.makeCompDescr(),
                            vehicleCD=outfit.vehicleCD)
        resOutfit = baseOutfit.adjust(resOutfit)
    resOutfit.setProgressionLevel(toLevel)
    if levelAdditionalOutfit:
        if levelAdditionalOutfit.attachments:
            attachmentSlot = resOutfit.misc.slotFor(GUI_ITEM_TYPE.ATTACHMENT)
            for attachment in levelAdditionalOutfit.attachments:
                intCD = makeIntCompactDescrByID('customizationItem',
                                                CustomizationType.ATTACHMENT,
                                                attachment.id)
                attachmentSlot.append(intCD, attachment)

        if levelAdditionalOutfit.sequences:
            sequenceSlot = resOutfit.misc.slotFor(GUI_ITEM_TYPE.SEQUENCE)
            for seq in levelAdditionalOutfit.sequences:
                intCD = makeIntCompactDescrByID('customizationItem',
                                                CustomizationType.SEQUENCE,
                                                seq.id)
                sequenceSlot.append(intCD, seq)

    return resOutfit
    def __setArenaMusicByStyle(self, vehiclePublicInfo, isPlayerVehicle):
        self.__arenaMusicSetup = None
        arena = avatar_getter.getArena()
        if arena is None:
            return
        else:
            arenaVisitor = self.__sessionProvider.arenaVisitor
            if arenaVisitor.bonus.hasRespawns():
                _logger.debug('Skip special arena sound according to game mode')
                return
            if isPlayerVehicle and vehiclePublicInfo.outfit:
                outfit = Outfit(vehiclePublicInfo.outfit, vehicleCD=vehiclePublicInfo.compDescr)
                if outfit.style and outfit.style.tags:
                    for tag, arenaMusic in self.__arenaMusicByStyle.iteritems():
                        if tag in outfit.style.tags:
                            self.__arenaMusicSetup = arena.arenaType.wwmusicSetup.copy()
                            self.__arenaMusicSetup.update(arenaMusic)
                            return

            return
Esempio n. 14
0
    def updateSpawnList(self, spawnListData):
        toAdd = spawnListData.difference(self._spawnList)
        toRemove = self._spawnList.difference(spawnListData)
        for data in toAdd:
            vDesc = VehicleDescriptor(compactDescr=data.vehicleCD)
            prereqs = set(vDesc.prerequisites())
            outfit = Outfit(component=getOutfitComponent(data.outfitCD),
                            vehicleCD=data.vehicleCD)
            modelsSetParams = ModelsSetParams(outfit.modelsSet,
                                              ModelStates.UNDAMAGED, [])
            compoundAssembler = model_assembler.prepareCompoundAssembler(
                vDesc, modelsSetParams,
                BigWorld.camera().spaceID)
            prereqs.add(compoundAssembler)
            self._appearanceCache.loadResources(data.vehicleCD, list(prereqs))

        for data in toRemove:
            self._appearanceCache.unloadResources(data.vehicleCD)

        self._spawnList = spawnListData
        _logger.debug('SpawnList cache updated=%s', spawnListData)
def getOutfitComponent(outfitCD, vehicleDescriptor=None, seasonType=None):
    if outfitCD:
        outfitComponent = parseOutfitDescr(outfitCD)
        if seasonType is None:
            seasonType = _currentMapSeason()
        if outfitComponent.styleId != 0 and outfitComponent.styleId != EMPTY_ITEM_ID and seasonType is not None:
            intCD = makeIntCompactDescrByID('customizationItem',
                                            CustomizationType.STYLE,
                                            outfitComponent.styleId)
            styleDescr = getItemByCompactDescr(intCD)
            if IS_EDITOR:
                if hasattr(outfitComponent, 'edSeasonsMask'):
                    if styleDescr.outfits is not None and bool(
                            styleDescr.outfits):
                        anyOutfit = styleDescr.outfits[
                            styleDescr.outfits.keys()[0]]
                        seasonType = anyOutfit.edSeasonsMask
                    else:
                        return outfitComponent
            baseOutfitComponent = deepcopy(styleDescr.outfits[seasonType])
            if styleDescr.isProgression or IS_EDITOR:
                if IS_EDITOR:
                    baseOutfitComponent.styleId = styleDescr.id
                outfit = Outfit(component=baseOutfitComponent,
                                vehicleCD=vehicleDescriptor.makeCompactDescr())
                if outfit and outfit.style and outfit.style.styleProgressions:
                    outfit = getStyleProgressionOutfit(
                        outfit, outfitComponent.styleProgressionLevel,
                        seasonType)
                    baseOutfitComponent = outfit.pack()
                baseOutfitComponent.styleProgressionLevel = outfitComponent.styleProgressionLevel
            if styleDescr.isWithSerialNumber:
                baseOutfitComponent.serial_number = outfitComponent.serial_number
            if vehicleDescriptor and ItemTags.ADD_NATIONAL_EMBLEM in styleDescr.tags:
                emblems = createNationalEmblemComponents(vehicleDescriptor)
                baseOutfitComponent.decals.extend(emblems)
            if isEditedStyle(outfitComponent):
                outfitComponent = baseOutfitComponent.applyDiff(
                    outfitComponent)
            else:
                outfitComponent = baseOutfitComponent
            if IS_EDITOR:

                def setupAlternateItem(itemType, outfit, sourceOutfit,
                                       collectionName):
                    alternateItem = outfit.editorData.alternateItems[itemType]
                    if alternateItem != 0:
                        sourceComponents = getattr(sourceOutfit,
                                                   collectionName)
                        if sourceComponents is not None:
                            if itemType != CustomizationType.MODIFICATION:
                                for componentItem in sourceComponents:
                                    componentItem.id = alternateItem

                            else:
                                for index, _ in enumerate(sourceComponents):
                                    sourceComponents[index] = alternateItem

                                setattr(sourceOutfit, collectionName,
                                        sourceComponents)
                    return

                anyOutfit = styleDescr.outfits[seasonType]
                setupAlternateItem(CustomizationType.DECAL, anyOutfit,
                                   outfitComponent, 'decals')
                setupAlternateItem(CustomizationType.PROJECTION_DECAL,
                                   anyOutfit, outfitComponent,
                                   'projection_decals')
                setupAlternateItem(CustomizationType.PAINT, anyOutfit,
                                   outfitComponent, 'paints')
                setupAlternateItem(CustomizationType.CAMOUFLAGE, anyOutfit,
                                   outfitComponent, 'camouflages')
                setupAlternateItem(CustomizationType.MODIFICATION, anyOutfit,
                                   outfitComponent, 'modifications')
                setupAlternateItem(CustomizationType.PERSONAL_NUMBER,
                                   anyOutfit, outfitComponent,
                                   'personal_numbers')
        return outfitComponent
    else:
        return CustomizationOutfit()
 def _prepareOutfit(self, outfitCD):
     outfitComponent = camouflages.getOutfitComponent(outfitCD)
     return Outfit(component=outfitComponent,
                   vehicleCD=self.typeDescriptor.makeCompactDescr())