sidePanelFactionAndSchool.py (5799B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation_new\steps\empireSelection\sidePanelFactionAndSchool.py 2 import uthread 3 from carbonui import uiconst 4 from carbonui.primitives.containerAutoSize import ContainerAutoSize 5 from carbonui.primitives.gradientSprite import GradientSprite 6 from carbonui.uianimations import animations 7 from characterdata import factions, schools 8 from eve.client.script.ui.const.eveIconConst import RACE_ICONS 9 from eve.client.script.ui.control.eveLabel import EveCaptionLarge, EveLabelLarge, EveCaptionSmall 10 from eve.client.script.ui.login.charcreation_new import charCreationSignals 11 from eve.client.script.ui.login.charcreation_new.baseSidePanel import BaseSidePanel 12 from eve.client.script.ui.login.charcreation_new.steps.empireSelection import empireSelectionConst 13 from eve.client.script.ui.login.charcreation_new.steps.empireSelection.empireSelectionConst import FACTIONSELECT_ANIMATION_DURATION 14 from eve.common.lib import appConst 15 from eveui import Sprite 16 LEFT = 30 17 18 class SidePanelFactionAndSchool(ContainerAutoSize): 19 default_name = 'SidePanelFactionAndSchool' 20 21 def ApplyAttributes(self, attributes): 22 super(SidePanelFactionAndSchool, self).ApplyAttributes(attributes) 23 factionID = attributes.factionID 24 schoolID = attributes.schoolID 25 self.factionPanel = SidePanelFaction(parent=self, align=uiconst.TOTOP, factionID=factionID) 26 self.schoolPanel = SidePanelSchool(parent=self, align=uiconst.TOTOP, padTop=10, schoolID=schoolID, factionID=factionID) 27 28 def HideSchoolPanel(self): 29 self.schoolPanel.Hide() 30 31 def ShowSchoolPanel(self): 32 self.schoolPanel.Show() 33 34 35 class SidePanelFaction(BaseSidePanel): 36 default_height = 270 37 default_opacity = 0.0 38 39 def ApplyAttributes(self, attributes): 40 super(SidePanelFaction, self).ApplyAttributes(attributes) 41 factionID = attributes.factionID 42 charCreationSignals.onEmpireFactionSelected.connect(self.OnEmpireFactionSelected) 43 self.factionIcon = Sprite(name='factionIcon', parent=self.mainCont, align=uiconst.CENTERTOP, pos=(0, 25, 100, 100)) 44 self.factionNameLabel = EveCaptionLarge(name='factionNameLabel', parent=self.mainCont, align=uiconst.TOPLEFT, pos=(LEFT, 45 115, 46 0, 47 0)) 48 self.descriptionLabel = EveLabelLarge(name='descriptionLabel', parent=self.mainCont, align=uiconst.TOPLEFT, pos=(LEFT, 49 170, 50 375, 51 0)) 52 if factionID: 53 self._UpdateFaction(factionID) 54 self.opacity = 1.0 55 56 def OnEmpireFactionSelected(self, factionID): 57 uthread.new(self._OnEmpireFactionSelected, factionID) 58 59 def _OnEmpireFactionSelected(self, factionID): 60 duration = FACTIONSELECT_ANIMATION_DURATION / 2 61 animations.FadeTo(self, self.opacity, 0.0, duration=duration, sleep=True) 62 self._UpdateFaction(factionID) 63 animations.FadeIn(self, duration=duration, timeOffset=duration * 1.5) 64 65 def _UpdateFaction(self, factionID): 66 self.factionIcon.texturePath = RACE_ICONS[appConst.raceByFaction[factionID]] 67 color = empireSelectionConst.COLOR_BY_FACTIONID[factionID] 68 self.factionNameLabel.text = factions.get_faction_name(factionID) 69 self.factionNameLabel.SetRGBA(*color) 70 self.descriptionLabel.text = factions.get_faction_short_description(factionID) 71 72 73 class SidePanelSchool(BaseSidePanel): 74 default_height = 210 75 default_opacity = 0.0 76 77 def ApplyAttributes(self, attributes): 78 super(SidePanelSchool, self).ApplyAttributes(attributes) 79 schoolID = attributes.schoolID 80 self.factionID = attributes.factionID 81 self.schoolID = None 82 charCreationSignals.onEmpireSchoolSelected.connect(self.OnSchoolSelected) 83 charCreationSignals.onEmpireFactionSelected.connect(self.OnEmpireFactionSelected) 84 self.icon = Sprite(name='icon', parent=self.mainCont, align=uiconst.CENTERLEFT, pos=(LEFT, 85 0, 86 64, 87 64)) 88 Sprite(name='iconBG', parent=self.mainCont, align=uiconst.CENTERLEFT, pos=(LEFT - 4, 89 0, 90 72, 91 64), texturePath='res:/UI/Texture/Classes/CharacterSelection/EmpireSelection/iconBG.png') 92 textCont = ContainerAutoSize(name='textCont', parent=self.mainCont, align=uiconst.CENTERLEFT, pos=(115, 0, 290, 0)) 93 self.schoolTitleLabel = EveCaptionSmall(name='schoolTitleLabel', parent=textCont, align=uiconst.TOTOP) 94 self.schoolNameLabel = EveCaptionLarge(name='schoolNameLabel', parent=textCont, align=uiconst.TOTOP, padTop=2) 95 self.descriptionLabel = EveLabelLarge(name='descriptionLabel', parent=textCont, align=uiconst.TOTOP, padTop=8) 96 if schoolID: 97 self._UpdateSchool(schoolID) 98 self.opacity = 1.0 99 100 def OnSchoolSelected(self, schoolID): 101 uthread.new(self._OnSchoolSelected, schoolID) 102 103 def OnEmpireFactionSelected(self, factionID): 104 self.factionID = factionID 105 106 def _OnSchoolSelected(self, schoolID): 107 duration = 0.3 108 if self.schoolID: 109 animations.FadeTo(self, self.opacity, 0.0, duration=duration, sleep=True) 110 self.schoolID = schoolID 111 if schoolID: 112 self._UpdateSchool(schoolID) 113 animations.FadeIn(self, duration=duration) 114 115 def _UpdateSchool(self, schoolID): 116 self.icon.texturePath = empireSelectionConst.ICONS_BY_SCHOOLID[schoolID] 117 self.schoolTitleLabel.text = schools.get_school_title(schoolID) 118 self.schoolNameLabel.text = schools.get_school_name(schoolID) 119 color = empireSelectionConst.COLOR_BY_FACTIONID[self.factionID] 120 self.schoolNameLabel.SetRGBA(*color) 121 self.descriptionLabel.text = schools.get_school_description(schoolID)