当前位置: 首页>>代码示例>>Python>>正文


Python Filter.fini方法代码示例

本文整理汇总了Python中filter.Filter.fini方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.fini方法的具体用法?Python Filter.fini怎么用?Python Filter.fini使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在filter.Filter的用法示例。


在下文中一共展示了Filter.fini方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Carousel

# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import fini [as 别名]
class Carousel(object):

    def __init__(self, aggregatedData):
        self.__aData = aggregatedData
        self.__currentType = CUSTOMIZATION_TYPE.CAMOUFLAGE
        self.__currentSlotIdx = 0
        self.__currentDuration = 0
        self.__carouselItems = []
        self.filter = Filter(self.__aData.availableGroupNames)
        self.filter.changed += self.__updateCarouselData
        self.slots = Slots(self.__aData)
        self.slots.selected += self.__onSlotSelected
        self.slots.updated += self.__onSlotUpdated
        self.updated = Event()

    def fini(self):
        self.slots.selected -= self.__onSlotSelected
        self.slots.updated -= self.__onSlotUpdated
        self.filter.changed -= self.__updateCarouselData
        self.__carouselItems = None
        self.__aData = None
        self.slots.fini()
        self.filter.fini()
        return

    @property
    def items(self):
        return self.__carouselItems

    @property
    def currentType(self):
        return self.__currentType

    @property
    def currentSlotIdx(self):
        return self.__currentSlotIdx

    def applyItem(self, carouselItemIdx):
        self.slots.updateSlot(self.__carouselItems[carouselItemIdx], duration=self.__currentDuration)

    def previewItem(self, carouselItemIdx):
        previewItemID = self.__carouselItems[carouselItemIdx]['id']
        if self.__currentType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
            g_hangarSpace.space.updateVehicleCamouflage(camouflageID=previewItemID)
        else:
            self.__updateItemOnTank3DModel(previewItemID)

    def changeDuration(self, duration):
        self.__currentDuration = duration
        self.__updateCarouselData()

    def __updateItemOnTank3DModel(self, previewItemID):
        cType = self.__currentType
        slotIdx = self.__currentSlotIdx
        slotItem = self.slots.getData()['data'][cType]['data'][slotIdx]
        changedPreviewModel = copy.deepcopy(self.__aData.viewModel[1:3])
        rawInstalledItem = [previewItemID, time.time(), 0]
        if cType == CUSTOMIZATION_TYPE.INSCRIPTION:
            rawInstalledItem.append(0)
        changedPreviewModel[cType - 1][slotItem['spot'] + self.slots.calculateVehicleIndex(slotIdx, cType)] = rawInstalledItem
        g_hangarSpace.space.updateVehicleSticker(changedPreviewModel)

    def __onSlotSelected(self, newType, newSlotIdx):
        self.__currentType = newType
        self.__currentSlotIdx = newSlotIdx
        self.filter.setTypeAndIdx(newType, newSlotIdx)
        if newType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
            self.filter.set(FILTER_TYPE.GROUP, CAMOUFLAGE_GROUP_MAPPING[newSlotIdx])
        self.filter.apply()

    def __getBtnTooltip(self, installedInSlot):
        if installedInSlot:
            params = (TOOLTIPS.CUSTOMIZATION_CAROUSEL_SLOT_REMOVE_HEADER, TOOLTIPS.CUSTOMIZATION_CAROUSEL_SLOT_REMOVE_BODY)
        else:
            params = (TOOLTIPS.CUSTOMIZATION_CAROUSEL_SLOT_SELECT_HEADER, TOOLTIPS.CUSTOMIZATION_CAROUSEL_SLOT_SELECT_BODY)
        return makeTooltip(*params)

    def __onSlotUpdated(self, newSlotData):
        self.__updateCarouselData()

    def __updateCarouselData(self):
        oldItemsCount = len(self.__carouselItems)
        del self.__carouselItems[:]
        appliedItems = []
        purchasedItems = []
        otherItems = []
        currentSlotItem = None
        installedItemID = self.slots.getInstalledItem(self.__currentSlotIdx, self.__currentType).getID()
        if self.__currentType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
            displayedItems = {}
            for itemID, item in self.__aData.displayed[self.__currentType].iteritems():
                if item.getGroup() == CAMOUFLAGE_GROUP_MAPPING[self.__currentSlotIdx]:
                    displayedItems[itemID] = item

        else:
            displayedItems = self.__aData.displayed[self.__currentType]
        for itemID, item in displayedItems.iteritems():
            if not self.filter.check(item):
                continue
            appliedToCurrentSlot = itemID == self.slots.getSelectedSlotItemID()
