Exemple #1
0
    def __buildReserveParams(self, reserve):
        if not reserve.isUsingInBattle():
            return [{'paramValue': '+{}%'.format(reserve.getBonusPercent()),
              'paramName': reserve.getDescription()}]
        else:
            paramsData = []
            item = self.__itemsCache.items.getItemByCD(int(reserve.intCD))
            if item is None:
                _logger.warning('There is not a reserve with intCD=%s', reserve.intCD)
                return paramsData
            paramsFilter = RESERVE_PARAMS_LIST.get(reserve.getType())
            if paramsFilter is None:
                _logger.warning('RESERVE_PARAMS_LIST does not know a reserve with type=%s', reserve.getType())
                return paramsData
            params = params_helper.getParameters(item)
            paramsResult = formatters.getFormattedParamsList(item.descriptor, params)
            for paramName, paramValue in paramsResult:
                if paramName in paramsFilter:
                    paramsStrR = R.strings.menu.moduleInfo.params.short.dyn(paramName)
                    if not paramsStrR.isValid():
                        paramsStrR = R.strings.menu.moduleInfo.params.dyn(paramName)
                    paramsData.append({'paramValue': paramValue,
                     'paramName': text_styles.concatStylesWithNBSP(text_styles.main(backport.text(paramsStrR())), text_styles.standard(formatters.measureUnitsForParameter(paramName)))})

            return paramsData
    def getVehicleInfo(self):
        vehicle = g_itemsCache.items.getItemByCD(self.vehicleCompactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ', self.vehicleCompactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    tankmanLabel = '%s %s (%d%%)' % (tankman.rankUserName, tankman.lastUserName, tankman.roleLevel)
                tankmenParams.append({'tankmanType': i18n.convert(tankmen.getSkillsConfig()[role].get('userString', '')),
                 'value': tankmanLabel})

            paramsList = formatters.getFormattedParamsList(vehicle.descriptor, params['parameters'], excludeRelative=True)
            info = {'vehicleName': vehicle.longUserName,
             'vehicleDiscription': vehicle.fullDescription,
             'vehicleImage': vehicle.icon,
             'vehicleLevel': vehicle.level,
             'vehicleNation': vehicle.nationID,
             'vehicleElite': vehicle.isElite,
             'vehicleType': vehicle.type,
             'VehicleInfoPropsData': [ {'name': n,
                                      'value': v} for n, v in paramsList ],
             'VehicleInfoBaseData': params['base'],
             'VehicleInfoCrewData': tankmenParams}
            self.as_setVehicleInfoS(info)
            return
Exemple #3
0
    def _getShortInfo(self, vehicle=None, expanded=False):
        """
        Returns string with item's parameters.
        
        :param vehicle: vehicle: vehicle which descriptor will be passed to the params_helper.getParameters
        :param expanded: indicates if it should be expanded.
        :return: formatted user-string
        """
        try:
            description = i18n.makeString('#menu:descriptions/' +
                                          self.itemTypeName +
                                          ('Full' if expanded else ''))
            vehicleDescr = vehicle.descriptor if vehicle is not None else None
            params = params_helper.getParameters(self, vehicleDescr)
            formattedParametersDict = dict(
                formatters.getFormattedParamsList(self.descriptor, params))
            if self.itemTypeName == vehicles._VEHICLE:
                formattedParametersDict[
                    'caliber'] = BigWorld.wg_getIntegralFormat(
                        self.descriptor.gun.shots[0].shell.caliber)
            result = description % formattedParametersDict
            return result
        except Exception:
            LOG_CURRENT_EXCEPTION()
            return ''

        return
    def getVehicleInfo(self):
        vehicle = self._itemsCache.items.getItemByCD(self.__vehicleCompactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ', self.__vehicleCompactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            skillsConfig = tankmen.getSkillsConfig()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    tankmanLabel = '%s %s (%d%%)' % (tankman.rankUserName, tankman.lastUserName, tankman.roleLevel)
                tankmenParams.append({'tankmanType': i18n.convert(skillsConfig.getSkill(role).userString),
                 'value': tankmanLabel})

            paramsList = formatters.getFormattedParamsList(vehicle.descriptor, params['parameters'], excludeRelative=True)
            info = {'vehicleName': vehicle.longUserName,
             'vehicleDescription': vehicle.fullDescription,
             'vehicleImage': vehicle.icon,
             'vehicleLevel': vehicle.level,
             'vehicleNation': vehicle.nationID,
             'vehicleElite': vehicle.isElite,
             'vehicleType': vehicle.type,
             'propsData': self.__packParams(paramsList),
             'baseData': params['base'],
             'crewData': tankmenParams}
            self.as_setVehicleInfoS(info)
            return
    def construct(self):
        block = []
        if self.configuration.params:
            bottom = 8
            bottomPadding = formatters.packPadding(bottom=bottom)
            shell = self.shell
            comparator = params_helper.shellOnVehicleComparator(
                shell, self.configuration.vehicle)
            isDistanceDependent = self._params.pop(
                'piercingPowerTable') is not None
            formattedParameters = params_formatters.getFormattedParamsList(
                shell.descriptor, self._params)
            block.append(
                formatters.packTitleDescBlock(title=text_styles.middleTitle(
                    _ms(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)),
                                              padding=bottomPadding))
            for paramName, paramValue in formattedParameters:
                if paramName == ModuleTooltipBlockConstructor.CALIBER:
                    continue
                if comparator is not None:
                    paramValue = params_formatters.colorizedFormatParameter(
                        comparator.getExtendedData(paramName),
                        params_formatters.BASE_SCHEME)
                if paramValue is not None:
                    paramUnits = _ms(
                        params_formatters.measureUnitsForParameter(paramName))
                    isPiercingPower = paramName == 'avgPiercingPower'
                    paramUnits += _ASTERISK if isPiercingPower and not isDistanceDependent else ''
                    block.append(
                        self._packParameterBlock(
                            backport.text(
                                R.strings.menu.moduleInfo.params.dyn(paramName)
                                ()), paramValue, paramUnits))

        return block
    def construct(self):
        block = []
        if self.configuration.params:
            top = 8
            bottom = 8
            topPadding = formatters.packPadding(top=top)
            bottomPadding = formatters.packPadding(bottom=bottom)
            shell = self.shell
            comparator = params_helper.shellComparator(
                shell, self.configuration.vehicle)
            piercingPowerTable = self._params.pop('piercingPowerTable')
            isDistanceDependent = piercingPowerTable is not None
            colorScheme = params_formatters.COLORLESS_SCHEME if self.configuration.colorless else params_formatters.BASE_SCHEME
            tableData = []
            if isinstance(piercingPowerTable, list):
                for distance, value in self.__iteratePiercingPowerTable(
                        piercingPowerTable, comparator, colorScheme):
                    tableData.append((value, distance))

            formattedParameters = params_formatters.getFormattedParamsList(
                shell.descriptor, self._params)
            block.append(
                formatters.packTitleDescBlock(title=text_styles.middleTitle(
                    _ms(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)),
                                              padding=bottomPadding))
            for paramName, paramValue in formattedParameters:
                if paramName == ModuleTooltipBlockConstructor.CALIBER:
                    continue
                if comparator is not None:
                    paramValue = params_formatters.colorizedFormatParameter(
                        comparator.getExtendedData(paramName), colorScheme)
                if paramValue is not None:
                    paramUnits = _ms(
                        params_formatters.measureUnitsForParameter(paramName))
                    isPiercingPower = paramName == 'avgPiercingPower'
                    if isPiercingPower:
                        if piercingPowerTable != NO_DATA:
                            paramUnits += _ASTERISK
                        if tableData and isDistanceDependent:
                            paramValue = '%s-%s' % (tableData[0][0],
                                                    tableData[-1][0])
                    block.append(
                        self._packParameterBlock(
                            backport.text(
                                R.strings.menu.moduleInfo.params.dyn(paramName)
                                ()), paramValue, paramUnits))

            if piercingPowerTable != NO_DATA:
                title = _ms(MENU.MODULEINFO_PARAMS_NOPIERCINGDISTANCE_FOOTNOTE)
                if isDistanceDependent and tableData:
                    title = _ms(
                        MENU.MODULEINFO_PARAMS_PIERCINGDISTANCE_FOOTNOTE,
                        minDist=tableData[0][1],
                        maxDist=tableData[-1][1])
                block.append(
                    formatters.packTitleDescBlock(
                        title=text_styles.standard(title), padding=topPadding))
        return block
    def construct(self):
        block = []
        block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(_ms(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)), padding=formatters.packPadding(bottom=8)))
        params = params_helper.getParameters(self.item)
        paramsResult = params_formatters.getFormattedParamsList(self.item.descriptor, params)
        for paramName, paramValue in paramsResult:
            block.append(self.__packParameterBloc(_ms('#menu:moduleInfo/params/' + paramName), paramValue, params_formatters.measureUnitsForParameter(paramName)))

        return block
    def construct(self):
        block = []
        block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(_ms(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)), padding=formatters.packPadding(bottom=8)))
        params = params_helper.getParameters(self.item)
        paramsResult = params_formatters.getFormattedParamsList(self.item.descriptor, params)
        for paramName, paramValue in paramsResult:
            block.append(self.__packParameterBloc(_ms('#menu:moduleInfo/params/' + paramName), paramValue, params_formatters.measureUnitsForParameter(paramName)))

        return block
