VR-Engage  2.2
Loading...
Searching...
No Matches
actionMenuManager.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file actionMenuManager.h
7//! \brief Defines the menu management system for VR-Engage
8//!
9//! This file contains the DtMenuManager and DtMenuCursor classes which handle
10//! the creation, organization, and rendering of interactive menus in VR-Engage.
11//! The menu manager coordinates multiple menus, handles cursor display, and
12//! processes menu-related input and messages.
13
14#pragma once
15
17
19
20#include "vreUtil/attribute.h"
21
22#include <vrvGraphics/DtGlFontManager.h>
23
24
25#include <map>
26#include <string>
27
28
29namespace makVrv
30{
31class DtDe;
32class DtOsgChannel;
33class DtSceneObjectAgent;
34class DtModelAgent;
35class DtTickable;
36class DtOverlayRenderer;
37} // namespace makVrv
38
39namespace makVre
40{
42class DtQmlActionMenu;
43class DtMenu;
44class DtInitTable;
45
46//! \brief Type definition for input validation delegate functions
47//!
48//! Defines a delegate function type for validating menu input strings.
49//! These validators are used to check if user-entered text meets specific format
50//! requirements for different input types like coordinates, numbers, etc.
52
53//! \brief Class for managing menu cursor visualization
54//!
55//! DtMenuCursor encapsulates the visual representation of a cursor in the menu system.
56//! It manages the 3D scene object, model, and updating logic needed to display
57//! a cursor at the current menu selection. Different cursor types can be used
58//! to provide visual feedback about the current context or selection type.
60{
61public:
62 //! \brief Constructor
63 //!
64 //! Creates a new menu cursor with default (empty) state.
66
67 //! \brief Virtual destructor
68 //!
69 //! Ensures proper cleanup of derived cursor classes.
70 virtual ~DtMenuCursor();
71
72 //! \brief Clears the cursor state
73 //!
74 //! Resets the cursor to an empty state, cleaning up any associated
75 //! scene objects, models, and updaters.
76 void clear();
77
78 //! \brief Scene object agent for the cursor visual
79 //!
80 //! Represents the cursor in the 3D scene graph, handling its position and visibility.
81 makVrv::DtSceneObjectAgent* mySceneObject;
82
83 //! \brief Model agent for the cursor visual
84 //!
85 //! Manages the 3D model used to represent the cursor visually.
86 makVrv::DtModelAgent* myModel;
87
88 //! \brief Tickable component for cursor updates
89 //!
90 //! Handles periodic updates to the cursor's position, orientation, and appearance.
91 makVrv::DtTickable* myUpdater;
92
93 //! \brief Name identifier for the cursor
94 //!
95 //! Unique name that identifies this cursor type in the cursor registry.
96 std::string myName;
97};
98
99
100//! \brief Central manager for all menus in VR-Engage
101//!
102//! DtMenuManager serves as the central coordinating system for all menus in VR-Engage.
103//! It manages the creation, organization, and interaction with menus, handling both
104//! standard action menus and input menus. The manager maintains a registry of menus
105//! by name, provides access to the player state store for dynamically updating menu
106//! content, and coordinates cursor visualization for menu selections.
107//!
108//! This class also provides input validation functionality for text input fields
109//! in menus, with a registry of validators for different data types and formats.
111{
112public:
113 //! \brief Constructor
114 //! \param updater Pointer to the action menu updater
115 //! \param state Reference to the player state attribute handle
116 //! \param de Pointer to the display engine
117 //!
118 //! Creates a new menu manager with references to the necessary components for
119 //! menu management, including the updater for visual presentation, the player
120 //! state store for dynamic content, and the display engine for rendering.
121 DtMenuManager(DtActionMenuUpdater* updater, DtAttributeHandle& state, makVrv::DtDe* de);
122
123 //! \brief Virtual destructor
124 //!
125 //! Ensures proper cleanup of all menu resources and derived manager classes.
126 virtual ~DtMenuManager();
127
128 //! \brief Gets the player state attribute store
129 //! \return Reference to the player state attribute handle
130 //!
131 //! Provides access to the player state attribute store, which contains
132 //! attributes used for dynamic menu content and conditional display.
134
135 //! \brief Creates standard action menus from configuration
136 //! \param config Configuration table with menu definitions
137 //!
138 //! Builds the standard menu system based on the provided configuration data.
139 //! This includes the main action menu and its submenus, creating the menu
140 //! hierarchy and registering all menus with the manager.
142
143 //! \brief Creates input menus from configuration
144 //! \param config Configuration table with input menu definitions
145 //!
146 //! Builds special input menus based on the provided configuration data.
147 //! Input menus are used for text and value entry, such as coordinates,
148 //! radio frequencies, or other user-entered data.
150
151 //! \brief Creates the standard set of input validators
152 //!
153 //! Sets up the default input validators for various data types and formats,
154 //! such as MGRS coordinates, laser codes, crypto keys, and numeric values.
155 //! These validators are used to ensure user input meets format requirements.
157
158 //! \brief Finds a validator for a specific input type
159 //! \param type String identifier for the validator type
160 //! \return The requested validator delegate, or an empty validator if not found
161 //!
162 //! Retrieves a validator function for the specified input type from the
163 //! validator registry. This is used by input menus to validate user-entered text.
164 DtInputValidator findValidator(const std::string& type);
165
166 //! \brief Adds a menu to the manager
167 //! \param menu Pointer to the menu to add
168 //!
169 //! Registers a menu with the manager and takes ownership of it.
170 //! The menu manager becomes responsible for deleting the menu when it's
171 //! no longer needed or when the manager is destroyed.
172 void addMenu(DtMenu* menu);
173
174 //! \brief Removes a menu from the manager
175 //! \param menu Pointer to the menu to remove
176 //!
177 //! Unregisters a menu from the manager without deleting it.
178 //! The caller becomes responsible for deleting the menu to avoid memory leaks.
179 void removeMenu(DtMenu* menu);
180
181 //! \brief Finds a menu by name
182 //! \param name Name of the menu to find
183 //! \return Pointer to the found menu, or NULL if not found
184 //!
185 //! Looks up a menu in the registry by its name identifier.
186 //! This is used to access specific menus for operations like
187 //! showing, hiding, or updating them.
188 DtMenu* findMenu(const std::string& name);
189
190 //! \brief Finds the currently active menu
191 //! \return Pointer to the active menu, or NULL if no menu is active
192 //!
193 //! Searches for and returns the currently active (visible) menu.
194 //! If multiple menus are active, behavior is undefined and typically
195 //! returns the first active menu found.
197
198 //! \brief Sets the active cursor by name
199 //! \param name Name of the cursor to activate
200 //!
201 //! Activates a specific cursor design by name. Different cursors can
202 //! provide visual feedback about the current context or selection type.
203 //! An empty name deactivates the cursor display.
204 void setActiveCursor(const std::string& name);
205
206 //! \brief Gets the display engine
207 //! \return Pointer to the display engine
208 //!
209 //! Provides access to the display engine used for rendering menus and cursors.
210 makVrv::DtDe* de() { return myDe; }
211
212 //! \brief Gets the QML action menu component
213 //! \return Pointer to the QML action menu
214 //!
215 //! Provides access to the QML-based action menu implementation.
216 //! This is used by components that need to directly interact with
217 //! the modern UI representation of menus.
219
220protected:
221 //! \brief Validates MGRS coordinate input
222 //! \param input The string to validate
223 //! \return True if the input is a valid MGRS coordinate
224 //!
225 //! Checks if the provided string is a valid Military Grid Reference System (MGRS)
226 //! coordinate format. MGRS is a geocoordinate standard used by NATO military forces.
227 bool validateMgrsInput(const std::string& input);
228
229 //! \brief Validates laser code input
230 //! \param input The string to validate
231 //! \return True if the input is a valid laser code
232 //!
233 //! Checks if the provided string is a valid laser designator code format.
234 //! Laser codes are used for targeting systems and typically follow specific formats.
235 bool validateLaserInput(const std::string& input);
236
237 //! \brief Validates cryptographic key input
238 //! \param input The string to validate
239 //! \return True if the input is a valid crypto key
240 //!
241 //! Checks if the provided string is a valid cryptographic key format.
242 //! Crypto keys are used for secure communications and follow specific formats.
243 bool validateCryptoKey(const std::string& input);
244
245 //! \brief Validates integer input
246 //! \param input The string to validate
247 //! \return True if the input is a valid integer
248 //!
249 //! Checks if the provided string represents a valid integer number.
250 bool validateIntegerInput(const std::string& input);
251
252 //! \brief Always returns true for any input
253 //! \param input The string to validate (unused)
254 //! \return Always returns true
255 //!
256 //! Placeholder validator that accepts any input. This can be used for
257 //! fields where no specific validation is needed or where validation
258 //! will be performed later in the processing pipeline.
259 bool validateTrue(const std::string& input);
260
261 //! \brief Validates latitude/longitude coordinate input
262 //! \param input The string to validate
263 //! \return True if the input contains valid decimal lat/lon coordinates
264 //!
265 //! Validates input string for decimal latitude and longitude in degrees.
266 //! Expected format is two numbers separated by a space, with the first
267 //! number representing latitude (-90 to 90) and the second representing
268 //! longitude (-180 to 180).
269 bool validateDecimalLatLonInDegrees(const std::string& input);
270
271 //! \brief Handles menu-related messages
272 //! \param msg Pointer to the message to handle
273 //! \return Message handling result
274 //!
275 //! Processes messages related to menu state changes, such as requests
276 //! to show or hide specific menus, menu selection events, and menu
277 //! configuration changes.
279
280protected:
281 //! \brief Pointer to the display engine
282 //!
283 //! The display engine used for rendering menus and cursors.
284 makVrv::DtDe* myDe;
285
286 //! \brief Type definition for a map of menu names to menu pointers
287 using MenuMap = std::map<std::string, DtMenu*>;
288
289 //! \brief Registry of all menus managed by this manager
290 //!
291 //! Maps menu names to their corresponding menu objects for lookup and management.
293
294 //! \brief Type definition for a map of validator names to validator functions
295 using ValidatorMap = std::map<std::string, DtInputValidator>;
296
297 //! \brief Registry of input validators
298 //!
299 //! Maps validator type names to their corresponding validator functions.
300 //! Used to validate user input in text entry fields.
302
303 //! \brief Handle to the player attribute store
304 //!
305 //! Provides access to player state attributes used for dynamic menu content
306 //! and conditional display logic.
308
309 //! \brief Global scale factor for menu elements
310 //!
311 //! Controls the overall size of menu elements for display scaling.
312 float myScale;
313
314 //! \brief Pointer to the current menu cursor
315 //!
316 //! Manages the visual representation of the cursor in menus.
318
319 //! \brief Pointer to the action menu updater
320 //!
321 //! Handles the visual updating and rendering of menus.
323};
324
325} // namespace makVre
Provides attribute handling system for hierarchical data storage and manipulation.
Component that manages action menu presentation and updates.
Definition actionMenuUpdater.h:80
Handle class for safe access to attributes.
Definition attributeHandle.h:30
Modern delegate class that can bind and invoke callables with any number of parameters.
Definition delegate.h:31
Table-based access to Lua state for configuration data.
Definition initializer.h:38
Class for managing menu cursor visualization.
Definition actionMenuManager.h:60
DtMenuCursor()
Constructor.
std::string myName
Name identifier for the cursor.
Definition actionMenuManager.h:96
makVrv::DtSceneObjectAgent * mySceneObject
Scene object agent for the cursor visual.
Definition actionMenuManager.h:81
makVrv::DtModelAgent * myModel
Model agent for the cursor visual.
Definition actionMenuManager.h:86
makVrv::DtTickable * myUpdater
Tickable component for cursor updates.
Definition actionMenuManager.h:91
void clear()
Clears the cursor state.
virtual ~DtMenuCursor()
Virtual destructor.
Core class for all interactive menus in VR-Engage.
Definition actionMenu.h:67
ValidatorMap myValidatorMap
Registry of input validators.
Definition actionMenuManager.h:301
DtVreMessageResult handleMenuMessage(DtVreMessage *msg)
Handles menu-related messages.
bool validateMgrsInput(const std::string &input)
Validates MGRS coordinate input.
DtInputValidator findValidator(const std::string &type)
Finds a validator for a specific input type.
void addMenu(DtMenu *menu)
Adds a menu to the manager.
void createDefaultValidators()
Creates the standard set of input validators.
void createMenus(DtInitTable &config)
Creates standard action menus from configuration.
std::map< std::string, DtInputValidator > ValidatorMap
Type definition for a map of validator names to validator functions.
Definition actionMenuManager.h:295
bool validateIntegerInput(const std::string &input)
Validates integer input.
DtMenuCursor * myCursor
Pointer to the current menu cursor.
Definition actionMenuManager.h:317
bool validateLaserInput(const std::string &input)
Validates laser code input.
void createInputMenus(DtInitTable &config)
Creates input menus from configuration.
DtAttributeHandle & playerStore()
Gets the player state attribute store.
Definition actionMenuManager.h:133
makVrv::DtDe * myDe
Pointer to the display engine.
Definition actionMenuManager.h:284
DtAttributeHandle myPlayerStore
Handle to the player attribute store.
Definition actionMenuManager.h:307
bool validateDecimalLatLonInDegrees(const std::string &input)
Validates latitude/longitude coordinate input.
DtMenuManager(DtActionMenuUpdater *updater, DtAttributeHandle &state, makVrv::DtDe *de)
Constructor.
virtual DtQmlActionMenu * qmlActionMenu() const
Gets the QML action menu component.
float myScale
Global scale factor for menu elements.
Definition actionMenuManager.h:312
DtMenu * findActiveMenu()
Finds the currently active menu.
void removeMenu(DtMenu *menu)
Removes a menu from the manager.
virtual ~DtMenuManager()
Virtual destructor.
DtMenu * findMenu(const std::string &name)
Finds a menu by name.
bool validateCryptoKey(const std::string &input)
Validates cryptographic key input.
MenuMap myMenuMap
Registry of all menus managed by this manager.
Definition actionMenuManager.h:292
makVrv::DtDe * de()
Gets the display engine.
Definition actionMenuManager.h:210
bool validateTrue(const std::string &input)
Always returns true for any input.
void setActiveCursor(const std::string &name)
Sets the active cursor by name.
DtActionMenuUpdater * myUpdater
Pointer to the action menu updater.
Definition actionMenuManager.h:322
std::map< std::string, DtMenu * > MenuMap
Type definition for a map of menu names to menu pointers.
Definition actionMenuManager.h:287
QML-based action menu interface for VR-Engage.
Definition qmlActionMenu.h:32
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
DtDelegate< bool, const std::string & > DtInputValidator
Type definition for input validation delegate functions.
Definition actionMenuManager.h:51
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition appLauncherComponent.h:28
Defines the base class for all VREngage messages.