def GetColorCodedSecurityStringForLocation(self, solarsystemID, itemName): sec, col = util.FmtSystemSecStatus( sm.GetService('map').GetSecurityStatus(solarsystemID), 1) col.a = 1.0 color = util.StrFromColor(col) text = '%s <color=%s>%s</color>' % (itemName, color, sec) return text
def GetSecurityStatus(self, solarSystemID, getColor=False): if self.securityInfo is None: uthread.Lock(self) try: self.securityInfo = {} for systemID, each in cfg.mapSystemCache.iteritems(): self.securityInfo[systemID] = each.pseudoSecurity finally: uthread.UnLock(self) return util.FmtSystemSecStatus( self.securityInfo.get(solarSystemID, 0.0), getColor)
def GetSolarSystemTrace(self, itemID, altText=None, traceFontSize=12): if util.IsStation(itemID): solarSystemID = cfg.stations.Get(itemID).solarSystemID elif util.IsSolarSystem(itemID): solarSystemID = itemID else: structure = sm.GetService('structureDirectory').GetStructureInfo( itemID) if structure is None: raise RuntimeError('Invalid destination') solarSystemID = structure.solarSystemID try: sec, col = util.FmtSystemSecStatus( sm.GetService('map').GetSecurityStatus(solarSystemID), 1) col.a = 1.0 securityLabel = "</b> <color=%s><hint='%s'>%s</hint></color>" % ( util.StrFromColor(col), localization.GetByLabel('UI/Map/StarMap/SecurityStatus'), sec) except KeyError: self.LogError('Neocom failed to get security status for item', solarSystemID, 'displaying BROKEN') log.LogException() sys.exc_clear() securityLabel = '' si = cfg.mapSystemCache.Get(solarSystemID) constellationID = si.constellationID regionID = si.regionID if altText: solarSystemAlt = " alt='%s'" % uiutil.StripTags( altText, stripOnly=['localized']) else: solarSystemAlt = '' locationTrace = '<url=showinfo:%s//%s%s>%s</url>%s' % ( const.typeSolarSystem, solarSystemID, solarSystemAlt, cfg.evelocations.Get(solarSystemID).locationName, securityLabel) if traceFontSize: locationTrace += '<fontsize=12>' if not util.IsWormholeRegion(regionID): seperator = '<fontsize=%(fontsize)s> </fontsize><<fontsize=%(fontsize)s> </fontsize>' % { 'fontsize': 8 } locationTrace += seperator locationTrace += '<url=showinfo:%s//%s>%s</url>' % ( const.typeConstellation, constellationID, cfg.evelocations.Get(constellationID).locationName) locationTrace += seperator locationTrace += '<url=showinfo:%s//%s>%s</url>' % ( const.typeRegion, regionID, cfg.evelocations.Get(regionID).locationName) return locationTrace
def GetSecurityStatus(self, solarSystemID): if self.securityInfo is None: uthread.Lock(self) try: self.securityInfo = {} for each in cfg.solarsystems: self.securityInfo[each.solarSystemID] = each.pseudoSecurity finally: uthread.UnLock(self) if solarSystemID in self.securityInfo: return util.FmtSystemSecStatus(self.securityInfo[solarSystemID]) return 0.0
def GetSecurityStatus(self, solarSystemID, getColor = False): """ returns 'pseudo' security for 'solarSystemID' in the following format: Rounds the security to the nearest one digit precision with the following exeption: 0.0 < sec < 0.05 is rounded up to 0.1 but not down to 0.0 example: 0.08 -> 0.1, -0.22 -> -0.2, 0.451 -> 0.5, 0.449 -> 0.4, -0.26 -> -0.3 """ if self.securityInfo is None: uthread.Lock(self) try: self.securityInfo = {} for systemID, each in cfg.mapSystemCache.iteritems(): self.securityInfo[systemID] = each.pseudoSecurity finally: uthread.UnLock(self) return util.FmtSystemSecStatus(self.securityInfo.get(solarSystemID, 0.0), getColor)
def GetLocation(self, solarSystemID): try: sec, col = util.FmtSystemSecStatus(sm.GetService('map').GetSecurityStatus(solarSystemID), 1) col.a = 1.0 securityLabel = "</b> <color=%s><hint='%s'>%s</hint></color>" % (util.StrFromColor(col), localization.GetByLabel('UI/Map/StarMap/SecurityStatus'), sec) except KeyError: log.LogException('Failed to get security status for item - displaying BROKEN') sys.exc_clear() securityLabel = '' solarSystem = cfg.mapSystemCache[solarSystemID] constellationID = solarSystem.constellationID regionID = solarSystem.regionID locationTrace = '<url=showinfo:%s//%s>%s</url>%s < <url=showinfo:%s//%s>%s</url> < <url=showinfo:%s//%s>%s</url>' % (inventoryConst.typeSolarSystem, solarSystemID, cfg.evelocations.Get(solarSystemID).locationName, securityLabel, inventoryConst.typeConstellation, constellationID, cfg.evelocations.Get(constellationID).locationName, inventoryConst.typeRegion, regionID, cfg.evelocations.Get(regionID).locationName) return locationTrace
def GetSystemColor(self, solarSystemID): sec, col = util.FmtSystemSecStatus( self.GetSecurityStatus(solarSystemID), 1) return col
def GetSystemSecurityDot(self, solarSystemID): sec, col = util.FmtSystemSecStatus( sm.GetService('map').GetSecurityStatus(solarSystemID), 1) col.a = 1.0 colString = hex(col.AsInt() & 4294967295L) return u'<color=%s>\u2022</color>' % colString
def AddAgentInfo(self, agentCont, i): if i + self.posInList >= self.totalAgents: return agent = self.agentsList[i + self.posInList] agentID = agent.agentID divisionID = agent.divisionID agentTypeID = agent.agentTypeID factionID = agent.factionID corporationID = agent.corporationID stationID = agent.stationID solarSystemID = agent.solarsystemID agentLevel = agent.level jumps = agent.jumps if self.showOnlyAvail.checked: isAvailable = True elif agent.level == 1 and agent.agentTypeID != const.agentTypeResearchAgent: if not session.warfactionid and agent.agentTypeID == const.agentTypeFactionalWarfareAgent: isAvailable = False else: isAvailable = True else: isAvailable = self.standingSvc.CanUseAgent(factionID, corporationID, agentID, agentLevel, agentTypeID) nameLabel = cfg.eveowners.Get(agentID).name corpLabel = '' if corporationID: corpLabel = cfg.eveowners.Get(corporationID).name locationLabel = '' solarSystemName = cfg.evelocations.Get(solarSystemID).name if stationID: station = sm.StartService('ui').GetStation(stationID) stationName = cfg.evelocations.Get(stationID).name stationTypeID = station.stationTypeID infoLinkTypeID = stationTypeID infoLinkSystemID = stationID locationLink = '<url=showinfo:%d//%d>%s</url>' % ( stationTypeID, stationID, solarSystemName) else: infoLinkTypeID = const.typeSolarSystem infoLinkSystemID = solarSystemID locationLink = '<url=showinfo:%d//%d>%s</url>' % ( const.typeSolarSystem, solarSystemID, solarSystemName) sec = sm.GetService('map').GetSecurityStatus(solarSystemID) secStatus, color = util.FmtSystemSecStatus(sec, True) color = int(util.Color.RGBtoHex(color.r, color.g, color.b), 16) startSystemInfoTag = '<url=showinfo:%d//%d>' % (infoLinkTypeID, infoLinkSystemID) endUrlTag = '</url>' startColorTag = '<color=%s>' % color endColorTag = '</color>' if jumps != 999: locationLabel = localization.GetByLabel( 'UI/AgentFinder/LocationText', startSystemInfoTag=startSystemInfoTag, system=solarSystemID, endSystemInfoTag=endUrlTag, startColorTag=startColorTag, secStatus=sec, endColorTag=endColorTag, jumps=jumps) else: locationLabel = localization.GetByLabel( 'UI/AgentFinder/LocationTextUnreachable', startSystemInfoTag=startSystemInfoTag, system=solarSystemID, endSystemInfoTag=endUrlTag, startColorTag=startColorTag, secStatus=sec, endColorTag=endColorTag) levelAndTypeLabel = '' agentDivision = sm.GetService( 'agents').GetDivisions()[divisionID].divisionName.replace( '&', '&') if agentID in sm.GetService('agents').GetTutorialAgentIDs(): levelAndTypeLabel = localization.GetByLabel( 'UI/AgentFinder/TutorialAgentDivision', divisionName=agentDivision) elif agentTypeID == const.agentTypeEpicArcAgent: levelAndTypeLabel = localization.GetByLabel( 'UI/AgentFinder/EpicArcAgentDivision', divisionName=agentDivision) elif agentTypeID == const.agentTypeCareerAgent: levelAndTypeLabel = localization.GetByLabel( 'UI/AgentFinder/CareerAgentDivision', divisionName=agentDivision) elif agentTypeID in (const.agentTypeGenericStorylineMissionAgent, const.agentTypeStorylineMissionAgent): levelAndTypeLabel = localization.GetByLabel( 'UI/AgentFinder/StorylineAgentDivision', divisionName=agentDivision) else: levelAndTypeLabel = localization.GetByLabel( 'UI/AgentFinder/LevelAgentDivision', agentLevel=uiutil.GetLevel(agentLevel), divisionName=agentDivision) leftCont = uicls.Container(name='leftCont', parent=agentCont, align=uiconst.TOLEFT, width=64) infoCont = uicls.Container(name='infoCont', parent=agentCont, align=uiconst.TOALL, clipChildren=True, padLeft=const.defaultPadding) icon = uicls.Icon(parent=leftCont, align=uiconst.TOPLEFT, size=64, ignoreSize=True) typeID = cfg.eveowners.Get(agentID).typeID icon.typeID = typeID icon.itemID = agentID icon.OnClick = (self.ShowInfo, icon) icon.GetMenu = (self.GetAgentMenu, icon) icon.LoadIconByTypeID(typeID, itemID=agentID, ignoreSize=True) if session.stationid: hint = localization.GetByLabel('UI/Chat/StartConversation') else: hint = localization.GetByLabel('UI/Common/ShowInfo') icon.hint = hint top = 0 startAgentInfoTag = '<url=showinfo:%d//%d>' % ( cfg.eveowners.Get(agentID).typeID, agentID) startInfoColorTag = '<color=-2039584>' nameText = localization.GetByLabel( 'UI/AgentFinder/AgentNameWithInfoLink', startAgentInfoTag=startAgentInfoTag, startColorTag=startInfoColorTag, agentName=nameLabel, endColorTag=endColorTag, endAgentInfoTag=endUrlTag) name = uicls.EveLabelMedium(text=nameText, parent=infoCont, top=top, state=uiconst.UI_NORMAL) name.GetMenu = (self.GetAgentMenu, icon) name.hint = localization.GetByLabel('UI/Common/ShowInfo') top += 16 startCorpInfoTag = '<url=showinfo:%d//%d>' % (const.typeCorporation, corporationID) corpText = localization.GetByLabel( 'UI/AgentFinder/CorpNameWithInfoLink', startCorporationInfoTag=startCorpInfoTag, startColorTag=startInfoColorTag, corpName=corpLabel, endColorTag=endColorTag, endCorporationInfoTag=endUrlTag) corp = uicls.EveLabelMedium(text=corpText, parent=infoCont, top=top, state=uiconst.UI_NORMAL, bold=True) corp.typeID = const.typeCorporation corp.itemID = corporationID corp.OnClick = (self.ShowInfo, corp, True) corp.hint = localization.GetByLabel('UI/Common/ShowInfo') top += 16 levelAndType = uicls.EveLabelMedium(text=levelAndTypeLabel, parent=infoCont, top=top) top += 16 location = uicls.EveLabelMedium(text=locationLabel, parent=infoCont, top=top, state=uiconst.UI_NORMAL) if not isAvailable: for item in infoCont.children: item.SetAlpha(0.4) icon.SetAlpha(0.4)
def GetAgents_thread(self): self.ShowLoading() self.agentsList = [] factionID = self.factionCombo.GetValue() corporationID = self.corpCombo.GetValue() divisionID = self.divisionCombo.GetValue() regionID = self.regionCombo.GetValue() solarsystemID = self.locationCombo.GetValue() securityStatus = self.secStatusCombo.GetValue() showOnlyAvail = self.showOnlyAvail.checked agentLevel = self.agentLevel for agent in self.agents: blue.pyos.BeNice() if agent.level != agentLevel: continue if factionID != -1 and agent.factionID != factionID: continue if corporationID != -1 and agent.corporationID != corporationID: continue if divisionID != -1: if divisionID == const.agentTypeStorylineMissionAgent: if agent.agentTypeID not in ( const.agentTypeStorylineMissionAgent, const.agentTypeGenericStorylineMissionAgent): continue elif divisionID == const.agentTypeFactionalWarfareAgent: if agent.agentTypeID != const.agentTypeFactionalWarfareAgent: continue elif divisionID == const.agentTypeCareerAgent: if agent.agentTypeID != const.agentTypeCareerAgent: continue elif agent.divisionID != divisionID or agent.agentTypeID in ( const.agentTypeFactionalWarfareAgent, const.agentTypeStorylineMissionAgent, const.agentTypeGenericStorylineMissionAgent, const.agentTypeCareerAgent): continue if agent.solarsystemID is None: agentSolarSystemID = sm.GetService( 'agents').GetSolarSystemOfAgent(agent.agentID) else: agentSolarSystemID = agent.solarsystemID if agentSolarSystemID is None: continue else: agentRegionID = self.mapSvc.GetRegionForSolarSystem( agentSolarSystemID) if regionID != -1 and agentRegionID != regionID: continue if solarsystemID != -1 and agentSolarSystemID != solarsystemID: continue sec = self.mapSvc.GetSecurityStatus(agentSolarSystemID) secStatus = util.FmtSystemSecStatus(sec) secClass = util.SecurityClassFromLevel(secStatus) if securityStatus != -1 and secClass != securityStatus: continue if showOnlyAvail: if not session.warfactionid and agent.agentTypeID == const.agentTypeFactionalWarfareAgent: continue if agent.level != 1 or agent.agentTypeID == const.agentTypeResearchAgent: if not self.standingSvc.CanUseAgent( agent.factionID, agent.corporationID, agent.agentID, agent.level, agent.agentTypeID): continue agentKV = util.KeyVal() agentKV.agentID = agent.agentID agentKV.agentTypeID = agent.agentTypeID agentKV.divisionID = agent.divisionID agentKV.level = agent.level agentKV.stationID = agent.stationID agentKV.corporationID = agent.corporationID agentKV.factionID = agent.factionID agentKV.solarsystemID = agentSolarSystemID jumps = 999 if agentSolarSystemID: jumps = len( sm.GetService('starmap').ShortestGeneralPath( agentSolarSystemID)) - 1 if jumps == -1: jumps = 999 agentKV.jumps = jumps self.agentsList.append(agentKV) self.agentsList.sort(key=lambda x: x.jumps) self.totalAgents = len(self.agentsList) self.posInList = 0 if self.totalAgents == 0: self.noAgentsOrLoadingText.text = localization.GetByLabel( 'UI/AgentFinder/NoAgentsFound') self.DisplayBrowse() else: self.HideLoading() self.DrawAgents()
def GetAttackersAndItemsFromKillMail(mail): attackers = [] items = [] rx = re.compile('=(\\d+(?:\\.\\d+)?)') tempBlob = rx.sub('="\\1"', mail.killBlob) pstate = util.Object() pstate.Set('state', 0) pstate.Set('lastitem', None) def _xmlTagStart(tag, attrs): state = pstate.Get('state', 0) if state == 99: return if tag == 'doc': return if tag == 'attackers': if state != 0: pstate.Set('state', 99) return pstate.Set('state', 1) elif tag == 'a': if state != 1: pstate.Set('state', 99) return pstate.Set('state', 2) attacker = util.KeyVal() attacker.characterID = attrs.get('c', None) attacker.corporationID = attrs.get('r', None) attacker.allianceID = attrs.get('a', None) attacker.factionID = attrs.get('f', None) attacker.shipTypeID = attrs.get('s', None) attacker.weaponTypeID = attrs.get('w', None) attacker.damageDone = int(float(attrs.get('d', 0))) attacker.secStatusText = attrs.get('t', '0.0') attacker.finalBlow = False attackers.append((attacker.damageDone, attacker)) elif tag == 'items': if state != 0 and state != 3: pstate.Set('state', 99) return pstate.Set('state', 4) elif tag == 'i': if state != 4 and state != 5: pstate.Set('state', 99) return item = util.KeyVal() item.typeID = attrs.get('t', None) item.flag = int(float(attrs.get('f', 0))) item.singleton = int(float(attrs.get('s', 0))) item.qtyDropped = int(float(attrs.get('d', 0))) item.qtyDestroyed = int(float(attrs.get('x', 0))) item.contents = [] if state == 4: pstate.Set('state', 5) if item.qtyDropped > 0 and item.qtyDestroyed > 0: item2 = util.KeyVal() item2.typeID = item.typeID item2.flag = item.flag item2.singleton = item.singleton item2.qtyDropped = item.qtyDropped item2.qtyDestroyed = 0 item2.contents = [] item.qtyDropped = 0 items.append(item) items.append(item2) else: items.append(item) pstate.Set('lastitem', item) else: pstate.Set('state', 6) litem = pstate.Get('lastitem', None) if litem is not None: litem.contents.append(item) pstate.Set('lastitem', litem) else: pstate.Set('state', 99) else: pstate.Set('state', 99) def _xmlTagEnd(tag): state = pstate.Get('state', 0) if state == 99: return if tag == 'doc': return if tag == 'attackers': if state != 1: pstate.Set('state', 99) return pstate.Set('state', 3) elif tag == 'a': if state != 2: pstate.Set('state', 99) return pstate.Set('state', 1) elif tag == 'items': if state != 4: pstate.Set('state', 99) return pstate.Set('state', 7) elif tag == 'i': if state != 5 and state != 6: pstate.Set('state', 99) return if state == 5: pstate.Set('state', 4) else: pstate.Set('state', 5) else: pstate.Set('state', 99) parser = xml.parsers.expat.ParserCreate() parser.StartElementHandler = _xmlTagStart parser.EndElementHandler = _xmlTagEnd parser.buffer_text = True parser.returns_unicode = False parser.Parse('<doc>' + tempBlob + '</doc>', 1) pstate.Set('state', 0) pstate.Set('lastitem', None) finalBlow = util.KeyVal() finalBlow.characterID = mail.finalCharacterID finalBlow.corporationID = mail.finalCorporationID finalBlow.allianceID = mail.finalAllianceID finalBlow.factionID = mail.finalFactionID finalBlow.shipTypeID = mail.finalShipTypeID finalBlow.weaponTypeID = mail.finalWeaponTypeID finalBlow.damageDone = mail.finalDamageDone if mail.finalSecurityStatus is None: finalBlow.secStatusText = '0.0' else: finalBlow.secStatusText = util.FmtSystemSecStatus( mail.finalSecurityStatus) finalBlow.finalBlow = True attackers.append((finalBlow.damageDone, finalBlow)) attackers.sort(reverse=True) return (attackers, items)
def GetSystemColor(self, solarSystemID): """Get the security color value for a solarsystem""" sec, col = util.FmtSystemSecStatus(self.GetSecurityStatus(solarSystemID), 1) return col
def PickNewHomeStation(self, *args): if getattr(self, 'picking', 0): return try: self.picking = 1 homeStationID = self.GetHomeStation() stations = self.GetPotentialHomeStations() stationTypeIDbyStationID = {} for station in stations: stationTypeIDbyStationID[station.stationID] = ( station.typeID, station.serviceMask) cfg.evelocations.Prime(stationTypeIDbyStationID.keys()) stationsWithMedical = [] stationsWithoutMedical = [] mapSvc = sm.GetService('map') uiSvc = sm.GetService('ui') for stationID, stationData in stationTypeIDbyStationID.iteritems(): typeID, serviceMask = stationData station = cfg.evelocations.Get(stationID) systemID = uiSvc.GetStation(stationID).solarSystemID regionID = mapSvc.GetRegionForSolarSystem(systemID) sec = mapSvc.GetSecurityStatus(systemID) secStatus = util.FmtSystemSecStatus(sec) region = cfg.evelocations.Get(regionID) data = util.KeyVal() data.label = '%s<t>%s<t>%s' % ( station.name, localization.GetByLabel( 'UI/Medical/Clone/NewHomeSecStatusEntry', securityStatus=secStatus), region.name) data.itemID = stationID data.typeID = typeID data.listvalue = [station.name, stationID] data.sublevel = 1 if serviceMask & const.stationServiceCloning == const.stationServiceCloning: stationsWithMedical.append(data) else: stationsWithoutMedical.append(data) groupWithMedical = util.KeyVal() groupWithMedical.label = localization.GetByLabel( 'UI/Medical/Clone/StationsWithCloning') groupWithMedical.id = ('clonePicker', 1) groupWithMedical.showicon = 'hide' groupWithMedical.BlockOpenWindow = 1 groupWithMedical.state = 'locked' groupWithMedical.showlen = 1 groupWithMedical.sublevel = 0 groupWithMedical.groupItems = stationsWithMedical groupWithoutMedical = util.KeyVal() groupWithoutMedical.label = localization.GetByLabel( 'UI/Medical/Clone/StationsWithoutCloning') groupWithoutMedical.id = ('clonePicker', 2) groupWithoutMedical.showicon = 'hide' groupWithoutMedical.BlockOpenWindow = 1 groupWithoutMedical.state = 'locked' groupWithoutMedical.showlen = 1 groupWithoutMedical.sublevel = 0 groupWithoutMedical.groupItems = stationsWithoutMedical scrollHeaders = [ localization.GetByLabel('UI/Medical/Clone/Station'), localization.GetByLabel('UI/Medical/Clone/SecurityStatus'), localization.GetByLabel('UI/Common/LocationTypes/Region') ] ret = uix.ListWnd( [groupWithMedical, groupWithoutMedical], 'station', localization.GetByLabel('UI/Medical/Clone/SelectHomeStation'), None, 1, windowName='newHomeStationWindow', lstDataIsGrouped=1, scrollHeaders=scrollHeaders) if ret: if not stationTypeIDbyStationID[ret[1]][ 1] & const.stationServiceCloning == const.stationServiceCloning: if eve.Message('AskSetHomeStationWithoutMedical', buttons=uiconst.YESNO, default=uiconst.ID_NO) != uiconst.ID_YES: self.picking = 0 return newHomeStationID = ret[1] else: self.picking = 0 return if newHomeStationID == homeStationID: raise UserError( 'MedicalYouAlreadyHaveACloneContractAtThatStation') newHomeStationTypeID = stationTypeIDbyStationID[newHomeStationID][ 0] if sm.GetService('godma').GetType( newHomeStationTypeID).isPlayerOwnable == 1: if eve.Message('AskSetHomeStationAtPOS', {}, uiconst.YESNO) != uiconst.ID_YES: self.picking = 0 return if eve.Message('AskAcceptCloneContractCost', {'cost': const.costCloneContract}, uiconst.YESNO) != uiconst.ID_YES: self.picking = 0 return self.SetHomeStation(newHomeStationID) finally: self.picking = 0