Exemplo n.º 1
0
 def GetLocationChildren(self, itemID):
     if util.IsConstellation(itemID):
         return cfg.mapConstellationCache.Get(itemID).solarSystemIDs
     if util.IsRegion(itemID):
         return cfg.mapRegionCache.Get(itemID).constellationIDs
     raise Exception('Unexpected itemID calling GetLocationChildren?' +
                     str(itemID))
Exemplo n.º 2
0
 def GetParentLocationID(self, locationID):
     if util.IsSolarSystem(locationID):
         solarSystem = cfg.mapSystemCache.Get(locationID)
         return (const.locationUniverse, solarSystem.regionID,
                 solarSystem.constellationID, locationID, None)
     if util.IsConstellation(locationID):
         constellation = cfg.mapConstellationCache.Get(locationID)
         return (const.locationUniverse, constellation.regionID, locationID,
                 None, None)
     if util.IsRegion(locationID):
         return (const.locationUniverse, locationID, None, None, None)
     if util.IsCelestial(locationID):
         solarSystemID = cfg.mapCelestialLocationCache[locationID]
         solarSystem = cfg.mapSystemCache.Get(solarSystemID)
         return (const.locationUniverse, solarSystem.regionID,
                 solarSystem.constellationID, solarSystemID, locationID)
     if util.IsStation(locationID):
         station = cfg.stations.Get(locationID)
         ssID = station.solarSystemID
         solarSystem = cfg.mapSystemCache.Get(ssID)
         return (const.locationUniverse, solarSystem.regionID,
                 solarSystem.constellationID, ssID, locationID)
     ssID = cfg.evelocations.Get(locationID).solarSystemID
     if ssID is None:
         structureInfo = sm.GetService(
             'structureDirectory').GetStructureInfo(locationID)
         if structureInfo is not None:
             ssID = structureInfo.solarSystemID
     if ssID is not None:
         mapData = cfg.mapSystemCache.Get(ssID)
         return (const.locationUniverse, mapData.regionID,
                 mapData.constellationID, ssID, locationID)
     return (const.locationUniverse, None, None, None, locationID)
Exemplo n.º 3
0
 def GetSolarSystemIDsIn(self, i):
     if util.IsSolarSystem(i):
         return [i]
     if util.IsConstellation(i):
         return list(cfg.mapConstellationCache.Get(i).solarSystemIDs)
     if util.IsRegion(i):
         return list(cfg.mapRegionCache.Get(i).solarSystemIDs)
Exemplo n.º 4
0
    def Linkify(self, locationID, linkText):
        if util.IsRegion(locationID):
            locationTypeID = const.typeRegion
        elif util.IsConstellation(locationID):
            locationTypeID = const.typeConstellation
        elif util.IsSolarSystem(locationID):
            locationTypeID = const.typeSolarSystem
        else:
            if util.IsCelestial(locationID):
                warnText = "LOCALIZATION ERROR: 'linkify' argument used for a location of type celestial."
                warnText += " This is not supported. Please use the 'linkinfo' tag with arguments instead. locID:"
                localization.LogWarn(warnText, locationID)
                return linkText
            if util.IsStation(locationID):
                try:
                    locationTypeID = cfg.stations.Get(locationID).stationTypeID
                except KeyError:
                    return '[no station: %d]' % locationID

            else:
                localization.LogInfo(
                    "LOCALIZATION LINK: The 'linkify' argument was used for a location whose type can not be identified.",
                    locationID)
                return linkText
        return '<a href=showinfo:%d//%d>%s</a>' % (locationTypeID, locationID,
                                                   linkText)
Exemplo n.º 5
0
    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()
