mapViewMarkersSettingButton.py (3774B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\mapView\controls\mapViewMarkersSettingButton.py 2 import evetypes 3 import localization 4 from carbonui import const as uiconst 5 from carbonui.uicore import uicore 6 from carbonui.control.buttonIcon import ButtonIcon 7 from carbonui.control.checkbox import Checkbox 8 from eve.client.script.ui.control.themeColored import LineThemeColored 9 from eve.client.script.ui.shared.mapView import mapViewConst 10 from eve.client.script.ui.shared.mapView.mapViewConst import VIEWMODE_MARKERS_SETTINGS, VIEWMODE_MARKERS_OPTIONS, VIEWMODE_MARKERS_OPTIONS_CUSTOM, VIEWMODE_MARKERS_CUSTOM_LABELS, MARKERS_OPTION_SOV_HUBS 11 from eve.client.script.ui.shared.mapView.mapViewSettings import ICON_ROOT, GetMapViewSetting, SetMapViewSetting 12 from eve.client.script.ui.shared.mapView.workforce import CanSeeSovHubs 13 14 class MapViewMarkersSettingButton(ButtonIcon): 15 default_iconSize = 24 16 default_width = 26 17 default_height = 26 18 settingGroupKey = None 19 mapViewID = None 20 callback = None 21 22 def ApplyAttributes(self, attributes): 23 ButtonIcon.ApplyAttributes(self, attributes) 24 self.settingGroupKey = VIEWMODE_MARKERS_SETTINGS 25 self.mapViewID = attributes.Get('mapViewID', mapViewConst.MAPVIEW_PRIMARY_ID) 26 self.callback = attributes.callback 27 self.SetTexturePath(ICON_ROOT + 'markersIcon.png') 28 29 def Close(self, *args): 30 ButtonIcon.Close(self, *args) 31 self.callback = None 32 33 def LoadTooltipPanel(self, tooltipPanel, *args): 34 if uicore.uilib.leftbtn: 35 return 36 tooltipPanel.columns = 2 37 tooltipPanel.AddLabelSmall(text=localization.GetByLabel('UI/Map/Markers'), bold=True, cellPadding=(8, 4, 4, 2), colSpan=tooltipPanel.columns) 38 divider = LineThemeColored(align=uiconst.TOTOP, state=uiconst.UI_DISABLED, height=1, padding=(1, 1, 1, 0), opacity=0.3) 39 tooltipPanel.AddCell(divider, cellPadding=(0, 0, 0, 2), colSpan=tooltipPanel.columns) 40 currentActive = GetMapViewSetting(self.settingGroupKey, self.mapViewID) 41 sortList = [] 42 for groupID in VIEWMODE_MARKERS_OPTIONS: 43 sortList.append((evetypes.GetGroupNameByGroup(groupID), groupID)) 44 45 customOptions = VIEWMODE_MARKERS_OPTIONS_CUSTOM[:] 46 if CanSeeSovHubs(): 47 customOptions.append(MARKERS_OPTION_SOV_HUBS) 48 for customID in customOptions: 49 sortList.append((localization.GetByLabel(VIEWMODE_MARKERS_CUSTOM_LABELS[customID]), customID)) 50 51 for optionName, optionID in sorted(sortList): 52 checkBox = Checkbox(align=uiconst.TOPLEFT, text=optionName, checked=optionID in currentActive, wrapLabel=False, callback=self.OnSettingButtonCheckBoxChange, settingsKey=optionID, settingsPath=None) 53 tooltipPanel.AddCell(cellObject=checkBox, colSpan=tooltipPanel.columns, cellPadding=(5, 0, 5, 0)) 54 55 tooltipPanel.AddSpacer(width=2, height=2, colSpan=tooltipPanel.columns) 56 tooltipPanel.state = uiconst.UI_NORMAL 57 58 def GetTooltipPointer(self): 59 return uiconst.POINT_TOP_1 60 61 def GetTooltipDelay(self): 62 return 5 63 64 def OnSettingButtonCheckBoxChange(self, checkbox, *args, **kwds): 65 currentActive = set(GetMapViewSetting(self.settingGroupKey, self.mapViewID)) 66 active = checkbox.GetValue() 67 settingsKey = checkbox.GetSettingsKey() 68 if active: 69 currentActive.add(settingsKey) 70 else: 71 try: 72 currentActive.remove(settingsKey) 73 except KeyError: 74 pass 75 76 SetMapViewSetting(self.settingGroupKey, list(currentActive), self.mapViewID) 77 if self.callback: 78 self.callback(self.settingGroupKey, list(currentActive))