Exemplo n.º 1
0
    def construct(self):
        module = self.module
        block = []

        def checkLocalization(key):
            localization = _ms('#artefacts:%s' % key)
            return (key != localization, localization)

        if self.lobbyContext.getServerSettings().spgRedesignFeatures.isStunEnabled():
            isRemovingStun = module.isRemovingStun
        else:
            isRemovingStun = False
        onUseStr = '%s/removingStun/onUse' if isRemovingStun else '%s/onUse'
        onUse = checkLocalization(onUseStr % module.descriptor.name)
        always = checkLocalization('%s/always' % module.descriptor.name)
        restriction = checkLocalization('%s/restriction' % module.descriptor.name)
        if bonus_helper.isSituationalBonus(module.name):
            effectDesc = text_styles.bonusPreviewText(_ms(module.shortDescription))
            icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_TOOLTIP_ASTERISK_OPTIONAL, 16, 16, 0, 4)
            desc = params_formatters.packSituationalIcon(effectDesc, icon)
        else:
            desc = text_styles.bonusAppliedText(_ms(module.shortDescription))
        if module.itemTypeID == ITEM_TYPES.optionalDevice:
            block.append(formatters.packTitleDescBlock(title='', desc=desc, padding=formatters.packPadding(top=-8)))
        else:
            topPadding = 0
            if always[0] and always[1]:
                block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(TOOLTIPS.EQUIPMENT_ALWAYS), desc=text_styles.bonusAppliedText(always[1])))
                topPadding = 5
            if onUse[0] and onUse[1]:
                block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(TOOLTIPS.EQUIPMENT_ONUSE), desc=text_styles.main(onUse[1]), padding=formatters.packPadding(top=topPadding)))
                topPadding = 5
            if restriction[0] and restriction[1]:
                block.append(formatters.packTitleDescBlock(title=text_styles.middleTitle(TOOLTIPS.EQUIPMENT_RESTRICTION), desc=text_styles.main(restriction[1]), padding=formatters.packPadding(top=topPadding)))
        return block
Exemplo n.º 2
0
 def __init__(self, module, configuration, leftPadding, rightPadding,
              stockParams, comparator):
     self.__stockParams = stockParams
     self.__comparator = comparator
     self.__isSituational = bonus_helper.isSituationalBonus(module.name)
     super(SimplifiedStatsBlockConstructor,
           self).__init__(module, configuration, leftPadding, rightPadding)
Exemplo n.º 3
0
    def _getBonuses(self):
        result = []
        bonuses = sorted(self._extendedData.bonuses, cmp=_bonusCmp)
        item = self.context.buildItem()
        bonusExtractor = bonus_helper.BonusExtractor(item, bonuses, self.__paramName)
        hasSituational = False
        for bnsType, bnsId, pInfo in bonusExtractor.getBonusInfo():
            isSituational = isSituationalBonus(bnsId)
            scheme = SITUATIONAL_SCHEME if isSituational else EXTRACTED_BONUS_SCHEME
            valueStr = param_formatter.formatParameterDelta(pInfo, scheme)
            if valueStr is not None:
                hasSituational = hasSituational or isSituational
                bonusName = _packBonusName(bnsType, bnsId)
                if isSituational:
                    icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_TOOLTIP_ASTERISK_OPTIONAL, 16, 16, 0, 2)
                    bonusName = param_formatter.packSituationalIcon(bonusName, icon)
                    titlePadding = formatters.packPadding(left=8, top=-2)
                else:
                    titlePadding = self.__titlePadding
                result.append(self.__packBonusField(bnsId, bonusName, value=_ms(TOOLTIPS.VEHICLEPARAMS_TITLE_VALUETEMPLATE, value=valueStr), padding=titlePadding))

        possibleBonuses = sorted(self._extendedData.possibleBonuses, cmp=_bonusCmp)
        inactiveBonuses = self._extendedData.inactiveBonuses
        for bnsId, bnsType in possibleBonuses:
            isInactive = (bnsId, bnsType) in inactiveBonuses
            result.append(self.__packBonusField(bnsId, _packBonusName(bnsType, bnsId, enabled=False, inactive=isInactive), isDisabled=True))

        return (result, hasSituational)
