|
VR-Engage
2.2
|
DtChatCommandsManager provides a centralized registry of available chat commands. It handles command registration, execution, and help text generation. When a user enters a command in the chat window, this manager locates and executes the appropriate command handler.
#include <vreChatCommandsManager.h>
Public Member Functions | |
| DtChatCommandsManager (DtPlayerStationApp &app) | |
| ~DtChatCommandsManager () | |
| virtual bool | addCommand (std::string commandString, std::shared_ptr< DtChatCommand > command, bool takeOwnership=false) |
| virtual void | removeCommand (std::string commandString) |
| virtual bool | runCommand (std::string consoleString) |
| virtual std::string | helpText (const std::string ¶meters) const |
| DtChatCommandsManager (const DtChatCommandsManager &orig)=delete | |
| DtChatCommandsManager & | operator= (const DtChatCommandsManager &orig)=delete |
Protected Attributes | |
| std::unordered_map< std::string, std::weak_ptr< DtChatCommand > > | myCommandMap |
| std::unordered_map< std::string, std::shared_ptr< DtChatCommand > > | myOwnedCommandMap |
| DtPlayerStationApp & | myApp |
| makVre::DtChatCommandsManager::DtChatCommandsManager | ( | DtPlayerStationApp & | app | ) |
Constructor.
| app | Reference to the player station application |
Creates a new chat commands manager associated with the given application. The manager starts with no registered commands.
Referenced by DtChatCommandsManager(), and operator=().
| makVre::DtChatCommandsManager::~DtChatCommandsManager | ( | ) |
Destructor.
Cleans up resources, including any owned command objects.
|
delete |
Deleted copy constructor and assignment operatorThese operations are not supported for the command manager.
References DtChatCommandsManager().
|
delete |
Deleted copy constructor and assignment operatorThese operations are not supported for the command manager.
References DtChatCommandsManager().
|
virtual |
Registers a new chat command.
| commandString | String that triggers this command (without the leading slash) |
| command | Shared pointer to the command implementation |
| takeOwnership | If true, the manager takes ownership of the command object |
Adds a new command to the registry. If takeOwnership is true, the manager will maintain a strong reference to the command and handle its lifetime. If false, the manager only keeps a weak reference, and the caller must ensure the command object remains valid for as long as it's registered.
|
virtual |
Unregisters a chat command.
| commandString | String that triggers the command to remove |
Removes a command from the registry. The command string is case-insensitive, so commands with the same spelling but different capitalization will be treated as identical. If the manager owned the command, it will be released.
|
virtual |
Executes a command from a console input string.
| consoleString | Full string entered in the chat/console |
Parses the input string to extract the command and its parameters, then executes the command if found. Commands are case-insensitive. The expected format is "/command parameters", where the leading slash identifies it as a command rather than normal chat text.
|
virtual |
Generates help text for available commands.
| parameters | Optional parameters to filter or customize help output |
Creates a formatted string containing help information for all registered commands that have showInHelp() returning true. This is typically shown when the user enters "/help" in the chat.
|
protected |
Map of command strings to weak pointers to commands.
Contains all registered commands that are not owned by the manager. The weak pointers prevent circular references but require external lifetime management for the command objects.
|
protected |
Map of command strings to shared pointers to commands.
Contains all registered commands that are owned by the manager. The shared pointers ensure the command objects remain valid as long as they are registered.
|
protected |
Reference to the player station application.
Provides access to application services and state needed by commands.