HoverRace  2.0
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
HoverRace::Client::Scene Class Referenceabstract

Scenes are analogous to fullscreen windows that are layered on top of each other. More...

#include <Scene.h>

+ Inheritance diagram for HoverRace::Client::Scene:

Classes

struct  ConnList
 Tracks connections as a group. More...
 

Public Types

enum  Phase {
  Phase::INITIALIZING, Phase::STARTING, Phase::RUNNING, Phase::STOPPING,
  Phase::STOPPED
}
 
enum  State {
  State::INITIALIZING, State::BACKGROUND, State::RAISING, State::FOREGROUND,
  State::LOWERING
}
 

Public Member Functions

 Scene (const std::string &name="Unnamed Scene")
 Constructor. More...
 
virtual ~Scene ()
 
void AdvanceScene (Util::OS::timestamp_t tick)
 
void AttachInput (Control::InputEventController &controller)
 Attach the user input to the scene. More...
 
void DetachInput (Control::InputEventController &controller)
 Detach the user input from the scene. More...
 
const std::string & GetName () const
 Retrieve the name of the scene. More...
 
Phase GetPhase () const
 
State GetState () const
 
virtual bool IsMouseCursorEnabled () const =0
 Determine if the mouse cursor is enabled for this scene. More...
 
bool MoveToBackground ()
 Signal that the scene is moving into the background. More...
 
bool MoveToForeground ()
 Signal that the scene is moving into the foreground. More...
 
virtual void OnScenePushed ()
 Called when the scene is actually pushed to the stage. More...
 
Sceneoperator= (const Scene &)=delete
 
virtual std::ostream & OutputDebugText (std::ostream &oss) const
 Output a stream of debug information describing this scene. More...
 
void PrepareScene ()
 
void RenderScene ()
 
bool SetPhase (Phase phase)
 Switch to another phase. More...
 

Protected Member Functions

virtual void Advance (Util::OS::timestamp_t tick)
 
virtual void AttachController (Control::InputEventController &controller, ConnList &conns)=0
 Configure the controller mappings. More...
 
virtual void DetachController (Control::InputEventController &controller, ConnList &conns)=0
 Remove the controller mappings. More...
 
Util::OS::timestamp_t GetPhaseDuration (Util::OS::timestamp_t curTime=Util::OS::Time())
 Calculate how much time we've spent in the current phase. More...
 
Util::OS::timestamp_t GetStartingPhaseTime ()
 Return how long the starting phase lasted. More...
 
Util::OS::timestamp_t GetStateDuration (Util::OS::timestamp_t curTime=Util::OS::Time())
 Calculate how much time we've spent in the current state. More...
 
virtual void OnPhaseChanged (Phase oldPhase)
 Fired immediately after entering a new phase. More...
 
virtual void OnPhaseTransition (double progress)
 Fired during the starting and stopping phases, if SetPhaseTransitionDuration() was set. More...
 
virtual void OnStateChanged (State oldState)
 Fired immediately after entering a new state. More...
 
virtual void OnStateTransition (double progress)
 Fired during the raising and lowering states, if SetStateTransitionDuration() was set. More...
 
virtual void PrepareRender ()
 
virtual void Render ()=0
 
void SetPhaseTransitionDuration (Util::OS::timestamp_t ms)
 Set the maximum duration of the starting or stopping phases. More...
 
void SetStateTransitionDuration (Util::OS::timestamp_t ms)
 Set the maximum duration of the raising or lowering state. More...
 

Protected Attributes

std::shared_ptr< Util::ProfileradvanceProfiler
 
std::shared_ptr< Util::ProfilerprepareProfiler
 
std::shared_ptr< Util::ProfilerrenderProfiler
 
std::shared_ptr< Util::ProfilerrootProfiler
 

Private Member Functions

bool SetState (State state)
 
Util::OS::timestamp_t TimeSincePrevTick (Util::OS::timestamp_t tick)
 

Private Attributes

ConnList attachConns
 Connected signals while controller is attached. More...
 
std::string name
 
Phase phase
 
double phaseTransitionDuration
 
