Beispiel #1
0
    def onVehiclesUpdate(self, vehicles):
        if vehicles is None or self.__lockUpdate:
            return
        vehCompDescr = vehicles.get(g_currentVehicle.invID)
        if vehCompDescr is not None:
            vehDescr = VehicleDescr(compactDescr=vehCompDescr)
            for interface in self.__interfaces.itervalues():
                interface.update(
                    CustomizationHelper.getUpdatedDescriptor(vehDescr))

            self.as_refreshItemsDataS()
Beispiel #2
0
    def __checkPrebattleLockedVehicle(self):
        from gui.prb_control import prb_getters
        clientPrb = prb_getters.getClientPrebattle()
        if clientPrb is not None:
            rosters = prb_getters.getPrebattleRosters(prebattle=clientPrb)
            for _, roster in rosters.iteritems():
                if BigWorld.player().id in roster:
                    vehCompDescr = roster[BigWorld.player().id].get('vehCompDescr', '')
                    if vehCompDescr:
                        vehDescr = VehicleDescr(vehCompDescr)
                        vehicle = self.itemsCache.items.getItemByCD(vehDescr.type.compactDescr)
                        if vehicle is not None:
                            return vehicle.invID

        return 0
 def __createOutfit(self, season, vehicleCD='', diff=None):
     component = deepcopy(self.descriptor.outfits[season])
     if vehicleCD and ItemTags.ADD_NATIONAL_EMBLEM in self.tags:
         vehDescr = VehicleDescr(vehicleCD)
         emblems = createNationalEmblemComponents(vehDescr)
         component.decals.extend(emblems)
     if diff is not None:
         diffComponent = parseCompDescr(diff)
         if component.styleId != diffComponent.styleId:
             _logger.error(
                 'Merging outfits of different styles is not allowed. ID1: %s ID2: %s',
                 component.styleId, diffComponent.styleId)
         else:
             component = component.applyDiff(diffComponent)
     return self.itemsFactory.createOutfit(component=component,
                                           vehicleCD=vehicleCD)
Beispiel #4
0
    def __calculate(self, rosters):
        classLevels = defaultdict(lambda : 0)
        totalLevel = 0
        vehClassTags = set(VEHICLE_CLASS_TAGS)
        for roster in rosters.itervalues():
            if not roster['state'] & PREBATTLE_ACCOUNT_STATE.READY:
                continue
            vehCompDescr = roster.get('vehCompDescr', '')
            if vehCompDescr:
                vehType = VehicleDescr(compactDescr=vehCompDescr).type
                level = vehType.level
                union = vehClassTags & vehType.tags
                if union:
                    vehClass = union.pop()
                    classLevels[vehClass] = max(classLevels[vehClass], level)
                totalLevel += level

        return (totalLevel, classLevels)
 def __setVoiceoverByVehicleOrTankman(self, vehiclePublicInfo, isPlayerVehicle):
     vehicleType = VehicleDescr(vehiclePublicInfo.compDescr).type
     if self.__setSpecialVoiceByVehicle(vehicleType.name, isPlayerVehicle):
         return
     else:
         groupID, isFemale, isPremium = tankmen.unpackCrewParams(vehiclePublicInfo.crewGroup)
         nationID, _ = vehicleType.id
         if self.__setSpecialVoiceByTankmen(nationID, groupID, isPremium):
             return
         preset = SoundGroups.g_instance.soundModes.currentNationalPreset
         isNationalPreset = preset[1] if preset is not None else False
         if isNationalPreset:
             commanderSkinID = vehiclePublicInfo.commanderSkinID
             if self.__setSpecialVoiceByCommanderSkinID(isFemale, commanderSkinID):
                 return
         genderSwitch = CREW_GENDER_SWITCHES.FEMALE if isFemale and isNationalPreset else CREW_GENDER_SWITCHES.DEFAULT
         SoundGroups.g_instance.soundModes.setCurrentNation(nations.NAMES[nationID], genderSwitch)
         return
    def _applyVehiclesFromCache(self, data):
        if not data:
            return
        vehCDs = []
        for strCD, equipment, crewData, shellIndex, hasCamouflage, battleBooster in data:
            intCD = VehicleDescr(strCD).type.compactDescr
            vehCmpData = self._createVehCompareData(intCD, initParameters={'strCD': strCD,
             'isFromCache': True,
             'crewData': crewData,
             'equipment': equipment,
             'shellIndex': shellIndex,
             'hasCamouflage': hasCamouflage,
             'battleBooster': battleBooster})
            if vehCmpData:
                self.__vehicles.append(vehCmpData)
                vehCDs.append(intCD)

        if vehCDs:
            self.__applyChanges(addedIDXs=range(0, len(vehCDs)), addedCDs=vehCDs)
    def _applyVehiclesFromCache(self, data):
        """
        Restores vehicle from cached data
        :param data: tuple - (strCD, crewLvl)
        :return:
        """
        if not data:
            return
        vehCDs = []
        for strCD, crewLvl in data:
            intCD = VehicleDescr(strCD).type.compactDescr
            vehCmpData = self._createVehCompareData(intCD, {'strCD': strCD,
             'crewLvl': crewLvl,
             'isFromCache': True})
            if vehCmpData:
                self.__vehicles.append(vehCmpData)
                vehCDs.append(intCD)

        if vehCDs:
            self.__applyChanges(addedIDXs=range(0, len(vehCDs)), addedCDs=vehCDs)
