Beispiel #1
0
    def setAnchors(self, displayObjects):
        if self.__vehicleCustomizationAnchors is None:
            _logger.error('Missing WGVehicleCustomizationAnchors.')
            return
        else:
            self.__delAllAnchors()
            modeId = self.__ctx.modeId
            tabId = self.__ctx.mode.tabId
            styleSlot = C11nId(areaId=Area.MISC,
                               slotType=GUI_ITEM_TYPE.STYLE,
                               regionIdx=0)
            styleAnchorParams = self.__ctx.mode.getAnchorParams(styleSlot)
            for displayObject in displayObjects:
                if not hasattr(displayObject, 'slotData'):
                    _logger.error(
                        'Incorrect anchor displayObject. Missing slotData section. %s',
                        displayObject)
                    continue
                slotData = displayObject.slotData
                slotId = C11nId(areaId=slotData.slotId.areaId,
                                slotType=slotData.slotId.slotType,
                                regionIdx=slotData.slotId.regionIdx)
                anchorParams = self.__ctx.mode.getAnchorParams(slotId)
                if anchorParams is None:
                    _logger.error('Failed to get anchor params for slotId: %s',
                                  slotId)
                    continue
                if modeId == CustomizationModes.EDITABLE_STYLE and slotId.slotType in EDITABLE_STYLE_APPLY_TO_ALL_AREAS_TYPES:
                    location = styleAnchorParams.location
                else:
                    location = anchorParams.location
                linesPosition = copy(location.position)
                slotWidth = 0.0
                if tabId in (CustomizationTabs.EMBLEMS,
                             CustomizationTabs.INSCRIPTIONS):
                    slotWidth = anchorParams.descriptor.size
                    slotHeight = slotWidth * SLOT_ASPECT_RATIO[slotId.slotType]
                    linesShift = slotHeight * _LINES_SHIFT
                    linesPosition -= location.up * linesShift
                position = location.position
                direction = location.normal
                uid = self.__vehicleCustomizationAnchors.addAnchor(
                    position, direction, linesPosition, slotWidth,
                    displayObject, True, True, False, True)
                anchor = Anchor(slotId, uid, position, direction)
                if slotId.slotType == GUI_ITEM_TYPE.PROJECTION_DECAL:
                    self.__closeGroups.add(slotId)
                    for aId, a in self.__processedAnchors.iteritems():
                        dist = (a.position - anchor.position).length
                        if dist < _MIN_PROJECTION_DECAL_ANCHORS_DIST:
                            self.__closeGroups.union(aId, slotId)

                self.__processedAnchors[slotId] = anchor
                anchor.setup()

            self.__changeAnchorsStates()
            self.__updateAnchorsVisability()
            return
Beispiel #2
0
 def tabChanged(self, tabIndex):
     self._tabIndex = tabIndex
     if self._tabIndex == C11nTabs.EFFECT:
         self._selectedAnchor = C11nId(areaId=Area.MISC,
                                       slotType=GUI_ITEM_TYPE.MODIFICATION,
                                       regionIdx=0)
     elif self._tabIndex == C11nTabs.STYLE:
         self._selectedAnchor = C11nId(areaId=Area.MISC,
                                       slotType=GUI_ITEM_TYPE.STYLE,
                                       regionIdx=0)
     else:
         self._selectedAnchor = C11nId()
     self._selectedCaruselItem = CaruselItemData()
     self.onCustomizationTabChanged(tabIndex)
