Ejemplo n.º 1
0
 def _packBlocks(self, paramName):
     extendedData = self.context.getComparator().getExtendedData(paramName)
     self.__paramName = extendedData.name
     title = text_styles.highTitle(MENU.tank_params(paramName))
     if param_formatter.isRelativeParameter(paramName):
         value = param_formatter.colorizedFormatParameter(extendedData, self.context.formatters)
         title += ' ' + text_styles.warning(_ms(TOOLTIPS.VEHICLEPARAMS_TITLE_VALUETEMPLATE, value=value))
     else:
         title += ' ' + text_styles.middleTitle(MEASURE_UNITS.get(paramName, ''))
     desc = _ms(TOOLTIPS.tank_params_desc(paramName))
     possibleBonuses = sorted(extendedData.possibleBonuses, _bonusCmp)
     if possibleBonuses is not None and len(possibleBonuses) > 0:
         desc += ' ' + _ms(TOOLTIPS.VEHICLEPARAMS_POSSIBLEBONUSES_DESC)
         desc += '\n' + self.__createBonusesStr(possibleBonuses)
     blocks = [formatters.packTitleDescBlock(title, text_styles.main(desc))]
     bonuses = sorted(extendedData.bonuses, _bonusCmp)
     if bonuses is not None and len(bonuses) > 0:
         blocks.append(formatters.packTitleDescBlock(text_styles.middleTitle(TOOLTIPS.VEHICLEPARAMS_BONUSES_TITLE), text_styles.main(self.__createBonusesStr(bonuses))))
     penalties = extendedData.penalties
     actualPenalties, nullPenaltyTypes = self.__getNumNotNullPenaltyTankman(penalties)
     penaltiesLen = len(penalties)
     numNotNullPenaltyTankman = len(actualPenalties)
     if numNotNullPenaltyTankman > 0:
         blocks.append(formatters.packTitleDescBlock(text_styles.critical(TOOLTIPS.VEHICLEPARAMS_PENALTIES_TITLE), text_styles.main(self.__createPenaltiesStr(actualPenalties))))
     if penaltiesLen > numNotNullPenaltyTankman:
         blocks.append(formatters.packImageTextBlockData(self.__createTankmanIsOutStr(nullPenaltyTypes), img=RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED, imgPadding=formatters.packPadding(top=2, left=3, right=6)))
     return blocks
    def _onLoading(self, vehicle, isInstalled=True):
        super(ShellsInfo, self)._onLoading()
        with self.viewModel.transaction() as tx:
            tx.setMaxCount(vehicle.ammoMaxSize)
            tx.setIsAutoRenewalEnabled(vehicle.isAutoLoad)
            shellsParams = []
            totalCount = 0
            shellsLayout = vehicle.shells.installed if isInstalled else vehicle.shells.layout
            for shell in shellsLayout:
                if shell is None:
                    continue
                shellModel = ShellInfoModel()
                shellModel.setName(shell.userName)
                shellModel.setType(shell.type)
                shellModel.setCount(shell.count)
                shellModel.setImageSource(R.images.gui.maps.icons.shell.medium.dyn(shell.type)())
                shellsParams.append(params_helper.getParameters(shell, vehicle.descriptor))
                tx.getShells().addViewModel(shellModel)
                totalCount += shell.count

            tx.setInstalledCount(totalCount)
            for paramName in _SHELLS_INFO_PARAMS:
                specificationModel = ShellsSpecificationModel()
                specificationModel.setParamName(paramName)
                specificationModel.setMetricValue(i18n.makeString(MEASURE_UNITS.get(paramName, '')))
                for shellParam in shellsParams:
                    value = formatParameter(paramName, shellParam.get(paramName))
                    specificationModel.getValues().addString('' if value is None else value)

                tx.getSpecifications().addViewModel(specificationModel)

        return
