inControlCont.py (4833B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\dockedUI\inControlCont.py 2 from carbonui import const as uiconst 3 from carbonui.primitives.containerAutoSize import ContainerAutoSize 4 from carbonui.primitives.fill import Fill 5 from carbonui.primitives.layoutGrid import LayoutGrid 6 from carbonui.primitives.sprite import Sprite 7 from carbonui.button.group import ButtonGroup 8 from eve.client.script.ui.control.eveIcon import GetLogoIcon 9 from eve.client.script.ui.control.eveLabel import EveLabelMedium, EveLabelSmall 10 from carbonui.control.window import Window 11 import localization 12 import uthread 13 14 class PlayerInControlCont(ContainerAutoSize): 15 default_alignMode = uiconst.TOPLEFT 16 maxTextWidth = 300 17 18 def ApplyAttributes(self, attributes): 19 ContainerAutoSize.ApplyAttributes(self, attributes) 20 charID = attributes.charID 21 parentLayoutGrid = LayoutGrid(parent=self, columns=2, align=uiconst.TOPLEFT, padding=6, cellSpacing=(10, 10)) 22 addHeader = attributes.get('addHeader', True) 23 if addHeader: 24 self.AddHeader(parentLayoutGrid) 25 sprite = Sprite(parent=parentLayoutGrid, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(0, 0, 128, 128)) 26 sm.GetService('photo').GetPortrait(charID, 128, sprite, allowServerTrip=True) 27 subLayoutGrid = LayoutGrid(parent=parentLayoutGrid, columns=2, align=uiconst.TOPLEFT) 28 spacer = Fill(align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, width=128, height=1, color=(0, 0, 0, 0)) 29 subLayoutGrid.AddCell(cellObject=spacer, colSpan=2) 30 parallelCalls = [] 31 parallelCalls.append((sm.RemoteSvc('charMgr').GetPublicInfo3, (charID,))) 32 parallelCalls.append((sm.GetService('corp').GetInfoWindowDataForChar, (charID, 1))) 33 charinfo, corpCharInfo = uthread.parallel(parallelCalls) 34 charName = cfg.eveowners.Get(charID).name 35 nameLabel = EveLabelMedium(text=charName, autoFitToText=True) 36 subLayoutGrid.AddCell(cellObject=nameLabel, colSpan=2) 37 titleText = self.GetTitleText(corpCharInfo) 38 titleLabel = EveLabelMedium(text=titleText, autoFitToText=True) 39 if titleLabel.textwidth > self.maxTextWidth: 40 titleLabel.width = self.maxTextWidth 41 subLayoutGrid.AddCell(cellObject=titleLabel, colSpan=2) 42 if corpCharInfo: 43 corpID = corpCharInfo.corpID 44 allianceID = corpCharInfo.allianceID 45 for eachID in (corpID, allianceID): 46 if eachID: 47 logo = self.GetLogo(eachID) 48 logo.hint = cfg.eveowners.Get(eachID).name 49 subLayoutGrid.AddCell(cellObject=logo) 50 51 def AddHeader(self, parent): 52 self.headerLabel = EveLabelSmall(text=localization.GetByLabel('UI/Station/PilotInControl'), padbottom=6) 53 parent.AddCell(cellObject=self.headerLabel, colSpan=2) 54 55 def GetTitleText(self, corpCharInfo): 56 titleList = [] 57 if corpCharInfo.title: 58 titleList.append(corpCharInfo.title) 59 for i in xrange(1, 17): 60 titleText = getattr(corpCharInfo, 'title%s' % i, None) 61 if titleText: 62 titleList.append(titleText) 63 64 if len(titleList): 65 title = localization.formatters.FormatGenericList(titleList) 66 return title 67 else: 68 return 69 70 def GetLogo(self, corpID): 71 logo = GetLogoIcon(itemID=corpID, state=uiconst.UI_NORMAL, align=uiconst.TOPLEFT, pos=(0, 0, 64, 64), ignoreSize=True) 72 return logo 73 74 75 class ConfirmTakeControl(Window): 76 __guid__ = 'ConfirmTakeControl' 77 default_captionLabelPath = 'UI/Station/PilotInControl' 78 79 def ApplyAttributes(self, attributes): 80 Window.ApplyAttributes(self, attributes) 81 self.MakeUnResizeable() 82 self.controller = attributes.controller 83 charInControl = attributes.charInControl 84 self.btnGroup = ButtonGroup(parent=self.sr.main, idx=0) 85 self.btnGroup.AddButton(localization.GetByLabel('UI/Commands/TakeStructureControl'), self.TakeControl) 86 self.btnGroup.AddButton(localization.GetByLabel('UI/Generic/Cancel'), self.Cancel) 87 self.playerCont = PlayerInControlCont(parent=self.sr.main, align=uiconst.CENTERTOP, addHeader=False, charID=charInControl, callback=self.OnContainerResized) 88 self.SetCaption(localization.GetByLabel('UI/Station/PilotInControl')) 89 self.ShowModal() 90 91 def OnContainerResized(self): 92 w, h = self.playerCont.GetAutoSize() 93 self.height = self.btnGroup.height + h + self.sr.headerParent.height 94 self.width = max(w, 300) 95 96 def TakeControl(self, *args): 97 try: 98 self.controller.TakeControl() 99 finally: 100 self.Close() 101 102 def Cancel(self, *args): 103 self.CloseByUser()