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

basePanel.py (4447B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\fittingScreen\fittingPanels\basePanel.py
      2 import eveui
      3 from carbonui import uiconst
      4 from carbonui.primitives.container import Container
      5 from carbonui.primitives.layoutGrid import LayoutGrid
      6 from eve.client.script.ui.control.eveLabel import EveLabelMedium
      7 from eve.client.script.ui.shared.fitting.fittingUtil import EatSignalChangingErrors
      8 from eve.client.script.ui.station.fitting.fittingTooltipUtils import SetFittingTooltipInfo
      9 from signals.signalUtil import ChangeSignalConnect
     10 
     11 class BaseMenuPanel(Container):
     12     default_iconSize = 32
     13 
     14     def ApplyAttributes(self, attributes):
     15         Container.ApplyAttributes(self, attributes)
     16         self.iconSize = attributes.get('iconSize', self.default_iconSize)
     17         self.controller = attributes.controller
     18         self.ChangeSignalConnection()
     19         self.dogmaLocation = self.controller.GetDogmaLocation()
     20         self.SetShipID(self.controller.GetItemID())
     21         self.panelLoaded = False
     22         self.ResetStatsDicts()
     23         panelName = attributes.name
     24         tooltipName = attributes.tooltipName
     25         labelHint = attributes.labelHint
     26         self.headerParent = self.GetHeaderStatsParent('%s_HeaderStatsParent' % panelName)
     27         self.statusText = self.GetHeaderLabel(self.headerParent)
     28         if labelHint:
     29             self.statusText.hint = labelHint
     30         if tooltipName:
     31             SetFittingTooltipInfo(targetObject=self.statusText, tooltipName=tooltipName)
     32 
     33     def ChangeSignalConnection(self, connect = True):
     34         signalAndCallback = [(self.controller.on_new_itemID, self.OnNewShipLoaded)]
     35         ChangeSignalConnect(signalAndCallback, connect)
     36 
     37     @eveui.skip_if_destroyed
     38     def OnNewShipLoaded(self, *args):
     39         self.SetDogmaLocation()
     40         self.SetShipID(self.controller.GetItemID())
     41 
     42     def SetDogmaLocation(self):
     43         self.dogmaLocation = self.controller.GetDogmaLocation()
     44 
     45     def SetShipID(self, shipID):
     46         self.shipID = shipID
     47 
     48     def FinalizePanelLoading(self, initialLoad = False):
     49         self.panelLoaded = True
     50         if not initialLoad:
     51             self.controller.UpdateStats()
     52 
     53     def ResetStatsDicts(self):
     54         self.statsLabelsByIdentifier = {}
     55         self.statsIconsByIdentifier = {}
     56         self.statsContsByIdentifier = {}
     57 
     58     def GetHeaderStatsParent(self, name):
     59         return Container(name=name, parent=None, align=uiconst.TORIGHT, state=uiconst.UI_PICKCHILDREN, width=200)
     60 
     61     def GetHeaderLabel(self, parent):
     62         return EveLabelMedium(text='', parent=parent, left=8, top=1, aidx=0, state=uiconst.UI_NORMAL, align=uiconst.CENTERRIGHT)
     63 
     64     def SetStatusText(self, text, hintText = None):
     65         self.statusText.text = text
     66         if hintText:
     67             self.statusText.hint = hintText
     68 
     69     def SetLabel(self, identifier, text):
     70         label = self.statsLabelsByIdentifier.get(identifier, None)
     71         if label:
     72             label.text = text
     73 
     74     def LoadIcon(self, identifier, iconID):
     75         icon = self.statsIconsByIdentifier.get(identifier, None)
     76         if icon:
     77             icon.LoadIcon(iconID, ignoreSize=True)
     78 
     79     def GetValueCont(self, iconSize):
     80         attributeCont = LayoutGrid(columns=3, state=uiconst.UI_NORMAL, align=uiconst.CENTERLEFT, padTop=1)
     81         attributeCont.AddCell()
     82         attributeCont.AddCell(cellObject=Container(name='widthSpacer', align=uiconst.TOLEFT, width=7 + iconSize))
     83         attributeCont.FillRow()
     84         attributeCont.AddCell(cellObject=Container(name='heightSpacer', align=uiconst.TOTOP, height=26))
     85         return attributeCont
     86 
     87     def GetValueParentGrid(self, columns = 2):
     88         self.state = uiconst.UI_PICKCHILDREN
     89         l, t, w, h = self.GetAbsolute()
     90         step = w / columns
     91         parentGrid = LayoutGrid(name='parentGrid', parent=self, columns=columns, state=uiconst.UI_PICKCHILDREN, align=uiconst.TOTOP)
     92         for i in xrange(columns):
     93             parentGrid.AddCell(cellObject=Container(name='spacer', align=uiconst.TOLEFT, width=step))
     94 
     95         return parentGrid
     96 
     97     def Close(self):
     98         with EatSignalChangingErrors(errorMsg='BaseMenuPanel'):
     99             self.ChangeSignalConnection(connect=False)
    100         self.controller = None
    101         Container.Close(self)
    102 
    103     def IsCurrentShipReady(self):
    104         if not self.controller or not self.controller.CurrentShipIsLoaded():
    105             return False
    106         return True