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

warningIconCont.py (7310B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\fittingScreen\warningIconCont.py
      2 import threadutils
      3 import uthread2
      4 from carbonui.primitives.container import Container
      5 from carbonui import const as uiconst
      6 from carbonui.primitives.sprite import Sprite
      7 import shipfitting.fittingWarnings as fittingWarnings
      8 from eve.client.script.ui.control.eveLabel import EveLabelMediumBold
      9 from eve.client.script.ui.shared.fittingScreen.skillRequirements import GetMissingSkills_HighestLevelByTypeID, GetSkillTooltip, GetAllTypeIDsMissingSkillsForShipAndContent
     10 from eve.client.script.ui.shared.fittingScreen.warningIconTooltip import EvaluateFitAndPopulateTooltip
     11 from shipfitting.fittingWarningConst import WARNING_LEVEL_HIGH, WARNING_LEVEL_MEDIUM, WARNING_LEVEL_LOW, WARNING_LEVEL_SKILL
     12 
     13 class WarningIconCont(Container):
     14     default_name = 'warningIconCont'
     15     default_width = 0
     16     default_height = 60
     17     default_align = uiconst.TOTOP
     18     default_state = uiconst.UI_NORMAL
     19 
     20     def ApplyAttributes(self, attributes):
     21         Container.ApplyAttributes(self, attributes)
     22         self.fittingController = attributes.fittingController
     23         self.currentTooltipPanel = None
     24         ICON_SIZE = 26
     25         contSize = ICON_SIZE + 4
     26         row1 = Container(name='row1', parent=self, height=contSize, align=uiconst.TOTOP)
     27         row2 = Container(name='row2', parent=self, height=contSize, align=uiconst.TOTOP)
     28         self.height = 2 * contSize
     29         self.redWarning = WarningIcon(parent=row1, warningLevel=WARNING_LEVEL_HIGH, tooltipFunc=self.LoadWarningTooltipPanel, width=contSize, iconSize=ICON_SIZE)
     30         self.yellowWarning = WarningIcon(parent=row1, warningLevel=WARNING_LEVEL_MEDIUM, tooltipFunc=self.LoadWarningTooltipPanel, width=contSize, iconSize=ICON_SIZE)
     31         self.whiteWarning = WarningIcon(parent=row1, warningLevel=WARNING_LEVEL_LOW, tooltipFunc=self.LoadWarningTooltipPanel, width=contSize, iconSize=ICON_SIZE)
     32         self.skillWarning1 = SkillWarningIcon(parent=row1, warningLevel=WARNING_LEVEL_SKILL, tooltipFunc=self.LoadSkillTooltip, width=contSize, iconSize=ICON_SIZE)
     33         self.skillWarning2 = SkillWarningIcon(parent=row2, warningLevel=WARNING_LEVEL_SKILL, tooltipFunc=self.LoadSkillTooltip, width=contSize, iconSize=ICON_SIZE)
     34         for eachWarningIcon in (self.skillWarning1,
     35          self.skillWarning2,
     36          self.redWarning,
     37          self.yellowWarning,
     38          self.whiteWarning):
     39             eachWarningIcon.display = False
     40 
     41     def GetFitName(self):
     42         itemID = self.fittingController.GetItemID()
     43         if isinstance(itemID, long):
     44             return cfg.evelocations.Get(itemID).name
     45         else:
     46             return sm.GetService('ghostFittingSvc').GetShipName()
     47 
     48     def LoadSkillTooltip(self, tooltipPanel, *args):
     49         self.currentTooltipPanel = tooltipPanel
     50         GetSkillTooltip(tooltipPanel, self.fittingController, fitName=self.GetFitName())
     51         allTypeIDs = GetAllTypeIDsMissingSkillsForShipAndContent(self.fittingController.GetDogmaLocation())
     52         _, missingSkillsForTypeID = GetMissingSkills_HighestLevelByTypeID(allTypeIDs)
     53         warningSlotDict = fittingWarnings.GetSlotsMissingSkills(missingSkillsForTypeID)
     54         self.fittingController.ChangeFittingWarningDisplay(warningSlotDict)
     55         tooltipPanel.beingDestroyedCallback = self.SkillTooltipPanelBeingDestroyed
     56         sm.ScatterEvent('OnSkillMissingTooltipShown')
     57 
     58     def SkillTooltipPanelBeingDestroyed(self, tooltipPanel, *args):
     59         self.TooltipPanelBeingDestroyed(tooltipPanel, *args)
     60         sm.ScatterEvent('OnSkillMissingTooltipClosed')
     61 
     62     def LoadWarningTooltipPanel(self, tooltipPanel, owner):
     63         self.currentTooltipPanel = tooltipPanel
     64         warningLevel = owner.GetWarningLevel()
     65         tooltipPanel.state = uiconst.UI_NORMAL
     66         tooltipPanel.LoadGeneric4ColumnTemplate()
     67         tooltipPanel.margin = (8, 4, 8, 4)
     68         EvaluateFitAndPopulateTooltip(tooltipPanel, self.fittingController, warningLevel, True)
     69         tooltipPanel.beingDestroyedCallback = self.TooltipPanelBeingDestroyed
     70 
     71     def TooltipPanelBeingDestroyed(self, tooltipPanel, *args):
     72         if self.currentTooltipPanel is None or self.currentTooltipPanel.destroyed:
     73             self.fittingController.ChangeFittingWarningDisplay({})
     74             return
     75         if self.currentTooltipPanel == tooltipPanel and self.currentTooltipPanel.beingDestroyed:
     76             self.fittingController.ChangeFittingWarningDisplay({})
     77 
     78     @threadutils.throttled(0.5)
     79     def _UpdateIcon(self):
     80         uthread2.StartTasklet(self.__UpdateIcon_thread)
     81 
     82     def __UpdateIcon_thread(self):
     83         activeWarningsByLevel = fittingWarnings.GetActiveWarningsByLevel(self.fittingController)
     84         for eachIcon in (self.redWarning, self.yellowWarning, self.whiteWarning):
     85             warningLevel = eachIcon.GetWarningLevel()
     86             numActiveWarnings = activeWarningsByLevel.get(warningLevel, 0)
     87             if numActiveWarnings:
     88                 eachIcon.display = True
     89                 eachIcon.SetCounter(numActiveWarnings)
     90             else:
     91                 eachIcon.display = False
     92 
     93         dogmaLocation = self.fittingController.GetDogmaLocation()
     94         allTypeIDs = GetAllTypeIDsMissingSkillsForShipAndContent(dogmaLocation)
     95         highestLevelByTypeID, _ = GetMissingSkills_HighestLevelByTypeID(allTypeIDs)
     96         if dogmaLocation != self.fittingController.GetDogmaLocation():
     97             return
     98         self.skillWarning1.display = self.skillWarning2.display = False
     99         if highestLevelByTypeID:
    100             mySkillIcon = self.skillWarning1 if len(activeWarningsByLevel) < 3 else self.skillWarning2
    101             mySkillIcon.display = True
    102             mySkillIcon.SetCounter(len(highestLevelByTypeID))
    103 
    104     def ChangeController(self, newController):
    105         self.fittingController = newController
    106 
    107     def UpdateIcon(self, *args):
    108         self._UpdateIcon()
    109 
    110     def Close(self):
    111         self.currentTooltipPanel = None
    112         Container.Close(self)
    113 
    114 
    115 class WarningIcon(Container):
    116     default_width = 28
    117     default_height = 0
    118     default_align = uiconst.TOLEFT
    119     default_state = uiconst.UI_NORMAL
    120     default_iconSize = 24
    121     texturePath = 'res:/UI/Texture/classes/Fitting/warningGroup.png'
    122 
    123     def ApplyAttributes(self, attributes):
    124         Container.ApplyAttributes(self, attributes)
    125         iconSize = attributes.get('iconSize', self.default_iconSize)
    126         self.warningLevel = attributes.warningLevel
    127         self.LoadTooltipPanel = attributes.tooltipFunc
    128         color = fittingWarnings.GetColorForLevel(self.warningLevel)
    129         warningIcon = Sprite(name='warningIcon', parent=self, align=uiconst.BOTTOMLEFT, texturePath=self.texturePath, pos=(0,
    130          0,
    131          iconSize,
    132          iconSize), state=uiconst.UI_DISABLED)
    133         warningIcon.SetRGBA(*color)
    134         self.counterLabel = EveLabelMediumBold(parent=self, align=uiconst.TOPRIGHT, left=2)
    135         self.counterLabel.SetRGBA(*color)
    136 
    137     def SetCounter(self, number):
    138         self.counterLabel.text = number
    139 
    140     def GetWarningLevel(self):
    141         return self.warningLevel
    142 
    143     def GetTooltipPointer(self):
    144         return uiconst.POINT_RIGHT_1
    145 
    146 
    147 class SkillWarningIcon(WarningIcon):
    148     texturePath = 'res:/ui/Texture/classes/Fitting/warningSkills.png'