Exemple #1
0
    def __setCarouselData(self, blData):
        itemVOs = []
        selectedIndex = -1
        for item in blData['items']:
            element = item['element']
            isInQuest = checkInQuest(element, self.__controller.filter.purchaseType)
            if item['installedInCurrentSlot']:
                label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_APPLIED)
            elif element.isInDossier:
                label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED)
            elif element.getIgrType() != IGR_TYPE.NONE:
                if element.getIgrType() == self.igrCtrl.getRoomType():
                    label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED)
                else:
                    label = icons.premiumIgrSmall()
            elif isInQuest:
                label = icons.quest()
            else:
                if item['duration'] == DURATION.PERMANENT:
                    priceFormatter = text_styles.gold
                    priceIcon = icons.gold()
                else:
                    priceFormatter = text_styles.credits
                    priceIcon = icons.credits()
                label = priceFormatter('{0}{1}'.format(element.getPrice(item['duration']), priceIcon))
            data = {'id': element.getID(),
             'icon': element.getTexturePath(),
             'label': label,
             'selected': item['appliedToCurrentSlot'] or item['installedInCurrentSlot'] and not blData['hasAppliedItem'],
             'goToTaskBtnVisible': isInQuest,
             'goToTaskBtnText': _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_ITEMCAROUSEL_RENDERER_GOTOTASK),
             'newElementIndicatorVisible': item['isNewElement']}
            if element.qualifier.getValue() > 0:
                data['bonusType'] = element.qualifier.getIcon16x16()
                data['bonusPower'] = text_styles.stats('+{0}%{1}'.format(element.qualifier.getValue(), '*' if element.qualifier.getDescription() is not None else ''))
            if data['selected']:
                selectedIndex = blData['items'].index(item)
            if element.isOnSale(item['duration']) and not element.isInDossier and not item['installedInCurrentSlot'] and not isInQuest:
                data['salePrice'] = getSalePriceString(self.__controller.slots.currentType, element, item['duration'])
            itemVOs.append(data)

        carouselLength = len(itemVOs)
        self.as_setCarouselDataS({'rendererList': itemVOs,
         'rendererWidth': blData['rendererWidth'],
         'filterCounter': '{0}{1}'.format(text_styles.stats(carouselLength) if carouselLength > 0 else text_styles.error(carouselLength), text_styles.main(_ms(VEHICLE_CUSTOMIZATION.CAROUSEL_FILTER_COUNTER, all=blData['unfilteredLength']))),
         'messageVisible': carouselLength == 0,
         'counterVisible': True,
         'goToIndex': blData['goToIndex'],
         'selectedIndex': selectedIndex})
        return
    def __setCarouselData(self, blData):
        itemVOs = []
        selectedIndex = -1
        for item in blData['items']:
            element = item['element']
            isInQuest = checkInQuest(element, self.__controller.filter.purchaseType)
            if item['installedInCurrentSlot']:
                label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_APPLIED)
            elif element.isInDossier:
                label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED)
            elif element.getIgrType() != IGR_TYPE.NONE:
                if element.getIgrType() == getIGRCtrl().getRoomType():
                    label = text_styles.main(VEHICLE_CUSTOMIZATION.CAROUSEL_ITEMLABEL_PURCHASED)
                else:
                    label = icons.premiumIgrSmall()
            elif isInQuest:
                label = icons.quest()
            else:
                if item['duration'] == DURATION.PERMANENT:
                    priceFormatter = text_styles.gold
                    priceIcon = icons.gold()
                else:
                    priceFormatter = text_styles.credits
                    priceIcon = icons.credits()
                label = priceFormatter('{0}{1}'.format(element.getPrice(item['duration']), priceIcon))
            data = {'id': element.getID(),
             'icon': element.getTexturePath(),
             'bonusType': element.qualifier.getIcon16x16(),
             'bonusPower': text_styles.stats('+{0}%{1}'.format(element.qualifier.getValue(), '*' if element.qualifier.getDescription() is not None else '')),
             'label': label,
             'selected': item['appliedToCurrentSlot'] or item['installedInCurrentSlot'] and not blData['hasAppliedItem'],
             'goToTaskBtnVisible': isInQuest,
             'goToTaskBtnText': _ms(VEHICLE_CUSTOMIZATION.CUSTOMIZATION_ITEMCAROUSEL_RENDERER_GOTOTASK),
             'newElementIndicatorVisible': item['isNewElement']}
            if data['selected']:
                selectedIndex = blData['items'].index(item)
            if element.isOnSale(item['duration']) and not element.isInDossier and not item['installedInCurrentSlot'] and not isInQuest:
                data['salePrice'] = getSalePriceString(self.__controller.slots.currentType, element, item['duration'])
            itemVOs.append(data)

        carouselLength = len(itemVOs)
        self.as_setCarouselDataS({'rendererList': itemVOs,
         'rendererWidth': blData['rendererWidth'],
         'filterCounter': '{0}{1}'.format(text_styles.stats(carouselLength) if carouselLength > 0 else text_styles.error(carouselLength), text_styles.main(_ms(VEHICLE_CUSTOMIZATION.CAROUSEL_FILTER_COUNTER, all=blData['unfilteredLength']))),
         'messageVisible': carouselLength == 0,
         'counterVisible': True,
         'goToIndex': blData['goToIndex'],
         'selectedIndex': selectedIndex})
        return
 def pickElement(self, carouselElementIdx):
     element = self.__carouselItems[carouselElementIdx]["element"]
     self.__events.onCarouselElementPicked(
         element, self.__currentDuration, checkInQuest(element, self.__filter.purchaseType)
     )
Exemple #4
0
 def pickElement(self, carouselElementIdx):
     element = self.__carouselItems[carouselElementIdx]['element']
     self.__events.onCarouselElementPicked(
         element, self.__currentDuration,
         checkInQuest(element, self.__filter.purchaseType))