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

selectedItemButton.py (4015B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\selectedItemButton.py
      2 from carbon.client.script.environment.AudioUtil import PlaySound
      3 from carbonui import uiconst
      4 from carbonui.control.buttonIcon import ButtonIcon
      5 from carbonui.control.contextMenu.menuUtil import ClearMenuLayer
      6 from carbonui.primitives.sprite import Sprite
      7 from carbonui.uicore import uicore
      8 from eve.client.script.ui.crimewatch import crimewatchConst
      9 from eve.client.script.ui.inflight.selectedItemConst import RESET_ACTIONS
     10 from eve.client.script.ui.services.menuEntries import DroneEngageTargetMenuEntryData
     11 from eve.client.script.ui.services.menuSvcExtras.movementFunctions import SetDefaultDist, GetGlobalActiveItemKeyName
     12 from menu import MenuLabel
     13 
     14 class SelectedItemButton(ButtonIcon):
     15 
     16     def ApplyAttributes(self, attributes):
     17         self.menuEntryData = attributes.menuEntryData
     18         self.cmdName = attributes.cmdName
     19         self.disabledHint = attributes.disabledHint
     20         self.iconHoverColor = None
     21         super(SelectedItemButton, self).ApplyAttributes(attributes)
     22         if self.menuEntryData.GetLabelPath() in RESET_ACTIONS:
     23             Sprite(texturePath='res:/UI/Texture/icons/44_32_8.png', parent=self, align=uiconst.TOALL, state=uiconst.UI_DISABLED, idx=0)
     24 
     25     def LoadTooltipPanel(self, tooltipPanel, *args):
     26         tooltipPanel.LoadGeneric2ColumnTemplate()
     27         shortcutString = uicore.cmd.GetShortcutStringByFuncName(self.cmdName)
     28         tooltipPanel.AddLabelShortcut(self._GetActionLabel(), shortcutString)
     29         if self.disabledHint:
     30             tooltipPanel.AddLabelMedium(text=self.disabledHint, colSpan=tooltipPanel.columns)
     31 
     32     def _GetActionLabel(self):
     33         return self.menuEntryData.GetTextDescriptive()
     34 
     35     def GetTooltipPointer(self):
     36         return uiconst.POINT_TOP_2
     37 
     38     def GetMenu(self):
     39         m = []
     40         label = ''
     41         key = GetGlobalActiveItemKeyName(self.menuEntryData.GetLabelPath())
     42         if key == 'Orbit':
     43             label = MenuLabel('UI/Inflight/SetDefaultOrbitDistance', {'typeName': self.menuEntryData.GetLabelPath()})
     44         elif key == 'KeepAtRange':
     45             label = MenuLabel('UI/Inflight/SetDefaultKeepAtRangeDistance', {'typeName': self.menuEntryData.GetLabelPath()})
     46         elif key == 'WarpTo':
     47             label = MenuLabel('UI/Inflight/SetDefaultWarpWithinDistance', {'typeName': self.menuEntryData.GetLabelPath()})
     48         if len(label) > 0:
     49             m.append((label, SetDefaultDist, (key,)))
     50         return m
     51 
     52     def OnMouseEnter(self, *args):
     53         if not self.IsEnabled():
     54             return
     55         super(SelectedItemButton, self).OnMouseEnter(*args)
     56         PlaySound(uiconst.SOUND_BUTTON_HOVER)
     57         self._GetCrimewatchIconColor()
     58 
     59     def _GetCrimewatchIconColor(self):
     60         if isinstance(self.menuEntryData, DroneEngageTargetMenuEntryData):
     61             crimewatchSvc = sm.GetService('crimewatchSvc')
     62             targetID = sm.GetService('target').GetActiveTargetID()
     63             requiredSafetyLevel = crimewatchSvc.GetRequiredSafetyLevelForEngagingDrones(self.menuEntryData.droneIDs, targetID)
     64             if crimewatchSvc.CheckUnsafe(requiredSafetyLevel):
     65                 if requiredSafetyLevel == const.shipSafetyLevelNone:
     66                     return crimewatchConst.Colors.Criminal.GetRGBA()
     67                 else:
     68                     return crimewatchConst.Colors.Suspect.GetRGBA()
     69 
     70     def _GetIconHoverColor(self):
     71         if self.iconHoverColor is None:
     72             self.iconHoverColor = self._GetCrimewatchIconColor() or super(SelectedItemButton, self)._GetIconHoverColor()
     73         return self.iconHoverColor
     74 
     75     def _ExecuteFunction(self):
     76         if self.uniqueUiName:
     77             sm.ScatterEvent('OnSelectedItemButtonClicked', self.uniqueUiName)
     78         super(SelectedItemButton, self)._ExecuteFunction()
     79         sm.StartService('ui').StopBlink(self)
     80         ClearMenuLayer()
     81 
     82     def GetActionID(self):
     83         return self.menuEntryData.GetLabelPath()