Exemple #9
0
 def getParams(self):
     result = []
     if self.isConsumable:
         from ClientFortifiedRegion import getBattleEquipmentByOrderID
         eqDescr = getBattleEquipmentByOrderID(self.orderID, self.level)
         if eqDescr is not None:
             eqItem = g_itemsCache.items.getItemByCD(eqDescr['compactDescr'])
             params = params_helper.getParameters(eqItem)
             result = formatters.getFormattedParamsList(eqDescr, params)
     return result
Exemple #10
0
 def getParams(self):
     result = []
     if self.isConsumable:
         from ClientFortifiedRegion import getBattleEquipmentByOrderID
         eqDescr = getBattleEquipmentByOrderID(self.orderID, self.level)
         if eqDescr is not None:
             eqItem = g_itemsCache.items.getItemByCD(eqDescr['compactDescr'])
             params = params_helper.getParameters(eqItem)
             result = formatters.getFormattedParamsList(eqDescr, params)
     return result
    def __buildBaseList(self):
        parameters = params_helper.getParameters(self._cache.item)
        if parameters is not None:
            formattedParameters = formatters.getFormattedParamsList(self._cache.item.descriptor, parameters)
            for paramName, value in formattedParameters:
                if not formatters.isRelativeParameter(paramName):
                    self._list.append({'titleText': formatters.formatVehicleParamName(paramName),
                     'valueText': text_styles.stats(value),
                     'isEnabled': False})

        return