Exemplo n.º 4
0
def new_construct(self):
    block = old_construct(self)
    from gui.Scaleform.locale.RES_ICONS import RES_ICONS
    from gui.shared.formatters import text_styles, icons
    from gui.shared.items_parameters import formatters as params_formatters, bonus_helper
    from gui.shared.utils.functions import stripColorTagDescrTags
    from helpers.i18n import makeString as _ms
    from items import ITEM_TYPES
    if self.module.itemTypeID == ITEM_TYPES.optionalDevice:
        if bonus_helper.isSituationalBonus(self.module.name):
            effectDesc = text_styles.bonusPreviewText(stripColorTagDescrTags(_ms(self.module.fullDescription)))
            # noinspection PyArgumentEqualDefault
            icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_TOOLTIP_ASTERISK_OPTIONAL, 16, 16, 0, 4)
            desc = params_formatters.packSituationalIcon(effectDesc, icon)
        else:
            desc = text_styles.bonusAppliedText(stripColorTagDescrTags(_ms(self.module.fullDescription)))
        block[0]['data']['blocksData'][1]['data']['text'] = desc
    return block
Exemplo n.º 5
0
 def _packBlocks(self, *args, **kwargs):
     self.item = self.context.buildItem(*args, **kwargs)
     items = super(ModuleBlockTooltipData, self)._packBlocks()
     module = self.item
     statsConfig = self.context.getStatsConfiguration(module)
     paramsConfig = self.context.getParamsConfiguration(module)
     statusConfig = self.context.getStatusConfiguration(module)
     leftPadding = 20
     rightPadding = 20
     topPadding = 20
     blockTopPadding = -4
     blockPadding = formatters.packPadding(left=leftPadding, right=rightPadding, top=blockTopPadding)
     textGap = -2
     valueWidth = 110
     items.append(formatters.packBuildUpBlockData(HeaderBlockConstructor(module, statsConfig, leftPadding, rightPadding).construct(), padding=formatters.packPadding(left=leftPadding, right=rightPadding, top=topPadding)))
     effectsItems = []
     replaceItems = []
     if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS:
         if module.itemTypeID == GUI_ITEM_TYPE.EQUIPMENT:
             cooldownSeconds = module.descriptor.cooldownSeconds
             if cooldownSeconds > 0:
                 items.append(formatters.packTextParameterBlockData(name=params_formatters.formatModuleParamName('cooldownSeconds'), value=text_styles.stats(int(cooldownSeconds)), valueWidth=valueWidth, padding=formatters.packPadding(left=leftPadding)))
         effectsBlock = EffectsBlockConstructor(module, statusConfig, leftPadding, rightPadding).construct()
         if effectsBlock:
             effectsItems.append(formatters.packBuildUpBlockData(effectsBlock))
     if statsConfig.vehicle is not None and not module.isInstalled(statsConfig.vehicle):
         if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS:
             comparator = params_helper.artifactComparator(statsConfig.vehicle, module, statsConfig.slotIdx, True)
         else:
             comparator = params_helper.itemOnVehicleComparator(statsConfig.vehicle, module)
         stockParams = params_helper.getParameters(self.itemsCache.items.getStockVehicle(statsConfig.vehicle.intCD))
         currentOptDev = None
         if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE:
             if statsConfig.vehicle.descriptor.optionalDevices[statsConfig.slotIdx] is not None:
                 compactDescr = statsConfig.vehicle.descriptor.optionalDevices[statsConfig.slotIdx].compactDescr
                 currentOptDev = self.itemsFactory.createOptionalDevice(compactDescr)
         if currentOptDev is not None and not module.isSimilarDevice(currentOptDev) or currentOptDev is None and module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE or module.itemTypeID == GUI_ITEM_TYPE.EQUIPMENT:
             simplifiedBlock = SimplifiedStatsBlockConstructor(module, paramsConfig, leftPadding, rightPadding, stockParams, comparator).construct()
             if simplifiedBlock:
                 effectsItems.append(formatters.packBuildUpBlockData(simplifiedBlock, gap=-4, padding=formatters.packPadding(left=leftPadding, right=rightPadding, top=-3, bottom=1)))
         if statsConfig.vehicle.optDevices[statsConfig.slotIdx]:
             if module.itemTypeID in GUI_ITEM_TYPE.ARTEFACTS:
                 if currentOptDev is not None and module.isSimilarDevice(currentOptDev):
                     comparator = params_helper.artifactComparator(statsConfig.vehicle, module, statsConfig.slotIdx, False)
                 else:
                     comparator = params_helper.artifactRemovedComparator(statsConfig.vehicle, self.item, statsConfig.slotIdx)
             simplifiedBlock = SimplifiedStatsBlockConstructor(module, paramsConfig, leftPadding, rightPadding, stockParams, comparator).construct()
             if simplifiedBlock:
                 replaceBlock = ModuleReplaceBlockConstructor(module, statsConfig, valueWidth, leftPadding).construct()
                 if replaceBlock:
                     replaceItems.append(formatters.packBuildUpBlockData(replaceBlock))
                 replaceItems.append(formatters.packBuildUpBlockData(simplifiedBlock, gap=-4, padding=formatters.packPadding(left=leftPadding, right=rightPadding, top=2, bottom=1)))
     if effectsItems:
         items.append(formatters.packBuildUpBlockData(effectsItems, padding=blockPadding, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, stretchBg=True))
     if replaceItems:
         items.append(formatters.packBuildUpBlockData(replaceItems, gap=-4, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, padding=blockPadding, stretchBg=True))
     priceBlock, invalidWidth = PriceBlockConstructor(module, statsConfig, valueWidth, leftPadding, rightPadding).construct()
     if priceBlock:
         self._setWidth(_TOOLTIP_MAX_WIDTH if invalidWidth else _TOOLTIP_MIN_WIDTH)
         items.append(formatters.packBuildUpBlockData(priceBlock, padding=formatters.packPadding(left=leftPadding, right=rightPadding, top=-1, bottom=-3), gap=textGap))
     statsModules = GUI_ITEM_TYPE.VEHICLE_MODULES + (GUI_ITEM_TYPE.OPTIONALDEVICE,)
     if module.itemTypeID in statsModules:
         commonStatsBlock = CommonStatsBlockConstructor(module, paramsConfig, statsConfig.slotIdx, valueWidth, leftPadding, rightPadding, params_formatters.BASE_SCHEME).construct()
         if commonStatsBlock:
             items.append(formatters.packBuildUpBlockData(commonStatsBlock, padding=blockPadding, gap=textGap))
     statusBlock = StatusBlockConstructor(module, statusConfig, leftPadding, rightPadding).construct()
     if statusBlock:
         items.append(formatters.packBuildUpBlockData(statusBlock, padding=blockPadding))
     if bonus_helper.isSituationalBonus(module.name):
         items.append(formatters.packImageTextBlockData(title='', desc=text_styles.standard(TOOLTIPS.VEHICLEPARAMS_BONUS_SITUATIONAL), img=RES_ICONS.MAPS_ICONS_TOOLTIP_ASTERISK_OPTIONAL, imgPadding=formatters.packPadding(left=4, top=3), txtGap=-4, txtOffset=20, padding=formatters.packPadding(left=59, right=20)))
     if module.itemTypeID == GUI_ITEM_TYPE.OPTIONALDEVICE and statsConfig.vehicle is not None and not module.isInstalled(statsConfig.vehicle) and module.hasSimilarDevicesInstalled(statsConfig.vehicle):
         items.append(formatters.packBuildUpBlockData(SimilarOptionalDeviceBlockConstructor(module, statusConfig, leftPadding, rightPadding).construct(), gap=-4, padding=formatters.packPadding(left=leftPadding, right=rightPadding, top=blockTopPadding, bottom=2), stretchBg=False))
     return items