droneGroup.py (7787B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\drones\droneGroup.py 2 import eveicon 3 import evetypes 4 import trinity 5 from carbonui import TextColor, uiconst 6 from carbonui.control.buttonIcon import ButtonIcon 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from carbonui.uianimations import animations 9 from carbonui.uicore import uicore 10 from carbonui.util.various_unsorted import IsUnder 11 from eve.client.script.ui.control.listgroup import ListGroup as Group 12 from eve.client.script.ui.inflight.drones import droneSignals, dronesDragData, dronesUtil 13 from eve.client.script.ui.inflight.drones.buttonSeperatorLine import ButtonSeperatorLine 14 from eve.client.script.ui.inflight.drones.droneGroupsController import GetDroneGroupsController 15 from eve.client.script.ui.inflight.drones.dronesDragData import HasInBayDroneIDs, HasInSpaceDroneIDs 16 from eve.client.script.ui.inflight.drones.dronesUtil import LoadShortcutTooltip 17 from eve.client.script.ui.services.menuSvcExtras import droneFunctions 18 from localization import GetByLabel 19 20 class DroneSubGroup(Group): 21 isDragObject = True 22 23 def Startup(self, *etc): 24 super(DroneSubGroup, self).Startup(*etc) 25 self.ConstructButtonCont() 26 self.ConstructButtons() 27 if self.sr.fill: 28 self.sr.fill.opacity = 0.9 * self.sr.fill.opacity 29 30 def Load(self, node): 31 super(DroneSubGroup, self).Load(node) 32 self.sr.label.rgba = TextColor.HIGHLIGHT 33 34 def ConstructButtonCont(self): 35 self.buttonCont = ContainerAutoSize(name='buttonCont', align=uiconst.TORIGHT, parent=self, state=uiconst.UI_HIDDEN, padRight=4, opacity=0.0) 36 37 def ConstructButtons(self): 38 pass 39 40 def OnMouseEnter(self, *args): 41 super(DroneSubGroup, self).OnMouseEnter(*args) 42 self.ShowButtonCont() 43 uicore.uilib.RegisterForTriuiEvents(uiconst.UI_MOUSEENTER, self.OnGlobalMouseEnter) 44 45 def OnGlobalMouseEnter(self, obj, *args): 46 if obj and not (IsUnder(obj, self) or obj == self): 47 self.HideButtonCont() 48 return False 49 else: 50 return True 51 52 def ShowButtonCont(self): 53 self.buttonCont.Show() 54 animations.FadeTo(self.buttonCont, self.buttonCont.opacity, 1.0, duration=0.1) 55 56 def HideButtonCont(self): 57 animations.FadeTo(self.buttonCont, self.buttonCont.opacity, 0.0, duration=0.1, callback=self.buttonCont.Hide) 58 59 def _ConstructFill(self): 60 self.sr.fill = None 61 62 def GetDroneIDs(self): 63 return GetDroneGroupsController().GetDroneIDsInSubGroup(self.sr.node.droneState, self.sr.node.groupName) 64 65 def GetDroneIDsAndTypeIDs(self): 66 droneData = self.GetDronesData() 67 return [ (itemID, typeID) for itemID, typeID, _, _ in droneData ] 68 69 def GetDronesData(self): 70 return GetDroneGroupsController().GetDroneDataForSubGroup(self.sr.node.droneState, self.sr.node.groupName) 71 72 def _MoveToGroup(self, typeID, droneIDs): 73 GetDroneGroupsController().MoveToGroup(evetypes.GetGroupID(typeID), self.GetGroupName(), droneIDs) 74 75 def GetGroupName(self): 76 return self.sr.node.id[1][0] 77 78 def ShowIconGlow(self): 79 self.sr.icon.outputMode = uiconst.OUTPUT_COLOR_AND_GLOW 80 animations.MorphScalar(self.sr.icon, 'glowBrightness', self.sr.icon.glowBrightness, 1.0, duration=uiconst.TIME_ENTRY) 81 82 def OnDragExit(self, dragObj, drag, *args): 83 self.HideIconGlow() 84 85 def HideIconGlow(self): 86 animations.MorphScalar(self.sr.icon, 'glowBrightness', self.sr.icon.glowBrightness, 0.0, duration=uiconst.TIME_EXIT) 87 88 89 buttonSize = 20 90 91 class DroneSubGroupInBay(DroneSubGroup): 92 93 def ConstructButtons(self): 94 button = ButtonIcon(parent=self.buttonCont, align=uiconst.TORIGHT, width=buttonSize, iconSize=16, texturePath=eveicon.launch_drones, func=self.OnLaunchDronesButton, hint=GetByLabel('UI/Drones/LaunchDrones'), blendMode=trinity.TR2_SBM_ADD) 95 button.LoadTooltipPanel = self.LoadLaunchButtonTooltipPanel 96 97 def LoadLaunchButtonTooltipPanel(self, tooltipPanel, *args): 98 if self.sr.node.isFavorite: 99 return LoadShortcutTooltip(tooltipPanel, commandName='CmdLaunchFavoriteDrones') 100 command = uicore.cmd.commandMap.GetCommandByName('CmdLaunchFavoriteDrones') 101 tooltipPanel.LoadGeneric1ColumnTemplate() 102 tooltipPanel.AddLabelMedium(text=command.GetName()) 103 104 def OnLaunchDronesButton(self, *args): 105 droneFunctions.LaunchDrones(self.GetDroneIDs()) 106 107 def OnDragEnter(self, dragSource, dragData): 108 super(DroneSubGroupInBay, self).OnDragEnter(dragSource, dragData) 109 if HasInSpaceDroneIDs(dragData): 110 droneSignals.on_in_bay_entry_drag_enter() 111 else: 112 droneIDs = set(dronesDragData.GetInBayDroneIDs(dragData)) 113 if droneIDs.difference(self.GetDroneIDs()): 114 self.ShowIconGlow() 115 116 def GetDragData(self): 117 return dronesDragData.DronesInBayDragData(self.GetDroneIDs()) 118 119 def OnDropData(self, dragObj, dragData): 120 self.HideIconGlow() 121 inSpaceDroneIDs = dronesDragData.GetInSpaceDroneIDs(dragData) 122 if inSpaceDroneIDs: 123 droneFunctions.ReturnToDroneBay(inSpaceDroneIDs) 124 droneSignals.on_drones_dropped_to_bay() 125 inBayDroneIDs = dronesDragData.GetInBayDroneIDs(dragData) 126 if inBayDroneIDs: 127 self._MoveToGroup(dragData[0].GetTypeID(), inBayDroneIDs) 128 129 130 class DroneSubGroupInSpace(DroneSubGroup): 131 132 def ConstructButtons(self): 133 ButtonIcon(parent=self.buttonCont, align=uiconst.TORIGHT, width=buttonSize, iconSize=16, texturePath=eveicon.recall_drones, func=self.OnRecallDronesButton, hint=GetByLabel('UI/Drones/ReturnDroneToBay'), blendMode=trinity.TR2_SBM_ADD) 134 ButtonSeperatorLine(parent=self.buttonCont, align=uiconst.TORIGHT) 135 ButtonIcon(parent=self.buttonCont, align=uiconst.TORIGHT, width=buttonSize, iconSize=16, texturePath=eveicon.return_and_orbit, func=self.OnReturnAndOrbitButton, hint=GetByLabel('UI/Drones/ReturnDroneAndOrbit'), blendMode=trinity.TR2_SBM_ADD, padRight=4) 136 primaryActionBtn = ButtonIcon(name='primaryActionBtn', parent=self.buttonCont, align=uiconst.TORIGHT, width=buttonSize, iconSize=16, texturePath=eveicon.engage_target, func=self.OnPrimaryActionButton, blendMode=trinity.TR2_SBM_ADD) 137 primaryActionBtn.GetHint = self.GetPrimaryActionBtnHint 138 139 def GetPrimaryActionBtnHint(self): 140 dronesData = self.GetDronesData() 141 _, typeID, _, _ = dronesData[0] 142 return dronesUtil.GetPrimaryActionName(typeID) 143 144 def OnReturnAndOrbitButton(self, *args): 145 droneFunctions.ReturnAndOrbit(self.GetDroneIDs()) 146 147 def OnPrimaryActionButton(self, *args): 148 droneFunctions.PerformPrimaryAction(self.GetDroneIDsAndTypeIDs()) 149 150 def OnRecallDronesButton(self, *args): 151 droneFunctions.ReturnToDroneBay(self.GetDroneIDs()) 152 153 def OnDragEnter(self, dragSource, dragData): 154 if HasInBayDroneIDs(dragData): 155 droneSignals.on_in_space_entry_drag_enter() 156 else: 157 droneIDs = set(dronesDragData.GetInSpaceDroneIDs(dragData)) 158 if droneIDs.difference(self.GetDroneIDs()): 159 self.ShowIconGlow() 160 161 def GetDragData(self): 162 return dronesDragData.DronesInSpaceDragData(self.GetDroneIDs()) 163 164 def OnDropData(self, dragObj, dragData): 165 self.HideIconGlow() 166 inBayDroneIDs = dronesDragData.GetInBayDroneIDs(dragData) 167 if inBayDroneIDs: 168 droneFunctions.LaunchDrones(inBayDroneIDs) 169 droneSignals.on_drones_dropped_in_space() 170 inSpaceDroneIDs = dronesDragData.GetInSpaceDroneIDs(dragData) 171 if inSpaceDroneIDs: 172 self._MoveToGroup(dragData[0].GetTypeID(), inSpaceDroneIDs)