VR-Engage  2.2
Loading...
Searching...
No Matches
menuState.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file menuState.h
7//! \brief Defines the DtMenuState class for menu-based application states
8//!
9//! This file contains the DtMenuState class which serves as a base class for
10//! all states that display a menu interface to the user. It manages the common
11//! functionality shared by menu-based states, including visual effects, input
12//! handling, and UI page management.
13
14#pragma once
15
18
20
21namespace makVrv
22{
23class DtObserver;
24}
25
26namespace makVre
27{
29class DtVreAppPage;
30
31//! \brief Structure for storing depth of field camera settings
32//!
33//! DtDepthOfFieldSettings stores depth of field camera settings that control
34//! the visual blur effect applied when menu states are active. These settings
35//! are cached when entering a menu state and restored when exiting.
37{
38 //! \brief Whether auto-focus is enabled
40
41 //! \brief Focal depth value in meters
42 //!
43 //! Distance at which objects are in perfect focus
45
46 //! \brief Focal range value in meters
47 //!
48 //! Distance range around the focal point where objects remain in focus
50};
51
52//! \brief Base class for all menu-based application states
53//!
54//! DtMenuState provides common functionality for states that display a menu
55//! interface to the user. It manages the application page that contains the menu,
56//! handles input events like Escape key and Back button clicks, and applies
57//! visual effects like depth of field blur to emphasize the menu.
58//!
59//! Derived states implement specific menu interfaces, such as the main menu,
60//! settings menu, role selection menu, or session selection menu.
62{
63public:
64 //! \brief Constructor
65 //! \param app Reference to the player station application
66 //!
67 //! Initializes a new menu state with a reference to the application.
68 //! Registers message handlers for input events.
70
71 //! \brief Virtual destructor
72 //!
73 //! Ensures proper cleanup of derived menu state classes.
74 virtual ~DtMenuState() override;
75
76 //! \brief Updates the menu state each frame
77 //! \param dt Time elapsed since the last update in seconds
78 //!
79 //! Called once per frame to update the menu state. This handles animation
80 //! updates, timed transitions, and other continuous operations for the menu.
81 virtual void tick(double dt) override;
82
83 //! \brief Called when entering this state
84 //! \param args Arguments passed from the previous state
85 //!
86 //! Initializes the menu state when it is pushed onto the state stack.
87 //! This typically involves creating the UI page, caching camera settings,
88 //! applying depth of field effects, and setting up the menu environment.
89 virtual void onEnter(const DtPlayerStationStateArgs* args) override;
90
91 //! \brief Called when exiting this state
92 //!
93 //! Cleans up resources when the menu state is removed from the state stack.
94 //! This typically involves hiding the UI page, restoring cached camera settings,
95 //! and removing depth of field effects.
96 virtual void onExit() override;
97
98 //! \brief Called when this state becomes the top state again
99 //! \param args Arguments passed when exposing this state
100 //!
101 //! Handles the case when a state that was pushed on top of this one is popped,
102 //! making this menu state the active state again. This typically refreshes the
103 //! UI to reflect any changes made while this state was covered.
104 virtual void onExposed(const DtPlayerStationStateArgs* args) override;
105
106 //! \brief Called when another state is pushed on top of this one
107 //!
108 //! Handles the case when a new state is pushed on top of this menu state.
109 //! This typically involves pausing menu animations or temporarily hiding
110 //! UI elements that would otherwise be visible underneath.
111 virtual void onStacked() override;
112
113protected:
114 //! \brief Handles Escape key press messages
115 //! \param message The escape key message to process
116 //! \return Message handling result
117 //!
118 //! Processes escape key press events, typically used to navigate back
119 //! or close the current menu. The default implementation pops this state
120 //! from the stack, returning to the previous state.
122
123 //! \brief Handles application mode change messages
124 //! \param message The application mode message to process
125 //! \return Message handling result
126 //!
127 //! Processes notifications about application mode changes, such as
128 //! transitioning between normal, admin, or lockdown modes. Updates the
129 //! UI and available options based on the new mode.
131
132 //! \brief Handles back button click messages
133 //! \param message The back button message to process
134 //! \return Message handling result
135 //!
136 //! Processes click events from the back button in the UI. Similar to the
137 //! escape key handler, this typically pops the current state from the stack.
139
140 //! \brief Updates the state of UI buttons in the application page
141 //!
142 //! Updates the enabled/disabled state of buttons in the UI based on
143 //! current application state and context. This is called when the state
144 //! changes or becomes visible again after being covered by another state.
145 virtual void updateAppPageButtons();
146
147protected:
148 //! \brief Shared pointer to the UI page
149 //!
150 //! Reference to the QML-based UI page that displays the menu interface.
151 //! This page is created when entering the state and destroyed when exiting.
152 std::shared_ptr<DtVreAppPage> myAppPage;
153
154 //! \brief Cached observer mode value
155 //!
156 //! Stores the original observer mode that was active before entering this state.
157 //! This value is saved in onEnter() and restored in onExit() to ensure the
158 //! application returns to its previous visual state when the menu is closed.
160
161 //! \brief Cached sensor mode value
162 //!
163 //! Stores the original sensor mode that was active before entering this state.
164 //! This value is saved in onEnter() and restored in onExit() to ensure the
165 //! application returns to its previous visual state when the menu is closed.
167
168 //! \brief Cached depth of field settings
169 //!
170 //! Stores the original depth of field camera settings that were active before
171 //! entering this state. When a menu is shown, a depth of field blur effect
172 //! is typically applied to the 3D scene to emphasize the menu interface.
173 //! These settings are restored when exiting the menu state.
175};
176
177} // namespace makVre
std::string myCachedSensorMode
Cached sensor mode value.
Definition menuState.h:166
int myCachedObserverMode
Cached observer mode value.
Definition menuState.h:159
DtDepthOfFieldSettings myCachedDepthOfFieldSettings
Cached depth of field settings.
Definition menuState.h:174
virtual void onExposed(const DtPlayerStationStateArgs *args) override
Called when this state becomes the top state again.
virtual void updateAppPageButtons()
Updates the state of UI buttons in the application page.
virtual void onEnter(const DtPlayerStationStateArgs *args) override
Called when entering this state.
std::shared_ptr< DtVreAppPage > myAppPage
Shared pointer to the UI page.
Definition menuState.h:152
DtMenuState(DtPlayerStationApp &app)
Constructor.
virtual void tick(double dt) override
Updates the menu state each frame.
virtual DtVreMessageResult handleEscKey(DtVreMessage *message)
Handles Escape key press messages.
virtual DtVreMessageResult handleBackButtonClicked(DtVreMessage *message)
Handles back button click messages.
virtual void onExit() override
Called when exiting this state.
virtual ~DtMenuState() override
Virtual destructor.
virtual void onStacked() override
Called when another state is pushed on top of this one.
virtual DtVreMessageResult handleAppModeUpdated(DtVreMessage *message)
Handles application mode change messages.
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:163
Class for passing arguments during state transitions.
Definition playerStationState.h:45
DtPlayerStationApp & app() const
Gets a reference to the player station application.
DtPlayerStationState(DtPlayerStationApp &app, std::string stateType)
Constructor.
Main application page for the VR-Engage in-game interface.
Definition vreAppPage.h:61
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition appLauncherComponent.h:28
Defines base classes for the VR-Engage state management system.
Structure for storing depth of field camera settings.
Definition menuState.h:37
bool myDofUseAutoFocus
Whether auto-focus is enabled.
Definition menuState.h:39
double myDofFocalDepth
Focal depth value in meters.
Definition menuState.h:44
double myDofFocalRange
Focal range value in meters.
Definition menuState.h:49
Defines the base class for all VREngage messages.