Beispiel #3
0
 def tabChanged(self, tabIndex):
     self._tabIndex = tabIndex
     mode = self._mode
     if self._tabIndex == C11nTabs.EFFECT:
         self._selectedAnchor = C11nId(areaId=Area.MISC, slotType=GUI_ITEM_TYPE.MODIFICATION, regionIdx=0)
     elif self._tabIndex == C11nTabs.STYLE:
         self._selectedAnchor = C11nId(areaId=Area.MISC, slotType=GUI_ITEM_TYPE.STYLE, regionIdx=0)
     else:
         self._selectedAnchor = C11nId()
     self._selectedCarouselItem = CaruselItemData()  # noqa
     self._lastTab[self.actualMode] = self._tabIndex
     if self._mode != mode:
         self.refreshOutfit()
     self.onCustomizationTabChanged(tabIndex)
     if self._mode != mode:
         self.onCustomizationModeChanged(self._mode)
    def setAnchors(self, displayObjects):
        if self.__vehicleCustomizationAnchors is not None:
            processedObjectIds = {}
            self._delAllAnchors()
            for displayObject in displayObjects:
                if hasattr(displayObject, 'slotData'):
                    slotId = displayObject.slotData.slotId
                    customSlotId = C11nId(areaId=slotId.areaId,
                                          slotType=slotId.slotId,
                                          regionIdx=slotId.regionId)
                    anchorParams = self.__getAnchorParams(customSlotId)
                    if anchorParams is not None:
                        anchorWorldPos = Math.Vector3(anchorParams.pos)
                        normal = Math.Vector3(anchorParams.normal)
                        if self.__ctx.currentTab in C11nTabs.REGIONS:
                            if customSlotId.areaId != Area.GUN:
                                normal.normalise()
                                anchorWorldPos -= normal * 0.2
                        scaleformUid = self.__vehicleCustomizationAnchors.addAnchor(
                            anchorWorldPos, normal, displayObject, True, True,
                            True)
                        processedObjectIds[customSlotId] = scaleformUid

            self.__processedAnchors = processedObjectIds
        return
Beispiel #5
0
 def anchorSelected(self, slotType, areaId, regionIdx):
     if self._tabIndex in (C11nTabs.EFFECT, C11nTabs.STYLE):
         return False
     else:
         prevSelectedAnchor = self._selectedAnchor
         self._selectedAnchor = C11nId(areaId=areaId,
                                       slotType=slotType,
                                       regionIdx=regionIdx)
         if prevSelectedAnchor != self._selectedAnchor:
             if self._vehicleAnchorsUpdater is not None and self.currentTab in C11nTabs.REGIONS:
                 self._vehicleAnchorsUpdater.changeAnchorParams(
                     prevSelectedAnchor, True, True)
         self.onCustomizationAnchorSelected(self._selectedAnchor.slotType,
                                            self._selectedAnchor.areaId,
                                            self._selectedAnchor.regionIdx)
         if areaId != -1 and regionIdx != -1 and self._selectedCaruselItem.intCD != -1:
             outfit = self._modifiedOutfits[self._currentSeason]
             slotId = self.__getFreeSlot(self._selectedAnchor, outfit)
             if slotId is None or not self.__isItemInstalledInOutfitSlot(
                     slotId, self._selectedCaruselItem.intCD):
                 item = self.service.getItemByCD(
                     self._selectedCaruselItem.intCD)
                 component = self.__getComponent(item.id,
                                                 self.selectedAnchor)
                 if self.installItem(self._selectedCaruselItem.intCD,
                                     slotId,
                                     SEASON_TYPE_TO_IDX[self.currentSeason],
                                     component):
                     return True
         return False
Beispiel #6
0
    def removeItemForAllSeasons(self, areaId, slotType, regionIdx):
        slotId = C11nId(areaId=areaId, slotType=slotType, regionIdx=regionIdx)
        for season in SeasonType.COMMON_SEASONS:
            self.removeItemFromSlot(season, slotId, refresh=False)

        self.refreshOutfit()
        self.onCustomizationItemsRemoved()
 def _getAnchorVOs(self):
     slotId = C11nId(self.STYLE_SLOT.areaId, self.STYLE_SLOT.slotType,
                     self.STYLE_SLOT.regionIdx)
     uid = customizationSlotIdToUid(slotId)
     intCD = self.modifiedStyle.intCD if self.modifiedStyle is not None else 0
     anchorVO = CustomizationSlotUpdateVO(slotId=slotId._asdict(),
                                          itemIntCD=intCD,
                                          uid=uid)
     return [anchorVO._asdict()]