Util::OS::timestamp_t phaseTs
 When current phase was started. More...
 
Util::OS::timestamp_t prevTick
 
Util::OS::timestamp_t startingPhaseTime
 
State state
 
double statePosition
 
Util::OS::timestamp_t stateTransitionDuration
 
double stateTransitionVelocity
 
Util::OS::timestamp_t stateTs
 When current state was started. More...
 

Detailed Description

Scenes are analogous to fullscreen windows that are layered on top of each other.

Each scene maintains its own state and handles its own rendering. Scenes navigate to other scenes via GameDirector.

See also
GameDirector
Author
Michael Imamura

Member Enumeration Documentation

Enumerator
INITIALIZING 

Scene has been created and is waiting to start.

STARTING 

Transitioning into the scene.

RUNNING 

Started and running normally.

STOPPING 

Transitioning away from the scene.

STOPPED 

The scene is ready to be destroyed.

Enumerator
INITIALIZING 

Scene has been created and is waiting to start.

BACKGROUND 

Scene is in the background.

RAISING 

Has focus, transitioning to the foreground.

FOREGROUND 
LOWERING 

Has focus, in foreground.

Lost focus, transitioning to the background.

Constructor & Destructor Documentation

HoverRace::Client::Scene::Scene ( const std::string &  name = "Unnamed Scene")

Constructor.

Parameters
nameThe name of the scene. See Scene::GetName.
virtual HoverRace::Client::Scene::~Scene ( )
inlinevirtual

Member Function Documentation

void HoverRace::Client::Scene::Advance ( Util::OS::timestamp_t  tick)
protectedvirtual
void HoverRace::Client::Scene::AdvanceScene ( Util::OS::timestamp_t  tick)
inline
virtual void HoverRace::Client::Scene::AttachController ( Control::InputEventController controller,
ConnList conns 
)
protectedpure virtual

Configure the controller mappings.

This is called whenever the scene becomes the foreground scene or the controller config needs to be rebuilt.

Parameters
controllerThe current controller being used. It can be assumed that the controller's action mappings have been cleared.
connsThe list to manage connections while the input is attached. Any connections added to this list will be automatically disconnected when then the input is detached.

Implemented in HoverRace::Client::DialogScene, HoverRace::Client::HoverScript::ConsoleScene, HoverRace::Client::TextEditScene, HoverRace::Client::TestLabScene::LabModule, HoverRace::Client::MessageScene, HoverRace::Client::StatusOverlayScene, HoverRace::Client::PauseMenuScene, HoverRace::Client::PaletteScene, HoverRace::Client::FormScene, HoverRace::Client::UiScene, HoverRace::Client::PlayGameScene, and HoverRace::Client::DemoGameScene.

void HoverRace::Client::Scene::AttachInput ( Control::InputEventController controller)

Attach the user input to the scene.

This is called whenever the scene becomes the foreground scene or the controller config needs to be rebuilt.

Parameters
controllerThe current controller being used. It can be assumed that the controller's action mappings have been cleared.
virtual void HoverRace::Client::Scene::DetachController ( Control::InputEventController controller,
ConnList conns 
)
protectedpure virtual

Remove the controller mappings.

Parameters
controllerThe current controller being used. It can be assumed that the controller's action mappings have been cleared.
connsThe same connection list passed to AttachController.

Implemented in HoverRace::Client::DialogScene, HoverRace::Client::HoverScript::ConsoleScene, HoverRace::Client::TextEditScene, HoverRace::Client::UiScene, HoverRace::Client::PlayGameScene, and HoverRace::Client::DemoGameScene.

void HoverRace::Client::Scene::DetachInput ( Control::InputEventController controller)

Detach the user input from the scene.

Parameters
controllerThe current controller being used. It can be assumed that the controller's action mappings have been cleared.
const std::string& HoverRace::Client::Scene::GetName ( ) const
inline

Retrieve the name of the scene.

This is for debugging and logging purposes; it is otherwise not intended to be user-visible (and thus should not be translated).

