IStateHandler class
#include <Jazz2/IStateHandler.h>
Base interface of a state handler, only one handler runs at a time.
Represents one top-level application state (main menu, in-game level, cinematic, etc.). The root controller keeps a single active handler and forwards per-frame, viewport and input callbacks to it.
Derived classes
- class EditorSession
- The level editor.
- class LevelHandler
- Level handler of a local game session.
- class Cinematics
- Handler that plays a cinematic video.
- class LoadingHandler
- Handler that only shows the loading indicator.
- class MainMenu
- Main menu.
Public types
- enum class CursorPolicy { Default, Visible, Hidden }
- How the mouse cursor is shown while a state handler is active.
Constructors, destructors, conversion operators
- IStateHandler()
- Creates a new instance.
- ~IStateHandler() virtual
- IStateHandler(const IStateHandler&) deleted
Public functions
- auto operator=(const IStateHandler&) -> IStateHandler& deleted
- auto GetViewSize() const -> nCine::Vector2i virtual
- Returns viewport size of the handler.
- void OnBeginFrame() virtual
- Called at the beginning of each frame.
- void OnEndFrame() virtual
- Called at the end of each frame.
-
void OnInitializeViewport(std::
int32_t width, std:: int32_t height) virtual - Called when the viewport needs to be initialized (e.g., when the resolution is changed).
-
void OnKeyPressed(const nCine::
KeyboardEvent& event) virtual - Called when a key is pressed.
-
void OnKeyReleased(const nCine::
KeyboardEvent& event) virtual - Called when a key is released.
-
void OnTextInput(const nCine::
TextInputEvent& event) virtual - Called when a text input is detected.
-
void OnTouchEvent(const nCine::
TouchEvent& event) virtual - Called when a touch event is triggered.
-
void OnMouseDown(const nCine::
MouseEvent& event) virtual - Called when a mouse button is pressed.
-
void OnMouseUp(const nCine::
MouseEvent& event) virtual - Called when a mouse button is released.
-
void OnMouseMove(const nCine::
MouseState& state) virtual - Called when the mouse is moved.
-
void OnMouseWheel(const nCine::
ScrollEvent& event) virtual - Called when the mouse wheel is scrolled, or a touchpad is scrolled with two fingers.
- void OnSuspend() virtual
- Called when the application is about to be suspended, before the resumable state is saved.
- void OnReplacing() virtual
- Called when another handler is about to be made in its place, before it loads what it needs.
- auto GetCursorPolicy() const -> CursorPolicy virtual
- Returns how the mouse cursor should be shown while the handler is active.
Enum documentation
enum class Jazz2:: IStateHandler:: CursorPolicy
How the mouse cursor is shown while a state handler is active.
| Enumerators | |
|---|---|
| Default |
Shown in a window, hidden in fullscreen |
| Visible |
Always shown |
| Hidden |
Always hidden |
Function documentation
void Jazz2:: IStateHandler:: OnMouseDown(const nCine:: MouseEvent& event) virtual
Called when a mouse button is pressed.
The position is in window coordinates, which may differ from the pixels of the drawable on a high-DPI display. The game itself doesn't use the mouse, only the level editor does.
void Jazz2:: IStateHandler:: OnReplacing() virtual
Called when another handler is about to be made in its place, before it loads what it needs.
The handler can still be alive while the next one loads, and the resources are shared, so what it changed of them goes back now. It isn't updated or drawn any more afterwards.