dollSelectionContainer.py (7261B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation_new\steps\dollSelection\dollSelectionContainer.py 2 import localization 3 import trinity 4 from carbon.client.script.environment.AudioUtil import PlaySound 5 from carbonui import uiconst 6 from carbonui.control.button import Button 7 from carbonui.primitives.boundingboxbracket import BoundingBoxBracket 8 from carbonui.primitives.container import Container 9 from carbonui.primitives.containerAutoSize import ContainerAutoSize 10 from carbonui.primitives.frame import Frame 11 from carbonui.primitives.transform import Transform 12 from carbonui.uianimations import animations 13 from carbonui.uicore import uicore 14 from charactercreator.const import CUSTOMIZATION_BUTTON_ANALYTIC_ID, RANDOMIZATION_BUTTON_ANALYTIC_ID 15 from eve.client.script.ui.login.charcreation_new import charCreationSignals, soundConst 16 from eve.client.script.ui.login.charcreation_new.charCreationSignals import onDollSelectionRandomizeStarting, onDollSelectionDollRandomized, onDollSelectionDollHovered, onDollSelectionDollClicked 17 from eve.client.script.ui.login.charcreation_new.loadingWheel import CharacterCreationLoadingWheel 18 from eve.client.script.ui.login.charcreation_new.sceneManager import GetCharacterCreationSceneManager 19 from eve.client.script.ui.login.charcreation_new.steps.dollSelection.dollSelectionConst import DURATION_HOVER 20 from eveexceptions import ExceptionEater 21 CORNER_FRAME_SCALE_IDLE = (0.95, 0.95) 22 CORNER_FRAME_SCALE_SELECTED = (1.0, 1.0) 23 BUTTON_HEIGHT = 35 24 BUTTON_HEIGHT_PRIMARY = 50 25 BUTTON_FONT_SIZE = 18 26 27 class DollSelectionContainer(BoundingBoxBracket): 28 default_screenMargin = 10.0 29 30 def ApplyAttributes(self, attributes): 31 super(DollSelectionContainer, self).ApplyAttributes(attributes) 32 onDollSelectionRandomizeStarting.connect(self.OnDollRandomizeStarting) 33 onDollSelectionDollRandomized.connect(self.OnDollRandomized) 34 self.charID = attributes.charID 35 self.isSelected = False 36 self.ConstructTrackObject() 37 charCreationSignals.onDollSelectionDollSelected.connect(self.OnDollSelected) 38 self.ConstructLoadingWheel() 39 self.mainCont = Container(name='mainCont', align=uiconst.TOPLEFT_PROP, parent=self, pos=(0.5, 30, 0.85, 0.92), maxWidth=260) 40 self.ConstructButtons() 41 self.ConstructBackground() 42 43 def ConstructButtons(self): 44 self.buttonCont = ContainerAutoSize(name='buttonCont', parent=self.mainCont, align=uiconst.TOBOTTOM, state=uiconst.UI_DISABLED, opacity=0) 45 self.randomizeDollBtn = Button(name='randomizeDollButtonCC', parent=self.buttonCont, align=uiconst.TOTOP, label=localization.GetByLabel('UI/CharacterCreation/DollSelection/ShuffleCharacter'), func=uicore.layer.charactercreation.controller.RandomizeSelectedDoll, hint=localization.GetByLabel('UI/CharacterCreation/DollSelection/ShuffleCharacterTooltip'), analyticID=RANDOMIZATION_BUTTON_ANALYTIC_ID) 46 self.goToCustomizationBtn = Button(name='customizationButtonCC', parent=self.buttonCont, align=uiconst.TOTOP, padTop=15, label=localization.GetByLabel('UI/CharacterCreation/DollSelection/FullCustomization'), func=uicore.layer.charactercreation.controller.GoToCustomization, hint=localization.GetByLabel('UI/CharacterCreation/DollSelection/FullCustomizationTooltip'), analyticID=CUSTOMIZATION_BUTTON_ANALYTIC_ID) 47 self.approveBtn = Button(name='nextButtonCC', parent=self.buttonCont, align=uiconst.TOTOP, padTop=30, label=localization.GetByLabel('UI/Agents/Dialogue/Buttons/Continue'), func=uicore.layer.charactercreation.controller.Approve) 48 49 def ConstructBackground(self): 50 self.cornerFrameTransform = Transform(name='cornerFrameTransform', parent=self, align=uiconst.TOALL, scale=CORNER_FRAME_SCALE_IDLE, scalingCenter=(0.5, 0.5)) 51 self.cornersFrame = Frame(parent=self.cornerFrameTransform, opacity=0, texturePath='res:/UI/Texture/classes/CharacterSelection/EmpireSelection/dollSelectionFrameCorners.png', cornerSize=20) 52 self.frame = Frame(parent=self, opacity=0, texturePath='res:/UI/Texture/classes/CharacterSelection/EmpireSelection/dollSelectionFrame.png', cornerSize=150) 53 54 def ConstructLoadingWheel(self): 55 self.loadingWheel = CharacterCreationLoadingWheel(name='loadingWheel', parent=self, top=-130, align=uiconst.CENTER, state=uiconst.UI_NORMAL) 56 self.loadingWheel.forcedOn = 0 57 self.loadingWheel.Hide() 58 self.loadingWheel.hint = localization.GetByLabel('UI/CharacterCreation/DollSelection/ShuffleCharacterLoadingTooltip') 59 60 def OnDollSelected(self, charID): 61 if charID == self.charID: 62 self.SetSelected() 63 else: 64 self.SetDeselected() 65 66 def OnDollRandomizeStarting(self, charID): 67 self.buttonCont.state = uiconst.UI_DISABLED 68 if charID == self.charID: 69 self.loadingWheel.Show() 70 71 def OnDollRandomized(self, charID): 72 self.buttonCont.state = uiconst.UI_NORMAL if self.isSelected else uiconst.UI_DISABLED 73 if charID == self.charID: 74 self.loadingWheel.Hide() 75 76 def SetSelected(self): 77 if self.isSelected: 78 return 79 self.isSelected = True 80 duration = 0.2 81 animations.Tr2DScaleTo(self.cornerFrameTransform, CORNER_FRAME_SCALE_IDLE, CORNER_FRAME_SCALE_SELECTED, duration=duration) 82 animations.FadeIn(self.frame, duration=duration, timeOffset=0.3) 83 animations.FadeIn(self.buttonCont, duration=duration, timeOffset=0.6) 84 self.buttonCont.Enable() 85 86 def SetDeselected(self): 87 self.isSelected = False 88 duration = 0.2 89 animations.FadeOut(self.buttonCont, duration=duration) 90 animations.FadeOut(self.frame, duration=duration) 91 animations.Tr2DScaleTo(self.cornerFrameTransform, CORNER_FRAME_SCALE_SELECTED, CORNER_FRAME_SCALE_IDLE, duration=duration) 92 self.buttonCont.Disable() 93 94 def ConstructTrackObject(self): 95 sceneMan = GetCharacterCreationSceneManager() 96 doll = sceneMan.GetDoll(self.charID) 97 trackObject = trinity.Load('res:/graphics/interior/charactercreation/plane/plane.red') 98 trinity.WaitForResourceLoads() 99 trackObject.translation = doll.translation 100 trackObject.rotation = (0, 0, 0) 101 trackObject.scaling = (1, 1, 1) 102 trackObject.display = False 103 trackObject.BoundingBoxOverride((-0.4, -0.1, -0.1), (0.4, 1.95, 0.1)) 104 sceneMan.scene.dynamics.append(trackObject) 105 self.trackObject = trackObject 106 107 def Close(self): 108 sceneMan = GetCharacterCreationSceneManager() 109 with ExceptionEater('characterCreation'): 110 sceneMan.scene.dynamics.fremove(self.trackObject) 111 self.trackObject = None 112 super(DollSelectionContainer, self).Close() 113 114 def OnMouseEnter(self, *args): 115 PlaySound(uiconst.SOUND_BUTTON_HOVER) 116 onDollSelectionDollHovered(self.charID) 117 animations.FadeIn(self.cornersFrame, endVal=1.0, duration=DURATION_HOVER) 118 119 def OnMouseExit(self, *args): 120 onDollSelectionDollHovered(None) 121 animations.FadeOut(self.cornersFrame, duration=DURATION_HOVER) 122 123 def OnClick(self, *args): 124 PlaySound(soundConst.SELECT_BODY) 125 onDollSelectionDollClicked(self.charID)