Ejemplo n.º 1
0
    def update_config(self):
        self.loginErrorString = l10n(
            config.get('login/pingServers/errorString', '--'))
        self.hangarErrorString = l10n(
            config.get('hangar/pingServers/errorString', '--'))
        self.loginShowTitle = config.get('login/pingServers/showTitle', True)
        self.hangarShowTitle = config.get('hangar/pingServers/showTitle', True)
        ignoredServersLogin = config.get('login/pingServers/ignoredServers',
                                         [])
        ignoredServersHangar = config.get('hangar/pingServers/ignoredServers',
                                          [])

        self.hosts_urls = {}
        self.loginHosts = []
        self.hangarHosts = []
        if self.loginSection is not None:
            for (name, subSec) in self.loginSection.items():
                host_name = subSec.readStrings('short_name')
                if len(host_name) > 0:
                    host_name = host_name[0]
                    if host_name not in ignoredServersLogin:
                        self.loginHosts.append(host_name)
                    if host_name not in ignoredServersHangar:
                        self.hangarHosts.append(host_name)

                self.hosts_urls[host_name] = subSec.readStrings('url')[0]

            alphanumeric_sort(self.loginHosts)
            alphanumeric_sort(self.hangarHosts)
            self.done_config = True
Ejemplo n.º 2
0
    def update_config(self):
        self.loginErrorString = l10n(config.get('login/pingServers/errorString', '--'))
        self.hangarErrorString = l10n(config.get('hangar/pingServers/errorString', '--'))
        self.loginShowTitle = config.get('login/pingServers/showTitle', True)
        self.hangarShowTitle = config.get('hangar/pingServers/showTitle', True)
        ignoredServers = config.get('hangar/pingServers/ignoredServers', [])

        self.hosts_urls = {}
        self.loginHosts = []
        self.hangarHosts = []
        if self.loginSection is not None:
            for (name, subSec) in self.loginSection.items():
                host_name = subSec.readStrings('name')[0]
                if 'Supertest' not in host_name:
                    if len(host_name) >= 13:
                        host_name = subSec.readStrings('short_name')[0]
                    elif host_name.startswith('WOT '):
                        host_name = host_name[4:]
                self.hosts_urls[host_name] = subSec.readStrings('url')[0]
                self.loginHosts.append(host_name)
                if host_name not in ignoredServers:
                    self.hangarHosts.append(host_name)
            alphanumeric_sort(self.loginHosts)
            alphanumeric_sort(self.hangarHosts)
            self.done_config = True
Ejemplo n.º 3
0
def ModuleInfoWindow_as_setModuleInfoS(base, self, moduleInfo):
    try:
        if moduleInfo['type'] == 'vehicleGun':
            veh_id = self._ModuleInfoWindow__vehicleDescr.type.compactDescr
            itemsCache = dependency.instance(IItemsCache)
            vehicle = itemsCache.items.getItemByCD(veh_id)
            gun = itemsCache.items.getItemByCD(
                self.moduleCompactDescr).descriptor
            turret = self._ModuleInfoWindow__vehicleDescr.turret  # not accurate, but not relevant here
            (viewRange, shellRadius,
             artiRadius) = _getRanges(turret, gun, vehicle.nationName,
                                      vehicle.type)
            if vehicle.type == 'SPG':  # arti
                moduleInfo['parameters']['params'].append({
                    'type':
                    '<h>' + l10n('shootingRadius') + ' <p>' + l10n('(m)') +
                    '</p></h>',
                    'value':
                    '<h>' + str(artiRadius) + '</h>'
                })
            elif shellRadius < 707:  # not arti, short range weapons
                moduleInfo['parameters']['params'].append({
                    'type':
                    '<h>' + l10n('shootingRadius') + ' <p>' + l10n('(m)') +
                    '</p></h>',
                    'value':
                    '<h>' + str(shellRadius) + '</h>'
                })
    except Exception, ex:
        err(traceback.format_exc())
Ejemplo n.º 4
0
def _filter_popover_getInitialVO(base, filters, mapping, xpRateMultiplier):
    data = base(filters, mapping, xpRateMultiplier)
    #debug(data['specials'])
    #debug(mapping)
    try:
        premium = data['specials'][mapping[_SECTION.SPECIALS].index(PREFS.PREMIUM)]
        normal = {'label': l10n('Normal'), 'tooltip': makeTooltip(l10n('NormalTooltipHeader'), l10n('NormalTooltipBody')), 'selected': filters[PREFS.NORMAL]}
        elite = data['specials'][mapping[_SECTION.SPECIALS].index(PREFS.ELITE)]
        non_elite = {'label': l10n('NonElite'), 'tooltip': makeTooltip(l10n('NonEliteTooltipHeader'), l10n('NonEliteTooltipBody')), 'selected': filters[PREFS.NON_ELITE]}
        complete_crew = {'label': l10n('CompleteCrew'), 'tooltip': makeTooltip(l10n('CompleteCrewTooltipHeader'), l10n('CompleteCrewTooltipBody')), 'selected': filters[PREFS.FULL_CREW]}
        no_master = {'label': l10n('NoMaster'), 'tooltip': makeTooltip(l10n('NoMasterTooltipHeader'), l10n('NoMasterTooltipBody')), 'selected': filters[PREFS.NO_MASTER]}
        reserve = {'label': l10n('ReserveFilter'), 'tooltip': makeTooltip(l10n('ReserveFilterTooltipHeader'), l10n('ReserveFilterTooltipBody')), 'selected': filters[PREFS.RESERVE]}

        is_igr = PREFS.IGR in mapping[_SECTION.SPECIALS]
        if is_igr:
            igr = data['specials'][-1]

        data['specials'] = [
            premium,       normal, 
            elite,         non_elite, 
            complete_crew, no_master,
            reserve]

        if is_igr:
            data['specials'].append(igr)
    except Exception as ex:
        err('_filter_popover_getInitialVO() exception: ' + traceback.format_exc())
    return data
Ejemplo n.º 5
0
    def update_config(self):
        self.loginErrorString = l10n(config.get('login/onlineServers/errorString', '--k'))
        self.hangarErrorString = l10n(config.get('hangar/onlineServers/errorString', '--k'))
        self.loginShowTitle = config.get('login/onlineServers/showTitle', True)
        self.hangarShowTitle = config.get('hangar/onlineServers/showTitle', True)
        ignoredServersLogin = config.get('login/onlineServers/ignoredServers', [])
        ignoredServersHangar = config.get('hangar/onlineServers/ignoredServers', [])

        self.loginHosts = []
        self.hangarHosts = []
        self.peripheryIdMap = {}
        if self.loginSection is not None:
            for (name, subSec) in self.loginSection.items():
                host_name = subSec.readStrings('short_name')
                if len(host_name) > 0:
                    host_name = host_name[0]
                    if host_name not in ignoredServersLogin:
                        self.loginHosts.append(host_name)
                    if host_name not in ignoredServersHangar:
                        self.hangarHosts.append(host_name)
                    self.peripheryIdMap[subSec.readStrings('periphery_id')[0]] = host_name

            alphanumeric_sort(self.loginHosts)
            alphanumeric_sort(self.hangarHosts)
            self.done_config = True
Ejemplo n.º 6
0
    def setXvmContactData(self, uid, value):
        try:
            if self.cached_data is None or 'players' not in self.cached_data:
                raise Exception('[INTERNAL_ERROR]')

            if (value['nick'] is None
                    or value['nick'] == '') and (value['comment'] is None
                                                 or value['comment'] == ''):
                self.cached_data['players'].pop(str(uid), None)
            else:
                self.cached_data['players'][str(uid)] = value

            json_data = simplejson.dumps(self.cached_data)
            #log(json_data)
            self._doRequest('addComments', json_data)

            return True

        except Exception as ex:
            self.contacts_disabled = True
            self.is_available = False
            self.cached_token = None
            self.cached_data = None

            errstr = _SYSTEM_MESSAGE_TPL.replace(
                '%VALUE%', '<b>{0}</b>\n\n{1}\n\n{2}'.format(
                    l10n('Error saving comments'), str(ex),
                    l10n('Comments disabled')))
            SystemMessages.pushMessage(errstr,
                                       type=SystemMessages.SM_TYPE.Error)
            err(traceback.format_exc())

            return False
Ejemplo n.º 7
0
    def update_config(self):
        self.loginErrorString = l10n(config.get('login/pingServers/errorString', '--'))
        self.hangarErrorString = l10n(config.get('hangar/pingServers/errorString', '--'))
        self.loginShowTitle = config.get('login/pingServers/showTitle', True)
        self.hangarShowTitle = config.get('hangar/pingServers/showTitle', True)
        ignoredServers = config.get('hangar/pingServers/ignoredServers', [])

        self.hosts_urls = {}
        self.loginHosts = []
        self.hangarHosts = []
        if self.loginSection is not None:
            for (name, subSec) in self.loginSection.items():
                host_name = subSec.readStrings('name')[0]
                if 'Supertest' not in host_name:
                    if len(host_name) >= 13:
                        host_name = subSec.readStrings('short_name')[0]
                    elif host_name.startswith('WOT '):
                        host_name = host_name[4:]
                self.hosts_urls[host_name] = subSec.readStrings('url')[0]
                self.loginHosts.append(host_name)
                if host_name not in ignoredServers:
                    self.hangarHosts.append(host_name)
            alphanumeric_sort(self.loginHosts)
            alphanumeric_sort(self.hangarHosts)
            self.done_config = True
Ejemplo n.º 8
0
    def setXvmContactData(self, uid, value):
        try:
            if self.cached_data is None or 'players' not in self.cached_data:
                raise Exception('[INTERNAL_ERROR]')

            if (value['nick'] is None or value['nick'] == '') and (value['comment'] is None or value['comment'] == ''):
                self.cached_data['players'].pop(str(uid), None)
            else:
                self.cached_data['players'][str(uid)] = value

            json_data = simplejson.dumps(self.cached_data)
            #log(json_data)
            self._doRequest('addComments', json_data)

            return True

        except Exception as ex:
            self.contacts_disabled = True
            self.is_available = False
            self.cached_token = None
            self.cached_data = None

            errstr = _SYSTEM_MESSAGE_TPL.replace('%VALUE%', '<b>{0}</b>\n\n{1}\n\n{2}'.format(
                l10n('Error saving comments'),
                str(ex),
                l10n('Comments disabled')))
            SystemMessages.pushMessage(errstr, type=SystemMessages.SM_TYPE.Error)
            err(traceback.format_exc())

            return False
Ejemplo n.º 9
0
def QuestsTileChainsView_as_setHeaderDataS(base, self, data):
    if data:
        data['filters']['taskTypeFilterData'].insert(2, {'label': l10n('Hide with honors'),
                                                         'data': FILTERS.HIDE_WITH_HONORS})
        data['filters']['taskTypeFilterData'].insert(3, {'label': l10n('Started'),
                                                         'data': FILTERS.STARTED})
    return base(self, data)