Beispiel #8
0
 def removeItemFromAllTankAreas(self, season, slotType):
     for areaId in Area.TANK_PARTS:
         regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
             areaId, slotType)
         for regionIdx in regionsIndexes:
             slotId = C11nId(areaId=areaId,
                             slotType=slotType,
                             regionIdx=regionIdx)
             self.removeItemFromSlot(season, slotId)
def removeUnselectedItemsFromEditableStyle(modifiedOutfits, baseOutfits, purchaseItems):
    for pItem in purchaseItems:
        if pItem.selected:
            continue
        season = pItem.group
        slotId = C11nId(pItem.areaID, pItem.slotType, pItem.regionIdx)
        outfit = modifiedOutfits[season]
        baseOutfit = baseOutfits[season]
        removeItemFromEditableStyle(outfit, baseOutfit, slotId)
Beispiel #10
0
    def removeItemFromAllTankAreas(self, season, slotType):
        for areaId in Area.TANK_PARTS:
            regionsIndexes = getAvailableRegions(areaId, slotType)
            for regionIdx in regionsIndexes:
                slotId = C11nId(areaId=areaId, slotType=slotType, regionIdx=regionIdx)
                self.removeItem(slotId, season, refresh=False)

        self._ctx.refreshOutfit(season)
        self._events.onItemsRemoved()
Beispiel #11
0
 def _currentSlotData(self):
     if self._slotID == -1 or self._areaID == -1 or self._slotID == GUI_ITEM_TYPE.STYLE:
         return
     else:
         slot = self.__ctx.currentOutfit.getContainer(self._areaID).slotFor(
             self._slotID)
         if slot is None or self._regionID == -1:
             return
         slotId = self.__ctx.getSlotIdByAnchorId(
             C11nId(self._areaID, self._slotID, self._regionID))
         return slot.getSlotData(slotId.regionIdx)
Beispiel #12
0
 def __onProjectionDecalOnlyOnceHintShown(self):
     if self.__c11nSettings.get(PROJECTION_DECAL_HINT_SHOWN_FIELD, False):
         return
     else:
         isCarouselEmpty = not self._carouselDP.collection
         slotId = C11nId(Area.MISC, GUI_ITEM_TYPE.PROJECTION_DECAL, -1)
         multiSlot = getMultiSlot(self.__ctx.mode.currentOutfit, slotId)
         isSlotEmpty = multiSlot is not None and multiSlot.isEmpty()
         visible = isSlotEmpty and not isCarouselEmpty
         self.as_setProjectionDecalHintVisibilityS(visible)
         return
Beispiel #13
0
 def __removeElement(self):
     if self._slotID == GUI_ITEM_TYPE.STYLE:
         self.__ctx.removeStyle(self._currentStyle.intCD)
     else:
         slotId = self.__ctx.getSlotIdByAnchorId(
             C11nId(areaId=self._areaID,
                    slotType=self._slotID,
                    regionIdx=self._regionID))
         if slotId is not None:
             self.__ctx.removeItemFromSlot(self.__ctx.currentSeason, slotId)
     return
