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

haulerBracket.py (3201B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\bracketsAndTargets\haulerBracket.py
      2 import carbonui.const as uiconst
      3 from carbon.common.script.util.format import FmtAmt
      4 from carbonui.primitives.container import Container
      5 from eve.client.script.ui.control.eveLabel import Label
      6 from eve.client.script.ui.control.gaugeCircular import GaugeCircular
      7 from eve.client.script.ui.inflight.bracketsAndTargets.inSpaceBracket import InSpaceBracket
      8 import localization
      9 from resourcewars.client.const import RW_PANEL_HAULER_PROGRESS_LABEL
     10 from resourcewars.client.rwinfopanelhaulertaskentry import HAULER_PROGRESS_COLOR
     11 
     12 class HaulerBracket(InSpaceBracket):
     13     BACKGROUND_GAUGE_COLOR = (0.3, 0.3, 0.3, 0.6)
     14     GAUGE_WIDTH = 2.5
     15     RADIUS = 16
     16 
     17     def __init__(self, **kwargs):
     18         super(HaulerBracket, self).__init__(**kwargs)
     19         self.rwService = sm.GetService('rwService')
     20         self.shouldShowHint = False
     21         self.initialized = False
     22         container = Container(parent=self, align=uiconst.CENTER, height=32, width=32)
     23         self.gauge = GaugeCircular(parent=container, name='haulerBracketGauge', radius=self.RADIUS, align=uiconst.CENTER, colorStart=HAULER_PROGRESS_COLOR, colorEnd=HAULER_PROGRESS_COLOR, colorBg=self.BACKGROUND_GAUGE_COLOR, lineWidth=self.GAUGE_WIDTH, clockwise=False, showMarker=False, state=uiconst.UI_DISABLED)
     24         self.percentage = 0.0
     25         haulerProgress = self.GetProgress()
     26         self.SetCapacityBarPercentage(haulerProgress)
     27         self.gauge.SetValue(self.percentage)
     28 
     29     def SetHint(self, hint):
     30         if self.label:
     31             self.label.Close()
     32         if getattr(self, 'hintLabel', False):
     33             self.hintLabel.Close()
     34         self.hintLabel = Label(parent=self, align=uiconst.TOLEFT_NOPUSH, text=hint, padLeft=self.RADIUS * 2)
     35 
     36     def UpdateHint(self):
     37         if self.shouldShowHint:
     38             hint = localization.GetByLabel(RW_PANEL_HAULER_PROGRESS_LABEL, current=FmtAmt(self.contents), total=FmtAmt(self.capacity))
     39         else:
     40             hint = ''
     41         self.SetHint(hint)
     42 
     43     def SetCapacityBarPercentage(self, haulerData):
     44         if haulerData is None:
     45             return
     46         self.contents = haulerData.contents
     47         self.capacity = haulerData.capacity
     48         self.initialized = True
     49         try:
     50             self.percentage = float(self.contents) / self.capacity
     51         except ZeroDivisionError:
     52             self.percentage = 0.0
     53 
     54         self.UpdateHint()
     55 
     56     def GetProgress(self):
     57         return self.rwService.get_progress_for_hauler(self.itemID)
     58 
     59     def Select(self, status):
     60         InSpaceBracket.Select(self, status)
     61         if status:
     62             self.SetCapacityBarPercentage(self.GetProgress())
     63         else:
     64             self.SetHint('')
     65 
     66     def UpdateQuantity(self, newQuantity):
     67         ratio = float(newQuantity) / self.capacity
     68         self.contents = newQuantity
     69         self.gauge.SetValueTimed(ratio, 1.0)
     70 
     71     def OnMouseEnter(self, *args):
     72         if self.initialized:
     73             self.shouldShowHint = True
     74         self.UpdateHint()
     75 
     76     def OnMouseExit(self, *args):
     77         self.shouldShowHint = False
     78         self.UpdateHint()