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

resourceLoadingIndicator.py (5051B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\resourceLoadingIndicator.py
      2 import blue
      3 from carbon.common.script.util.timerstuff import AutoTimer
      4 from carbonui.primitives.base import ReverseScaleDpi
      5 from eve.client.script.ui.control.themeColored import FillThemeColored, SpriteThemeColored
      6 from localization import GetByLabel
      7 import uthread2
      8 import math
      9 import weakref
     10 import carbonui.const as uiconst
     11 from carbonui.primitives.container import Container
     12 from carbonui.uicore import uicore
     13 
     14 class ResourceLoadingIndicator(Container):
     15     default_name = 'loadingindicator'
     16     default_align = uiconst.TOPLEFT
     17     default_width = 48
     18     default_height = 32
     19     default_state = uiconst.UI_NORMAL
     20     tooltip = None
     21     isGlobal = False
     22     enabled = True
     23     active = False
     24 
     25     def ApplyAttributes(self, attributes):
     26         Container.ApplyAttributes(self, attributes)
     27         self.isGlobal = bool(attributes.isGlobal)
     28         if not self.isGlobal:
     29             sm.GetService('gameui').DisableResourceLoadingIndicator()
     30         self.wheel = SpriteThemeColored(parent=self, align=uiconst.CENTER, pos=(0, 0, 48, 48), texturePath='res:/UI/Texture/loadingWheel.png', state=uiconst.UI_DISABLED, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.0)
     31         self.wheelfull = SpriteThemeColored(parent=self, align=uiconst.CENTER, pos=(0, 0, 48, 48), texturePath='res:/UI/Texture/loadingWheel_full.png', state=uiconst.UI_DISABLED, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW, opacity=0.1)
     32         self.downloadingBar = FillThemeColored(parent=self, align=uiconst.BOTTOMLEFT, state=uiconst.UI_HIDDEN, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW)
     33         self.loadingBar = FillThemeColored(parent=self, align=uiconst.BOTTOMLEFT, state=uiconst.UI_HIDDEN, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW)
     34         self.queueBar = FillThemeColored(parent=self, align=uiconst.BOTTOMLEFT, state=uiconst.UI_HIDDEN, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW)
     35         uthread2.StartTasklet(self._Update_t)
     36 
     37     def Close(self, *args):
     38         if not self.isGlobal:
     39             sm.GetService('gameui').EnableResourceLoadingIndicator()
     40         Container.Close(self, *args)
     41 
     42     def Enable(self):
     43         self.enabled = True
     44         self.display = True
     45 
     46     def Disable(self):
     47         self.enabled = False
     48         self.display = False
     49 
     50     def LoadTooltipPanel(self, tooltipPanel, *args, **kwds):
     51         tooltipPanel.LoadGeneric1ColumnTemplate()
     52         tooltipPanel.AddLabelMedium(text=GetByLabel('Tooltips/Neocom/ResourceLoadingIndicator'), bold=True)
     53         if self.downloadingBar.display:
     54             tooltipPanel.readout = tooltipPanel.AddLabelMedium()
     55         self.tooltip = weakref.ref(tooltipPanel)
     56 
     57     def GetTooltipPointer(self):
     58         if self.downloadingBar.display:
     59             return uiconst.POINT_LEFT_3
     60         else:
     61             return uiconst.POINT_LEFT_2
     62 
     63     def _UpdateHelper(self):
     64         if not self.enabled:
     65             return
     66         status = blue.threadMonitor.GetStatus()
     67         downloads = 0
     68         loads = 0
     69         for threadId, threadStatus in status:
     70             if threadStatus == 3:
     71                 downloads += 1
     72             elif threadStatus > 0:
     73                 loads += 1
     74 
     75         if self.downloadingBar.display:
     76             barWidth = ReverseScaleDpi(self.displayWidth) / 3 - 2
     77             barHeight = ReverseScaleDpi(self.displayHeight)
     78             self.downloadingBar.height = min(downloads, barHeight)
     79             self.downloadingBar.width = barWidth
     80             self.loadingBar.height = min(loads, barHeight)
     81             self.loadingBar.width = barWidth
     82             self.loadingBar.left = barWidth + 1
     83             inQueue = blue.resMan.pendingLoads + blue.resMan.pendingPrepares
     84             self.queueBar.height = min(inQueue, barHeight)
     85             self.queueBar.width = barWidth
     86             self.queueBar.left = barWidth * 2 + 2
     87             if self.tooltip:
     88                 tooltip = self.tooltip()
     89                 if tooltip and not tooltip.destroyed:
     90                     tooltip.readout.text = 'downloads: %s<br>loads: %s<br>inQueue: %s' % (downloads, loads, inQueue)
     91         if downloads > 0:
     92             if not self.active:
     93                 self.active = True
     94                 uicore.animations.FadeTo(self.wheel, startVal=self.wheel.opacity, endVal=1.0, duration=0.3)
     95             if not self.wheel.HasAnimation('rotation'):
     96                 uicore.animations.MorphScalar(self.wheel, 'rotation', self.wheel.rotation, -2 * math.pi + self.wheel.rotation, duration=1.0, curveType=uiconst.ANIM_LINEAR, loops=uiconst.ANIM_REPEAT)
     97         elif self.active:
     98             self.active = False
     99             uicore.animations.FadeTo(self.wheel, startVal=self.wheel.opacity, endVal=0.0, duration=0.3)
    100 
    101     def _Update_t(self):
    102         while not self.destroyed:
    103             self._UpdateHelper()
    104             uthread2.Sleep(1.0)
    105 
    106     def SetBarsActive(self, active):
    107         self.downloadingBar.display = active
    108         self.loadingBar.display = active
    109         self.queueBar.display = active