pointerObject.py (7546B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\pointerTool\pointerObject.py 2 import re 3 import eve.client.script.ui.shared.pointerTool.pointerToolConst as pConst 4 import eveicon 5 import localization 6 from carbonui.uicore import uicore 7 from characterdata import factions 8 from characterdata.careerpath import get_career_path_name_id 9 from eve.client.script.ui.inflight import actionConst 10 from eve.client.script.ui.inflight.selectedItemConst import POINTER_ACTIONS 11 from eve.client.script.ui.shared.careerPortal import careerConst 12 from eve.client.script.ui.shared.mapView.categories.const import get_category_name, get_category_icon 13 from eve.client.script.ui.shared.mapView.mapViewColorHandler import GetFormatFunctionLabel 14 from eve.client.script.ui.shared.pointerTool.pointerToolUtil import TextAndTexture 15 from eve.client.script.ui.skillPlan.skillPlanConst import ICON_BY_FACTION_ID 16 from eveicon import IconData 17 from fsdBuiltData.common.iconIDs import GetIconFile 18 from localization import GetByMessageID, GetByLabel, GetMessageIDForLabel 19 from uihighlighting import UiHighlightDirections 20 REGEX = re.compile('{.*}') 21 tokenReplacer = '{...}' 22 23 class PointerObject(object): 24 25 def __init__(self, uiElementName, label, **kwargs): 26 self.uiElementName = uiElementName 27 self.label = label 28 self.labelLower = label.lower() 29 self.labelLong = kwargs.get('labelLong', None) 30 self.texturePath = kwargs.get('texturePath', None) 31 self.iconData = kwargs.get('iconData', None) 32 self.iconSizes = kwargs.get('iconSizes', None) 33 self.cmdName = kwargs.get('cmdName', None) 34 self.offset = kwargs.get('offset', None) 35 self.defaultDirection = kwargs.get('defaultDirection', None) 36 self.pointerScope = kwargs.get('pointerScope', None) 37 self.isMenuOption = kwargs.get('isMenuOption', False) 38 39 def GetTexAndTexture(self): 40 return TextAndTexture(self.label, self.texturePath, self.iconSizes, iconData=self.iconData) 41 42 43 def GetPointerObjectFromAuthoredPointer(pointerData): 44 iconData = None 45 texturePath = getattr(pointerData, 'texturePath', None) 46 if not texturePath and pointerData.iconID: 47 texturePath = GetIconFile(pointerData.iconID) 48 if not texturePath and getattr(pointerData, 'iconDataName', None): 49 iconName = pointerData.iconDataName.replace('eveicon.', '') 50 iconData = eveicon.get(iconName) 51 return PointerObject(pointerData.uiElementName, GetByMessageID(pointerData.title), texturePath=texturePath, offset=getattr(pointerData, 'offset', None), defaultDirection=getattr(pointerData, 'defaultDirection', None), pointerScope=getattr(pointerData, 'pointerScope', None), isMenuOption=getattr(pointerData, 'isMenuOption', None), iconData=iconData) 52 53 54 def GetPointerObjectFromActions(labelPath, action): 55 if labelPath in POINTER_ACTIONS: 56 return 57 text = GetMessageLabelForAction(labelPath) 58 if text is None: 59 return 60 labelLong = GetByLabel('UI/Help/PointerWndSelectedItemAction', actionName=text) 61 iconData = actionConst.ICON_BY_ACTIONID.get(labelPath, None) 62 if iconData: 63 texturePath = None 64 elif isinstance(action.iconPath, IconData): 65 texturePath = None 66 iconData = action.iconPath 67 else: 68 texturePath = action.iconPath 69 iconData = None 70 return PointerObject(action.uniqueUiName, label=text, texturePath=texturePath, iconData=iconData, labelLong=labelLong) 71 72 73 def GetPointerObjectForStationSvc(serviceInfo): 74 serviceLabel = serviceInfo.label 75 cmd = uicore.cmd.commandMap.GetCommandByName(serviceInfo.command) 76 if cmd: 77 serviceLabel = cmd.GetName() 78 labelLong = GetByLabel('UI/Help/PointerWndStationServicesLongName', serviceName=serviceLabel) 79 return PointerObject(pConst.GetUniqueStationServiceName(serviceInfo.name), label=serviceLabel, texturePath=serviceInfo.iconID, labelLong=labelLong) 80 81 82 def GetPointerObjectForAgencyTab(agencyContentGroup): 83 uiElementName = pConst.GetUniqueAgencyTabName(agencyContentGroup.GetID()) 84 label = GetByLabel('UI/Help/AgencyTabName', tabName=agencyContentGroup.GetName()) 85 return PointerObject(uiElementName, label, texturePath='res:/UI/Texture/classes/HelpPointer/tabFlat.png') 86 87 88 def GetPointerObjectForAgencyCard(agencyContentGroup): 89 uiElementName = pConst.GetUniqueAgencyCardName(agencyContentGroup.GetID()) 90 label = GetByLabel('UI/Help/AgencyCardName', cardName=agencyContentGroup.GetName()) 91 return PointerObject(uiElementName, label, texturePath='res:/UI/Texture/classes/HelpPointer/agencyCardFlat.png') 92 93 94 def GetPointerObjectForNeocom(btnID, btnData, label): 95 iconPath = btnData.iconPath 96 texturePath = None 97 iconData = None 98 if not iconPath and btnData.wndCls: 99 iconPath = btnData.wndCls.default_iconNum 100 if isinstance(iconPath, IconData): 101 iconData = iconPath 102 else: 103 texturePath = iconPath 104 return PointerObject(pConst.GetUniqueNeocomPointerName(btnID), label, texturePath=texturePath, iconData=iconData, cmdName=btnData.cmdName) 105 106 107 def GetPointerObjectForSkillPlan(skillPlan): 108 uiElementName = pConst.GetUniqueSkillPlanName(skillPlan.GetID().int) 109 label = GetByLabel('UI/Help/SkillPlansName', skillPlanName=skillPlan.GetName()) 110 return PointerObject(uiElementName, label, texturePath='res:/UI/Texture/classes/HelpPointer/skillCardFlat.png') 111 112 113 def GetPointerObjectForSkillPlanFaction(skillPlan): 114 if None in (skillPlan.careerPathID, skillPlan.factionID): 115 return 116 uiElementName = pConst.GetUniqueSkillPlanFactionName(skillPlan.careerPathID, skillPlan.factionID) 117 careerPathName = GetByMessageID(get_career_path_name_id(skillPlan.careerPathID)) 118 factionName = factions.get_faction_name(skillPlan.factionID) 119 factionIcon = ICON_BY_FACTION_ID.get(skillPlan.factionID, None) 120 label = GetByLabel('UI/Help/SkillPlansFaction', careerPathName=careerPathName, factionName=factionName) 121 return PointerObject(uiElementName, label, defaultDirection=UiHighlightDirections.UP, texturePath=factionIcon) 122 123 124 def GetPointerObjectForSkillPlanCareer(skillPlan): 125 if skillPlan.careerPathID is None: 126 return 127 uiElementName = pConst.GetUniqueSkillPlanCareerName(skillPlan.careerPathID) 128 careerPathName = GetByMessageID(get_career_path_name_id(skillPlan.careerPathID)) 129 careerIcon = careerConst.CAREERS_32_SIZES.get(skillPlan.careerPathID, None) 130 label = GetByLabel('UI/Help/SkillPlansCareer', careerPathName=careerPathName) 131 return PointerObject(uiElementName, label, defaultDirection=UiHighlightDirections.UP, texturePath=careerIcon) 132 133 134 def GetPointerObjectMapCategory(categoryID): 135 uiElementName = pConst.GetUniqueMapGroupBtn(categoryID) 136 label = GetByLabel('UI/Help/MapFilterCategory', categoryName=get_category_name(categoryID)) 137 return PointerObject(uiElementName, label, iconData=get_category_icon(categoryID), defaultDirection=UiHighlightDirections.UP) 138 139 140 def GetPointerObjectMapFilter(filterID): 141 uiElementName = pConst.GetUniqueMapFilter(filterID) 142 label = GetByLabel('UI/Help/MapFilter', filterName=GetFormatFunctionLabel(filterID)) 143 return PointerObject(uiElementName, label, defaultDirection=UiHighlightDirections.UP) 144 145 146 def GetMessageLabelForAction(labelPath): 147 try: 148 messageID = GetMessageIDForLabel(labelPath) 149 except KeyError: 150 return None 151 152 try: 153 text = localization._GetRawByMessageID(messageID) 154 return re.sub('{.*}', tokenReplacer, text) 155 except KeyError: 156 return None