HoverRace
2.0
|
Scenes are analogous to fullscreen windows that are layered on top of each other. More...
#include <Scene.h>
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... | |
Scene & | operator= (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::Profiler > | advanceProfiler |
std::shared_ptr< Util::Profiler > | prepareProfiler |
std::shared_ptr< Util::Profiler > | renderProfiler |
std::shared_ptr< Util::Profiler > | rootProfiler |
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... | |
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.
|
strong |
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. |
|
strong |
HoverRace::Client::Scene::Scene | ( | const std::string & | name = "Unnamed Scene" | ) |
Constructor.
name | The name of the scene. See Scene::GetName. |
|
inlinevirtual |
|
protectedvirtual |
|
inline |
|
protectedpure virtual |
Configure the controller mappings.
This is called whenever the scene becomes the foreground scene or the controller config needs to be rebuilt.
controller | The current controller being used. It can be assumed that the controller's action mappings have been cleared. |
conns | The 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.
controller | The current controller being used. It can be assumed that the controller's action mappings have been cleared. |
|
protectedpure virtual |
Remove the controller mappings.
controller | The current controller being used. It can be assumed that the controller's action mappings have been cleared. |
conns | The 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.
controller | The current controller being used. It can be assumed that the controller's action mappings have been cleared. |
|
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).
|
inline |
|
inlineprotected |
Calculate how much time we've spent in the current phase.
curTime | The current (or simulated) timestamp. |
curTime
is before the start of the phase, then zero is returned.
|
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.
|
inline |
|
inlineprotected |
Calculate how much time we've spent in the current state.
curTime | The current (or simulated) timestamp. |
curTime
is before the start of the state, then zero is returned.
|
pure virtual |
Determine if the mouse cursor is enabled for this scene.
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.
true
if the state changed. bool HoverRace::Client::Scene::MoveToForeground | ( | ) |
Signal that the scene is moving into the foreground.
true
if the state changed.
|
inlineprotectedvirtual |
Fired immediately after entering a new phase.
oldPhase | The previous phase. |
Reimplemented in HoverRace::Client::Module::TransitionModule, and HoverRace::Client::LoadingScene.
|
inlineprotectedvirtual |
Fired during the starting and stopping phases, if SetPhaseTransitionDuration() was set.
progress | The 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.
|
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.
|
inlineprotectedvirtual |
Fired immediately after entering a new state.
oldState | The previous state. |
Reimplemented in HoverRace::Client::Module::TransitionModule, and HoverRace::Client::MainMenuScene.
|
inlineprotectedvirtual |
Fired during the raising and lowering states, if SetStateTransitionDuration() was set.
progress | The 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.
|
inlinevirtual |
Output a stream of debug information describing this scene.
The output text may include newlines.
[in,out] | oss | The output stream to write to. |
Reimplemented in HoverRace::Client::GameScene.
|
inlineprotectedvirtual |
Reimplemented in HoverRace::Client::Module::TypeCaseModule, HoverRace::Client::Module::HudModule, HoverRace::Client::GameScene, HoverRace::Client::DialogScene, HoverRace::Client::UiScene, HoverRace::Client::HoverScript::ConsoleScene, HoverRace::Client::TextEditScene, HoverRace::Client::StatusOverlayScene, HoverRace::Client::SettingsScene, HoverRace::Client::TestLabScene::LabModule, HoverRace::Client::MessageScene, HoverRace::Client::LoadingScene, HoverRace::Client::FormScene, HoverRace::Client::MainMenuScene, HoverRace::Client::PauseMenuScene, HoverRace::Client::PaletteScene, HoverRace::Client::DebugScene, and HoverRace::Client::TestLabScene.
|
inline |
|
protectedpure virtual |
Implemented in HoverRace::Client::Module::TypeCaseModule, HoverRace::Client::Module::HudModule, HoverRace::Client::GameScene, HoverRace::Client::UiScene, HoverRace::Client::DialogScene, HoverRace::Client::HoverScript::ConsoleScene, HoverRace::Client::GameSelectScene, HoverRace::Client::StatusOverlayScene, HoverRace::Client::TestLabScene::LabModule, HoverRace::Client::MessageScene, HoverRace::Client::LoadingScene, HoverRace::Client::FormScene, HoverRace::Client::MainMenuScene, HoverRace::Client::PauseMenuScene, HoverRace::Client::PaletteScene, HoverRace::Client::DebugScene, and HoverRace::Client::TestLabScene.
|
inline |
bool HoverRace::Client::Scene::SetPhase | ( | Phase | phase | ) |
Switch to another phase.
STOPPING
phase themselves. Instead, they should call GameDirector::PopScene or GameDirector::ReplaceScene. phase | The new phase. |
true
if the phase change was successful, false
otherwise.
|
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.
ms | The duration (may be zero to disable starting and stopping phases). |
|
private |
|
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.
ms | The duration (may be zero to disable raising and lowering states). |
|
inlineprivate |
|
protected |
|
private |
Connected signals while controller is attached.
|
private |
|
private |
|
private |
|
private |
When current phase was started.
|
protected |
|
private |
|
protected |
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
When current state was started.