Exemplo n.º 6
0
 def GetItem(self, itemID, retall=False):
     if util.IsStation(itemID):
         station = cfg.stations.Get(itemID)
         return util.KeyVal(itemID=itemID,
                            locationID=station.solarSystemID,
                            itemName=cfg.evelocations.Get(itemID).name,
                            typeID=station.stationTypeID,
                            groupID=const.groupStation,
                            x=station.x,
                            y=station.y,
                            z=station.z)
     if util.IsSolarSystem(itemID):
         solarSystem = cfg.mapSystemCache.Get(itemID)
         return util.KeyVal(
             itemID=itemID,
             locationID=solarSystem.constellationID,
             itemName=cfg.evelocations.Get(itemID).name,
             typeID=const.typeSolarSystem,
             groupID=const.groupSolarSystem,
             factionID=getattr(solarSystem, 'factionID', None),
             neighbours=[i.solarSystemID for i in solarSystem.neighbours],
             x=solarSystem.center.x,
             y=solarSystem.center.y,
             z=solarSystem.center.z,
             security=solarSystem.securityStatus)
     if util.IsConstellation(itemID):
         constellation = cfg.mapConstellationCache.Get(itemID)
         return util.KeyVal(itemID=itemID,
                            locationID=constellation.regionID,
                            itemName=cfg.evelocations.Get(itemID).name,
                            typeID=const.typeConstellation,
                            neighbours=list(constellation.neighbours),
                            groupID=const.groupConstellation,
                            x=constellation.center.x,
                            y=constellation.center.y,
                            z=constellation.center.z)
     if util.IsRegion(itemID):
         region = cfg.mapRegionCache.Get(itemID)
         return util.KeyVal(itemID=itemID,
                            locationID=const.locationUniverse,
                            itemName=cfg.evelocations.Get(itemID).name,
                            neighbours=list(region.neighbours),
                            typeID=const.typeRegion,
                            groupID=const.groupRegion,
                            x=region.center.x,
                            y=region.center.y,
                            z=region.center.z)
     if util.IsCelestial(itemID):
         solarSystemID = cfg.mapCelestialLocationCache[itemID]
         typeID, pos = self._GetCelestialsTypeIdAndPosition(
             itemID, solarSystemID)
         return util.KeyVal(itemID=itemID,
                            locationID=solarSystemID,
                            itemName=cfg.evelocations.Get(itemID).name,
                            typeID=typeID,
                            x=pos[0],
                            y=pos[1],
                            z=pos[2])
Exemplo n.º 7
0
 def ShowSovereignty(self, itemID):
     if util.IsConstellation(itemID):
         constellationID = itemID
     if util.IsSolarSystem(itemID):
         systemID = itemID
     if util.IsRegion(itemID):
         regionID = itemID
     location = (systemID, constellationID, regionID)
     sm.GetService('sov').GetSovOverview(location)
Exemplo n.º 8
0
    def ExpandItems(self, itemIDs):
        ret = []
        for i in itemIDs:
            if util.IsSolarSystem(i):
                ret.append(i)
            elif util.IsConstellation(i):
                ret.extend(self.GetChildren(i))
            elif util.IsRegion(i):
                for constellation in self.GetChildren(i):
                    ret.extend(self.GetChildren(constellation))

        return ret
Exemplo n.º 9
0
 def GetMenu(self):
     m = []
     if self.legend.data is not None:
         m += sm.GetService('menu').GetGMMenu(itemID=self.legend.data)
     if self.legend.data is not None:
         if util.IsFaction(self.legend.data):
             m += sm.GetService('menu').GetMenuFormItemIDTypeID(self.legend.data, const.typeFaction)
         elif util.IsRegion(self.legend.data):
             m += sm.GetService('menu').CelestialMenu(self.legend.data)
         else:
             m += sm.GetService('menu').GetMenuFormItemIDTypeID(self.legend.data, const.typeAlliance)
     return m
