fighterDebugWindow.py (10079B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\squadrons\fighterDebugWindow.py 2 from carbonui import uicore, uiconst 3 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText 4 from carbonui.control.buttonIcon import ButtonIcon 5 from carbonui.control.button import Button 6 from carbonui.primitives.container import Container 7 from carbonui.primitives.containerAutoSize import ContainerAutoSize 8 from eve.client.script.ui.control.eveLabel import EveLabelSmall 9 from carbonui.control.window import Window 10 from fighters import ABILITY_SLOT_0, ABILITY_SLOT_1, ABILITY_SLOT_2 11 from spacecomponents.client.components.behavior import EnableDebugging 12 from carbonui.uicore import uicore 13 import geo2 14 15 class FighterDebugWindow(Window): 16 default_windowID = 'FighterDebugWindow' 17 default_width = 250 18 default_height = 360 19 default_caption = 'Fighter debugger' 20 default_icon = '41_13' 21 currentFighterID = None 22 23 def ApplyAttributes(self, attributes): 24 Window.ApplyAttributes(self, attributes) 25 self.MakeUnResizeable() 26 self.Layout() 27 self.SetMinSize([350, 500], refresh=True) 28 29 def Layout(self): 30 fighter_cont = Container(parent=self.content, align=uiconst.TOTOP, height=Button.default_height, padBottom=8) 31 EveLabelSmall(text='Fighter ID', parent=ContainerAutoSize(parent=fighter_cont, align=uiconst.TOLEFT), align=uiconst.CENTERLEFT, padRight=8) 32 self.fighterIDBox = SingleLineEditText(name='fighterID', parent=fighter_cont, align=uiconst.TOLEFT, OnChange=self.OnFighterIDBoxChange, padRight=8) 33 self.fighterIDBox.SetText(self._GetFighterID()) 34 Button(parent=fighter_cont, name='DebugFighter', label='DBG', func=self.OnDebugFighterButton, align=uiconst.TOLEFT) 35 target_cont = ContainerAutoSize(parent=self.content, align=uiconst.TOTOP, height=Button.default_height, padBottom=8) 36 EveLabelSmall(text='Target ID', parent=ContainerAutoSize(parent=target_cont, align=uiconst.TOLEFT), align=uiconst.CENTERLEFT, padRight=8) 37 self.targetIDBox = SingleLineEditText(parent=target_cont, name='targetID', align=uiconst.TOLEFT) 38 self.targetIDBox.SetText(session.shipid) 39 orbit_container = ContainerAutoSize(parent=self.content, align=uiconst.TOTOP, height=Button.default_height, padBottom=8) 40 Button(parent=orbit_container, name='OrbitTarget', label='Orbit Target', func=self.OnOrbitTargetButton, align=uiconst.TOLEFT, padRight=8) 41 Button(name='OrbitMe', parent=orbit_container, label='Orbit Me', func=self.OnOrbitMeButton, align=uiconst.TOLEFT) 42 Button(name='StopMovement', label='Stop movement', func=self.OnMoveStopButton, parent=ContainerAutoSize(parent=self.content, align=uiconst.TOTOP, padBottom=8), align=uiconst.TOPLEFT) 43 xyz_container = ContainerAutoSize(parent=self.content, align=uiconst.TOTOP, height=Button.default_height, padBottom=8) 44 EveLabelSmall(text='x,y,z', parent=ContainerAutoSize(parent=xyz_container, align=uiconst.TOLEFT), align=uiconst.CENTERLEFT, padRight=8) 45 self.gotoPosBox = SingleLineEditText(name='gotoPos', parent=xyz_container, align=uiconst.TOLEFT) 46 ButtonIcon(name='pickXYZ', parent=xyz_container, align=uiconst.TOLEFT, width=16, iconSize=16, texturePath='res:/UI/Texture/Icons/38_16_150.png', hint='Pick random position near target', func=self.OnPickXYZ) 47 point_container = ContainerAutoSize(parent=self.content, align=uiconst.TOTOP, height=Button.default_height, padBottom=8) 48 Button(parent=point_container, name='GotoPoint', label='Goto this point', func=self.OnGotoPointButton, align=uiconst.TOLEFT, padRight=8) 49 Button(parent=point_container, name='ToggleMoveMode', label='Toggle Movement', func=self.OnToggleMoveButton, align=uiconst.TOLEFT) 50 EveLabelSmall(text='Ability 0', parent=self.content, align=uiconst.TOTOP, padBottom=8) 51 ability0_btns_container = ContainerAutoSize(parent=self.content, align=uiconst.TOTOP, height=Button.default_height, padBottom=8) 52 Button(parent=ability0_btns_container, name='ActivateAbilityOnTarget', label='Activate (target)', func=self.OnActivateAbilityOnTarget, args=(ABILITY_SLOT_0,), align=uiconst.TOLEFT, padRight=8) 53 Button(parent=ability0_btns_container, name='ActivateAbilityOnSelf', label='Activate (self)', func=self.OnActivateAbilityOnSelf, args=(ABILITY_SLOT_0,), align=uiconst.TOLEFT, padRight=8) 54 Button(parent=ability0_btns_container, name='DeactivateAbility', label='Deactivate', func=self.OnDeactivateAbility, args=(ABILITY_SLOT_0,), align=uiconst.TOLEFT) 55 EveLabelSmall(text='Ability 1', align=uiconst.TOTOP, parent=self.content, padBottom=8) 56 ability1_btns_container = ContainerAutoSize(parent=self.content, align=uiconst.TOTOP, height=Button.default_height, padBottom=8) 57 Button(parent=ability1_btns_container, name='ActivateAbilityOnTarget', label='Activate (target)', func=self.OnActivateAbilityOnTarget, args=(ABILITY_SLOT_1,), align=uiconst.TOLEFT, padRight=8) 58 Button(parent=ability1_btns_container, name='ActivateAbilityOnSelf', label='Activate (self)', func=self.OnActivateAbilityOnSelf, args=(ABILITY_SLOT_1,), align=uiconst.TOLEFT, padRight=8) 59 Button(parent=ability1_btns_container, name='DeactivateAbility', label='Deactivate', func=self.OnDeactivateAbility, args=(ABILITY_SLOT_1,), align=uiconst.TOLEFT) 60 EveLabelSmall(text='Ability 2', align=uiconst.TOTOP, parent=self.content, padBottom=8) 61 ability2_btns_container = ContainerAutoSize(parent=self.content, align=uiconst.TOTOP, height=Button.default_height, padBottom=8) 62 Button(parent=ability2_btns_container, name='ActivateAbilityOnTarget', label='Activate (target)', func=self.OnActivateAbilityOnTarget, args=(ABILITY_SLOT_2,), align=uiconst.TOLEFT, padRight=8) 63 Button(parent=ability2_btns_container, name='ActivateAbilityOnSelf', label='Activate (self)', func=self.OnActivateAbilityOnSelf, args=(ABILITY_SLOT_2,), align=uiconst.TOLEFT, padRight=8) 64 Button(parent=ability2_btns_container, name='DeactivateAbility', label='Deactivate', func=self.OnDeactivateAbility, args=(ABILITY_SLOT_2,), align=uiconst.TOLEFT) 65 66 def _GetFighterID(self): 67 return self.currentFighterID 68 69 def _GetTargetID(self): 70 try: 71 return int(self.targetIDBox.text.strip()) 72 except ValueError: 73 return None 74 75 def OnFighterIDBoxChange(self, *args): 76 try: 77 self.currentFighterID = int(self.fighterIDBox.text.strip()) 78 except ValueError: 79 pass 80 81 def OnDebugFighterButton(self, *args): 82 self._OnDebugFighterButton(*args) 83 84 def _OnDebugFighterButton(self, *args): 85 fighterID = self._GetFighterID() 86 if fighterID is not None: 87 EnableDebugging(fighterID) 88 89 def OnPickXYZ(self, *args): 90 self._OnPickXYZ(*args) 91 92 def _OnPickXYZ(self, *args): 93 michelle = sm.GetService('michelle') 94 targetID = self._GetTargetID() or session.shipid 95 ball = michelle.GetBall(targetID) 96 if ball: 97 import random 98 shipPos = geo2.VectorD(ball.x, ball.y, ball.z) 99 offsetRange = ball.radius + 2000 100 offset = geo2.Vector(random.uniform(-1, 1), random.uniform(-1, 1), random.uniform(-1, 1)) 101 targetPos = geo2.Vec3AddD(shipPos, geo2.Vec3Scale(geo2.Vec3Normalize(offset), offsetRange)) 102 self.gotoPosBox.SetText('%.0f, %.0f, %0.f' % (targetPos[0], targetPos[1], targetPos[2])) 103 104 def OnGotoPointButton(self, *args): 105 self._OnGotoPointButton(*args) 106 107 def _OnGotoPointButton(self, *args): 108 fighterID = self._GetFighterID() 109 if fighterID is not None: 110 point = geo2.VectorD([ float(v.strip()) for v in self.gotoPosBox.text.strip().split(',') ]) 111 sm.GetService('fighters').CmdGotoPoint([fighterID], list(point)) 112 113 def OnToggleMoveButton(self, *args): 114 self._OnOnToggleMoveButton(*args) 115 116 def _OnOnToggleMoveButton(self, *args): 117 uicore.layer.inflight.positionalControl.StartMoveCommand() 118 119 def OnOrbitTargetButton(self, *args): 120 self._OnOrbitTargetButton(*args) 121 122 def _OnOrbitTargetButton(self, *args): 123 fighterID = self._GetFighterID() 124 targetID = self._GetTargetID() 125 if fighterID is not None and targetID is not None: 126 sm.GetService('fighters').CmdMovementOrbit([fighterID], targetID, 5000) 127 128 def OnOrbitMeButton(self, *args): 129 self._OnOrbitMeButton(*args) 130 131 def _OnOrbitMeButton(self, *args): 132 fighterID = self._GetFighterID() 133 if fighterID is not None: 134 sm.GetService('fighters').CmdMovementOrbit([fighterID], session.shipid, 5000) 135 136 def OnMoveStopButton(self, *args): 137 self._OnMoveStopButton(*args) 138 139 def _OnMoveStopButton(self, *args): 140 fighterID = self._GetFighterID() 141 if fighterID is not None: 142 sm.GetService('fighters').CmdMovementStop([fighterID]) 143 144 def OnActivateAbilityOnTarget(self, abilitySlotID): 145 self._OnActivateAbilityOnTarget(abilitySlotID) 146 147 def _OnActivateAbilityOnTarget(self, abilitySlotID): 148 fighterID = self._GetFighterID() 149 targetID = self._GetTargetID() 150 if fighterID is not None and targetID is not None: 151 sm.GetService('fighters').ActivateAbilitySlotsOnTarget([fighterID], abilitySlotID, targetID) 152 153 def OnActivateAbilityOnSelf(self, abilitySlotID): 154 self._OnActivateAbilityOnSelf(abilitySlotID) 155 156 def _OnActivateAbilityOnSelf(self, abilitySlotID): 157 fighterID = self._GetFighterID() 158 if fighterID is not None: 159 sm.GetService('fighters').ActivateAbilitySlotsOnSelf([fighterID], abilitySlotID) 160 161 def OnDeactivateAbility(self, abilitySlotID): 162 self._OnDeactivateAbility(abilitySlotID) 163 164 def _OnDeactivateAbility(self, abilitySlotID): 165 fighterID = self._GetFighterID() 166 if fighterID is not None: 167 sm.GetService('fighters').DeactivateAbilitySlots([fighterID], abilitySlotID)