palette.py (32036B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\maps\palette.py 2 import types 3 import evetypes 4 import localization 5 import log 6 import trinity 7 import uthread 8 from carbonui import uiconst 9 from carbonui.control.radioButton import RadioButton 10 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText 11 from carbonui.primitives.container import Container 12 from carbonui.primitives.containerAutoSize import ContainerAutoSize 13 from carbonui.uicore import uicore 14 from carbonui.util.various_unsorted import SortListOfTuples 15 from eve.client.script.ui.control import eveLabel, eveScroll 16 from carbonui.button.group import ButtonGroup, ButtonSizeMode 17 from carbonui.control.button import Button 18 from eve.client.script.ui.control.entries.checkbox import CheckboxEntry 19 from eve.client.script.ui.control.entries.header import Header 20 from eve.client.script.ui.control.entries.util import GetFromClass 21 from carbonui.control.window import Window 22 from eve.client.script.ui.control.listgroup import ListGroup 23 from carbonui.control.tabGroup import TabGroup 24 from eve.common.script.util.systemExclusions import IsValidDestination 25 from eve.client.script.ui.shared.maps import mapcommon, maputils 26 from eve.client.script.ui.shared.maps.entries import LegendEntry, LocationSearchItem 27 from eve.common.lib import appConst as const 28 from eveexceptions import UserError 29 ROUTECOL = {'White': trinity.TriColor(1.0, 1.0, 1.0, 0.5), 30 'Red': trinity.TriColor(1.0, 0.0, 0.0, 0.5), 31 'Green': trinity.TriColor(0.0, 1.0, 0.0, 0.5), 32 'Blue': trinity.TriColor(0.0, 0.0, 1.0, 0.5), 33 'Yellow': trinity.TriColor(1.0, 1.0, 0.0, 0.5)} 34 ILLEGALITY_AVOID_NONE = 0 35 ILLEGALITY_AVOID_STANDING_LOSS = 1 36 ILLEGALITY_AVOID_CONFISCATE = 2 37 ILLEGALITY_AVOID_ATTACK = 3 38 39 class MapPalette(Window): 40 __guid__ = 'form.MapsPalette' 41 default_analyticID = 'OldMap' 42 __notifyevents__ = ['OnMapModeChangeDone', 'OnLoadWMCPSettings', 'OnFlattenModeChanged'] 43 default_top = '__center__' 44 default_width = 400 45 default_height = 320 46 default_windowID = 'mapspalette' 47 default_iconNum = 'res:/ui/Texture/WindowIcons/map.png' 48 default_isOverlayed = True 49 50 @staticmethod 51 def default_left(*args): 52 leftpush, rightpush = Window.GetSideOffset() 53 return uicore.desktop.width - rightpush - MapPalette.default_width - 80 54 55 def ApplyAttributes(self, attributes): 56 Window.ApplyAttributes(self, attributes) 57 self._cfgTopHeaderTmpl = None 58 self._cfgTopDivTmpl = None 59 self._cfgTopPushTmpl = None 60 self._cfgCheckBoxTmpl = None 61 self._cfgBottomHeaderTmpl = None 62 self._cfgButtonTmpl = None 63 self.starColorGroups = [] 64 self.starColorByID = None 65 self.scope = uiconst.SCOPE_INGAME 66 self.SetMinSize([400, 200]) 67 self.SetCaption(localization.GetByLabel('UI/Map/MapPallet/CaptionMapPallet')) 68 self.MakeUnKillable() 69 self.loadedTab = None 70 if self.destroyed: 71 return 72 self.topParent = Container(name='topParent', parent=self.GetMainArea(), align=uiconst.TOTOP, height=36, clipChildren=True) 73 self.sr.scroll = eveScroll.Scroll(parent=self.sr.main, padding=(const.defaultPadding, 74 const.defaultPadding, 75 const.defaultPadding, 76 const.defaultPadding)) 77 self.sr.scroll.sr.id = 'mapspalletescroll_withsort' 78 self.sr.scroll2 = eveScroll.Scroll(parent=self.sr.main, padding=(const.defaultPadding, 79 const.defaultPadding, 80 const.defaultPadding, 81 const.defaultPadding)) 82 self.sr.scroll2.sr.id = 'mapspalletescroll_withhoutsort' 83 self.sr.scroll2.OnSelectionChange = self.OnSelectionChange 84 flattened = settings.user.ui.Get('mapFlattened', 1) 85 toggleFlatLabel = localization.GetByLabel('UI/Map/MapPallet/btnFlattenMap') 86 if flattened: 87 toggleFlatLabel = localization.GetByLabel('UI/Map/MapPallet/btnUnflattenMap') 88 if sm.GetService('viewState').IsViewActive('starmap'): 89 toggleMapLabel = localization.GetByLabel('UI/Map/MapPallet/btnSolarsystemMap') 90 else: 91 toggleMapLabel = localization.GetByLabel('UI/Map/MapPallet/btnStarMap') 92 self.sr.flattenBtns = ButtonGroup(parent=self.topParent, align=uiconst.CENTER, button_size_mode=ButtonSizeMode.DYNAMIC, buttons=[Button(label=localization.GetByLabel('UI/Map/MapPallet/btnCloseMap'), func=sm.GetService('viewState').CloseSecondaryView, args=(), fixedwidth=92), Button(label=toggleMapLabel, func=self.ToggleMapMode, args=(), fixedwidth=136), Button(label=toggleFlatLabel, func=self.ClickToggleFlatten, args='self', fixedwidth=92)], idx=0) 93 searchpar = ContainerAutoSize(name='searchpar', parent=self.sr.main, align=uiconst.TOTOP, idx=self.topParent.GetOrder() + 1) 94 searchpar.OnTabSelect = self.GiveInputFocus 95 inpt = SingleLineEditText(name='', label=localization.GetByLabel('UI/Map/MapPallet/lblSearchForLocation'), parent=searchpar, pos=(5, 22, 98, 0), maxLength=64) 96 inpt.OnReturn = self.OnReturnSearch 97 self.sr.searchinput = inpt 98 Button(parent=inpt.parent, label=localization.GetByLabel('UI/Map/MapPallet/btnSearchForLocation'), func=self.Search, args=1, pos=(inpt.left + inpt.width + 4, 99 inpt.top, 100 0, 101 0), btn_default=1) 102 starviewstabs = TabGroup(name='tabparent', parent=self.sr.main, idx=searchpar.GetOrder() + 1) 103 starviewstabs.Startup([[localization.GetByLabel('UI/Map/MapPallet/tabStars'), 104 self.sr.scroll2, 105 self, 106 'starview_color'], 107 [localization.GetByLabel('UI/Map/MapPallet/tabLabels'), 108 self.sr.scroll2, 109 self, 110 'mapsettings_labels'], 111 [localization.GetByLabel('UI/Map/MapPallet/tabMapLines'), 112 self.sr.scroll2, 113 self, 114 'mapsettings_lines'], 115 [localization.GetByLabel('UI/Map/MapPallet/tabTiles'), 116 self.sr.scroll2, 117 self, 118 'mapsettings_tiles'], 119 [localization.GetByLabel('UI/Map/MapPallet/tabLegend'), 120 self.sr.scroll2, 121 self, 122 'mapsettings_legend'], 123 [localization.GetByLabel('UI/Map/MapPallet/tabMapAnimation'), 124 self.sr.scroll2, 125 self, 126 'mapsettings_other']], 'starviewssub', autoselecttab=0) 127 self.sr.starviewstabs = starviewstabs 128 self.sr.maintabs = TabGroup(name='tabparent', parent=self.sr.main, idx=self.topParent.GetOrder() + 1) 129 self.sr.maintabs.Startup([[localization.GetByLabel('UI/Map/MapPallet/tabSearch'), 130 self.sr.scroll, 131 self, 132 'mapsearchpanel', 133 searchpar], [localization.GetByLabel('UI/Map/MapPallet/tabStarMap'), 134 self.sr.scroll2, 135 self, 136 'mapsettings', 137 starviewstabs], [localization.GetByLabel('UI/Map/MapPallet/tabSolarSystemMap'), 138 self.sr.scroll2, 139 self, 140 'mapsettings_solarsystem', 141 None]], 'mapspalette', autoselecttab=1) 142 143 def GiveInputFocus(self, *args): 144 uicore.registry.SetFocus(self.sr.searchinput) 145 146 def ToggleMapMode(self, *args): 147 sm.GetService('map').ToggleMode() 148 149 def ClickToggleFlatten(self, btn, *args): 150 sm.GetService('starmap').ToggleFlattenMode() 151 152 def OnFlattenModeChanged(self, isFlat, *args): 153 btn = self.sr.flattenBtns.buttons[2] 154 if isFlat: 155 btn.SetLabel(localization.GetByLabel('UI/Map/MapPallet/btnUnflattenMap')) 156 else: 157 btn.SetLabel(localization.GetByLabel('UI/Map/MapPallet/btnFlattenMap')) 158 159 def ShowPanel(self, panelname): 160 uthread.pool('MapPalette::ShowPanel', self.sr.maintabs.ShowPanelByName, panelname) 161 162 def Load(self, key): 163 self.SetHint() 164 if key == 'mapsearchpanel': 165 self.Search(0) 166 elif key == 'mapsettings': 167 self.sr.starviewstabs.AutoSelect() 168 elif key == 'options': 169 self.sr.optionstabs.AutoSelect() 170 elif key[:11] == 'mapsettings' or key[:8] == 'starview': 171 if key == self.loadedTab: 172 return 173 self.LoadSettings(key) 174 if self.destroyed: 175 return 176 self.loadedTab = key 177 178 def OnMapModeChangeDone(self, mode): 179 if self.destroyed or not hasattr(self, 'sr'): 180 return 181 btnMode = self.sr.flattenBtns.buttons[1] 182 btnFlat = self.sr.flattenBtns.buttons[2] 183 if mode == 'starmap': 184 btnFlat.Enable() 185 btnMode.SetLabel(localization.GetByLabel('UI/Map/MapPallet/tabSolarSystemMap')) 186 elif mode == 'systemmap': 187 btnFlat.Disable() 188 btnMode.SetLabel(localization.GetByLabel('UI/Map/MapPallet/tabStarMap')) 189 190 def OnReturnSearch(self, *args): 191 self.Search(1) 192 193 def Search(self, errorifnothing, *args): 194 t = uthread.new(self.Search_thread, errorifnothing) 195 t.context = 'mappalette::Search' 196 197 def Search_thread(self, errorifnothing): 198 if not self or self.destroyed: 199 return 200 self.searchresult = None 201 search = self.sr.searchinput.GetValue().strip() 202 if len(search) < 1: 203 if errorifnothing: 204 raise UserError('Min3Chars') 205 elif len(search) < 3 and not localization.util.IsTextInConciseLanguage(localization.util.GetLanguageID(), search): 206 raise UserError('Min3Chars') 207 else: 208 self.SetHint() 209 if self is not None and not self.destroyed: 210 self.ShowLoad() 211 else: 212 return 213 self.searchresult = sm.GetService('map').FindByName(search) 214 if self is None or self.destroyed: 215 return 216 self.ShowSearchResult() 217 if self == None: 218 return 219 self.HideLoad() 220 221 def ShowSearchResult(self, *args): 222 self.listtype = 'location' 223 mapSvc = sm.GetService('map') 224 tmplst = [] 225 scrolllist = [] 226 if self.searchresult and len(self.searchresult): 227 for each in self.searchresult: 228 if not IsValidDestination(each.itemID): 229 continue 230 wasID = each.itemID 231 found = [each.itemName] 232 while wasID: 233 wasID = mapSvc.GetParent(wasID) 234 if wasID: 235 item = mapSvc.GetItem(wasID) 236 if item is not None: 237 found.append(item.itemName) 238 239 if len(found) == 3: 240 trace = localization.GetByLabel('UI/Map/MapPallet/Trace3Locations', location1=found[0], location2=found[1], location3=found[2]) 241 elif len(found) == 2: 242 trace = localization.GetByLabel('UI/Map/MapPallet/Trace2Locations', location1=found[0], location2=found[1]) 243 else: 244 trace = '/'.join(found) 245 entry = GetFromClass(LocationSearchItem, {'itemID': each.itemID, 246 'typeID': each.typeID, 247 'genericDisplayLabel': found[0], 248 'label': '%s<t>%s' % (trace, evetypes.GetName(each.typeID))}) 249 scrolllist.append(entry) 250 251 if self is None or self.destroyed: 252 return 253 headers = [localization.GetByLabel('UI/Map/MapPallet/hdrSearchName'), localization.GetByLabel('UI/Map/MapPallet/hdrSearchType')] 254 self.sr.scroll.Load(contentList=scrolllist, headers=headers) 255 if not len(scrolllist): 256 self.SetHint(localization.GetByLabel('UI/Map/MapPallet/lblSearchNothingFound')) 257 258 def Confirm(self, *args): 259 pass 260 261 def Deselect(self, *args): 262 pass 263 264 def Select(self, selection, *args): 265 sm.GetService('starmap').SetInterest(selection.id) 266 267 def OnLoadWMCPSettings(self, tabName): 268 if self.loadedTab == tabName: 269 self.LoadSettings(tabName) 270 271 def LoadSettings(self, what): 272 scrolllist = [] 273 if what == 'mapsettings_lines': 274 showlines = settings.user.ui.Get('showlines', 4) 275 scrolllist.append(GetFromClass(Header, {'label': localization.GetByLabel('UI/Map/MapPallet/hdrConnectionLines')})) 276 for config in [['showlines', 277 0, 278 localization.GetByLabel('UI/Map/MapPallet/cbNoLines'), 279 showlines == 0], 280 ['showlines', 281 1, 282 localization.GetByLabel('UI/Map/MapPallet/cbSelectionLinesOnly'), 283 showlines == 1], 284 ['showlines', 285 2, 286 localization.GetByLabel('UI/Map/MapPallet/cbSelectionRegionLinesOnly'), 287 showlines == 2], 288 ['showlines', 289 3, 290 localization.GetByLabel('UI/Map/MapPallet/cbSelectionRegionNeighborLinesOnly'), 291 showlines == 3], 292 ['showlines', 293 4, 294 localization.GetByLabel('UI/Map/MapPallet/cbAllLinesOnly'), 295 showlines == 4]]: 296 self.AddCheckBox(config, scrolllist, 'showlines') 297 298 for config in [['map_alliance_jump_lines', 299 None, 300 localization.GetByLabel('UI/Map/MapPallet/cbAllianceJumpLines'), 301 settings.user.ui.Get('map_alliance_jump_lines', 1) == 1]]: 302 self.AddCheckBox(config, scrolllist) 303 304 showJumpBridgesSetting = settings.user.ui.Get('showJumpBridges', 0) 305 for config in [['showJumpBridges', 306 0, 307 localization.GetByLabel('UI/Map/MapPallet/cbMyJumpBridges'), 308 showJumpBridgesSetting == 0], ['showJumpBridges', 309 1, 310 localization.GetByLabel('UI/Map/MapPallet/cbAllJumpBridges'), 311 showJumpBridgesSetting == 1]]: 312 self.AddCheckBox(config, scrolllist, 'showJumpBridges') 313 314 scrolllist.append(GetFromClass(Header, {'label': localization.GetByLabel('UI/Map/MapPallet/hdrColorLinesBy')})) 315 for config in [['mapcolorby', 316 mapcommon.COLORMODE_UNIFORM, 317 localization.GetByLabel('UI/Map/MapPallet/cbColorByJumpType'), 318 settings.user.ui.Get('mapcolorby', mapcommon.COLORMODE_UNIFORM) == mapcommon.COLORMODE_UNIFORM], ['mapcolorby', 319 mapcommon.COLORMODE_REGION, 320 localization.GetByLabel('UI/Map/MapPallet/cbColorByRegion'), 321 settings.user.ui.Get('mapcolorby', mapcommon.COLORMODE_UNIFORM) == mapcommon.COLORMODE_REGION], ['mapcolorby', 322 mapcommon.COLORMODE_STANDINGS, 323 localization.GetByLabel('UI/Map/MapPallet/cbColorByStanding'), 324 settings.user.ui.Get('mapcolorby', mapcommon.COLORMODE_UNIFORM) == mapcommon.COLORMODE_STANDINGS]]: 325 self.AddCheckBox(config, scrolllist, 'mapcolorby') 326 327 if what == 'mapsettings_tiles': 328 scrolllist.append(GetFromClass(Header, {'label': localization.GetByLabel('UI/Map/MapPallet/hdrTileSettings')})) 329 for config in [['map_tile_no_tiles', 330 None, 331 localization.GetByLabel('UI/Map/MapPallet/cbTilesNone'), 332 settings.user.ui.Get('map_tile_no_tiles', 1) == 1], 333 ['map_tile_activity', 334 None, 335 localization.GetByLabel('UI/Map/MapPallet/cbTilesSovChanges'), 336 settings.user.ui.Get('map_tile_activity', 0) == 1], 337 ['map_tile_show_unflattened', 338 None, 339 localization.GetByLabel('UI/Map/MapPallet/cbTilesSovChangesUnflattened'), 340 settings.user.ui.Get('map_tile_show_unflattened', 0) == 1], 341 ['map_tile_show_outlines', 342 None, 343 localization.GetByLabel('UI/Map/MapPallet/cbTilesSovChangesOutlined'), 344 settings.user.ui.Get('map_tile_show_outlines', 1) == 1]]: 345 self.AddCheckBox(config, scrolllist) 346 347 activeTileMode = settings.user.ui.Get('map_tile_mode', 0) 348 scrolllist.append(GetFromClass(Header, {'label': localization.GetByLabel('UI/Map/MapPallet/hdrTileSovColorBy')})) 349 for tileMode, text in [(0, localization.GetByLabel('UI/Map/MapPallet/cbTilesSovereignty')), (1, localization.GetByLabel('UI/Map/MapPallet/cbTilesStandings'))]: 350 config = ['map_tile_mode', 351 tileMode, 352 text, 353 activeTileMode == tileMode] 354 self.AddCheckBox(config, scrolllist, 'map_tile_mode') 355 356 if what == 'mapsettings_legend': 357 scrolllist += self.GetLegendGroups() 358 starscolorby = settings.user.ui.Get('starscolorby', mapcommon.STARMODE_SECURITY) 359 if what == 'starview_color': 360 scrolllist += self.GetStarColorGroups() 361 if what == 'mapsettings_solarsystem': 362 scrolllist += maputils.GetSolarSystemOptions() 363 if what == 'mapsettings_other': 364 self.AddCheckBox(['mapautoframe', 365 None, 366 localization.GetByLabel('UI/Map/MapPallet/cbAnimFrameSelect'), 367 settings.user.ui.Get('mapautoframe', 1) == 1], scrolllist) 368 if settings.user.ui.Get('mapautoframe', 1) == 1: 369 self.AddCheckBox(['mapautozoom', 370 None, 371 localization.GetByLabel('UI/Map/MapPallet/cbAnimAutoZoom'), 372 settings.user.ui.Get('mapautozoom', 0) == 1], scrolllist) 373 if what == 'mapsettings_labels': 374 scrolllist.append(GetFromClass(Header, {'label': localization.GetByLabel('UI/Map/MapPallet/hdrRegionLables')})) 375 for config in [['rlabel_region', 376 0, 377 localization.GetByLabel('UI/Map/MapPallet/cbRegionNoLabel'), 378 settings.user.ui.Get('rlabel_region', 1) == 0], 379 ['rlabel_region', 380 1, 381 localization.GetByLabel('UI/Map/MapPallet/cbRegionSelected'), 382 settings.user.ui.Get('rlabel_region', 1) == 1], 383 ['rlabel_region', 384 2, 385 localization.GetByLabel('UI/Map/MapPallet/cbRegionAndNeigbour'), 386 settings.user.ui.Get('rlabel_region', 1) == 2], 387 ['rlabel_region', 388 3, 389 localization.GetByLabel('UI/Map/MapPallet/cbRegionAll'), 390 settings.user.ui.Get('rlabel_region', 1) == 3]]: 391 self.AddCheckBox(config, scrolllist, 'rlabel_region') 392 393 scrolllist.append(GetFromClass(Header, {'label': localization.GetByLabel('UI/Map/MapPallet/hdrOtherLables')})) 394 for config in [['label_constellation', 395 None, 396 localization.GetByLabel('UI/Map/MapPallet/cbOtherConstellation'), 397 settings.user.ui.Get('label_constellation', 1) == 1], ['label_solarsystem', 398 None, 399 localization.GetByLabel('UI/Map/MapPallet/cbOtherSolarSysytem'), 400 settings.user.ui.Get('label_solarsystem', 1) == 1], ['label_landmarknames', 401 None, 402 localization.GetByLabel('UI/Map/MapPallet/cbOtherLandmarks'), 403 settings.user.ui.Get('label_landmarknames', 1) == 1]]: 404 self.AddCheckBox(config, scrolllist) 405 406 if self.destroyed: 407 return 408 self.sr.scroll2.Load(contentList=scrolllist) 409 410 def GetActiveStarColorMode(self): 411 starscolorby = settings.user.ui.Get('starscolorby', mapcommon.STARMODE_SECURITY) 412 if not self.starColorByID: 413 self.starColorByID = {} 414 groupList = ['Root'] + self.GetAllStarColorGroupLabels() 415 try: 416 groupList.remove('Sovereignty_Sovereignty') 417 except ValueError: 418 log.LogError('Error while removing a sov option from the prime list - a long load may be impending!') 419 420 for groupName in groupList: 421 func = getattr(self, 'Get%sOptions' % groupName, None) 422 if func is None: 423 continue 424 ops = func() 425 for label, id in ops: 426 self.starColorByID[id] = (groupName, label) 427 428 if starscolorby not in self.starColorByID: 429 if type(starscolorby) == types.TupleType and starscolorby[0] in (mapcommon.STARMODE_FACTION, mapcommon.STARMODE_MILITIA, mapcommon.STARMODE_FACTIONEMPIRE): 430 _starmode, factionID = starscolorby 431 options = {mapcommon.STARMODE_FACTION: ('Sovereignty_Sovereignty', localization.GetByLabel('UI/Map/MapPallet/cbModeFactions')), 432 mapcommon.STARMODE_FACTIONEMPIRE: ('Sovereignty_Sovereignty', localization.GetByLabel('UI/Map/MapPallet/cbStarsByEmpireFactions'))}.get(_starmode, (None, None)) 433 colorBy, factionName = options 434 if factionID >= 0: 435 factionName = cfg.eveowners.Get(factionID).name 436 self.starColorByID[starscolorby] = (colorBy, factionName) 437 elif starscolorby == mapcommon.STARMODE_SOV_STANDINGS: 438 self.starColorByID[starscolorby] = ('Sovereignty_Sovereignty', localization.GetByLabel('UI/Map/MapPallet/cbStarsByStandings')) 439 return self.starColorByID.get(starscolorby, (None, None)) 440 441 def GetStarColorEntries(self, forGroup): 442 starscolorby = settings.user.ui.Get('starscolorby', mapcommon.STARMODE_SECURITY) 443 func = getattr(maputils, 'Get%sOptions' % forGroup, None) 444 if not func: 445 log.LogError('Missing function to provide options for', forGroup) 446 return [] 447 scrolllist = [] 448 sublevel = 2 if forGroup.find('_') > 0 else 0 449 for label, flag in func(): 450 config = ['starscolorby', 451 flag, 452 label, 453 starscolorby == flag] 454 entry = self.AddCheckBox(config, None, 'starscolorby', sublevel=sublevel) 455 scrolllist.append(entry) 456 457 return scrolllist 458 459 def GetAllStarColorGroupLabels(self): 460 self.GetStarColorGroupsSorted() 461 topLevel = [ each[0] for each in self.starColorGroups ] 462 tmp = [ each[2] for each in self.starColorGroups if each[2] != [] ] 463 subLevel = [] 464 for each in tmp: 465 subLevel.extend([ yu[0] for yu in each ]) 466 467 return topLevel + subLevel 468 469 def GetStarColorGroupsSorted(self): 470 if not self.starColorGroups: 471 starColorGroups = [('Personal', localization.GetByLabel('UI/Map/MapPallet/hdrStarsMyInformation'), []), 472 ('Services', localization.GetByLabel('UI/Map/MapPallet/hdrStarsServices'), []), 473 ('Statistics', localization.GetByLabel('UI/Map/MapPallet/hdrStarsStatistics'), []), 474 ('Sovereignty', localization.GetByLabel('UI/Map/MapPallet/hdrStarsSovereignty'), [('Sovereignty_FactionalWarfare', localization.GetByLabel('UI/Map/MapPallet/hdrStarsSovereigntyFacWar'), []), 475 ('Sovereignty_Sovereignty', localization.GetByLabel('UI/Map/MapPallet/hdrStarsSovereignty'), []), 476 ('Sovereignty_Changes', localization.GetByLabel('UI/Map/MapPallet/hdrStarsSovereigntyChanges'), []), 477 ('Sovereignty_Development_Indices', localization.GetByLabel('UI/Map/MapPallet/hdrStarsSovereigntyIndixes'), []), 478 ('Sovereignty_Insurgency', localization.GetByLabel('UI/Map/MapPallet/insurgencies'), [])]), 479 ('Autopilot', localization.GetByLabel('UI/Map/MapPallet/hdrStarsAutoPilot'), []), 480 ('Planets', localization.GetByLabel('UI/Map/MapPallet/hdrStarsPlanets'), []), 481 ('Industry', localization.GetByLabel('UI/Map/MapPallet/hdrStarsIndustry'), [('Industry_Jobs', localization.GetByLabel('UI/Map/MapPallet/hdrIndustryJobs'), []), ('Industry_CostModifier', localization.GetByLabel('UI/Map/MapPallet/hdrIndustryCostModifier'), [])])] 482 for group, label, subitems in starColorGroups: 483 if subitems: 484 temp = [] 485 for _group, _label, _subitems in subitems: 486 temp.append((_label, (_group, _label, _subitems))) 487 488 temp = SortListOfTuples(temp) 489 subitems = temp 490 self.starColorGroups.append((label, (group, label, subitems))) 491 492 self.starColorGroups = SortListOfTuples(self.starColorGroups) 493 return self.starColorGroups 494 495 def GetStarColorGroups(self): 496 self.GetStarColorGroupsSorted() 497 starscolorby = settings.user.ui.Get('starscolorby', mapcommon.STARMODE_SECURITY) 498 scrolllist = self.GetStarColorEntries('Root') 499 activeGroup, activeLabel = self.GetActiveStarColorMode() 500 for groupName, groupLabel, subitems in self.starColorGroups: 501 id = ('mappalette', groupName) 502 uicore.registry.SetListGroupOpenState(id, 0) 503 data = {'GetSubContent': self.GetSubContent, 504 'label': groupLabel, 505 'id': id, 506 'groupItems': subitems, 507 'iconMargin': 32, 508 'showlen': 0, 509 'state': 'locked', 510 'BlockOpenWindow': 1, 511 'key': groupName} 512 if activeGroup == groupName: 513 data['posttext'] = localization.GetByLabel('UI/Map/MapPallet/lblActiveColorCategory', activeLabel=activeLabel) 514 elif activeGroup is not None and activeGroup.startswith(groupName + '_'): 515 for subgroupName, subgroupLabel, subsubitems in subitems: 516 if activeGroup == subgroupName: 517 data['posttext'] = localization.GetByLabel('UI/Map/MapPallet/lblActiveColorCategory', activeLabel=subgroupLabel) 518 519 scrolllist.append(GetFromClass(ListGroup, data)) 520 521 return scrolllist 522 523 def GetStarColorSubGroups(self, subitems): 524 scrolllist = [] 525 activeGroup, activeLabel = self.GetActiveStarColorMode() 526 for groupName, groupLabel, subitems in subitems: 527 id = ('mappalette', groupName) 528 uicore.registry.SetListGroupOpenState(id, 0) 529 data = {'GetSubContent': self.GetSubContent, 530 'label': groupLabel, 531 'id': id, 532 'groupItems': [], 533 'iconMargin': 32, 534 'showlen': 0, 535 'state': 'locked', 536 'BlockOpenWindow': 1, 537 'key': groupName, 538 'sublevel': 1} 539 if activeGroup == groupName: 540 data['posttext'] = localization.GetByLabel('UI/Map/MapPallet/lblActiveColorCategory', activeLabel=activeLabel) 541 scrolllist.append(GetFromClass(ListGroup, data)) 542 543 return scrolllist 544 545 def GetSubContent(self, data, newitems = 0): 546 if data.groupItems: 547 return self.GetStarColorSubGroups(data.groupItems) 548 for entry in self.sr.scroll.GetNodes(): 549 if entry.__guid__ != 'listentry.Group' or entry.id == data.id: 550 continue 551 if entry.open: 552 if entry.panel: 553 entry.panel.Toggle() 554 else: 555 uicore.registry.SetListGroupOpenState(entry.id, 0) 556 entry.scroll.PrepareSubContent(entry) 557 558 if data.key in self.GetAllStarColorGroupLabels(): 559 return self.GetStarColorEntries(data.key) 560 return [] 561 562 def UpdateActiveStarColor(self): 563 activeGroup, activeLabel = self.GetActiveStarColorMode() 564 for entry in self.sr.scroll.GetNodes(): 565 if entry.__guid__ != 'listentry.Group' or entry.key not in self.GetAllStarColorGroupLabels(): 566 continue 567 post = '' 568 if entry.key == activeGroup: 569 post = localization.GetByLabel('UI/Map/MapPallet/lblActiveColorCategory', activeLabel=activeLabel) 570 entry.posttext = post 571 if entry.panel: 572 entry.panel.UpdateLabel() 573 574 def GetLegendGroups(self): 575 common = {'groupItems': [], 576 'iconMargin': 32, 577 'showlen': 0, 578 'state': 'locked', 579 'BlockOpenWindow': 1} 580 scrolllist = [] 581 forLst = [('star', localization.GetByLabel('UI/Map/MapPallet/tabStars')), ('tile', localization.GetByLabel('UI/Map/MapPallet/tabTiles'))] 582 for groupName, groupLabel in forLst: 583 id = ('mappalette', groupName) 584 uicore.registry.SetListGroupOpenState(id, 0) 585 data = common.copy() 586 data.update({'GetSubContent': self.GetLegendEntries, 587 'label': groupLabel, 588 'id': id, 589 'key': groupName}) 590 scrolllist.append(GetFromClass(ListGroup, data)) 591 592 return scrolllist 593 594 def GetLegendEntries(self, data): 595 legendList = sm.GetService('starmap').GetLegend(data.key) 596 legendList.sort() 597 scrolllist = [] 598 for legendItem in legendList: 599 scrolllist.append(GetFromClass(LegendEntry, {'label': legendItem.caption, 600 'key': data.key, 601 'editable': False, 602 'selectable': True, 603 'hilightable': False, 604 'legend': legendItem})) 605 606 return scrolllist 607 608 def SetHint(self, hintstr = None): 609 if self.sr.scroll: 610 self.sr.scroll.ShowHint(hintstr) 611 self.sr.scroll2.ShowHint(hintstr) 612 613 def AddCheckBox(self, config, scrolllist, group = None, sublevel = 0): 614 cfgname, retval, desc, default = config 615 data = {'label': desc, 616 'checked': default, 617 'cfgname': cfgname, 618 'retval': retval, 619 'group': group, 620 'sublevel': sublevel, 621 'OnChange': self.CheckBoxChange} 622 if scrolllist is not None: 623 scrolllist.append(GetFromClass(CheckboxEntry, data)) 624 else: 625 return GetFromClass(CheckboxEntry, data) 626 627 def CheckBoxChange(self, button, *args): 628 starmapSvc = sm.GetService('starmap') 629 key = button.GetSettingsKey() 630 if isinstance(button, RadioButton): 631 val = button.GetReturnValue() 632 else: 633 val = button.checked 634 settings.user.ui.Set(key, val) 635 if key == 'mapautoframe': 636 self.LoadSettings('mapsettings_other') 637 viewingStarmap = sm.GetService('viewState').IsViewActive('starmap') 638 if viewingStarmap: 639 if key == 'mapautoframe': 640 starmapSvc.SetInterest() 641 elif key == 'mapautozoom': 642 starmapSvc.SetInterest() 643 elif key == 'mapcolorby': 644 starmapSvc.UpdateLines(updateColor=1) 645 elif key in ('showlines', 'map_alliance_jump_lines', 'showJumpBridges'): 646 starmapSvc.UpdateLines() 647 elif key == 'starscolorby': 648 starmapSvc.SetStarColorMode() 649 self.UpdateActiveStarColor() 650 elif key[:6] == 'label_': 651 starmapSvc.CheckAllLabels('Mappalette::CheckBoxChange') 652 elif key == 'rlabel_region': 653 starmapSvc.CheckAllLabels('Mappalette::CheckBoxChange2') 654 elif key.startswith('map_tile_'): 655 starmapSvc.UpdateHexMap() 656 657 def AddSeperator(self, height, where): 658 Container(name='push', align=uiconst.TOTOP, height=height, parent=where) 659 660 def AddHeader(self, header, where, height = 12): 661 eveLabel.EveLabelMedium(text=header, parent=where, align=uiconst.TOTOP, height=12, state=uiconst.UI_NORMAL) 662 663 def OnSelectionChange(self, selected): 664 dataList = [] 665 colorList = [] 666 for node in selected: 667 if node.key == 'tile': 668 if node.legend.data is not None: 669 dataList.append(node.legend.data) 670 else: 671 colorList.append(node.legend.color) 672 673 if sm.GetService('viewState').IsViewActive('starmap'): 674 sm.GetService('starmap').HighlightTiles(dataList, colorList) 675 676 def Minimize(self, *args, **kwds): 677 if self.windowID == 'mapspalette': 678 settings.user.ui.Set('MapWindowMinimized', True) 679 Window.Minimize(self, *args, **kwds) 680 681 def Maximize(self, *args, **kwds): 682 if self.windowID == 'mapspalette': 683 settings.user.ui.Set('MapWindowMinimized', False) 684 Window.Maximize(self, *args, **kwds)