Exemplo n.º 10
0
 def GetNeighbors(self, itemID):
     if util.IsWormholeSystem(itemID) or util.IsWormholeConstellation(itemID) or util.IsWormholeRegion(itemID):
         return []
     if util.IsSolarSystem(itemID):
         solarSystem = cfg.mapSystemCache.Get(itemID)
         return [ i.solarSystemID for i in solarSystem.neighbours ]
     if util.IsConstellation(itemID):
         constellation = cfg.mapConstellationCache.Get(itemID)
         return constellation.neighbours
     if util.IsRegion(itemID):
         region = cfg.mapRegionCache.Get(itemID)
         return region.neighbours
     return []
Exemplo n.º 11
0
    def ShowAll(self, key, keyID, sortKey, *args):
        if keyID is None:
            keyID = settings.char.ui.Get('assetsKeyID_%s' % key, None)
        oldSortKey = settings.char.ui.Get('assetsSortKey', None)
        if sortKey is not None:
            if oldSortKey != sortKey:
                for k in self.scrollPosition.keys():
                    self.scrollPosition[k] = 0.0

        else:
            sortKey = oldSortKey
        settings.char.ui.Set('assetsKeyID_%s' % key, keyID)
        settings.char.ui.Set('assetsSortKey', sortKey)
        self.ShowLoad()
        self.SetHint()
        closed = [0, 1][getattr(self, 'invalidateOpenState_%s' % key, 0)]
        sortlocations = sm.StartService('assets').GetAll(key, keyID=keyID, sortKey=sortKey)
        options = [(localization.GetByLabel('UI/Common/Current'), (key, 0))]
        opts = {}
        for r in sm.StartService('assets').locationCache.iterkeys():
            if key == 'regitems' and util.IsRegion(r) or key == 'conitems' and util.IsConstellation(r) or key == 'sysitems' and util.IsSolarSystem(r):
                opts[cfg.evelocations.Get(r).name] = r

        keys = opts.keys()
        keys.sort()
        for k in keys:
            options.append((k, (key, opts[k])))

        try:
            self.sr.filtcombo.LoadOptions(options, None)
            if keyID:
                self.sr.filtcombo.SelectItemByLabel(cfg.evelocations.Get(keyID).name)
            if sortKey:
                self.sr.sortcombo.SelectItemByIndex(sortKey)
        except (Exception,):
            sys.exc_clear()

        scrolllist = []
        for solarsystemID, station in sortlocations:
            scrolllist.append(listentry.Get('Group', self.GetLocationData(solarsystemID, station, key, forceClosed=closed, scrollID=self.sr.scroll.sr.id, sortKey=sortKey)))

        if self.destroyed:
            return
        setattr(self, 'invalidateOpenState_%s' % key, 0)
        locText = {'allitems': localization.GetByLabel('UI/Inventory/AssetsWindow/NoAssetsAtStation'),
         'regitems': localization.GetByLabel('UI/Inventory/AssetsWindow/NoAssetsInRegion'),
         'conitems': localization.GetByLabel('UI/Inventory/AssetsWindow/NoAssetsInConstellation'),
         'sysitems': localization.GetByLabel('UI/Inventory/AssetsWindow/NoAssetsInSolarSystem')}
        scrollPosition = self.scrollPosition[key]
        self.sr.scroll.Load(contentList=scrolllist, headers=uix.GetInvItemDefaultHeaders(), noContentHint=locText[key], scrollTo=scrollPosition)
        self.HideLoad()
Exemplo n.º 12
0
    def GetFilterOptions(self, rows, flagName):
        filterOptions = self.GetRegions(rows, flagName)
        options = [(localization.GetByLabel('UI/Corporations/Assets/CurrentRegion'), (flagName, 0)), (localization.GetByLabel('UI/Corporations/Assets/AllRegions'), (flagName, 1))]
        opts = {}
        for r in filterOptions:
            if util.IsRegion(r):
                label = localization.GetByLabel('UI/Common/LocationDynamic', location=r)
                opts[label] = r

        keys = opts.keys()
        keys.sort()
        for k in keys:
            options.append((k, (flagName, opts[k])))

        return options
