transitions.py (14040B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\view\transitions.py 2 from carbonui.primitives.container import Container 3 from carbonui.util.color import Color 4 from eve.client.script.ui.camera.cameraUtil import GetBallWaitForModel, IsDynamicCameraMovementEnabled 5 from eve.client.script.ui.control import eveLabel 6 from eve.client.script.ui.services.viewStateSvc import Transition 7 from eve.client.script.ui.shared.dockedUI.lobbyWnd import LobbyWnd 8 from eve.client.script.ui.view.viewStateConst import ViewState 9 from eve.common.lib import appConst as const 10 import evecamera 11 import carbonui.const as uiconst 12 import blue 13 import localization 14 import log 15 import uthread 16 from carbonui.uicore import uicore 17 18 class FadeToBlackTransition(Transition): 19 __guid__ = 'viewstate.FadeToBlackTransition' 20 21 def __init__(self, fadeTimeMS = 1000, fadeInTimeMS = None, fadeOutTimeMS = None, **kwargs): 22 Transition.__init__(self, **kwargs) 23 self.fadeInTimeMS = fadeInTimeMS or fadeTimeMS 24 self.fadeOutTimeMS = fadeOutTimeMS or fadeTimeMS 25 26 def StartTransition(self, fromView, toView): 27 Transition.StartTransition(self, fromView, toView) 28 sm.GetService('loading').FadeIn(self.fadeInTimeMS) 29 30 def EndTransition(self, fromView, toView): 31 Transition.EndTransition(self, fromView, toView) 32 sm.GetService('loading').FadeOut(self.fadeOutTimeMS, opacityStart=1.0, color=Color.BLACK) 33 34 35 class EmptyTransition(Transition): 36 __guid__ = 'viewstate.EmptyTransition' 37 38 39 class FadeToBlackLiteTransition(Transition): 40 __guid__ = 'viewstate.FadeToBlackLiteTransition' 41 42 def __init__(self, fadeTimeMS = 1000, fadeInTimeMS = None, fadeOutTimeMS = None, **kwargs): 43 Transition.__init__(self, **kwargs) 44 self.fadeInTimeMS = fadeInTimeMS or fadeTimeMS 45 self.fadeOutTimeMS = fadeOutTimeMS or fadeTimeMS 46 self.fadeLayer = None 47 48 def StartTransition(self, fromView, toView): 49 Transition.StartTransition(self, fromView, toView) 50 viewState = sm.GetService('viewState') 51 fadeTimeInSeconds = self.fadeInTimeMS / 1000.0 52 sm.GetService('sceneManager').FadeIn(duration=fadeTimeInSeconds) 53 self.fadeLayer = Container(name='transition_overlay', parent=viewState.overlayLayerParent, pickState=uiconst.TR2_SPS_OFF, bgColor=Color.BLACK, opacity=0.0) 54 uicore.animations.FadeIn(self.fadeLayer, duration=fadeTimeInSeconds, sleep=True) 55 56 def EndTransition(self, fromView, toView): 57 fadeTimeInSeconds = self.fadeInTimeMS / 1000.0 58 uicore.animations.FadeOut(self.fadeLayer, duration=fadeTimeInSeconds) 59 sm.GetService('sceneManager').FadeOut(duration=fadeTimeInSeconds, sleep=True) 60 self.fadeLayer.Close() 61 del self.fadeLayer 62 Transition.EndTransition(self, fromView, toView) 63 64 65 class DeathTransition(Transition): 66 __guid__ = 'viewstate.DeathTransition' 67 DELAYED_NOTIFICATIONS = (const.notificationTypeCloneActivationMsg, const.notificationTypeCloneActivationMsg2) 68 69 def __init__(self, **kwargs): 70 Transition.__init__(self, **kwargs) 71 self.keyDownCookie = None 72 self.maxWaitSeconds = 10 73 self.minWaitSeconds = 2 74 self.notifyContainer = None 75 self.startTime = None 76 77 def StartTransition(self, fromView, toView): 78 Transition.StartTransition(self, fromView, toView) 79 duration = max(blue.os.desiredSimDilation, 0.1) * 0.3 80 self.AnimateUIOut(duration=duration) 81 sm.GetService('audio').SendUIEvent('transition_pod_dead_play') 82 self.StartDeathScene() 83 sm.GetService('loading').FadeOut(2500) 84 self.WaitForMouseUp() 85 sm.GetService('loading').FadeIn(500) 86 87 def EndTransition(self, fromView, toView): 88 sm.GetService('audio').SendUIEvent('npe_pod_reanimate') 89 self.notifyContainer.Close() 90 sm.GetService('loading').FadeOut(500) 91 duration = max(blue.os.desiredSimDilation, 0.3) * 2 92 self.AnimateUIIn(duration=duration) 93 Transition.EndTransition(self, fromView, toView) 94 for notificationTypeID in self.DELAYED_NOTIFICATIONS: 95 sm.GetService('notificationSvc').ProcessDelayedNotifications(notificationTypeID) 96 97 sm.ScatterEvent('OnDeathTransitionEnded') 98 99 def StartDeathScene(self): 100 log.LogNotice('DeathTransition:: Starting death scene %s') 101 sceneManager = sm.GetService('sceneManager') 102 deathHandler = sm.GetService('gameui').playerDeathHandler 103 deathScene = getattr(deathHandler, 'podDeathScene', None) 104 if deathScene: 105 try: 106 deathHandler.podDeathScene = None 107 sceneManager.SetPrimaryCamera(evecamera.CAM_DEATHSCENE) 108 corpse = deathHandler.GetCorpseModel() 109 if corpse is not None: 110 corpse.name = 'myCorpse' 111 deathScene.objects.insert(0, corpse) 112 else: 113 log.LogWarn('Failed to load corpse model for character %s' % session.charid, channel='svc.viewState') 114 pod = deathHandler.GetCapsuleModel() 115 deathScene.objects.append(pod) 116 sceneManager.SetActiveScene(deathScene) 117 except Exception as e: 118 log.LogTraceback('Failed at loading podDeathScene: %s' % repr(e), channel='svc.viewState') 119 120 else: 121 log.LogTraceback('Unable to load podDeathScene', channel='svc.viewState') 122 self.notifyContainer = Container(name='notifyContainer', parent=uicore.desktop, state=uiconst.UI_DISABLED, align=uiconst.BOTTOMLEFT, pos=(20, 0, 500, 100)) 123 uthread.new(self.WriteCloneActivationText_thread) 124 125 def WriteCloneActivationText_thread(self, *args): 126 blue.synchro.SleepSim(1000) 127 redColor = (0.9, 0.1, 0.1) 128 cloneText = localization.GetByLabel('UI/Inflight/ActivatingClone') 129 currentLocation = session.stationid or session.structureid 130 if currentLocation: 131 locationName = cfg.evelocations.Get(currentLocation).name 132 else: 133 locationName = '' 134 cloneSubText = localization.GetByLabel('UI/Inflight/ActivatingCloneSubText', locationName=locationName) 135 cloneSubTextLabel = eveLabel.EveLabelLarge(parent=self.notifyContainer, name='cloneSubTextLabel', text=cloneSubText, align=uiconst.TOPLEFT, bold=True) 136 cloneText = localization.GetByLabel('UI/Inflight/ActivatingClone') 137 cloneActivatingLabel = eveLabel.EveCaptionLarge(parent=self.notifyContainer, name='cloneActivatingLabel', text='', align=uiconst.TOPLEFT, top=cloneSubTextLabel.top + cloneSubTextLabel.textheight, bold=True) 138 uicore.animations.BlinkIn(cloneActivatingLabel, startVal=0.0, endVal=1.0, duration=1.0, loops=uiconst.ANIM_REPEAT, curveType=uiconst.ANIM_WAVE) 139 cloneSubTextLabel.text = '' 140 for char in cloneSubText: 141 cloneSubTextLabel.text += char 142 sm.GetService('audio').SendUIEvent('ui_text_singlechar_play') 143 blue.synchro.SleepSim(20) 144 145 for char in cloneText: 146 cloneActivatingLabel.text += char 147 sm.GetService('audio').SendUIEvent('ui_text_singlechar_play') 148 blue.synchro.SleepSim(20) 149 150 def WaitForMouseUp(self): 151 now = blue.os.GetWallclockTime() 152 self.startTime = now 153 self.endWaitTime = now + self.maxWaitSeconds * const.SEC 154 self.breakFromLoop = False 155 self.mouseDownCookie = uicore.event.RegisterForTriuiEvents(uiconst.UI_MOUSEUP, self.ClearBlock) 156 while not self.breakFromLoop and blue.os.GetWallclockTime() < self.endWaitTime: 157 blue.synchro.Yield() 158 159 uicore.event.UnregisterForTriuiEvents(self.mouseDownCookie) 160 self.mouseDownCookie = None 161 self.endWaitTime = None 162 self.startTime = None 163 self.breakFromLoop = False 164 165 def ClearBlock(self, *args): 166 now = blue.os.GetWallclockTime() 167 if now < self.startTime + self.minWaitSeconds * const.SEC: 168 return 1 169 self.breakFromLoop = True 170 return 1 171 172 173 class SpaceToStationTransition(Transition): 174 __guid__ = 'viewstate.SpaceToStationTransition' 175 176 def __init__(self, **kwargs): 177 Transition.__init__(self, **kwargs) 178 self.hangarDock = ToHangarTransition() 179 self.cloning = DeathTransition() 180 181 def StartTransition(self, fromView, toView): 182 Transition.StartTransition(self, fromView, toView) 183 if self.transitionReason == 'clone': 184 self.cloning.StartTransition(fromView, toView) 185 else: 186 self.hangarDock.StartTransition(fromView, toView) 187 188 def EndTransition(self, fromView, toView): 189 if self.transitionReason == 'clone': 190 self.cloning.EndTransition(fromView, toView) 191 else: 192 self.hangarDock.EndTransition(fromView, toView) 193 Transition.EndTransition(self, fromView, toView) 194 195 196 class SpaceToStructureTransition(Transition): 197 __guid__ = 'viewstate.SpaceToStructureTransition' 198 199 def __init__(self, **kwargs): 200 Transition.__init__(self, **kwargs) 201 self.dock = self.GetDockTransition() 202 self.cloning = DeathTransition() 203 204 def GetDockTransition(self): 205 return Transition() 206 207 def StartTransition(self, fromView, toView): 208 Transition.StartTransition(self, fromView, toView) 209 if self.transitionReason == 'clone': 210 self.cloning.StartTransition(fromView, toView) 211 else: 212 self.dock.StartTransition(fromView, toView) 213 sm.ScatterEvent('OnDockingTransitionStart') 214 215 def EndTransition(self, fromView, toView): 216 if self.transitionReason == 'clone': 217 self.cloning.EndTransition(fromView, toView) 218 else: 219 self.dock.EndTransition(fromView, toView) 220 sm.ScatterEvent('OnDockingTransitionEnd') 221 Transition.EndTransition(self, fromView, toView) 222 223 224 class StationToSpaceTransition(FadeToBlackTransition): 225 226 def EndTransition(self, fromView, toView): 227 GetBallWaitForModel(session.shipid) 228 blue.synchro.SleepWallclock(10) 229 FadeToBlackTransition.EndTransition(self, fromView, toView) 230 231 def GetCameraID(self): 232 currCamID = sm.GetService('viewState').GetView(ViewState.Space).GetRegisteredCameraID() 233 if IsDynamicCameraMovementEnabled() and currCamID == evecamera.CAM_SHIPORBIT: 234 return evecamera.CAM_UNDOCK 235 236 237 class CharSelectCreateToSpaceTransition(Transition): 238 239 def __init__(self, fadeTimeMS = 1000, fadeInTimeMS = 250, fadeOutTimeMS = 2000, **kwargs): 240 Transition.__init__(self, **kwargs) 241 self.fadeInTimeMS = fadeInTimeMS or fadeTimeMS 242 self.fadeOutTimeMS = fadeOutTimeMS or fadeTimeMS 243 244 def StartTransition(self, fromView, toView): 245 Transition.StartTransition(self, fromView, toView) 246 sm.GetService('audio').SendUIEvent('cinematic_ship_intro_state_off') 247 if self._ShouldFadeLoadingLayer(): 248 sm.GetService('loading').FadeIn(self.fadeInTimeMS) 249 sm.GetService('gameui').ResetResourceLoadingIndicatorPosition() 250 251 def EndTransition(self, fromView, toView): 252 Transition.EndTransition(self, fromView, toView) 253 uthread.new(self._EndTransition) 254 255 def _EndTransition(self): 256 sm.ScatterEvent('OnCurrSessionSpaceEnteredFirstTime') 257 GetBallWaitForModel(session.shipid) 258 if self._ShouldFadeLoadingLayer(): 259 sm.GetService('loading').FadeOut(self.fadeOutTimeMS, opacityStart=1.0) 260 261 def _ShouldFadeLoadingLayer(self): 262 return not sm.GetService('cc').IsIntroPlaying() 263 264 def GetCameraID(self): 265 cameraID = sm.GetService('viewState').GetView(ViewState.Space).GetRegisteredCameraID() 266 if IsDynamicCameraMovementEnabled(): 267 if cameraID in (evecamera.CAM_SHIPORBIT, evecamera.CAM_SHIPORBIT_ABYSSAL_SPACE, evecamera.CAM_SHIPORBIT_HAZARD): 268 return evecamera.CAM_ENTERSPACE 269 270 271 class ToHangarTransition(FadeToBlackTransition): 272 273 def __init__(self, fadeTimeMS = 500, fadeInTimeMS = 500, fadeOutTimeMS = 2000, **kwargs): 274 FadeToBlackTransition.__init__(self, fadeTimeMS, fadeInTimeMS, fadeOutTimeMS, **kwargs) 275 276 def StartTransition(self, fromView, toView): 277 sm.GetService('audio').SendUIEvent('global_stop_all_hangar') 278 sm.ScatterEvent('OnDockingTransitionStart') 279 super(ToHangarTransition, self).StartTransition(fromView, toView) 280 281 def EndTransition(self, fromView, toView): 282 if session.stationid or session.structureid: 283 sm.GetService('viewState').GetView(ViewState.Hangar).OnDocking() 284 sm.ScatterEvent('OnDockingTransitionEnd') 285 FadeToBlackTransition.EndTransition(self, fromView, toView) 286 287 288 class ToCharCreationTransition(FadeToBlackTransition): 289 290 def StartTransition(self, fromView, toView): 291 FadeToBlackTransition.StartTransition(self, fromView, toView) 292 sm.GetService('michelle').RemoveBallpark() 293 294 295 class ToStructureFromCharCreationTransition(FadeToBlackTransition): 296 297 def EndTransition(self, fromView, toView): 298 self._LoadSceneForCurrentSolarSystem() 299 FadeToBlackTransition.EndTransition(self, fromView, toView) 300 301 def _LoadSceneForCurrentSolarSystem(self): 302 sceneManager = sm.GetService('sceneManager') 303 sceneRes = sceneManager.GetSceneForSystem(session.solarsystemid) 304 sceneManager.LoadScene(sceneRes, registerKey='default', applyScene=False) 305 306 307 class HangarToHangarTransition(FadeToBlackLiteTransition): 308 309 def __init__(self, **kwargs): 310 super(HangarToHangarTransition, self).__init__(**kwargs) 311 self.hangarView = sm.GetService('viewState').GetView(ViewState.Hangar) 312 313 def StartTransition(self, fromView, toView): 314 super(HangarToHangarTransition, self).StartTransition(fromView, toView) 315 self.hangarView.ClearScene() 316 self.hangarView.SetUpModels() 317 318 def EndTransition(self, fromView, toView): 319 self.hangarView.OnHangarToHangar() 320 FadeToBlackLiteTransition.EndTransition(self, fromView, toView)