characterNaming.py (10038B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation\steps\characterNaming.py 2 import blue 3 from carbonui import const as uiconst, fontconst 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.containerAutoSize import ContainerAutoSize 6 from carbonui.primitives.fill import Fill 7 from carbonui.primitives.frame import Frame 8 from carbonui.uicore import uicore 9 from carbonui.uianimations import animations 10 from charactercreator import const as ccConst 11 from charactercreator.client.feature_flags import is_starting_in_starter_space_enabled 12 from characterdata.schools import get_school_ids_by_race_id 13 from characterdata.schools import get_school 14 from characterdata.schools import get_school_description 15 from characterdata.schools import get_school_name 16 from characterdata.schools import get_school_title 17 from eve.client.script.ui import eveColor 18 from eve.client.script.ui.control.eveIcon import Icon 19 from eve.client.script.ui.login.charcreation import ccUtil 20 from eve.client.script.ui.login.charcreation.charCreation import BaseCharacterCreationStep 21 from eve.client.script.ui.login.charcreation.hexes import CCHexButtonSchool 22 from eve.client.script.ui.login.charcreation.label import CCLabel 23 from eve.client.script.ui.login.charcreation.steps.sections.chooseNameSection import ChooseNameSection 24 from eve.common.lib import appConst as const 25 import localization 26 import random 27 from localization.util import AmOnChineseServer 28 padding = 16 29 topRightPushContainerMaxHeight = 130 30 topRightPushContainerMinHeight = 16 31 32 class CharacterNaming(BaseCharacterCreationStep): 33 __notifyevents__ = ['OnHideUI', 'OnShowUI'] 34 stepID = ccConst.NAMINGSTEP 35 36 def ApplyAttributes(self, attributes): 37 BaseCharacterCreationStep.ApplyAttributes(self, attributes) 38 self.schoolInfo = {} 39 self.schoolConts = {} 40 self.educationCont = None 41 self.startEducationHeight = 180 42 self.topRightPushContainer = Container(name='topRightPushContainer', parent=self.rightSide, height=topRightPushContainerMaxHeight, align=uiconst.TOTOP) 43 self.rightSideContentContainer = ContainerAutoSize(name='rightSideContentContainer', parent=self.rightSide, align=uiconst.TOTOP) 44 self.rightSideAlignContainer = ContainerAutoSize(name='rightSideAlignContainer', parent=self.rightSideContentContainer, align=uiconst.TOPRIGHT, width=410, top=0, left=10) 45 self.SetupEducationSection() 46 self.SetupNameSection() 47 if is_starting_in_starter_space_enabled and self.educationCont: 48 self.educationCont.Hide() 49 contentContainer = ContainerAutoSize(name='contentContainer', parent=self.leftSide, align=uiconst.TOPLEFT, top=130, width=128, left=25) 50 self.portraitCont = Container(name='portraitCont', parent=contentContainer, align=uiconst.TOTOP, height=128) 51 Frame(parent=self.portraitCont, color=ccConst.COLOR + (0.3,)) 52 self.facePortrait = Icon(parent=self.portraitCont, idx=1, align=uiconst.CENTER, pos=(0, 0, 128, 128)) 53 self.UpdatePortraitPhoto() 54 self.UpdateLayout() 55 56 def UpdatePortraitPhoto(self): 57 photo = uicore.layer.charactercreation.controller.GetActivePortrait() 58 if photo is not None: 59 self.facePortrait.texture.atlasTexture = photo 60 self.facePortrait.texture.atlasTexture.Reload() 61 62 def SetupNameSection(self): 63 contHeight = 120 if AmOnChineseServer() else 160 64 self.nameCont = ChooseNameSection(name='nameSelectionContainer', parent=self.rightSideAlignContainer, align=uiconst.TOTOP, height=contHeight, padding=(0, 65 padding, 66 0, 67 0), state=uiconst.UI_PICKCHILDREN) 68 69 def UpdateLayout(self): 70 info = self.GetInfo() 71 self.AdjustHeightAndWidth(doMorph=0) 72 try: 73 self.SetSchoolFromID(info.schoolID, doMorph=0) 74 except Exception: 75 if self and not self.destroyed: 76 raise 77 78 def SetupEducationSection(self, *args): 79 info = self.GetInfo() 80 if self.educationCont: 81 self.educationCont.Close() 82 self.educationCont = Container(name='educationCont', parent=self.rightSideAlignContainer, align=uiconst.TOTOP, height=self.startEducationHeight, padding=(0, 83 padding, 84 padding, 85 0)) 86 sub = Container(name='sub', parent=self.educationCont, align=uiconst.TOALL, state=uiconst.UI_PICKCHILDREN, padding=(padding, 87 padding, 88 padding, 89 padding)) 90 topCont = Container(name='topCont', parent=sub, align=uiconst.TOTOP, state=uiconst.UI_PICKCHILDREN, pos=(0, 20, 0, 64)) 91 text = CCLabel(state=uiconst.UI_NORMAL, parent=sub, text=localization.GetByLabel('UI/CharacterCreation/EducationSelection'), fontsize=20, align=uiconst.TOPLEFT, letterspace=1, idx=1, pos=(0, -6, 0, 0), uppercase=1, color=eveColor.PRIMARY_BLUE) 92 text.hint = localization.GetByLabel('UI/CharacterCreation/HelpTexts/chooseEducationHint') 93 self.schoolTextCont = textCont = Container(name='textCont', parent=sub, align=uiconst.TOALL, state=uiconst.UI_PICKCHILDREN) 94 self.schoolNameText = CCLabel(parent=textCont, text='', fontsize=14, align=uiconst.TOPLEFT, letterspace=1, idx=1, pos=(0, 0, 0, 0), color=ccConst.COLOR50) 95 self.schoolTitleText = CCLabel(parent=textCont, text='', fontsize=12, align=uiconst.TOPLEFT, letterspace=1, idx=1, padTop=20, color=ccConst.COLOR50) 96 self.schoolDescrText = CCLabel(parent=textCont, text='', fontsize=fontconst.EVE_SMALL_FONTSIZE, align=uiconst.TOTOP, letterspace=0, idx=1, padTop=40, shadowOffset=(0, 0), bold=0, color=ccConst.COLOR50) 97 Frame(name='hiliteFrame', parent=self.educationCont, frameConst=ccConst.MAINFRAME_INV) 98 Fill(name='fill', parent=self.educationCont, color=(0.0, 0.0, 0.0, 0.5)) 99 if not self.schoolInfo: 100 schoolIds = get_school_ids_by_race_id(info.raceID) 101 for id in schoolIds: 102 info = get_school(id) 103 self.schoolInfo[id] = info 104 105 left = 0 106 offsetByRace = {const.raceCaldari: 17, 107 const.raceMinmatar: 14, 108 const.raceAmarr: 11, 109 const.raceGallente: 20} 110 iconNumOffset = offsetByRace.get(info.raceID) 111 for schoolID, info in self.schoolInfo.iteritems(): 112 c = Container(name='c', parent=topCont, align=uiconst.TOPLEFT, state=uiconst.UI_PICKCHILDREN, pos=(left, 113 0, 114 115, 115 64)) 116 hexName = get_school_name(schoolID) 117 isSchoolDisabled = ccUtil.IsSchoolDisabled(schoolID) 118 hex = CCHexButtonSchool(name='schoolHex', parent=c, align=uiconst.CENTERTOP, state=uiconst.UI_NORMAL, pos=(0, 0, 64, 64), pickRadius=32, info=info, id=schoolID, hexName=hexName, func=self.SetSchool, iconNum=schoolID - iconNumOffset) 119 if isSchoolDisabled: 120 hex.SetHint(localization.GetByLabel('UI/CharacterCreation/DisabledSchool')) 121 hex.clickable = False 122 left += 125 123 self.schoolConts[schoolID] = hex 124 125 def SetSchoolFromID(self, schoolID, doMorph = 1, *args): 126 selected = self.schoolConts.get(schoolID, None) 127 self.SetSchool(selected, doMorph=doMorph) 128 129 def SetSchool(self, selected = None, doMorph = 1, *args): 130 if selected is None: 131 allowedSchools = [ hex for schoolID, hex in self.schoolConts.iteritems() if not ccUtil.IsSchoolDisabled(schoolID) ] 132 selected = random.choice(allowedSchools) 133 uicore.layer.charactercreation.controller.SelectSchool(selected.id) 134 selected.SelectHex(self.schoolConts.values()) 135 self.schoolNameText.text = get_school_title(selected.id) 136 self.schoolTitleText.text = selected.hexName 137 self.schoolDescrText.text = get_school_description(selected.id) 138 selected.frame.state = uiconst.UI_DISABLED 139 self.AdjustHeightAndWidth(doMorph=doMorph) 140 uicore.layer.charactercreation.controller.metrics.pick_school(selected.id) 141 142 def CheckAvailability(self, *args): 143 return self.nameCont.CheckAvailability() 144 145 def AdjustHeightAndWidth(self, doMorph = 1, *args): 146 if not self.educationCont: 147 return 148 schoolTextContHeight = self.educationCont.height - 105 149 textHeight = self.schoolDescrText.textheight + self.schoolDescrText.padTop 150 missingSchoolHeight = textHeight - schoolTextContHeight 151 totalMissing = max(missingSchoolHeight, 0) 152 if totalMissing > 0: 153 for missingHeight, cont in [(missingSchoolHeight, self.educationCont)]: 154 if missingHeight < -10: 155 cont.height -= 5 156 blue.synchro.Yield() 157 if self and not self.destroyed: 158 self.AdjustHeightAndWidth(doMorph=doMorph) 159 return 160 161 availableHeight = uicore.desktop.height - self.educationCont.height - self.nameCont.height - 4 * padding 162 if availableHeight >= totalMissing: 163 if missingSchoolHeight > 0: 164 self.educationCont.height += missingSchoolHeight + 2 165 elif self.rightSide.width < uicore.desktop.width * 0.6: 166 if doMorph: 167 animations.MorphScalar(self.rightSide, 'width', endVal=self.rightSide.width + 50, duration=0.025, sleep=True) 168 else: 169 self.rightSide.width += 50 170 blue.synchro.Yield() 171 self.AdjustHeightAndWidth(doMorph=doMorph) 172 excessHeight = ccConst.BUTTON_AREA_HEIGHT + self.educationCont.height + self.nameCont.height + 4 * padding + topRightPushContainerMaxHeight - uicore.desktop.height 173 if excessHeight > 0: 174 adjust = min(excessHeight, topRightPushContainerMaxHeight) 175 self.topRightPushContainer.height = max(topRightPushContainerMinHeight, topRightPushContainerMaxHeight - adjust) 176 else: 177 self.topRightPushContainer.height = topRightPushContainerMaxHeight