Exemplo n.º 13
0
    def IterateSolarSystemIDs(self, itemID=None):
        if itemID is None:
            for regionID in self.GetKnownspaceRegions():
                for s in cfg.mapRegionCache.Get(regionID).solarSystemIDs:
                    yield s

        elif util.IsSolarSystem(itemID):
            yield itemID
        elif util.IsConstellation(itemID):
            for systemID in cfg.mapConstellationCache.Get(
                    itemID).solarSystemIDs:
                yield systemID

        elif util.IsRegion(itemID):
            for systemID in cfg.mapRegionCache.Get(itemID).solarSystemIDs:
                yield systemID
Exemplo n.º 14
0
 def GetParent(self, itemID):
     if util.IsSolarSystem(itemID):
         solarSystem = cfg.mapSystemCache.Get(itemID)
         return solarSystem.constellationID
     elif util.IsConstellation(itemID):
         constellation = cfg.mapConstellationCache.Get(itemID)
         return constellation.regionID
     elif util.IsRegion(itemID):
         return const.locationUniverse
     elif util.IsCelestial(itemID):
         return cfg.mapCelestialLocationCache[itemID]
     elif util.IsStation(itemID):
         station = cfg.stations.Get(itemID)
         return station.solarSystemID
     else:
         return None
Exemplo n.º 15
0
    def IterateSolarSystemIDs(self, itemID = None):
        """returns an iterator with all the solarsystem IDs contained in itemID"""
        if itemID is None:
            for regionID in self.GetKnownspaceRegions():
                for s in cfg.mapRegionCache.Get(regionID).solarSystemIDs:
                    yield s

        elif util.IsSolarSystem(itemID):
            yield itemID
        elif util.IsConstellation(itemID):
            for systemID in cfg.mapConstellationCache.Get(itemID).solarSystemIDs:
                yield systemID

        elif util.IsRegion(itemID):
            for systemID in cfg.mapRegionCache.Get(itemID).solarSystemIDs:
                yield systemID
Exemplo n.º 16
0
    def GetMapData(self, ids, idlevel, drawlevel):
        mapitems = []
        mapsvc = sm.GetService('map')
        cache = mapsvc.GetMapCache()
        items = cache['items']
        hierarchy = cache['hierarchy']
        if idlevel == 0:
            for _regionID in hierarchy.iterkeys():
                if _regionID > const.mapWormholeRegionMin:
                    continue
                mapitems.append(items[_regionID].item)
                for _constellationID in hierarchy[_regionID].iterkeys():
                    if drawlevel >= 2:
                        mapitems.append(items[_constellationID].item)
                    if drawlevel == 3:
                        for _solarsystemID in hierarchy[_regionID][_constellationID].iterkeys():
                            mapitems.append(items[_solarsystemID].item)

        elif idlevel == 1:
            for regionID in ids:
                if regionID > const.mapWormholeRegionMin:
                    continue
                if util.IsRegion(regionID) and regionID in items:
                    mapitems.append(items[regionID].item)
                    for _constellationID in hierarchy[regionID].iterkeys():
                        if drawlevel >= 2:
                            mapitems.append(items[_constellationID].item)
                        if drawlevel == 3:
                            for _solarsystemID in hierarchy[regionID][_constellationID].iterkeys():
                                mapitems.append(items[_solarsystemID].item)

        elif idlevel == 2:
            for constellationID in ids:
                if constellationID > const.mapWormholeConstellationMin:
                    continue
                if util.IsConstellation(constellationID) and constellationID in items:
                    mapitems.append(items[constellationID].item)
                    _regionID = mapsvc.GetParentLocationID(constellationID)
                    for _solarsystemID in hierarchy[_regionID][constellationID].iterkeys():
                        mapitems.append(items[_solarsystemID].item)

        elif idlevel == 3:
            for solarsystemID in ids:
                if util.IsSolarSystem(solarsystemID):
                    mapitems += mapsvc.GetSolarsystemItems(solarsystemID)

        return mapitems
