NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

bountyWindow.py (55044B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\bountyWindow.py
      2 from carbonui.control.scrollContainer import ScrollContainer
      3 from carbonui.control.singlelineedits.singleLineEditInteger import SingleLineEditInteger
      4 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText
      5 from carbonui.control.window import Window
      6 from carbonui.primitives.container import Container
      7 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      8 from carbonui.primitives.fill import Fill
      9 from carbonui.primitives.gradientSprite import GradientSprite
     10 from carbonui.primitives.sprite import Sprite
     11 from carbonui.util.various_unsorted import SortListOfTuples
     12 from eve.client.script.ui.control import eveIcon, eveLabel, eveScroll
     13 from eve.client.script.ui.control.allUserEntries import AllUserEntries
     14 from carbonui.button.group import ButtonGroup
     15 from carbonui.control.buttonIcon import ButtonIcon
     16 from carbonui.control.button import Button
     17 from eve.client.script.ui.control.entries.generic import Generic
     18 from eve.client.script.ui.control.entries.util import GetFromClass
     19 from eve.client.script.ui.control.listgroup import ListGroup
     20 from eve.client.script.ui.control.themeColored import SpriteThemeColored
     21 from eve.client.script.ui.control.toggleButtonGroup import ToggleButtonGroup
     22 from eve.client.script.ui.control.expandablemenu import ExpandableMenuContainer
     23 from eve.client.script.ui.control.utilMenu import UtilMenu
     24 from eve.client.script.ui.quickFilter import QuickFilterEdit
     25 from eve.client.script.ui.util import searchUtil
     26 from eve.common.lib import appConst as const
     27 from eve.common.script.search.const import ResultType
     28 from eve.common.script.sys import idCheckers
     29 from eve.common.script.sys.idCheckers import IsNPC
     30 from eve.common.script.util import bountyUtil, eveFormat
     31 import carbonui.const as uiconst
     32 import localization
     33 import uthread
     34 import log
     35 import blue
     36 from math import pi
     37 from carbonui.uicore import uicore
     38 from eveservices.menu import GetMenuService
     39 from globalConfig.getFunctions import CheckPlayerBountyEnabled
     40 SHOW_CHAR = 1
     41 SHOW_CORP = 2
     42 SHOW_ALLIANCE = 3
     43 
     44 class BountyWindow(Window):
     45     __guid__ = 'form.BountyWindow'
     46     __notifyevents__ = ['OnBountyPlaced']
     47     default_width = 400
     48     default_height = 510
     49     default_minSize = (default_width, default_height)
     50     default_windowID = 'bounties'
     51     default_captionLabelPath = 'UI/Station/BountyOffice/BountyOffice'
     52     default_descriptionLabelPath = 'Tooltips/StationServices/BountyOffice_description'
     53     default_iconNum = 'res:/ui/Texture/WindowIcons/bountyoffice.png'
     54 
     55     def ApplyAttributes(self, attributes):
     56         CheckPlayerBountyEnabled(sm.GetService('machoNet'))
     57         Window.ApplyAttributes(self, attributes)
     58         sm.RegisterNotify(self)
     59         self.ownerID = None
     60         self.searchedForOwnerID = None
     61         self.topBountyInited = False
     62         self.bountyHuntersInited = False
     63         self.myBountiesInited = False
     64         self.myBountiesUpdated = False
     65         self.searchingTopBounty = False
     66         self.searchingPlaceBounty = False
     67         self.selectedMenu = None
     68         self.bountySvc = sm.GetService('bountySvc')
     69         mainCont = Container(name='mainCont', parent=self.sr.main, padding=const.defaultPadding)
     70         placeBountiesCont = ContainerAutoSize(name='placeBounties', parent=mainCont, align=uiconst.TOBOTTOM, padTop=16)
     71         eveLabel.EveCaptionMedium(text=localization.GetByLabel('UI/Station/BountyOffice/PlaceBounty'), parent=placeBountiesCont, align=uiconst.TOTOP)
     72         self.searchCont = Container(name='searchCont', parent=placeBountiesCont, align=uiconst.TOTOP, height=32, padTop=4)
     73         self.verifiedCont = ContainerAutoSize(name='verifiedCont', parent=placeBountiesCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, minHeight=32)
     74         self.verifiedCont.display = False
     75         placeCont = Container(name='placeCont', parent=placeBountiesCont, align=uiconst.TOTOP, height=32, padTop=4)
     76         imgCont = Container(name='imgCont', parent=self.searchCont, width=30, align=uiconst.TOLEFT)
     77         Sprite(name='killerLogo', parent=imgCont, align=uiconst.TOPLEFT, texturePath='res:/UI/Texture/silhouette_64.png', pos=(0, 0, 32, 32))
     78         self.searchEdit = SingleLineEditText(name='searchEdit', parent=self.searchCont, maxLength=32, align=uiconst.TOALL, hintText=localization.GetByLabel('UI/Station/BountyOffice/SearchForUser'), pos=(0, 0, 0, 0), padLeft=4)
     79         self.searchEdit.OnReturn = self.SearchPlaceBounty
     80         self.searchEdit.OnDropData = self.PlaceDropData
     81         self.imgCont = Container(name='imgCont', parent=self.verifiedCont, width=32, align=uiconst.TOLEFT)
     82         clearCont = Container(name='clearCont', parent=self.verifiedCont, width=24, align=uiconst.TORIGHT)
     83         textCont = ContainerAutoSize(name='textCont', parent=self.verifiedCont, align=uiconst.TOTOP, padLeft=4)
     84         self.bountyOwner = Sprite(parent=self.imgCont, align=uiconst.CENTERLEFT, idx=0, texturePath='res:/UI/Texture/silhouette_64.png', pos=(0, 0, 32, 32))
     85         self.clearBtn = ButtonIcon(name='surrenderBtn', parent=clearCont, align=uiconst.CENTER, width=16, iconSize=16, texturePath='res:/UI/Texture/Icons/73_16_210.png', hint=localization.GetByLabel('UI/Inventory/Clear'), func=self.ClearBounty)
     86         self.nameLabel = eveLabel.EveLabelMedium(name='bountyName', parent=textCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, maxLines=1)
     87         self.bountyLabel = eveLabel.EveLabelSmall(name='bountyAmount', parent=textCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL)
     88         self.placeBountiesBtn = Button(parent=placeCont, label=localization.GetByLabel('UI/Station/BountyOffice/Place'), align=uiconst.TORIGHT, func=self.PlaceBounty)
     89         self.placeBountiesBtn.Disable()
     90         self.bountyAmount = SingleLineEditInteger(name='placeEdit', parent=placeCont, align=uiconst.TOALL, width=0, maxValue=const.MAX_BOUNTY_AMOUNT, hintText=localization.GetByLabel('UI/Station/BountyOffice/EnterAmount'), padRight=const.defaultPadding, top=0, dataType=long)
     91         self.bountyAmount.OnReturn = self.PlaceBounty
     92         expandableCont = Container(name='expandableCont', parent=mainCont, align=uiconst.TOALL)
     93         self.bountiesCont = Container(name='bountiesCont', padTop=2)
     94         self.searchOnListEdit = QuickFilterEdit(name='searchOnListEdit', parent=self.bountiesCont, maxLength=32, align=uiconst.TOTOP, hintText=localization.GetByLabel('UI/Station/BountyOffice/SearchForUser'), height=32, padTop=2, OnClearFilter=self.ClearSearch, isCharCorpOrAllianceField=True)
     95         self.searchOnListEdit.ReloadFunction = self.OnSearchFieldChanged
     96         self.searchOnListEdit.OnReturn = self.SearchTopBounty
     97         self.topBountiesButtons = ToggleButtonGroup(parent=self.bountiesCont, align=uiconst.TOTOP, callback=self.OnButtonSelected, padTop=4)
     98         for btnID, label in self.GetMenuTabs():
     99             self.topBountiesButtons.AddButton(btnID, label, self.bountiesCont)
    100 
    101         self.topBountiesButtons.SelectByID(settings.user.ui.Get('topBountiesType', SHOW_CHAR))
    102         self.topBountiesScroll = ScrollContainer(name='topBountiesScroll', parent=self.bountiesCont, align=uiconst.TOALL, padTop=4)
    103         self.bountyHuntersCont = Container(name='bountyHuntersCont', padTop=2)
    104         self.bountyHunterButtons = ToggleButtonGroup(parent=self.bountyHuntersCont, align=uiconst.TOTOP, callback=self.OnButtonSelected, padTop=4)
    105         for btnID, label in self.GetMenuTabs():
    106             self.bountyHunterButtons.AddButton(btnID, label, self.bountyHuntersCont)
    107 
    108         self.bountyHunterButtons.SelectByID(settings.user.ui.Get('bountyHuntersType', SHOW_CHAR))
    109         self.bountyHuntersScroll = ScrollContainer(name='bountyHuntersScroll', parent=self.bountyHuntersCont, align=uiconst.TOALL, padTop=4)
    110         self.myBountiesCont = Container(name='myBountiesCont', padTop=2)
    111         self.myBountiesScroll = ScrollContainer(name='myBountiesScroll', parent=self.myBountiesCont, align=uiconst.TOALL, padTop=4)
    112         self.noBountiesPlaced = Container(name='loadingCont', parent=self.myBountiesCont, align=uiconst.TOALL)
    113         eveLabel.EveCaptionMedium(text=localization.GetByLabel('UI/Station/BountyOffice/NoOutstandingBounties'), parent=self.noBountiesPlaced, align=uiconst.CENTER)
    114         self.em = ExpandableMenuContainer(parent=expandableCont, clipChildren=True)
    115         self.em.multipleExpanded = False
    116         emTabs = self.GetEMTabs()
    117         self.em.Load(emTabs, 'bounties')
    118 
    119     def ConstructTopParent(self):
    120         topParent = Container(name='topParent', parent=self.GetMainArea(), align=uiconst.TOTOP, height=52, clipChildren=True)
    121         SpriteThemeColored(name='mainicon', parent=topParent, state=uiconst.UI_DISABLED, pos=(0, -8, 64, 64), texturePath=self.iconNum, colorType=uiconst.COLORTYPE_UIHILIGHTGLOW)
    122         self.label = eveLabel.WndCaptionLabel(text=localization.GetByLabel('UI/Station/BountyOffice/BountyOffice'), parent=topParent)
    123 
    124     def LoadTopBounties(self, initialLoad = False):
    125         self.selectedMenu = 'topBounties'
    126         if self.topBountyInited:
    127             return
    128         showType = settings.user.ui.Get('topBountiesType', SHOW_CHAR)
    129         self.DrawTopBounties(showType)
    130         self.topBountyInited = True
    131 
    132     def LoadBountyHunters(self, initialLoad = False):
    133         self.selectedMenu = 'topBountyHunters'
    134         if self.bountyHuntersInited:
    135             return
    136         showType = settings.user.ui.Get('bountyHuntersType', SHOW_CHAR)
    137         self.DrawBountyHunters(showType)
    138         self.bountyHuntersInited = True
    139 
    140     def LoadMyBounties(self, initialLoad = False):
    141         if self.myBountiesInited and not self.myBountiesUpdated:
    142             return
    143         self.DrawMyBounties()
    144         self.myBountiesInited = True
    145         self.myBountiesUpdated = False
    146 
    147     def GetEMTabs(self):
    148         tabs = [(localization.GetByLabel('UI/Station/BountyOffice/MostWanted'),
    149           self.bountiesCont,
    150           self.LoadTopBounties,
    151           None,
    152           None,
    153           None,
    154           False,
    155           True), (localization.GetByLabel('UI/Station/BountyOffice/TopBountyHunters'),
    156           self.bountyHuntersCont,
    157           self.LoadBountyHunters,
    158           None,
    159           None,
    160           None,
    161           False,
    162           False), (localization.GetByLabel('UI/Station/BountyOffice/MyBounties'),
    163           self.myBountiesCont,
    164           self.LoadMyBounties,
    165           None,
    166           None,
    167           None,
    168           False,
    169           False)]
    170         return tabs
    171 
    172     def GetMenuTabs(self):
    173         return ((SHOW_CHAR, localization.GetByLabel('UI/Station/BountyOffice/ShowCharacters')), (SHOW_CORP, localization.GetByLabel('UI/Station/BountyOffice/ShowCorporations')), (SHOW_ALLIANCE, localization.GetByLabel('UI/Station/BountyOffice/ShowAlliances')))
    174 
    175     def OnButtonSelected(self, mode, *args):
    176         if self.selectedMenu == 'topBounties':
    177             if mode != settings.user.ui.Get('topBountiesType', SHOW_CHAR):
    178                 self.DrawTopBounties(mode)
    179                 settings.user.ui.Set('topBountiesType', mode)
    180         elif self.selectedMenu == 'topBountyHunters':
    181             if mode != settings.user.ui.Get('bountyHuntersType', SHOW_CHAR):
    182                 self.DrawBountyHunters(mode)
    183                 settings.user.ui.Set('bountyHuntersType', mode)
    184 
    185     def SearchTopBounty(self, *args):
    186         if self.searchOnListEdit.GetValue() == '':
    187             return
    188         if self.searchingTopBounty:
    189             return
    190         self.searchingTopBounty = True
    191         try:
    192             ownerID = self.Search(self.searchOnListEdit)
    193         finally:
    194             self.searchingTopBounty = False
    195 
    196         if self.searchedForOwnerID and self.searchedForOwnerID == ownerID:
    197             return
    198         if ownerID:
    199             self.searchedForOwnerID = ownerID
    200             ownerName = cfg.eveowners.Get(ownerID).name
    201             self.searchOnListEdit.SetValue(ownerName)
    202             if self.ShowSearched(ownerID):
    203                 self.ScrollToActiveEntry()
    204 
    205     def ScrollToActiveEntry(self):
    206         uthread.new(self._ScrollToActiveEntry)
    207 
    208     def _ScrollToActiveEntry(self):
    209         blue.synchro.Yield()
    210         entry = self.treeEntryByID.get(self.rank, None)
    211         if not entry:
    212             return
    213         _, topEntry = entry.GetAbsolutePosition()
    214         _, topScroll, _, height = self.topBountiesScroll.mainCont.GetAbsolute()
    215         denum = height - entry.height
    216         if denum:
    217             fraction = float(topEntry - topScroll) / denum
    218             self.topBountiesScroll.ScrollToVertical(fraction)
    219 
    220     def OnSearchFieldChanged(self, *args):
    221         if self.searchOnListEdit.GetValue().strip() == '':
    222             showType = settings.user.ui.Get('topBountiesType', SHOW_CHAR)
    223             self.DrawTopBounties(showType)
    224 
    225     def PlaceDropData(self, dragObj, nodes):
    226         for node in nodes:
    227             if hasattr(node, 'Get'):
    228                 if node.Get('__guid__', None) not in AllUserEntries():
    229                     return
    230                 ownerID = node.charID
    231                 if ownerID:
    232                     if idCheckers.IsCharacter(ownerID) or idCheckers.IsCorporation(ownerID) or idCheckers.IsAlliance(ownerID):
    233                         self.ownerID = ownerID
    234                         self.ShowResult(ownerID)
    235                 break
    236 
    237     def ClearSearch(self, *args):
    238         self.searchedForOwnerID = None
    239         self.searchOnListEdit.SetValue('')
    240         showType = settings.user.ui.Get('topBountiesType', SHOW_CHAR)
    241         self.DrawTopBounties(showType)
    242         self.topBountiesScroll.ScrollToVertical(0.0)
    243 
    244     def SearchPlaceBounty(self, *args):
    245         if self.searchEdit.GetValue() == '':
    246             return
    247         if self.searchingPlaceBounty:
    248             return
    249         if self.verifiedCont.display == True:
    250             return
    251         self.searchingPlaceBounty = True
    252         try:
    253             self.ownerID = self.Search(self.searchEdit)
    254         finally:
    255             self.searchingPlaceBounty = False
    256 
    257         if self.ownerID:
    258             self.ShowResult(self.ownerID)
    259 
    260     def Search(self, edit):
    261         searchString = edit.GetValue()
    262         if not searchString or searchString == '':
    263             return None
    264         groupIDList = [ResultType.character, ResultType.corporation, ResultType.alliance]
    265         searchResult = searchUtil.GetResultsList(searchString.strip(), groupIDList, hideNPC=True)
    266         searchResult = [ x for x in searchResult if not IsNPC(x) ]
    267         if not len(searchResult):
    268             edit.SetValue('')
    269             edit.SetHintText(localization.GetByLabel('UI/Station/BountyOffice/NoOneFound'))
    270         else:
    271             if len(searchResult) == 1:
    272                 ownerID = searchResult[0]
    273                 return ownerID
    274             dlg = BountyPicker.Open(resultList=searchResult)
    275             dlg.ShowModal()
    276             if dlg.ownerID:
    277                 return dlg.ownerID
    278             edit.SetValue('')
    279             return None
    280 
    281     def ShowSearched(self, ownerID):
    282         self.topBountiesScroll.Flush()
    283         self.treeEntryByID = {}
    284         try:
    285             searchedBounties = self.bountySvc.SearchBounties(ownerID)
    286         except:
    287             self.searchOnListEdit.SetValue('')
    288             entityName = cfg.eveowners.Get(ownerID).name
    289             self.searchOnListEdit.SetHintText(localization.GetByLabel('UI/Station/BountyOffice/SearchedForHasNoBounty', entityName=entityName))
    290             return False
    291 
    292         ownersToPrime = set()
    293         for rank, bounty in searchedBounties:
    294             ownersToPrime.add(bounty.targetID)
    295             if hasattr(bounty, 'corporationID'):
    296                 ownersToPrime.add(bounty.corporationID)
    297             if hasattr(bounty, 'allianceID'):
    298                 ownersToPrime.add(bounty.allianceID)
    299 
    300         cfg.eveowners.Prime(ownersToPrime)
    301         if idCheckers.IsCharacter(ownerID):
    302             contType = CharBounty
    303         else:
    304             contType = CorpBounty
    305         for rank, bounty in searchedBounties:
    306             focus = False
    307             corpID = getattr(bounty, 'corporationID', None)
    308             allianceID = getattr(bounty, 'allianceID', None)
    309             rowNumber = rank + 1
    310             bountyAmount = self.bountySvc.GetBountyFromCache(bounty.targetID)
    311             if bounty.targetID == self.searchedForOwnerID:
    312                 focus = True
    313                 self.rank = rank
    314             cont = contType(name='topBounty', parent=self.topBountiesScroll, ownerID=bounty.targetID, bounty=bountyAmount, corpID=corpID, allianceID=allianceID, place=rowNumber, focus=focus)
    315             self.treeEntryByID[rank] = cont
    316 
    317         return True
    318 
    319     def ShowResult(self, ownerID):
    320         if ownerID and not IsNPC(ownerID):
    321             self.imgCont.Flush()
    322             bountyAmount = self.GetBountyAmount(ownerID)
    323             self.verifiedCont.display = True
    324             self.placeBountiesBtn.Enable()
    325             self.searchCont.display = False
    326             ownerType = cfg.eveowners.Get(ownerID).typeID
    327             if idCheckers.IsCharacter(ownerID):
    328                 ownerPortrait = Sprite(parent=self.imgCont, align=uiconst.CENTERLEFT, idx=0, texturePath='res:/UI/Texture/silhouette_64.png', pos=(0, 0, 32, 32))
    329                 sm.GetService('photo').GetPortrait(ownerID, 30, ownerPortrait)
    330             else:
    331                 ownerPortrait = eveIcon.GetLogoIcon(itemID=ownerID, parent=self.imgCont, acceptNone=False, align=uiconst.CENTERLEFT, height=32, width=32, state=uiconst.UI_NORMAL)
    332             ownerPortrait.OnClick = (self.ShowInfo, ownerID, ownerType)
    333             ownerName = cfg.eveowners.Get(ownerID).name
    334             self.bountyOwner.hint = ownerName
    335             self.nameLabel.text = localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=ownerName, info=('showinfo', ownerType, ownerID))
    336             self.bountyLabel.text = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount, False))
    337             minBounty = bountyUtil.GetMinimumBountyAmount(ownerID)
    338             self.bountyAmount.SetHintText(localization.GetByLabel('UI/Station/BountyOffice/InsertAmount', bountyAmount=eveFormat.FmtISK(minBounty)))
    339             uicore.registry.SetFocus(self.bountyAmount)
    340             self.SetBountyHint(ownerID)
    341 
    342     def SetBountyHint(self, ownerID):
    343         bountyOwnerIDs = self.GetEntities(ownerID)
    344         bountyAmounts = self.GetBountyAmounts(*bountyOwnerIDs)
    345         charBounty = 0
    346         corpBounty = 0
    347         allianceBounty = 0
    348         if len(bountyAmounts):
    349             for ownerID, value in bountyAmounts.iteritems():
    350                 if idCheckers.IsCharacter(ownerID):
    351                     charBounty = value
    352                 elif idCheckers.IsCorporation(ownerID):
    353                     corpBounty = value
    354                 elif idCheckers.IsAlliance(ownerID):
    355                     allianceBounty = value
    356 
    357         bountyHint = localization.GetByLabel('UI/Station/BountyOffice/BountyHint', charBounty=eveFormat.FmtISK(charBounty, 0), corpBounty=eveFormat.FmtISK(corpBounty, 0), allianceBounty=eveFormat.FmtISK(allianceBounty, 0))
    358         self.bountyLabel.hint = bountyHint
    359 
    360     def GetBountyAmounts(self, *ownerIDs):
    361         bountyAmounts = sm.GetService('bountySvc').GetBounties(*ownerIDs)
    362         return bountyAmounts
    363 
    364     def OnBountyPlaced(self, ownerID):
    365         self.myBountiesUpdated = True
    366         self.LoadMyBounties()
    367         if ownerID == self.ownerID and self.verifiedCont.display == True:
    368             bountyAmount = self.GetBountyAmount(ownerID)
    369             self.bountyLabel.text = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount, False))
    370 
    371     def GetEntities(self, ownerID):
    372         charID = None
    373         corpID = None
    374         allianceID = None
    375         if idCheckers.IsCharacter(ownerID):
    376             corpInfo = sm.GetService('corp').GetInfoWindowDataForChar(ownerID)
    377             charID = ownerID
    378             corpID = corpInfo.corpID
    379             allianceID = corpInfo.allianceID
    380         elif idCheckers.IsCorporation(ownerID):
    381             corpInfo = sm.RemoteSvc('corpmgr').GetPublicInfo(ownerID)
    382             corpID = ownerID
    383             allianceID = corpInfo.allianceID
    384         else:
    385             allianceID = ownerID
    386         bountyInfo = (charID, corpID, allianceID)
    387         return bountyInfo
    388 
    389     def GetBountyAmount(self, ownerID):
    390         bountyInfo = self.GetEntities(ownerID)
    391         bountyAmount = self.bountySvc.GetBounty(*bountyInfo)
    392         return bountyAmount
    393 
    394     def ClearBounty(self, *args):
    395         self.ownerID = None
    396         self.searchEdit.SetValue('')
    397         self.searchCont.display = True
    398         self.verifiedCont.display = False
    399         self.bountyAmount.SetHintText(localization.GetByLabel('UI/Station/BountyOffice/EnterAmount'))
    400         self.placeBountiesBtn.Disable()
    401 
    402     def PlaceBounty(self, *args):
    403         if self.placeBountiesBtn.disabled:
    404             return
    405         if not self.ownerID:
    406             return
    407         ownerID = self.ownerID
    408         amount = self.bountyAmount.GetValue()
    409         minBounty = bountyUtil.GetMinimumBountyAmount(ownerID)
    410         if amount < minBounty:
    411             self.bountyAmount.SetValue('')
    412             self.bountyAmount.SetHintText(localization.GetByLabel('UI/Station/BountyOffice/TooLowEnterMore', minAmount=eveFormat.FmtISK(minBounty)))
    413             return
    414         if ownerID and amount:
    415             self.bountySvc.AddToBounty(ownerID, amount)
    416             self.searchEdit.SetValue('')
    417             self.bountyAmount.SetValue('')
    418             bountyAmount = self.GetBountyAmount(ownerID)
    419             self.bountyLabel.text = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount))
    420             sm.GetService('objectCaching').InvalidateCachedMethodCall('charMgr', 'GetPublicInfo3', ownerID)
    421             sm.ScatterEvent('OnBountyPlaced', ownerID)
    422 
    423     def ShowInfo(self, ownerID, typeID, *args):
    424         sm.GetService('info').ShowInfo(typeID, ownerID)
    425 
    426     def DrawTopBounties(self, showType):
    427         uthread.new(self.DrawTopBounties_thread, showType)
    428 
    429     def DrawTopBounties_thread(self, showType):
    430         self.topBountiesScroll.Flush()
    431         topBounties = self.GetTopBounties(showType)
    432         if showType == SHOW_CHAR:
    433             topContType = TopCharBounty
    434             contType = CharBounty
    435         else:
    436             topContType = TopCorpBounty
    437             contType = CorpBounty
    438         ownersToPrime = set()
    439         for b in topBounties:
    440             ownersToPrime.add(b.targetID)
    441             if hasattr(b, 'corporationID'):
    442                 ownersToPrime.add(b.corporationID)
    443             if hasattr(b, 'allianceID'):
    444                 ownersToPrime.add(b.allianceID)
    445 
    446         cfg.eveowners.Prime(ownersToPrime)
    447         for rowNumber, bounty in enumerate(topBounties):
    448             corpID = getattr(bounty, 'corporationID', None)
    449             allianceID = getattr(bounty, 'allianceID', None)
    450             bountyAmount = self.bountySvc.GetBountyFromCache(bounty.targetID)
    451             if rowNumber == 10:
    452                 return
    453             if rowNumber == 0:
    454                 topContType(name='topBounty', parent=self.topBountiesScroll, ownerID=bounty.targetID, bounty=bountyAmount, corpID=corpID, allianceID=allianceID)
    455             else:
    456                 contType(name='bounty', parent=self.topBountiesScroll, ownerID=bounty.targetID, bounty=bountyAmount, corpID=corpID, allianceID=allianceID, place=rowNumber + 1)
    457 
    458     def GetTopBounties(self, showType):
    459         if showType == SHOW_CHAR:
    460             topBounties = self.bountySvc.GetTopPilotBounties(0)
    461         elif showType == SHOW_CORP:
    462             topBounties = self.bountySvc.GetTopCorpBounties(0)
    463         else:
    464             topBounties = self.bountySvc.GetTopAllianceBounties(0)
    465         return topBounties
    466 
    467     def DrawBountyHunters(self, showType):
    468         uthread.new(self.DrawBountyHunters_thread, showType)
    469 
    470     def DrawBountyHunters_thread(self, showType):
    471         self.bountyHuntersScroll.Flush()
    472         bountyHunters = self.GetTopBountyHunters(showType)
    473         if showType == SHOW_CHAR:
    474             topContType = TopCharBounty
    475             contType = CharBounty
    476         else:
    477             topContType = TopCorpBounty
    478             contType = CorpBounty
    479         ownersToPrime = set()
    480         for b in bountyHunters:
    481             ownersToPrime.add(b.bountyHunterID)
    482             if hasattr(b, 'corporationID'):
    483                 ownersToPrime.add(b.corporationID)
    484             if hasattr(b, 'allianceID'):
    485                 ownersToPrime.add(b.allianceID)
    486 
    487         cfg.eveowners.Prime(ownersToPrime)
    488         for bounty in bountyHunters:
    489             ownerID = bounty.bountyHunterID
    490             corpID = getattr(bounty, 'corporationID', None)
    491             allianceID = getattr(bounty, 'allianceID', None)
    492             rowNumber = getattr(bounty, 'rowNumber', 0)
    493             bountiesClaimed = getattr(bounty, 'bountiesClaimed', 0)
    494             numberOfKills = getattr(bounty, 'numberOfKills', 0)
    495             if bounty.rowNumber == 1:
    496                 topContType(name='topBountyHunter', parent=self.bountyHuntersScroll, ownerID=ownerID, corpID=corpID, allianceID=allianceID, bountiesClaimed=bountiesClaimed, numberOfKills=numberOfKills)
    497             else:
    498                 contType(name='bountyHunter', parent=self.bountyHuntersScroll, ownerID=ownerID, corpID=corpID, allianceID=allianceID, place=rowNumber, bountiesClaimed=bountiesClaimed, numberOfKills=numberOfKills)
    499 
    500     def GetTopBountyHunters(self, showType):
    501         if showType == SHOW_CHAR:
    502             bountyHunters = self.bountySvc.GetTopPilotBountyHunters(0)
    503         elif showType == SHOW_CORP:
    504             bountyHunters = self.bountySvc.GetTopCorporationBountyHunters(0)
    505         else:
    506             bountyHunters = self.bountySvc.GetTopAllianceBountyHunters(0)
    507         return bountyHunters
    508 
    509     def DrawMyBounties(self):
    510         uthread.new(self.DrawMyBounties_thread)
    511 
    512     def DrawMyBounties_thread(self):
    513         self.myBountiesScroll.Flush()
    514         myBounties = self.bountySvc.GetMyBounties()
    515         if not len(myBounties):
    516             self.noBountiesPlaced.display = True
    517             self.myBountiesScroll.display = False
    518         else:
    519             self.noBountiesPlaced.display = False
    520             self.myBountiesScroll.display = True
    521             ownersToPrime = set()
    522             for b in myBounties:
    523                 ownersToPrime.add(b.targetID)
    524                 if hasattr(b, 'corporationID'):
    525                     ownersToPrime.add(b.corporationID)
    526                 if hasattr(b, 'allianceID'):
    527                     ownersToPrime.add(b.allianceID)
    528 
    529             cfg.eveowners.Prime(ownersToPrime)
    530             ownerIDs = set()
    531             for bounty in myBounties:
    532                 ownerIDs.add(bounty.targetID)
    533                 for entityID in ('corporationID', 'allianceID'):
    534                     ownerID = getattr(bounty, entityID, None)
    535                     if ownerID is not None:
    536                         ownerIDs.add(ownerID)
    537 
    538             sm.GetService('bountySvc').GetBounties(*ownerIDs)
    539             for bounty in sorted(myBounties, key=lambda x: x.contributionID, reverse=True):
    540                 ownerID = bounty.targetID
    541                 corpID = getattr(bounty, 'corporationID', None)
    542                 allianceID = getattr(bounty, 'allianceID', None)
    543                 myAmount = getattr(bounty, 'amount', 0)
    544                 if idCheckers.IsCharacter(ownerID):
    545                     contType = CharBounty
    546                 else:
    547                     contType = CorpBounty
    548                 contType(name='myBounty', parent=self.myBountiesScroll, ownerID=ownerID, corpID=corpID, allianceID=allianceID, myAmount=myAmount)
    549 
    550 
    551 class TopBountyContainer(Container):
    552     __notifyevents__ = ['OnBountyPlaced']
    553     default_height = 138
    554     default_align = uiconst.TOTOP
    555 
    556     def ApplyAttributes(self, attributes):
    557         Container.ApplyAttributes(self, attributes)
    558         sm.RegisterNotify(self)
    559         self.ownerID = attributes.get('ownerID', None)
    560         self.bounty = attributes.get('bounty', 0)
    561         self.corpID = attributes.get('corpID', None)
    562         self.allianceID = attributes.get('allianceID', session.allianceid)
    563         self.bountiesClaimed = attributes.get('bountiesClaimed', 0)
    564         self.numberOfKills = attributes.get('numberOfKills', 0)
    565         self.ConstructLayout()
    566 
    567     def ConstructLayout(self):
    568         ownerID = self.ownerID
    569         Container(name='bottomPadding', parent=self, align=uiconst.TOBOTTOM, height=10)
    570         mainCont = Container(name='mainCont', parent=self, align=uiconst.TOBOTTOM, height=128)
    571         Fill(bgParent=mainCont, color=(1.0, 1.0, 1.0, 0.075))
    572         self.imgCont = Container(name='myImgCont', parent=mainCont, align=uiconst.TOLEFT, width=128, state=uiconst.UI_NORMAL)
    573         self.placeBountyCont = Container(name='placeBountyCont', parent=mainCont, align=uiconst.TORIGHT, width=20, state=uiconst.UI_NORMAL)
    574         if idCheckers.IsAlliance(self.ownerID):
    575             bountyOwnerIDs = (self.ownerID, None, None)
    576         elif idCheckers.IsCorporation(self.ownerID):
    577             bountyOwnerIDs = (self.ownerID, None, self.allianceID)
    578         else:
    579             bountyOwnerIDs = (self.ownerID, self.corpID, self.allianceID)
    580         utilMenu = PlaceBountyUtilMenu(parent=self.placeBountyCont, ownerID=self.ownerID, bountyOwnerIDs=bountyOwnerIDs, align=uiconst.CENTER)
    581         self.placeBountyCont.width = utilMenu.width
    582         myTextCont = Container(name='textCont', parent=mainCont, align=uiconst.TOALL, padLeft=const.defaultPadding * 2, clipChildren=True)
    583         self.textCont = ContainerAutoSize(parent=myTextCont, name='textCont', align=uiconst.CENTERLEFT)
    584         self.nameLabel = eveLabel.EveCaptionSmall(text='', parent=self.textCont, maxLines=1, align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL)
    585         self.bountyLabel = eveLabel.EveCaptionSmall(text='', parent=self.textCont, maxLines=1, align=uiconst.TOPLEFT, top=26, state=uiconst.UI_NORMAL)
    586         ownerName = cfg.eveowners.Get(ownerID).name
    587         ownerType = self.ownerType = cfg.eveowners.Get(ownerID).typeID
    588         self.ownerLabel = localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=ownerName, info=('showinfo', ownerType, ownerID))
    589         self.numberCont = ContainerAutoSize(parent=self.imgCont, name='numberCont', align=uiconst.TOPLEFT, idx=0)
    590         Fill(bgParent=self.numberCont, color=(0.0, 0.0, 0.0, 0.4))
    591         self.numberLabel = eveLabel.EveCaptionLarge(text='1', parent=self.numberCont, align=uiconst.TOPLEFT, idx=0, left=2, padRight=2)
    592 
    593     def DisplayBountyAmount(self):
    594         bountyAmount = self.bounty
    595         self.bountyLabel.text = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount, 0))
    596         Sprite(name='wanted', parent=self.imgCont, idx=0, texturePath='res:/UI/Texture/wanted.png', width=128, height=34, align=uiconst.CENTERBOTTOM, state=uiconst.UI_PICKCHILDREN, top=2)
    597 
    598     def OnBountyPlaced(self, ownerID):
    599         if ownerID == self.ownerID:
    600             if self.bounty > 0:
    601                 bountyAmount = sm.GetService('bountySvc').GetBountyFromCache(ownerID)
    602                 self.bountyLabel.text = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount, 0))
    603 
    604     def ShowInfo(self, itemID, typeID, *args):
    605         sm.GetService('info').ShowInfo(typeID, itemID)
    606 
    607 
    608 class BountyContainer(Container):
    609     __notifyevents__ = ['OnBountyPlaced']
    610     default_height = 76
    611     default_align = uiconst.TOTOP
    612 
    613     def ApplyAttributes(self, attributes):
    614         Container.ApplyAttributes(self, attributes)
    615         sm.RegisterNotify(self)
    616         self.ownerID = attributes.get('ownerID', None)
    617         self.bounty = attributes.get('bounty', 0)
    618         self.myAmount = attributes.get('myAmount', 0)
    619         self.corpID = attributes.get('corpID', None)
    620         self.allianceID = attributes.get('allianceID', None)
    621         self.place = attributes.get('place', None)
    622         self.focus = attributes.get('focus', False)
    623         self.bountiesClaimed = attributes.get('bountiesClaimed', 0)
    624         self.numberOfKills = attributes.get('numberOfKills', 0)
    625         self.ConstructLayout()
    626 
    627     def ConstructLayout(self):
    628         ownerID = self.ownerID
    629         theCont = Container(name='theCont', parent=self)
    630         Container(name='mainCont', parent=theCont, align=uiconst.TOTOP, height=6)
    631         mainCont = Container(name='mainCont', parent=theCont, align=uiconst.TOTOP, height=64)
    632         self.imgCont = Container(name='myImgCont', parent=mainCont, align=uiconst.TOLEFT, width=64, state=uiconst.UI_NORMAL)
    633         if self.focus:
    634             Fill(bgParent=mainCont, color=(1.0, 1.0, 1.0, 0.075))
    635         self.placeBountyCont = Container(name='placeBountyCont', parent=mainCont, align=uiconst.TORIGHT, width=20, state=uiconst.UI_NORMAL)
    636         if idCheckers.IsAlliance(self.ownerID):
    637             bountyOwnerIDs = (self.ownerID, None, None)
    638         elif idCheckers.IsCorporation(self.ownerID):
    639             bountyOwnerIDs = (self.ownerID, None, self.allianceID)
    640         else:
    641             bountyOwnerIDs = (self.ownerID, self.corpID, self.allianceID)
    642         utilMenu = PlaceBountyUtilMenu(parent=self.placeBountyCont, ownerID=self.ownerID, bountyOwnerIDs=bountyOwnerIDs, align=uiconst.CENTER)
    643         self.placeBountyCont.width = utilMenu.width
    644         myTextCont = Container(name='textCont', parent=mainCont, align=uiconst.TOALL, padLeft=const.defaultPadding, clipChildren=True)
    645         self.textCont = ContainerAutoSize(parent=myTextCont, name='textCont', align=uiconst.CENTERLEFT)
    646         self.nameLabel = eveLabel.EveLabelMedium(text='', parent=self.textCont, maxLines=1, align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL)
    647         self.bountyLabel = eveLabel.EveLabelMediumBold(text='', parent=self.textCont, maxLines=1, align=uiconst.TOPLEFT, top=16, state=uiconst.UI_NORMAL)
    648         ownerName = cfg.eveowners.Get(ownerID).name
    649         ownerType = self.ownerType = cfg.eveowners.Get(ownerID).typeID
    650         self.ownerLabel = localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=ownerName, info=('showinfo', ownerType, ownerID))
    651         self.numberCont = ContainerAutoSize(parent=self.imgCont, name='numberCont', align=uiconst.TOPLEFT, idx=0)
    652         Fill(bgParent=self.numberCont, color=(0.0, 0.0, 0.0, 0.4))
    653         self.numberLabel = eveLabel.EveLabelMediumBold(text=self.place, parent=self.numberCont, align=uiconst.TOPLEFT, idx=0, left=2, padRight=2)
    654 
    655     def DisplayMyAmount(self):
    656         myAmount = self.myAmount
    657         self.bountyLabel.text = localization.GetByLabel('UI/Station/BountyOffice/MyContribution', bountyAmount=eveFormat.FmtISK(myAmount, 0))
    658         if idCheckers.IsAlliance(self.ownerID):
    659             bountyOwnerIDs = (self.ownerID, None, None)
    660         elif idCheckers.IsCorporation(self.ownerID):
    661             bountyOwnerIDs = (self.ownerID, None, self.allianceID)
    662         else:
    663             bountyOwnerIDs = (self.ownerID, self.corpID, self.allianceID)
    664         bountyAmount = sm.GetService('bountySvc').GetBounty(*bountyOwnerIDs)
    665         self.bountyLabel.hint = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount, 0))
    666         Sprite(name='wanted', parent=self.imgCont, idx=0, texturePath='res:/UI/Texture/wanted.png', width=64, height=17, align=uiconst.CENTERBOTTOM, state=uiconst.UI_PICKCHILDREN, top=1)
    667 
    668     def DisplayBountyAmount(self):
    669         bountyAmount = self.bounty
    670         self.bountyLabel.text = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount, 0))
    671         Sprite(name='wanted', parent=self.imgCont, idx=0, texturePath='res:/UI/Texture/wanted.png', width=64, height=17, align=uiconst.CENTERBOTTOM, state=uiconst.UI_PICKCHILDREN, top=1)
    672 
    673     def OnBountyPlaced(self, ownerID):
    674         if ownerID == self.ownerID:
    675             if self.bounty > 0:
    676                 bountyAmount = sm.GetService('bountySvc').GetBountyFromCache(ownerID)
    677                 self.bountyLabel.text = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount, 0))
    678 
    679     def ShowInfo(self, itemID, typeID, *args):
    680         sm.GetService('info').ShowInfo(typeID, itemID)
    681 
    682 
    683 class TopCharBounty(TopBountyContainer):
    684 
    685     def ApplyAttributes(self, attributes):
    686         TopBountyContainer.ApplyAttributes(self, attributes)
    687 
    688     def ConstructLayout(self):
    689         TopBountyContainer.ConstructLayout(self)
    690         self.corpLabel = eveLabel.EveLabelMedium(text='', parent=self.textCont, maxLines=1, align=uiconst.TOPLEFT, top=26, state=uiconst.UI_NORMAL)
    691         self.bountyLabel.top = 44
    692         self.LoadInfo()
    693 
    694     def LoadInfo(self):
    695         ownerID = self.ownerID
    696         corpID = self.corpID
    697         allianceID = self.allianceID
    698         ownerType = self.ownerType
    699         self.nameLabel.text = self.ownerLabel
    700         ownerLogo = Sprite(parent=self.imgCont, align=uiconst.TOALL, size=128, idx=0, texturePath='res:/UI/Texture/silhouette.png')
    701         sm.GetService('photo').GetPortrait(ownerID, 128, ownerLogo)
    702         ownerLogo.OnClick = (self.ShowInfo, ownerID, ownerType)
    703         ownerLogo.hint = cfg.eveowners.Get(ownerID).name
    704         if corpID:
    705             corpText = localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=cfg.eveowners.Get(corpID).name, info=('showinfo', const.typeCorporation, corpID))
    706         if allianceID:
    707             ticker = cfg.allianceshortnames.Get(allianceID).shortName
    708             allianceText = ' [%s]' % localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=ticker, info=('showinfo', const.typeAlliance, allianceID))
    709             corpText += allianceText
    710         self.corpLabel.text = corpText
    711         self.nameLabel.text = self.ownerLabel
    712         if self.bounty > 0:
    713             self.DisplayBountyAmount()
    714         elif self.bountiesClaimed > 0:
    715             self.DisplayISKDestroyed()
    716         self.numberCont.SetOrder(0)
    717 
    718     def DisplayISKDestroyed(self):
    719         killAmount = eveFormat.FmtISK(self.bountiesClaimed, 0)
    720         self.bountyLabel.text = localization.GetByLabel('UI/Station/BountyOffice/BountyClaimed', kills=self.numberOfKills, iskAmount=killAmount)
    721 
    722 
    723 class CharBounty(BountyContainer):
    724 
    725     def ApplyAttributes(self, attributes):
    726         BountyContainer.ApplyAttributes(self, attributes)
    727 
    728     def ConstructLayout(self):
    729         BountyContainer.ConstructLayout(self)
    730         self.corpLabel = eveLabel.EveLabelSmall(text='', parent=self.textCont, maxLines=1, align=uiconst.TOPLEFT, top=16, state=uiconst.UI_NORMAL)
    731         self.bountyLabel.top = 30
    732         self.LoadInfo()
    733 
    734     def LoadInfo(self):
    735         ownerID = self.ownerID
    736         corpID = self.corpID
    737         allianceID = self.allianceID
    738         ownerType = self.ownerType
    739         self.nameLabel.text = self.ownerLabel
    740         ownerLogo = Sprite(parent=self.imgCont, align=uiconst.TOALL, size=64, idx=0, texturePath='res:/UI/Texture/silhouette_64.png')
    741         sm.GetService('photo').GetPortrait(ownerID, 64, ownerLogo)
    742         ownerLogo.OnClick = (self.ShowInfo, ownerID, ownerType)
    743         ownerLogo.hint = cfg.eveowners.Get(ownerID).name
    744         if corpID:
    745             corpText = localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=cfg.eveowners.Get(corpID).name, info=('showinfo', const.typeCorporation, corpID))
    746         if allianceID:
    747             ticker = cfg.allianceshortnames.Get(allianceID).shortName
    748             allianceText = ' [%s]' % localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=ticker, info=('showinfo', const.typeAlliance, allianceID))
    749             corpText += allianceText
    750         self.corpLabel.text = corpText
    751         self.nameLabel.text = self.ownerLabel
    752         if self.bounty > 0:
    753             self.DisplayBountyAmount()
    754         elif self.bountiesClaimed > 0:
    755             self.DisplayISKDestroyed()
    756         elif self.myAmount > 0:
    757             self.DisplayMyAmount()
    758         self.numberCont.SetOrder(0)
    759 
    760     def DisplayISKDestroyed(self):
    761         killAmount = eveFormat.FmtISK(self.bountiesClaimed, 0)
    762         self.bountyLabel.text = localization.GetByLabel('UI/Station/BountyOffice/BountyClaimed', kills=self.numberOfKills, iskAmount=killAmount)
    763 
    764 
    765 class TopCorpBounty(TopBountyContainer):
    766 
    767     def ApplyAttributes(self, attributes):
    768         TopBountyContainer.ApplyAttributes(self, attributes)
    769 
    770     def ConstructLayout(self):
    771         TopBountyContainer.ConstructLayout(self)
    772         self.LoadInfo()
    773 
    774     def LoadInfo(self):
    775         ownerID = self.ownerID
    776         corpID = self.corpID
    777         allianceID = self.allianceID
    778         ownerType = self.ownerType
    779         ownerLogo = eveIcon.GetLogoIcon(ownerID, parent=self.imgCont, acceptNone=False, align=uiconst.TOPRIGHT, height=128, width=128, state=uiconst.UI_NORMAL)
    780         if idCheckers.IsCorporation(ownerID):
    781             if allianceID:
    782                 ticker = cfg.allianceshortnames.Get(allianceID).shortName
    783                 allianceText = ' [%s]' % localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=ticker, info=('showinfo', const.typeAlliance, allianceID))
    784                 self.ownerLabel += allianceText
    785         ownerLogo.OnClick = (self.ShowInfo, ownerID, ownerType)
    786         ownerLogo.SetSize(128, 128)
    787         self.nameLabel.text = self.ownerLabel
    788         if self.bounty > 0:
    789             self.DisplayBountyAmount()
    790         elif self.bountiesClaimed > 0:
    791             self.DisplayISKDestroyed()
    792 
    793     def DisplayISKDestroyed(self):
    794         killAmount = eveFormat.FmtISK(self.bountiesClaimed, 0)
    795         self.bountyLabel.text = localization.GetByLabel('UI/Station/BountyOffice/BountyClaimedCorps', iskAmount=killAmount)
    796 
    797 
    798 class CorpBounty(BountyContainer):
    799 
    800     def ApplyAttributes(self, attributes):
    801         BountyContainer.ApplyAttributes(self, attributes)
    802 
    803     def ConstructLayout(self):
    804         BountyContainer.ConstructLayout(self)
    805         self.LoadInfo()
    806 
    807     def LoadInfo(self):
    808         ownerID = self.ownerID
    809         corpID = self.corpID
    810         allianceID = self.allianceID
    811         ownerType = self.ownerType
    812         ownerLogo = eveIcon.GetLogoIcon(ownerID, parent=self.imgCont, acceptNone=False, align=uiconst.TOPRIGHT, height=64, width=64, state=uiconst.UI_NORMAL)
    813         if idCheckers.IsCorporation(ownerID):
    814             if allianceID:
    815                 ticker = cfg.allianceshortnames.Get(allianceID).shortName
    816                 allianceText = ' [%s]' % localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=ticker, info=('showinfo', const.typeAlliance, allianceID))
    817                 self.ownerLabel += allianceText
    818         ownerLogo.OnClick = (self.ShowInfo, ownerID, ownerType)
    819         ownerLogo.SetSize(64, 64)
    820         self.nameLabel.text = self.ownerLabel
    821         if self.bounty > 0:
    822             self.DisplayBountyAmount()
    823         elif self.bountiesClaimed > 0:
    824             self.DisplayISKDestroyed()
    825         elif self.myAmount > 0:
    826             self.DisplayMyAmount()
    827 
    828     def DisplayISKDestroyed(self):
    829         killAmount = eveFormat.FmtISK(self.bountiesClaimed, 0)
    830         self.bountyLabel.text = localization.GetByLabel('UI/Station/BountyOffice/BountyClaimedCorps', iskAmount=killAmount)
    831 
    832 
    833 class PlaceBountyUtilMenu(UtilMenu):
    834     default_name = 'placeBountyUtilMenu'
    835     default_menuAlign = uiconst.TOPRIGHT
    836     default_align = uiconst.BOTTOMRIGHT
    837     default_texturePath = ''
    838     default_top = -2
    839     default_iconSize = 0
    840 
    841     def ApplyAttributes(self, attributes):
    842         label = attributes.label or localization.GetByLabel('UI/Station/BountyOffice/AddBounty')
    843         attributes.GetUtilMenu = self.SetBounty
    844         attributes.label = label
    845         attributes.labelAlign = uiconst.CENTERRIGHT
    846         UtilMenu.ApplyAttributes(self, attributes)
    847         self.ownerID = attributes.get('ownerID', None)
    848         self.bountyOwnerIDs = attributes.get('bountyOwnerIDs', None)
    849         self.hint = localization.GetByLabel('UI/Station/BountyOffice/PlaceBounty')
    850 
    851     def SetBounty(self, menuParent):
    852         cont = menuParent.AddContainer(align=uiconst.TOTOP, padding=const.defaultPadding)
    853         cont.GetEntryWidth = lambda mc = cont: 375
    854         eveLabel.EveLabelLarge(text=localization.GetByLabel('UI/Station/BountyOffice/PlaceBounty'), parent=cont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, bold=True)
    855         ownerID = self.ownerID
    856         victimCont = Container(name='victimCont', parent=cont, align=uiconst.TOTOP, height=30, padTop=8)
    857         imgCont = Container(name='imgCont', parent=victimCont, width=30, align=uiconst.TOLEFT)
    858         textCont = Container(name='textCont', parent=victimCont, align=uiconst.TOALL, padLeft=const.defaultPadding)
    859         nameLabel = eveLabel.EveLabelMedium(name='bountyName', parent=textCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, maxLines=1)
    860         self.bountyLabel = eveLabel.EveLabelSmall(name='bountyAmount', parent=textCont, align=uiconst.TOBOTTOM, state=uiconst.UI_NORMAL)
    861         bountyAmount = self.GetBountyAmount(*self.bountyOwnerIDs)
    862         ownerType = cfg.eveowners.Get(ownerID).typeID
    863         if idCheckers.IsCharacter(ownerID):
    864             ownerPortrait = Sprite(parent=imgCont, align=uiconst.TOALL, idx=0, texturePath='res:/UI/Texture/silhouette_64.png')
    865             sm.GetService('photo').GetPortrait(ownerID, 30, ownerPortrait)
    866         else:
    867             ownerPortrait = eveIcon.GetLogoIcon(itemID=ownerID, parent=imgCont, acceptNone=False, align=uiconst.TOPRIGHT, height=30, width=30, state=uiconst.UI_NORMAL)
    868         ownerName = cfg.eveowners.Get(ownerID).name
    869         nameLabel.text = localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=ownerName, info=('showinfo', ownerType, ownerID))
    870         self.bountyLabel.text = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount, False))
    871         bountyCont = Container(name='bountyCont', parent=cont, align=uiconst.TOTOP, height=32, padTop=10)
    872         self.placeBountiesBtn = Button(parent=bountyCont, label=localization.GetByLabel('UI/Station/BountyOffice/Place'), align=uiconst.TOPRIGHT, func=self.PlaceBounty)
    873         minAmount = self.GetMinimumBountyAmount()
    874         editWidth = 375 - self.placeBountiesBtn.width - 6
    875         self.bountyAmount = SingleLineEditInteger(name='placeEdit', parent=bountyCont, align=uiconst.TOPLEFT, width=editWidth, maxValue=const.MAX_BOUNTY_AMOUNT, hintText=localization.GetByLabel('UI/Station/BountyOffice/InsertAmount', bountyAmount=eveFormat.FmtISK(minAmount)), padRight=const.defaultPadding, top=0, dataType=long)
    876         self.bountyAmount.OnReturn = self.PlaceBounty
    877         self.SetBountyHint()
    878 
    879     def SetBountyHint(self):
    880         bountyAmounts = self.GetBountyAmounts(*self.bountyOwnerIDs)
    881         charBounty = 0
    882         corpBounty = 0
    883         allianceBounty = 0
    884         if len(bountyAmounts):
    885             for ownerID, value in bountyAmounts.iteritems():
    886                 if idCheckers.IsCharacter(ownerID):
    887                     charBounty = value
    888                 elif idCheckers.IsCorporation(ownerID):
    889                     corpBounty = value
    890                 elif idCheckers.IsAlliance(ownerID):
    891                     allianceBounty = value
    892 
    893         bountyHint = localization.GetByLabel('UI/Station/BountyOffice/BountyHint', charBounty=eveFormat.FmtISK(charBounty, 0), corpBounty=eveFormat.FmtISK(corpBounty, 0), allianceBounty=eveFormat.FmtISK(allianceBounty, 0))
    894         self.bountyLabel.hint = bountyHint
    895 
    896     def GetBountyAmounts(self, *ownerIDs):
    897         bountyAmounts = sm.GetService('bountySvc').GetBounties(*ownerIDs)
    898         return bountyAmounts
    899 
    900     def GetBountyAmount(self, *ownerIDs):
    901         bountyAmount = sm.GetService('bountySvc').GetBounty(*ownerIDs)
    902         return bountyAmount
    903 
    904     def GetMinimumBountyAmount(self):
    905         ownerID = self.ownerID
    906         return bountyUtil.GetMinimumBountyAmount(ownerID)
    907 
    908     def PlaceBounty(self, *args):
    909         if self.placeBountiesBtn.disabled:
    910             return
    911         if not self.ownerID:
    912             return
    913         ownerID = self.ownerID
    914         amount = self.bountyAmount.GetValue()
    915         minAmount = self.GetMinimumBountyAmount()
    916         if amount < minAmount:
    917             self.bountyAmount.SetValue('')
    918             self.bountyAmount.SetHintText(localization.GetByLabel('UI/Station/BountyOffice/TooLowEnterMore', minAmount=eveFormat.FmtISK(minAmount)))
    919             return
    920         if ownerID and amount:
    921             sm.GetService('bountySvc').AddToBounty(ownerID, amount)
    922             self.bountyAmount.SetValue('')
    923             bountyAmount = self.GetBountyAmount(*self.bountyOwnerIDs)
    924             bountyText = localization.GetByLabel('UI/Common/BountyAmount', bountyAmount=eveFormat.FmtISK(bountyAmount))
    925             self.bountyLabel.text = bountyText
    926             sm.GetService('objectCaching').InvalidateCachedMethodCall('charMgr', 'GetPublicInfo3', ownerID)
    927             sm.ScatterEvent('OnBountyPlaced', ownerID)
    928             self.CloseMenu()
    929 
    930     def GetFullWidth(self):
    931         return const.defaultPadding * 2 + self._label.width
    932 
    933     def SetLabel(self, label, labelAlign):
    934         UtilMenu.SetLabel(self, label, labelAlign)
    935         self._label.left = const.defaultPadding
    936 
    937 
    938 class BountyPicker(Window):
    939     __guid__ = 'form.BountyPicker'
    940     default_windowID = 'BountyPicker'
    941 
    942     def ApplyAttributes(self, attributes):
    943         Window.ApplyAttributes(self, attributes)
    944         self.ownerID = None
    945         self.resultList = attributes.Get('resultList', '')
    946         self.SetScope(uiconst.SCOPE_INGAME)
    947         self.Confirm = self.ValidateOK
    948         self.SetCaption(localization.GetByLabel('UI/Station/BountyOffice/PlaceBounty'))
    949         self.SetMinSize([320, 300])
    950         self.sr.main = self.GetChild('main')
    951         self.sr.standardBtns = ButtonGroup(btns=[[localization.GetByLabel('UI/Generic/OK'),
    952           self.OnOK,
    953           (),
    954           81], [localization.GetByLabel('UI/Generic/Cancel'),
    955           self.OnCancel,
    956           (),
    957           81]])
    958         self.sr.main.children.insert(0, self.sr.standardBtns)
    959         self.scroll = eveScroll.Scroll(parent=self.sr.main, padding=const.defaultPadding)
    960         self.scroll.multiSelect = False
    961         self.MakeList()
    962 
    963     def MakeList(self):
    964         scrolllist = []
    965         charList = []
    966         corpList = []
    967         allianceList = []
    968         if self.resultList:
    969             cfg.eveowners.Prime(self.resultList)
    970         for ownerID in self.resultList:
    971             if idCheckers.IsCharacter(ownerID):
    972                 charList.append(ownerID)
    973             elif idCheckers.IsCorporation(ownerID):
    974                 corpList.append(ownerID)
    975             elif idCheckers.IsAlliance(ownerID):
    976                 allianceList.append(ownerID)
    977 
    978         if len(charList):
    979             myLabel = localization.GetByLabel('UI/Search/UniversalSearch/Characters')
    980             charGroup = self.GetGroup(charList, myLabel, 'charBounty')
    981             scrolllist.append(charGroup)
    982         if len(corpList):
    983             myLabel = localization.GetByLabel('UI/Search/UniversalSearch/Corporations')
    984             charGroup = self.GetGroup(corpList, myLabel, 'corpBounty')
    985             scrolllist.append(charGroup)
    986         if len(allianceList):
    987             myLabel = localization.GetByLabel('UI/Search/UniversalSearch/Alliances')
    988             charGroup = self.GetGroup(allianceList, myLabel, 'allianceBounty')
    989             scrolllist.append(charGroup)
    990         self.scroll.Load(fixedEntryHeight=18, contentList=scrolllist, noContentHint=localization.GetByLabel('UI/Station/BountyOffice/NoOneFound'))
    991 
    992     def GetGroup(self, list, label, type):
    993         return GetFromClass(ListGroup, {'GetSubContent': self.GetSubContent,
    994          'label': label,
    995          'id': ('bounty', type, label),
    996          'state': 'locked',
    997          'BlockOpenWindow': 1,
    998          'showicon': 'hide',
    999          'showlen': 1,
   1000          'groupName': type,
   1001          'groupItems': list,
   1002          'updateOnToggle': 0})
   1003 
   1004     def GetSubContent(self, items, *args):
   1005         cfg.eveowners.Prime(items.groupItems)
   1006         scrolllist = []
   1007         for ownerID in items.groupItems:
   1008             owner = cfg.eveowners.Get(ownerID)
   1009             scrolllist.append((owner.ownerName.lower(), GetFromClass(PlaceBountyEntry, {'label': owner.ownerName,
   1010               'OnDblClick': self.OnOK,
   1011               'typeID': owner.typeID,
   1012               'itemID': ownerID,
   1013               'confirmOnDblClick': 1,
   1014               'listvalue': [owner.ownerName, ownerID]})))
   1015 
   1016         scrolllist = SortListOfTuples(scrolllist)
   1017         return scrolllist
   1018 
   1019     def Confirm(self):
   1020         self.OnOK()
   1021 
   1022     def ValidateOK(self):
   1023         log.LogInfo('ValidateOK')
   1024         if self.ownerID is None:
   1025             return 0
   1026         return 1
   1027 
   1028     def OnOK(self, *args):
   1029         if len(self.scroll.GetNodes()) == 0:
   1030             self.ownerID = None
   1031             self.CloseByUser()
   1032         sel = self.scroll.GetSelected()
   1033         if sel:
   1034             self.ownerID = sel[0].itemID
   1035             self.CloseByUser()
   1036 
   1037     def OnCancel(self, *args):
   1038         self.ownerID = None
   1039         self.CloseByUser()
   1040 
   1041 
   1042 class PlaceBountyEntry(Generic):
   1043     __guid__ = 'listentry.PlaceBountyEntry'
   1044 
   1045     def Startup(self, *args):
   1046         Generic.Startup(self, args)
   1047         self.sr.label.left = 40
   1048         self.sr.label.state = uiconst.UI_NORMAL
   1049         self.imgCont = Container(name='imgCont', parent=self, width=34, align=uiconst.TOLEFT, padTop=2, padBottom=2, padLeft=2)
   1050         self.stateCont = Container(name='stateCont', parent=self, width=16, align=uiconst.TORIGHT)
   1051 
   1052     def Load(self, node):
   1053         self.sr.node = node
   1054         data = node
   1055         ownerID = self.ownerID = data.itemID
   1056         self.typeID = data.typeID
   1057         label = localization.GetByLabel('UI/Contracts/ContractsWindow/ShowInfoLink', showInfoName=data.label, info=('showinfo', self.typeID, self.ownerID))
   1058         self.sr.label.text = label
   1059         if node.selected:
   1060             self.Select()
   1061         else:
   1062             self.Deselect()
   1063         if idCheckers.IsCharacter(ownerID):
   1064             ownerLogo = Sprite(parent=self.imgCont, align=uiconst.TOALL, size=32, texturePath='res:/UI/Texture/silhouette_64.png')
   1065             sm.GetService('photo').GetPortrait(ownerID, 32, ownerLogo)
   1066         else:
   1067             ownerLogo = eveIcon.GetLogoIcon(ownerID, parent=self.imgCont, acceptNone=False, align=uiconst.TOPRIGHT, height=32, width=32, state=uiconst.UI_NORMAL)
   1068             ownerLogo.SetSize(32, 32)
   1069         ownerLogo.OnClick = (self.ShowInfo, ownerID, self.typeID)
   1070         ownerLogo.hint = cfg.eveowners.Get(ownerID).name
   1071 
   1072     def GetHeight(_self, *args):
   1073         node, width = args
   1074         node.height = 38
   1075         return node.height
   1076 
   1077     def GetMenu(self):
   1078         if self.sr.node.Get('GetMenu', None):
   1079             return self.sr.node.GetMenu(self)
   1080         if self.ownerID:
   1081             return GetMenuService().GetMenuFromItemIDTypeID(self.ownerID, self.typeID, includeMarketDetails=True)
   1082         if self.typeID:
   1083             return GetMenuService().GetMenuFromItemIDTypeID(None, self.typeID, includeMarketDetails=True)
   1084         return []
   1085 
   1086     def ShowInfo(self, ownerID, typeID, *args):
   1087         sm.GetService('info').ShowInfo(typeID, ownerID)