Ejemplo n.º 10
0
def DetailedStatisticsUtils_getStatistics(base, targetData, isCurrentuser, layout):
    res = base(targetData, isCurrentuser, layout)
    global _lastVehCD
    if _lastVehCD is not None and config.networkServicesSettings.statAwards:
        try:
            battles = targetData.getBattlesCount()
            dmg = targetData.getDamageDealt()
            frg = targetData.getFragsCount()

            # remove empty lines
            if res[0]['data'][4] is None:
                del res[0]['data'][4]
            #if res[1]['data'][1] is None:
            #    del res[1]['data'][1]
            #if res[1]['data'][4] is None:
            #    del res[1]['data'][4]

            # xTE
            data = -1
            vinfo = vehinfo.getVehicleInfoData(_lastVehCD)
            ref = {'avgdmg': vinfo.get('avgdmg', None),
                   'avgfrg': vinfo.get('avgfrg', None),
                   'topdmg': vinfo.get('topdmg', None),
                   'topfrg': vinfo.get('topfrg', None)}
            #log('vehCD: {} b:{} d:{} f:{}'.format(_lastVehCD, battles, dmg, frg))
            if battles > 0 and dmg >= 0 and frg >= 0:
                curdmg = float(dmg) / battles
                curfrg = float(frg) / battles
                ref['curdmg'] = curdmg
                ref['curfrg'] = curfrg
                x = vehinfo.calculateXTE(_lastVehCD, curdmg, curfrg)
                ref['xte'] = x
                ref['xte_sup'] = xvm_scale.XvmScaleToSup(x)
                if x >= 0:
                    color = utils.getDynamicColorValue(consts.DYNAMIC_VALUE_TYPE.X, x)
                    xStr = 'XX' if x == 100 else ('0' if x < 10 else '') + str(x)
                    data = '<font color="#{}" size="12">({} {}%)</font>  <font color="{}">{}</font>'.format(
                        XFW_COLORS.UICOLOR_LABEL, l10n('better than'), ref['xte_sup'], color, xStr)
                    #log("xte={} color={}".format(xStr, color))
            res[0]['data'].insert(0, {
                'label': 'xTE',
                'data': data,
                'tooltip': 'xvm_xte',
                'tooltipData': {'body': ref, 'header': {}, 'note': None}})

            # xTDB
            item = res[1]['data'][2]
            if battles > 0 and dmg >= 0:
                x = vehinfo.calculateXTDB(_lastVehCD, float(dmg) / battles)
                sup = xvm_scale.XvmScaleToSup(x)
                if x >= 0:
                    color = utils.getDynamicColorValue(consts.DYNAMIC_VALUE_TYPE.X, x)
                    item['data'] = '<font color="#{}" size="12">({} {}%)</font>  <font color="{}">{}</font>'.format(
                        XFW_COLORS.UICOLOR_LABEL, l10n('better than'), sup, color, item['data'])

        except:
            err(traceback.format_exc())

    return res
Ejemplo n.º 11
0
def confirmReserveVehicle(self):
    try:
        showDialog(
            SimpleDialogMeta(l10n('reserve_confirm_title'),
                             l10n('reserve_confirm_message'),
                             I18nConfirmDialogButtons()),
            partial(checkReserveVehicle, self.vehCD))
    except Exception as ex:
        err(traceback.format_exc())
Ejemplo n.º 12
0
def _SquadActionsHandler_confirmCallback(base, self, result):
    if not result:
        return
    try:
        if battle_tiers_difference >= WARN_SQUAD_BATTLETIER_DIFFERENCE:
            showDialog(SimpleDialogMeta(l10n('Warning'), l10n('Squad tanks battle tiers difference') + ': %s.' % battle_tiers_difference, I18nConfirmDialogButtons()), partial(base, self))
            return True
    except Exception, ex:
        err(traceback.format_exc())
Ejemplo n.º 13
0
def _SquadActionsHandler_confirmCallback(base, self, result):
    if not result:
        return
    try:
        if battle_tiers_difference >= WARN_SQUAD_BATTLETIER_DIFFERENCE:
            showDialog(SimpleDialogMeta(l10n('Warning'), l10n('Squad tanks battle tiers difference') + ': %s.' % battle_tiers_difference, I18nConfirmDialogButtons()), partial(base, self))
            return True
    except Exception, ex:
        err(traceback.format_exc())
def _VehicleContextMenuHandler_generateOptions(base, self, ctx = None):
    result = base(self, ctx)
    try:
        if reserve.is_reserved(self.vehCD):
            result.insert(-1, self._makeItem(VEHICLE.UNCHECKRESERVE, l10n('uncheck_reserve_menu')))
        else:
            result.insert(-1, self._makeItem(VEHICLE.CHECKRESERVE, l10n('check_reserve_menu')))
    except Exception as ex:
        err(traceback.format_exc())
    return result
Ejemplo n.º 15
0
def ModuleInfoWindow_as_setModuleInfoS(base, self, moduleInfo):
    try:
        if moduleInfo['type'] == 'vehicleGun':
            veh_id = self._ModuleInfoWindow__vehicleDescr.type.compactDescr
            vehicle = g_itemsCache.items.getItemByCD(veh_id)
            gun = g_itemsCache.items.getItemByCD(self.moduleCompactDescr).descriptor
            turret = self._ModuleInfoWindow__vehicleDescr.turret    # not accurate, but not relevant here
            (viewRange, shellRadius, artiRadius) = _getRanges(turret, gun, vehicle.nationName, vehicle.type)
            if vehicle.type == 'SPG':   # arti
                moduleInfo['parameters']['params'].append({'type': '<h>' + l10n('shootingRadius') + ' <p>' + l10n('(m)') + '</p></h>', 'value': '<h>' + str(artiRadius) + '</h>'})
            elif shellRadius < 707:     # not arti, short range weapons
                moduleInfo['parameters']['params'].append({'type': '<h>' + l10n('shootingRadius') + ' <p>' + l10n('(m)') + '</p></h>', 'value': '<h>' + str(shellRadius) + '</h>'})
    except Exception, ex:
        err(traceback.format_exc())
def teamDamage_onHealthChanged(self, diffHealth, attackerID, attackReasonID):
    player = BigWorld.player()
    attacker = avatar_getter.getArena().vehicles.get(attackerID)
    if (None in (player, attacker)) or (
            diffHealth <=
            battleMessagesConfig['teamDamage']['ignoreLessThan']):
        return
    if (player.team == attacker['team'] ==
            self.publicInfo.team) and (self.id != attackerID):
        message = _getL10n(battleMessagesConfig['teamDamage']['format'])
        message = message.replace('{{damage}}', str(diffHealth))
        message = message.replace('{{damage-reason}}',
                                  l10n(ATTACK_REASONS[attackReasonID]))
        message = message.replace('{{victim-name}}', self.publicInfo.name)
        message = message.replace('{{victim-vehicle}}',
                                  self.typeDescriptor.type.shortUserString)
        message = message.replace('{{attacker-name}}', attacker['name'])
        message = message.replace('{{attacker-vehicle}}',
                                  attacker['vehicleType'].type.shortUserString)

        enabledFor = battleMessagesConfig['teamDamage']['enabledFor']
        if enabledFor == 'all':
            showTeamDamage(message)
        elif (enabledFor
              == 'player') and ((self.publicInfo.name == player.name) or
                                (attacker['name'] == player.name)):
            showTeamDamage(message)
        elif (enabledFor
              == 'ally') and (self.publicInfo.name != player.name) and (
                  attacker['name'] != player.name):
            showTeamDamage(message)
Ejemplo n.º 17
0
def BarracksMeta_as_setTankmenS(base, self, data):
    try:
        if cfg_hangar_barracksShowFlags or cfg_hangar_barracksShowSkills:
            imgPath = 'img://../mods/shared_resources/xvm/res/icons/barracks'
            for tankman in data['tankmenData']:
                if ('role' not in tankman) or tankman['notRecruited']:
                    continue
                tankman['rank'] = tankman['role']
                tankman_role_arr = []
                if cfg_hangar_barracksShowFlags:
                    tankman_role_arr.append("<img src='%s/nations/%s.png' vspace='-3'>" % (imgPath, nations.NAMES[tankman['nationID']]))
                if cfg_hangar_barracksShowSkills:
                    tankman_role_arr.append('')
                    itemsCache = dependency.instance(IItemsCache)
                    tankman_full_info = itemsCache.items.getTankman(tankman['tankmanID'])
                    if tankman_full_info is not None:
                        for skill in tankman_full_info.skills:
                            tankman_role_arr[-1] += "<img src='%s/skills/%s' vspace='-3'>" % (imgPath, skill.icon)
                        if len(tankman_full_info.skills):
                            tankman_role_arr[-1] += "%s%%" % tankman_full_info.descriptor.lastSkillLevel
                        if tankman_full_info.hasNewSkill and tankman_full_info.newSkillCount[0] > 0:
                            tankman_role_arr[-1] += "<img src='%s/skills/new_skill.png' vspace='-3'>x%s" % (imgPath, tankman_full_info.newSkillCount[0])
                    if not tankman_role_arr[-1]:
                        tankman_role_arr[-1] = l10n('noSkills')
                tankman['role'] = ' '.join(tankman_role_arr)
    except Exception as ex:
        err(traceback.format_exc())
    return base(self, data)
Ejemplo n.º 18
0
def squad_update_tiers(self, *args, **kwargs):
    try:
        global squad_window_handler, battle_tiers_difference
        squad_window_handler = self
        if not window_populated:
            return
        min_tier = 0
        max_tiers = []
        squad_unitFunctional = self.unitFunctional.getUnit()[1]
        if not squad_unitFunctional:
            as_xfw_cmd(COMMANDS.AS_UPDATE_TIERS, '')
            return
        for squad_vehicle in squad_unitFunctional.getVehicles().values():
            veh = g_itemsCache.items.getItemByCD(squad_vehicle[0].vehTypeCompDescr)
            (veh_tier_low, veh_tier_high) = getTiers(veh.level, veh.type, veh.name)
            min_tier = max(veh_tier_low, min_tier)
            max_tiers.append(veh_tier_high)

        text_tiers = ''
        if min_tier > 0:
            max_tier = max(max_tiers)
            battle_tiers_difference = max_tier - min(max_tiers)
            text_tiers = ' - %s: %s..%s' % (l10n('Squad battle tiers'), min_tier, max_tier)
        as_xfw_cmd(COMMANDS.AS_UPDATE_TIERS, text_tiers)
    except Exception, ex:
        err(traceback.format_exc())
Ejemplo n.º 19
0
def squad_update_tiers(self, *args, **kwargs):
    try:
        global squad_window_handler, battle_tiers_difference
        squad_window_handler = self
        if not window_populated:
            return
        min_tier = 0
        max_tiers = []
        entity = self.prbEntity.getUnit()[1]
        if not entity:
            as_xfw_cmd(COMMANDS.AS_UPDATE_TIERS, '')
            return
        for squad_vehicle in entity.getVehicles().values():
            itemsCache = dependency.instance(IItemsCache)
            veh = itemsCache.items.getItemByCD(
                squad_vehicle[0].vehTypeCompDescr)
            (veh_tier_low, veh_tier_high) = getTiers(veh.level, veh.type,
                                                     veh.name)
            min_tier = max(veh_tier_low, min_tier)
            max_tiers.append(veh_tier_high)

        text_tiers = ''
        if min_tier > 0:
            max_tier = max(max_tiers)
            battle_tiers_difference = max_tier - min(max_tiers)
            text_tiers = ' - %s: %s..%s' % (l10n('Squad battle tiers'),
                                            min_tier, max_tier)
        as_xfw_cmd(COMMANDS.AS_UPDATE_TIERS, text_tiers)
    except Exception, ex:
        err(traceback.format_exc())
Ejemplo n.º 20
0
 def onHealthChanged(self,
                     vehicle,
                     newHealth,
                     attackerID,
                     attackReasonID,
                     isVehicle=True):
     self.resetData()
     self.isVehicle = isVehicle
     self.vehicleID = vehicle.id
     self.data['isAlive'] = vehicle.isAlive()
     if attackReasonID < 8:
         self.data['attackReasonID'] = attackReasonID
     elif attackReasonID in [9, 10, 13, 24]:
         self.data['attackReasonID'] = 24
     elif attackReasonID in [11, 14, 25]:
         self.data['attackReasonID'] = 25
     self.data['blownup'] = newHealth <= -5
     newHealth = max(0, newHealth)
     self.data['damage'] = (
         self.vehHealth[vehicle.id]['health'] -
         newHealth) if vehicle.id in self.vehHealth else (-newHealth)
     if self.data['attackReasonID'] != 0:
         self.criticalHit = False
         self.splashHit = False
         self.compName = None
     else:
         self.setParametersShot()
         self.data['damageDeviation'] = self.getDamageDeviation(newHealth)
     if not self.isVehicle:
         self.entityNumber = vehicle.destructibleEntityID
         self.data[
             'teamDmg'] = 'ally-dmg' if vehicle.isPlayerTeam else 'enemy-dmg'
         self.data['shortUserString'] = l10n(PILLBOX).format(
             self.entityNumber)
     self.updateData()
