infoPicker.py (3253B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\factionalWarfare\enlistmentFlow\infoPicker.py 2 from carbonui import TextColor 3 from carbonui.text.styles import TextBody 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.containerAutoSize import ContainerAutoSize 6 import carbonui.const as uiconst 7 from carbonui.primitives.layoutGrid import LayoutGrid 8 import eve.client.script.ui.shared.factionalWarfare.enlistmentFlow.enlistmentUtil as enlistmentUtil 9 from eve.client.script.ui.control.toggleButtonGroupCircular import ToggleButtonGroupCircular 10 from eve.client.script.ui.shared.factionalWarfare.enlistmentFlow.enlistmentConst import INFO_MAX_WIDTH 11 from localization import GetByLabel 12 BUTTON_SIZE = 32 13 14 class InfoPickerCont(ContainerAutoSize): 15 default_align = uiconst.TOTOP 16 default_name = 'infoPicker' 17 default_maxWidth = INFO_MAX_WIDTH 18 19 def ApplyAttributes(self, attributes): 20 super(InfoPickerCont, self).ApplyAttributes(attributes) 21 self.factionID = None 22 self.selectedInfo = enlistmentUtil.INFO_1 23 self.grid = LayoutGrid(parent=self, align=uiconst.TOTOP, columns=2, padTop=24) 24 self.grid.AddCell(cellObject=Container(name='spacer', align=uiconst.TOPLEFT, width=0)) 25 self.grid.AddCell(cellObject=Container(name='spacer', align=uiconst.TOPLEFT, width=INFO_MAX_WIDTH)) 26 self.textHeightSpacer = Container(parent=self.grid, name='spacer', align=uiconst.TOPLEFT, width=0) 27 self.infoLabel = TextBody(parent=self.grid, align=uiconst.TOPLEFT, text='', maxWidth=INFO_MAX_WIDTH, color=TextColor.SECONDARY) 28 self.buttonCont = ContainerAutoSize(align=uiconst.CENTER) 29 self.grid.AddCell(self.buttonCont, colSpan=2) 30 self.toggleBtnGroup = ToggleButtonGroupCircular(name='toggleBtnGroup', parent=self.buttonCont, align=uiconst.TOPLEFT, callback=self.OnToggleBtnClicked) 31 self.LoadIcons() 32 btnID = enlistmentUtil.INFO_ICONS[0][0] 33 self.toggleBtnGroup.SelectByID(btnID) 34 35 def LoadIcons(self): 36 for infoConst, texturePath, hintLabelPath in enlistmentUtil.INFO_ICONS: 37 self.toggleBtnGroup.AddButton(btnID=infoConst, iconPath=texturePath, iconSize=16, btnSize=32, hint=GetByLabel(hintLabelPath)) 38 39 def OnToggleBtnClicked(self, btnID, oldBtnID): 40 self.ClickIcon(btnID) 41 42 def ClickIcon(self, infoConst): 43 self.selectedInfo = infoConst 44 self.LoadInfo() 45 46 def UpdateFaction(self, factionID): 47 self.factionID = factionID 48 self.LoadInfo() 49 50 def LoadInfo(self): 51 infoLabelPath = enlistmentUtil.GetInfoLabelPath(self.factionID, self.selectedInfo) 52 self.textHeightSpacer.height = self.FindMaxTextHeight(self.factionID) 53 text = GetByLabel(infoLabelPath) if infoLabelPath else '' 54 self.infoLabel.text = text 55 56 def FindMaxTextHeight(self, factionID): 57 if not factionID: 58 return 0 59 maxHeight = 0 60 for labelPath in enlistmentUtil.INFO_BY_FACTION_ID[factionID].itervalues(): 61 textwidth, textHeight = TextBody.MeasureTextSize(GetByLabel(labelPath), maxWidth=INFO_MAX_WIDTH) 62 maxHeight = max(maxHeight, textHeight) 63 64 return maxHeight + 2