Exemplo n.º 17
0
    def IterateSolarSystemIDs(self, itemID=None):
        if itemID is None:
            for regionID in self.GetKnownspaceRegions():
                for constellationID in self.GetChildren(regionID):
                    for systemID in self.GetChildren(constellationID):
                        yield systemID

        elif util.IsSolarSystem(itemID):
            yield itemID
        elif util.IsConstellation(itemID):
            for systemID in self.GetChildren(itemID):
                yield systemID

        elif util.IsRegion(itemID):
            for constellationID in self.GetChildren(itemID):
                for systemID in self.GetChildren(constellationID):
                    yield systemID
Exemplo n.º 18
0
 def GetParentLocationID(self, locationID):
     if util.IsSolarSystem(locationID):
         solarSystem = cfg.mapSystemCache.Get(locationID)
         return (const.locationUniverse,
          solarSystem.regionID,
          solarSystem.constellationID,
          locationID,
          None)
     if util.IsConstellation(locationID):
         constellation = cfg.mapConstellationCache.Get(locationID)
         return (const.locationUniverse,
          constellation.regionID,
          locationID,
          None,
          None)
     if util.IsRegion(locationID):
         return (const.locationUniverse,
          locationID,
          None,
          None,
          None)
     if util.IsCelestial(locationID):
         solarSystemID = cfg.mapCelestialLocationCache[locationID]
         solarSystem = cfg.mapSystemCache.Get(solarSystemID)
         return (const.locationUniverse,
          solarSystem.regionID,
          solarSystem.constellationID,
          solarSystemID,
          locationID)
     if util.IsStation(locationID):
         station = cfg.stations.Get(locationID)
         ssID = station.solarSystemID
         solarSystem = cfg.mapSystemCache.Get(ssID)
         return (const.locationUniverse,
          solarSystem.regionID,
          solarSystem.constellationID,
          ssID,
          locationID)
     return (const.locationUniverse,
      None,
      None,
      None,
      locationID)
Exemplo n.º 19
0
 def GetMenu(self):
     """
     tiles can highlight, hopefully stars someday
     here we have to deal with different types of data
     factionID
     regionID
     allianceID
     and just color
     """
     m = []
     if self.legend.data is not None:
         m += sm.GetService('menu').GetGMMenu(itemID=self.legend.data)
     if self.legend.data is not None:
         if util.IsFaction(self.legend.data):
             m += sm.GetService('menu').GetMenuFormItemIDTypeID(self.legend.data, const.typeFaction)
         elif util.IsRegion(self.legend.data):
             m += sm.GetService('menu').CelestialMenu(self.legend.data)
         else:
             m += sm.GetService('menu').GetMenuFormItemIDTypeID(self.legend.data, const.typeAlliance)
     return m
