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

containersMETE.py (7640B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\industry\views\containersMETE.py
      2 import carbonui.const as uiconst
      3 from carbon.client.script.environment.AudioUtil import PlaySound
      4 from carbonui.control.singlelineedits.singleLineEditInteger import SingleLineEditInteger
      5 from carbonui.primitives.container import Container
      6 from carbonui.primitives.sprite import Sprite
      7 from carbonui.primitives.stretchspritehorizontal import StretchSpriteHorizontal
      8 from carbonui.util.color import Color
      9 from eve.client.script.ui.control.eveLabel import EveLabelMediumBold
     10 from eve.client.script.ui.control.gauge import Gauge
     11 from eve.client.script.ui.control.themeColored import FillThemeColored
     12 from eve.client.script.ui.shared.industry.industryUIConst import COLOR_NOTREADY, COLOR_FRAME, COLOR_READY, GetJobColor
     13 from eve.client.script.ui.shared.industry.views.errorFrame import ErrorFrame
     14 import industry
     15 from industry.const import MIN_MATERIAL_EFFICIENCY, MIN_TIME_EFFICIENCY, MAX_TIME_EFFICIENCY, MAX_MATERIAL_EFFICIENCY
     16 import localization
     17 from carbonui.uicore import uicore
     18 
     19 class BaseContainerMETE(Container):
     20     default_align = uiconst.TOPLEFT
     21     default_state = uiconst.UI_NORMAL
     22 
     23     def ApplyAttributes(self, attributes):
     24         Container.ApplyAttributes(self, attributes)
     25         self.value = 0.0
     26         iconPath = attributes.iconPath
     27         iconSize = attributes.iconSize
     28         minValue = attributes.minValue
     29         maxValue = attributes.maxValue
     30         showBG = attributes.get('showBG', True)
     31         isCompact = attributes.get('isCompact', False)
     32         self.jobData = attributes.jobData
     33         self.gauge = Gauge(parent=self, align=uiconst.TOBOTTOM, state=uiconst.UI_DISABLED, height=6, gaugeHeight=6, padTop=1, backgroundColor=(1.0, 1.0, 1.0, 0.05))
     34         if isCompact:
     35             self.icon = None
     36             self.valueLabel = None
     37             return
     38         mainCont = Container(name='mainCont', parent=self)
     39         if showBG:
     40             self.bg = StretchSpriteHorizontal(bgParent=mainCont, texturePath='res:/UI/Texture/Classes/Industry/Center/bgMETE.png')
     41             FillThemeColored(bgParent=self, opacity=0.5)
     42         else:
     43             self.bg = None
     44         left = 8 if showBG else 2
     45         self.icon = Sprite(name='icon', parent=mainCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(left,
     46          3,
     47          self.ICONSIZE,
     48          self.ICONSIZE), texturePath=self.ICONPATH, opacity=0.6)
     49         self.valueLabel = EveLabelMediumBold(parent=mainCont, align=uiconst.TOPRIGHT, top=4, left=left)
     50         self.removeIcon = Sprite(parent=mainCont, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, texturePath='res:/ui/texture/icons/73_16_45.png', pos=(0, 0, 12, 12), color=Color.RED, hint=localization.GetByLabel('UI/Industry/PreviewModeHint'))
     51         self.removeIcon.OnClick = self.OnRemoveIconClick
     52         self.previewEdit = SingleLineEditInteger(name='previewEdit', parent=mainCont, align=uiconst.CENTERRIGHT, state=uiconst.UI_HIDDEN, maxValue=self.MAXVAL, OnChange=self.OnPreviewEdit, pos=(12, 0, 43, 20))
     53         self.errorFrame = ErrorFrame(bgParent=self, padding=(1, 1, 1, 8))
     54 
     55     def SetValue(self, value):
     56         if self.value * (value or 1) < 0.0:
     57             self.gauge.SetValueInstantly(0.0)
     58         self.value = value
     59         if value < 0:
     60             self.gauge.SetGaugeAlign(uiconst.TORIGHT_PROP)
     61             self.gauge.SetValue(float(value) / self.MINVAL)
     62             self.gauge.SetColor(COLOR_NOTREADY)
     63         else:
     64             self.gauge.SetGaugeAlign(uiconst.TOLEFT_PROP)
     65             self.gauge.SetValue(float(value) / self.MAXVAL)
     66             self.gauge.SetColor(COLOR_READY)
     67         if not self.valueLabel:
     68             return
     69         if value < 0:
     70             self.valueLabel.text = '<color=%s>%s%%' % (Color.RGBtoHex(*COLOR_NOTREADY), value)
     71         elif value == 0:
     72             self.valueLabel.text = '<color=%s>%s%%' % (Color.RGBtoHex(*COLOR_FRAME), value)
     73         else:
     74             self.valueLabel.text = '<color=%s>%s%%' % (Color.RGBtoHex(*COLOR_READY), value)
     75 
     76     def OnRemoveIconClick(self):
     77         self.ExitPreviewMode()
     78 
     79     def EnterPreviewMode(self):
     80         if not self.IsPreviewEnabled():
     81             return
     82         self.previewEdit.Show()
     83         self.previewEdit.SetValue(self.GetPreviewEditValue())
     84         self.valueLabel.Hide()
     85         self.errorFrame.Show()
     86         self.removeIcon.Show()
     87         uicore.registry.SetFocus(self.previewEdit)
     88 
     89     def ExitPreviewMode(self):
     90         self.previewEdit.Hide()
     91         self.valueLabel.Show()
     92         self.errorFrame.Hide()
     93         self.removeIcon.Hide()
     94 
     95     def OnClick(self, *args):
     96         PlaySound(uiconst.SOUND_BUTTON_CLICK)
     97         self.EnterPreviewMode()
     98 
     99     def OnMouseEnter(self, *args):
    100         PlaySound(uiconst.SOUND_BUTTON_HOVER)
    101         if self.bg and self.IsPreviewEnabled():
    102             uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.5, duration=0.3)
    103 
    104     def OnMouseExit(self, *args):
    105         if self.bg:
    106             uicore.animations.FadeTo(self.bg, self.bg.opacity, 1.0, duration=0.3)
    107 
    108     def OnNewJobData(self, jobData):
    109         self.jobData = jobData
    110         self.display = True
    111         if jobData:
    112             if self.jobData.activityID == industry.REACTION:
    113                 self.display = False
    114             elif self.jobData and self.jobData.blueprint.IsAncientRelic():
    115                 self.display = False
    116         self.ExitPreviewMode()
    117 
    118     def IsPreviewEnabled(self):
    119         if not self.jobData or self.jobData.activityID != industry.MANUFACTURING or self.jobData.jobID:
    120             return False
    121         return True
    122 
    123     def IsPreviewActive(self):
    124         return self.errorFrame.display
    125 
    126     def GetHint(self):
    127         if self.IsPreviewEnabled() and not self.IsPreviewActive():
    128             return '<br><br>' + localization.GetByLabel('UI/Industry/EnterPreviewModeHint')
    129         return ''
    130 
    131 
    132 class ContainerTE(BaseContainerMETE):
    133     ICONPATH = 'res:/UI/Texture/Classes/Industry/iconTE.png'
    134     ICONSIZE = 16
    135     MINVAL = MIN_TIME_EFFICIENCY
    136     MAXVAL = MAX_TIME_EFFICIENCY
    137 
    138     def GetHint(self):
    139         hint = '<b>%s</b><br>%s' % (localization.GetByLabel('UI/Industry/TimeEfficiency'), localization.GetByLabel('UI/Industry/TimeEfficiencyHint'))
    140         hint += BaseContainerMETE.GetHint(self)
    141         return hint
    142 
    143     def OnPreviewEdit(self, *args):
    144         self.jobData.timeEfficiency = int(self.previewEdit.GetValue())
    145         self.jobData.update(self.jobData)
    146 
    147     def GetPreviewEditValue(self):
    148         return self.jobData.timeEfficiency
    149 
    150     def ExitPreviewMode(self):
    151         BaseContainerMETE.ExitPreviewMode(self)
    152         if self.jobData:
    153             self.jobData.timeEfficiency = None
    154             self.jobData.update(self.jobData)
    155 
    156 
    157 class ContainerME(BaseContainerMETE):
    158     ICONPATH = 'res:/UI/Texture/Classes/Industry/iconME.png'
    159     ICONSIZE = 17
    160     MINVAL = MIN_MATERIAL_EFFICIENCY
    161     MAXVAL = MAX_MATERIAL_EFFICIENCY
    162 
    163     def GetHint(self):
    164         hint = '<b>%s</b><br>%s' % (localization.GetByLabel('UI/Industry/MaterialEfficiency'), localization.GetByLabel('UI/Industry/MaterialEfficiencyHint'))
    165         hint += BaseContainerMETE.GetHint(self)
    166         return hint
    167 
    168     def OnPreviewEdit(self, *args):
    169         self.jobData.materialEfficiency = int(self.previewEdit.GetValue())
    170         self.jobData.update(self.jobData)
    171 
    172     def GetPreviewEditValue(self):
    173         return self.jobData.materialEfficiency
    174 
    175     def ExitPreviewMode(self):
    176         BaseContainerMETE.ExitPreviewMode(self)
    177         if self.jobData:
    178             self.jobData.materialEfficiency = None
    179             self.jobData.update(self.jobData)