#.........这里部分代码省略.........
开发者ID:webiumsk,项目名称:WOT0.10.0,代码行数:103,代码来源:carousel.py

示例2: Carousel

# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import fini [as 别名]
class Carousel(object):

    def __init__(self, aggregatedData):
        self.__aData = aggregatedData
        self.__currentType = CUSTOMIZATION_TYPE.CAMOUFLAGE
        self.__currentSlotIdx = 0
        self.__currentDuration = 0
        self.__carouselItems = []
        self.filter = Filter(self.__aData.availableGroupNames)
        self.filter.changed += self.__updateCarouselData
        self.slots = Slots(self.__aData)
        self.slots.selected += self.__onSlotSelected
        self.slots.updated += self.__onSlotUpdated
        self.updated = Event()

    def fini(self):
        self.slots.selected -= self.__onSlotSelected
        self.slots.updated -= self.__onSlotUpdated
        self.filter.changed -= self.__updateCarouselData
        self.__carouselItems = None
        self.__aData = None
        self.slots.fini()
        self.filter.fini()
        return

    @property
    def items(self):
        return self.__carouselItems

    @property
    def currentType(self):
        return self.__currentType

    @property
    def currentSlotIdx(self):
        return self.__currentSlotIdx

    def applyItem(self, carouselItemIdx):
        carouselItem = self.__carouselItems[carouselItemIdx]
        self.slots.applyItem(carouselItem, duration=self.__currentDuration)

    def changeDuration(self, duration):
        self.__currentDuration = duration
        self.__updateCarouselData()

    def __onSlotSelected(self, newType, newSlotIdx):
        self.__currentType = newType
        self.__currentSlotIdx = newSlotIdx
        self.filter.setTypeAndIdx(newType, newSlotIdx)
        if newType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
            self.filter.set(FILTER_TYPE.GROUP, CAMOUFLAGE_GROUP_MAPPING[newSlotIdx])
        self.filter.apply()

    def __onSlotUpdated(self, newSlotData):
        if self.__currentType == newSlotData['type'] and self.__currentSlotIdx == newSlotData['idx']:
            self.filter.setTypeAndIdx(newSlotData['type'], newSlotData['idx'])
            self.__updateCarouselData()

    def __updateCarouselData(self):
        oldItemsCount = len(self.__carouselItems)
        del self.__carouselItems[:]
        appliedItems = defaultdict(list)
        purchasedItems = defaultdict(list)
        otherItems = defaultdict(list)
        allItems = [appliedItems, purchasedItems, otherItems]
        currentSlotItem = None
        installedItemID = self.slots.getInstalledItem(self.__currentSlotIdx, self.__currentType).getID()
        if self.__currentType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
            displayedItems = {}
            for itemID, item in self.__aData.displayed[self.__currentType].iteritems():
                if item.getGroup() == CAMOUFLAGE_GROUP_MAPPING[self.__currentSlotIdx]:
                    displayedItems[itemID] = item

        else:
            displayedItems = self.__aData.displayed[self.__currentType]
        filterExceptions = {FILTER_TYPE.SHOW_IN_DOSSIER: self.__aData.installed[self.__currentType]}
        for itemID, item in displayedItems.iteritems():
            if self.filter.check(item, filterExceptions):
                appliedToCurrentSlot = itemID == self.slots.getSelectedSlotItemID()
                installedInSlot = itemID == installedItemID
                isInQuests = item.isInQuests and not item.isInDossier and self.filter.purchaseType == PURCHASE_TYPE.QUEST
                carouselItem = {'id': itemID,
                 'object': item,
                 'appliedToCurrentSlot': appliedToCurrentSlot,
                 'price': item.getPrice(self.__currentDuration),
                 'priceIsGold': item.priceIsGold(self.__currentDuration),
                 'isInDossier': item.isInDossier,
                 'isInQuests': isInQuests,
                 'duration': self.__currentDuration,
                 'installedInSlot': installedInSlot}
                if appliedToCurrentSlot:
                    currentSlotItem = carouselItem
                if installedInSlot:
                    group = appliedItems[item.getGroup()]
                elif item.isInDossier:
                    group = purchasedItems[item.getGroup()]
                else:
                    group = otherItems[item.getGroup()]
                if item.isFeatured:
                    group.insert(0, carouselItem)
#.........这里部分代码省略.........
开发者ID:aevitas,项目名称:wotsdk,代码行数:103,代码来源:customization_2_0carousel.py


注:本文中的filter.Filter.fini方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。