Exemple #12
0
    def __buildBaseList(self):
        parameters = params_helper.getParameters(self._cache.item)
        if parameters is not None:
            formattedParameters = formatters.getFormattedParamsList(self._cache.item.descriptor, parameters)
            for paramName, value in formattedParameters:
                if not formatters.isRelativeParameter(paramName):
                    self._list.append({'titleText': formatters.formatVehicleParamName(paramName),
                     'valueText': text_styles.stats(value),
                     'isEnabled': False})

        return
    def getReserveParams(self, cmd):
        result = {}
        for intCD in cmd.reserve_intCDs:
            item = self.__itemsCache.items.getItemByCD(int(intCD))
            if item is None:
                _logger.warning('There is not a reserve with intCD=(%s)', intCD)
                continue
            rawParams = params_helper.getParameters(item)
            result[intCD] = {pName:pValue for pName, pValue in formatters.getFormattedParamsList(item.descriptor, rawParams)}

        return result
    def _getShortInfo(self, vehicle=None, expanded=False):
        try:
            description = i18n.makeString(self._getShortInfoKey() +
                                          ('Full' if expanded else ''))
            vehicleDescr = vehicle.descriptor if vehicle is not None else None
            params = params_helper.getParameters(self, vehicleDescr)
            formattedParametersDict = dict(
                formatters.getFormattedParamsList(self.descriptor, params))
            result = description % formattedParametersDict
            return result
        except Exception:
            LOG_CURRENT_EXCEPTION()
            return ''

        return
Exemple #15
0
    def _getShortInfo(self, vehicle=None, expanded=False):
        try:
            description = i18n.makeString('#menu:descriptions/' + self.itemTypeName + ('Full' if expanded else ''))
            vehicleDescr = vehicle.descriptor if vehicle is not None else None
            params = params_helper.getParameters(self, vehicleDescr)
            formattedParametersDict = dict(formatters.getFormattedParamsList(self.descriptor, params))
            if self.itemTypeName == vehicles._VEHICLE:
                formattedParametersDict['caliber'] = BigWorld.wg_getIntegralFormat(self.descriptor.gun.shots[0].shell.caliber)
            result = description % formattedParametersDict
            return result
        except Exception:
            LOG_CURRENT_EXCEPTION()
            return ''

        return