def getStylePurchaseItems(style, modifiedOutfits, c11nService=None, prolongRent=False, progressionLevel=-1):
    purchaseItems = []
    vehicle = g_currentVehicle.item
    vehicleCD = vehicle.descriptor.makeCompactDescr()
    isStyleInstalled = c11nService.getCurrentOutfit(SeasonType.SUMMER).id == style.id
    inventoryCounts = __getInventoryCounts(modifiedOutfits, vehicleCD)
    styleCount = style.fullInventoryCount(vehicle.intCD)
    isFromInventory = not prolongRent and (styleCount > 0 or isStyleInstalled)
    if style.isProgressive:
        totalPrice = ItemPrice(Money(), Money())
        currentProgressionLvl = style.getLatestOpenedProgressionLevel(vehicle)
        progressivePrice = style.getUpgradePrice(currentProgressionLvl, progressionLevel)
        if style.isProgressionPurchasable(progressionLevel):
            totalPrice = progressivePrice
        if not style.isHidden and not isFromInventory:
            totalPrice += style.getBuyPrice()
        isFromInventory = False if progressionLevel > currentProgressionLvl else isFromInventory
        purchaseItem = PurchaseItem(style, totalPrice, areaID=None, slotType=None, regionIdx=None, selected=True, group=AdditionalPurchaseGroups.STYLES_GROUP_ID, isFromInventory=isFromInventory, locked=True, progressionLevel=progressionLevel)
        purchaseItems.append(purchaseItem)
    else:
        purchaseItem = PurchaseItem(style, style.getBuyPrice(), areaID=None, slotType=None, regionIdx=None, selected=True, group=AdditionalPurchaseGroups.STYLES_GROUP_ID, isFromInventory=isFromInventory, locked=True)
        purchaseItems.append(purchaseItem)
    for season in SeasonType.COMMON_SEASONS:
        modifiedOutfit = modifiedOutfits[season]
        if style.isProgressive:
            modifiedOutfit = c11nService.removeAdditionalProgressionData(outfit=modifiedOutfit, style=style, vehCD=vehicleCD, season=season)
        baseOutfit = style.getOutfit(season, vehicleCD)
        for intCD, component, regionIdx, container, _ in modifiedOutfit.itemsFull():
            item = c11nService.getItemByCD(intCD)
            itemTypeID = item.itemTypeID
            slotType = ITEM_TYPE_TO_SLOT_TYPE.get(itemTypeID)
            if slotType is None:
                continue
            slotId = C11nId(container.getAreaID(), slotType, regionIdx)
            modifiedSlotData = SlotData(intCD, component)
            baseSlotData = getSlotDataFromSlot(baseOutfit, slotId)
            isEdited = baseSlotData.intCD != modifiedSlotData.intCD
            if isEdited:
                if slotId != correctSlot(slotId):
                    continue
                price = item.getBuyPrice()
                isFromInventory = inventoryCounts[intCD] > 0 or item.isStyleOnly
                locked = bool(style.getDependenciesIntCDs()) and itemTypeID in EDITABLE_STYLE_IRREMOVABLE_TYPES and itemTypeID != GUI_ITEM_TYPE.CAMOUFLAGE
            else:
                price = ItemPrice(Money(credits=0), Money())
                isFromInventory = True
                locked = isPurchaseItemLocked(item, style)
            purchaseItem = PurchaseItem(item, price=price, areaID=slotId.areaId, slotType=slotId.slotType, regionIdx=slotId.regionIdx, selected=True, group=season, isFromInventory=isFromInventory, component=component, locked=locked, isEdited=isEdited)
            purchaseItems.append(purchaseItem)
            inventoryCounts[intCD] -= 1

    return purchaseItems
Beispiel #15
0
 def changeProjectionDecalScale(self, areaId, regionIdx, scale):
     slotId = self.getSlotIdByAnchorId(
         C11nId(areaId, GUI_ITEM_TYPE.PROJECTION_DECAL, regionIdx))
     slot = self.currentOutfit.getContainer(slotId.areaId).slotFor(
         slotId.slotType)
     component = slot.getComponent(slotId.regionIdx)
     if component.scaleFactorId != scale:
         component.scaleFactorId = scale
         self.refreshOutfit()
         self.onCustomizationProjectionDecalScaleChanged(
             areaId, regionIdx, scale)
         self.itemDataChanged(areaId, GUI_ITEM_TYPE.PROJECTION_DECAL,
                              regionIdx)
 def onClose(self):
     self.__ctx.events.onHideStyleInfo()
     self.disableBlur()
     self.__visible = False
     self.__selectedStyle = None
     if self.__prevStyle is None:
         slotId = C11nId(areaId=Area.MISC,
                         slotType=GUI_ITEM_TYPE.STYLE,
                         regionIdx=0)
         self.__ctx.mode.removeItem(slotId)
     elif self.__prevStyle != self.__ctx.mode.modifiedStyle:
         self.__installStyle(self.__prevStyle)
     self.__prevStyle = None
     return
