Пример #1
0
    def _getInitialFilterVO(self, contexts):
        filters = self.filter.getFilters(self._usedFilters)
        filtersVO = {
            'mainBtn': {
                'value': getButtonsAssetPath('params'),
                'tooltip': TANK_CAROUSEL_FILTER.TOOLTIP_PARAMS
            },
            'hotFilters': [],
            'isVisible': self._getFiltersVisible()
        }
        for entry in self._usedFilters:
            filterCtx = contexts.get(entry, FilterSetupContext())
            filtersVO['hotFilters'].append({
                'id':
                entry,
                'value':
                getButtonsAssetPath(filterCtx.asset or entry),
                'selected':
                filters[entry],
                'enabled':
                True,
                'tooltip':
                makeTooltip(
                    '#tank_carousel_filter:tooltip/{}/header'.format(entry),
                    _ms('#tank_carousel_filter:tooltip/{}/body'.format(entry),
                        **filterCtx.ctx))
            })

        return filtersVO
    def _getInitialFilterVO(self, contexts):
        filters = self.filter.getFilters(self._usedFilters)
        filtersVO = {'mainBtn': {'value': getButtonsAssetPath('params'),
                     'tooltip': '#tank_carousel_filter:tooltip/params'},
         'hotFilters': [],
         'isVisible': self._getFiltersVisible()}
        for entry in self._usedFilters:
            filterCtx = contexts.get(entry, FilterSetupContext())
            filtersVO['hotFilters'].append({'id': entry,
             'value': getButtonsAssetPath(filterCtx.asset or entry),
             'selected': filters[entry],
             'enabled': True,
             'tooltip': makeTooltip('#tank_carousel_filter:tooltip/{}/header'.format(entry), _ms('#tank_carousel_filter:tooltip/{}/body'.format(entry), **filterCtx.ctx))})

        length = len(filtersVO['hotFilters'])
        for id_ in range(0, length):
            entry = filtersVO['hotFilters'][id_]
            if entry['id'] in _DISABLED_FILTERS:
                entry['enabled'] = False
                entry['selected'] = False

        return filtersVO
