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

fitting.py (7416B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\control\entries\fitting.py
      2 import dynamicitemattributes
      3 import evetypes
      4 import localization
      5 from carbon.common.script.util.format import FmtDate
      6 from carbonui import uiconst
      7 from carbonui.primitives.container import Container
      8 from carbonui.primitives.sprite import Sprite
      9 from eve.client.script.ui.control.entries.generic import Generic, events
     10 from eve.client.script.ui.control.entries.item import Item
     11 from eve.client.script.ui.control.eveIcon import Icon
     12 from eve.client.script.ui.control.eveLabel import EveLabelMedium
     13 from eve.client.script.ui.shared.fittingScreen import FITTING_OWNER_COMMUNITY, FITTING_OWNER_CORP, FITTING_OWNER_ALLIANCE
     14 from eve.client.script.ui.shared.industry.views.errorFrame import ErrorFrame
     15 from eve.client.script.ui.util import uix
     16 from eve.common.lib import appConst as const
     17 from eveservices.menu import GetMenuService
     18 
     19 class FittingEntry(Generic):
     20     __guid__ = 'listentry.FittingEntry'
     21     isDragObject = True
     22 
     23     def GetDragData(self, *args):
     24         nodes = [self.sr.node]
     25         return nodes
     26 
     27     def Startup(self, *args):
     28         parent = Container(name='parent', parent=self, align=uiconst.TOALL, pos=(0, 0, 16, 0))
     29         self.sr.have = Icon(parent=self, align=uiconst.CENTERRIGHT, left=0, top=0, height=16, width=16)
     30         self.sr.ownerTypeIcon = Sprite(parent=parent, align=uiconst.CENTERLEFT, left=0, top=0, height=9, width=9)
     31         self.sr.ownerTypeIcon.display = False
     32         self.sr.label = EveLabelMedium(parent=parent, left=5, state=uiconst.UI_DISABLED, maxLines=1, align=uiconst.CENTERLEFT)
     33         self.sr.label.autoFadeSides = 16
     34         for eventName in events:
     35             setattr(self.sr, eventName, None)
     36 
     37     def Load(self, node):
     38         Generic.Load(self, node)
     39         hasSkill = self.HasSkill(node)
     40         if hasSkill:
     41             iconNum = 'ui_38_16_193'
     42             hint = localization.GetByLabel('UI/Control/Entries/FittingSkillOK')
     43         else:
     44             iconNum = 'ui_38_16_194'
     45             hint = localization.GetByLabel('UI/Control/Entries/FittingSkillMissing')
     46         self.sr.have.LoadIcon(iconNum, ignoreSize=True)
     47         self.sr.have.SetSize(16, 16)
     48         self.sr.have.hint = hint
     49         self.sr.label.Update()
     50         if node.ownerType in (FITTING_OWNER_CORP, FITTING_OWNER_COMMUNITY, FITTING_OWNER_ALLIANCE):
     51             if node.ownerType == FITTING_OWNER_ALLIANCE:
     52                 texturePath = 'res:/UI/Texture/classes/Fitting/iconAllianceSmall.png'
     53                 hintPath = 'UI/Fitting/AllianceFittingHint'
     54             elif node.ownerType == FITTING_OWNER_CORP:
     55                 texturePath = 'res:/UI/Texture/classes/FlagIcon/2.png'
     56                 hintPath = 'UI/Fitting/CorpFittingHint'
     57             else:
     58                 texturePath = 'res:/UI/Texture/classes/Fitting/iconCommunityFitsSmall.png'
     59                 hintPath = 'UI/Fitting/CommunityFittingHint'
     60             self.sr.ownerTypeIcon.SetTexturePath(texturePath)
     61             self.sr.ownerTypeIcon.left = self.sr.label.left - 5
     62             self.sr.ownerTypeIcon.display = True
     63             self.sr.ownerTypeIcon.hint = localization.GetByLabel(hintPath)
     64         if node.ownerType is not None:
     65             self.sr.label.left += 9
     66 
     67     def GetHeight(self, *args):
     68         node, width = args
     69         if node.Get('vspace', None):
     70             node.height = uix.GetTextHeight(node.label, maxLines=1) + node.vspace
     71         else:
     72             node.height = uix.GetTextHeight(node.label, maxLines=1) + 4
     73         return node.height
     74 
     75     def HasSkill(self, node):
     76         return sm.StartService('fittingSvc').HasSkillForFit(node.fitting)
     77 
     78     def LoadTooltipPanel(self, tooltipPanel, *args):
     79         fitting = self.sr.node.fitting
     80         tooltipPanel.LoadGeneric1ColumnTemplate()
     81         tooltipPanel.AddLabelMedium(text=fitting.name, bold=True)
     82         tooltipPanel.AddLabelSmall(text=evetypes.GetName(fitting.shipTypeID), bold=True)
     83         if fitting.description:
     84             tooltipPanel.AddLabelSmall(text=fitting.description, wrapWidth=200)
     85         savedDate = getattr(fitting, 'savedDate', None)
     86         if savedDate:
     87             saveDateText = localization.GetByLabel('UI/Fitting/FittingLastSavedHint', timestamp=FmtDate(savedDate))
     88             tooltipPanel.AddLabelMedium(text=saveDateText)
     89 
     90 
     91 class FittingModuleEntry(Item):
     92     __guid__ = 'listentry.FittingModuleEntry'
     93 
     94     def Startup(self, *args):
     95         super(FittingModuleEntry, self).Startup(*args)
     96         self.labelCont.padRight = 32
     97         self.padLeft = 2
     98         self.sr.haveIcon = Icon(parent=self, align=uiconst.CENTERRIGHT, pos=(18, 0, 16, 16))
     99         self.hints = [localization.GetByLabel('UI/Control/Entries/FittingModuleSkillMissing'), localization.GetByLabel('UI/Control/Entries/FittingModuleSkillOK')]
    100 
    101     def HasSkill(self, node):
    102         if node.effectID == const.effectRigSlot:
    103             return True
    104         godma = sm.StartService('godma')
    105         return godma.CheckSkillRequirementsForType(node.typeID)
    106 
    107     def Load(self, node):
    108         super(FittingModuleEntry, self).Load(node)
    109         isObsolete = node.get('isObsolete', False)
    110         if isObsolete:
    111             if getattr(self, 'invalidGroupBG', None) is None:
    112                 self.invalidGroupBG = ErrorFrame(bgParent=self, padding=(2, 2, 2, 2), color=(1, 0, 0, 0.1), opacityLow=0.1, opacityHigh=0.2)
    113                 self.invalidGroupBG.Show()
    114             texturePath = 'res:/ui/texture/icons/44_32_7.png'
    115             self.sr.haveIcon.LoadIcon(texturePath, ignoreSize=True)
    116             self.sr.haveIcon.SetRGBA(1.0, 0.1, 0.1, 0.8)
    117             self.sr.haveIcon.hint = localization.GetByLabel('UI/Fitting/TypeIsObsolete')
    118         else:
    119             hasSkill = self.HasSkill(node)
    120             if hasSkill:
    121                 iconNum = 'ui_38_16_193'
    122             else:
    123                 iconNum = 'ui_38_16_194'
    124             hint = self.hints[hasSkill]
    125             self.sr.haveIcon.LoadIcon(iconNum, ignoreSize=True)
    126             self.sr.haveIcon.hint = hint
    127             if not node.isValidGroup and getattr(self, 'invalidGroupBG', None) is None:
    128                 self.invalidGroupBG = ErrorFrame(bgParent=self, padding=(2, 2, 2, 2), color=(1, 0, 0, 0.1), opacityLow=0.1, opacityHigh=0.2)
    129                 self.invalidGroupBG.Show()
    130             elif dynamicitemattributes.IsDynamicType(node.typeID):
    131                 if getattr(self, 'errorFrame', None) is None:
    132                     self.errorFrame = ErrorFrame(bgParent=self, padding=(2, 2, 2, 2), color=(1.0, 0.35, 0.0), opacityLow=0.1, opacityHigh=0.2)
    133                     self.errorFrame.Show()
    134                 texturePath = 'res:/ui/texture/icons/44_32_7.png'
    135                 self.sr.haveIcon.LoadIcon(texturePath, ignoreSize=True)
    136                 self.sr.haveIcon.SetRGBA(1.0, 0.1, 0.1, 0.8)
    137                 self.sr.haveIcon.hint = localization.GetByLabel('UI/Fitting/FittingWindow/FittingManagement/AbyssalModuleWarning')
    138         self.labelCont.padRight = 16 if self.sr.infoicon.state == uiconst.UI_HIDDEN else 32
    139 
    140     def GetMenu(self):
    141         if self.sr.node and self.sr.node.Get('GetMenu', None):
    142             return self.sr.node.GetMenu(self)
    143         if getattr(self, 'itemID', None) or getattr(self, 'typeID', None):
    144             return GetMenuService().GetMenuFromItemIDTypeID(getattr(self, 'itemID', None), getattr(self, 'typeID', None), includeMarketDetails=True)
    145         return []