def GetMap(self, src): if self.destroyed: return data = uiutil.PrepareArgs(src[8:]) if 'ids' not in data: log.LogError('Invalid starmap data:', data, ' (missing ids)') return if 'level' in data: drawLevel = self.DRAW_LEVELS[data['level'].lower()] else: drawLevel = 3 ids = [] if type(data['ids']) == types.IntType: ids = [data['ids']] else: for each in data['ids'].replace(' ', '').split(','): try: ids.append(int(each)) except Exception as e: log.LogWarn(e) if not ids: idLevel = 0 if util.IsRegion(ids[0]): idLevel = 1 if util.IsConstellation(ids[0]): idLevel = 2 if util.IsSolarSystem(ids[0]): idLevel = 3 import xtriui pilmap = xtriui.Map2D(parent=self, align=uiconst.TOALL) pilmap.Draw(ids, idLevel, drawLevel, int(self.attrs.size)) if self.destroyed: return for each in pilmap.children[:]: if each.name == 'frame': each.Close() if 'marks' in data: marks = [] for each in data['marks'].split(','): mark = each.split('::') if len(mark) == 4: try: id = int(mark[0]) hint = unicode(mark[1]) color = unicode(mark[2]) sumin = mark[3] marks += [id, hint, color, sumin] except Exception as e: log.LogWarn('Failed mark parsing', mark, e) if marks: pilmap.SetMarks(marks) pilmap.UpdateMyLocation()
def GetMap(self, ids, idlevel, drawlevel, selected = None): if getattr(self, 'loadingMap', 0): return self.loadingMap = 1 uiutil.FlushList(self.children[idlevel:]) self.ids[idlevel] = ids cfg.evelocations.Prime(ids) l, t, absWidth, absHeight = self.GetAbsolute() pilmap = xtriui.Map2D(name='map', align=uiconst.TOTOP, state=uiconst.UI_NORMAL, height=absWidth) pilmap.OnSelectItem = self.OnMapSelection pilmap.GetParentMenu = self.GetMenu pilmapList = [] basesize = self.absoluteRight - self.absoluteLeft if drawlevel == DRAWLVLSYS: pilmap.width = pilmap.height = basesize pilmap.left = pilmap.top = (pilmap.width - basesize) / 2 pilmap.align = uiconst.RELATIVE pilmap.dragAllowed = 1 mapparent = uiprimitives.Container(name='mapparent', align=uiconst.TOTOP, lockAspect=1, parent=self, clipChildren=1, height=absWidth) LineThemeColored(parent=mapparent, align=uiconst.TOBOTTOM) pilmapList = mapparent.children self.SetLoadExternalPointer(mapparent, self.ids[idlevel][0]) addstuff = mapparent else: LineThemeColored(parent=pilmap.overlays, align=uiconst.TOBOTTOM) pilmapList = self.children self.SetLoadExternalPointer(pilmap, self.ids[idlevel][0]) addstuff = pilmap.overlays pilmap.Draw(ids, idlevel, drawlevel, basesize) uicore.animations.FadeIn(pilmap, duration=0.3) pilmapList.append(pilmap) listicon = xtriui.ListSurroundingsBtn(parent=addstuff, align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL, pos=(0, 3, 16, 16), idx=0, showIcon=True) locConsts = {0: {const.typeUniverse: ''}, 1: {const.typeRegion: localization.GetByLabel('UI/Common/LocationTypes/Region')}, 2: {const.typeConstellation: localization.GetByLabel('UI/Common/LocationTypes/Constellation')}, 3: {const.typeSolarSystem: localization.GetByLabel('UI/Common/LocationTypes/SolarSystem')}} levelName = locConsts.get(idlevel, '').values()[0] levelID = locConsts.get(idlevel, '').keys()[0] for id in ids: if levelID != const.typeUniverse: locName = cfg.evelocations.Get(id).name hintStr = '' buttonStr = '' if levelID == const.typeUniverse: buttonStr = localization.GetByLabel('UI/Common/LocationTypes/Universe') hintStr = localization.GetByLabel('UI/Map/MapBrowser/ListRegions') elif levelID == const.typeRegion: buttonStr = localization.GetByLabel('UI/Map/MapBrowser/NameRegion', name=locName) hintStr = localization.GetByLabel('UI/Map/MapBrowser/ListConstellations', name=locName) elif levelID == const.typeConstellation: buttonStr = localization.GetByLabel('UI/Map/MapBrowser/NameConstellation', name=locName) hintStr = localization.GetByLabel('UI/Map/MapBrowser/ListSolarSystems', name=locName) elif levelID == const.typeSolarSystem: buttonStr = localization.GetByLabel('UI/Map/MapBrowser/NameSolarSystem', name=locName) hintStr = localization.GetByLabel('UI/Map/MapBrowser/ListCelestials', name=locName) listbtn = uicontrols.EveLabelMedium(text=buttonStr, parent=addstuff, left=listicon.left + listicon.width + 4, top=5, color=(1.0, 1.0, 1.0, 0.75), idx=0, state=uiconst.UI_NORMAL) listbtn.expandOnLeft = True listbtn.GetMenu = listicon.GetMenu for id in ids: if id != const.typeUniverse: listicon.sr.typeID = listbtn.sr.typeID = levelID listicon.sr.itemID = listbtn.sr.itemID = id listbtn.sr.hint = hintStr if self.destroyed: return if drawlevel == DRAWLVLSYS: listbtn.sr.groupByType = listicon.sr.groupByType = 1 listbtn.sr.mapitems = listicon.sr.mapitems = pilmap.mapitems elif drawlevel in (DRAWLVLCON, DRAWLVLSOL): listbtn.sr.mapitems = listicon.sr.mapitems = pilmap.mapitems[1:] else: listbtn.sr.mapitems = listicon.sr.mapitems = pilmap.mapitems listbtn.solarsystemid = listicon.solarsystemid = ids[0] if selected: pilmap.SetSelected([selected]) self.Refresh() self.loadingMap = 0