NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

overviewUtil.py (6267B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\overview\overviewUtil.py
      2 import collections
      3 import localization
      4 from carbon.common.script.util.commonutils import StripTags
      5 from carbonui import fontconst
      6 from carbonui.control.comboEntryData import ComboEntryDataCaption, ComboEntryData
      7 from eve.client.script.parklife.overview.default.categories import CATEGORY_NAME_LABELS, CATEGORY_ORDER
      8 from eve.client.script.ui.control.eveLabel import Label
      9 from eve.client.script.ui.inflight.overview import overviewColumns
     10 from eve.client.script.ui.inflight.overview.overviewConst import COLUMN_VELOCITY, COLUMN_ANGULARVELOCITY, COLUMN_TRANSVERSALVELOCITY, COLUMN_RADIALVELOCITY, ALLCOLUMNS
     11 from localization import GetByLabel
     12 from overviewPresets import overviewSettingsConst as osConst
     13 
     14 def IsFleetMember(slimItem):
     15     if not session.fleetid or not slimItem or not slimItem.ownerID:
     16         return False
     17     return sm.GetService('fleet').IsMember(slimItem.ownerID)
     18 
     19 
     20 def GetSortValueWhenBroadcastGoToTop(_node, fleetBroadcasts, currentDirection):
     21     if _node.itemID in fleetBroadcasts:
     22         toTopValue = 1
     23     else:
     24         toTopValue = 2
     25     if not currentDirection:
     26         toTopValue *= -1
     27     return (toTopValue, _node.sortValue)
     28 
     29 
     30 def GetAllianceTickerName(slimItem):
     31     return '[' + cfg.allianceshortnames.Get(slimItem.allianceID).shortName + ']'
     32 
     33 
     34 def GetCorpTickerName(slimItem):
     35     return '[' + cfg.corptickernames.Get(slimItem.corpID).tickerName + ']'
     36 
     37 
     38 def PrepareLocalizationTooltip(text):
     39     localizedTags = Label.ExtractLocalizedTags(text)
     40     if localizedTags:
     41         hint = localizedTags[0].get('hint', None)
     42         text = StripTags(text)
     43     else:
     44         hint = None
     45     return (text, hint)
     46 
     47 
     48 def GetSlimItemForCharID(charID):
     49     ballpark = sm.GetService('michelle').GetBallpark()
     50     if ballpark:
     51         for rec in ballpark.slimItems.itervalues():
     52             if rec.charID == charID:
     53                 return rec
     54 
     55 
     56 def GetEntryFontSize():
     57     useSmallText = sm.GetService('overviewPresetSvc').GetSettingValueOrDefaultFromName(osConst.SETTING_NAME_SMALL_TEXT, False)
     58     if useSmallText:
     59         fontSize = fontconst.EVE_SMALL_FONTSIZE
     60     else:
     61         fontSize = fontconst.EVE_MEDIUM_FONTSIZE
     62     return fontSize
     63 
     64 
     65 def GetEntryHeight(isCompact):
     66     useSmallText = sm.GetService('overviewPresetSvc').GetSettingValueOrDefaultFromName(osConst.SETTING_NAME_SMALL_TEXT, False)
     67     if useSmallText:
     68         return 17
     69     elif not isCompact:
     70         return 24
     71     else:
     72         return 19
     73 
     74 
     75 def GetColumnValuesToCalculate(columns):
     76     calculateRadialVelocity = False
     77     calculateCombinedVelocity = False
     78     calculateRadialNormal = False
     79     calculateTransveralVelocity = False
     80     calculateAngularVelocity = False
     81     calculateVelocity = False
     82     showVelocityCombined = False
     83     if COLUMN_VELOCITY in columns:
     84         calculateVelocity = True
     85         showVelocityCombined = True
     86     if COLUMN_ANGULARVELOCITY in columns:
     87         calculateRadialVelocity = True
     88         calculateCombinedVelocity = True
     89         calculateRadialNormal = True
     90         calculateTransveralVelocity = True
     91         calculateAngularVelocity = True
     92         showVelocityCombined = True
     93     if COLUMN_TRANSVERSALVELOCITY in columns:
     94         calculateRadialVelocity = True
     95         calculateCombinedVelocity = True
     96         calculateRadialNormal = True
     97         calculateTransveralVelocity = True
     98         showVelocityCombined = True
     99     if COLUMN_RADIALVELOCITY in columns:
    100         calculateRadialVelocity = True
    101         calculateCombinedVelocity = True
    102         calculateRadialNormal = True
    103         showVelocityCombined = True
    104     return (calculateAngularVelocity,
    105      calculateCombinedVelocity,
    106      calculateRadialNormal,
    107      calculateRadialVelocity,
    108      calculateTransveralVelocity,
    109      calculateVelocity,
    110      showVelocityCombined)
    111 
    112 
    113 def GetColumnSettingsAndSortKeys(currentActive = None, tabID = None):
    114     columns = overviewColumns.GetColumns(tabID)
    115     if currentActive:
    116         sortKeys = columns[columns.index(currentActive):]
    117     else:
    118         sortKeys = []
    119     columnSettings = {}
    120     for columnID in ALLCOLUMNS:
    121         if columnID in columns:
    122             if columnID in sortKeys:
    123                 columnSettings[columnID] = (True, sortKeys.index(columnID))
    124             else:
    125                 columnSettings[columnID] = (True, None)
    126         else:
    127             columnSettings[columnID] = (False, None)
    128 
    129     return (columnSettings, sortKeys)
    130 
    131 
    132 def GetFilterComboOptions():
    133     ret = []
    134     customFilters = GetCustomFiltersSorted()
    135     if customFilters:
    136         ret += [ComboEntryDataCaption(GetByLabel('UI/Overview/CustomFilters'))] + GetComboEntries(customFilters)
    137     ret += [ComboEntryDataCaption(GetByLabel('UI/Overview/DefaultFilters'))] + GetComboEntries(GetDefaultFiltersSorted())
    138     return ret
    139 
    140 
    141 def GetComboEntries(presetNames):
    142     presetSvc = sm.GetService('overviewPresetSvc')
    143     return [ ComboEntryData(presetSvc.GetPresetDisplayName(presetName), presetName, hint=presetSvc.GetDefaultOverviewDescription(presetName)) for presetName in presetNames ]
    144 
    145 
    146 def GetCustomFiltersSorted():
    147     presetSvc = sm.GetService('overviewPresetSvc')
    148     return GetFiltersSorted(presetSvc.GetCustomPresetNames())
    149 
    150 
    151 def GetFiltersSorted(preset_names):
    152     presetSvc = sm.GetService('overviewPresetSvc')
    153     return localization.util.Sort(preset_names, key=lambda p: presetSvc.GetPresetDisplayName(p))
    154 
    155 
    156 def GetDefaultFiltersSorted():
    157     ret = []
    158     for preset_names in GetDefaultFiltersByCategory().values():
    159         ret.extend(preset_names)
    160 
    161     return ret
    162 
    163 
    164 def GetDefaultFiltersByCategory():
    165     presetSvc = sm.GetService('overviewPresetSvc')
    166     ret = collections.defaultdict(list)
    167     for preset_name in presetSvc.GetDefaultOverviewPresetNames():
    168         category_id = presetSvc.GetDefaultOverviewCategoryID(preset_name)
    169         ret[category_id].append(preset_name)
    170 
    171     return _GetFiltersByCategorySorted(ret)
    172 
    173 
    174 def _GetFiltersByCategorySorted(preset_names_by_category_id):
    175     ret = collections.OrderedDict()
    176     for category_id in CATEGORY_ORDER:
    177         if category_id in preset_names_by_category_id:
    178             ret[category_id] = GetFiltersSorted(preset_names_by_category_id[category_id])
    179 
    180     return ret