Exemple #16
0
    def _getShortInfo(self, vehicle = None, expanded = False):
        try:
            description = i18n.makeString('#menu:descriptions/' + self.itemTypeName + ('Full' if expanded else ''))
            vehicleDescr = vehicle.descriptor if vehicle is not None else None
            params = params_helper.getParameters(self, vehicleDescr)
            formattedParametersDict = dict(formatters.getFormattedParamsList(self.descriptor, params))
            if self.itemTypeName == vehicles._VEHICLE:
                formattedParametersDict['caliber'] = BigWorld.wg_getIntegralFormat(self.descriptor.gun['shots'][0]['shell']['caliber'])
            result = description % formattedParametersDict
            return result
        except Exception:
            LOG_CURRENT_EXCEPTION()
            return ''

        return
Exemple #17
0
    def getVehicleInfo(self):
        vehicle = self._itemsCache.items.getItemByCD(
            self.__vehicleCompactDescr)
        if vehicle is None:
            LOG_ERROR('There is error while showing vehicle info window: ',
                      self.__vehicleCompactDescr)
            return
        else:
            params = vehicle.getParams()
            tankmenParams = list()
            skillsConfig = tankmen.getSkillsConfig()
            for slotIdx, tankman in vehicle.crew:
                role = vehicle.descriptor.type.crewRoles[slotIdx][0]
                tankmanLabel = ''
                if tankman is not None:
                    lastUserName = tankman.lastUserName
                    if tankman.skinID != NO_CREW_SKIN_ID and self._lobbyContext.getServerSettings(
                    ).isCrewSkinsEnabled():
                        skinItem = self._itemsCache.items.getCrewSkin(
                            tankman.skinID)
                        lastUserName = i18n.makeString(skinItem.getLastName())
                    tankmanLabel = '%s %s (%d%%)' % (
                        tankman.rankUserName, lastUserName, tankman.roleLevel)
                tankmenParams.append({
                    'tankmanType':
                    i18n.convert(skillsConfig.getSkill(role).userString),
                    'value':
                    tankmanLabel
                })

            roleStr = getRoleTextWithLabel(vehicle.role, vehicle.roleLabel)
            paramsList = formatters.getFormattedParamsList(
                vehicle.descriptor, params['parameters'], excludeRelative=True)
            info = {
                'vehicleName': vehicle.longUserName,
                'vehicleDescription': vehicle.fullDescription,
                'vehicleImage': vehicle.icon,
                'vehicleLevel': vehicle.level,
                'vehicleNation': vehicle.nationID,
                'vehicleElite': vehicle.isElite,
                'vehicleType': vehicle.type,
                'propsData': self.__packParams(paramsList),
                'baseData': params['base'],
                'crewData': tankmenParams,
                'roleStr': roleStr
            }
            self.as_setVehicleInfoS(info)
            return
Exemple #18
0
    def invoke(self, content, varID):
        self._gui.showWaiting('request-item-params')
        itemCD = self.getVar(varID)
        if itemCD is None:
            return
        else:
            itemTypeID, nationID, compTypeID = vehicles.parseIntCompactDescr(itemCD)
            raise itemTypeID != ITEM_TYPE_NAMES[1] or AssertionError
            try:
                guiItem = g_itemsCache.items.getItemByCD(itemCD)
                content['itemTypeName'] = guiItem.itemTypeName
                content['itemLevel'] = guiItem.level
                params = guiItem.getParams(g_currentVehicle.item).get('parameters', dict())
                content['itemParams'] = formatters.getFormattedParamsList(g_currentVehicle.item.descriptor, params)
            except Exception:
                LOG_CURRENT_EXCEPTION()

            self._gui.hideWaiting('request-item-params')
            return