Returns
The name (may be empty).
Phase HoverRace::Client::Scene::GetPhase ( ) const
inline
Util::OS::timestamp_t HoverRace::Client::Scene::GetPhaseDuration ( Util::OS::timestamp_t  curTime = Util::OS::Time())
inlineprotected

Calculate how much time we've spent in the current phase.

Parameters
curTimeThe current (or simulated) timestamp.
Returns
The duration. If curTime is before the start of the phase, then zero is returned.
Util::OS::timestamp_t HoverRace::Client::Scene::GetStartingPhaseTime ( )
inlineprotected

Return how long the starting phase lasted.

This is useful for making the STOPPING phase have the same duration as the STARTING phase, especially if the STARTING phase was interrupted. If the current phase is the STARTING phase, then this returns the current time in the phase so far.

Returns
The duration of the phase.
State HoverRace::Client::Scene::GetState ( ) const
inline
Util::OS::timestamp_t HoverRace::Client::Scene::GetStateDuration ( Util::OS::timestamp_t  curTime = Util::OS::Time())
inlineprotected

Calculate how much time we've spent in the current state.

Parameters
curTimeThe current (or simulated) timestamp.
Returns
The duration. If curTime is before the start of the state, then zero is returned.
virtual bool HoverRace::Client::Scene::IsMouseCursorEnabled ( ) const
pure virtual

Determine if the mouse cursor is enabled for this scene.

Returns
true if the cursor should be shown, false if it should be hidden.

Implemented in HoverRace::Client::GameScene, HoverRace::Client::LoadingScene, HoverRace::Client::StatusOverlayScene, HoverRace::Client::DebugScene, HoverRace::Client::PaletteScene, and HoverRace::Client::UiScene.

bool HoverRace::Client::Scene::MoveToBackground ( )

Signal that the scene is moving into the background.

Returns
true if the state changed.
bool HoverRace::Client::Scene::MoveToForeground ( )

Signal that the scene is moving into the foreground.

Returns
true if the state changed.
virtual void HoverRace::Client::Scene::OnPhaseChanged ( Phase  oldPhase)
inlineprotectedvirtual

Fired immediately after entering a new phase.

Parameters
oldPhaseThe previous phase.
See also
GetPhase()

Reimplemented in HoverRace::Client::Module::TransitionModule, and HoverRace::Client::LoadingScene.

virtual void HoverRace::Client::Scene::OnPhaseTransition ( double  progress)
inlineprotectedvirtual

Fired during the starting and stopping phases, if SetPhaseTransitionDuration() was set.

Parameters
progressThe animation progress (during the STARTING phase this goes from 0.0 to 1.0, and in reverse for the STOPPING phase).

Reimplemented in HoverRace::Client::Module::TransitionModule, HoverRace::Client::DialogScene, HoverRace::Client::MessageScene, HoverRace::Client::LoadingScene, HoverRace::Client::GameSelectScene, HoverRace::Client::TrackSelectScene, and HoverRace::Client::SessionLoadingScene.

virtual void HoverRace::Client::Scene::OnScenePushed ( )
inlinevirtual

Called when the scene is actually pushed to the stage.

In terms of phases, this is called just before the scene enters the STARTING phase, so the scene will be still in the INITIALIZING phase.

This is useful for handling anything that needs to be done just before the first frame is rendered, but after the constructor has run.

An example is pushing another scene on top of this scene. This can't be done in the constructor since this scene hasn't been pushed yet (so the scenes would be out-of-order on the stage).

Reimplemented in HoverRace::Client::TestLabScene, and HoverRace::Client::PracticeSetupScene.

virtual void HoverRace::Client::Scene::OnStateChanged ( State  oldState)
inlineprotectedvirtual

Fired immediately after entering a new state.

Parameters
oldStateThe previous state.
See also
GetState()

Reimplemented in HoverRace::Client::Module::TransitionModule, and HoverRace::Client::MainMenuScene.

virtual void HoverRace::Client::Scene::OnStateTransition ( double  progress)
inlineprotectedvirtual

Fired during the raising and lowering states, if SetStateTransitionDuration() was set.