Beispiel #17
0
    def installItemToAllTankAreas(self, season, slotType, slotData):
        additionallyAppliedItems = 0
        for areaId in Area.TANK_PARTS:
            regionsIndexes = getAvailableRegions(areaId, slotType)
            multiSlot = self._modifiedOutfits[season].getContainer(areaId).slotFor(slotType)
            for regionIdx in regionsIndexes:
                otherSlotData = multiSlot.getSlotData(regionIdx)
                df = slotData.weakDiff(otherSlotData)
                if not otherSlotData.intCD or df.intCD:
                    slotId = C11nId(areaId=areaId, slotType=slotType, regionIdx=regionIdx)
                    res = self.installItem(intCD=slotData.intCD, slotId=slotId, season=season, component=slotData.component)
                    if res:
                        additionallyAppliedItems += 1

        return additionallyAppliedItems
Beispiel #18
0
 def changeStyleProgressionLevelPreview(self, level):
     entity = self.hangarSpace.getVehicleEntity()
     if not entity or not level:
         return 1
     else:
         outfit = entity.appearance.outfit
         if not outfit.style or not outfit.style.isProgression:
             return 1
         outfit.setProgressionLevel(level)
         self.tryOnOutfit(outfit)
         if self.__customizationCtx is not None:
             slotID = C11nId(areaId=Area.MISC,
                             slotType=GUI_ITEM_TYPE.STYLE,
                             regionIdx=0)
             self.__customizationCtx.events.onComponentChanged(slotID, True)
         return outfit.progressionLevel
Beispiel #19
0
    def installItemForAllSeasons(self, areaID, slotType, regionIdx,
                                 currentSlotData):
        additionalyApplyedItems = 0
        for season in SeasonType.COMMON_SEASONS:
            slotData = self.getModifiedOutfit(season).getContainer(
                areaID).slotFor(slotType).getSlotData(regionIdx)
            df = currentSlotData.weakDiff(slotData)
            if slotData.item is None or df.item is not None:
                seasonIdx = SEASON_TYPE_TO_IDX[season]
                self.installItem(
                    currentSlotData.item.intCD,
                    C11nId(areaId=areaID,
                           slotType=slotType,
                           regionIdx=regionIdx), seasonIdx)
                additionalyApplyedItems += 1

        return additionalyApplyedItems
    def __getOriginalItemsData(self):
        itemData = {}
        notModifiedOutfit = self.__ctx.mode.getNotModifiedItems()
        for intCD, _, regionIdx, container, _ in notModifiedOutfit.itemsFull():
            item = self.__service.getItemByCD(intCD)
            if item.isHiddenInUI():
                continue
            if self.__isNonHistoric and item.isHistorical():
                continue
            areaId = container.getAreaID()
            slotType = ITEM_TYPE_TO_SLOT_TYPE[item.itemTypeID]
            slotId = C11nId(areaId, slotType, regionIdx)
            if intCD not in itemData:
                itemData[intCD] = C11nPopoverItemData(item=item, isFromInventory=True)
            itemData[intCD].slotsIds.append(slotId._asdict())

        itemBlocks = sorted(itemData.values(), key=orderKey)
        return itemBlocks
Beispiel #21
0
    def _getAnchorVOs(self):
        anchorVOs = []
        if g_currentVehicle.isPresent():
            for areaId in Area.ALL:
                slot = self.currentOutfit.getContainer(areaId).slotFor(self.slotType)
                for regionIdx, anchor in g_currentVehicle.item.getAnchors(self.slotType, areaId):
                    if anchor.hiddenForUser:
                        continue
                    model = self.currentOutfit.modelsSet or SLOT_DEFAULT_ALLOWED_MODEL
                    if model not in anchor.compatibleModels:
                        continue
                    slotId = C11nId(areaId, self.slotType, regionIdx)
                    intCD = slot.getItemCD(regionIdx)
                    uid = customizationSlotIdToUid(slotId)
                    anchorVO = CustomizationSlotUpdateVO(slotId=slotId._asdict(), itemIntCD=intCD, uid=uid)
                    anchorVOs.append(anchorVO._asdict())

        return anchorVOs