Exemple #19
0
    def construct(self):
        block = []
        if self.configuration.params:
            top = 8
            bottom = 8
            topPadding = formatters.packPadding(top=top)
            bottomPadding = formatters.packPadding(bottom=bottom)
            tbPadding = formatters.packPadding(top=top, bottom=bottom)
            shell = self.shell
            comparator = params_helper.shellComparator(shell, self.configuration.vehicle)
            piercingPowerTable = self._params.pop('piercingPowerTable')
            isDistanceDependent = piercingPowerTable is not None
            maxShotDistance = self._params.pop('maxShotDistance', None)
            formattedParameters = params_formatters.getFormattedParamsList(shell.descriptor, self._params)
            block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(_ms(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)), padding=bottomPadding))
            for paramName, paramValue in formattedParameters:
                if comparator is not None:
                    paramValue = params_formatters.colorizedFormatParameter(comparator.getExtendedData(paramName), params_formatters.BASE_SCHEME)
                if paramValue is not None:
                    paramUnits = _ms(params_formatters.measureUnitsForParameter(paramName))
                    isPiercingPower = paramName == 'avgPiercingPower'
                    paramUnits += _ASTERISK if isPiercingPower and not isDistanceDependent else ''
                    if not (isPiercingPower and isDistanceDependent):
                        block.append(self._packParameterBlock(_ms('#menu:moduleInfo/params/' + paramName), paramValue, paramUnits))

            if isinstance(piercingPowerTable, list):
                piercingUnits = _ms(params_formatters.measureUnitsForParameter('piercingPower'))
                block.append(formatters.packTitleDescBlock(title=text_styles.standard(_ms(MENU.MODULEINFO_PARAMS_PIERCINGDISTANCEHEADER)), padding=tbPadding))
                for distance, value in self.__iteratePiercingPowerTable(piercingPowerTable, comparator):
                    if maxShotDistance is not None and distance == _AUTOCANNON_SHOT_DISTANCE:
                        piercingUnits += _ASTERISK
                    block.append(self._packParameterBlock(_ms(MENU.MODULEINFO_PARAMS_PIERCINGDISTANCE, dist=distance), value, piercingUnits))

                if maxShotDistance is not None:
                    block.append(formatters.packTitleDescBlock(title=text_styles.standard(_ms(MENU.MODULEINFO_PARAMS_MAXSHOTDISTANCE_FOOTNOTE)), padding=topPadding))
            elif piercingPowerTable != NO_DATA:
                title = _ms(MENU.MODULEINFO_PARAMS_NOPIERCINGDISTANCE_FOOTNOTE)
                distanceNote = ''
                if maxShotDistance is not None:
                    distanceNote = _ms(MENU.MODULEINFO_PARAMS_NOPIERCINGDISTANCE_FOOTNOTE_MAXDISTANCE)
                title = title % distanceNote
                block.append(formatters.packTitleDescBlock(title=text_styles.standard(title), padding=topPadding))
        return block
 def construct(self):
     shell = self.shell
     block = list()
     formattedParameters = params_formatters.getFormattedParamsList(
         shell.descriptor, self._params)
     paramName = ModuleTooltipBlockConstructor.CALIBER
     paramValue = dict(formattedParameters).get(paramName)
     block.append(
         formatters.packImageTextBlockData(
             title=text_styles.highTitle(shell.userName),
             desc=text_styles.concatStylesToMultiLine(
                 text_styles.main(
                     backport.text(
                         R.strings.item_types.shell.kinds.dyn(
                             shell.type)())),
                 params_formatters.formatParamNameColonValueUnits(
                     paramName=paramName, paramValue=paramValue)),
             descPadding=formatters.packPadding(top=7),
             img=shell.getBonusIcon(size='big'),
             imgPadding=formatters.packPadding(left=-8, right=20),
             txtGap=-4))
     return block
Exemple #21
0
    def invoke(self, content, varID):
        self._gui.showWaiting('request-item-params')
        itemCD = self.getVar(varID)
        if itemCD is None:
            return
        else:
            itemTypeID, nationID, compTypeID = vehicles.parseIntCompactDescr(
                itemCD)
            raise itemTypeID != ITEM_TYPE_NAMES[1] or AssertionError
            try:
                guiItem = game_vars.getItemByIntCD(itemCD)
                content['itemTypeName'] = guiItem.itemTypeName
                content['itemLevel'] = guiItem.level
                params = guiItem.getParams(g_currentVehicle.item).get(
                    'parameters', dict())
                content['itemParams'] = formatters.getFormattedParamsList(
                    g_currentVehicle.item.descriptor, params)
            except Exception:
                LOG_CURRENT_EXCEPTION()

            self._gui.hideWaiting('request-item-params')
            return