Exemplo n.º 20
0
    def GetIconByType(self,
                      sprite,
                      typeID,
                      itemID=None,
                      size=None,
                      ignoreSize=False,
                      isCopy=False):
        if typeID is None or not evetypes.Exists(typeID):
            return
        actSize = size or 64
        categoryID = evetypes.GetCategoryID(typeID)
        blueprint = BLUEPRINT_NONE
        if categoryID == const.categoryBlueprint:
            if isCopy:
                blueprint = BLUEPRINT_COPY
            else:
                blueprint = BLUEPRINT_NORMAL
            try:
                typeID = cfg.blueprints.Get(typeID).productTypeID
                categoryID = evetypes.GetCategoryID(typeID)
            except KeyError:
                return sprite.LoadIcon(icon=NOT_AVAILABLE_PATH,
                                       ignoreSize=ignoreSize)

        elif categoryID == const.categoryInfantry:
            blueprint = BLUEPRINT_DUST
        elif categoryID == const.categoryAncientRelic:
            blueprint = BLUEPRINT_RELIC
        groupID = evetypes.GetGroupID(typeID)
        if itemID and groupID in (const.groupRegion, const.groupConstellation,
                                  const.groupSolarSystem):
            if not (util.IsSolarSystem(itemID) or util.IsConstellation(itemID)
                    or util.IsRegion(itemID)):
                log.LogError('Not valid itemID for 2D map, itemID: ', itemID,
                             ', typeID: ', typeID)
                log.LogTraceback()
            level = [
                const.groupRegion, const.groupConstellation,
                const.groupSolarSystem
            ].index(groupID) + 1
            return self.Do2DMap(sprite, [itemID], level, level + 1, actSize)
        if TypeIsRenderable(typeID, groupID, categoryID):
            if groupID == const.groupCharacter:
                return self.GetPortrait(itemID, actSize, sprite)
            else:
                return self.OrderByTypeID(
                    [[typeID, sprite, actSize, itemID, blueprint]])
        elif groupID == const.groupShipSkins:
            self.DoSkinLicenseIcon(typeID, sprite)
        else:
            iconInfo = inventorycommon.typeHelpers.GetIcon(typeID)
            if iconInfo and iconInfo.iconFile:
                icon = iconInfo.iconFile.strip()
                if icon:
                    if blueprint != BLUEPRINT_NONE:
                        return self.DoBlueprint(sprite,
                                                typeID,
                                                size=actSize,
                                                blueprint=blueprint)
                    else:
                        return sprite.LoadIcon(icon=icon,
                                               ignoreSize=ignoreSize)
Exemplo n.º 21
0
 def LoadIconByTypeID(self, typeID, itemID = None, size = None, ignoreSize = False, isCopy = False):
     icon = None
     isBlueprint = False
     invtype = cfg.invtypes.GetIfExists(typeID)
     if invtype:
         group = invtype.Group()
         if group.categoryID == const.categoryBlueprint:
             isBlueprint = True
             typeID = cfg.invbptypes.Get(typeID).productTypeID
             invtype = cfg.invtypes.Get(typeID)
             group = invtype.Group()
         if group.categoryID == const.categoryInfantry:
             isBlueprint = True
         graphic = invtype.Icon()
         if graphic and graphic.iconFile:
             icon = graphic.iconFile.strip()
         actSize = size or 64
         if itemID and group.id in (const.groupRegion, const.groupConstellation, const.groupSolarSystem):
             if not (util.IsSolarSystem(itemID) or util.IsConstellation(itemID) or util.IsRegion(itemID)):
                 log.LogError('Not valid itemID for 2D map, itemID: ', itemID, ', typeID: ', typeID)
                 log.LogTraceback()
             level = [const.groupRegion, const.groupConstellation, const.groupSolarSystem].index(group.id) + 1
             imagePath = sm.GetService('photo').Do2DMap(self, [itemID], level, level + 1, actSize)
         elif group.id in (const.groupStrategicCruiser,) or not itemID and group.id in (const.groupPlanet, const.groupMoon):
             if isBlueprint:
                 icon = STRAGEGIC_CRUISER_BLUEPRINT_ICON_MAP[typeID]
             elif not icon:
                 icon = 'ui_7_64_15'
         elif (typeID == const.typePlanetaryLaunchContainer or group.id not in self.TYPE_DISALLOWED_GROUPS) and (group.id in self.TYPE_ALLOWED_GROUPS or group.categoryID in self.TYPE_ALLOWED_CATEGORIES):
             if group.id == const.groupCharacter:
                 sm.GetService('photo').GetPortrait(itemID, actSize, self)
             else:
                 sm.GetService('photo').OrderByTypeID([[typeID,
                   self,
                   actSize,
                   itemID,
                   isBlueprint,
                   isCopy]])
                 isBlueprint = None
             icon = None
     if icon:
         self.LoadIcon(icon=icon, ignoreSize=ignoreSize)
     if isBlueprint:
         sm.GetService('photo').DoBlueprint(self, typeID, size=actSize, isCopy=isCopy)