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

panelGateIcons.py (8493B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\info\panels\panelGateIcons.py
      2 import itertoolsext
      3 from carbonui.primitives.container import Container
      4 from carbonui.primitives.sprite import Sprite
      5 from eve.client.script.ui.control.entries.mouse_inside_scroll_entry import MouseInsideScrollEntry
      6 from eve.client.script.ui.control.entries.util import GetFromClass
      7 from eve.client.script.ui.control.eveIcon import GetLogoIcon
      8 from eve.client.script.ui.control.eveLabel import EveLabelMedium
      9 from eve.client.script.ui.control.eveScroll import Scroll
     10 from eve.common.lib import appConst as const
     11 import evegraphics.gateLogoConst as gateLogoConst
     12 from eveservices.menu import GetMenuService
     13 from eveuniverse.security import securityClassHighSec, securityClassLowSec, securityClassZeroSec, SecurityClassFromLevel, securityClassSafeSec
     14 from localization import GetByLabel
     15 import carbonui.const as uiconst
     16 
     17 def is_hazardous_security_transition(sourceSecurity, destinationSecurity):
     18     currentSecurityClass = SecurityClassFromLevel(sourceSecurity)
     19     destSecurityClass = SecurityClassFromLevel(destinationSecurity)
     20     return (currentSecurityClass, destSecurityClass) in HAZARDOUS_SECURITY_TRANSITIONS
     21 
     22 
     23 def is_there_any_warning(destinationSecurity, destinationSystemStatusIcons):
     24     sourceSecurity = cfg.mapSystemCache[session.solarsystemid2].pseudoSecurity
     25     isHazardousSecurityTransition = is_hazardous_security_transition(sourceSecurity, destinationSecurity)
     26     return isHazardousSecurityTransition or itertoolsext.any(destinationSystemStatusIcons, lambda x: x in gateLogoConst.HAZARDOUS_STATUS_ICONS)
     27 
     28 
     29 class PanelGateIcons(Container):
     30 
     31     def ApplyAttributes(self, attributes):
     32         Container.ApplyAttributes(self, attributes)
     33         self.gateIconData = attributes.gateIconData
     34 
     35     def Load(self):
     36         self.Flush()
     37         entries = self.GetOwnerEntries()
     38         self.scroll = Scroll(parent=self, padding=const.defaultPadding)
     39         self.scroll.Load(contentList=entries)
     40 
     41     def GetOwnerEntries(self):
     42         entries = []
     43         sourceSecurity = cfg.mapSystemCache[session.solarsystemid2].pseudoSecurity
     44         destinationSecurity = cfg.mapSystemCache[self.gateIconData.destinationSolarSystemID].pseudoSecurity
     45         isHazardousSecurityTransition = is_hazardous_security_transition(sourceSecurity, destinationSecurity)
     46         isThereAnyWarning = is_there_any_warning(destinationSecurity, self.gateIconData.destinationSystemStatusIcons)
     47         originSystemOwnerID = self.gateIconData.originSystemOwnerID
     48         if originSystemOwnerID:
     49             ownerInfo = cfg.eveowners.Get(originSystemOwnerID)
     50             text = GetByLabel('UI/GateIcons/CurrentSystemOwner', ownerName=ownerInfo.name)
     51             entry = GetFromClass(GateOwnerEntry, {'ownerID': originSystemOwnerID,
     52              'text': text,
     53              'ownerTypeID': ownerInfo.typeID,
     54              'isThereAnyWarning': isThereAnyWarning})
     55             entries.append(entry)
     56         destSystemOwnerID = self.gateIconData.destinationSystemOwnerID
     57         if destSystemOwnerID:
     58             ownerInfo = cfg.eveowners.Get(destSystemOwnerID)
     59             text = GetByLabel('UI/GateIcons/DestSystemOwner', ownerName=ownerInfo.name)
     60             entry = GetFromClass(GateOwnerEntry, {'ownerID': destSystemOwnerID,
     61              'text': text,
     62              'ownerTypeID': ownerInfo.typeID,
     63              'isThereAnyWarning': isThereAnyWarning})
     64             entries.append(entry)
     65         for eachIcon in self.gateIconData.destinationSystemStatusIcons:
     66             if eachIcon.startswith('SEC_'):
     67                 isHazard = isHazardousSecurityTransition
     68             else:
     69                 isHazard = eachIcon in gateLogoConst.HAZARDOUS_STATUS_ICONS
     70             entry = GetFromClass(GateIconEntry, data={'texturePath': GetFullTexturePath(gateLogoConst.SYSTEM_STATUS_ICONS.get(eachIcon, None)),
     71              'text': GetByLabel(TEXT_FOR_SYSTEM_STATUS_ICONS.get(eachIcon, '')),
     72              'isHazard': isHazard,
     73              'isThereAnyWarning': isThereAnyWarning})
     74             entries.append(entry)
     75 
     76         return entries
     77 
     78 
     79 class GateOwnerEntry(MouseInsideScrollEntry):
     80     ENTRYHEIGHT = 50
     81 
     82     def ApplyAttributes(self, attributes):
     83         MouseInsideScrollEntry.ApplyAttributes(self, attributes)
     84         self.node = attributes.node
     85         isThereAnyWarning = self.node.isThereAnyWarning
     86         if isThereAnyWarning:
     87             iconLeft = 42
     88         else:
     89             iconLeft = 6
     90         ownerID = self.node.ownerID
     91         self.ownerIcon = GetLogoIcon(itemID=ownerID, parent=self, acceptNone=False, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL, pos=(iconLeft,
     92          0,
     93          48,
     94          48), ignoreSize=True)
     95         if isThereAnyWarning:
     96             labelLeft = 96
     97         else:
     98             labelLeft = 58
     99         EveLabelMedium(parent=self, text=self.node.text, align=uiconst.CENTERLEFT, left=labelLeft)
    100 
    101     def Load(self, node):
    102         pass
    103 
    104     def GetMenu(self):
    105         return GetMenuService().GetMenuFromItemIDTypeID(self.node.ownerID, self.node.ownerTypeID)
    106 
    107 
    108 class GateIconEntry(MouseInsideScrollEntry):
    109     ENTRYHEIGHT = 50
    110     ICONSIZE = 48
    111     ICON_CROP = 5
    112     WARNING_PATH = 'res:/UI/Texture/classes/gatenotifications/Stargate_TravelWarning3_tri.png'
    113 
    114     def ApplyAttributes(self, attributes):
    115         MouseInsideScrollEntry.ApplyAttributes(self, attributes)
    116         self.node = attributes.node
    117         isThereAnyWarning = self.node.isThereAnyWarning
    118         isHazard = self.node.isHazard
    119         iconLeft = 10
    120         if isThereAnyWarning:
    121             iconLeft += 36
    122             if isHazard:
    123                 hint = GetByLabel('UI/GateIcons/Hazardous')
    124                 hazardIcon = Sprite(parent=self, name='hazardIcon', texturePath=self.WARNING_PATH, pos=(10, 0, 32, 32), align=uiconst.CENTERLEFT, opacity=0.75, hint=hint)
    125         texturePath = self.node.texturePath
    126         croppedSize = self.ICONSIZE - 2 * self.ICON_CROP
    127         spriteCont = Container(parent=self, name='spriteCont', pos=(iconLeft,
    128          0,
    129          croppedSize,
    130          croppedSize), align=uiconst.CENTERLEFT, clipChildren=True)
    131         Sprite(parent=spriteCont, name='icon', texturePath=texturePath, pos=(0,
    132          0,
    133          self.ICONSIZE,
    134          self.ICONSIZE), align=uiconst.CENTER, opacity=0.75)
    135         EveLabelMedium(parent=self, text=self.node.text, align=uiconst.CENTERLEFT, left=spriteCont.left + spriteCont.width + 10)
    136 
    137     def Load(self, node):
    138         pass
    139 
    140 
    141 def GetFullTexturePath(textureName):
    142     return gateLogoConst.SYSTEM_STATUS_DIR + textureName
    143 
    144 
    145 TEXT_FOR_SYSTEM_STATUS_ICONS = {gateLogoConst.INCURSION: 'UI/GateIcons/Incursion',
    146  gateLogoConst.TRIGLAVIAN_INVASION_LEVEL_0: 'UI/GateIcons/Invasion',
    147  gateLogoConst.TRIGLAVIAN_INVASION_LEVEL_1: 'UI/GateIcons/Invasion',
    148  gateLogoConst.TRIGLAVIAN_INVASION_LEVEL_2: 'UI/GateIcons/Invasion',
    149  gateLogoConst.FW_NORMAL: 'UI/GateIcons/FwNormal',
    150  gateLogoConst.FW_CONTESTED: 'UI/GateIcons/FwContested',
    151  gateLogoConst.SOV_NORMAL: 'UI/GateIcons/SovNormal',
    152  gateLogoConst.SOV_CONTESTED: 'UI/GateIcons/SovContested',
    153  gateLogoConst.DANGER_NORMAL: 'UI/GateIcons/DangerNormal',
    154  gateLogoConst.DANGER_CAUTION: 'UI/GateIcons/DangerCaution',
    155  gateLogoConst.DANGER_HIGH: 'UI/GateIcons/DangerHigh',
    156  gateLogoConst.SECURITY_0_0: 'UI/GateIcons/SecurityStatus',
    157  gateLogoConst.SECURITY_0_1: 'UI/GateIcons/SecurityStatus',
    158  gateLogoConst.SECURITY_0_2: 'UI/GateIcons/SecurityStatus',
    159  gateLogoConst.SECURITY_0_3: 'UI/GateIcons/SecurityStatus',
    160  gateLogoConst.SECURITY_0_4: 'UI/GateIcons/SecurityStatus',
    161  gateLogoConst.SECURITY_0_5: 'UI/GateIcons/SecurityStatus',
    162  gateLogoConst.SECURITY_0_6: 'UI/GateIcons/SecurityStatus',
    163  gateLogoConst.SECURITY_0_7: 'UI/GateIcons/SecurityStatus',
    164  gateLogoConst.SECURITY_0_8: 'UI/GateIcons/SecurityStatus',
    165  gateLogoConst.SECURITY_0_9: 'UI/GateIcons/SecurityStatus',
    166  gateLogoConst.SECURITY_1_0: 'UI/GateIcons/SecurityStatus',
    167  gateLogoConst.GATE_CLOSED: 'UI/GateIcons/GateClosed',
    168  gateLogoConst.GATE_OPEN: 'UI/GateIcons/GateOpen',
    169  gateLogoConst.TRAFFIC_LOW: 'UI/GateIcons/TrafficLow',
    170  gateLogoConst.TRAFFIC_MEDIUM: 'UI/GateIcons/TrafficMedium',
    171  gateLogoConst.TRAFFIC_HIGH: 'UI/GateIcons/TrafficHigh'}
    172 HAZARDOUS_SECURITY_TRANSITIONS = [(securityClassSafeSec, securityClassLowSec),
    173  (securityClassSafeSec, securityClassZeroSec),
    174  (securityClassHighSec, securityClassLowSec),
    175  (securityClassHighSec, securityClassZeroSec),
    176  (securityClassLowSec, securityClassZeroSec)]