charCreationBodyPicker.py (3964B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation_new\charCreationBodyPicker.py 2 import carbonui.const as uiconst 3 import localization 4 from carbon.common.script.util import timerstuff 5 from carbonui.primitives.container import Container 6 from carbonui.primitives.sprite import Sprite 7 from carbonui.uianimations import animations 8 from eve.client.script.ui.login.charcreation_new.hexes import CCHexButtonHead, CCHexButtonBody 9 from eve.client.script.ui.login.charcreation_new.charCreation import GHOST_TEXTURE_PATH 10 from eve.client.script.ui.login.charcreation_new.sceneManager import GetCharacterCreationSceneManager 11 12 class CCHeadBodyPicker(Container): 13 __guid__ = 'uicls.CCHeadBodyPicker' 14 default_name = 'CCHeadBodyPicker' 15 default_opacity = 0 16 default_width = 130 17 default_height = 130 18 19 def ApplyAttributes(self, attributes): 20 super(CCHeadBodyPicker, self).ApplyAttributes(attributes) 21 self.headCallback = attributes.headCallback 22 self.bodyCallback = attributes.bodyCallback 23 self.ConstructLayout() 24 self.updateTimer = timerstuff.AutoTimer(33, self.UpdatePosition) 25 animations.FadeIn(self, duration=0.25) 26 27 def ConstructLayout(self, *args): 28 self.headHex = CCHexButtonHead(name='headHex', parent=self, align=uiconst.CENTERTOP, state=uiconst.UI_NORMAL, pos=(0, 0, 64, 64), pickRadius=21, info=None, id=0, hexName=localization.GetByLabel('UI/CharacterCreation/ZoomIn'), func=self.HeadClicked, iconNum=0, showIcon=False) 29 self.headSolid = self.headHex.selection 30 self.headSolid.SetState(uiconst.UI_DISABLED) 31 self.headFrame = self.headHex.frame 32 self.bodyHex = CCHexButtonBody(name='bodyHex', parent=self, align=uiconst.CENTERTOP, state=uiconst.UI_NORMAL, pos=(0, 16, 128, 128), pickRadius=42, info=None, id=0, hexName=localization.GetByLabel('UI/CharacterCreation/ZoomOut'), func=self.BodyClicked, iconNum=0, showIcon=False) 33 self.bodySolid = self.bodyHex.selection 34 self.bodySolid.SetState(uiconst.UI_DISABLED) 35 self.bodyFrame = self.bodyHex.frame 36 sprite = Sprite(name='ghostSprite', parent=self, align=uiconst.CENTERTOP, state=uiconst.UI_DISABLED, pos=(0, 7, 128, 128), idx=0, texturePath=GHOST_TEXTURE_PATH) 37 sprite.SetRect(0, 0, 0, 0) 38 39 def UpdatePosition(self, *args): 40 if self.destroyed: 41 return 42 camera = GetCharacterCreationSceneManager().camera 43 if camera is not None: 44 portion = camera.GetPortionFromDistance() 45 self.headSolid.SetOpacity(max(0.2, 1.0 - portion)) 46 self.bodySolid.SetOpacity(max(0.2, portion)) 47 for hex in (self.headHex, self.bodyHex): 48 if hex.selection.opacity >= 0.5 and len(self.children) and hex == self.children[-1]: 49 toSwap = self.children[-2] 50 self.children.remove(toSwap) 51 self.children.append(toSwap) 52 break 53 54 def MouseOverPart(self, frameName, *args): 55 sm.StartService('audio').SendUIEvent(unicode('ui_icc_button_mouse_over_play')) 56 frame = self.get(frameName, None) 57 if frame: 58 frame.state = uiconst.UI_DISABLED 59 60 def MouseExitPart(self, frameName, *args): 61 frame = self.get(frameName, None) 62 if frame: 63 frame.state = uiconst.UI_HIDDEN 64 65 def HeadClicked(self, *args): 66 sm.StartService('audio').SendUIEvent(unicode('ui_icc_button_mouse_down_play')) 67 self.headFrame.state = uiconst.UI_HIDDEN 68 self.bodyFrame.state = uiconst.UI_HIDDEN 69 if self.headCallback: 70 self.headCallback() 71 72 def BodyClicked(self, *args): 73 sm.StartService('audio').SendUIEvent(unicode('ui_icc_button_mouse_down_play')) 74 self.headFrame.state = uiconst.UI_HIDDEN 75 self.bodyFrame.state = uiconst.UI_HIDDEN 76 if self.bodyCallback: 77 self.bodyCallback()