Beispiel #22
0
 def __init__(self):
     self._currentSeason = SeasonType.SUMMER
     self.__visibleTabs = defaultdict(set)
     self._tabIndex = C11nTabs.PAINT
     self._lastTab = C11nTabs.PAINT
     self._originalStyle = None
     self._modifiedStyle = None
     self._originalOutfits = {}
     self._modifiedOutfits = {}
     self._currentOutfit = None
     self._originalMode = C11nMode.CUSTOM
     self._mode = self._originalMode
     self._state = {}
     self._selectedCaruselItem = CaruselItemData()
     self._selectedAnchor = C11nId()
     self._eventsManager = Event.EventManager()
     self._vehicleAnchorsUpdater = None
     self._c11CameraManager = None
     self._autoRentEnabled = False
     self.onCustomizationSeasonChanged = Event.Event(self._eventsManager)
     self.onCustomizationModeChanged = Event.Event(self._eventsManager)
     self.onCustomizationTabChanged = Event.Event(self._eventsManager)
     self.onCustomizationItemInstalled = Event.Event(self._eventsManager)
     self.onCustomizationItemsRemoved = Event.Event(self._eventsManager)
     self.onCustomizationCamouflageColorChanged = Event.Event(
         self._eventsManager)
     self.onCustomizationCamouflageScaleChanged = Event.Event(
         self._eventsManager)
     self.onCustomizationProjectionDecalScaleChanged = Event.Event(
         self._eventsManager)
     self.onCustomizationItemsBought = Event.Event(self._eventsManager)
     self.onCustomizationItemSold = Event.Event(self._eventsManager)
     self.onCacheResync = Event.Event(self._eventsManager)
     self.onChangesCanceled = Event.Event(self._eventsManager)
     self.onCaruselItemSelected = Event.Event(self._eventsManager)
     self.onCaruselItemUnselected = Event.Event(self._eventsManager)
     self.onCarouselFilter = Event.Event(self._eventsManager)
     self.onCustomizationAnchorSelected = Event.Event(self._eventsManager)
     self.onPropertySheetShown = Event.Event(self._eventsManager)
     self.onPropertySheetHidden = Event.Event(self._eventsManager)
     self.onCustomizationItemDataChanged = Event.Event(self._eventsManager)
     self.onClearItem = Event.Event(self._eventsManager)
     return
Beispiel #23
0
    def removeItemsFromSeason(self,
                              season=None,
                              filterMethod=None,
                              refresh=True):
        season = season or self.season
        outfit = self._modifiedOutfits[season]
        for intCD, _, regionIdx, container, _ in outfit.itemsFull():
            item = self._service.getItemByCD(intCD)
            if item.isHiddenInUI():
                continue
            if filterMethod is None or filterMethod(item):
                areaId = container.getAreaID()
                slotType = ITEM_TYPE_TO_SLOT_TYPE[item.itemTypeID]
                slotId = C11nId(areaId, slotType, regionIdx)
                self.removeItem(slotId, season, refresh=False)

        if refresh:
            self._ctx.refreshOutfit(season)
            self._events.onItemsRemoved()
        return
Beispiel #24
0
    def installItemToAllTankAreas(self, season, slotType, currentSlotData):
        currentSeasonIdx = SEASON_TYPE_TO_IDX[season]
        additionalyApplyedItems = 0
        for areaId in Area.TANK_PARTS:
            regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
                areaId, slotType)
            multiSlot = self.currentOutfit.getContainer(areaId).slotFor(
                slotType)
            for regionIdx in regionsIndexes:
                slotData = multiSlot.getSlotData(regionIdx)
                df = currentSlotData.weakDiff(slotData)
                if slotData.item is None or df.item is not None:
                    self.installItem(
                        currentSlotData.item.intCD,
                        C11nId(areaId=areaId,
                               slotType=slotType,
                               regionIdx=regionIdx), currentSeasonIdx,
                        currentSlotData.component)
                    additionalyApplyedItems += 1

        return additionalyApplyedItems
Beispiel #25
0
    def getSlotIdByAnchorId(self, anchorId):
        if anchorId.slotType != GUI_ITEM_TYPE.PROJECTION_DECAL:
            return anchorId
        else:
            outfit = self._modifiedOutfits[self.currentSeason]
            anchorParams = self.service.getAnchorParams(
                anchorId.areaId, anchorId.slotType, anchorId.regionIdx)
            if anchorParams is None:
                return
            multySlot = outfit.getContainer(anchorId.areaId).slotFor(
                anchorId.slotType)
            if multySlot is not None:
                for regionIdx in range(multySlot.capacity()):
                    component = multySlot.getComponent(regionIdx)
                    if component is not None and component.slotId == anchorParams.vehicleSlotId:
                        return C11nId(areaId=anchorId.areaId,
                                      slotType=anchorId.slotType,
                                      regionIdx=regionIdx)

            return
            return
    def __getModifiedItemsData(self):
        itemData = {}
        purchaseItems = self.__ctx.mode.getPurchaseItems()
        purchaseItems = ifilter(lambda i: not i.isDismantling and i.group == self.__ctx.season, purchaseItems)
        modifiedOutfit = self.__ctx.mode.getModifiedOutfit()
        originalOutfit = self.__ctx.mode.getOriginalOutfit()
        for pItem in purchaseItems:
            if self.__isNonHistoric and pItem.item.isHistorical():
                continue
            slotId = C11nId(pItem.areaID, pItem.slotType, pItem.regionIdx)
            modifiedSlotData = getSlotDataFromSlot(modifiedOutfit, slotId)
            originalSlotData = getSlotDataFromSlot(originalOutfit, slotId)
            if modifiedSlotData is None or originalSlotData is None or modifiedSlotData.isEqual(originalSlotData):
                continue
            key = (pItem.item.intCD, pItem.isFromInventory)
            if key not in itemData:
                itemData[key] = C11nPopoverItemData(item=pItem.item, isFromInventory=pItem.isFromInventory)
            itemData[key].slotsIds.append(slotId._asdict())

        itemBlocks = sorted(itemData.values(), key=orderKey)
        return itemBlocks
Beispiel #27
0
    def __getFreeSlot(self, anchorId, outfit):
        slotId = self.getSlotIdByAnchorId(anchorId)
        if slotId is not None:
            return slotId
        elif anchorId.slotType not in QUANTITY_LIMITED_CUSTOMIZATION_TYPES:
            return anchorId
        else:
            container = outfit.getContainer(anchorId.areaId)
            if container is None:
                return
            multySlot = outfit.misc.slotFor(anchorId.slotType)
            if multySlot is None:
                return
            for regionIdx in range(
                    QUANTITY_LIMITED_CUSTOMIZATION_TYPES[anchorId.slotType]):
                if multySlot.getItem(regionIdx) is None:
                    return C11nId(areaId=anchorId.areaId,
                                  slotType=anchorId.slotType,
                                  regionIdx=regionIdx)

            return
            return
def getUnsuitableDependentData(outfit, selCamoItemID, styleDependencies, service=None):
    result = []
    styleDependencies = styleDependencies
    outfitItemsList = tuple(((cIntCD, regionIdx, container) for cIntCD, _, regionIdx, container, _ in outfit.itemsFull()))
    getItemByCD = service.getItemByCD
    camoDependencies = styleDependencies.get(selCamoItemID)
    if camoDependencies:
        for cIntCD, regionIdx, container in outfitItemsList:
            possiblyUnsuitable = getItemByCD(cIntCD)
            posUnsuitTypeId = possiblyUnsuitable.itemTypeID
            posUnsuitType = possiblyUnsuitable.descriptor.itemType
            posUnsuitId = possiblyUnsuitable.id
            dependentByType = camoDependencies.get(posUnsuitType)
            if dependentByType and posUnsuitId not in dependentByType:
                for dependent in styleDependencies.itervalues():
                    dItemIds = dependent.get(posUnsuitType)
                    if dItemIds and posUnsuitId in dItemIds:
                        slotType = ITEM_TYPE_TO_SLOT_TYPE[posUnsuitTypeId]
                        slotIdToChange = C11nId(container.getAreaID(), slotType, regionIdx)
                        result.append((possiblyUnsuitable, slotIdToChange))
                        break

    return result
