def OnSessionMutated(self, isremote, session, change): if not self.useJumpMonitor: return try: if type(session) == types.TupleType: if len(session) == 1 and session[0] >= const.minFakeItem: self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'wormhole %s' % session[0] self.checkBallpark = True elif len(session) == 2 and util.IsStargate(session[0]) and util.IsStargate(session[1]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'stargate %d->%d' % (session[0], session[1]) self.checkBallpark = True elif len(session) == 2 and util.IsPlayerItem(session[0]) and util.IsSolarSystem(session[1]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'pos cyno array:%d' % (session[0],) self.checkBallpark = True elif len(session) == 3 and util.IsPlayerItem(session[0]) and util.IsPlayerItem(session[1]) and util.IsSolarSystem(session[2]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'bridge src:%s dst:%d in:%d' % (session[0], session[1], session[2]) self.checkBallpark = True elif len(session) == 3 and util.IsCharacter(session[0]) and util.IsSolarSystem(session[2]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'cyno char:%s cyno:%d' % (session[0], session[1]) self.checkBallpark = True elif len(session) == 4 and util.IsCharacter(session[0]) and util.IsPlayerItem(session[1]) and util.IsSolarSystem(session[3]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'ship bridge char:%s-%s cyno:%d' % (session[0], session[1], session[2]) self.checkBallpark = True except: sys.exc_clear()
def OnTraceMouseDownWithUrl_thread(self, url): if not url.startswith('showinfo:'): return itemID = None ids = url[9:].split('//') try: itemID = None if len(ids) > 1: itemID = int(ids[1]) except: log.LogTraceback( 'failed to convert string to ids when opening radial menu for link' ) return if itemID is None or not util.IsSolarSystem(itemID): return localStargate = uix.FindLocalStargate(itemID) if localStargate: destinationID = localStargate.itemID typeID = localStargate.typeID else: destinationID = itemID typeID = const.typeSolarSystem sm.GetService('menu').TryExpandActionMenu(itemID=destinationID, clickedObject=self, typeID=typeID)
def OnClick(self, *args): if util.IsSolarSystem(self.destinationID): sm.GetService('info').ShowInfo(const.typeSolarSystem, self.destinationID) typeID = self.GetStationOrStructureTypeID(self.destinationID) if typeID: sm.GetService('info').ShowInfo(typeID, self.destinationID)
def GodmaItemChanged(self, item, change): if item.itemID == session.charid: return if self.dogmaLocation is not None: shipID = self.dogmaLocation.shipID if item.locationID in (shipID, session.charid): self.dogmaLocation.OnItemChange(item, change) elif change.get(const.ixLocationID, None) in (shipID, session.charid): self.dogmaLocation.OnItemChange(item, change) elif item.itemID == shipID and session.stationid2 is not None: if item.locationID != session.stationid or item.flagID != const.flagHangar: if util.IsWorldSpace( item.locationID) or util.IsSolarSystem( item.locationID): self.LogInfo( 'ActiveShip moved as we are undocking. Ignoring') elif util.IsStation( item.locationID ) and item.flagID == const.flagHangar and item.ownerID == session.charid: self.LogInfo( "Active ship moved stations but is still in it's hangar", item, change, session.stationid) else: sm.GetService('station').TryLeaveShip(item) self.dogmaLocation.UnboardShip(session.charid) self.LogError('Our active ship got moved', item, change)
def OnMouseDown_thread(self): destinationID = self.destinationID if util.IsStation(destinationID ) and session.solarsystemid2 != self.solarSystemID: systemNeighbors = sm.GetService('map').GetNeighbors( self.solarSystemID) if session.solarsystemid2 in systemNeighbors: destinationID = self.solarSystemID if util.IsSolarSystem(destinationID): localStargate = uix.FindLocalStargate(destinationID) if localStargate: destinationID = localStargate.itemID typeID = localStargate.typeID else: typeID = const.typeSolarSystem elif util.IsStation(destinationID): station = sm.StartService('ui').GetStation(destinationID) typeID = station.stationTypeID else: structure = sm.GetService('structureDirectory').GetStructureInfo( destinationID) if structure is not None: typeID = structure.typeID sm.GetService('menu').TryExpandActionMenu(itemID=destinationID, clickedObject=self, typeID=typeID)
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)
def _SetStructureName(structureID, solarsystemID): if not util.IsSolarSystem(solarsystemID): log.LogError("Can't rename a structure that's not in space. What is", structureID, 'doing inside', solarsystemID, 'anyways?') return currentName = cfg.evelocations.Get(structureID).locationName namePrefix = '%s - ' % localization.CleanImportantMarkup( cfg.evelocations.Get(solarsystemID).locationName) if not currentName.startswith(namePrefix): currentName = namePrefix + currentName def _CheckLen(name, *args): if len(name) - len(namePrefix) < structures.MIN_STRUCTURE_NAME_LEN: raise UserError('CharNameTooShort') newName = uiutil.NamePopup( localization.GetByLabel('UI/Menusvc/SetName'), localization.GetByLabel('UI/Menusvc/TypeInNewName'), setvalue=currentName, maxLength=32 + len(namePrefix), fixedPrefix=namePrefix, validator=_CheckLen) if newName: sm.RemoteSvc('structureDeployment').RenameStructure( structureID, newName)
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)
def OnItemChange(self, item, change): itemLocationIDs = [item.locationID] if const.ixLocationID in change: itemLocationIDs.append(change[const.ixLocationID]) wnd = self.GetWnd() if wnd and not wnd.destroyed: if change.keys() == [const.ixLocationID ] and change.values() == [0]: return if util.IsStation( item.locationID ) or const.ixLocationID in change and util.IsStation( change[const.ixLocationID]): key = wnd.sr.maintabs.GetSelectedArgs() if key is not None: if key[:7] == 'station': if util.IsSolarSystem( item.locationID ) and const.ixLocationID in change and change[ const.ixLocationID] == eve.session.stationid: return if eve.session.stationid in itemLocationIDs: wnd.sr.maintabs.ReloadVisible() elif key in ('allitems', 'regitems', 'conitems', 'sysitems'): uthread.new( wnd.UpdateLite, item.locationID, key, change.get(const.ixLocationID, item.locationID))
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)
def TravelTo(self, itemID): stationID = None if util.IsSolarSystem(itemID): solarSystemID = itemID else: stationID = itemID solarSystemID = cfg.stations.Get(itemID).solarSystemID Log('RouteID: %s' % self.routeID) Log('Travel: Destination systemID %s, stationID %s' % (solarSystemID, stationID)) self.Undock() self.Hop(10000) Log('Stopping ship') uicore.cmd.CmdStopShip() ap = sm.GetService('autoPilot') ap.SetOff() while session.solarsystemid2 != solarSystemID: if not ap.GetState(): Log('Travel: Activating autopilot...') sm.StartService('starmap').SetWaypoint( solarSystemID, clearOtherWaypoints=True) sm.GetService('autoPilot').SetOn() SleepSim(5000) Log('Travel: Arrived in destination system!')
def OnClick(self, *args): if util.IsSolarSystem(self.destinationID): sm.GetService('info').ShowInfo(const.typeSolarSystem, self.destinationID) elif util.IsStation(self.destinationID): station = sm.StartService('ui').GetStation(self.destinationID) sm.GetService('info').ShowInfo(station.stationTypeID, self.destinationID)
def GetMenu(self, *args): if util.IsSolarSystem(self.destinationID): return sm.GetService('menu').GetMenuFormItemIDTypeID( self.destinationID, const.typeSolarSystem) if util.IsStation(self.destinationID): station = sm.StartService('ui').GetStation(self.destinationID) return sm.GetService('menu').GetMenuFormItemIDTypeID( self.destinationID, station.stationTypeID)
def GetHint(self, *args): ret = sm.GetService('infoPanel').GetSolarSystemTrace( self.destinationID, traceFontSize=None) if not util.IsSolarSystem(self.destinationID): if util.IsStation(self.destinationID) or sm.GetService( 'structureDirectory').GetStructureInfo(self.destinationID): ret += '<br>' + cfg.evelocations.Get(self.destinationID).name return ret
def GetMenu(self, *args): if util.IsSolarSystem(self.destinationID): return sm.GetService('menu').GetMenuFormItemIDTypeID( self.destinationID, const.typeSolarSystem) typeID = self.GetStationOrStructureTypeID(self.destinationID) if typeID: return sm.GetService('menu').GetMenuFormItemIDTypeID( self.destinationID, typeID)
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])
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 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)
def SanitizedDestinationID(destinationID): try: destinationID = int(destinationID) except: log.LogError('Unable to convert destinationID into an integer!') return None if util.IsSolarSystem(destinationID) or util.IsStation(destinationID): return destinationID
def ConvertStationIDToSolarSystemIDIfNecessary(waypointID): if util.IsStation(waypointID): return cfg.stations.Get(waypointID).solarSystemID if util.IsSolarSystem(waypointID): return waypointID structure = sm.GetService('structureDirectory').GetStructureInfo( waypointID) if structure is not None: return structure.solarSystemID return waypointID
def SanitizedSolarsystemID(solarsystemID): try: solarsystemID = int(solarsystemID) except: log.LogError('Unable to convert solarsystemID into an integer!') return None if not util.IsSolarSystem(solarsystemID): return None return solarsystemID
def OnSessionMutated(self, isremote, session, change): """ OnSessionMutated is called on the client, by the client when certain jump events are requested. The only way to differentiate between jump types is to observe the change dictionnary and trap known patterns. Current patterns of change are: wormhole jump: chnage contains a single value, the wormhole object. Which is a fake item not in the DB stargate jump: the clean one really, change contains 2 values, both stargates itemID cyno jump: 3 value tuple, of the form: character holding the cyno, cyno itemID (which is fakeItem too) and destination solarsystem """ if not self.useJumpMonitor: return try: if type(session) == types.TupleType: if len(session) == 1 and session[0] >= const.minFakeItem: self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'wormhole %s' % session[0] self.checkBallpark = True elif len(session) == 2 and util.IsStargate(session[0]) and util.IsStargate(session[1]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'stargate %d->%d' % (session[0], session[1]) self.checkBallpark = True elif len(session) == 2 and util.IsPlayerItem(session[0]) and util.IsSolarSystem(session[1]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'pos cyno array:%d' % (session[0],) self.checkBallpark = True elif len(session) == 3 and util.IsPlayerItem(session[0]) and util.IsPlayerItem(session[1]) and util.IsSolarSystem(session[2]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'bridge src:%s dst:%d in:%d' % (session[0], session[1], session[2]) self.checkBallpark = True elif len(session) == 3 and util.IsCharacter(session[0]) and util.IsSolarSystem(session[2]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'cyno char:%s cyno:%d' % (session[0], session[1]) self.checkBallpark = True elif len(session) == 4 and util.IsCharacter(session[0]) and util.IsPlayerItem(session[1]) and util.IsSolarSystem(session[3]): self.jumpStartTime = blue.os.GetWallclockTime() self.jumpType = 'ship bridge char:%s-%s cyno:%d' % (session[0], session[1], session[2]) self.checkBallpark = True except: sys.exc_clear()
def OnSessionChanged(self, isremote, session, change): if 'locationid' in change: newLocationID = change['locationid'][1] if util.IsSolarSystem( newLocationID ) and self.primaryJob.sceneType != SCENE_TYPE_SPACE: log.LogWarn( 'SceneManager: I detected a session change into space but no one has bothered to update my scene type!' ) self.SetSceneType(SCENE_TYPE_SPACE)
def GetDragData(self, *args): entry = util.KeyVal() entry.__guid__ = 'xtriui.ListSurroundingsBtn' entry.itemID = self.destinationID entry.label = cfg.evelocations.Get(self.destinationID).name if util.IsSolarSystem(self.destinationID): entry.typeID = const.typeSolarSystem else: station = sm.StartService('ui').GetStation(self.destinationID) entry.typeID = station.stationTypeID return [entry]
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
def GetDragData(self, *args): entry = util.KeyVal() entry.__guid__ = 'xtriui.ListSurroundingsBtn' entry.itemID = self.destinationID entry.label = cfg.evelocations.Get(self.destinationID).name if util.IsSolarSystem(self.destinationID): entry.typeID = const.typeSolarSystem else: typeID = self.GetStationOrStructureTypeID(self.destinationID) if typeID: entry.typeID = typeID return [entry]
def GetLocationMenu(self, node): if util.IsStation(node.locationID): stationInfo = sm.GetService('ui').GetStation(node.locationID) menu = sm.GetService('menu').CelestialMenu(node.locationID, typeID=stationInfo.stationTypeID, parentID=stationInfo.solarSystemID) if node.flag == 72: checkIsDirector = const.corpRoleDirector == eve.session.corprole & const.corpRoleDirector if checkIsDirector: menu.append((localization.GetByLabel('UI/Corporations/Assets/TrashItemsAtLocation'), self.TrashJunkAtLocation, (node.locationID,))) return menu if util.IsSolarSystem(node.locationID): return sm.GetService('menu').CelestialMenu(node.locationID) return []
def GetCurrentData(self, locationID): fwData = {} if util.IsSolarSystem(locationID) and not util.IsWormholeSystem(locationID): constellationID = sm.GetService('map').GetParent(locationID) data = sm.RemoteSvc('map').GetCurrentSovData(constellationID) indexedData = data.Index('locationID') sovData = [indexedData[locationID]] fwData = sm.RemoteSvc('map').GetConstellationLPData(constellationID).Index('solarSystemID') else: if util.IsConstellation(locationID): fwData = sm.RemoteSvc('map').GetConstellationLPData(locationID).Index('solarSystemID') sovData = sm.RemoteSvc('map').GetCurrentSovData(locationID) return (sovData, fwData)
def OnSessionChanged(self, isremote, session, change): """ This will catch cases of someone transferring to another context without updating the scene type """ if 'locationid' in change: newLocationID = change['locationid'][1] if util.IsSolarSystem( newLocationID ) and self.primaryJob.sceneType != SCENE_TYPE_SPACE: log.LogWarn( 'SceneManager: I detected a session change into space but no one has bothered to update my scene type!' ) self.SetSceneType(SCENE_TYPE_SPACE)
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 []