Parameters
progressThe animation progress (during the RAISING phase this goes from 0.0 to 1.0, and in reverse for the LOWERING phase).

Reimplemented in HoverRace::Client::Module::TransitionModule, HoverRace::Client::GameSelectScene, and HoverRace::Client::MainMenuScene.

Scene& HoverRace::Client::Scene::operator= ( const Scene )
delete
virtual std::ostream& HoverRace::Client::Scene::OutputDebugText ( std::ostream &  oss) const
inlinevirtual

Output a stream of debug information describing this scene.

The output text may include newlines.

Parameters
[in,out]ossThe output stream to write to.
Returns
The same output stream as was passed in.

Reimplemented in HoverRace::Client::GameScene.

virtual void HoverRace::Client::Scene::PrepareRender ( )
inlineprotectedvirtual
void HoverRace::Client::Scene::PrepareScene ( )
inline
virtual void HoverRace::Client::Scene::Render ( )
protectedpure virtual
void HoverRace::Client::Scene::RenderScene ( )
inline
bool HoverRace::Client::Scene::SetPhase ( Phase  phase)

Switch to another phase.

Warning
Scenes should not switch to the STOPPING phase themselves. Instead, they should call GameDirector::PopScene or GameDirector::ReplaceScene.
Parameters
phaseThe new phase.
Returns
true if the phase change was successful, false otherwise.
void HoverRace::Client::Scene::SetPhaseTransitionDuration ( Util::OS::timestamp_t  ms)
inlineprotected

Set the maximum duration of the starting or stopping phases.

Subclasses should call this function in the constructor or the first tick in order to set how long the starting phase will last. The stopping phase always lasts as long as the starting phase.

If set to zero (the default), then the starting and stopping phases will be skipped.

If set to non-zero, then the OnPhaseTransition() function will be called during Advance() so subclasses can customize the animation.

Parameters
msThe duration (may be zero to disable starting and stopping phases).
bool HoverRace::Client::Scene::SetState ( State  state)
private
void HoverRace::Client::Scene::SetStateTransitionDuration ( Util::OS::timestamp_t  ms)
inlineprotected

Set the maximum duration of the raising or lowering state.

Subclasses should call this function in the constructor or the first tick in order to set how long the raising state will last. The lowering state always lasts as long as the raising state.

If set to zero (the default), then the raising and lowering states will be skipped.

If set to non-zero, then the OnStateTransition() function will be called during Advance() so subclasses can customize the animation.

Parameters
msThe duration (may be zero to disable raising and lowering states).
Util::OS::timestamp_t HoverRace::Client::Scene::TimeSincePrevTick ( Util::OS::timestamp_t  tick)
inlineprivate

Member Data Documentation

std::shared_ptr<Util::Profiler> HoverRace::Client::Scene::advanceProfiler
protected
ConnList HoverRace::Client::Scene::attachConns
private

Connected signals while controller is attached.

std::string HoverRace::Client::Scene::name
private
Phase HoverRace::Client::Scene::phase
private
double HoverRace::Client::Scene::phaseTransitionDuration
private
Util::OS::timestamp_t HoverRace::Client::Scene::phaseTs
private

When current phase was started.

std::shared_ptr<Util::Profiler> HoverRace::Client::Scene::prepareProfiler
protected
Util::OS::timestamp_t HoverRace::Client::Scene::prevTick
private
std::shared_ptr<Util::Profiler> HoverRace::Client::Scene::renderProfiler
protected
std::shared_ptr<Util::Profiler> HoverRace::Client::Scene::rootProfiler
protected
Util::OS::timestamp_t HoverRace::Client::Scene::startingPhaseTime
private
State HoverRace::Client::Scene::state
private
double HoverRace::Client::Scene::statePosition
private
Util::OS::timestamp_t HoverRace::Client::Scene::stateTransitionDuration
private
double HoverRace::Client::Scene::stateTransitionVelocity
private
Util::OS::timestamp_t HoverRace::Client::Scene::stateTs
private

When current state was started.


The documentation for this class was generated from the following files: