def _removeItem(self, slotId, season=None):
     if self.__modifiedStyle is None:
         return
     elif slotId == self.STYLE_SLOT:
         self.__modifiedStyle = None
         self._modifiedOutfits = {
             s: self._service.getEmptyOutfit()
             for s in SeasonType.COMMON_SEASONS
         }
         return
     elif not self.__modifiedStyle.isEditable:
         return _logger.error(
             'Failed to remove item from slotId: %s for style: %s. Style is not Editable',
             slotId, self.__modifiedStyle)
     else:
         season = season or self.season
         outfit = self._modifiedOutfits[season]
         vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
         baseOutfit = self.__modifiedStyle.getOutfit(season,
                                                     vehicleCD=vehicleCD)
         fitOutfit(baseOutfit, getCurrentVehicleAvailableRegionsMap())
         removeItemFromEditableStyle(outfit, baseOutfit, slotId)
         diff = getEditableStyleOutfitDiff(outfit, baseOutfit)
         self._ctx.stylesDiffsCache.saveDiff(self.__modifiedStyle, season,
                                             diff)
         return
Ejemplo n.º 2
0
    def _onStart(self):
        if self._ctx.modeId != CustomizationModes.STYLED:
            _logger.error(
                'Failed to start Style Edit Mode. Style Edit Mode could be started only from Styled mode.'
            )
            self._ctx.changeMode(CustomizationModes.STYLED)
            return
        outfit = self._ctx.mode.currentOutfit
        if not outfit.id:
            _logger.error('Failed to start Style Edit Mode. No applied style.')
            self._ctx.changeMode(CustomizationModes.STYLED)
            return
        style = self._service.getItemByID(GUI_ITEM_TYPE.STYLE, outfit.id)
        if not style.isEditable:
            _logger.error(
                'Failed to start Style Edit Mode. Applied style is not editable.'
            )
            self._ctx.changeMode(CustomizationModes.STYLED)
            return
        self._isInited = False
        self.__style = style
        vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
        availableRegionsMap = getCurrentVehicleAvailableRegionsMap()
        for season in SeasonType.COMMON_SEASONS:
            baseOutfit = self.__style.getOutfit(season, vehicleCD)
            fitOutfit(baseOutfit, availableRegionsMap)
            self.__baseOutfits[season] = baseOutfit

        serverSettings = self._settingsCore.serverSettings
        if style.isProgressionRequired:
            hintShown = bool(
                serverSettings.getOnceOnlyHintsSetting(
                    OnceOnlyHints.
                    C11N_PROGRESSION_REQUIRED_STYLE_SLOT_BUTTON_HINT))
            if not hintShown:
                serverSettings.setOnceOnlyHintsSettings({
                    OnceOnlyHints.C11N_PROGRESSION_REQUIRED_STYLE_SLOT_HINT:
                    HINT_SHOWN_STATUS,
                    OnceOnlyHints.C11N_PROGRESSION_REQUIRED_STYLE_SLOT_BUTTON_HINT:
                    HINT_SHOWN_STATUS,
                    OnceOnlyHints.C11N_EDITABLE_STYLE_SLOT_HINT:
                    HINT_SHOWN_STATUS,
                    OnceOnlyHints.C11N_EDITABLE_STYLE_SLOT_BUTTON_HINT:
                    HINT_SHOWN_STATUS
                })
        else:
            hintShown = bool(
                serverSettings.getOnceOnlyHintsSetting(
                    OnceOnlyHints.C11N_EDITABLE_STYLE_SLOT_BUTTON_HINT))
            if not hintShown:
                serverSettings.setOnceOnlyHintsSettings({
                    OnceOnlyHints.C11N_EDITABLE_STYLE_SLOT_HINT:
                    HINT_SHOWN_STATUS,
                    OnceOnlyHints.C11N_EDITABLE_STYLE_SLOT_BUTTON_HINT:
                    HINT_SHOWN_STATUS
                })
        super(EditableStyleMode, self)._onStart()
Ejemplo n.º 3
0
    def __getSeasonItemsData(self, season, purchaseItems, availableRegionsMap,
                             vehicleDescriptor):
        itemData = {}
        for pItem in purchaseItems:
            item = pItem.item
            if item.isHiddenInUI():
                continue
            sType = getItemSlotType(item.descriptor)
            key = (pItem.item.intCD, pItem.isFromInventory)
            if key not in itemData:
                isBase = not pItem.isEdited
                if item.itemTypeID == GUI_ITEM_TYPE.STYLE:
                    isRemovable = False
                elif sType in self.__style.changeableSlotTypes:
                    isRemovable = not isBase or item.itemTypeID not in EDITABLE_STYLE_IRREMOVABLE_TYPES
                else:
                    isRemovable = False
                itemData[key] = C11nPopoverItemData(
                    item=item,
                    season=season,
                    isBase=isBase,
                    isRemovable=isRemovable,
                    isRemoved=False,
                    isFromInventory=pItem.isFromInventory)
            slotId = C11nId(pItem.areaID, pItem.slotType, pItem.regionIdx)
            itemData[key].slotsIds.append(slotId._asdict())

        baseOutfit = self.__style.getOutfit(
            season, vehicleCD=vehicleDescriptor.makeCompactDescr())
        fitOutfit(baseOutfit, availableRegionsMap)
        nationalEmblemItem = self.__service.getItemByID(
            GUI_ITEM_TYPE.EMBLEM, vehicleDescriptor.type.defaultPlayerEmblemID)
        showStyle = True
        nationalEmblemDetected = False
        otherDetected = False
        for intCD, _, regionIdx, container, _ in baseOutfit.itemsFull():
            item = self.__service.getItemByCD(intCD)
            if item.isHiddenInUI():
                continue
            else:
                showStyle = False
            if not nationalEmblemDetected and intCD == nationalEmblemItem.intCD:
                nationalEmblemDetected = True
            elif not otherDetected and intCD != nationalEmblemItem.intCD:
                otherDetected = True
            key = (intCD, True)
            if key not in itemData:
                itemData[key] = C11nPopoverItemData(item=item,
                                                    season=season,
                                                    isBase=True,
                                                    isRemoved=True,
                                                    isFromInventory=True)
            if itemData[key].isRemoved:
                areaId = container.getAreaID()
                slotType = ITEM_TYPE_TO_SLOT_TYPE[item.itemTypeID]
                slotId = C11nId(areaId, slotType, regionIdx)
                itemData[key].slotsIds.append(slotId._asdict())

        if nationalEmblemDetected and not otherDetected:
            showStyle = True
            key = (nationalEmblemItem.intCD, True)
            itemData.pop(key)
        if showStyle:
            key = (self.__style.intCD, True)
            itemData[key] = C11nPopoverItemData(item=self.__style,
                                                season=season,
                                                isBase=True,
                                                isRemoved=False,
                                                isFromInventory=True)
        data = [
            self.__makeItemDataVO(itemData)
            for itemData in sorted(itemData.values(), key=orderKey)
        ]
        return data
Ejemplo n.º 4
0
 def _fitOutfits(self, modifiedOnly=False):
     availableRegionsMap = getCurrentVehicleAvailableRegionsMap()
     for season in SeasonType.COMMON_SEASONS:
         fitOutfit(self._modifiedOutfits[season], availableRegionsMap)
         if not modifiedOnly:
             fitOutfit(self._originalOutfits[season], availableRegionsMap)