Ejemplo n.º 3
0
def _formatModuleParamName(paramName):
    builder = text_styles.builder()
    resource = R.strings.menu.moduleInfo.params
    paramMsgId = backport.msgid(
        resource.dyn(paramName)()) if resource.dyn(paramName) else None
    builder.addStyledText(text_styles.main, paramMsgId)
    builder.addStyledText(_standardText, MEASURE_UNITS.get(paramName, ''))
    return builder.render()
Ejemplo n.º 4
0
    def _fillSpecification(self, model, item):
        specifications = model.getSpecifications()
        specifications.clear()
        for paramName in _SHELLS_INFO_PARAMS:
            specificationModel = ShellSpecificationModel()
            specificationModel.setParamName(paramName)
            specificationModel.setMetricValue(
                i18n.makeString(MEASURE_UNITS.get(paramName, '')))
            shellParam = params_helper.getParameters(
                item,
                self._getVehicle().descriptor)
            specificationModel.setValue(
                formatParameter(paramName, shellParam.get(paramName)) or '')
            specifications.addViewModel(specificationModel)

        specifications.invalidate()
Ejemplo n.º 5
0
 def _packBlocks(self, paramName):
     extendedData = self.context.getComparator().getExtendedData(paramName)
     self.__paramName = extendedData.name
     title = text_styles.highTitle(MENU.tank_params(paramName))
     if param_formatter.isRelativeParameter(paramName):
         value = ''
         if self.context.showTitleValue:
             value = param_formatter.colorizedFormatParameter(
                 extendedData, self.context.formatters)
         title += ' ' + text_styles.warning(
             _ms(TOOLTIPS.VEHICLEPARAMS_TITLE_VALUETEMPLATE, value=value))
     else:
         title += ' ' + text_styles.middleTitle(
             MEASURE_UNITS.get(paramName, ''))
     desc = _ms(TOOLTIPS.tank_params_desc(paramName))
     possibleBonuses = sorted(extendedData.possibleBonuses, _bonusCmp)
     if possibleBonuses is not None and len(possibleBonuses) > 0:
         desc += ' ' + _ms(TOOLTIPS.VEHICLEPARAMS_POSSIBLEBONUSES_DESC)
         desc += '\n' + self.__createBonusesStr(possibleBonuses)
     blocks = [formatters.packTitleDescBlock(title, text_styles.main(desc))]
     bonuses = sorted(extendedData.bonuses, _bonusCmp)
     if bonuses is not None and len(bonuses) > 0:
         blocks.append(
             formatters.packTitleDescBlock(
                 text_styles.middleTitle(
                     TOOLTIPS.VEHICLEPARAMS_BONUSES_TITLE),
                 text_styles.main(self.__createBonusesStr(bonuses))))
     penalties = extendedData.penalties
     actualPenalties, nullPenaltyTypes = self.__getNumNotNullPenaltyTankman(
         penalties)
     penaltiesLen = len(penalties)
     numNotNullPenaltyTankman = len(actualPenalties)
     if numNotNullPenaltyTankman > 0:
         blocks.append(
             formatters.packTitleDescBlock(
                 text_styles.critical(
                     TOOLTIPS.VEHICLEPARAMS_PENALTIES_TITLE),
                 text_styles.main(
                     self.__createPenaltiesStr(actualPenalties))))
     if penaltiesLen > numNotNullPenaltyTankman:
         blocks.append(
             formatters.packImageTextBlockData(
                 self.__createTankmanIsOutStr(nullPenaltyTypes),
                 img=RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICONFILLED,
                 imgPadding=formatters.packPadding(top=2, left=3, right=6)))
     return blocks
Ejemplo n.º 6
0
def _formatModuleParamName(paramName):
    builder = text_styles.builder()
    builder.addStyledText(text_styles.main, MENU.moduleinfo_params(paramName))
    builder.addStyledText(_standardText, MEASURE_UNITS.get(paramName, ''))
    return builder.render()