Exemplo n.º 1
0
def ModuleInfoMeta_as_setModuleInfoS(base, self, moduleInfo):
    try:
        if moduleInfo.get('type') == 'shell':
            if not shells_vehicles_compatibility:
                relate_shells_vehicles()
            if self.moduleCompactDescr in shells_vehicles_compatibility:
                moduleInfo['compatible'].append({'type': i18n.makeString(MENU.moduleinfo_compatible('vehicles')), 'value': ', '.join(shells_vehicles_compatibility[self.moduleCompactDescr])})
    except Exception as ex:
        err(traceback.format_exc())
    base(self, moduleInfo)
    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
Exemplo n.º 3
0
    def _populate(self):
        super(View, self)._populate()
        module = getItemByCompact(self.moduleId)
        description = ''
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[11]):
            description = stripShortDescrTags(module.description)
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[10], ITEM_TYPE_NAMES[11]):
            icon = module.icon
        else:
            icon = module.level
        extraModuleInfo = ''
        moduleData = {'name': module.longName,
         'windowTitle': ' '.join([module.longName, i18n.makeString(MENU.MODULEINFO_TITLE)]),
         'type': module.itemTypeName,
         'description': description,
         'level': icon,
         'params': [],
         'compatible': [],
         'effects': {}}
        params = ItemsParameters.g_instance.get(module.descriptor, self.__vehicleDescr)
        moduleParameters = params.get('parameters', tuple())
        isGun = module.itemTypeName == ITEM_TYPE_NAMES[4]
        excludedParametersNames = []
        if isGun:
            gunReloadingType = dict(moduleParameters)[GUN_RELOADING_TYPE]
            LOG_DEBUG('gunReloadingTypegunReloadingTypegunReloadingTypegunReloadingType', gunReloadingType)
            if gunReloadingType == GUN_NORMAL:
                excludedParametersNames.append(SHELLS_COUNT_PROP_NAME)
                excludedParametersNames.append(RELOAD_MAGAZINE_TIME_PROP_NAME)
                excludedParametersNames.append(SHELL_RELOADING_TIME_PROP_NAME)
            elif gunReloadingType == GUN_CLIP:
                description = i18n.makeString(MENU.MODULEINFO_CLIPGUNLABEL)
                excludedParametersNames.append(RELOAD_TIME_PROP_NAME)
                extraModuleInfo = CLIP_ICON_PATH
            elif gunReloadingType == GUN_CAN_BE_CLIP:
                excludedParametersNames.append(SHELLS_COUNT_PROP_NAME)
                excludedParametersNames.append(RELOAD_MAGAZINE_TIME_PROP_NAME)
                excludedParametersNames.append(SHELL_RELOADING_TIME_PROP_NAME)
                otherParamsInfoList = []
                for paramType, paramValue in moduleParameters:
                    if paramType in excludedParametersNames:
                        otherParamsInfoList.append({'type': i18n.makeString(MENU.moduleinfo_params(paramType)),
                         'value': paramValue})

                imgPathArr = CLIP_ICON_PATH.split('..')
                imgPath = 'img://gui' + imgPathArr[1]
                moduleData['otherParameters'] = {'headerText': i18n.makeString(MENU.MODULEINFO_PARAMETERSCLIPGUNLABEL, imgPath),
                 'params': otherParamsInfoList}
        moduleData['description'] = description
        excludedParametersNames.append(GUN_RELOADING_TYPE)
        paramsList = []
        for paramType, paramValue in moduleParameters:
            if paramType not in excludedParametersNames:
                paramsList.append({'type': i18n.makeString(MENU.moduleinfo_params(paramType)),
                 'value': paramValue})

        moduleData['parameters'] = {'headerText': i18n.makeString(MENU.MODULEINFO_PARAMETERSLABEL) if len(paramsList) > 0 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.itemTypeName == ITEM_TYPE_NAMES[11]:
            effectsNametemplate = '#artefacts:%s/%s'
            moduleData['effects'] = {'effectOnUse': i18n.makeString(effectsNametemplate % (module.unicName, 'onUse')),
             'effectAlways': i18n.makeString(effectsNametemplate % (module.unicName, 'always')),
             'effectRestriction': i18n.makeString(effectsNametemplate % (module.unicName, 'restriction'))}
        self.as_setModuleInfoS(moduleData)
Exemplo n.º 4
0
    def _populate(self):
        super(View, self)._populate()
        module = g_itemsCache.items.getItemByCD(self.moduleCompactDescr)
        description = ''
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[11]):
            description = stripShortDescrTags(module.fullDescription)
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[10],
                                   ITEM_TYPE_NAMES[11]):
            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.itemTypeName == ITEM_TYPE_NAMES[4]
        isShell = module.itemTypeName == ITEM_TYPE_NAMES[10]
        isChassis = module.itemTypeName == ITEM_TYPE_NAMES[2]
        excludedParametersNames = extraParamsInfo.get('excludedParams',
                                                      tuple())
        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 = CLIP_ICON_PATH
            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)
                        })

                imgPathArr = CLIP_ICON_PATH.split('..')
                imgPath = 'img://gui' + imgPathArr[1]
                moduleData['otherParameters'] = {
                    'headerText':
                    i18n.makeString(MENU.MODULEINFO_PARAMETERSCLIPGUNLABEL,
                                    imgPath),
                    'params':
                    otherParamsInfoList
                }
        if isChassis:
            if moduleParameters['isHydraulic']:
                description = i18n.makeString(
                    MENU.MODULEINFO_HYDRAULICCHASSISLABEL)
                extraModuleInfo = HYDRAULIC_ICON_PATH
        moduleData['description'] = description
        paramsList = []
        for paramName, paramValue in formattedModuleParameters:
            if paramName not in excludedParametersNames:
                paramsList.append({
                    'type':
                    formatters.formatModuleParamName(paramName) + '\n',
                    'value':
                    text_styles.stats(paramValue)
                })

        moduleData['parameters'] = {
            'headerText':
            i18n.makeString(MENU.MODULEINFO_PARAMETERSLABEL)
            if len(paramsList) > 0 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.itemTypeName == ITEM_TYPE_NAMES[11]:
            effectsNametemplate = '#artefacts:%s/%s'
            moduleData['effects'] = {
                'effectOnUse':
                i18n.makeString(effectsNametemplate % (module.name, 'onUse')),
                'effectAlways':
                i18n.makeString(effectsNametemplate % (module.name, 'always')),
                'effectRestriction':
                i18n.makeString(effectsNametemplate %
                                (module.name, 'restriction'))
            }
        if isShell and self.__isAdditionalInfoShow is not None:
            moduleData['additionalInfo'] = self.__isAdditionalInfoShow
        self.as_setModuleInfoS(moduleData)
        self._updateActionButton()
        return
Exemplo n.º 5
0
    def _populate(self):
        super(View, self)._populate()
        module = g_itemsCache.items.getItemByCD(self.moduleCompactDescr)
        description = ''
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[11]):
            description = stripShortDescrTags(module.fullDescription)
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[10], ITEM_TYPE_NAMES[11]):
            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.itemTypeName == ITEM_TYPE_NAMES[4]
        isShell = module.itemTypeName == ITEM_TYPE_NAMES[10]
        excludedParametersNames = extraParamsInfo.get('excludedParams', tuple())
        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 = CLIP_ICON_PATH
            elif gunReloadingType == GUN_CAN_BE_CLIP:
                otherParamsInfoList = []
                for paramName, paramValue in formattedModuleParameters:
                    if paramName in excludedParametersNames:
                        otherParamsInfoList.append({'type': i18n.makeString(MENU.moduleinfo_params(paramName)) + '\n',
                         'value': paramValue})

                imgPathArr = CLIP_ICON_PATH.split('..')
                imgPath = 'img://gui' + imgPathArr[1]
                moduleData['otherParameters'] = {'headerText': i18n.makeString(MENU.MODULEINFO_PARAMETERSCLIPGUNLABEL, imgPath),
                 'params': otherParamsInfoList}
        moduleData['description'] = description
        paramsList = []
        for paramName, paramValue in formattedModuleParameters:
            if paramName not in excludedParametersNames:
                paramsList.append({'type': i18n.makeString(MENU.moduleinfo_params(paramName)) + '\n',
                 'value': paramValue})

        moduleData['parameters'] = {'headerText': i18n.makeString(MENU.MODULEINFO_PARAMETERSLABEL) if len(paramsList) > 0 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.itemTypeName == ITEM_TYPE_NAMES[11]:
            effectsNametemplate = '#artefacts:%s/%s'
            moduleData['effects'] = {'effectOnUse': i18n.makeString(effectsNametemplate % (module.name, 'onUse')),
             'effectAlways': i18n.makeString(effectsNametemplate % (module.name, 'always')),
             'effectRestriction': i18n.makeString(effectsNametemplate % (module.name, 'restriction'))}
        if isShell and self.__isAdditionalInfoShow is not None:
            moduleData['additionalInfo'] = self.__isAdditionalInfoShow
        self.as_setModuleInfoS(moduleData)
        self._updateActionButton()
        return
Exemplo n.º 6
0
    def _populate(self):
        super(View, self)._populate()
        module = getItemByCompact(self.moduleId)
        description = ''
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[11]):
            description = stripShortDescrTags(module.description)
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[10],
                                   ITEM_TYPE_NAMES[11]):
            icon = module.icon
        else:
            icon = module.level
        extraModuleInfo = ''
        moduleData = {
            'name':
            module.longName,
            'windowTitle':
            ' '.join([module.longName,
                      i18n.makeString(MENU.MODULEINFO_TITLE)]),
            'type':
            module.itemTypeName,
            'description':
            description,
            'level':
            icon,
            'params': [],
            'compatible': [],
            'effects': {}
        }
        params = ItemsParameters.g_instance.get(module.descriptor,
                                                self.__vehicleDescr)
        moduleParameters = params.get('parameters', tuple())
        isGun = module.itemTypeName == ITEM_TYPE_NAMES[4]
        excludedParametersNames = []
        if isGun:
            gunReloadingType = dict(moduleParameters)[GUN_RELOADING_TYPE]
            LOG_DEBUG(
                'gunReloadingTypegunReloadingTypegunReloadingTypegunReloadingType',
                gunReloadingType)
            if gunReloadingType == GUN_NORMAL:
                excludedParametersNames.append(SHELLS_COUNT_PROP_NAME)
                excludedParametersNames.append(RELOAD_MAGAZINE_TIME_PROP_NAME)
                excludedParametersNames.append(SHELL_RELOADING_TIME_PROP_NAME)
            elif gunReloadingType == GUN_CLIP:
                description = i18n.makeString(MENU.MODULEINFO_CLIPGUNLABEL)
                excludedParametersNames.append(RELOAD_TIME_PROP_NAME)
                extraModuleInfo = CLIP_ICON_PATH
            elif gunReloadingType == GUN_CAN_BE_CLIP:
                excludedParametersNames.append(SHELLS_COUNT_PROP_NAME)
                excludedParametersNames.append(RELOAD_MAGAZINE_TIME_PROP_NAME)
                excludedParametersNames.append(SHELL_RELOADING_TIME_PROP_NAME)
                otherParamsInfoList = []
                for paramType, paramValue in moduleParameters:
                    if paramType in excludedParametersNames:
                        otherParamsInfoList.append({
                            'type':
                            i18n.makeString(MENU.moduleinfo_params(paramType)),
                            'value':
                            paramValue
                        })

                imgPathArr = CLIP_ICON_PATH.split('..')
                imgPath = 'img://gui' + imgPathArr[1]
                moduleData['otherParameters'] = {
                    'headerText':
                    i18n.makeString(MENU.MODULEINFO_PARAMETERSCLIPGUNLABEL,
                                    imgPath),
                    'params':
                    otherParamsInfoList
                }
        moduleData['description'] = description
        excludedParametersNames.append(GUN_RELOADING_TYPE)
        paramsList = []
        for paramType, paramValue in moduleParameters:
            if paramType not in excludedParametersNames:
                paramsList.append({
                    'type':
                    i18n.makeString(MENU.moduleinfo_params(paramType)),
                    'value':
                    paramValue
                })

        moduleData['parameters'] = {
            'headerText':
            i18n.makeString(MENU.MODULEINFO_PARAMETERSLABEL)
            if len(paramsList) > 0 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.itemTypeName == ITEM_TYPE_NAMES[11]:
            effectsNametemplate = '#artefacts:%s/%s'
            moduleData['effects'] = {
                'effectOnUse':
                i18n.makeString(effectsNametemplate %
                                (module.unicName, 'onUse')),
                'effectAlways':
                i18n.makeString(effectsNametemplate %
                                (module.unicName, 'always')),
                'effectRestriction':
                i18n.makeString(effectsNametemplate %
                                (module.unicName, 'restriction'))
            }
        self.as_setModuleInfoS(moduleData)
Exemplo n.º 7
0
    def _packBlocks(self, *args, **kwargs):
        self.item = self.context.buildItem(*args, **kwargs)
        items = super(ShellBlockToolTipData, self)._packBlocks()
        shell = self.item
        statsConfig = self.context.getStatsConfiguration(shell)
        paramsConfig = self.context.getParamsConfiguration(shell)
        statusConfig = self.context.getStatusConfiguration(shell)
        valueWidth = 107
        leftPadding = 20
        rightPadding = 20
        lrPaddings = formatters.packPadding(left=leftPadding,
                                            right=rightPadding)
        blockTopPadding = -4
        blockPadding = formatters.packPadding(left=leftPadding,
                                              right=rightPadding,
                                              top=blockTopPadding)
        textGap = -2
        vDescr = paramsConfig.vehicle.descriptor if paramsConfig.vehicle is not None else None
        params = params_helper.getParameters(shell, vDescr)
        showBasicData = self.__basicDataAllowed and params['isBasic']
        items.append(
            formatters.packBuildUpBlockData(
                HeaderBlockConstructor(shell, statsConfig, leftPadding,
                                       rightPadding, params).construct(),
                padding=formatters.packPadding(left=35,
                                               right=rightPadding,
                                               top=14)))
        priceBlock, invalidWidth = PriceBlockConstructor(
            shell, statsConfig, 80).construct()
        if priceBlock:
            self._setWidth(
                _TOOLTIP_MAX_WIDTH if invalidWidth else _TOOLTIP_MIN_WIDTH)
            items.append(
                formatters.packBuildUpBlockData(priceBlock,
                                                padding=blockPadding,
                                                gap=textGap))
        statusBlock = StatusBlockConstructor(shell, statusConfig).construct()
        if self.__basicDataAllowed:
            statsBlock = CommonStatsBlockConstructor(shell, paramsConfig,
                                                     valueWidth,
                                                     params).construct()
        else:
            statsBlock = _AdvancedCommonStatsBlockConstructior(
                shell, paramsConfig, valueWidth, params).construct()
        bottomPadding = 4 if statusBlock or showBasicData else 0
        if statsBlock:
            items.append(
                formatters.packBuildUpBlockData(statsBlock,
                                                padding=formatters.packPadding(
                                                    left=leftPadding,
                                                    right=rightPadding,
                                                    top=blockTopPadding,
                                                    bottom=bottomPadding),
                                                gap=textGap))
        if statusBlock:
            items.append(
                formatters.packBuildUpBlockData(statusBlock,
                                                padding=lrPaddings))
        if statsConfig.showCompatibles:
            moduleCompatibles = params_helper.getCompatibles(shell)
            compatibleBlocks = []
            for paramType, paramValue in moduleCompatibles:
                compatibleBlocks.append(
                    formatters.packTitleDescBlock(
                        title=text_styles.middleTitle(
                            _ms(MENU.moduleinfo_compatible(paramType))),
                        desc=text_styles.main(paramValue)))

            compatibleBlocks.append(
                formatters.packTextBlockData(text=text_styles.stats(
                    _ms(MENU.MODULEINFO_ADDITIONALINFO))))
            if compatibleBlocks:
                items.append(
                    formatters.packBuildUpBlockData(
                        compatibleBlocks,
                        padding=formatters.packPadding(left=leftPadding,
                                                       bottom=8)))
        if showBasicData:
            boldText = text_styles.neutral(
                TOOLTIPS.SHELL_BASIC_DESCRIPTION_BOLD)
            items.append(
                formatters.packBuildUpBlockData([
                    formatters.packTextBlockData(text_styles.standard(
                        _ms(TOOLTIPS.SHELL_BASIC_DESCRIPTION, bold=boldText)),
                                                 padding=lrPaddings)
                ],
                                                padding=formatters.packPadding(
                                                    right=rightPadding)))
        return items
Exemplo n.º 8
0
    def _populate(self):
        super(View, self)._populate()
        module = g_itemsCache.items.getItemByCD(self.moduleCompactDescr)
        description = ""
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[11]):
            description = stripShortDescrTags(module.fullDescription)
        if module.itemTypeName in (ITEM_TYPE_NAMES[9], ITEM_TYPE_NAMES[10], ITEM_TYPE_NAMES[11]):
            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 = ItemsParameters.g_instance.get(module.descriptor, self.__vehicleDescr)
        moduleParameters = params.get("parameters", tuple())
        isGun = module.itemTypeName == ITEM_TYPE_NAMES[4]
        isShell = module.itemTypeName == ITEM_TYPE_NAMES[10]
        excludedParametersNames = []
        if isGun:
            gunReloadingType = dict(moduleParameters)[GUN_RELOADING_TYPE]
            if gunReloadingType == GUN_NORMAL:
                excludedParametersNames.append(SHELLS_COUNT_PROP_NAME)
                excludedParametersNames.append(RELOAD_MAGAZINE_TIME_PROP_NAME)
                excludedParametersNames.append(SHELL_RELOADING_TIME_PROP_NAME)
            elif gunReloadingType == GUN_CLIP:
                description = i18n.makeString(MENU.MODULEINFO_CLIPGUNLABEL)
                excludedParametersNames.append(RELOAD_TIME_PROP_NAME)
                extraModuleInfo = CLIP_ICON_PATH
            elif gunReloadingType == GUN_CAN_BE_CLIP:
                excludedParametersNames.append(SHELLS_COUNT_PROP_NAME)
                excludedParametersNames.append(RELOAD_MAGAZINE_TIME_PROP_NAME)
                excludedParametersNames.append(SHELL_RELOADING_TIME_PROP_NAME)
                otherParamsInfoList = []
                for paramType, paramValue in moduleParameters:
                    if paramType in excludedParametersNames:
                        otherParamsInfoList.append(
                            {"type": i18n.makeString(MENU.moduleinfo_params(paramType)), "value": paramValue}
                        )

                imgPathArr = CLIP_ICON_PATH.split("..")
                imgPath = "img://gui" + imgPathArr[1]
                moduleData["otherParameters"] = {
                    "headerText": i18n.makeString(MENU.MODULEINFO_PARAMETERSCLIPGUNLABEL, imgPath),
                    "params": otherParamsInfoList,
                }
        moduleData["description"] = description
        excludedParametersNames.append(GUN_RELOADING_TYPE)
        paramsList = []
        for paramType, paramValue in moduleParameters:
            if paramType not in excludedParametersNames:
                paramsList.append({"type": i18n.makeString(MENU.moduleinfo_params(paramType)), "value": paramValue})

        moduleData["parameters"] = {
            "headerText": i18n.makeString(MENU.MODULEINFO_PARAMETERSLABEL) if len(paramsList) > 0 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.itemTypeName == ITEM_TYPE_NAMES[11]:
            effectsNametemplate = "#artefacts:%s/%s"
            moduleData["effects"] = {
                "effectOnUse": i18n.makeString(effectsNametemplate % (module.name, "onUse")),
                "effectAlways": i18n.makeString(effectsNametemplate % (module.name, "always")),
                "effectRestriction": i18n.makeString(effectsNametemplate % (module.name, "restriction")),
            }
        if isShell and self.__isAdditionalInfoShow is not None:
            moduleData["additionalInfo"] = self.__isAdditionalInfoShow
        self.as_setModuleInfoS(moduleData)
        self._updateActionButton()
        return