예제 #1
0
def new_construct(self):
    block = old_construct(self)
    from gui.Scaleform.locale.RES_ICONS import RES_ICONS
    from gui.shared.formatters import text_styles, icons
    from gui.shared.items_parameters import formatters as params_formatters, bonus_helper
    from gui.shared.utils.functions import stripColorTagDescrTags
    from helpers.i18n import makeString as _ms
    from items import ITEM_TYPES
    if self.module.itemTypeID == ITEM_TYPES.optionalDevice:
        if bonus_helper.isSituationalBonus(self.module.name):
            effectDesc = text_styles.bonusPreviewText(stripColorTagDescrTags(_ms(self.module.fullDescription)))
            # noinspection PyArgumentEqualDefault
            icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_TOOLTIP_ASTERISK_OPTIONAL, 16, 16, 0, 4)
            desc = params_formatters.packSituationalIcon(effectDesc, icon)
        else:
            desc = text_styles.bonusAppliedText(stripColorTagDescrTags(_ms(self.module.fullDescription)))
        block[0]['data']['blocksData'][1]['data']['text'] = desc
    return block
        def __call__(self, bonus):
            result = []
            for item, count in bonus.getItems().iteritems():
                if item is not None and count:
                    description = item.fullDescription
                    if item.itemTypeID in (GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.EQUIPMENT):
                        description = stripColorTagDescrTags(description)
                    tooltip = makeTooltip(header=item.userName, body=description)
                    result.append(self._BonusFmt(item.icon, backport.getIntegralFormat(count), tooltip, None))

            return result
예제 #3
0
    def getList(self):
        result = []
        for item, count in self.getItems().iteritems():
            if item is not None and count:
                description = item.fullDescription
                if item.itemTypeID in (GUI_ITEM_TYPE.OPTIONALDEVICE, GUI_ITEM_TYPE.EQUIPMENT):
                    description = stripColorTagDescrTags(description)
                tooltip = makeTooltip(header=item.userName, body=description)
                result.append({'value': BigWorld.wg_getIntegralFormat(count),
                 'itemSource': item.icon,
                 'tooltip': tooltip})

        return result
예제 #4
0
def packTitleDescBlock(
        title,
        desc=None,
        gap=TXT_GAP_FOR_BIG_TITLE,
        useHtml=True,
        textBlockLinkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_TEXT_BLOCK_LINKAGE,
        blocksLinkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_LINKAGE,
        padding=None,
        descPadding=None):
    blocks = [packTextBlockData(title, useHtml, textBlockLinkage)]
    if desc is not None:
        blocks.append(
            packTextBlockData(stripColorTagDescrTags(desc), useHtml,
                              textBlockLinkage, descPadding))
    return packBuildUpBlockData(blocks, gap, blocksLinkage, padding)
