def GetOwnerLogo(parent, ownerID, size=64, noServerCall=False, callback=False, orderIfMissing=True): if util.IsCharacter(ownerID) or util.IsAlliance(ownerID): logo = Icon(icon=None, parent=parent, pos=(0, 0, size, size), ignoreSize=True) if util.IsAlliance(ownerID): path = sm.GetService('photo').GetAllianceLogo( ownerID, 128, logo, callback=callback, orderIfMissing=orderIfMissing) else: path = sm.GetService('photo').GetPortrait( ownerID, size, logo, callback=callback, orderIfMissing=orderIfMissing) return path is not None if util.IsCorporation(ownerID) or util.IsFaction(ownerID): GetLogoIcon(itemID=ownerID, parent=parent, pos=(0, 0, size, size), ignoreSize=True) else: raise RuntimeError('ownerID %d is not of an owner type!!' % ownerID) return True
def PopulateView(self, ownerID, scroll): try: sm.GetService('corpui').ShowLoad() self.viewingOwnerID = ownerID regwars = sm.GetService('war').GetWars(self.viewingOwnerID) facwars = {} if not util.IsAlliance(self.viewingOwnerID) and util.IsCorporation(self.viewingOwnerID) and sm.StartService('facwar').GetCorporationWarFactionID(self.viewingOwnerID): facwars = self.GetFactionWars(self.viewingOwnerID) owners = set() for wars in (regwars, facwars): for war in wars.itervalues(): owners.add(war.declaredByID) owners.add(war.againstID) owners.update(getattr(war, 'allies', {}).keys()) if len(owners): cfg.eveowners.Prime(owners) cfg.corptickernames.Prime(owners) if self.destroyed: return scrolllist = [] allyNegotiationsByWarID = defaultdict(list) for row in sm.GetService('war').GetAllyNegotiations(): allyNegotiationsByWarID[row.warID].append(row) for wars in (regwars, facwars): for war in wars.itervalues(): activeAllies = set() self.__AddToList(war, scrolllist) try: for allyID, allyRow in war.allies.iteritems(): if blue.os.GetWallclockTime() > allyRow.timeFinished: continue activeAllies.add(allyID) scrolllist.append(listentry.Get('AllyEntry', {'warID': war.warID, 'allyID': allyID, 'isAlly': True, 'allyRow': allyRow})) except AttributeError: pass if war.warID in allyNegotiationsByWarID: for neg in allyNegotiationsByWarID[war.warID]: if neg.ownerID1 in activeAllies: continue scrolllist.append(listentry.Get('AllyEntry', {'warID': neg.warID, 'allyID': neg.ownerID1, 'warNegotiation': neg})) if self.tabs.GetSelectedArgs() == 'all' and len(scrolllist): searchValue = self.searchEdit.GetValue() scrolllist.insert(0, listentry.Get('HeaderClear', {'label': localization.GetByLabel('UI/Corporations/Wars/SearchResult', searchResult=searchValue), 'func': self.ClearSearch})) corpName = cfg.eveowners.Get(self.viewingOwnerID).ownerName notContentHint = localization.GetByLabel('UI/Corporations/CorporationWindow/Wars/CorpOrAllianceNotInvolvedInWars', corpName=corpName) scroll.Load(contentList=scrolllist, headers=[], noContentHint=notContentHint) finally: sm.GetService('corpui').HideLoad()
def GetMinimumBountyAmount(ownerID): if util.IsCharacter(ownerID): return const.MIN_BOUNTY_AMOUNT_CHAR if util.IsCorporation(ownerID): return const.MIN_BOUNTY_AMOUNT_CORP if util.IsAlliance(ownerID): return const.MIN_BOUNTY_AMOUNT_ALLIANCE return 0
def OnShowOwnerDetailsWindow(self, targetID): if util.IsCharacter(targetID): sm.GetService('info').ShowInfo(const.typeCharacterGallente, targetID) elif util.IsCorporation(targetID): sm.GetService('info').ShowInfo(const.typeCorporation, targetID) elif util.IsAlliance(targetID): sm.GetService('info').ShowInfo(const.typeAlliance, targetID)
def GetLogoIcon(itemID = None, **kw): if util.IsAlliance(itemID): logo = uicls.Icon(icon=None, **kw) sm.GetService('photo').GetAllianceLogo(itemID, 128, logo) return logo elif not util.IsCorporation(itemID) or CheckCorpID(itemID): return LogoIcon(itemID=itemID, **kw) else: return CorpIcon(corpID=itemID, **kw)
def SearchBounties(self, targetID): if util.IsCharacter(targetID): fetcher = sm.ProxySvc('bountyProxy').SearchCharBounties elif util.IsCorporation(targetID): fetcher = sm.ProxySvc('bountyProxy').SearchCorpBounties elif util.IsAlliance(targetID): fetcher = sm.ProxySvc('bountyProxy').SearchAllianceBounties bountyAndRank = fetcher(targetID) bountyUtil.CacheBounties(self.bounties, [bounty for rank, bounty in bountyAndRank]) return bountyAndRank
def GetDroppedCharCorpOrAllianceName(node): if not IsUserNode(node): return validTypeIDs = const.characterTypeByBloodline.values() + [ const.typeCorporation, const.typeAlliance ] itemID = GetItemIDFromTextLink(node, validTypeIDs) if itemID is None: itemID = node.itemID if util.IsCharacter(itemID) or util.IsCorporation( itemID) or util.IsAlliance(itemID): itemName = cfg.eveowners.Get(itemID).name return util.KeyVal(itemName=itemName, itemID=itemID)
def ApplyAttributes(self, attributes): itemID = attributes.get('itemID', None) icon = None if itemID is not None: if util.IsCorporation(itemID): if CheckCorpID(itemID): icon = CORP_ICONS[itemID] else: raise ValueError, 'LogoIcon class does not support custom corp icons. Use CorpIcon for that' elif util.IsAlliance(itemID): raise ValueError, 'LogoIcon class does not support Alliance Logos. Use GetLogoIcon or GetOwnerIcon' elif util.IsFaction(itemID): isSmall = attributes.get('isSmall', self.default_isSmall) icon = self.GetFactionIconID(itemID, isSmall) elif itemID in RACE_ICONS: icon = RACE_ICONS[itemID] if icon is None: icon = 'ui_1_16_256' attributes['icon'] = icon EveIcon.ApplyAttributes(self, attributes)
def ConstructHeader(self): if self.loadingHeader: return self.loadingHeader = True self.topCont.Flush() characterName = cfg.eveowners.Get(session.charid).name if not getattr(self, 'charMgr', None): self.charMgr = sm.RemoteSvc('charMgr') if not getattr(self, 'cc', None): self.charsvc = sm.GetService('cc') self.sr.charinfo = charinfo = self.charMgr.GetPublicInfo( session.charid) if settings.user.ui.Get('charsheetExpanded', 1): parent = self.topCont self.sr.picParent = Container(name='picpar', parent=parent, align=uiconst.TOPLEFT, width=200, height=200, left=const.defaultPadding, top=16) self.sr.pic = Sprite(parent=self.sr.picParent, align=uiconst.TOALL, left=1, top=1, height=1, width=1) self.sr.pic.OnClick = self.OpenPortraitWnd self.sr.pic.cursor = uiconst.UICURSOR_MAGNIFIER uicontrols.Frame(parent=self.sr.picParent, opacity=0.2) sm.GetService('photo').GetPortrait(session.charid, 256, self.sr.pic) infoTextPadding = self.sr.picParent.width + const.defaultPadding * 4 characterLink = GetByLabel( 'UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=characterName, info=('showinfo', const.typeCharacterAmarr, session.charid)) self.sr.nameText = uicontrols.EveCaptionMedium( text=characterLink, parent=self.topCont, left=infoTextPadding, top=12, state=uiconst.UI_NORMAL) self.sr.raceinfo = raceinfo = cfg.races.Get(charinfo.raceID) self.sr.bloodlineinfo = bloodlineinfo = cfg.bloodlines.Get( charinfo.bloodlineID) self.sr.schoolinfo = schoolinfo = self.charsvc.GetData( 'schools', ['schoolID', charinfo.schoolID]) self.sr.ancestryinfo = ancestryinfo = self.charsvc.GetData( 'ancestries', ['ancestryID', charinfo.ancestryID]) if self.destroyed: self.loadingHeader = False return securityStatus = sm.GetService( 'crimewatchSvc').GetMySecurityStatus() roundedSecurityStatus = localization.formatters.FormatNumeric( securityStatus, decimalPlaces=1) cloneLocationRow = sm.RemoteSvc('charMgr').GetHomeStationRow() if cloneLocationRow: stationID = cloneLocationRow.stationID cloneLocationSystemID = cloneLocationRow.solarSystemID if cloneLocationSystemID: labelPath = 'UI/CharacterSheet/CharacterSheetWindow/CloneLocationHint' cloneLocationHint = GetByLabel( labelPath, locationId=stationID, systemId=cloneLocationSystemID) cloneLocation = cfg.evelocations.Get( cloneLocationSystemID).name else: cloneLocationHint = cfg.evelocations.Get(stationID).name cloneLocation = GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/UnknownSystem') else: cloneLocation = GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/UnknownSystem') cloneLocationHint = '' alliance = '' if session.allianceid: cfg.eveowners.Prime([session.allianceid]) alliance = (GetByLabel('UI/Common/Alliance'), cfg.eveowners.Get(session.allianceid).name, '') faction = '' if session.warfactionid: fac = sm.StartService('facwar').GetFactionalWarStatus() faction = (GetByLabel('UI/Common/Militia'), cfg.eveowners.Get(fac.factionID).name, '') bounty = '' bountyOwnerIDs = (session.charid, session.corpid, session.allianceid) bountyAmount = sm.GetService('bountySvc').GetBounty( *bountyOwnerIDs) bountyAmounts = sm.GetService('bountySvc').GetBounties( *bountyOwnerIDs) charBounty = 0 corpBounty = 0 allianceBounty = 0 if len(bountyAmounts): for ownerID, value in bountyAmounts.iteritems(): if util.IsCharacter(ownerID): charBounty = value elif util.IsCorporation(ownerID): corpBounty = value elif util.IsAlliance(ownerID): allianceBounty = value bountyHint = GetByLabel('UI/Station/BountyOffice/BountyHint', charBounty=util.FmtISK(charBounty, 0), corpBounty=util.FmtISK(corpBounty, 0), allianceBounty=util.FmtISK( allianceBounty, 0)) bounty = (GetByLabel('UI/Station/BountyOffice/Bounty'), util.FmtISK(bountyAmount, 0), bountyHint) skillPoints = int(sm.GetService('skills').GetSkillPoints()) textList = [ (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/SkillPoints'), localization.formatters.FormatNumeric(skillPoints, useGrouping=True), ''), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/HomeSystem'), cloneLocation, cloneLocationHint), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/CharacterBackground' ), GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/CharacterBackgroundInformation', raceName=localization.GetByMessageID(raceinfo.raceNameID), bloodlineName=localization.GetByMessageID( bloodlineinfo.bloodlineNameID), ancestryName=localization.GetByMessageID( ancestryinfo.ancestryNameID)), GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/CharacterBackgroundHint' )), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/DateOfBirth'), localization.formatters.FormatDateTime( charinfo.createDateTime, dateFormat='long', timeFormat='long'), ''), (GetByLabel('UI/CharacterSheet/CharacterSheetWindow/School'), localization.GetByMessageID(schoolinfo.schoolNameID), ''), (GetByLabel('UI/Common/Corporation'), cfg.eveowners.Get(session.corpid).name, ''), (GetByLabel( 'UI/CharacterSheet/CharacterSheetWindow/SecurityStatus'), roundedSecurityStatus, localization.formatters.FormatNumeric(securityStatus, decimalPlaces=4)) ] if faction: textList.insert(len(textList) - 1, faction) if alliance: textList.insert(len(textList) - 1, alliance) if bounty: textList.insert(len(textList), bounty) numLines = len(textList) + 2 mtext = 'Xg<br>' * numLines mtext = mtext[:-4] th = GetTextHeight(mtext) topParentHeight = max(220, th + const.defaultPadding * 2 + 2) top = max(34, self.sr.nameText.top + self.sr.nameText.height) leftContainer = Container(parent=self.topCont, left=infoTextPadding, top=top, align=uiconst.TOPLEFT) rightContainer = Container(parent=self.topCont, top=top, align=uiconst.TOPLEFT) subTop = 0 for label, value, hint in textList: label = uicontrols.EveLabelMedium(text=label, parent=leftContainer, idx=0, state=uiconst.UI_NORMAL, align=uiconst.TOPLEFT, top=subTop) label.hint = hint label._tabMargin = 0 display = uicontrols.EveLabelMedium(text=value, parent=rightContainer, idx=0, state=uiconst.UI_NORMAL, align=uiconst.TOPLEFT, top=subTop) display.hint = hint display._tabMargin = 0 subTop += label.height leftContainer.AutoFitToContent() rightContainer.left = leftContainer.left + leftContainer.width + 20 rightContainer.AutoFitToContent() self.topCont.EnableAutoSize() else: self.topCont.DisableAutoSize() self.topCont.height = 18 charsheetExpanded = settings.user.ui.Get('charsheetExpanded', 1) if not charsheetExpanded: uicontrols.EveLabelMedium(text=characterName, parent=self.topCont, left=8, top=1, state=uiconst.UI_DISABLED) expandOptions = [ GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Expand'), GetByLabel('UI/CharacterSheet/CharacterSheetWindow/Collapse') ] a = uicontrols.EveLabelSmall(text=expandOptions[charsheetExpanded], parent=self.topCont, left=15, top=3, state=uiconst.UI_NORMAL, align=uiconst.TOPRIGHT, bold=True) a.OnClick = self.ToggleGeneral expander = Sprite(parent=self.topCont, pos=(3, 2, 11, 11), name='expandericon', state=uiconst.UI_NORMAL, texturePath=[ 'res:/UI/Texture/Shared/expanderDown.png', 'res:/UI/Texture/Shared/expanderUp.png' ][charsheetExpanded], align=uiconst.TOPRIGHT) expander.OnClick = self.ToggleGeneral self.loadingHeader = False