Пример #3
0
    def _getInitialVO(self, filters, xpRateMultiplier):
        mapping = self.__mapping
        vehType = self.__getSelectedVehType(filters)
        dataVO = {
            'nationsSectionId':
            _SECTION.NATIONS,
            'vehicleTypesSectionId':
            _SECTION.VEHICLE_TYPES,
            'levelsSectionId':
            _SECTION.LEVELS,
            'specialSectionId':
            _SECTION.SPECIALS,
            'hiddenSectionId':
            _SECTION.HIDDEN,
            'progressionsSectionId':
            _SECTION.PROGRESSIONS,
            'rolesSectionId':
            _SECTION.ROLES_WITH_EXTRA,
            'titleLabel':
            text_styles.highTitle('#tank_carousel_filter:popover/title'),
            'nationsLabel':
            text_styles.standard(
                '#tank_carousel_filter:popover/label/nations'),
            'vehicleTypesLabel':
            text_styles.standard(
                '#tank_carousel_filter:popover/label/vehicleTypes'),
            'levelsLabel':
            text_styles.standard('#tank_carousel_filter:popover/label/levels'),
            'specialsLabel':
            text_styles.standard(
                '#tank_carousel_filter:popover/label/specials'),
            'hiddenLabel':
            text_styles.standard('#tank_carousel_filter:popover/label/hidden'),
            'progressionsLabel':
            text_styles.standard(
                '#tank_carousel_filter:popover/label/progressions'),
            'rolesLabel':
            self.__getRolesLabel(vehType),
            'searchInputLabel':
            backport.text(R.strings.tank_carousel_filter.popover.label.
                          searchNameVehicle()),
            'searchInputName':
            filters.get('searchNameVehicle') or '',
            'searchInputTooltip':
            makeTooltip(
                '#tank_carousel_filter:tooltip/searchInput/header',
                backport.text(
                    R.strings.tank_carousel_filter.tooltip.searchInput.body(),
                    count=50)),
            'searchInputMaxChars':
            50,
            'nations': [],
            'vehicleTypes': [],
            'levels': [],
            'specials': [],
            'hidden': [],
            'progressions': [],
            'roles': {},
            'hiddenSectionVisible':
            True,
            'specialSectionVisible':
            True,
            'tankTierSectionVisible':
            True,
            'searchSectionVisible':
            True,
            'progressionsSectionVisible':
            False,
            'rolesSectionVisible':
            False,
            'changeableArrowDirection':
            False
        }

        def isSelected(entry):
            return filters.get(entry, False)

        for entry in mapping[_SECTION.NATIONS]:
            dataVO['nations'].append({
                'value':
                getNationsFilterAssetPath(entry),
                'tooltip':
                makeTooltip('#nations:{}'.format(entry),
                            '#tank_carousel_filter:tooltip/nations/body'),
                'selected':
                isSelected(entry)
            })

        for entry in mapping[_SECTION.LEVELS]:
            dataVO['levels'].append({
                'value': getLevelsAssetPath(entry),
                'selected': isSelected(entry)
            })

        for entry in mapping[_SECTION.VEHICLE_TYPES]:
            dataVO['vehicleTypes'].append({
                'value':
                getVehicleTypeAssetPath(entry),
                'tooltip':
                makeTooltip('#menu:carousel_tank_filter/{}'.format(entry),
                            '#tank_carousel_filter:tooltip/vehicleTypes/body'),
                'selected':
                isSelected(entry)
            })

        for entry in mapping[_SECTION.HIDDEN]:
            dataVO['hidden'].append({
                'label':
                text_styles.standard(
                    '#tank_carousel_filter:popover/checkbox/{}'.format(entry)),
                'tooltip':
                makeTooltip(
                    '#tank_carousel_filter:tooltip/{}/header'.format(entry),
                    '#tank_carousel_filter:tooltip/{}/body'.format(entry)),
                'selected':
                isSelected(entry)
            })

        for entry in mapping[_SECTION.SPECIALS]:
            contexts = getFilterPopoverSetupContexts(xpRateMultiplier)
            filterCtx = contexts.get(entry, FilterSetupContext())
            tooltipRes = R.strings.tank_carousel_filter.tooltip.dyn(entry)
            dataVO['specials'].append({
                'value':
                getButtonsAssetPath(filterCtx.asset or entry),
                'tooltip':
                makeTooltip(
                    backport.text(tooltipRes.header()) if tooltipRes else '',
                    backport.text(tooltipRes.body(), **filterCtx.ctx))
                if tooltipRes else '',
                'selected':
                isSelected(entry),
                'enabled':
                not (entry == 'bonus' and self._isFrontline)
            })

        for entry in mapping[_SECTION.PROGRESSIONS]:
            contexts = getFilterPopoverSetupContexts(xpRateMultiplier)
            filterCtx = contexts.get(entry, FilterSetupContext())
            tooltipRes = R.strings.tank_carousel_filter.tooltip.dyn(entry)
            dataVO['progressions'].append({
                'value':
                getButtonsAssetPath(filterCtx.asset or entry),
                'tooltip':
                makeTooltip(
                    backport.text(tooltipRes.header()) if tooltipRes else '',
                    backport.text(tooltipRes.body(), **filterCtx.ctx))
                if tooltipRes else '',
                'selected':
                isSelected(entry)
            })

        for vType in mapping[_SECTION.VEHICLE_TYPES]:
            if vType != VEHICLE_CLASS_NAME.SPG:
                dataVO['roles'][vType] = [
                    self.__getRoleVO(entry, filters)
                    for entry in mapping[_SECTION.ROLES].get(vType, [])
                    if entry is not None
                ]

        if not dataVO['hidden']:
            dataVO['hiddenSectionVisible'] = False
        if not dataVO['specials']:
            dataVO['specialSectionVisible'] = False
        if self._withRoles and vehType is not None and vehType is not VEHICLE_CLASS_NAME.SPG:
            dataVO['rolesSectionVisible'] = True
        return dataVO