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

jobsStrip.py (9076B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\industry\jobsStrip.py
      2 import math
      3 from carbon.client.script.environment.AudioUtil import PlaySound
      4 from carbonui import fontconst
      5 from carbonui.primitives.container import Container
      6 from carbonui.primitives.layoutGrid import LayoutGrid
      7 from carbonui.util.color import Color
      8 from eve.client.script.ui.control.eveLabel import Label
      9 from eve.client.script.ui.control.themeColored import FrameThemeColored
     10 from eve.client.script.ui.shared.industry import industryUIConst
     11 from eve.client.script.ui.shared.industry.activitySelectionButtons import ActivitySelectionButtons
     12 import carbonui.const as uiconst
     13 from carbonui.primitives.gradientSprite import GradientSprite
     14 from eve.client.script.ui.shared.industry.submitButton import SubmitButton
     15 import telemetry
     16 from eve.client.script.ui.shared.industry.views.errorFrame import ErrorFrame
     17 from eve.client.script.ui.shared.industry.views.industryTooltips import JobsSummaryTooltipPanel, AllJobsSummaryTooltipPanel
     18 import industry
     19 import localization
     20 from carbonui.uicore import uicore
     21 
     22 class JobsStrip(Container):
     23     default_name = 'JobsStrip'
     24     default_height = 50
     25 
     26     def ApplyAttributes(self, attributes):
     27         Container.ApplyAttributes(self, attributes)
     28         callback = attributes.callback
     29         submit = attributes.submit
     30         self.oldJobData = None
     31         self.jobData = attributes.jobData
     32         self.jobsSummary = JobsSummary(parent=self, align=uiconst.CENTERLEFT, left=10)
     33         self.allJobsSummary = AllJobsSummary(parent=self, align=uiconst.CENTERLEFT, left=10)
     34         self.activitySelectionButtons = ActivitySelectionButtons(parent=self, align=uiconst.CENTER, callback=callback, width=248, height=38)
     35         self.submitBtn = SubmitButton(parent=self, align=uiconst.CENTERRIGHT, fixedheight=30, fixedwidth=120, left=7)
     36         GradientSprite(bgParent=self, rotation=-math.pi / 2, rgbData=[(0, (0.3, 0.3, 0.3))], alphaData=[(0, 0.3), (1.0, 0.05)])
     37         FrameThemeColored(bgParent=self, colorType=uiconst.COLORTYPE_UIBASECONTRAST)
     38         self.UpdateState()
     39 
     40     @telemetry.ZONE_METHOD
     41     def OnNewJobData(self, jobData):
     42         self.jobData = jobData
     43         self.activitySelectionButtons.OnNewJobData(jobData)
     44         self.submitBtn.OnNewJobData(jobData)
     45         if jobData:
     46             self.jobData.on_updated.connect(self.UpdateState)
     47             self.jobsSummary.OnNewJobData(jobData)
     48         self.UpdateState()
     49 
     50     def UpdateState(self, *args):
     51         if self.jobData:
     52             self.submitBtn.Show()
     53             self.jobsSummary.Show()
     54             self.allJobsSummary.Hide()
     55         else:
     56             self.submitBtn.Hide()
     57             self.jobsSummary.Hide()
     58             self.allJobsSummary.Show()
     59 
     60 
     61 class JobsSummary(LayoutGrid):
     62     default_columns = 2
     63     default_state = uiconst.UI_NORMAL
     64     __notifyevents__ = ['OnIndustrySlotsUpdated']
     65 
     66     def ApplyAttributes(self, attributes):
     67         LayoutGrid.ApplyAttributes(self, attributes)
     68         self.activityType = None
     69         self.jobData = None
     70         self.countCaption = Label(color=Color.GRAY, fontsize=fontconst.EVE_SMALL_FONTSIZE, top=2)
     71         self.AddCell(self.countCaption, cellPadding=(0, 0, 5, 0))
     72         self.countLabel = Label()
     73         cell = self.AddCell(self.countLabel, cellPadding=(5, 0, 5, 3))
     74         self.slotsErrorFrame = ErrorFrame(parent=cell, align=uiconst.TOALL, state=uiconst.UI_DISABLED, padBottom=3)
     75         label = Label(text=localization.GetByLabel('UI/Industry/ControlRange'), color=Color.GRAY, fontsize=fontconst.EVE_SMALL_FONTSIZE, top=2)
     76         self.AddCell(label, cellPadding=(0, 0, 5, 0))
     77         self.rangeLabel = Label()
     78         cell = self.AddCell(self.rangeLabel, cellPadding=(5, 0, 5, 0))
     79         self.rangeErrorFrame = ErrorFrame(parent=cell, align=uiconst.TOALL, state=uiconst.UI_DISABLED)
     80         sm.RegisterNotify(self)
     81 
     82     def OnIndustrySlotsUpdated(self, *args):
     83         if self.jobData:
     84             self.UpdateState()
     85 
     86     def OnNewJobData(self, jobData):
     87         self.jobData = jobData
     88         if self.jobData:
     89             self.jobData.on_updated.connect(self.UpdateState)
     90         self.UpdateState()
     91 
     92     def UpdateState(self, *args):
     93         activityID = self.jobData.activityID
     94         activityType = industryUIConst.GetActivityType(activityID)
     95         changed = self.activityType != activityType
     96         self.activityType = activityType
     97         if changed:
     98             uicore.animations.FadeOut(self, sleep=True, duration=0.1)
     99             if self.activityType == industryUIConst.TYPE_MANUFACTURING:
    100                 self.countCaption.text = localization.GetByLabel('UI/Industry/ManufacturingJobs')
    101             elif self.activityType == industryUIConst.TYPE_REACTION:
    102                 self.countCaption.text = localization.GetByLabel('UI/Industry/ReactionJobs')
    103             elif self.activityType == industryUIConst.TYPE_SCIENCE:
    104                 self.countCaption.text = localization.GetByLabel('UI/Industry/ScienceJobs')
    105         c = industryUIConst.GetActivityColor(activityID)
    106         color = Color.RGBtoHex(*c)
    107         usedSlots = sm.GetService('industrySvc').GetJobCountForActivity(activityID)
    108         usedSlotsText = '-' if usedSlots is None else usedSlots
    109         self.countLabel.text = '%s / <color=%s>%s</color>' % (usedSlotsText, color, self.jobData.max_slots)
    110         skillLabel = industryUIConst.GetControlRangeLabel(self.jobData.max_distance)
    111         self.rangeLabel.text = '<color=%s>%s' % (color, skillLabel)
    112         if changed:
    113             uicore.animations.FadeIn(self, duration=0.3)
    114         if self.jobData and self.jobData.HasError(industry.Error.SLOTS_FULL):
    115             self.slotsErrorFrame.Show()
    116         else:
    117             self.slotsErrorFrame.Hide()
    118         if self.jobData and self.jobData.HasError(industry.Error.FACILITY_DISTANCE):
    119             self.rangeErrorFrame.Show()
    120         else:
    121             self.rangeErrorFrame.Hide()
    122 
    123     def LoadTooltipPanel(self, tooltipPanel, *args):
    124         JobsSummaryTooltipPanel(self.jobData, tooltipPanel)
    125 
    126     def OnMouseEnter(self, *args):
    127         PlaySound(uiconst.SOUND_BUTTON_HOVER)
    128 
    129 
    130 class AllJobsSummary(LayoutGrid):
    131     default_columns = 2
    132     default_state = uiconst.UI_NORMAL
    133     __notifyevents__ = ['OnIndustrySlotsUpdated', 'OnSkillsChanged']
    134 
    135     def ApplyAttributes(self, attributes):
    136         LayoutGrid.ApplyAttributes(self, attributes)
    137         captionCellPadding = (0, 0, 0, 0)
    138         countLabelCellPadding = (5, 0, 5, 0)
    139         self.manufacturingCountCaption = Label(color=Color.GRAY, fontsize=fontconst.EVE_SMALL_FONTSIZE, text=localization.GetByLabel('UI/Industry/ManufacturingJobs'))
    140         self.AddCell(self.manufacturingCountCaption, cellPadding=captionCellPadding)
    141         self.manufacturingCountLabel = Label(fontsize=fontconst.EVE_SMALL_FONTSIZE)
    142         cell = self.AddCell(self.manufacturingCountLabel, cellPadding=countLabelCellPadding)
    143         self.scienceCountCaption = Label(color=Color.GRAY, fontsize=fontconst.EVE_SMALL_FONTSIZE, text=localization.GetByLabel('UI/Industry/ScienceJobs'))
    144         self.AddCell(self.scienceCountCaption, cellPadding=captionCellPadding)
    145         self.scienceCountLabel = Label(fontsize=fontconst.EVE_SMALL_FONTSIZE)
    146         cell = self.AddCell(self.scienceCountLabel, cellPadding=countLabelCellPadding)
    147         self.reactionCountCaption = Label(color=Color.GRAY, fontsize=fontconst.EVE_SMALL_FONTSIZE, text=localization.GetByLabel('UI/Industry/ReactionJobs'))
    148         self.AddCell(self.reactionCountCaption, cellPadding=captionCellPadding)
    149         self.reactionCountLabel = Label(fontsize=fontconst.EVE_SMALL_FONTSIZE)
    150         cell = self.AddCell(self.reactionCountLabel, cellPadding=countLabelCellPadding)
    151         self.UpdateState()
    152         sm.RegisterNotify(self)
    153 
    154     def OnSkillsChanged(self, *args):
    155         self.UpdateState()
    156 
    157     def OnIndustrySlotsUpdated(self, *args):
    158         self.UpdateState()
    159 
    160     def UpdateState(self, *args):
    161         dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
    162         attributeValues = dogmaLocation.GetIndustryCharacterModifiers(session.charid)
    163         industrySvc = sm.GetService('industrySvc')
    164         for activityID, slotLimitAttributeID, countLabel in [(industry.MANUFACTURING, const.attributeManufactureSlotLimit, self.manufacturingCountLabel), (industry.RESEARCH_TIME, const.attributeMaxLaborotorySlots, self.scienceCountLabel), (industry.REACTION, const.attributeReactionSlotLimit, self.reactionCountLabel)]:
    165             usedSlots = industrySvc.GetJobCountForActivity(activityID)
    166             c = industryUIConst.GetActivityColor(activityID)
    167             color = Color.RGBtoHex(*c)
    168             maxSlots = int(attributeValues[slotLimitAttributeID])
    169             usedSlotsText = '-' if usedSlots is None else usedSlots
    170             countLabel.text = '%s / <color=%s>%s</color>' % (usedSlotsText, color, maxSlots)
    171 
    172     def LoadTooltipPanel(self, tooltipPanel, *args):
    173         AllJobsSummaryTooltipPanel(tooltipPanel)
    174 
    175     def OnMouseEnter(self, *args):
    176         PlaySound(uiconst.SOUND_BUTTON_HOVER)