def formatters_formatModuleParamName(base, paramName): builder = text_styles.builder() if weightTooHeavy and paramName == 'weight': builder.addStyledText(text_styles.error, MENU.moduleinfo_params(paramName)) builder.addStyledText(text_styles.error, param_formatter.MEASURE_UNITS.get(paramName, '')) else: builder.addStyledText(text_styles.main, MENU.moduleinfo_params(paramName)) builder.addStyledText(text_styles.standard, param_formatter.MEASURE_UNITS.get(paramName, '')) return builder.render()
def formatModuleParamName(paramName): builder = text_styles.builder() builder.addStyledText(text_styles.main, MENU.moduleinfo_params(paramName)) builder.addStyledText(text_styles.standard, MEASURE_UNITS.get(paramName, '')) return builder.render()
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)
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
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)
def formatParamNameColonValueUnits(paramName, paramValue): builder = text_styles.builder(delimiter=_NBSP) builder.addStyledText(text_styles.main, '{}{}'.format(makeString(MENU.moduleinfo_params(paramName)), _COLON)) builder.addStyledText(text_styles.expText, paramValue) builder.addStyledText(text_styles.standard, MEASURE_UNITS_NO_BRACKETS.get(paramName, '')) return builder.render()
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