Ejemplo n.º 21
0
def _QuestsTileChainsView_as_setHeaderDataS(base, self, data):
    if data:
        data['filters']['taskTypeFilterData'].insert(
            2, {
                'label': l10n('Hide with honors'),
                'data': FILTERS.HIDE_WITH_HONORS
            })
        data['filters']['taskTypeFilterData'].insert(3, {
            'label': l10n('Started'),
            'data': FILTERS.STARTED
        })
        data['filters']['taskTypeFilterData'].insert(
            4, {
                'label': l10n('Incomplete'),
                'data': FILTERS.INCOMPLETE
            })
    return base(self, data)
Ejemplo n.º 22
0
def CrewContextMenuHandler_generateOptions(base, self, ctx = None):
    # debug('CrewContextMenuHandler_generateOptions')
    if self._tankmanID:
        return base(self, ctx) + [
            self._makeSeparator(),
            self._makeItem(CREW.DROP_ALL_CREW, l10n(CREW.DROP_ALL_CREW)),
        ]
    else:
        return [
            self._makeItem(CREW.PUT_OWN_CREW, l10n(CREW.PUT_OWN_CREW)),
            self._makeSeparator(),
            self._makeItem(CREW.PUT_BEST_CREW, l10n(CREW.PUT_BEST_CREW)),
            self._makeSeparator(),
            self._makeItem(CREW.PUT_CLASS_CREW, l10n(CREW.PUT_CLASS_CREW)),
            self._makeSeparator(),
            self._makeItem(CREW.PUT_PREVIOUS_CREW, l10n(CREW.PUT_PREVIOUS_CREW)),
        ]
Ejemplo n.º 23
0
def CrewContextMenuHandler_generateOptions(base, self, ctx = None):
    # debug('CrewContextMenuHandler_generateOptions')
    if self._tankmanID:
        return base(self, ctx) + [
            self._makeSeparator(),
            self._makeItem(CREW.DROP_ALL_CREW, l10n(CREW.DROP_ALL_CREW)),
        ]
    else:
        return [
            self._makeItem(CREW.PUT_OWN_CREW, l10n(CREW.PUT_OWN_CREW)),
            self._makeSeparator(),
            self._makeItem(CREW.PUT_BEST_CREW, l10n(CREW.PUT_BEST_CREW)),
            self._makeSeparator(),
            self._makeItem(CREW.PUT_CLASS_CREW, l10n(CREW.PUT_CLASS_CREW)),
            self._makeSeparator(),
            self._makeItem(CREW.PUT_PREVIOUS_CREW, l10n(CREW.PUT_PREVIOUS_CREW)),
        ]
Ejemplo n.º 24
0
def PlayerContactsCMHandler_generateOptions(base, self, ctx=None):
    #log('PlayerContactsCMHandler_generateOptions')
    options = base(self, ctx)
    options.append(
        self._makeItem(MENU.XVM_EDIT_CONTACT_DATA,
                       l10n('Edit data'),
                       optInitData={'enabled': contacts.isAvailable()}))
    return options
Ejemplo n.º 25
0
def ContactTooltipData_getDisplayableData(base, self, dbID, defaultName):
    result = base(self, dbID, defaultName)
    if contacts.isAvailable():
        #if result['xvm_contact_data']['nick']: # commented for use original nick in tooltip
        #    result['userProps']['userName'] = result['xvm_contact_data']['nick']
        if result['xvm_contact_data']['comment']:
            result['note'] = "<font color='#%s'>%s</font>" % (
                XFW_COLORS.UICOLOR_LABEL,
                l10n(result['xvm_contact_data']['comment']))
    return result
Ejemplo n.º 26
0
def barrack_packActiveTankman(base, tankman):
    try:
        if isinstance(tankman, Tankman):
            tankmanData = barrack._packTankmanData(tankman)

            if tankman.isInTank:
                actionBtnLabel = MENU.BARRACKS_BTNUNLOAD
                actionBtnTooltip = TOOLTIPS.BARRACKS_TANKMEN_UNLOAD
            else:
                actionBtnLabel = MENU.BARRACKS_BTNDISSMISS
                actionBtnTooltip = TOOLTIPS.BARRACKS_TANKMEN_DISMISS
            tankmanData.update({
                'isRankNameVisible': True,
                'recoveryPeriodText': None,
                'actionBtnLabel': actionBtnLabel,
                'actionBtnTooltip': actionBtnTooltip,
                'skills': None,
                'isSkillsVisible': False
            })

            if cfg_hangar_barracksShowFlags or cfg_hangar_barracksShowSkills:
                imgPath = 'img://../mods/shared_resources/xvm/res/icons/barracks'
                tankmanData['rank'] = tankmanData['role']
                tankman_role_arr = []
                if cfg_hangar_barracksShowFlags:
                    tankman_role_arr.append(
                        "<img src='%s/nations/%s.png' vspace='-3'>" %
                        (imgPath, nations.NAMES[tankmanData['nationID']]))
                if cfg_hangar_barracksShowSkills:
                    tankman_role_arr.append('')
                    itemsCache = dependency.instance(IItemsCache)
                    tankman_full_info = itemsCache.items.getTankman(
                        tankmanData['tankmanID'])
                    if tankman_full_info is not None:
                        for skill in tankman_full_info.skills:
                            tankman_role_arr[
                                -1] += "<img src='%s/skills/%s' vspace='-3'>" % (
                                    imgPath, skill.icon)
                        if len(tankman_full_info.skills):
                            tankman_role_arr[
                                -1] += "%s%%" % tankman_full_info.descriptor.lastSkillLevel
                        if tankman_full_info.hasNewSkill and tankman_full_info.newSkillCount[
                                0] > 0:
                            tankman_role_arr[
                                -1] += "<img src='%s/skills/new_skill.png' vspace='-3'>x%s" % (
                                    imgPath,
                                    tankman_full_info.newSkillCount[0])
                    if not tankman_role_arr[-1]:
                        tankman_role_arr[-1] = l10n('noSkills')
                    tankmanData['role'] = ' '.join(tankman_role_arr)
            return tankmanData
        else:
            return tankman
    except Exception as ex:
        err(traceback.format_exc())
Ejemplo n.º 27
0
    def initialize(self):
        try:
            self.is_available = False

            if not self.contacts_disabled:
                self.contacts_disabled = not config.networkServicesSettings.comments
            if self.contacts_disabled:
                return

            if config.token.online:
                token = config.token.token
                if token is None:
                    raise Exception('[TOKEN_NOT_INITIALIZED] {0}'.format(
                        l10n('Network services unavailable')))

                if self.cached_data is None or self.cached_token != token:
                    self.cached_token = token
                    json_data = self._doRequest('getComments')
                    data = {
                        'ver': _CONTACTS_DATA_VERSION,
                        'players': {}
                    } if json_data is None else simplejson.loads(json_data)
                    if data['ver'] != _CONTACTS_DATA_VERSION:
                        pass  # data = convertOldVersion(data)
                    self.cached_data = data

                self.is_available = True

        except Exception as ex:
            self.contacts_disabled = True
            self.is_available = False
            self.cached_token = None
            self.cached_data = None

            errstr = _SYSTEM_MESSAGE_TPL.replace(
                '%VALUE%', '<b>{0}</b>\n\n{1}\n\n{2}'.format(
                    l10n('Error loading comments'), str(ex),
                    l10n('Comments disabled')))
            SystemMessages.pushMessage(errstr,
                                       type=SystemMessages.SM_TYPE.Warning)
            warn(traceback.format_exc())
Ejemplo n.º 28
0
    def update_config(self):
        self.loginErrorString = l10n(config.get('login/pingServers/errorString', '--'))
        self.hangarErrorString = l10n(config.get('hangar/pingServers/errorString', '--'))
        self.loginShowTitle = config.get('login/pingServers/showTitle', True)
        self.hangarShowTitle = config.get('hangar/pingServers/showTitle', True)
        ignoredServersLogin = config.get('login/pingServers/ignoredServers', [])
        ignoredServersHangar = config.get('hangar/pingServers/ignoredServers', [])

        self.hosts_urls = {}
        self.loginHosts = []
        self.hangarHosts = []
        if self.loginSection is not None:
            for (name, subSec) in self.loginSection.items():
                host_name = subSec.readStrings('short_name')[0]
                self.hosts_urls[host_name] = subSec.readStrings('url')[0]
                if host_name not in ignoredServersLogin:
                    self.loginHosts.append(host_name)
                if host_name not in ignoredServersHangar:
                    self.hangarHosts.append(host_name)
            alphanumeric_sort(self.loginHosts)
            alphanumeric_sort(self.hangarHosts)
            self.done_config = True
Ejemplo n.º 29
0
    def initialize(self):
        try:
            self.is_available = False

            self.contacts_disabled = not token.networkServicesSettings['comments']
            if self.contacts_disabled:
                return

            if token.isOnline:
                t = token.getToken()
                if t is None:
                    raise Exception('[TOKEN_NOT_INITIALIZED] {0}'.format(l10n('Network services unavailable')))
                if t == '':
                    raise Exception('[NO_TOKEN] {0}'.format(l10n('Network services unavailable')))

                if self.cached_data is None or self.cached_token != t:
                    self.cached_token = t
                    json_data = self._doRequest('getComments')
                    data = {'ver':_CONTACTS_DATA_VERSION,'players':{}} if json_data is None else simplejson.loads(json_data)
                    if data['ver'] != _CONTACTS_DATA_VERSION:
                        pass # data = convertOldVersion(data)
                    self.cached_data = data

                self.is_available = True

        except Exception as ex:
            self.contacts_disabled = True
            self.is_available = False
            self.cached_token = None
            self.cached_data = None

            errstr = _SYSTEM_MESSAGE_TPL.replace('%VALUE%', '<b>{0}</b>\n\n{1}\n\n{2}'.format(
                l10n('Error loading comments'),
                str(ex),
                l10n('Comments disabled')))
            SystemMessages.pushMessage(errstr, type=SystemMessages.SM_TYPE.Warning)
            warn(traceback.format_exc())
Ejemplo n.º 30
0
 def updateData(self):
     maxHealth = self.vehHealth[
         self.
         vehicleID]['maxHealth'] if self.vehicleID in self.vehHealth else 0
     self.data['dmgRatio'] = self.data[
         'damage'] * 100 // maxHealth if maxHealth != 0 else 0
     if self.vehicleID:
         attacked = self.player.arena.vehicles.get(self.vehicleID)
         if attacked is not None:
             vehicleType = attacked['vehicleType']
             self.data['name'] = attacked['name']
             self.data['clanAbbrev'] = attacked['clanAbbrev']
             if vehicleType:
                 _type = vehicleType.type
                 self.data['attackedVehicleType'] = list(
                     _type.tags.intersection(VEHICLE_CLASSES))[0]
                 self.data[
                     'attackerVehicleName'] = vehicleType.name.replace(
                         ':', '-', 1) if vehicleType.name else ''
                 self.data['shortUserString'] = _type.shortUserString
                 self.data['level'] = vehicleType.level
                 self.data['nation'] = nations.NAMES[
                     _type.customizationNationID]
                 if self.data['attackReasonID'] == 2:
                     self.data['diff-masses'] = (
                         self.player.vehicleTypeDescriptor.physics['weight']
                         - vehicleType.physics['weight']) / 1000.0
             self.setRatings()
         elif not self.isVehicle:
             self.data['shortUserString'] = l10n(PILLBOX).format(
                 self.entityNumber)
             self.compName = None
             self.criticalHit = None
         self.data['clanicon'] = _stat.getClanIcon(self.vehicleID)
         arenaDP = self.guiSessionProvider.getArenaDP()
         if arenaDP is not None:
             vInfo = arenaDP.getVehicleInfo(vID=self.vehicleID)
             self.data[
                 'squadnum'] = vInfo.squadIndex if vInfo.squadIndex != 0 else None
             self.data['teamDmg'] = self.getTeamDmg(vInfo)
     self.data['splashHit'] = self.splashHit
     self.data['criticalHit'] = self.criticalHit
     self.data['compName'] = self.compName
     self.data['battletype-key'] = self.battletypeKey
     self.updateLabels()
