technologyView.py (4876B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation\empireTechnologyViews\technologyView.py 2 import carbonui.const as uiconst 3 from carbonui.primitives.container import Container 4 from carbonui.primitives.sprite import Sprite 5 from eve.client.script.ui.login.charcreation.technologyViewUtils import TechExampleButton 6 TECH_EXAMPLE_BUTTON_HEIGHT = 50 7 TECH_EXAMPLE_BUTTON_SEPARATION = 8 8 TECH_EXAMPLE_BUTTON_PAD_LEFT = 25 9 TECH_EXAMPLE_BUTTON_PAD_BOT = 30 10 TECH_EXAMPLE_BUTTON_ICON_SIZE = 32 11 TECH_EXAMPLE_BUTTON_ICON_TO_TEXT = 16 12 TECH_EXAMPLE_BUTTON_INTERNAL_PADDING = 3 13 14 class TechnologyView(Container): 15 16 def ApplyAttributes(self, attributes): 17 self.AddInternalPadding(attributes) 18 Container.ApplyAttributes(self, attributes) 19 self.raceID = attributes.Get('raceID', None) 20 self.technology = attributes.Get('technology', None) 21 22 def AddInternalPadding(self, attributes): 23 internalPadTop = attributes.Get('internalPadTop', 0) 24 internalPadBottom = attributes.Get('internalPadBottom', 0) 25 height = attributes.Get('height') 26 attributes.Set('height', height - internalPadTop - internalPadBottom) 27 padTop = attributes.Get('padTop', 0) 28 attributes.Set('padTop', padTop + internalPadTop) 29 padBottom = attributes.Get('padBottom', 0) 30 attributes.Set('padBottom', padBottom + internalPadBottom) 31 32 33 class TechnologyViewWithCentralPic(TechnologyView): 34 35 def ApplyAttributes(self, attributes): 36 TechnologyView.ApplyAttributes(self, attributes) 37 mainView = self.technology.GetMainView(self.raceID) 38 if mainView: 39 self.AddMainView(mainView) 40 41 def AddMainView(self, mainView): 42 self.centralViewContainer = Container(name='centralViewContainer', parent=self, align=uiconst.ANCH_TOPLEFT, width=self.width, height=self.height, state=uiconst.UI_DISABLED, opacity=0.0) 43 centralViewWrapper = Container(name='centralViewWrapper', parent=self.centralViewContainer, align=uiconst.TOLEFT, width=self.centralViewContainer.width, height=self.centralViewContainer.height) 44 Sprite(name='centralView', parent=centralViewWrapper, align=uiconst.TOTOP, width=centralViewWrapper.width, height=centralViewWrapper.height, texturePath=mainView, useSizeFromTexture=False) 45 46 def ShowMainView(self): 47 self.centralViewContainer.opacity = 1.0 48 49 50 class TechnologyViewWithExampleButtons(TechnologyView): 51 52 def ApplyAttributes(self, attributes): 53 TechnologyView.ApplyAttributes(self, attributes) 54 self.techExampleOrder = attributes.Get('techExampleOrder', 1) 55 self.techExampleButtons = {} 56 self._AddTechExampleButtons() 57 self.techExampleView = None 58 self.SetTechExampleView(order=self.techExampleOrder) 59 60 def _AddTechExampleButtons(self): 61 numButtons = self.technology.GetNumberOfExamples() 62 if numButtons < 1: 63 return 64 textWidth = self.technology.GetMaxTechExampleTitleWidth(self.raceID) + 2 * TECH_EXAMPLE_BUTTON_INTERNAL_PADDING 65 totalWidth = TECH_EXAMPLE_BUTTON_PAD_LEFT + TECH_EXAMPLE_BUTTON_ICON_SIZE + 2 * TECH_EXAMPLE_BUTTON_ICON_TO_TEXT + textWidth 66 padBottom = TECH_EXAMPLE_BUTTON_PAD_BOT 67 totalHeight = self.height - padBottom 68 self.techExamplesContainer = Container(name='techExamplesContainer', align=uiconst.TOALL, parent=self, state=uiconst.UI_PICKCHILDREN) 69 techExampleButtonsContainer = Container(name='techExampleButtonsContainer', align=uiconst.TOLEFT, parent=self.techExamplesContainer, width=totalWidth, height=totalHeight, padLeft=TECH_EXAMPLE_BUTTON_PAD_LEFT) 70 wrapperHeight = TECH_EXAMPLE_BUTTON_HEIGHT * numButtons + TECH_EXAMPLE_BUTTON_SEPARATION * (numButtons - 1) 71 techExampleButtonsWrapper = Container(name='techExampleButtonsWrapper', align=uiconst.BOTTOMLEFT, parent=techExampleButtonsContainer, width=totalWidth, height=wrapperHeight) 72 numButton = 1 73 for order, techExample in self.technology.GetTechExamples(): 74 self.techExampleButtons[order] = TechExampleButton(parent=techExampleButtonsWrapper, name='techExampleButton%d' % order, align=uiconst.TOTOP, width=totalWidth, height=TECH_EXAMPLE_BUTTON_HEIGHT, state=uiconst.UI_NORMAL, order=order, raceID=self.raceID, techExample=techExample, techExampleSetter=self.SetTechExampleView, iconSize=TECH_EXAMPLE_BUTTON_ICON_SIZE, padIconToText=TECH_EXAMPLE_BUTTON_ICON_TO_TEXT) 75 numButton += 1 76 77 def _ActivateTechExampleButton(self, order): 78 for buttonOrder, button in self.techExampleButtons.iteritems(): 79 if buttonOrder == order: 80 button.SetActive() 81 else: 82 button.SetInactive() 83 84 def SetTechExampleView(self, order): 85 self._ActivateTechExampleButton(order) 86 self.techExampleOrder = order