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

spaceRadialMenuFunctions.py (37196B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\radialMenu\spaceRadialMenuFunctions.py
      2 import types
      3 import logging
      4 import eveicon
      5 from carbonui.control.contextMenu.menuEntryData import BaseMenuEntryData
      6 from collections import OrderedDict
      7 from menu import MenuLabel, CaptionIsInMultiFunctions
      8 from eve.client.script.ui.shared.radialMenu import NORMAL_RADIAL_MENU, BROADCAST_RADIAL_MENU
      9 from eve.client.script.ui.shared.radialMenu.broadcastRadialMenuFunctions import GetBroadcastForShieldMenuAction, GetBroadcastForArmorMenuAction, GetBroadcastForCapacitorMenuAction, GetBroadcastTargetMenuAction, GetBroadcastAlignToMenuAction, GetBroadcastWarpToMenuAction
     10 from eve.client.script.ui.util.uix import GetBallparkRecord
     11 from eve.common.script.sys.eveCfg import GetActiveShip
     12 from eve.common.script.sys.idCheckers import IsCharacter
     13 import inventorycommon.const as invConst
     14 import carbonui.const as uiconst
     15 import evetypes
     16 from eve.client.script.ui.services.menuSvcExtras.movementFunctions import KeepAtRange as movementFunctions__KeepAtRange
     17 from eve.client.script.ui.services.menuSvcExtras.movementFunctions import Orbit as movementFunctions__Orbit
     18 from eve.client.script.ui.services.menuSvcExtras.movementFunctions import GetWarpToRanges as movementFunctions__GetWarpToRanges
     19 from eve.client.script.ui.services.menuSvcExtras.movementFunctions import WarpToBookmark as movementFunctions__WarpToBookmark
     20 from eve.client.script.ui.services.menuSvcExtras.movementFunctions import WarpToItem as movementFunctions__WarpToItem
     21 import eve.client.script.ui.util.defaultRangeUtils as defaultRangeUtils
     22 from eve.client.script.ui.shared.radialMenu.radialMenuUtils import RadialMenuOptionsInfo
     23 from eve.client.script.ui.shared.radialMenu.radialMenuUtils import RangeRadialMenuAction
     24 from eve.client.script.ui.shared.radialMenu.radialMenuUtils import SecondLevelRadialMenuAction
     25 from eve.client.script.ui.shared.radialMenu.radialMenuUtils import SimpleRadialMenuAction
     26 from carbonui.uiconst import MOUSEBUTTONS
     27 from eve.client.script.ui.inflight.dungeoneditor import DungeonEditor
     28 from spacecomponents.common.componentConst import FITTING_CLASS, SCOOP_CLASS, CARGO_BAY
     29 from spacecomponents.common.data import get_space_component_names_for_type
     30 from spacecomponents.common.helper import HasMicroJumpDriverComponent, HasItemTrader, HasShipcasterComponent, HasUnderConstructionComponent, HasTowGameObjectiveComponent, HasStarterShipcasterComponent
     31 from structures import FLEX_STRUCTURE_TYPES
     32 from utillib import KeyVal
     33 from carbonui.uicore import uicore
     34 from eveservices.menu import GetMenuService
     35 logger = logging.getLogger(__name__)
     36 primaryCategoryActions = {invConst.categoryDrone: [SimpleRadialMenuAction(option1='UI/Drones/EngageTarget', option2='UI/Drones/LaunchDrone')],
     37  invConst.categoryShip: [SimpleRadialMenuAction(option1='UI/Inflight/BoardShip')],
     38  invConst.categoryStation: [SimpleRadialMenuAction(option1='UI/Inflight/DockInStation', option2='UI/Inflight/JumpThroughStargate', option3Path='UI/Inflight/JumpThroughJumpgate', option4Path='UI/Inflight/SetDestination')],
     39  invConst.categoryStructure: [SimpleRadialMenuAction(option1='UI/Inflight/DockInStation', option2='UI/Inflight/JumpThroughStargate', option3Path='UI/Inflight/JumpThroughJumpgate', option4Path='UI/Inflight/SetDestination')],
     40  invConst.categoryAsteroid: [SimpleRadialMenuAction(option1='UI/Inflight/SetDestination')]}
     41 primaryGroupActions = {invConst.groupAgentsinSpace: [SimpleRadialMenuAction(option1='UI/Chat/StartConversation')],
     42  invConst.groupDestructibleAgentsInSpace: [SimpleRadialMenuAction(option1='UI/Chat/StartConversation')],
     43  invConst.groupAuditLogSecureContainer: [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')],
     44  invConst.groupBillboard: [SimpleRadialMenuAction(option1='UI/Commands/ReadNews')],
     45  invConst.groupBiomass: [SimpleRadialMenuAction(option1='UI/Inflight/ScoopToCargoHold')],
     46  invConst.groupCargoContainer: [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')],
     47  invConst.groupSecureCargoContainer: [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')],
     48  invConst.groupMissionContainer: [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')],
     49  invConst.groupFreightContainer: [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')],
     50  invConst.groupMiningDrone: [SimpleRadialMenuAction(option1='UI/Drones/MineWithDrone', option2='UI/Drones/LaunchDrone')],
     51  invConst.groupPlanet: [SimpleRadialMenuAction(option1='UI/PI/Common/ViewInPlanetMode', option2='UI/Inflight/SetDestination')],
     52  invConst.groupSalvageDrone: [SimpleRadialMenuAction(option1='UI/Drones/Salvage', option2='UI/Drones/LaunchDrone')],
     53  invConst.groupStargate: [SimpleRadialMenuAction(option1='UI/Inflight/Jump', option2='UI/Inflight/SetDestination')],
     54  invConst.groupWormhole: [SimpleRadialMenuAction(option1='UI/Inflight/EnterWormhole')],
     55  invConst.groupWreck: [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')],
     56  invConst.groupWarpGate: [SimpleRadialMenuAction(option1='UI/Inflight/ActivateGate')],
     57  invConst.groupAbyssalTraces: [SimpleRadialMenuAction(option1='UI/Inflight/ActivateGate')],
     58  invConst.groupSpawnContainer: [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')],
     59  invConst.groupSpewContainer: [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')],
     60  invConst.groupTitan: [SimpleRadialMenuAction(option1='UI/Inflight/BoardShip', option2='UI/Fleet/JumpThroughToSystem')],
     61  invConst.groupBlackOps: [SimpleRadialMenuAction(option1='UI/Inflight/BoardShip', option2='UI/Fleet/JumpThroughToSystem')],
     62  invConst.groupCapitalIndustrialShip: [SimpleRadialMenuAction(option1='UI/Inflight/BoardShip', option2='UI/Fleet/JumpThroughToSystem')],
     63  invConst.groupOrbitalInfrastructure: [SimpleRadialMenuAction(option1='UI/PI/Common/AccessCustomOffice')],
     64  invConst.groupSkyhook: [SimpleRadialMenuAction(option1='UI/PI/Common/AccessCustomOffice')],
     65  invConst.groupSolarSystem: [SimpleRadialMenuAction(option1='UI/Inflight/JumpThroughStargate', option2='UI/Inflight/JumpThroughJumpgate', option3Path='UI/Inflight/SetDestination')],
     66  invConst.groupMoon: [SimpleRadialMenuAction(option1='UI/Inflight/SetDestination')],
     67  invConst.groupSun: [SimpleRadialMenuAction(option1='UI/Inflight/SetDestination')],
     68  invConst.groupIndustrialCommandShip: [SimpleRadialMenuAction(option1='UI/Inflight/BoardShip', option2='UI/Commands/OpenFleetHangar')],
     69  invConst.groupAssemblyArray: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSStorage')],
     70  invConst.groupControlTower: [SimpleRadialMenuAction(option1='UI/Inflight/POS/ManageControlTower')],
     71  invConst.groupCorporateHangarArray: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSStorage')],
     72  invConst.groupMobileLaboratory: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSStorage')],
     73  invConst.groupMobileLaserSentry: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSCrystalStorage')],
     74  invConst.groupMobileMissileSentry: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSAmmo')],
     75  invConst.groupMobileHybridSentry: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSAmmo')],
     76  invConst.groupMobileProjectileSentry: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSAmmo')],
     77  invConst.groupMobileReactor: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSStorage')],
     78  invConst.groupPersonalHangar: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSStorage')],
     79  invConst.groupReprocessingArray: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSRefinery')],
     80  invConst.groupCompressionArray: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSCompression')],
     81  invConst.groupShipMaintenanceArray: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSVessels')],
     82  invConst.groupSilo: [SimpleRadialMenuAction(option1='UI/Inflight/POS/AccessPOSStorage')],
     83  invConst.groupInfrastructureHub: [SimpleRadialMenuAction(option1='UI/Menusvc/OpenHubManager')],
     84  invConst.groupControlBunker: [SimpleRadialMenuAction(option1='UI/FactionWarfare/IHub/OpenInfrastructureHubPanel')],
     85  invConst.groupDeadspaceOverseersBelongings: [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')]}
     86 primaryTypeActions = {invConst.typeUpwellSmallStargate: [SimpleRadialMenuAction(option1='UI/Inflight/JumpUsingBridge')],
     87  invConst.typeNeedlejackTrace: [SimpleRadialMenuAction(option1='UI/Inflight/ActivateTraceGate')],
     88  invConst.typeYoiulTrace: [SimpleRadialMenuAction(option1='UI/Inflight/ActivateTraceGate')],
     89  invConst.typeTriglavianSpaceTrace: [SimpleRadialMenuAction(option1='UI/Inflight/ActivateTraceGate')]}
     90 bookMarkOption = SimpleRadialMenuAction(option1='UI/Inflight/BookmarkLocation', option2='UI/Inflight/EditBookmark')
     91 lookAtOption = SimpleRadialMenuAction(option1='UI/Inflight/LookAtObject', option2='UI/Inflight/ResetCamera')
     92 setInterestOption = SimpleRadialMenuAction(option1='UI/Inflight/SetAsCameraInterest')
     93 bookMarkAndLookatOptions = [lookAtOption, bookMarkOption, setInterestOption]
     94 secondaryCategoryActions = {invConst.categoryAsteroid: bookMarkAndLookatOptions,
     95  invConst.categoryEntity: [lookAtOption, setInterestOption],
     96  invConst.categoryShip: [lookAtOption, setInterestOption],
     97  invConst.categoryStation: bookMarkAndLookatOptions,
     98  invConst.categoryStructure: bookMarkAndLookatOptions + [SimpleRadialMenuAction(option1='UI/Inflight/AccessHangarTransfer')],
     99  invConst.categoryStarbase: bookMarkAndLookatOptions,
    100  invConst.categorySovereigntyStructure: bookMarkAndLookatOptions,
    101  invConst.categoryCelestial: bookMarkAndLookatOptions,
    102  invConst.categoryOrbital: bookMarkAndLookatOptions,
    103  invConst.categoryDeployable: bookMarkAndLookatOptions,
    104  invConst.categoryFighter: [lookAtOption, setInterestOption],
    105  invConst.categoryDrone: [lookAtOption, setInterestOption] + [SimpleRadialMenuAction(option1='UI/Drones/ReturnDroneAndOrbit'),
    106                           SimpleRadialMenuAction(option1='UI/Inflight/ScoopToCargoHold'),
    107                           SimpleRadialMenuAction(option1='UI/Drones/ReturnDroneToBay'),
    108                           SimpleRadialMenuAction(),
    109                           SimpleRadialMenuAction(option1='UI/Drones/ScoopDroneToBay')]}
    110 secondaryGroupActions = {invConst.groupAuditLogSecureContainer: [SimpleRadialMenuAction(option1='UI/Inflight/ScoopToCargoHold')],
    111  invConst.groupBillboard: [bookMarkOption],
    112  invConst.groupMoon: [SimpleRadialMenuAction(), SimpleRadialMenuAction(), SimpleRadialMenuAction(option1='UI/Inflight/WarpToMoonMiningPoint')],
    113  invConst.groupSkyhook: [SimpleRadialMenuAction(option1='UI/OrbitalSkyhook/SkyhookWnd/AccessOrbitalSkyhookOffice')],
    114  invConst.groupMercenaryDen: [SimpleRadialMenuAction(option1='UI/Sovereignty/MercenaryDen/ConfigurationWindow/ConfigureMercenaryDen')]}
    115 secondaryTypeActions = {}
    116 for typeID in FLEX_STRUCTURE_TYPES:
    117     secondaryTypeActions[typeID] = [SimpleRadialMenuAction(option1='UI/Inflight/BoardStructure')]
    118 
    119 secondaryTypeActions[invConst.typeUpwellAutoMoonMiner] += [SimpleRadialMenuAction(option1='UI/Inflight/OpenMoonMaterialBay')]
    120 subMenusToExpand = ['UI/Inflight/MoonMiningPoint']
    121 placeholderIconPath = 'res:/UI/Texture/Icons/9_64_13.png'
    122 iconDict = {'UI/Commands/ShowInfo': 'res:/UI/Texture/Icons/44_32_24.png',
    123  'UI/Inflight/ApproachObject': 'res:/UI/Texture/Icons/44_32_23.png',
    124  'UI/Inflight/ApproachLocationActionGroup': 'res:/UI/Texture/Icons/44_32_23.png',
    125  'UI/Inflight/AlignTo': 'res:/UI/Texture/Icons/44_32_59.png',
    126  'UI/Inflight/OrbitObject': 'res:/UI/Texture/Icons/44_32_21.png',
    127  'UI/Inflight/Submenus/KeepAtRange': 'res:/UI/Texture/Icons/44_32_22.png',
    128  'UI/Inflight/LockTarget': 'res:/UI/Texture/Icons/44_32_17.png',
    129  'UI/Inflight/UnlockTarget': 'res:/UI/Texture/classes/RadialMenuActions/untarget.png',
    130  'UI/Inflight/CancelLockTarget': 'res:/UI/Texture/classes/RadialMenuActions/untarget.png',
    131  'UI/Inflight/LookAtObject': 'res:/UI/Texture/Icons/44_32_20.png',
    132  'UI/Inflight/ResetCamera': 'res:/UI/Texture/classes/RadialMenuActions/resetCamera.png',
    133  'UI/Inflight/SetAsCameraInterest': 'res:/UI/Texture/Icons/44_32_65.png',
    134  'UI/Inflight/BoardShip': 'res:/UI/Texture/Icons/44_32_40.png',
    135  'UI/Inflight/BoardStructure': 'res:/UI/Texture/Icons/44_32_40.png',
    136  'UI/Inflight/DockInStation': 'res:/UI/Texture/Icons/44_32_9.png',
    137  'UI/Inflight/Jump': 'res:/UI/Texture/Icons/44_32_39.png',
    138  'UI/Inflight/JumpByShipcaster': 'res:/UI/Texture/Icons/44_32_39.png',
    139  'UI/Inflight/JumpUsingBridge': 'res:/UI/Texture/Icons/44_32_39.png',
    140  'UI/Inflight/JumpThroughStargate': 'res:/UI/Texture/Icons/44_32_39.png',
    141  'UI/Inflight/JumpThroughJumpgate': 'res:/UI/Texture/Icons/44_32_39.png',
    142  'UI/Fleet/JumpThroughToSystem': 'res:/UI/Texture/Icons/44_32_39.png',
    143  'UI/Commands/OpenCargo': 'res:/UI/Texture/Icons/44_32_35.png',
    144  'UI/Commands/OpenCargoHold': 'res:/UI/Texture/Icons/44_32_35.png',
    145  'UI/Commands/OpenFleetHangar': 'res:/UI/Texture/Icons/44_32_35.png',
    146  'UI/PI/Common/AccessCustomOffice': 'res:/UI/Texture/Icons/44_32_35.png',
    147  'UI/OrbitalSkyhook/SkyhookWnd/AccessOrbitalSkyhookOffice': eveicon.settings_wheel,
    148  'UI/Sovereignty/MercenaryDen/ConfigurationWindow/ConfigureMercenaryDen': eveicon.settings_wheel,
    149  'UI/Inflight/AccessHangarTransfer': 'res:/UI/Texture/Icons/44_32_35.png',
    150  'UI/Inflight/OpenMoonMaterialBay': eveicon.retrieve,
    151  'UI/Inflight/ScoopToCargoHold': 'res:/UI/Texture/Icons/scoopcargo.png',
    152  'UI/Drones/ScoopDroneToBay': 'res:/UI/Texture/classes/RadialMenuActions/scoopDrone.png',
    153  'UI/Drones/LaunchDrone': 'res:/UI/Texture/Icons/44_32_2.png',
    154  'UI/Drones/ReturnDroneToBay': 'res:/UI/Texture/Icons/44_32_1.png',
    155  'UI/Chat/StartConversation': 'res:/UI/Texture/Icons/44_32_33.png',
    156  'UI/Inflight/EnterWormhole': 'res:/UI/Texture/Icons/44_32_39.png',
    157  'UI/Drones/EngageTarget': 'res:/UI/Texture/Icons/44_32_11.png',
    158  'UI/Drones/MineWithDrone': 'res:/UI/Texture/Icons/44_32_5.png',
    159  'UI/Drones/Salvage': 'res:/UI/Texture/Icons/44_32_4.png',
    160  'UI/Drones/ReturnDroneAndOrbit': 'res:/UI/Texture/Icons/44_32_3.png',
    161  'UI/Commands/ReadNews': 'res:/UI/Texture/Icons/44_32_47.png',
    162  'UI/Inflight/Submenus/WarpToWithin': 'res:/UI/Texture/Icons/44_32_18.png',
    163  'UI/Fleet/WarpToMemberSubmenuOption': 'res:/UI/Texture/Icons/44_32_18.png',
    164  'UI/Inflight/WarpToBookmark': 'res:/UI/Texture/Icons/44_32_18.png',
    165  'UI/Inflight/BookmarkLocation': 'res:/UI/Texture/Icons/bookmark.png',
    166  'UI/Inflight/EditBookmark': 'res:/UI/Texture/classes/RadialMenuActions/edit_bookmark.png',
    167  'UI/PI/Common/ViewInPlanetMode': 'res:/UI/Texture/Icons/77_32_34.png',
    168  'UI/Inflight/ActivateGate': 'res:/UI/Texture/Icons/44_32_39.png',
    169  'UI/Inflight/ActivateTraceGate': 'res:/UI/Texture/Icons/44_32_39.png',
    170  'UI/Common/Open': 'res:/UI/Texture/Icons/44_32_35.png',
    171  'UI/Inflight/StopMyShip': 'res:/UI/Texture/Icons/44_32_38.png',
    172  'UI/Inflight/StopMyCapsule': 'res:/UI/Texture/Icons/44_32_38.png',
    173  'UI/Inflight/HUDOptions/ReleaseControl': 'res:/UI/Texture/classes/RadialMenuActions/releaseStructureControl.png',
    174  'UI/Inflight/HUDOptions/BoardPreviousShipFromFlex': 'res:/UI/Texture/classes/RadialMenuActions/releaseStructureControl.png',
    175  'UI/Inflight/SetDestination': 'res:/UI/Texture/classes/RadialMenuActions/setDestination.png',
    176  'UI/Fitting/UseFittingService': 'res:/UI/Texture/classes/RadialMenuActions/useFittingService.png',
    177  'UI/Inflight/SetDefaultWarpWithinDistanceShort': 'res:/UI/Texture/classes/RadialMenuActions/setWarpDefault.png',
    178  'UI/Inflight/SetDefaultKeepAtRangeDistanceShort': 'res:/UI/Texture/classes/RadialMenuActions/setKeepRangeDefault.png',
    179  'UI/Inflight/SetDefaultOrbitDistanceShort': 'res:/UI/Texture/classes/RadialMenuActions/setOrbitDefault.png',
    180  'UI/Inflight/POS/ManageControlTower': 'res:/UI/Texture/classes/RadialMenuActions/manageStarbase.png',
    181  'UI/Menusvc/OpenHubManager': 'res:/UI/Texture/classes/RadialMenuActions/manageStarbase.png',
    182  'UI/FactionWarfare/IHub/OpenInfrastructureHubPanel': 'res:/UI/Texture/classes/RadialMenuActions/manageStarbase.png',
    183  'UI/Inflight/POS/AccessPOSStorage': 'res:/UI/Texture/Icons/44_32_35.png',
    184  'UI/Inflight/POS/AccessPOSCrystalStorage': 'res:/UI/Texture/Icons/44_32_35.png',
    185  'UI/Inflight/POS/AccessPOSAmmo': 'res:/UI/Texture/Icons/44_32_35.png',
    186  'UI/Inflight/POS/AccessPOSRefinery': 'res:/UI/Texture/Icons/44_32_35.png',
    187  'UI/Inflight/POS/AccessPOSCompression': 'res:/UI/Texture/Icons/44_32_35.png',
    188  'UI/Inflight/POS/AccessPOSVessels': 'res:/UI/Texture/Icons/44_32_35.png',
    189  'UI/Inflight/SpaceComponents/MicroJumpDriver/ActivateMicroJumpDrive': 'res:/UI/Texture/Icons/44_32_39.png',
    190  'UI/Inflight/Scanner/IngoreResult': 'res:/UI/Texture/classes/RadialMenuActions/ignore_results.png',
    191  'UI/Inflight/Scanner/IgnoreOtherResults': 'res:/UI/Texture/classes/RadialMenuActions/ignore_others_results.png',
    192  'UI/Inflight/Scanner/ProbeScanner': 'res:/UI/Texture/Icons/probe_scan.png',
    193  'UI/Inflight/SpaceComponents/ItemTrader/Access': 'res:/UI/Texture/Icons/44_32_35.png',
    194  'UI/Inflight/SpaceComponents/UnderConstruction/Access': 'res:/UI/Texture/Icons/44_32_35.png',
    195  'UI/Inflight/Scanner/DirectionalScan': 'res:/UI/Texture/Icons/d-scan.png',
    196  'UI/Fleet/FleetBroadcast/Commands/HealShield': 'res:/UI/Texture/Icons/44_32_52.png',
    197  'UI/Fleet/FleetBroadcast/Commands/HealArmor': 'res:/UI/Texture/Icons/44_32_53.png',
    198  'UI/Fleet/FleetBroadcast/Commands/HealCapacitor': 'res:/UI/Texture/Icons/44_32_54.png',
    199  'UI/Fleet/FleetBroadcast/Commands/BroadcastWarpTo': 'res:/UI/Texture/Icons/44_32_55.png',
    200  'UI/Fleet/FleetBroadcast/Commands/BroadcastAlignTo': 'res:/UI/Texture/Icons/44_32_57.png',
    201  'UI/Fleet/FleetBroadcast/Commands/BroadcastTarget': 'res:/UI/Texture/Icons/44_32_17.png',
    202  'UI/Inflight/WarpToMoonMiningPoint': 'res:/UI/Texture/Classes/Moonmining//warpToMiningPoint.png',
    203  'UI/Inflight/SpaceComponents/TowGameObjective/startTowing': 'res:/UI/Texture/icons/tow_icon.png',
    204  'UI/Inflight/SpaceComponents/TowGameObjective/stopTowing': 'res:/UI/Texture/icons/tow_icon_reset.png'}
    205 
    206 def GetSpaceComponentPrimaryActionsForTypeID(typeID):
    207     componentNames = get_space_component_names_for_type(typeID)
    208     if CARGO_BAY in componentNames and not HasItemTrader(typeID) and not HasUnderConstructionComponent(typeID):
    209         return [SimpleRadialMenuAction(option1='UI/Commands/OpenCargo')]
    210     if HasMicroJumpDriverComponent(typeID):
    211         return [SimpleRadialMenuAction(option1='UI/Inflight/SpaceComponents/MicroJumpDriver/ActivateMicroJumpDrive')]
    212     if HasItemTrader(typeID):
    213         return [SimpleRadialMenuAction(option1='UI/Inflight/SpaceComponents/ItemTrader/Access')]
    214     if HasUnderConstructionComponent(typeID):
    215         return [SimpleRadialMenuAction(option1='UI/Inflight/SpaceComponents/UnderConstruction/Access')]
    216     if HasShipcasterComponent(typeID) or HasStarterShipcasterComponent(typeID):
    217         return [SimpleRadialMenuAction(option1='UI/Inflight/JumpByShipcaster')]
    218     if HasTowGameObjectiveComponent(typeID):
    219         return [SimpleRadialMenuAction(option1='UI/Inflight/SpaceComponents/TowGameObjective/startTowing', option2='UI/Inflight/SpaceComponents/TowGameObjective/stopTowing')]
    220 
    221 
    222 def GetSpaceComponentSecondaryActions(typeID):
    223     componentNames = get_space_component_names_for_type(typeID)
    224     actions = []
    225     if SCOOP_CLASS in componentNames:
    226         actions.append(SimpleRadialMenuAction(option1='UI/Inflight/ScoopToCargoHold'))
    227     if FITTING_CLASS in componentNames:
    228         actions.append(SimpleRadialMenuAction(option1='UI/Fitting/UseFittingService'))
    229     return actions
    230 
    231 
    232 def GetObjectsActions(categoryID, groupID, typeID = None, itemID = None, bookmarkInfo = None, siteData = None, menuType = NORMAL_RADIAL_MENU, *args):
    233     secondaryActions = GetObjectsSecondaryActions(categoryID, groupID, typeID=typeID, itemID=itemID, bookmarkInfo=bookmarkInfo, siteData=siteData)
    234     generalActions = GetGeneralActions(hasExtraOptions=bool(secondaryActions), itemID=itemID, bookmarkInfo=bookmarkInfo, siteData=siteData, menuType=menuType)
    235     myActions = generalActions[:]
    236     if menuType == BROADCAST_RADIAL_MENU:
    237         return [SimpleRadialMenuAction()] + myActions
    238     if itemID == GetActiveShip():
    239         return myActions
    240     primaryComponentActions = GetSpaceComponentPrimaryActionsForTypeID(typeID)
    241     typeActions = primaryTypeActions.get(typeID, None)
    242     groupActions = primaryGroupActions.get(groupID, None)
    243     categoryActions = primaryCategoryActions.get(categoryID, None)
    244     siteActions = siteData.GetSiteActions() if siteData else None
    245     if primaryComponentActions:
    246         primaryActions = primaryComponentActions
    247     elif siteActions:
    248         primaryActions = siteActions
    249     else:
    250         primaryActions = typeActions or groupActions or categoryActions or [SimpleRadialMenuAction()]
    251     return primaryActions + myActions
    252 
    253 
    254 def GetObjectsSecondaryActions(categoryID, groupID, typeID = None, itemID = None, bookmarkInfo = None, siteData = None, menuType = NORMAL_RADIAL_MENU):
    255     if menuType == BROADCAST_RADIAL_MENU:
    256         return []
    257     myActions = []
    258     categoryActions = secondaryCategoryActions.get(categoryID, None)
    259     if categoryActions:
    260         myActions += categoryActions
    261     groupActions = secondaryGroupActions.get(groupID, None)
    262     if groupActions:
    263         myActions += groupActions
    264     typeActions = secondaryTypeActions.get(typeID, None)
    265     if typeActions:
    266         myActions += typeActions
    267     if itemID == GetActiveShip() and session.solarsystemid:
    268         myActions += GetMyShipSpecialCaseSecondLevel(typeID=typeID, itemID=itemID)
    269     secondaryComponentActions = GetSpaceComponentSecondaryActions(typeID)
    270     if secondaryComponentActions:
    271         myActions += secondaryComponentActions
    272     if siteData:
    273         myActions.extend(siteData.GetSecondaryActions())
    274     if myActions:
    275         myActions = [SecondLevelRadialMenuAction(hasExtraOptions=False)] + myActions
    276     return myActions
    277 
    278 
    279 def GetGeneralActions(hasExtraOptions = True, itemID = None, bookmarkInfo = None, siteData = None, menuType = NORMAL_RADIAL_MENU):
    280     if itemID == GetActiveShip() and menuType != BROADCAST_RADIAL_MENU:
    281         if itemID == session.structureid:
    282             topOption = SimpleRadialMenuAction(option1='UI/Inflight/HUDOptions/ReleaseControl', option2='UI/Inflight/HUDOptions/BoardPreviousShipFromFlex')
    283         else:
    284             topOption = SimpleRadialMenuAction(option1='UI/Inflight/StopMyShip', option2='UI/Inflight/StopMyCapsule')
    285         generalActions = [topOption,
    286          GetOrbitOption(itemID, isMyShip=True),
    287          SecondLevelRadialMenuAction(hasExtraOptions=hasExtraOptions),
    288          GetKeepAtRangeOption(itemID, isMyShip=True),
    289          SimpleRadialMenuAction(option1='UI/Commands/OpenCargoHold'),
    290          SimpleRadialMenuAction(),
    291          SimpleRadialMenuAction(option1='UI/Commands/ShowInfo'),
    292          GetWarpToOption(itemID, bookmarkInfo=None, isMyShip=True)]
    293     else:
    294         if siteData is not None:
    295             itemID = siteData.siteID
    296         if menuType == BROADCAST_RADIAL_MENU:
    297             generalActions = GetBroadcastMenuGeneralActions(itemID)
    298         else:
    299             generalActions = [GetOrbitOption(itemID),
    300              SecondLevelRadialMenuAction(hasExtraOptions=hasExtraOptions),
    301              GetKeepAtRangeOption(itemID),
    302              SimpleRadialMenuAction(option1='UI/Inflight/LockTarget', option2='UI/Inflight/UnlockTarget', option3Path='UI/Inflight/CancelLockTarget'),
    303              GetApproachOption(bookmarkInfo, siteData),
    304              SimpleRadialMenuAction(option1='UI/Commands/ShowInfo'),
    305              GetWarpToOption(itemID, bookmarkInfo, siteData=siteData)]
    306     return generalActions
    307 
    308 
    309 def GetBroadcastMenuGeneralActions(itemID):
    310     generalActions = [GetBroadcastForShieldMenuAction(itemID),
    311      GetBroadcastForArmorMenuAction(itemID),
    312      GetBroadcastForCapacitorMenuAction(itemID),
    313      GetBroadcastTargetMenuAction(),
    314      GetBroadcastAlignToMenuAction(),
    315      SimpleRadialMenuAction(),
    316      GetBroadcastWarpToMenuAction()]
    317     return generalActions
    318 
    319 
    320 def GetOrbitOption(itemID, isMyShip = False, *args):
    321     if isMyShip:
    322         return RangeRadialMenuAction(optionPath='UI/Inflight/SetDefaultOrbitDistanceShort', rangeList=GetOrbitRangesForDefault(), defaultRange=GetOrbitDefault(), callback=SetDefaultOrbit, funcArgs=itemID, alwaysAvailable=True)
    323     return RangeRadialMenuAction(optionPath='UI/Inflight/OrbitObject', rangeList=GetOrbitRanges(), defaultRange=GetOrbitDefault(), callback=Orbit, funcArgs=itemID)
    324 
    325 
    326 def GetKeepAtRangeOption(itemID, isMyShip = False, *args):
    327     if isMyShip:
    328         return RangeRadialMenuAction(optionPath='UI/Inflight/SetDefaultKeepAtRangeDistanceShort', rangeList=GetKeepAtRangeRangesForDefault(), defaultRange=GetKeepAtRangeDefault(), callback=SetDefaultKeepAtRange, funcArgs=itemID, alwaysAvailable=True)
    329     return RangeRadialMenuAction(optionPath='UI/Inflight/Submenus/KeepAtRange', rangeList=GetKeepAtRangeRanges(), defaultRange=GetKeepAtRangeDefault(), callback=KeepAtRange, funcArgs=itemID)
    330 
    331 
    332 def GetWarpToOption(itemID, bookmarkInfo, isMyShip = False, siteData = None, *args):
    333     if isMyShip:
    334         return RangeRadialMenuAction(optionPath='UI/Inflight/SetDefaultWarpWithinDistanceShort', rangeList=GetWarpToRanges(), defaultRange=GetWarpToDefault(), callback=SetDefaultWarpTo, funcArgs=itemID, alwaysAvailable=True)
    335     if bookmarkInfo:
    336         callback = WarpToBookmark
    337         funcArgs = bookmarkInfo
    338         optionPath2 = 'UI/Inflight/WarpToBookmark'
    339     elif siteData:
    340         callback = siteData.WarpToAction
    341         funcArgs = None
    342         optionPath2 = 'UI/Inflight/WarpToBookmark'
    343     else:
    344         optionPath2 = 'UI/Fleet/WarpToMemberSubmenuOption'
    345         callback = WarpTo
    346         funcArgs = itemID
    347     return RangeRadialMenuAction(optionPath='UI/Inflight/Submenus/WarpToWithin', option2Path=optionPath2, rangeList=GetWarpToRanges(), defaultRange=GetWarpToDefault(), callback=callback, funcArgs=funcArgs)
    348 
    349 
    350 def GetApproachOption(bookmarkInfo, siteData, *args):
    351     if bookmarkInfo or siteData:
    352         option1 = 'UI/Inflight/AlignTo'
    353         option2 = 'UI/Inflight/ApproachLocationActionGroup'
    354     else:
    355         option1 = 'UI/Inflight/AlignTo'
    356         option2 = 'UI/Inflight/ApproachObject'
    357     return SimpleRadialMenuAction(option1=option1, option2=option2)
    358 
    359 
    360 def GetMyShipSpecialCaseSecondLevel(typeID = None, itemID = None, *args):
    361     secondLevelOptions = []
    362     if session.solarsystemid and not session.structureid:
    363         func = GetMenuService().Bookmark
    364         funcArgs = (itemID, typeID, session.solarsystemid)
    365         secondLevelOptions += [SimpleRadialMenuAction(option1='UI/Inflight/BookmarkLocation', alwaysAvailable=True, func=func, funcArgs=funcArgs)]
    366     return secondLevelOptions
    367 
    368 
    369 def FindRadialMenuOptions(slimItem = None, itemID = None, typeID = None, primaryActions = True, bookmarkInfo = None, manyItemsData = None, siteData = None, menuType = 1):
    370     filterList = []
    371     if not bookmarkInfo and not manyItemsData and not slimItem and itemID:
    372         slimItem = GetBallparkRecord(itemID)
    373     menuSvc = GetMenuService()
    374     if manyItemsData:
    375         allMenuOptions = manyItemsData.menuFunction(manyItemsData.itemData)
    376     elif bookmarkInfo is not None:
    377         allMenuOptions = menuSvc.BookmarkMenu(bookmarkInfo)
    378         typeID = bookmarkInfo.typeID
    379     elif slimItem:
    380         allMenuOptions = menuSvc.UnmergedCelestialMenu(slimItem)
    381         typeID = slimItem.typeID
    382         filterList.append('UI/Inflight/SetDestination')
    383     elif siteData is not None:
    384         allMenuOptions = siteData.GetMenu()
    385         if typeID is None:
    386             typeID = getattr(siteData, 'typeID', None)
    387     elif itemID and IsCharacter(itemID):
    388         allMenuOptions = menuSvc.CharacterMenu(itemID) + menuSvc.FleetMenu(itemID)
    389     elif typeID is not None:
    390         allMenuOptions = menuSvc.GetMenuFromItemIDTypeID(itemID, typeID)
    391     else:
    392         allMenuOptions = []
    393     if typeID is not None:
    394         categoryID = evetypes.GetCategoryID(typeID)
    395         groupID = evetypes.GetGroupID(typeID)
    396     else:
    397         categoryID = None
    398         groupID = None
    399     if primaryActions:
    400         allWantedMenuOptions = GetObjectsActions(categoryID, groupID, typeID, itemID, bookmarkInfo=bookmarkInfo, siteData=siteData, menuType=menuType)
    401     else:
    402         allWantedMenuOptions = GetObjectsSecondaryActions(categoryID, groupID, typeID, itemID, bookmarkInfo, siteData=siteData, menuType=menuType)
    403     return PrepareRadialMenuOptions(allMenuOptions, allWantedMenuOptions, filterList)
    404 
    405 
    406 def AddOption(optionLabel, menuOption, oneClickMenuOptions, activeSingleOptions):
    407     menuOption.activeOption = optionLabel
    408     menuOption.labelArgs = oneClickMenuOptions[optionLabel].labelArgs
    409     callbackInfo = oneClickMenuOptions[optionLabel].callbackInfo
    410     menuOption.func = callbackInfo[0]
    411     if len(callbackInfo) > 1:
    412         if CaptionIsInMultiFunctions(optionLabel):
    413             menuOption.funcArgs = (callbackInfo[1],)
    414         else:
    415             menuOption.funcArgs = callbackInfo[1]
    416     else:
    417         menuOption.funcArgs = None
    418     activeSingleOptions[optionLabel] = menuOption
    419 
    420 
    421 def PrepareRadialMenuOptions(allMenuOptions, allWantedMenuOptions, filterList, *args):
    422     oneClickMenuOptions = {}
    423     otherMenuOptions = set()
    424     allMenuOptionsExpanded = _GetAllMenuOptionsWithExpanded(allMenuOptions, filterList)
    425     for eachMenuEntry in allMenuOptionsExpanded:
    426         actionName, labelArgs = GetActionNameAndArgs(eachMenuEntry)
    427         if isinstance(eachMenuEntry, BaseMenuEntryData):
    428             if eachMenuEntry.HasSubMenuData() or not eachMenuEntry.IsEnabled():
    429                 otherMenuOptions.add(actionName)
    430             elif hasattr(eachMenuEntry, 'func'):
    431                 oneClickMenuOptions[actionName] = KeyVal(callbackInfo=(eachMenuEntry.func,), labelArgs=labelArgs)
    432         elif isinstance(eachMenuEntry[1], (types.MethodType, types.LambdaType)):
    433             oneClickMenuOptions[actionName] = KeyVal(callbackInfo=eachMenuEntry[1:], labelArgs=labelArgs)
    434         else:
    435             otherMenuOptions.add(actionName)
    436 
    437     activeSingleOptions = {}
    438     inactiveSingleOptions = set()
    439     activeRangeOptions = {}
    440     inactiveRangeOptions = set()
    441     for menuOption in allWantedMenuOptions[:]:
    442         option1 = menuOption.option1Path
    443         option2 = menuOption.Get('option2Path', None)
    444         option3 = menuOption.Get('option3Path', None)
    445         option4 = menuOption.Get('option4Path', None)
    446         if isinstance(menuOption, SimpleRadialMenuAction):
    447             if menuOption.get('forcedInactive', False):
    448                 inactiveSingleOptions.add(option1)
    449             elif option1 in oneClickMenuOptions:
    450                 AddOption(option1, menuOption, oneClickMenuOptions, activeSingleOptions)
    451             elif _IsOptionAvailable(oneClickMenuOptions, option2):
    452                 AddOption(option2, menuOption, oneClickMenuOptions, activeSingleOptions)
    453             elif _IsOptionAvailable(oneClickMenuOptions, option3):
    454                 AddOption(option3, menuOption, oneClickMenuOptions, activeSingleOptions)
    455             elif _IsOptionAvailable(oneClickMenuOptions, option4):
    456                 AddOption(option4, menuOption, oneClickMenuOptions, activeSingleOptions)
    457             elif menuOption.get('alwaysAvailable', False):
    458                 menuOption.activeOption = option1
    459                 activeSingleOptions[option1] = menuOption
    460             else:
    461                 inactiveSingleOptions.add(option1)
    462         elif isinstance(menuOption, RangeRadialMenuAction):
    463             if option1 in otherMenuOptions or menuOption.get('alwaysAvailable', False):
    464                 activeRangeOptions[option1] = menuOption
    465             elif option2 in otherMenuOptions:
    466                 menuOption.activeOption = option2
    467                 activeRangeOptions[option2] = menuOption
    468             elif option2 in oneClickMenuOptions:
    469                 newMenuOption = SimpleRadialMenuAction(option1=option1, option2=option2)
    470                 AddOption(option2, newMenuOption, oneClickMenuOptions, activeSingleOptions)
    471                 idx = allWantedMenuOptions.index(menuOption)
    472                 allWantedMenuOptions[idx] = newMenuOption
    473             else:
    474                 inactiveRangeOptions.add(option1)
    475 
    476     optionsInfo = RadialMenuOptionsInfo(allWantedMenuOptions=allWantedMenuOptions, activeSingleOptions=activeSingleOptions, inactiveSingleOptions=inactiveSingleOptions, activeRangeOptions=activeRangeOptions, inactiveRangeOptions=inactiveRangeOptions)
    477     return optionsInfo
    478 
    479 
    480 def _IsOptionAvailable(oneClickMenuOptions, option):
    481     if option is None:
    482         return False
    483     return option in oneClickMenuOptions
    484 
    485 
    486 def _GetAllMenuOptionsWithExpanded(allMenuOptions, filterList):
    487     allMenuOptionsExpanded = OrderedDict()
    488     subMenuOptions = []
    489     for eachMenuEntry in allMenuOptions:
    490         if eachMenuEntry is None:
    491             continue
    492         actionName, labelArgs = GetActionNameAndArgs(eachMenuEntry)
    493         if actionName in filterList:
    494             continue
    495         allMenuOptionsExpanded[actionName] = eachMenuEntry
    496         if actionName in subMenusToExpand:
    497             for eachSubOption in eachMenuEntry[1]:
    498                 subMenuOptions.append(eachSubOption)
    499 
    500     for eachSubOption in subMenuOptions:
    501         actionName, labelArgs = GetActionNameAndArgs(eachSubOption)
    502         if actionName not in allMenuOptionsExpanded and actionName not in filterList:
    503             allMenuOptionsExpanded[actionName] = eachSubOption
    504 
    505     return allMenuOptionsExpanded.values()
    506 
    507 
    508 def GetActionNameAndArgs(eachMenuEntry):
    509     if isinstance(eachMenuEntry, BaseMenuEntryData):
    510         menuLabel = eachMenuEntry.GetMenuLabel()
    511     else:
    512         menuLabel = eachMenuEntry[0]
    513     if isinstance(menuLabel, (MenuLabel, list)):
    514         actionName = menuLabel[0]
    515         labelArgs = menuLabel[1]
    516     else:
    517         actionName = menuLabel
    518         labelArgs = {}
    519     return (actionName, labelArgs)
    520 
    521 
    522 def GetIconPath(labelPath):
    523     return iconDict.get(labelPath, None)
    524 
    525 
    526 def KeepAtRange(itemID, distance, percOfAllRange):
    527     movementFunctions__KeepAtRange(itemID, distance)
    528 
    529 
    530 def GetKeepAtRangeRanges():
    531     return GetRanges(minValue=500, maxValue=30000)
    532 
    533 
    534 def GetKeepAtRangeRangesForDefault():
    535     return GetRanges(minValue=50, maxValue=100000)
    536 
    537 
    538 def GetKeepAtRangeDefault():
    539     return GetMenuService().GetDefaultActionDistance('KeepAtRange')
    540 
    541 
    542 def Orbit(itemID, distance, percOfAllRange):
    543     movementFunctions__Orbit(itemID, distance)
    544 
    545 
    546 def GetOrbitRanges():
    547     return GetRanges(minValue=500, maxValue=30000)
    548 
    549 
    550 def GetOrbitRangesForDefault():
    551     return GetRanges(minValue=500, maxValue=100000)
    552 
    553 
    554 def GetOrbitDefault():
    555     return GetMenuService().GetDefaultActionDistance('Orbit')
    556 
    557 
    558 def WarpTo(itemID, distance, percOfAllRange):
    559     if IsCharacter(itemID):
    560         GetMenuService().WarpToMember(charID=itemID, warpRange=distance)
    561     else:
    562         movementFunctions__WarpToItem(itemID=itemID, warpRange=distance)
    563 
    564 
    565 def WarpToBookmark(bookmarkInfo, distance, percOfAllRange):
    566     movementFunctions__WarpToBookmark(bookmark=bookmarkInfo, warpRange=distance)
    567 
    568 
    569 def GetWarpToRanges():
    570     return movementFunctions__GetWarpToRanges()
    571 
    572 
    573 def GetWarpToDefault():
    574     return GetMenuService().GetDefaultActionDistance('WarpTo')
    575 
    576 
    577 def GetRanges(minValue = 250, maxValue = 30000):
    578     newValue = minValue
    579     rangeList = []
    580     while newValue <= maxValue:
    581         rangeList.append(newValue)
    582         if newValue < 500:
    583             interval = 150
    584         elif newValue < 5000:
    585             interval = 250
    586         elif newValue < 8000:
    587             interval = 500
    588         elif newValue < 30000:
    589             interval = 1000
    590         else:
    591             interval = 5000
    592         newValue += interval
    593 
    594     return rangeList
    595 
    596 
    597 def SetDefaultKeepAtRange(itemID, distance, percOfAllRange):
    598     defaultRangeUtils.SetDefaultKeepAtRangeDist(distance)
    599 
    600 
    601 def SetDefaultOrbit(itemID, distance, percOfAllRange):
    602     defaultRangeUtils.SetDefaultOrbitDist(distance)
    603 
    604 
    605 def SetDefaultWarpTo(itemID, distance, percOfAllRange):
    606     defaultRangeUtils.SetDefaultWarpToDist(distance)
    607 
    608 
    609 def IsRadialMenuButtonActive():
    610     actionmenuBtn = settings.user.ui.Get('actionmenuBtn', uiconst.MOUSELEFT)
    611     if not isinstance(actionmenuBtn, int):
    612         actionmenuBtn = uiconst.MOUSELEFT
    613     myBtn = actionmenuBtn
    614     menuType = NORMAL_RADIAL_MENU
    615     actionmenuBtnState = uicore.uilib.GetMouseButtonState(actionmenuBtn)
    616     if not actionmenuBtnState:
    617         myBtn = GetSingleMouseBtnBroadcastRadialMenu()
    618         menuType = BROADCAST_RADIAL_MENU
    619         if not myBtn or not uicore.uilib.GetMouseButtonState(myBtn):
    620             return None
    621     if AreOtherMouseBtnsDown(myBtn):
    622         return None
    623     if DungeonEditor.IsOpen():
    624         return None
    625     return menuType
    626 
    627 
    628 def AreOtherMouseBtnsDown(myBtn):
    629     for eachBtn in MOUSEBUTTONS:
    630         if eachBtn == myBtn:
    631             continue
    632         btnDown = uicore.uilib.GetMouseButtonState(eachBtn)
    633         if btnDown:
    634             return True
    635 
    636     return False
    637 
    638 
    639 def GetSingleMouseBtnBroadcastRadialMenu():
    640     if settings.user.cmd.customCmds:
    641         broadcastRm = settings.user.cmd.customCmds.get('CmdOpenBroadcastRadialMenu', None)
    642     else:
    643         broadcastRm = None
    644     if broadcastRm and len(broadcastRm) == 1:
    645         mBtn = mouseBtnMap.get(broadcastRm[0], None)
    646         if mBtn in MOUSEBUTTONS:
    647             return mBtn
    648 
    649 
    650 mouseBtnMap = {uiconst.VK_MBUTTON: uiconst.MOUSEMIDDLE,
    651  uiconst.VK_XBUTTON1: uiconst.MOUSEXBUTTON1,
    652  uiconst.VK_XBUTTON2: uiconst.MOUSEXBUTTON2}