Ejemplo n.º 1
0
def _getDropdownPriceVO(element):
    result = []
    for duration, text in zip(DURATION.ALL, _DURATION_LABELS):
        if duration == DURATION.PERMANENT:
            textStyle = text_styles.gold
            icon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2
        else:
            textStyle = text_styles.credits
            icon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2
        dropdownItem = {
            'labelPrice':
            text_styles.main(_ms(text)),
            'label':
            makeHtmlString(
                'html_templates:lobby/customization', 'DDString', {
                    'text': textStyle(element.getPrice(duration)),
                    'icon': getAbsoluteUrl(icon)
                })
        }
        if element.isOnSale(duration):
            isGold = duration == DURATION.PERMANENT
            dropdownItem['salePrice'] = getSalePriceString(
                isGold, element, duration)
            dropdownItem['isSale'] = True
        result.append(dropdownItem)

    return result
Ejemplo n.º 2
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
Ejemplo n.º 3
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() == 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
Ejemplo n.º 4
0
def _getDropdownPriceVO(element):
    result = []
    for duration, text in zip(DURATION.ALL, _DURATION_LABELS):
        if duration == DURATION.PERMANENT:
            textStyle = text_styles.gold
            icon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICON_2
        else:
            textStyle = text_styles.credits
            icon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2
        dropdownItem = {'labelPrice': text_styles.main(_ms(text)),
         'label': makeHtmlString('html_templates:lobby/customization', 'DDString', {'text': textStyle(element.getPrice(duration)),
                   'icon': getAbsoluteUrl(icon)})}
        if element.isOnSale(duration):
            isGold = duration == DURATION.PERMANENT
            dropdownItem['salePrice'] = getSalePriceString(isGold, element, duration)
            dropdownItem['isSale'] = True
        result.append(dropdownItem)

    return result