Exemple #22
0
 def construct(self):
     shell = self.shell
     formattedParameters = params_formatters.getFormattedParamsList(
         shell.descriptor, self._params)
     paramName = ModuleTooltipBlockConstructor.CALIBER
     paramValue = dict(formattedParameters).get(paramName)
     headerText = formatters.packTitleDescBlock(
         title=text_styles.highTitle(shell.userName),
         desc=text_styles.concatStylesToMultiLine(
             text_styles.main(
                 backport.text(
                     R.strings.item_types.shell.kinds.dyn(shell.type)())),
             params_formatters.formatParamNameColonValueUnits(
                 paramName=paramName, paramValue=paramValue)),
         padding=formatters.packPadding(left=-15),
         descPadding=formatters.packPadding(top=4),
         gap=-4)
     headerImage = formatters.packImageBlockData(
         img=shell.getBonusIcon(size='big'),
         align=BLOCKS_TOOLTIP_TYPES.ALIGN_CENTER,
         padding=formatters.packPadding(right=30, top=-5, bottom=-5))
     return [headerText, headerImage]
Exemple #23
0
    def construct(self):
        module = self.module
        vehicle = self.configuration.vehicle
        params = self.configuration.params
        block = []
        vDescr = vehicle.descriptor if vehicle is not None else None
        moduleParams = params_helper.getParameters(module, vDescr)
        paramsKeyName = module.itemTypeID
        if params:
            reloadingType = None
            if module.itemTypeID == GUI_ITEM_TYPE.GUN:
                reloadingType = module.getReloadingType(vehicle.descriptor if vehicle is not None else None)
            if reloadingType == GUN_CLIP:
                paramsKeyName = self.CLIP_GUN_MODULE_PARAM
            paramsList = self.MODULE_PARAMS.get(paramsKeyName, [])
            if vehicle is not None:
                if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE:
                    currModule = module
                else:
                    currModuleDescr, _ = vehicle.descriptor.getComponentsByType(module.itemTypeName)
                    currModule = self.itemsCache.items.getItemByCD(currModuleDescr.compactDescr)
                comparator = params_helper.itemsComparator(module, currModule, vehicle.descriptor)
                for paramName in paramsList:
                    if paramName in moduleParams:
                        paramInfo = comparator.getExtendedData(paramName)
                        fmtValue = params_formatters.colorizedFormatParameter(paramInfo, self.__colorScheme)
                        if fmtValue is not None:
                            block.append(formatters.packTextParameterBlockData(name=params_formatters.formatModuleParamName(paramName), value=fmtValue, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))

            else:
                formattedModuleParameters = params_formatters.getFormattedParamsList(module.descriptor, moduleParams)
                for paramName, paramValue in formattedModuleParameters:
                    if paramName in paramsList and paramValue is not None:
                        block.append(formatters.packTextParameterBlockData(name=params_formatters.formatModuleParamName(paramName), value=paramValue, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))

        if block:
            block.insert(0, formatters.packTextBlockData(text_styles.middleTitle(_ms(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)), padding=formatters.packPadding(bottom=8)))
        return block
Exemple #24
0
    def construct(self):
        module = self.module
        vehicle = self.configuration.vehicle
        params = self.configuration.params
        block = []
        vDescr = vehicle.descriptor if vehicle is not None else None
        moduleParams = dict(params_helper.getParameters(module, vDescr))
        paramsKeyName = module.itemTypeID
        if params:
            reloadingType = None
            if module.itemTypeID == GUI_ITEM_TYPE.GUN:
                reloadingType = module.getReloadingType(vehicle.descriptor if vehicle is not None else None)
            if reloadingType == GUN_CLIP:
                paramsKeyName = self.CLIP_GUN_MODULE_PARAM
            paramsList = self.MODULE_PARAMS.get(paramsKeyName, [])
            if vehicle is not None:
                if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE:
                    currModule = module
                else:
                    currModuleDescr, _ = vehicle.descriptor.getComponentsByType(module.itemTypeName)
                    currModule = g_itemsCache.items.getItemByCD(currModuleDescr['compactDescr'])
                comparator = params_helper.itemsComparator(module, currModule, vehicle.descriptor)
                for paramName in paramsList:
                    if paramName in moduleParams:
                        paramInfo = comparator.getExtendedData(paramName)
                        fmtValue = params_formatters.colorizedFormatParameter(paramInfo, params_formatters.BASE_FORMATTERS)
                        if fmtValue is not None:
                            block.append(formatters.packTextParameterBlockData(name=params_formatters.formatModuleParamName(paramName), value=fmtValue, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))

            else:
                formattedModuleParameters = params_formatters.getFormattedParamsList(module.descriptor, moduleParams)
                for paramName, paramValue in formattedModuleParameters:
                    if paramName in paramsList and paramValue is not None:
                        block.append(formatters.packTextParameterBlockData(name=params_formatters.formatModuleParamName(paramName), value=paramValue, valueWidth=self._valueWidth, padding=formatters.packPadding(left=-5)))

        if len(block) > 0:
            block.insert(0, formatters.packTextBlockData(text_styles.middleTitle(_ms(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)), padding=formatters.packPadding(bottom=8)))
        return block