Beispiel #8
0
    def _construct(self, vehicleType=None):
        for container in scaffold():
            self._containers[container.getAreaID()] = container

        if not self.vehicleCD:
            return
        else:
            if IS_EDITOR and vehicleType is not None:
                vehicleDescriptor = vehicleType
            else:
                vehicleDescriptor = VehicleDescr(compactDescr=self.vehicleCD)
            projDecalType = SLOT_TYPE_TO_ANCHOR_TYPE_MAP[GUI_ITEM_TYPE.PROJECTION_DECAL]
            areasAnchors = ((anchor for anchor in vehicleDescriptor.chassis.slotsAnchors),
             (anchor for anchor in vehicleDescriptor.hull.slotsAnchors),
             (anchor for anchor in vehicleDescriptor.turret.slotsAnchors),
             (anchor for anchor in vehicleDescriptor.gun.slotsAnchors))
            projDecalRegions = [ anchor.slotId for areaAnchors in areasAnchors for anchor in areaAnchors if anchor.type == projDecalType ]
            projectionDeclasMultiSlot = ProjectionDecalsMultiSlot(slotTypes=(GUI_ITEM_TYPE.PROJECTION_DECAL,), regions=projDecalRegions, limit=MAX_PROJECTION_DECALS)
            self.misc.setSlotFor(GUI_ITEM_TYPE.PROJECTION_DECAL, projectionDeclasMultiSlot)
            return
    def _applyVehiclesFromCache(self, data):
        if not data:
            return
        else:
            vehCDs = []
            for strCD, equipment, crew, shellIndex, hasCamouflage, booster, postProgression, dynSlotID in data:
                intCD = VehicleDescr(strCD).type.compactDescr
                vehCmpData = self._createVehCompareData(
                    intCD,
                    initParameters={
                        'strCD':
                        strCD,
                        'isFromCache':
                        True,
                        'crewData':
                        crew,
                        'equipment':
                        equipment,
                        'shellIndex':
                        shellIndex,
                        'hasCamouflage':
                        hasCamouflage,
                        'battleBooster':
                        booster,
                        'postProgressionState':
                        VehicleState(postProgression),
                        'dynSlotType':
                        vehicles.g_cache.supplySlots().slotDescrs[dynSlotID]
                        if dynSlotID else None
                    })
                if vehCmpData:
                    self.__vehicles.append(vehCmpData)
                    vehCDs.append(intCD)

            if vehCDs:
                self.__applyChanges(addedIDXs=range(0, len(vehCDs)),
                                    addedCDs=vehCDs)
            return
