NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

characterDollSelection.py (6907B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation_new\steps\dollSelection\characterDollSelection.py
      2 import blue
      3 import geo2
      4 import carbonui.const as uiconst
      5 import localization
      6 import trinity
      7 import uthread
      8 from carbon.client.script.environment.AudioUtil import PlaySound
      9 from carbonui.uianimations import animations
     10 from carbonui.uicore import uicore
     11 from charactercreator import const as ccConst
     12 from eve.client.script.ui.login.charcreation_new import soundConst
     13 import eve.client.script.ui.login.charcreation_new.ccUtil as ccUtil
     14 from eve.client.script.ui.login.charcreation_new.charCreation import BaseCharacterCreationStep
     15 from eve.client.script.ui.login.charcreation_new.dollManager import GetCharacterCreationDollManager
     16 from eve.client.script.ui.login.charcreation_new.sceneManager import GetCharacterCreationSceneManager
     17 from eve.client.script.ui.login.charcreation_new.charCreationSignals import onDollSelectionDollHovered, onDollSelectionDollSelected, onDollSelectionRandomizeStarting, onDollSelectionDollRandomized
     18 from eve.client.script.ui.login.charcreation_new.steps.dollSelection import dollSelectionConst
     19 from eve.client.script.ui.login.charcreation_new.steps.dollSelection.dollSelectionConst import DURATION_HOVER
     20 from eve.client.script.ui.login.charcreation_new.steps.dollSelection.dollSelectionContainer import DollSelectionContainer
     21 from eve.client.script.ui.login.charcreation_new.steps.stepHeader import StepHeader
     22 from localization import GetByLabel
     23 
     24 class CharacterDollSelection(BaseCharacterCreationStep):
     25     __guid__ = 'uicls.CharacterDollSelection'
     26     __notifyevents__ = ['OnColorPaletteChanged', 'OnHideUI', 'OnShowUI']
     27     stepID = ccConst.DOLLSTEP
     28 
     29     def ApplyAttributes(self, attributes):
     30         BaseCharacterCreationStep.ApplyAttributes(self, attributes)
     31         onDollSelectionRandomizeStarting.connect(self.OnDollRandomizeStarting)
     32         onDollSelectionDollRandomized.connect(self.OnDollRandomized)
     33         self.characterIDs = attributes.characterIDs
     34         self.selectedCharacterID = None
     35         self.hoveredCharacterID = None
     36         onDollSelectionDollSelected.connect(self.OnDollSelected)
     37         onDollSelectionDollHovered.connect(self.OnDollHovered)
     38         self.header = StepHeader(parent=self, align=uiconst.CENTERTOP, top=60, title=GetByLabel('UI/CharacterCreation/DollSelection/DollSelectionTitle'), subtitle=GetByLabel('UI/CharacterCreation/DollSelection/DollSelectionSubtitle'))
     39         self.loadingThread = None
     40         self._StartLoadingThread()
     41         PlaySound(soundConst.BODY_TYPE_SELECTION_LOOP)
     42 
     43     def _StartLoadingThread(self, charIDsLoading = None):
     44         if not self.loadingThread:
     45             self.loadingThread = uthread.new(self.LoadCharactersThread, charIDsLoading=charIDsLoading)
     46 
     47     def OnDoneLoadingCharacters(self):
     48         self.InitAvatarPositions()
     49         self.ConstructPickContainers()
     50         self.AnimEntryLights()
     51 
     52     def ConstructPickContainers(self):
     53         self.leftSidePickingContainer = DollSelectionContainer(parent=self, charID=self.characterIDs[0], state=uiconst.UI_NORMAL)
     54         self.rightSidePickingContainer = DollSelectionContainer(parent=self, charID=self.characterIDs[1], state=uiconst.UI_NORMAL)
     55 
     56     def OnDollRandomizeStarting(self, charID):
     57         self.leftSidePickingContainer.state = uiconst.UI_PICKCHILDREN
     58         self.rightSidePickingContainer.state = uiconst.UI_PICKCHILDREN
     59 
     60     def OnDollRandomized(self, charID):
     61         self.leftSidePickingContainer.state = uiconst.UI_NORMAL
     62         self.rightSidePickingContainer.state = uiconst.UI_NORMAL
     63 
     64     def OnDollHovered(self, characterID):
     65         self.hoveredCharacterID = characterID
     66         if characterID == self.characterIDs[0]:
     67             leftFalloff = 1.5
     68             rightFalloff = 0.0
     69         elif characterID:
     70             leftFalloff = 0.0
     71             rightFalloff = 1.5
     72         else:
     73             leftFalloff = rightFalloff = 0.0
     74         self.AnimateLightFalloff('LeftSelectionSpotlight', leftFalloff, DURATION_HOVER)
     75         self.AnimateLightFalloff('RightSelectionSpotlight', rightFalloff, DURATION_HOVER)
     76 
     77     def AnimEntryLights(self):
     78         duration = 3.0
     79         timeOffset = 0.2
     80         if ccUtil.IsSlowMachine():
     81             FALLOFF_FRONTMAIN = 4.0
     82         else:
     83             FALLOFF_FRONTMAIN = 0.6
     84         FALLOFF_FRONTAMBIENT = 2.5
     85         self.AnimateLightFalloff('FrontMain', FALLOFF_FRONTMAIN, duration, timeOffset)
     86         self.AnimateLightFalloff('FrontAmbient', FALLOFF_FRONTAMBIENT, duration, timeOffset)
     87 
     88     def AnimateLightFalloff(self, lightName, value, duration, timeOffset = 0.0):
     89         light = self.GetLight(lightName)
     90         if light:
     91             animations.MorphScalar(light, 'falloff', light.falloff, value, duration=duration, timeOffset=timeOffset)
     92 
     93     def GetLight(self, lightName):
     94         return GetCharacterCreationSceneManager().GetLightByName(lightName)
     95 
     96     def OnDollSelected(self, characterID):
     97         self.selectedCharacterID = characterID
     98 
     99     def GetCamera(self):
    100         ccSceneMan = GetCharacterCreationSceneManager()
    101         camera = ccSceneMan.camera
    102         return camera
    103 
    104     def InitAvatarPositions(self):
    105         characterSvc = sm.GetService('character')
    106         leftAvatar = self.GetAvatar(self.characterIDs[0])
    107         leftAvatar.translation = dollSelectionConst.DOLL_POSITION_LEFT
    108         leftAvatar.rotation = geo2.QuaternionRotationSetYawPitchRoll(dollSelectionConst.DOLL_LEFT_YAW, 0.0, 0.0)
    109         characterSvc.UpdateDoll(self.characterIDs[0], fromWhere='InitAvatarPositions', forceUpdate=True)
    110         rightAvatar = self.GetAvatar(self.characterIDs[1])
    111         rightAvatar.translation = dollSelectionConst.DOLL_POSITION_RIGHT
    112         rightAvatar.rotation = geo2.QuaternionRotationSetYawPitchRoll(dollSelectionConst.DOLL_RIGHT_YAW, 0.0, 0.0)
    113         characterSvc.UpdateDoll(self.characterIDs[1], fromWhere='InitAvatarPositions', forceUpdate=True)
    114 
    115     def GetAvatar(self, charID):
    116         characterSvc = sm.GetService('character')
    117         return characterSvc.GetSingleCharactersAvatar(charID)
    118 
    119     def LoadCharactersThread(self, charIDsLoading = None, *args):
    120         if charIDsLoading is None:
    121             charIDsLoading = self.characterIDs
    122         layer = uicore.layer.charactercreation.controller
    123         dolls = (GetCharacterCreationDollManager().GetDoll(charID) for charID in charIDsLoading)
    124         layer.ShowLoading(why=localization.GetByLabel('UI/CharacterCreation/UpdatingCharacter'))
    125         isReady = False
    126         while not self.destroyed and not isReady:
    127             isReady = all((doll.IsReady() for doll in dolls))
    128             blue.pyos.synchro.Yield()
    129 
    130         layer.HideLoading()
    131         self.OnDoneLoadingCharacters()
    132         self.loadingThread = None
    133 
    134     def Close(self):
    135         PlaySound(soundConst.BODY_TYPE_SELECTION_LOOP_STOP)
    136         super(CharacterDollSelection, self).Close()