radialMenuShipUI.py (5528B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\radialMenuShipUI.py 2 from carbonui import uiconst 3 from carbonui.uicore import uicore 4 from eve.client.script.ui.control import eveLabel 5 from eve.client.script.ui.control.tooltips import ShortcutHint 6 from eve.client.script.ui.shared.radialMenu.radialMenu import RadialMenu 7 from eve.client.script.ui.shared.radialMenu.radialMenu import ThreePartContainer 8 from eve.client.script.ui.shared.radialMenu.radialMenuUtils import RadialMenuSizeInfo 9 RM1_SizeInfo = RadialMenuSizeInfo(width=118, height=118, shadowSize=104, rangeSize=50, sliceCount=4, buttonWidth=84, buttonHeight=49, buttonPaddingTop=5, buttonPaddingBottom=5, actionDistance=59) 10 11 class RadialMenuShipUI(RadialMenu): 12 default_left = 0 13 default_top = 0 14 default_align = uiconst.TOPLEFT 15 default_width = RM1_SizeInfo.width 16 default_height = RM1_SizeInfo.height 17 sizeInfo = RM1_SizeInfo 18 default_showActionText = True 19 shadowTexture = 'res:/UI/Texture/classes/RadialMenu/menuShadow3.png' 20 buttonBackgroundOpacity = 0.9 21 22 def SetSpecificValues(self, attributes): 23 self.anchorObject = attributes.anchorObject 24 self.displayName = attributes.displayName 25 self.upCounter = 0 26 27 def SetPosition(self): 28 left, top, width, height = self.anchorObject.GetAbsolute() 29 self.originalX = self.currentCenterX = left + width / 2 30 self.originalY = self.currentCenterY = top + height / 2 31 self.left = self.originalX - self.width / 2 32 self.top = self.originalY - self.height / 2 33 34 def LoadMyActions(self, doReset = False, animate = False, *args): 35 optionsInfo = self.GetMyActions() 36 if optionsInfo is None: 37 return 38 self.LoadButtons(self.firstLayerCont, optionsInfo, doReset=doReset) 39 if animate: 40 self.AnimateMenuFromCenter(duration=0.1) 41 42 def GetMyActions(self, *args): 43 pass 44 45 def AdjustTextShadow(self, *args): 46 if not self.optionLabel.display: 47 if getattr(self, 'labelShadow', None): 48 self.labelShadow.display = False 49 return 50 shorcutPadding = self.GetPaddingBecauseOfShortcut() 51 centerWidth = self.optionLabel.textwidth + shorcutPadding 52 self.optionLabel.left = -shorcutPadding / 2 53 height = self.optionLabel.textheight + 4 54 top = -18 55 self.labelShadow.display = True 56 self.labelShadow.SetCenterSizeAndTop(centerWidth, height, top=top) 57 58 def GetPaddingBecauseOfShortcut(self): 59 if not self.shortcutHint.textLabel.text: 60 return 0 61 return self.shortcutHint.width + 5 62 63 def AddOptionText(self): 64 self.labelShadow = ThreePartContainer(parent=self, name='labelShadow', pos=(0, 0, 200, 30), align=uiconst.CENTERTOP, state=uiconst.UI_DISABLED, idx=0, leftTexturePath='res:/UI/Texture/classes/RadialMenu/textShadowLeft.png', rightTexturePath='res:/UI/Texture/classes/RadialMenu/textShadowRight.png', centerTexturePath='res:/UI/Texture/classes/RadialMenu/textShadowCenter.png', sideSize=24, color=(0, 0, 0, 0.6)) 65 self.labelShadow.display = False 66 self.shortcutHint = ShortcutHint(parent=self.labelShadow, text='', bgColor=(0.15, 0.15, 0.15, 1.0), textColor=(0.5, 0.5, 0.5, 1.0), align=uiconst.CENTERRIGHT, left=24, idx=0) 67 self.optionLabel = eveLabel.EveLabelLarge(parent=self.labelShadow, state=uiconst.UI_DISABLED, align=uiconst.CENTER, top=0, idx=0, bold=True) 68 self.optionLabel.display = False 69 self.AdjustTextShadow() 70 71 def GetIconTexturePath(self, activeOption, menuOptions = None): 72 return menuOptions.iconPath 73 74 def OnMouseUp(self, button, *args): 75 uicore.uilib.UnclipCursor() 76 self.cursorClipped = False 77 self.upCounter += 1 78 radialMenuBtn = self.GetRadialMenuButton() 79 if button != radialMenuBtn: 80 self.Close() 81 if self.selectedBtn: 82 self.ClickButton(self.selectedBtn) 83 elif self.upCounter > 1: 84 self.Close() 85 86 def OnMouseUpBlocker(self, button, *args): 87 RadialMenu.OnMouseUp(self, button, *args) 88 89 def IsRadialMenuButtonActive(self, *args): 90 if self.upCounter: 91 return False 92 menuButton = self.GetRadialMenuButton() 93 actionmenuBtnState = uicore.uilib.GetMouseButtonState(menuButton) 94 return actionmenuBtnState 95 96 def GetRadialMenuButton(self, *args): 97 return uiconst.MOUSELEFT 98 99 def HiliteOneButton(self, btnCont, buttonLayer): 100 RadialMenu.HiliteOneButton(self, btnCont, buttonLayer) 101 self.SetShortcut(btnCont) 102 self.AdjustTextShadow() 103 104 def SetShortcut(self, btnCont): 105 shortcutStr = self.GetShortcutString(btnCont) 106 if not shortcutStr: 107 return self.ClearShortcutHint() 108 self.shortcutHint.display = True 109 self.shortcutHint.textLabel.text = shortcutStr 110 self.shortcutHint.AdjustSize() 111 112 def GetShortcutString(self, btnCont): 113 if not btnCont or not btnCont.actionButton: 114 return 115 commandName = getattr(btnCont.actionButton, 'commandName', None) 116 if not commandName: 117 return 118 command = uicore.cmd.commandMap.GetCommandByName(commandName) 119 if not command: 120 return 121 shortcutStr = command.GetShortcutAsString() 122 return shortcutStr 123 124 def ClearShortcutHint(self): 125 self.shortcutHint.textLabel.text = '' 126 self.shortcutHint.display = False