Beispiel #10
0
 def __createOutfit(self, season, vehicleCD='', diff=None):
     component = deepcopy(self.descriptor.outfits[season])
     vehDescr = None
     if vehicleCD:
         vehDescr = VehicleDescr(vehicleCD)
     if vehDescr and ItemTags.ADD_NATIONAL_EMBLEM in self.tags:
         emblems = createNationalEmblemComponents(vehDescr)
         component.decals.extend(emblems)
     if vehDescr and self.isProgressive:
         vehicle = self._itemsCache.items.getItemByCD(
             vehDescr.type.compactDescr)
         component.styleProgressionLevel = self.getLatestOpenedProgressionLevel(
             vehicle)
     if diff is not None:
         diffComponent = parseCompDescr(diff)
         if component.styleId != diffComponent.styleId:
             _logger.error(
                 'Merging outfits of different styles is not allowed. ID1: %s ID2: %s',
                 component.styleId, diffComponent.styleId)
         else:
             component = component.applyDiff(diffComponent)
     return self.itemsFactory.createOutfit(component=component,
                                           vehicleCD=vehicleCD)
 def __setVoiceoverByVehicleOrTankman(self, vehiclePublicInfo, isPlayerVehicle):
     vehicleType = VehicleDescr(vehiclePublicInfo.compDescr).type
     if self.__setSpecialVoiceByVehicle(vehicleType.name, isPlayerVehicle):
         return
     else:
         nationID, _ = vehicleType.id
         isFemale = False
         crewGroups = vehiclePublicInfo.crewGroups
         if crewGroups:
             groupID, isFemale, isPremium = tankmen.unpackCrewParams(crewGroups[0])
             if self.__setSpecialVoiceByTankmen(nationID, groupID, isPremium, crewGroups):
                 return
         else:
             _logger.error('There is not information about vehicle commander to extract correct sound mode')
         preset = SoundGroups.g_instance.soundModes.currentNationalPreset
         isNationalPreset = preset[1] if preset is not None else False
         if isNationalPreset:
             commanderSkinID = vehiclePublicInfo.commanderSkinID
             if self.__setSpecialVoiceByCommanderSkinID(isFemale, commanderSkinID):
                 return
         genderSwitch = CREW_GENDER_SWITCHES.FEMALE if isFemale and isNationalPreset else CREW_GENDER_SWITCHES.DEFAULT
         SoundGroups.g_instance.soundModes.setCurrentNation(nations.NAMES[nationID], genderSwitch)
         return
Beispiel #12
0
 def _getVehicleLevel(self, vInfoVO):
     descriptor = VehicleDescr(
         compactDescr=vInfoVO.vehicleType.strCompactDescr)
     return max(descriptor.chassis.level, descriptor.turret.level,
                descriptor.gun.level, descriptor.radio.level,
                descriptor.engine.level)
Beispiel #13
0
def new_refreshNationalVoice(base, self, *a, **kw):
    base(self, *a, **kw)
    player = BigWorld.player()
    if not g_config.data['enabled'] or self.id not in (player.playerVehicleID, player.observedVehicleID):
        return
    g_config.setSystemValue(nations.NAMES[VehicleDescr(self.publicInfo.compDescr).type.id[0]])
Beispiel #14
0
 def _validateVehicle(self, other):
     if not self.vehicleCD or not other.vehicleCD or VehicleDescr(compactDescr=self.vehicleCD).type.compactDescr != VehicleDescr(compactDescr=other.vehicleCD).type.compactDescr:
         raise SoftException("Outfit's vehicleDescriptors are different")
 def getEmptyOutfitWithNationalEmblems(self, vehicleCD):
     vehDesc = VehicleDescr(vehicleCD)
     decals = createNationalEmblemComponents(vehDesc)
     component = CustomizationOutfit(decals=decals)
     return self.itemsFactory.createOutfit(component=component,
                                           vehicleCD=vehicleCD)