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

ship_stance_button.py (3628B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\ship_stance_button.py
      2 import blue
      3 import shipmode
      4 from carbonui import const as uiconst
      5 from carbonui.uicore import uicore
      6 from eve.client.script.ui.inflight.shipHud.leftSideButton import LeftSideButton
      7 from eve.client.script.ui.inflight.shipModuleButton.ramps import ShipModuleReactivationTimer
      8 from eve.client.script.ui.inflight.shipstance import ShipStanceButtonController
      9 
     10 class ShipStanceButton(LeftSideButton):
     11     __notifyevents__ = ['OnStanceActive']
     12 
     13     def ApplyAttributes(self, attributes):
     14         LeftSideButton.ApplyAttributes(self, attributes)
     15         self.shipID = None
     16         if attributes.stanceID is not None:
     17             self.SetAsStance(attributes.shipID, attributes.typeID, attributes.stanceID, attributes.stance)
     18         self.activationDelay = ShipModuleReactivationTimer(parent=self, idx=-1, height=self.height, width=self.width, state=uiconst.UI_DISABLED)
     19         self.activationDelay.display = False
     20         sm.RegisterNotify(self)
     21 
     22     def SetAsStance(self, shipID, typeID, stanceID, currentStanceID):
     23         self.shipID = shipID
     24         self.stanceID = stanceID
     25         self.typeID = typeID
     26         stanceData = shipmode.get_stance_data(typeID, stanceID)
     27         self.stanceName = stanceData.get_name()
     28         self.stanceDescription = stanceData.get_description()
     29         self.currentStanceID = currentStanceID
     30         self.commandName = stanceData.get_command_name()
     31         self.LoadIcon(stanceData.get_icon_num())
     32         self._UpdateStanceState(self.currentStanceID)
     33 
     34     def LoadTooltipPanel(self, tooltipPanel, *args):
     35         tooltipPanel.LoadGeneric1ColumnTemplate()
     36         tooltipPanel.cellSpacing = 6
     37         tooltipPanel.AddCommandTooltip(uicore.cmd.commandMap.GetCommandByName(self.commandName))
     38         tooltipPanel.AddLabelLarge(text=self.stanceName)
     39         tooltipPanel.AddLabelMedium(text=self.stanceDescription, color=(0.6, 0.6, 0.6, 1))
     40 
     41     def OnClick(self, *args):
     42         stanceBtnControllerClass = self.GetStanceBtnControllerClass()
     43         stanceBtnControllerClass().set_stance(self.stanceID, self.shipID, self.typeID)
     44 
     45     def OnStanceActive(self, shipID, stanceID):
     46         if self.shipID is None or self.shipID != shipID:
     47             return
     48         self._UpdateStanceState(stanceID)
     49         if stanceID != self.stanceID:
     50             try:
     51                 ship = sm.GetService('godma').GetItem(self.shipID)
     52                 switchTime = ship.stanceSwitchTime * const.MSEC
     53             except Exception:
     54                 switchTime = 0.0
     55 
     56             self.icon.opacity = 0.5
     57             if switchTime:
     58                 self.activationDelay.display = True
     59                 try:
     60                     self.activationDelay.AnimateTimer(blue.os.GetSimTime(), switchTime)
     61                 finally:
     62                     self.activationDelay.display = False
     63                     self.icon.opacity = 1.0
     64 
     65     def _UpdateStanceState(self, stanceID):
     66         if stanceID == self.stanceID:
     67             self.busy.state = uiconst.UI_DISABLED
     68         else:
     69             self.busy.state = uiconst.UI_HIDDEN
     70 
     71     def GetStanceBtnControllerClass(self):
     72         return ShipStanceButtonController
     73 
     74 
     75 class ShipStanceFittingButton(ShipStanceButton):
     76 
     77     def ApplyAttributes(self, attributes):
     78         ShipStanceButton.ApplyAttributes(self, attributes)
     79         self.controller = attributes.controller
     80 
     81     def GetStanceBtnControllerClass(self):
     82         return self.controller.GetStanceBtnControllerClass()
     83 
     84     def Close(self):
     85         self.controller = None
     86         ShipStanceButton.Close(self)