Ejemplo n.º 31
0
def BarracksMeta_as_setTankmenS(base, self, data):
    try:
        if cfg_hangar_barracksShowFlags or cfg_hangar_barracksShowSkills:
            imgPath = 'img://../mods/shared_resources/xvm/res/icons/barracks'
            for tankman in data['tankmenData']:
                if ('role' not in tankman) or tankman['notRecruited']:
                    continue
                tankman['rank'] = tankman['role']
                tankman_role_arr = []
                if cfg_hangar_barracksShowFlags:
                    tankman_role_arr.append(
                        "<img src='%s/nations/%s.png' vspace='-3'>" %
                        (imgPath, nations.NAMES[tankman['nationID']]))
                if cfg_hangar_barracksShowSkills:
                    tankman_role_arr.append('')
                    itemsCache = dependency.instance(IItemsCache)
                    tankman_full_info = itemsCache.items.getTankman(
                        tankman['tankmanID'])
                    if tankman_full_info is not None:
                        for skill in tankman_full_info.skills:
                            tankman_role_arr[
                                -1] += "<img src='%s/skills/%s' vspace='-3'>" % (
                                    imgPath, skill.icon)
                        if len(tankman_full_info.skills):
                            tankman_role_arr[
                                -1] += "%s%%" % tankman_full_info.descriptor.lastSkillLevel
                        if tankman_full_info.hasNewSkill and tankman_full_info.newSkillCount[
                                0] > 0:
                            tankman_role_arr[
                                -1] += "<img src='%s/skills/new_skill.png' vspace='-3'>x%s" % (
                                    imgPath,
                                    tankman_full_info.newSkillCount[0])
                    if not tankman_role_arr[-1]:
                        tankman_role_arr[-1] = l10n('noSkills')
                tankman['role'] = ' '.join(tankman_role_arr)
    except Exception as ex:
        err(traceback.format_exc())
    return base(self, data)
Ejemplo n.º 32
0
def BarracksMeta_as_setTankmenS(base, self, tankmenCount, tankmenInSlots, placesCount, tankmenInBarracks, tankmanArr):
    try:
        imgPath = 'img://../mods/shared_resources/xvm/res/icons/barracks'
        for tankman in tankmanArr:
            if 'role' not in tankman:
                continue
            tankman['rank'] = tankman['role']
            tankman['role'] = "<img src='%s/nations/%s.png' vspace='-3'>" % (imgPath, nations.NAMES[tankman['nationID']])
            tankman_full_info = g_itemsCache.items.getTankman(tankman['tankmanID'])
            skills_str = ''
            for skill in tankman_full_info.skills:
                skills_str += "<img src='%s/skills/%s' vspace='-3'>" % (imgPath, skill.icon)
            if len(tankman_full_info.skills):
                skills_str += "%s%%" % tankman_full_info.descriptor.lastSkillLevel
            if tankman_full_info.hasNewSkill:
                skills_str += "<img src='%s/skills/new_skill.png' vspace='-3'>x%s" % (imgPath, tankman_full_info.newSkillCount[0])
            if not skills_str:
                skills_str = l10n('noSkills')
            tankman['role'] += ' ' + skills_str
    except Exception as ex:
        err(traceback.format_exc())

    return base(self, tankmenCount, tankmenInSlots, placesCount, tankmenInBarracks, tankmanArr)
Ejemplo n.º 33
0
def confirmReserveVehicle(self):
    try:
        showDialog(SimpleDialogMeta(l10n('reserve_confirm_title'), l10n('reserve_confirm_message'), I18nConfirmDialogButtons()), partial(checkReserveVehicle, self.vehCD))
    except Exception as ex:
        err(traceback.format_exc())
Ejemplo n.º 34
0
def _filter_popover_getInitialVO(base, filters, mapping, xpRateMultiplier):
    data = base(filters, mapping, xpRateMultiplier)
    #debug(data['specials'])
    #debug(mapping)
    try:
        premium = data['specials'][mapping[_SECTION.SPECIALS].index(
            PREFS.PREMIUM)]
        normal = {
            'label':
            l10n('Normal'),
            'tooltip':
            makeTooltip(l10n('NormalTooltipHeader'),
                        l10n('NormalTooltipBody')),
            'selected':
            filters[PREFS.NORMAL]
        }
        elite = data['specials'][mapping[_SECTION.SPECIALS].index(PREFS.ELITE)]
        non_elite = {
            'label':
            l10n('NonElite'),
            'tooltip':
            makeTooltip(l10n('NonEliteTooltipHeader'),
                        l10n('NonEliteTooltipBody')),
            'selected':
            filters[PREFS.NON_ELITE]
        }
        complete_crew = {
            'label':
            l10n('CompleteCrew'),
            'tooltip':
            makeTooltip(l10n('CompleteCrewTooltipHeader'),
                        l10n('CompleteCrewTooltipBody')),
            'selected':
            filters[PREFS.FULL_CREW]
        }
        no_master = {
            'label':
            l10n('NoMaster'),
            'tooltip':
            makeTooltip(l10n('NoMasterTooltipHeader'),
                        l10n('NoMasterTooltipBody')),
            'selected':
            filters[PREFS.NO_MASTER]
        }
        reserve = {
            'label':
            l10n('ReserveFilter'),
            'tooltip':
            makeTooltip(l10n('ReserveFilterTooltipHeader'),
                        l10n('ReserveFilterTooltipBody')),
            'selected':
            filters[PREFS.RESERVE]
        }

        is_igr = PREFS.IGR in mapping[_SECTION.SPECIALS]
        if is_igr:
            igr = data['specials'][-1]

        data['specials'] = [
            premium, normal, elite, non_elite, complete_crew, no_master,
            reserve
        ]

        if is_igr:
            data['specials'].append(igr)
    except Exception as ex:
        err('_filter_popover_getInitialVO() exception: ' +
            traceback.format_exc())
    return data
Ejemplo n.º 35
0
def ContactTooltipData_getDisplayableData(base, self, dbID, defaultName):
    result = base(self, dbID, defaultName)
    if contacts.isAvailable():
        #if result['xvm_contact_data']['nick']: # commented for use original nick in tooltip
        #    result['userProps']['userName'] = result['xvm_contact_data']['nick']
        if result['xvm_contact_data']['comment']:
            result['note'] = "<font color='#%s'>%s</font>"  % (XFWCOLORS.UICOLOR_LABEL, l10n(result['xvm_contact_data']['comment']))
    return result
Ejemplo n.º 36
0
def i18n_makeString(base, key, *args, **kwargs):
    if key == '#menu:tankCarousel/vehicleStates/ammoNotFull': # originally returns empty string
        return l10n('lowAmmo')
    return base(key, *args, **kwargs)
Ejemplo n.º 37
0
def vehicle_nation():
    td = _typeDescriptor()
    return None if not td else l10n(NAMES[td.type.customizationNationID])
Ejemplo n.º 38
0
def confirmReserveVehicle(self):
    showDialog(SimpleDialogMeta(l10n('reserve_confirm_title'), l10n('reserve_confirm_message'), I18nConfirmDialogButtons()), partial(checkReserveVehicle, self.vehCD))