예제 #5
0
def _doFormatToolTipFromText(tooltipID, formatType):
    result = ''
    for tooltipKind in _TOOLTIP_KIND:
        tooltipBlock = tooltipKind.upper()
        tags = {
            'open': '{' + tooltipBlock + '}',
            'close': '{/' + tooltipBlock + '}'
        }
        indicies = {
            'start': tooltipID.find(tags['open']),
            'end': tooltipID.find(tags['close'])
        }
        if indicies['start'] != -1 and indicies['end'] != -1:
            indicies['start'] += len(tags['open'])
            result += _getFormattedText(
                stripColorTagDescrTags(
                    tooltipID[indicies['start']:indicies['end']]),
                tooltipBlock, formatType)

    return result
    def _populate(self):
        super(View, self)._populate()
        module = self.itemsCache.items.getItemByCD(self.moduleCompactDescr)
        description = ''
        if module.itemTypeID in (GUI_ITEM_TYPE.OPTIONALDEVICE,
                                 GUI_ITEM_TYPE.EQUIPMENT):
            description = stripColorTagDescrTags(module.fullDescription)
        if module.itemTypeID in (GUI_ITEM_TYPE.OPTIONALDEVICE,
                                 GUI_ITEM_TYPE.SHELL, GUI_ITEM_TYPE.EQUIPMENT):
            icon = module.icon
        else:
            icon = module.level
        extraModuleInfo = ''
        moduleData = {
            'name':
            module.longUserName,
            'windowTitle':
            ' '.join(
                [module.longUserName,
                 i18n.makeString(MENU.MODULEINFO_TITLE)]),
            'type':
            module.itemTypeName,
            'description':
            description,
            'level':
            icon,
            'params': [],
            'compatible': [],
            'effects': {},
            'moduleLabel':
            module.getGUIEmblemID(),
            'moduleLevel':
            module.level
        }
        params = params_helper.get(module, self.__vehicleDescr)
        moduleParameters = params.get('parameters', {})
        formattedModuleParameters = formatters.getFormattedParamsList(
            module.descriptor, moduleParameters)
        extraParamsInfo = params.get('extras', {})
        isGun = module.itemTypeID == GUI_ITEM_TYPE.GUN
        isShell = module.itemTypeID == GUI_ITEM_TYPE.SHELL
        isChassis = module.itemTypeID == GUI_ITEM_TYPE.CHASSIS
        isOptionalDevice = module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE
        excludedParametersNames = extraParamsInfo.get('excludedParams',
                                                      tuple())
        highlightPossible = False
        if isGun:
            if 'maxShotDistance' in moduleParameters:
                if moduleParameters['maxShotDistance'] >= _DEF_SHOT_DISTANCE:
                    excludedParametersNames += ('maxShotDistance', )
            gunReloadingType = extraParamsInfo[GUN_RELOADING_TYPE]
            if gunReloadingType == GUN_CLIP:
                description = i18n.makeString(MENU.MODULEINFO_CLIPGUNLABEL)
                extraModuleInfo = RES_ICONS.MAPS_ICONS_MODULES_MAGAZINEGUNICON
            elif gunReloadingType == GUN_AUTO_RELOAD:
                description = i18n.makeString(
                    MENU.MODULEINFO_AUTORELOADGUNLABEL)
                extraModuleInfo = RES_ICONS.MAPS_ICONS_MODULES_AUTOLOADERGUN
                self._settingsCore.serverSettings.saveInUIStorage(
                    {UI_STORAGE_KEYS.AUTO_RELOAD_MARK_IS_SHOWN: True})
                highlightPossible = self._settingsCore.serverSettings.checkAutoReloadHighlights(
                    increase=True)
            elif gunReloadingType == GUN_CAN_BE_CLIP:
                otherParamsInfoList = []
                for paramName, paramValue in formattedModuleParameters:
                    if paramName in excludedParametersNames:
                        otherParamsInfoList.append({
                            'type':
                            formatters.formatModuleParamName(paramName) + '\n',
                            'value':
                            text_styles.stats(paramValue)
                        })

                moduleData['otherParameters'] = {
                    'headerText':
                    i18n.makeString(
                        MENU.MODULEINFO_PARAMETERSCLIPGUNLABEL,
                        getAbsoluteUrl(
                            RES_ICONS.MAPS_ICONS_MODULES_MAGAZINEGUNICON)),
                    'params':
                    otherParamsInfoList
                }
        if isChassis:
            if moduleParameters['isHydraulic']:
                description = i18n.makeString(
                    MENU.MODULEINFO_HYDRAULICCHASSISLABEL)
                extraModuleInfo = RES_ICONS.MAPS_ICONS_MODULES_HYDRAULICCHASSISICON
        moduleData['description'] = description
        paramsList = []
        for paramName, paramValue in formattedModuleParameters:
            if paramName not in excludedParametersNames:
                paramRow = {
                    'type': formatters.formatModuleParamName(paramName) + '\n',
                    'value': text_styles.stats(paramValue)
                }
                if highlightPossible and paramName == AUTO_RELOAD_PROP_NAME:
                    paramRow['highlight'] = True
                paramsList.append(paramRow)

        moduleData['parameters'] = {
            'headerText':
            i18n.makeString(MENU.MODULEINFO_PARAMETERSLABEL)
            if paramsList else '',
            'params':
            paramsList
        }
        moduleData[EXTRA_MODULE_INFO] = extraModuleInfo
        moduleCompatibles = params.get('compatible', tuple())
        for paramType, paramValue in moduleCompatibles:
            compatible = moduleData.get('compatible')
            compatible.append({
                'type':
                i18n.makeString(MENU.moduleinfo_compatible(paramType)),
                'value':
                paramValue
            })

        if module.itemTypeID == GUI_ITEM_TYPE.EQUIPMENT:
            effectsNametemplate = '#artefacts:%s/%s'
            if self.lobbyContext.getServerSettings(
            ).spgRedesignFeatures.isStunEnabled():
                isRemovingStun = module.isRemovingStun
            else:
                isRemovingStun = False
            onUseStr = 'removingStun/onUse' if isRemovingStun else 'onUse'
            moduleData['effects'] = {
                'effectOnUse':
                i18n.makeString(effectsNametemplate % (module.name, onUseStr)),
                'effectAlways':
                i18n.makeString(effectsNametemplate % (module.name, 'always')),
                'effectRestriction':
                i18n.makeString(effectsNametemplate %
                                (module.name, 'restriction'))
            }
            cooldownSeconds = module.descriptor.cooldownSeconds
            if cooldownSeconds > 0:
                moduleData['addParams'] = {
                    'type':
                    formatters.formatModuleParamName('cooldownSeconds') + '\n',
                    'value': text_styles.stats(cooldownSeconds) + '\n'
                }
        if isShell and self.__isAdditionalInfoShow is not None:
            moduleData['additionalInfo'] = self.__isAdditionalInfoShow
        if isOptionalDevice:
            moduleData[
                'highlightType'] = SLOT_HIGHLIGHT_TYPES.EQUIPMENT_PLUS if module.isDeluxe(
                ) else SLOT_HIGHLIGHT_TYPES.NO_HIGHLIGHT
        self.as_setModuleInfoS(moduleData)
        self._updateActionButton()
        return
 def fullDescription(self):
     return stripColorTagDescrTags(self.descriptor.description)
 def _getShortInfo(self, vehicle=None, expanded=False):
     return stripColorTagDescrTags(self.shortDescription)
예제 #9
0
 def _getShortInfo(self, vehicle=None, expanded=False):
     kpi = self.getKpi()
     return stripColorTagDescrTags(
         self.shortDescriptionSpecial) if not kpi or len(kpi) >= 2 or any(
             (bonus.type == KPI.Type.AGGREGATE_MUL
              for bonus in kpi)) else getKpiFormatDescription(kpi[0])
예제 #10
0
 def makeItemTooltip(item):
     description = item.fullDescription
     if item.itemTypeID in (GUI_ITEM_TYPE.OPTIONALDEVICE,
                            GUI_ITEM_TYPE.EQUIPMENT):
         description = stripColorTagDescrTags(description)
     return makeTooltip(header=item.userName, body=description)