Exemple #25
0
    def construct(self):
        block = []
        if self.configuration.params:
            shell = self.shell
            vehicle = self.configuration.vehicle
            vDescr = vehicle.descriptor if vehicle is not None else None
            params = params_helper.getParameters(shell, vDescr)
            piercingPower = params.pop('piercingPower')
            piercingPowerTable = params.pop('piercingPowerTable')
            maxShotDistance = params.pop('maxShotDistance') if 'maxShotDistance' in params else None
            formattedParameters = params_formatters.getFormattedParamsList(shell.descriptor, params)
            block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(_ms(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)), padding=formatters.packPadding(bottom=8)))
            for paramName, paramValue in formattedParameters:
                block.append(self.__packParameterBlock(_ms('#menu:moduleInfo/params/' + paramName), paramValue, params_formatters.measureUnitsForParameter(paramName)))

            piercingUnits = _ms(params_formatters.measureUnitsForParameter('piercingPower'))
            if isinstance(piercingPowerTable, list):
                block.append(formatters.packTitleDescBlock(title=text_styles.standard(_ms(MENU.MODULEINFO_PARAMS_PIERCINGDISTANCEHEADER)), padding=formatters.packPadding(bottom=8, top=8)))
                for distance, value in piercingPowerTable:
                    if maxShotDistance is not None and distance == _AUTOCANNON_SHOT_DISTANCE:
                        piercingUnits += '*'
                    block.append(self.__packParameterBlock(_ms(MENU.MODULEINFO_PARAMS_PIERCINGDISTANCE, dist=distance), params_formatters.baseFormatParameter('piercingPower', value), piercingUnits))

                if maxShotDistance is not None:
                    block.append(formatters.packTitleDescBlock(title=text_styles.standard(_ms(MENU.MODULEINFO_PARAMS_MAXSHOTDISTANCE_FOOTNOTE)), padding=formatters.packPadding(top=8)))
            else:
                if piercingPowerTable != NO_DATA:
                    piercingUnits += '*'
                block.append(self.__packParameterBlock(_ms(MENU.MODULEINFO_PARAMS_PIERCINGPOWER), params_formatters.baseFormatParameter('piercingPower', piercingPower), piercingUnits))
                if piercingPowerTable != NO_DATA:
                    title = _ms(MENU.MODULEINFO_PARAMS_NOPIERCINGDISTANCE_FOOTNOTE)
                    distanceNote = ''
                    if maxShotDistance is not None:
                        distanceNote = _ms(MENU.MODULEINFO_PARAMS_NOPIERCINGDISTANCE_FOOTNOTE_MAXDISTANCE)
                    title = title % distanceNote
                    block.append(formatters.packTitleDescBlock(title=text_styles.standard(title), padding=formatters.packPadding(top=8)))
        return block
    def __getMainParamsBlock(self, name, item):
        block = [
            formatters.packTitleDescBlock(
                title=text_styles.middleTitle(
                    backport.text(R.strings.fortifications.reserves.tooltip.
                                  mainApplyEffect())),
                desc=text_styles.standard(
                    backport.text(
                        R.strings.fortifications.reserves.tooltip.
                        applyDescription.dyn(name)())),
                descPadding=formatters.packPadding(top=4))
        ]
        params = params_helper.getParameters(item)
        paramsResult = paramsFormatters.getFormattedParamsList(
            item.descriptor, params)
        for paramName, paramValue in paramsResult:
            block.append(
                self.__packParameterBlock(
                    backport.text(
                        R.strings.menu.moduleInfo.params.dyn(paramName)()),
                    paramValue,
                    paramsFormatters.measureUnitsForParameter(paramName)))

        return block
    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 _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
    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