inventoryRadialMenuFunctions.py (7755B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\radialMenu\inventoryRadialMenuFunctions.py 2 from eve.client.script.ui.shared.radialMenu.radialMenuUtils import SecondLevelRadialMenuAction, SimpleRadialMenuAction 3 from carbonui.uiconst import MOUSEBUTTONS 4 import carbonui.const as uiconst 5 from eve.client.script.ui.shared.radialMenu.spaceRadialMenuFunctions import PrepareRadialMenuOptions 6 import evetypes 7 from carbonui.uicore import uicore 8 from eveservices.menu import GetMenuService 9 placeholderIconPath = 'res:/UI/Texture/Icons/9_64_13.png' 10 iconDict = {'UI/Commands/ShowInfo': 'res:/UI/Texture/Icons/44_32_24.png', 11 'UI/Inventory/ItemActions/MakeShipActive': 'res:/UI/Texture/Icons/44_32_40.png', 12 'UI/Inventory/ItemActions/Reprocess': 'res:/UI/Texture/classes/RadialMenuActions/reprocess.png', 13 'UI/Inventory/ItemActions/Repackage': 'res:/UI/Texture/classes/RadialMenuActions/repackage.png', 14 'UI/Commands/OpenFleetHangar': 'res:/UI/Texture/Icons/44_32_35.png', 15 'UI/Inventory/ItemActions/TrashIt': 'res:/UI/Texture/classes/RadialMenuActions/trashIt.png', 16 'UI/Inventory/ItemActions/PlugInImplant': 'res:/UI/Texture/classes/RadialMenuActions/plugInImplant.png', 17 'UI/Inventory/ItemActions/CreateContract': 'res:/ui/Texture/WindowIcons/contracts.png', 18 'UI/Inventory/ItemActions/SellThisItem': 'res:/UI/Texture/classes/RadialMenuActions/sellItem.png', 19 'UI/Inventory/ItemActions/FitToActiveShip': 'res:/UI/Texture/classes/RadialMenuActions/fitToShip.png', 20 'UI/Commands/Repair': 'res:/UI/Texture/classes/RadialMenuActions/repair.png', 21 'UI/Inventory/ItemActions/GetRepairQuote': 'res:/UI/Texture/classes/RadialMenuActions/repair.png', 22 'UI/Inventory/ItemActions/BuyThisType': 'res:/UI/Texture/classes/RadialMenuActions/buyThisType.png', 23 'UI/Inventory/ItemActions/ViewTypesMarketDetails': 'res:/UI/Texture/classes/RadialMenuActions/viewMarketDetails.png'} 24 baseActionMapping = {1: SimpleRadialMenuAction(), 25 2: SimpleRadialMenuAction(), 26 3: SimpleRadialMenuAction(), 27 4: SimpleRadialMenuAction(), 28 5: SimpleRadialMenuAction(), 29 6: SecondLevelRadialMenuAction(hasExtraOptions=True, levelType='market', texturePath='res:/UI/Texture/classes/RadialMenuActions/market.png'), 30 7: SimpleRadialMenuAction(option1='UI/Commands/ShowInfo'), 31 8: SimpleRadialMenuAction()} 32 actionsMapping = {} 33 34 def AddReworkToMapping(category, mapping = None): 35 if mapping is None: 36 mapping = baseActionMapping.copy() 37 mapping.update({3: SecondLevelRadialMenuAction(hasExtraOptions=True, levelType='rework')}) 38 actionsMapping[category] = mapping 39 return mapping 40 41 42 shipMapping = baseActionMapping.copy() 43 shipMapping.update({1: SimpleRadialMenuAction(option1='UI/Inventory/ItemActions/MakeShipActive', option2='UI/Inventory/ItemActions/AssembleShip', option3='UI/Inventory/ItemActions/LeaveShip'), 44 3: SecondLevelRadialMenuAction(hasExtraOptions=True, levelType='rework')}) 45 actionsMapping[const.categoryShip] = shipMapping 46 moduleMapping = baseActionMapping.copy() 47 moduleMapping.update({1: SimpleRadialMenuAction(option1='UI/Inventory/ItemActions/FitToActiveShip'), 48 3: SecondLevelRadialMenuAction(hasExtraOptions=True, levelType='rework')}) 49 actionsMapping[const.categoryModule] = moduleMapping 50 actionsMapping[const.categoryStructureModule] = moduleMapping 51 asteroidMapping = baseActionMapping.copy() 52 asteroidMapping.update({1: SimpleRadialMenuAction(option1='UI/Inventory/ItemActions/Reprocess')}) 53 actionsMapping[const.categoryAsteroid] = asteroidMapping 54 blueprintMapping = baseActionMapping.copy() 55 blueprintMapping.update({1: SimpleRadialMenuAction(option1='UI/ScienceAndIndustry/ScienceAndIndustryWindow/Filters/Manufacturing')}) 56 actionsMapping[const.categoryBlueprint] = blueprintMapping 57 skillMapping = baseActionMapping.copy() 58 skillMapping.update({1: SimpleRadialMenuAction(option1='UI/SkillQueue/InjectSkill'), 59 5: SimpleRadialMenuAction(option1='UI/SkillQueue/AddSkillMenu/TrainNowToLevel1')}) 60 actionsMapping[const.categorySkill] = skillMapping 61 implantMapping = baseActionMapping.copy() 62 implantMapping.update({1: SimpleRadialMenuAction(option1='UI/Inventory/ItemActions/PlugInImplant'), 63 3: SecondLevelRadialMenuAction(hasExtraOptions=True, levelType='rework')}) 64 actionsMapping[const.categoryImplant] = implantMapping 65 droneMapping = baseActionMapping.copy() 66 droneMapping.update({1: SimpleRadialMenuAction(option1='UI/Drones/LaunchDrone'), 67 3: SecondLevelRadialMenuAction(hasExtraOptions=True, levelType='rework')}) 68 actionsMapping[const.categoryDrone] = droneMapping 69 mobileMapping = baseActionMapping.copy() 70 mobileMapping.update({1: SimpleRadialMenuAction(option1='UI/Inventory/ItemActions/LaunchForSelf'), 71 3: SecondLevelRadialMenuAction(hasExtraOptions=True, levelType='rework')}) 72 actionsMapping[const.categoryDeployable] = mobileMapping 73 AddReworkToMapping(const.categoryCelestial) 74 AddReworkToMapping(const.categoryCharge) 75 AddReworkToMapping(const.categoryCharge) 76 AddReworkToMapping(const.categoryStarbase) 77 AddReworkToMapping(const.categorySubSystem) 78 secondaryOptionsMapping = {'rework': [SimpleRadialMenuAction('UI/Inventory/ItemActions/GetRepairQuote'), SimpleRadialMenuAction('UI/Inventory/ItemActions/Repackage'), SimpleRadialMenuAction('UI/Inventory/ItemActions/Reprocess')], 79 'market': [SimpleRadialMenuAction('UI/Inventory/ItemActions/ViewTypesMarketDetails'), SimpleRadialMenuAction('UI/Inventory/ItemActions/SellThisItem'), SimpleRadialMenuAction('UI/Inventory/ItemActions/BuyThisType')]} 80 81 def GetObjectsActions(categoryID, groupID, typeID = None, itemID = None, *args): 82 generalActions = GetGeneralActions(categoryID, groupID, typeID=typeID, itemID=itemID) 83 myActions = generalActions[:] 84 return myActions 85 86 87 def GetObjectsSecondaryActions(categoryID, groupID, typeID = None, itemID = None, levelType = ''): 88 myActions = secondaryOptionsMapping.get(levelType, []) 89 if myActions: 90 myActions = [SecondLevelRadialMenuAction(hasExtraOptions=False)] + myActions 91 return myActions 92 93 94 def GetGeneralActions(categoryID, groupID, typeID, itemID): 95 generalActions = actionsMapping.get(categoryID, baseActionMapping).values() 96 for eachAction in generalActions: 97 if isinstance(eachAction, SecondLevelRadialMenuAction): 98 secondaryActions = GetObjectsSecondaryActions(categoryID, groupID, typeID, itemID, levelType=eachAction.levelType) 99 if secondaryActions: 100 eachAction.hasExtraOptions = True 101 102 return generalActions 103 104 105 def FindRadialMenuOptions(itemID = None, typeID = None, primaryActions = True, manyItemsData = None, rec = None, levelType = None): 106 filterList = [] 107 allMenuOptions = GetMenuService().InvItemMenu(rec) 108 if typeID is not None: 109 categoryID = evetypes.GetCategoryID(typeID) 110 groupID = evetypes.GetGroupID(typeID) 111 else: 112 categoryID = None 113 groupID = None 114 if primaryActions: 115 allWantedMenuOptions = GetObjectsActions(categoryID, groupID, typeID, itemID) 116 else: 117 allWantedMenuOptions = GetObjectsSecondaryActions(categoryID, groupID, typeID, itemID, levelType=levelType) 118 return PrepareRadialMenuOptions(allMenuOptions, allWantedMenuOptions, filterList) 119 120 121 def GetIconPath(labelPath): 122 return iconDict.get(labelPath, None) 123 124 125 def IsRadialMenuButtonActive(): 126 actionmenuBtn = settings.user.ui.Get('actionmenuBtn', uiconst.MOUSELEFT) 127 if not isinstance(actionmenuBtn, int): 128 actionmenuBtn = uiconst.MOUSELEFT 129 actionmenuBtnState = uicore.uilib.GetMouseButtonState(actionmenuBtn) 130 if not actionmenuBtnState: 131 return False 132 for eachBtn in MOUSEBUTTONS: 133 if eachBtn == actionmenuBtn: 134 continue 135 btnDown = uicore.uilib.GetMouseButtonState(eachBtn) 136 if btnDown: 137 return False 138 139 return True