def getStylePurchaseItems(style, modifiedOutfits, c11nService=None):
    purchaseItems = []
    vehicle = g_currentVehicle.item
    vehicleCD = vehicle.descriptor.makeCompactDescr()
    isStyleInstalled = c11nService.getCurrentOutfit(SeasonType.SUMMER).id == style.id
    inventoryCounts = __getInventoryCounts(modifiedOutfits, vehicleCD)
    styleCount = style.fullInventoryCount(vehicle.intCD)
    isFromInventory = styleCount > 0 or isStyleInstalled
    purchaseItem = PurchaseItem(style, style.getBuyPrice(), areaID=None, slotType=None, regionIdx=None, selected=True, group=AdditionalPurchaseGroups.STYLES_GROUP_ID, isFromInventory=isFromInventory, isDismantling=False, locked=True)
    purchaseItems.append(purchaseItem)
    for season in SeasonType.COMMON_SEASONS:
        modifiedOutfit = modifiedOutfits[season]
        baseOutfit = style.getOutfit(season, vehicleCD)
        for intCD, component, regionIdx, container, _ in modifiedOutfit.itemsFull():
            item = c11nService.getItemByCD(intCD)
            slotType = ITEM_TYPE_TO_SLOT_TYPE.get(item.itemTypeID)
            if slotType is None:
                continue
            slotId = C11nId(container.getAreaID(), slotType, regionIdx)
            modifiedSlotData = SlotData(intCD, component)
            baseSlotData = getSlotDataFromSlot(baseOutfit, slotId)
            isEdited = baseSlotData.intCD != modifiedSlotData.intCD
            if isEdited:
                if slotId != correctSlot(slotId):
                    continue
                price = item.getBuyPrice()
                isFromInventory = inventoryCounts[intCD] > 0 or item.isStyleOnly
                locked = False
            else:
                price = ItemPrice(Money(credits=0), Money())
                isFromInventory = True
                locked = isPurchaseItemLocked(item, style)
            purchaseItem = PurchaseItem(item, price=price, areaID=slotId.areaId, slotType=slotId.slotType, regionIdx=slotId.regionIdx, selected=True, group=season, isFromInventory=isFromInventory, component=component, locked=locked, isEdited=isEdited)
            purchaseItems.append(purchaseItem)
            inventoryCounts[intCD] -= 1

    return purchaseItems
 def changeStyleProgressionLevelPreview(self, level):
     entity = self.hangarSpace.getVehicleEntity()
     if not entity or not level or not entity.isVehicleLoaded:
         return 1
     else:
         outfit = entity.appearance.outfit
         if not outfit.style or not outfit.style.isProgression:
             return 1
         if g_currentPreviewVehicle.isPresent():
             vehicle = g_currentPreviewVehicle.item
             if vehicle:
                 season = g_tankActiveCamouflage.get(
                     vehicle.intCD, vehicle.getAnyOutfitSeason())
                 resOutfit = getStyleProgressionOutfit(
                     outfit, level, season)
                 self.tryOnOutfit(resOutfit)
                 if self.__customizationCtx is not None:
                     slotID = C11nId(areaId=Area.MISC,
                                     slotType=GUI_ITEM_TYPE.STYLE,
                                     regionIdx=0)
                     self.__customizationCtx.events.onComponentChanged(
                         slotID, True)
                 return resOutfit.progressionLevel
         return 1