Ejemplo n.º 39
0
def VehicleParamsField_getValue(base, self):
    # log('VehicleParamsField_getValue')
    try:
        global carousel_tooltips_cache
        vehicle = self._tooltip.item
        context_name = self._tooltip.context.getComponent()
        cache_result = carousel_tooltips_cache.get(vehicle.intCD, {}).get(context_name)
        if cache_result:
            return cache_result
        result = list()
        configuration = self._tooltip.context.getParamsConfiguration(vehicle)
        params = configuration.params
        crew = configuration.crew
        eqs = configuration.eqs
        devices = configuration.devices
        veh_descr = vehicle.descriptor
        gun = vehicle.gun.descriptor
        turret = vehicle.turret.descriptor
        vehicleCommonParams = dict(ItemsParameters.g_instance.getParameters(veh_descr))
        vehicleRawParams = dict(ParametersCache.g_instance.getParameters(veh_descr))
        result.append([])
        veh_type_inconfig = vehicle.type.replace('AT-SPG', 'TD')
        clipGunInfoShown = False
        premium_shells = {}
        for shell in vehicle.shells:
            premium_shells[shell.intCompactDescr] = shell.isPremium
        if params:
            values = config.get('tooltips/%s' % veh_type_inconfig)
            if values and len(values):
                params_list = values # overriding parameters
            else:
                params_list = self.PARAMS.get(vehicle.type, 'default') # original parameters
            for paramName in params_list:
                if paramName == 'turretArmor' and not vehicle.hasTurrets:
                    continue
                #inner name, for example - ussr:R100_SU122A
                if paramName == 'innerName':
                    result[-1].append([h1_pad(vehicle.name), ''])
                    continue
                #maxHealth
                if paramName == 'maxHealth':
                    result[-1].append([h1_pad(i18n.makeString('#menu:vehicleInfo/params/maxHealth')), h1_pad(veh_descr.maxHealth)])
                    continue
                #battle tiers
                if paramName == 'battleTiers':
                    (minTier, maxTier) = getTiers(vehicle.level, vehicle.type, vehicle.name)
                    result[-1].append([h1_pad(l10n('Battle tiers')), h1_pad('%s..%s' % (minTier, maxTier))])
                    continue
                #gravity
                if paramName == 'gravity':
                    gravity_str = '%g' % round(veh_descr.shot['gravity'], 2)
                    result[-1].append([h1_pad(l10n('gravity')), h1_pad(gravity_str)])
                    continue
                #camo coeffitients
                if paramName == 'camo_coeff':
                    topTurret = veh_descr.type.turrets[0][-1]
                    camo_coeff_arr = getCamoValues(vehicle.name, turret['name'] == topTurret['name'], gun['name'])
                    camo_coeff_str = '/'.join(map(camo_smart_round, camo_coeff_arr))
                    result[-1].append([h1_pad(l10n('camoCoeff') + ' <p>(%)</p>'), h1_pad(camo_coeff_str)])
                    continue
                #radioRange
                if paramName == 'radioRange':
                    radioRange_str = '%s' % int(vehicle.radio.descriptor['distance'])
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/radioDistance').replace('h>', 'h1>'), h1_pad(radioRange_str)])
                    continue
                #explosionRadius
                if paramName == 'explosionRadius':
                    explosionRadiusMin = 999
                    explosionRadiusMax = 0
                    for shot in gun['shots']:
                        if 'explosionRadius' in shot['shell']:
                            if shot['shell']['explosionRadius'] < explosionRadiusMin:
                                explosionRadiusMin = shot['shell']['explosionRadius']
                            if shot['shell']['explosionRadius'] > explosionRadiusMax:
                                explosionRadiusMax = shot['shell']['explosionRadius']
                    if explosionRadiusMax == 0: # no HE
                        continue
                    explosionRadius_str = '%g' % round(explosionRadiusMin, 2)
                    if explosionRadiusMin != explosionRadiusMax:
                        explosionRadius_str += '/%s' % gold_pad('%g' % round(explosionRadiusMax, 2))
                    result[-1].append([self._getParameterValue(paramName, vehicleCommonParams, vehicleRawParams)[0], h1_pad(explosionRadius_str)])
                    continue
                #shellSpeedSummary
                if paramName == 'shellSpeedSummary':
                    shellSpeedSummary_arr = []
                    for shot in gun['shots']:
                        shellSpeed_str = '%g' % round(shot['speed'] * 1.25)
                        if premium_shells[shot['shell']['compactDescr']]:
                            shellSpeed_str = gold_pad(shellSpeed_str)
                        shellSpeedSummary_arr.append(shellSpeed_str)
                    shellSpeedSummary_str = '/'.join(shellSpeedSummary_arr)
                    result[-1].append([h1_pad('%s <p>%s</p>' % (l10n('shellSpeed'), l10n('(m/sec)'))), h1_pad(shellSpeedSummary_str)])
                    continue
                #piercingPowerAvg
                if paramName == 'piercingPowerAvg':
                    piercingPowerAvg = '%g' % veh_descr.shot['piercingPower'][0]
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/avgPiercingPower').replace('h>', 'h1>'), h1_pad(piercingPowerAvg)])
                    continue
                #piercingPowerAvgSummary
                if paramName == 'piercingPowerAvgSummary':
                    piercingPowerAvgSummary_arr = []
                    for shot in gun['shots']:
                        piercingPower_str = '%g' % shot['piercingPower'][0]
                        if premium_shells[shot['shell']['compactDescr']]:
                            piercingPower_str = gold_pad(piercingPower_str)
                        piercingPowerAvgSummary_arr.append(piercingPower_str)
                    piercingPowerAvgSummary_str = '/'.join(piercingPowerAvgSummary_arr)
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/avgPiercingPower').replace('h>', 'h1>'), h1_pad(piercingPowerAvgSummary_str)])
                    continue
                #damageAvgSummary
                if paramName == 'damageAvgSummary':
                    damageAvgSummary_arr = []
                    for shot in gun['shots']:
                        damageAvg_str = '%g' % shot['shell']['damage'][0]
                        if premium_shells[shot['shell']['compactDescr']]:
                            damageAvg_str = gold_pad(damageAvg_str)
                        damageAvgSummary_arr.append(damageAvg_str)
                    damageAvgSummary_str = '/'.join(damageAvgSummary_arr)
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/avgDamage').replace('h>', 'h1>'), h1_pad(damageAvgSummary_str)])
                    continue
                #magazine loading
                if (paramName == 'reloadTimeSecs' or paramName == 'rateOfFire') and vehicle.gun.isClipGun():
                    if clipGunInfoShown:
                        continue
                    (shellsCount, shellReloadingTime) = gun['clip']
                    reloadMagazineTime = gun['reloadTime']
                    shellReloadingTime_str = '%g' % round(shellReloadingTime, 2)
                    reloadMagazineTime_str = '%g' % round(reloadMagazineTime, 2)
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/shellsCount').replace('h>', 'h1>'), h1_pad(shellsCount)])
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/shellReloadingTime').replace('h>', 'h1>'), h1_pad(shellReloadingTime_str)])
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/reloadMagazineTime').replace('h>', 'h1>'), h1_pad(reloadMagazineTime_str)])
                    clipGunInfoShown = True
                    continue
                #rate of fire
                if paramName == 'rateOfFire' and not vehicle.gun.isClipGun():
                    rateOfFire_str = '%g' % round(60 / gun['reloadTime'], 2)
                    result[-1].append([i18n.makeString('#menu:moduleInfo/params/reloadTime').replace('h>', 'h1>'), h1_pad(rateOfFire_str)])
                    continue
                # gun traverse limits
                if paramName == 'traverseLimits' and gun['turretYawLimits']:
                    (traverseMin, traverseMax) = gun['turretYawLimits']
                    traverseLimits_str = '%g..+%g' % (round(degrees(traverseMin)), round(degrees(traverseMax)))
                    result[-1].append([h1_pad(l10n('traverseLimits')), h1_pad(traverseLimits_str)])
                    continue
                # elevation limits (front)
                if paramName == 'pitchLimits':
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(0, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    result[-1].append([h1_pad(l10n('pitchLimits')), h1_pad(pitchLimits_str)])
                    continue
                # elevation limits (side)
                if paramName == 'pitchLimitsSide':
                    if gun['turretYawLimits'] and abs(degrees(gun['turretYawLimits'][0])) < 89: continue # can't look aside 90 degrees
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(pi / 2, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    result[-1].append([h1_pad(l10n('pitchLimitsSide')), h1_pad(pitchLimits_str)])
                    continue
                # elevation limits (rear)
                if paramName == 'pitchLimitsRear':
                    if gun['turretYawLimits']: continue # can't look back
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(pi, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    result[-1].append([h1_pad(l10n('pitchLimitsRear')), h1_pad(pitchLimits_str)])
                    continue
                # shooting range
                if paramName == 'shootingRadius':
                    viewRange, shellRadius, artiRadius = _getRanges(turret, gun, vehicle.nationName, vehicle.type)
                    if vehicle.type == 'SPG':
                        result[-1].append([h1_pad('%s <p>%s</p>' % (l10n('shootingRadius'), l10n('(m)'))), h1_pad(artiRadius)])
                    elif shellRadius < 707:
                        result[-1].append([h1_pad('%s <p>%s</p>' % (l10n('shootingRadius'), l10n('(m)'))), h1_pad(shellRadius)])
                    continue
                #reverse max speed
                if paramName == 'speedLimits':
                    (speedLimitForward, speedLimitReverse) = veh_descr.physics['speedLimits']
                    speedLimits_str = str(int(speedLimitForward * 3.6)) + '/' + str(int(speedLimitReverse * 3.6))
                    result[-1].append([self._getParameterValue(paramName, vehicleCommonParams, vehicleRawParams)[0], speedLimits_str])
                    continue
                #turret rotation speed
                if paramName == 'turretRotationSpeed':
                    if not vehicle.hasTurrets:
                        paramName = 'gunRotationSpeed'
                    turretRotationSpeed_str = str(int(degrees(veh_descr.turret['rotationSpeed'])))
                    result[-1].append([self._getParameterValue(paramName, vehicleCommonParams, vehicleRawParams)[0], turretRotationSpeed_str])
                    continue
                #terrain resistance
                if paramName == 'terrainResistance':
                    resistances_arr = []
                    for key in veh_descr.chassis['terrainResistance']:
                        resistances_arr.append('%g' % round(key, 2))
                    terrainResistance_str = '/'.join(resistances_arr)
                    result[-1].append([h1_pad(l10n('terrainResistance')), h1_pad(terrainResistance_str)])
                    continue
                #custom text
                if paramName.startswith('TEXT:'):
                    customtext = paramName[5:]
                    result[-1].append([h1_pad(l10n_macros_replace(customtext)), ''])
                    continue
                if paramName in vehicleCommonParams or paramName in vehicleRawParams:
                    result[-1].append(self._getParameterValue(paramName, vehicleCommonParams, vehicleRawParams))

        if vehicle.isInInventory:
            # optional devices icons, must be in the end
            if 'optDevicesIcons' in params_list:
                optDevicesIcons_arr = []
                for key in vehicle.optDevices:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    optDevicesIcons_arr.append('<img src="%s" height="16" width="16">' % imgPath)
                optDevicesIcons_str = ' '.join(optDevicesIcons_arr)
                result[-1].append([optDevicesIcons_str, ''])

            # equipment icons, must be in the end
            if 'equipmentIcons' in params_list:
                equipmentIcons_arr = []
                for key in vehicle.eqs:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    equipmentIcons_arr.append('<img src="%s" height="16" width="16">' % imgPath)
                equipmentIcons_str = ' '.join(equipmentIcons_arr)
                if config.get('tooltips/combineIcons') and optDevicesIcons_str:
                    result[-1][-1][0] += ' ' + equipmentIcons_str
                else:
                    result[-1].append([equipmentIcons_str, ''])

        # crew roles icons, must be in the end
        if 'crewRolesIcons' in params_list:
            imgPath = 'img://../mods/shared_resources/xvm/res/icons/tooltips/roles'
            crewRolesIcons_arr = []
            for tankman_role in vehicle.descriptor.type.crewRoles:
                crewRolesIcons_arr.append('<img src="%s/%s.png" height="16" width="16">' % (imgPath, tankman_role[0]))
            crewRolesIcons_str = ''.join(crewRolesIcons_arr)
            result[-1].append([crewRolesIcons_str, ''])

        result.append([])
        if config.get('tooltips/hideBottomText'):
            pass
        else:
            if crew:
                currentCrewSize = 0
                if vehicle.isInInventory:
                    currentCrewSize = len([ x for _, x in vehicle.crew if x is not None ])
                result[-1].append({'label': 'crew',
                 'current': currentCrewSize,
                 'total': len(vehicle.descriptor.type.crewRoles)})
            if eqs:
                result[-1].append({'label': 'equipments',
                 'current': len([ x for x in vehicle.eqs if x ]),
                 'total': len(vehicle.eqs)})
            if devices:
                result[-1].append({'label': 'devices',
                 'current': len([ x for x in vehicle.descriptor.optionalDevices if x ]),
                 'total': len(vehicle.descriptor.optionalDevices)})

        if vehicle.intCD not in carousel_tooltips_cache:
            carousel_tooltips_cache[vehicle.intCD] = {}
        carousel_tooltips_cache[vehicle.intCD][context_name] = result
        return result
    except Exception as ex:
        err(traceback.format_exc())
        return base(self)
Ejemplo n.º 40
0
    def updateData(self):
        self.data['teamDmg'] = self.getTeamDmg(self.vehicleID)
        maxHealth = self.vehHealth[
            self.
            vehicleID]['maxHealth'] if self.vehicleID in self.vehHealth else 0
        self.data['dmgRatio'] = self.data[
            'damage'] * 100 // maxHealth if maxHealth != 0 else 0
        if self.vehicleID:
            attacked = self.player.arena.vehicles.get(self.vehicleID)
            if attacked is not None:
                vehicleType = attacked['vehicleType']
                self.data['name'] = attacked['name']
                self.data['clanAbbrev'] = attacked['clanAbbrev']
                if vehicleType:
                    _type = vehicleType.type
                    self.data['attackedVehicleType'] = list(
                        _type.tags.intersection(VEHICLE_CLASSES))[0]
                    self.data[
                        'attackerVehicleName'] = vehicleType.name.replace(
                            ':', '-', 1) if vehicleType.name else ''
                    self.data['shortUserString'] = _type.shortUserString
                    self.data['level'] = vehicleType.level
                    self.data['nation'] = nations.NAMES[
                        _type.customizationNationID]
                    self.data['diff-masses'] = (
                        self.player.vehicleTypeDescriptor.physics['weight'] -
                        vehicleType.physics['weight']
                    ) / 1000.0 if self.data['attackReasonID'] == 2 else None
                else:
                    self.resetDataVehInfo()
                if (_stat.resp is not None) and (attacked['name']
                                                 in _stat.resp['players']):
                    stats = _stat.resp['players'][attacked['name']]
                    self.data['wn8'] = stats.get('wn8', None)
                    self.data['xwn8'] = stats.get('xwn8', None)
                    self.data['wtr'] = stats.get('wtr', None)
                    self.data['xwtr'] = stats.get('xwtr', None)
                    self.data['eff'] = stats.get('e', None)
                    self.data['xeff'] = stats.get('xeff', None)
                    self.data['wgr'] = stats.get('wgr', None)
                    self.data['xwgr'] = stats.get('xwgr', None)
                    self.data['xte'] = stats.get('v').get('xte', None)
                else:
                    self.resetDataStats()
            elif not self.isVehicle:
                self.resetDataStats()
                self.resetDataVehInfo()
                self.data['shortUserString'] = l10n(PILLBOX).format(
                    self.entityNumber)
                self.data['name'] = ''
                self.data['clanAbbrev'] = ''
                self.data['clanicon'] = None
                self.data['squadnum'] = None
                self.data['compName'] = None
                self.data['criticalHit'] = None
            else:
                self.data['name'] = ''
                self.data['clanAbbrev'] = ''
                self.resetDataStats()
                self.resetDataVehInfo()
            self.data['clanicon'] = _stat.getClanIcon(self.vehicleID)

            arenaDP = self.guiSessionProvider.getArenaDP()
            if arenaDP is not None:
                vInfo = arenaDP.getVehicleInfo(vID=self.vehicleID)
                self.data[
                    'squadnum'] = vInfo.squadIndex if vInfo.squadIndex != 0 else None
            else:
                self.data['squadnum'] = None
        else:
            self.resetDataVehInfo()
            self.resetDataStats()
            self.data['name'] = ''
            self.data['clanAbbrev'] = ''
            self.data['clanicon'] = None
            self.data['squadnum'] = None
        self.updateLabels()
Ejemplo n.º 41
0
def CommonStatsBlockConstructor_construct(base, self):
    try:
        self.leftPadding = -15
        vehicle = self.vehicle
        cache_result = carousel_tooltips_cache.get(vehicle.intCD)
        if cache_result:
            return cache_result
        result = []
        if not config.get('tooltips/hideSimplifiedVehParams'):
            result.append(formatters.packTitleDescBlock(text_styles.middleTitle(i18n.makeString(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)), padding=formatters.packPadding(left=0, right=self.rightPadding, bottom=8)))
        params = self.configuration.params
        veh_descr = vehicle.descriptor
        gun = vehicle.gun.descriptor
        turret = vehicle.turret.descriptor
        comparator = idealCrewComparator_helper(vehicle)
        vehicleCommonParams = getParameters_helper(vehicle)
        veh_type_inconfig = vehicle.type.replace('AT-SPG', 'TD')
        clipGunInfoShown = False
        premium_shells = {}

        for shell in vehicle.shells:
            premium_shells[shell.intCompactDescr] = shell.isPremium
        if params:
            values = config.get('tooltips/%s' % veh_type_inconfig)
            if values and len(values):
                params_list = values # overriding parameters
            else:
                params_list = self.PARAMS.get(vehicle.type, 'default') # original parameters
            paramInfo = None
            for paramName in params_list:
                if paramName is None:
                    continue
                if paramName == 'rateOfFire':
                    paramName = 'reloadTime'
                elif paramName == 'traverseLimits':
                    paramName = 'gunYawLimits' if 'gunYawLimits' in vehicleCommonParams else 'turretYawLimits'
                elif paramName == 'radioRange':
                    paramName = 'radioDistance'
                elif paramName == 'reloadTimeSecs' and vehicle.gun.isClipGun():
                    paramName = 'clipFireRate'
                elif paramName == 'turretRotationSpeed' and not vehicle.hasTurrets:
                    paramName = 'gunRotationSpeed'
                if paramName in vehicleCommonParams:
                    paramInfo = comparator.getExtendedData(paramName)
                if paramName == 'turretArmor' and not vehicle.hasTurrets:
                    continue
                #maxHealth
                elif paramName == 'maxHealth':
                    tooltip_add_param(self, result, i18n.makeString('#menu:vehicleInfo/params/maxHealth'), formatNumber(veh_descr.maxHealth))
                #battle tiers
                elif paramName == 'battleTiers':
                    (minTier, maxTier) = getTiers(vehicle.level, vehicle.type, vehicle.name)
                    tooltip_add_param(self, result, l10n('Battle tiers'), '%s..%s' % (minTier, maxTier))
                #explosionRadius
                elif paramName == 'explosionRadius':
                    explosionRadiusMin = 999
                    explosionRadiusMax = 0
                    for shot in gun['shots']:
                        if 'explosionRadius' in shot['shell']:
                            if shot['shell']['explosionRadius'] < explosionRadiusMin:
                                explosionRadiusMin = shot['shell']['explosionRadius']
                            if shot['shell']['explosionRadius'] > explosionRadiusMax:
                                explosionRadiusMax = shot['shell']['explosionRadius']
                    if explosionRadiusMax == 0: # no HE
                        continue
                    explosionRadius_str = formatNumber(explosionRadiusMin)
                    if explosionRadiusMin != explosionRadiusMax:
                        explosionRadius_str += '/%s' % gold_pad(formatNumber(explosionRadiusMax))
                    tooltip_add_param(self, result, getParameterValue(paramName), explosionRadius_str)
                #shellSpeedSummary
                elif paramName == 'shellSpeedSummary':
                    shellSpeedSummary_arr = []
                    for shot in gun['shots']:
                        shellSpeed_str = '%g' % round(shot['speed'] * 1.25)
                        if premium_shells[shot['shell']['compactDescr']]:
                            shellSpeed_str = gold_pad(shellSpeed_str)
                        shellSpeedSummary_arr.append(shellSpeed_str)
                    shellSpeedSummary_str = '/'.join(shellSpeedSummary_arr)
                    tooltip_add_param(self, result, tooltip_with_units(l10n('shellSpeed'), l10n('(m/sec)')), shellSpeedSummary_str)
                #piercingPowerAvg
                elif paramName == 'piercingPowerAvg':
                    piercingPowerAvg = formatNumber(veh_descr.shot['piercingPower'][0])
                    tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/avgPiercingPower')), piercingPowerAvg)
                #piercingPowerAvgSummary
                elif paramName == 'piercingPowerAvgSummary':
                    piercingPowerAvgSummary_arr = []
                    for shot in gun['shots']:
                        piercingPower_str = formatNumber(shot['piercingPower'][0])
                        if premium_shells[shot['shell']['compactDescr']]:
                            piercingPower_str = gold_pad(piercingPower_str)
                        piercingPowerAvgSummary_arr.append(piercingPower_str)
                    piercingPowerAvgSummary_str = '/'.join(piercingPowerAvgSummary_arr)
                    tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/avgPiercingPower')), piercingPowerAvgSummary_str)
                #damageAvgSummary
                elif paramName == 'damageAvgSummary':
                    damageAvgSummary_arr = []
                    for shot in gun['shots']:
                        damageAvg_str = formatNumber(shot['shell']['damage'][0])
                        if premium_shells[shot['shell']['compactDescr']]:
                            damageAvg_str = gold_pad(damageAvg_str)
                        damageAvgSummary_arr.append(damageAvg_str)
                    damageAvgSummary_str = '/'.join(damageAvgSummary_arr)
                    tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/avgDamage')), damageAvgSummary_str)
                #magazine loading
                # elif (paramName == 'reloadTimeSecs' or paramName == 'rateOfFire') and vehicle.gun.isClipGun():
                #     if clipGunInfoShown:
                #         continue
                #     (shellsCount, shellReloadingTime) = gun['clip']
                #     reloadMagazineTime = gun['reloadTime']
                #     shellReloadingTime_str = formatNumber(shellReloadingTime)
                #     reloadMagazineTime_str = formatNumber(reloadMagazineTime)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/shellsCount')), shellsCount)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/shellReloadingTime')), shellReloadingTime_str)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/reloadMagazineTime')), reloadMagazineTime_str)
                #     clipGunInfoShown = True
                #rate of fire
                # elif paramName == 'rateOfFire' and not vehicle.gun.isClipGun():
                #     rateOfFire_str = formatNumber(60 / gun['reloadTime'])
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/reloadTime')), rateOfFire_str)
                # gun traverse limits
                # elif paramName == 'traverseLimits' and gun['turretYawLimits']:
                #     (traverseMin, traverseMax) = gun['turretYawLimits']
                #     traverseLimits_str = '%g..+%g' % (round(degrees(traverseMin)), round(degrees(traverseMax)))
                #     tooltip_add_param(self, result, l10n('traverseLimits'), traverseLimits_str)
                # elevation limits (front)
                # elif paramName == 'pitchLimits':
                #     (pitchMax, pitchMin) = calcPitchLimitsFromDesc(0, gun['pitchLimits'])
                #     pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                #     tooltip_add_param(self, result, l10n('pitchLimits'), pitchLimits_str)
                # elevation limits (side)
                elif paramName == 'pitchLimitsSide':
                    if gun['turretYawLimits'] and abs(degrees(gun['turretYawLimits'][0])) < 89: continue # can't look aside 90 degrees
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(pi / 2, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    tooltip_add_param(self, result, l10n('pitchLimitsSide'), pitchLimits_str)
                # elevation limits (rear)
                elif paramName == 'pitchLimitsRear':
                    if gun['turretYawLimits']: continue # can't look back
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(pi, gun['pitchLimits'])
                    pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                    tooltip_add_param(self, result, l10n('pitchLimitsRear'), pitchLimits_str)
                # shooting range
                elif paramName == 'shootingRadius':
                    viewRange, shellRadius, artiRadius = _getRanges(turret, gun, vehicle.nationName, vehicle.type)
                    if vehicle.type == 'SPG':
                        tooltip_add_param(self, result, tooltip_with_units(l10n('shootingRadius'), l10n('(m)')), artiRadius)
                    elif shellRadius < 707:
                        tooltip_add_param(self, result, tooltip_with_units(l10n('shootingRadius'), l10n('(m)')), shellRadius)
                #reverse max speed
                elif paramName == 'speedLimits':
                    (speedLimitForward, speedLimitReverse) = veh_descr.physics['speedLimits']
                    speedLimits_str = str(int(speedLimitForward * 3.6)) + '/' + str(int(speedLimitReverse * 3.6))
                    tooltip_add_param(self, result, getParameterValue(paramName), speedLimits_str)
                #turret rotation speed
                # elif paramName == 'turretRotationSpeed' or paramName == 'gunRotationSpeed':
                #     if not vehicle.hasTurrets:
                #         paramName = 'gunRotationSpeed'
                #     turretRotationSpeed_str = str(int(degrees(veh_descr.turret['rotationSpeed'])))
                #     tooltip_add_param(self, result, tooltip_with_units(i18n.makeString('#menu:tank_params/%s' % paramName).rstrip(), i18n.makeString('#menu:tank_params/gps')), turretRotationSpeed_str)
                #terrain resistance
                elif paramName == 'terrainResistance':
                    resistances_arr = []
                    for key in veh_descr.chassis['terrainResistance']:
                        resistances_arr.append(formatNumber(key))
                    terrainResistance_str = '/'.join(resistances_arr)
                    tooltip_add_param(self, result, l10n('terrainResistance'), terrainResistance_str)
                #radioRange
                # elif paramName == 'radioRange':
                #     radioRange_str = '%s' % int(vehicle.radio.descriptor['distance'])
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/radioDistance')), radioRange_str)
                #gravity
                elif paramName == 'gravity':
                    gravity_str = formatNumber(veh_descr.shot['gravity'])
                    tooltip_add_param(self, result, l10n('gravity'), gravity_str)
                #inner name, for example - ussr:R100_SU122A
                elif paramName == 'innerName':
                    tooltip_add_param(self, result, vehicle.name, '')
                #custom text
                elif paramName.startswith('TEXT:'):
                    customtext = paramName[5:]
                    tooltip_add_param(self, result, l10n(customtext), '')
                elif paramInfo is not None and paramName in paramInfo.name:
                    valueStr = str(param_formatter.formatParameter(paramName, paramInfo.value))
                    tooltip_add_param(self, result, getParameterValue(paramName), valueStr)
        if vehicle.isInInventory:
            # optional devices icons, must be in the end
            if 'optDevicesIcons' in params_list:
                optDevicesIcons_arr = []
                for key in vehicle.optDevices:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    optDevicesIcons_arr.append('<img src="%s" height="16" width="16">' % imgPath)
                optDevicesIcons_str = ' '.join(optDevicesIcons_arr)
                tooltip_add_param(self, result, optDevicesIcons_str, '')

            # equipment icons, must be in the end
            if 'equipmentIcons' in params_list:
                equipmentIcons_arr = []
                for key in vehicle.eqs:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    equipmentIcons_arr.append('<img src="%s" height="16" width="16">' % imgPath)
                equipmentIcons_str = ' '.join(equipmentIcons_arr)
                if config.get('tooltips/combineIcons') and optDevicesIcons_str:
                    tmp_list = []
                    tooltip_add_param(self, tmp_list, equipmentIcons_str, '')
                    result[-1]['data']['name'] += ' ' + tmp_list[0]['data']['name']
                else:
                    tooltip_add_param(self, result, equipmentIcons_str, '')

        # crew roles icons, must be in the end
        if 'crewRolesIcons' in params_list:
            imgPath = 'img://../mods/shared_resources/xvm/res/icons/tooltips/roles'
            crewRolesIcons_arr = []
            for tankman_role in vehicle.descriptor.type.crewRoles:
                crewRolesIcons_arr.append('<img src="%s/%s.png" height="16" width="16">' % (imgPath, tankman_role[0]))
            crewRolesIcons_str = ''.join(crewRolesIcons_arr)
            tooltip_add_param(self, result, crewRolesIcons_str, '')
        if (len(result) > 30) and config.get('tooltips/hideBottomText'): # limitation
            result = result[:30]
        elif (len(result) > 29) and not config.get('tooltips/hideBottomText'): # limitation
            result = result[:29]
        carousel_tooltips_cache[vehicle.intCD] = result
        return result
    except Exception as ex:
        err(traceback.format_exc())
        return base(self)
Ejemplo n.º 42
0
def CommonStatsBlockConstructor_construct(base, self):
    try:
        self.leftPadding = -15
        vehicle = self.vehicle
        cache_result = carousel_tooltips_cache.get(vehicle.intCD)
        if cache_result:
            return cache_result
        result = []
        if not config.get('tooltips/hideSimplifiedVehParams'):
            result.append(
                formatters.packTitleDescBlock(text_styles.middleTitle(
                    i18n.makeString(TOOLTIPS.TANKCARUSEL_MAINPROPERTY)),
                                              padding=formatters.packPadding(
                                                  left=0,
                                                  right=self.rightPadding,
                                                  bottom=8)))
        params = self.configuration.params
        veh_descr = vehicle.descriptor
        gun = vehicle.gun.descriptor
        turret = vehicle.turret.descriptor
        comparator = idealCrewComparator_helper(vehicle)
        vehicleCommonParams = getParameters_helper(vehicle)
        veh_type_inconfig = vehicle.type.replace('AT-SPG', 'TD')
        clipGunInfoShown = False
        premium_shells = {}

        for shell in vehicle.shells:
            premium_shells[shell.intCompactDescr] = shell.isPremium
        if params:
            values = config.get('tooltips/%s' % veh_type_inconfig)
            if values and len(values):
                params_list = values  # overriding parameters
            else:
                params_list = self.PARAMS.get(vehicle.type,
                                              'default')  # original parameters
            paramInfo = None
            for paramName in params_list:
                if paramName is None:
                    continue
                if paramName == 'rateOfFire':
                    paramName = 'reloadTime'
                elif paramName == 'traverseLimits':
                    paramName = 'gunYawLimits' if 'gunYawLimits' in vehicleCommonParams else 'turretYawLimits'
                elif paramName == 'radioRange':
                    paramName = 'radioDistance'
                elif paramName == 'reloadTimeSecs' and (gun.clip[0] > 1):
                    paramName = 'clipFireRate'
                elif paramName == 'turretRotationSpeed' and not vehicle.hasTurrets:
                    paramName = 'gunRotationSpeed'
                if paramName in vehicleCommonParams:
                    paramInfo = comparator.getExtendedData(paramName)
                if paramName == 'turretArmor' and not vehicle.hasTurrets:
                    continue
                #maxHealth
                elif paramName == 'maxHealth':
                    tooltip_add_param(
                        self, result,
                        i18n.makeString('#menu:vehicleInfo/params/maxHealth'),
                        formatNumber(veh_descr.maxHealth))
                #battle tiers
                elif paramName == 'battleTiers':
                    (minTier, maxTier) = getTiers(vehicle.level, vehicle.type,
                                                  vehicle.name)
                    tooltip_add_param(self, result, l10n('Battle tiers'),
                                      '%s..%s' % (minTier, maxTier))
                #explosionRadius
                elif paramName == 'explosionRadius':
                    explosionRadiusMin = 999
                    explosionRadiusMax = 0
                    for shot in gun.shots:
                        if shot.shell.kind == SHELL_TYPES.HIGH_EXPLOSIVE:
                            explosionRadius = shot.shell.type.explosionRadius
                            if explosionRadius < explosionRadiusMin:
                                explosionRadiusMin = explosionRadius
                            if explosionRadius > explosionRadiusMax:
                                explosionRadiusMax = explosionRadius
                    if explosionRadiusMax == 0:  # no HE
                        continue
                    explosionRadius_str = formatNumber(explosionRadiusMin)
                    if explosionRadiusMin != explosionRadiusMax:
                        explosionRadius_str += '/%s' % gold_pad(
                            formatNumber(explosionRadiusMax))
                    tooltip_add_param(self, result,
                                      getParameterValue(paramName),
                                      explosionRadius_str)
                #shellSpeedSummary
                elif paramName == 'shellSpeedSummary':
                    shellSpeedSummary_arr = []
                    for shot in gun.shots:
                        shellSpeed_str = '%g' % round(shot.speed * 1.25)
                        if premium_shells[shot.shell.compactDescr]:
                            shellSpeed_str = gold_pad(shellSpeed_str)
                        shellSpeedSummary_arr.append(shellSpeed_str)
                    shellSpeedSummary_str = '/'.join(shellSpeedSummary_arr)
                    tooltip_add_param(
                        self, result,
                        tooltip_with_units(l10n('shellSpeed'),
                                           l10n('(m/sec)')),
                        shellSpeedSummary_str)
                #piercingPowerAvg
                elif paramName == 'piercingPowerAvg':
                    piercingPowerAvg = formatNumber(
                        veh_descr.shot.piercingPower[0])
                    tooltip_add_param(
                        self, result,
                        replace_p(
                            i18n.makeString(
                                '#menu:moduleInfo/params/avgPiercingPower')),
                        piercingPowerAvg)
                #piercingPowerAvgSummary
                elif paramName == 'piercingPowerAvgSummary':
                    piercingPowerAvgSummary_arr = []
                    for shot in gun.shots:
                        piercingPower_str = formatNumber(shot.piercingPower[0])
                        if premium_shells[shot.shell.compactDescr]:
                            piercingPower_str = gold_pad(piercingPower_str)
                        piercingPowerAvgSummary_arr.append(piercingPower_str)
                    piercingPowerAvgSummary_str = '/'.join(
                        piercingPowerAvgSummary_arr)
                    tooltip_add_param(
                        self, result,
                        replace_p(
                            i18n.makeString(
                                '#menu:moduleInfo/params/avgPiercingPower')),
                        piercingPowerAvgSummary_str)
                #damageAvgSummary
                elif paramName == 'damageAvgSummary':
                    damageAvgSummary_arr = []
                    for shot in gun.shots:
                        damageAvg_str = formatNumber(shot.shell.damage[0])
                        if premium_shells[shot.shell.compactDescr]:
                            damageAvg_str = gold_pad(damageAvg_str)
                        damageAvgSummary_arr.append(damageAvg_str)
                    damageAvgSummary_str = '/'.join(damageAvgSummary_arr)
                    tooltip_add_param(
                        self, result,
                        replace_p(
                            i18n.makeString(
                                '#menu:moduleInfo/params/avgDamage')),
                        damageAvgSummary_str)
                #magazine loading
                # elif (paramName == 'reloadTimeSecs' or paramName == 'rateOfFire') and vehicle.gun.isClipGun():
                #     if clipGunInfoShown:
                #         continue
                #     (shellsCount, shellReloadingTime) = gun.clip
                #     reloadMagazineTime = gun.reloadTime
                #     shellReloadingTime_str = formatNumber(shellReloadingTime)
                #     reloadMagazineTime_str = formatNumber(reloadMagazineTime)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/shellsCount')), shellsCount)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/shellReloadingTime')), shellReloadingTime_str)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/reloadMagazineTime')), reloadMagazineTime_str)
                #     clipGunInfoShown = True
                #rate of fire
                # elif paramName == 'rateOfFire' and not vehicle.gun.isClipGun():
                #     rateOfFire_str = formatNumber(60 / gun.reloadTime)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/reloadTime')), rateOfFire_str)
                # gun traverse limits
                # elif paramName == 'traverseLimits' and gun.turretYawLimits:
                #     (traverseMin, traverseMax) = gun.turretYawLimits
                #     traverseLimits_str = '%g..+%g' % (round(degrees(traverseMin)), round(degrees(traverseMax)))
                #     tooltip_add_param(self, result, l10n('traverseLimits'), traverseLimits_str)
                # elevation limits (front)
                # elif paramName == 'pitchLimits':
                #     (pitchMax, pitchMin) = calcPitchLimitsFromDesc(0, gun.pitchLimits)
                #     pitchLimits_str = '%g..+%g' % (round(degrees(-pitchMin)), round(degrees(-pitchMax)))
                #     tooltip_add_param(self, result, l10n('pitchLimits'), pitchLimits_str)
                # elevation limits (side)
                elif paramName == 'pitchLimitsSide':
                    if gun.turretYawLimits and abs(
                            degrees(gun.turretYawLimits[0])) < 89:
                        continue  # can't look aside 90 degrees
                    (pitchMax, pitchMin) = calcPitchLimitsFromDesc(
                        pi / 2, gun.pitchLimits)
                    pitchLimits_str = '%g..+%g' % (round(
                        degrees(-pitchMin)), round(degrees(-pitchMax)))
                    tooltip_add_param(self, result, l10n('pitchLimitsSide'),
                                      pitchLimits_str)
                # elevation limits (rear)
                elif paramName == 'pitchLimitsRear':
                    if gun.turretYawLimits: continue  # can't look back
                    (pitchMax,
                     pitchMin) = calcPitchLimitsFromDesc(pi, gun.pitchLimits)
                    pitchLimits_str = '%g..+%g' % (round(
                        degrees(-pitchMin)), round(degrees(-pitchMax)))
                    tooltip_add_param(self, result, l10n('pitchLimitsRear'),
                                      pitchLimits_str)
                # shooting range
                elif paramName == 'shootingRadius':
                    viewRange, shellRadius, artiRadius = _getRanges(
                        turret, gun, vehicle.nationName, vehicle.type)
                    if vehicle.type == 'SPG':
                        tooltip_add_param(
                            self, result,
                            tooltip_with_units(l10n('shootingRadius'),
                                               l10n('(m)')), artiRadius)
                    elif shellRadius < 707:
                        tooltip_add_param(
                            self, result,
                            tooltip_with_units(l10n('shootingRadius'),
                                               l10n('(m)')), shellRadius)
                #reverse max speed
                elif paramName == 'speedLimits':
                    (speedLimitForward,
                     speedLimitReverse) = veh_descr.physics['speedLimits']
                    speedLimits_str = str(int(
                        speedLimitForward * 3.6)) + '/' + str(
                            int(speedLimitReverse * 3.6))
                    tooltip_add_param(self, result,
                                      getParameterValue(paramName),
                                      speedLimits_str)
                #turret rotation speed
                # elif paramName == 'turretRotationSpeed' or paramName == 'gunRotationSpeed':
                #     if not vehicle.hasTurrets:
                #         paramName = 'gunRotationSpeed'
                #     turretRotationSpeed_str = str(int(degrees(veh_descr.turret.rotationSpeed)))
                #     tooltip_add_param(self, result, tooltip_with_units(i18n.makeString('#menu:tank_params/%s' % paramName).rstrip(), i18n.makeString('#menu:tank_params/gps')), turretRotationSpeed_str)
                #terrain resistance
                elif paramName == 'terrainResistance':
                    resistances_arr = []
                    for key in veh_descr.chassis.terrainResistance:
                        resistances_arr.append(formatNumber(key))
                    terrainResistance_str = '/'.join(resistances_arr)
                    tooltip_add_param(self, result, l10n('terrainResistance'),
                                      terrainResistance_str)
                #radioRange
                # elif paramName == 'radioRange':
                #     radioRange_str = '%s' % int(vehicle.radio.descriptor.distance)
                #     tooltip_add_param(self, result, replace_p(i18n.makeString('#menu:moduleInfo/params/radioDistance')), radioRange_str)
                #gravity
                elif paramName == 'gravity':
                    gravity_str = formatNumber(veh_descr.shot.gravity)
                    tooltip_add_param(self, result, l10n('gravity'),
                                      gravity_str)
                #inner name, for example - ussr:R100_SU122A
                elif paramName == 'innerName':
                    tooltip_add_param(self, result, vehicle.name, '')
                #custom text
                elif paramName.startswith('TEXT:'):
                    customtext = paramName[5:]
                    tooltip_add_param(self, result, l10n(customtext), '')
                elif paramInfo is not None and paramName in paramInfo.name:
                    valueStr = str(
                        param_formatter.formatParameter(
                            paramName, paramInfo.value))
                    tooltip_add_param(self, result,
                                      getParameterValue(paramName), valueStr)
        if vehicle.isInInventory:
            # optional devices icons, must be in the end
            if 'optDevicesIcons' in params_list:
                optDevicesIcons_arr = []
                for key in vehicle.optDevices:
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    optDevicesIcons_arr.append(
                        '<img src="%s" height="16" width="16">' % imgPath)
                optDevicesIcons_str = ' '.join(optDevicesIcons_arr)
                tooltip_add_param(self, result, optDevicesIcons_str, '')

            # equipment icons, must be in the end
            if 'equipmentIcons' in params_list:
                equipmentIcons_arr = []
                for key in vehicle.equipment.regularConsumables.getInstalledItems(
                ):
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    equipmentIcons_arr.append(
                        '<img src="%s" height="16" width="16">' % imgPath)
                for key in vehicle.equipment.battleBoosterConsumables.getInstalledItems(
                ):
                    if key:
                        imgPath = 'img://gui' + key.icon.lstrip('.')
                    else:
                        imgPath = 'img://gui/maps/icons/artefact/empty.png'
                    equipmentIcons_arr.append(
                        '<img src="%s" height="16" width="16">' % imgPath)
                equipmentIcons_str = ' '.join(equipmentIcons_arr)
                if config.get('tooltips/combineIcons') and optDevicesIcons_str:
                    tmp_list = []
                    tooltip_add_param(self, tmp_list, equipmentIcons_str, '')
                    result[-1]['data'][
                        'name'] += ' ' + tmp_list[0]['data']['name']
                else:
                    tooltip_add_param(self, result, equipmentIcons_str, '')

        # crew roles icons, must be in the end
        if 'crewRolesIcons' in params_list:
            imgPath = 'img://../mods/shared_resources/xvm/res/icons/tooltips/roles'
            crewRolesIcons_arr = []
            for tankman_role in vehicle.descriptor.type.crewRoles:
                crewRolesIcons_arr.append(
                    '<img src="%s/%s.png" height="16" width="16">' %
                    (imgPath, tankman_role[0]))
            crewRolesIcons_str = ''.join(crewRolesIcons_arr)
            tooltip_add_param(self, result, crewRolesIcons_str, '')
        if (len(result) >
                30) and config.get('tooltips/hideBottomText'):  # limitation
            result = result[:30]
        elif (len(result) >
              29) and not config.get('tooltips/hideBottomText'):  # limitation
            result = result[:29]
        carousel_tooltips_cache[vehicle.intCD] = result
        return result
    except Exception as ex:
        err(traceback.format_exc())
        return base(self)
Ejemplo n.º 43
0
def _getL10n(text):
    if text.find('{{l10n:') > -1:
        return l10n(text)
    return text
Ejemplo n.º 44
0
def _i18n_makeString(base, key, *args, **kwargs):
    if key == MENU.TANKCAROUSEL_VEHICLESTATES_AMMONOTFULL: # originally returns empty string
        return l10n('lowAmmo')
    return base(key, *args, **kwargs)
Ejemplo n.º 45
0
def _TankCarouselFilterPopover_getInitialVO(base, self, filters, xpRateMultiplier):
    data = base(self, filters, xpRateMultiplier)
    if PREFS.NORMAL in filters:
        mapping = self._VehiclesFilterPopover__mapping
        #debug(data['specials'])
        #debug(mapping)
        try:
            premium = data['specials'][mapping[_SECTION.SPECIALS].index(PREFS.PREMIUM)]
            premium = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/premium.png', 'tooltip': makeTooltip(l10n('PremiumTooltipHeader'), l10n('PremiumTooltipBody'))}
            special = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/special.png', 'tooltip': makeTooltip(l10n('SpecialTooltipHeader'), l10n('SpecialTooltipBody')), 'selected': filters[PREFS.SPECIAL]}
            normal = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/normal.png', 'tooltip': makeTooltip(l10n('NormalTooltipHeader'), l10n('NormalTooltipBody')), 'selected': filters[PREFS.NORMAL]}
            elite = data['specials'][mapping[_SECTION.SPECIALS].index(PREFS.ELITE)]
            elite['value'] = '../../../mods/shared_resources/xvm/res/icons/carousel/filter/elite.png'
            non_elite = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/nonelite.png', 'tooltip': makeTooltip(l10n('NonEliteTooltipHeader'), l10n('NonEliteTooltipBody')), 'selected': filters[PREFS.NON_ELITE]}
            full_crew = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/fullcrew.png', 'tooltip': makeTooltip(l10n('CompleteCrewTooltipHeader'), l10n('CompleteCrewTooltipBody')), 'selected': filters[PREFS.FULL_CREW]}
            training_crew = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/trainingcrew.png', 'tooltip': makeTooltip(l10n('TrainingCrewTooltipHeader'), l10n('TrainingCrewTooltipBody')), 'selected': filters[PREFS.TRAINING_CREW]}
            no_master = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/nomaster.png', 'tooltip': makeTooltip(l10n('NoMasterTooltipHeader'), l10n('NoMasterTooltipBody')), 'selected': filters[PREFS.NO_MASTER]}
            reserve = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/reserve.png', 'tooltip': makeTooltip(l10n('ReserveFilterTooltipHeader'), l10n('ReserveFilterTooltipBody')), 'selected': filters[PREFS.RESERVE]}
            crystals = data['specials'][mapping[_SECTION.SPECIALS].index(PREFS.CRYSTALS)]
            crystals['value'] = '../../../mods/shared_resources/xvm/res/icons/carousel/filter/crystals.png'
            rented = data['specials'][mapping[_SECTION.SPECIALS].index(PREFS.RENTED)]
            rented['value'] = '../../../mods/shared_resources/xvm/res/icons/carousel/filter/rented.png'

            is_igr = PREFS.IGR in mapping[_SECTION.SPECIALS]
            if is_igr:
                igr = data['specials'][-1]
            data['specials'] = [
                premium, special, normal, elite, non_elite,
                full_crew, training_crew, no_master, reserve, crystals,
                rented]
            if is_igr:
                data['specials'].append(igr)
        except Exception as ex:
            err('_TankCarouselFilterPopover_getInitialVO() exception: ' + traceback.format_exc())
    return data
Ejemplo n.º 46
0
def shell_type(num):
    gs = _gunShots()
    ns = _numShell(num)
    return None if (not gs) or (len(gs) < num) else l10n(
        gs[ns].shell.kind.lower())
Ejemplo n.º 47
0
    def updateData(self):
        self.data['teamDmg'] = self.getTeamDmg(self.vehicleID)
        maxHealth = self.vehHealth[self.vehicleID]['maxHealth'] if self.vehicleID in self.vehHealth else 0
        self.data['dmgRatio'] = self.data['damage'] * 100 // maxHealth if maxHealth != 0 else 0
        if self.vehicleID:
            attacked = self.player.arena.vehicles.get(self.vehicleID)
            if attacked is not None:
                vehicleType = attacked['vehicleType']
                self.data['name'] = attacked['name']
                self.data['clanAbbrev'] = attacked['clanAbbrev']
                if vehicleType:
                    _type = vehicleType.type
                    self.data['attackedVehicleType'] = list(_type.tags.intersection(VEHICLE_CLASSES))[0]
                    self.data['attackerVehicleName'] = vehicleType.name.replace(':', '-', 1) if vehicleType.name else ''
                    self.data['shortUserString'] = _type.shortUserString
                    self.data['level'] = vehicleType.level
                    self.data['nation'] = nations.NAMES[_type.customizationNationID]
                    self.data['diff-masses'] = (self.player.vehicleTypeDescriptor.physics['weight'] - vehicleType.physics['weight']) / 1000.0 if self.data['attackReasonID'] == 2 else None
                else:
                    self.resetDataVehInfo()
                if (_stat.resp is not None) and (attacked['name'] in _stat.resp['players']):
                    stats = _stat.resp['players'][attacked['name']]
                    self.data['wn8'] = stats.get('wn8', None)
                    self.data['xwn8'] = stats.get('xwn8', None)
                    self.data['wtr'] = stats.get('wtr', None)
                    self.data['xwtr'] = stats.get('xwtr', None)
                    self.data['eff'] = stats.get('e', None)
                    self.data['xeff'] = stats.get('xeff', None)
                    self.data['wgr'] = stats.get('wgr', None)
                    self.data['xwgr'] = stats.get('xwgr', None)
                    self.data['xte'] = stats.get('v').get('xte', None)
                else:
                    self.resetDataStats()
            elif not self.isVehicle:
                self.resetDataStats()
                self.resetDataVehInfo()
                self.data['shortUserString'] = l10n(PILLBOX).format(self.entityNumber)
                self.data['name'] = ''
                self.data['clanAbbrev'] = ''
                self.data['clanicon'] = None
                self.data['squadnum'] = None
                self.data['compName'] = None
                self.data['criticalHit'] = None
            else:
                self.data['name'] = ''
                self.data['clanAbbrev'] = ''
                self.resetDataStats()
                self.resetDataVehInfo()
            self.data['clanicon'] = _stat.getClanIcon(self.vehicleID)

            arenaDP = self.guiSessionProvider.getArenaDP()
            if arenaDP is not None:
                vInfo = arenaDP.getVehicleInfo(vID=self.vehicleID)
                self.data['squadnum'] = vInfo.squadIndex if vInfo.squadIndex != 0 else None
            else:
                self.data['squadnum'] = None
        else:
            self.resetDataVehInfo()
            self.resetDataStats()
            self.data['name'] = ''
            self.data['clanAbbrev'] = ''
            self.data['clanicon'] = None
            self.data['squadnum'] = None
        self.updateLabels()
Ejemplo n.º 48
0
def _i18n_makeString(base, key, *args, **kwargs):
    if key == MENU.TANKCAROUSEL_VEHICLESTATES_AMMONOTFULL:  # originally returns empty string
        return l10n('lowAmmo')
    return base(key, *args, **kwargs)
Ejemplo n.º 49
0
def PlayerContactsCMHandler_generateOptions(base, self, ctx = None):
    #log('PlayerContactsCMHandler_generateOptions')
    options = base(self, ctx)
    options.append(self._makeItem(MENU.XVM_EDIT_CONTACT_DATA, l10n('Edit data'), optInitData={'enabled': contacts.isAvailable()}))
    return options
Ejemplo n.º 50
0
def i18n_makeString(base, key, *args, **kwargs):
    if key == '#menu:tankCarousel/vehicleStates/ammoNotFull':  # originally returns empty string
        return l10n('lowAmmo')
    return base(key, *args, **kwargs)
Ejemplo n.º 51
0
def _TankCarouselFilterPopover_getInitialVO(base, self, filters, xpRateMultiplier):
    data = base(self, filters, xpRateMultiplier)
    mapping = self._VehiclesFilterPopover__mapping
    #debug(data['specials'])
    #debug(mapping)
    try:
        premium = data['specials'][mapping[_SECTION.SPECIALS].index(PREFS.PREMIUM)]
        premium['value'] = '../../../mods/shared_resources/xvm/res/icons/carousel/filter/premium.png'
        normal = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/normal.png', 'tooltip': makeTooltip(l10n('NormalTooltipHeader'), l10n('NormalTooltipBody')), 'selected': filters[PREFS.NORMAL]}
        elite = data['specials'][mapping[_SECTION.SPECIALS].index(PREFS.ELITE)]
        elite['value'] = '../../../mods/shared_resources/xvm/res/icons/carousel/filter/elite.png'
        non_elite = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/nonelite.png', 'tooltip': makeTooltip(l10n('NonEliteTooltipHeader'), l10n('NonEliteTooltipBody')), 'selected': filters[PREFS.NON_ELITE]}
        complete_crew = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/fullcrew.png', 'tooltip': makeTooltip(l10n('CompleteCrewTooltipHeader'), l10n('CompleteCrewTooltipBody')), 'selected': filters[PREFS.FULL_CREW]}
        no_master = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/nomaster.png', 'tooltip': makeTooltip(l10n('NoMasterTooltipHeader'), l10n('NoMasterTooltipBody')), 'selected': filters[PREFS.NO_MASTER]}
        reserve = {'value': '../../../mods/shared_resources/xvm/res/icons/carousel/filter/reserve.png', 'tooltip': makeTooltip(l10n('ReserveFilterTooltipHeader'), l10n('ReserveFilterTooltipBody')), 'selected': filters[PREFS.RESERVE]}

        is_igr = PREFS.IGR in mapping[_SECTION.SPECIALS]
        if is_igr:
            igr = data['specials'][-1]
        data['specials'] = [
            premium, normal, elite, non_elite, complete_crew,
            no_master, reserve]
        if is_igr:
            data['specials'].append(igr)
    except Exception as ex:
        err('_TankCarouselFilterPopover_getInitialVO() exception: ' + traceback.format_exc())
    return data