VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtVreChatManager Class Reference

Detailed Description

DtVreChatManager provides a Qt-free public API for sending chat messages, managing channels, controlling the chat window UI, and registering slash commands. It is a member of DtPlayerStationApp and is available through app.chatManager().

DtVreChatManager participates in the per-class creator factory via DtVreUniqueBase. Override the default implementation by calling DtVreChatManager::registerCreator<MyManager>() before app initialization. Custom subclasses must have a default constructor and override initialize().

#include <vreChatManager.h>

Inheritance diagram for makVre::DtVreChatManager:
[legend]

Public Member Functions

 DtVreChatManager ()
 
virtual ~DtVreChatManager ()
 
virtual void initialize (DtPlayerStationApp &app)
 
virtual void setWindow (DtChatWindowInterface *window)
 
virtual void send (const std::string &message)
 
virtual void sendChatMessage (const std::string &message, const std::string &channel, int force)
 
virtual void sendToSystemChannel (const std::string &message)
 
virtual bool isChannelActive (const std::string &channelName, int force) const
 
virtual void open ()
 
virtual void close ()
 
virtual void openOrFocus ()
 
virtual void togglePinChat ()
 
virtual bool isVisible () const
 
virtual bool isFullChatVisible () const
 
virtual bool isShowingAllowed () const
 
virtual void setShowingAllowed (bool canShow)
 
virtual bool updateChatChannelsFromScenario (const DtFilename &scenario)
 
virtual bool updateChatChannelsFromConfigFile (const DtFilename &chatConfigFile)
 
virtual DtFilename getChatConfigFile (const DtFilename &scenarioFilename) const
 
virtual bool addCommand (const std::string &commandString, std::shared_ptr< DtChatCommand > command, bool takeOwnership=false)
 
virtual void removeCommand (const std::string &commandString)
 
virtual bool runCommand (const std::string &consoleString)
 
virtual std::string helpText (const std::string &parameters) const
 
- Public Member Functions inherited from makVre::DtVreUniqueBase< DtVreChatManager >
 DtVreUniqueBase ()
 
virtual ~DtVreUniqueBase ()
 
std::string type () const override
 
- Public Member Functions inherited from makVre::DtVreUniqueObject
 DtVreUniqueObject ()
 
virtual ~DtVreUniqueObject ()
 
- Public Member Functions inherited from makVre::DtVreBase
 DtVreBase ()
 
virtual ~DtVreBase ()=default
 
virtual void setName (const std::string &name)
 
virtual std::string name () const
 

Protected Member Functions

virtual DtVreMessageResult handlePlayerCreatedMessage (DtVreMessage *msg)
 
virtual DtVreMessageResult handlePlayerDestroyedMessage (DtVreMessage *msg)
 
virtual DtVreMessageResult handleIncomingChatMessage (DtVreMessage *msg)
 
virtual DtVreMessageResult handleVrfSessionStatusMessage (DtVreMessage *msg)
 
virtual DtVreMessageResult handleEnterPlayerState (DtVreMessage *msg)
 
virtual DtVreMessageResult handleExitPlayerState (DtVreMessage *msg)
 
virtual void onCurrentStateChanged (std::string state)
 

Protected Attributes

DtChatWindowInterface * myWindow = nullptr
 
DtPlayerStationApp * myApp = nullptr
 
DtAttributeCallbackManager myAttributeCallbacks
 
DtFilename myDefaultChatConfigFile
 
DtFilename myCurrentChatConfigFile
 
DtFilename myDefaultConfigFilename = DtFilename("defaultChatConfig.mtl")
 
DtFilename myDefaultConfigDirectory = DtFilename("$(APP_DIR)/settings")
 
DtFilename myDefaultChatConfigUserFilenamePostfix = DtFilename("_ChatConfig.mtl")
 
DtFilename myDefaultChatConfigUserDirectory = DtFilename("$(USER_DIR)/chatConfigs")
 
std::unordered_map< std::string, std::weak_ptr< DtChatCommand > > myCommandMap
 
std::unordered_map< std::string, std::shared_ptr< DtChatCommand > > myOwnedCommandMap
 
- Protected Attributes inherited from makVre::DtVreBase
std::string myName
 

Additional Inherited Members

- Public Types inherited from makVre::DtVreUniqueBase< DtVreChatManager >
using Super
 
using Ptr
 
using Uptr
 
- Static Public Member Functions inherited from makVre::DtVreUniqueBase< DtVreChatManager >
static std::string Type ()
 
static Uptr create ()
 
static void registerCreator ()
 
- Static Protected Member Functions inherited from makVre::DtVreUniqueBase< DtVreChatManager >
static std::shared_ptr< DtBaseCreator< DtVreChatManager > > & creator ()
 

Constructor & Destructor Documentation

◆ DtVreChatManager()

makVre::DtVreChatManager::DtVreChatManager ( )

Default constructor (required by DtVreUniqueBase factory)

◆ ~DtVreChatManager()

virtual makVre::DtVreChatManager::~DtVreChatManager ( )
virtual

Virtual destructor; removes registered message handlers.

Member Function Documentation

◆ initialize()

virtual void makVre::DtVreChatManager::initialize ( DtPlayerStationApp & app)
virtual

Phase-2 initializer — call immediately after create()

Parameters
appReference to the owning player station application

Registers all message handlers, sets up configuration file paths, and connects the application state change callback.

Note
Must be called once before the first window is constructed.

◆ setWindow()

virtual void makVre::DtVreChatManager::setWindow ( DtChatWindowInterface * window)
virtual

Wires the concrete chat window to this manager.

Parameters
windowNon-owning pointer to the DtChatWindowInterface implementation

Called automatically by DtVreChatWindow at the end of its constructor. Triggers initial channel configuration load and updateAvailableChannels(). Guarded: all subsequent window calls check for null.

◆ send()

virtual void makVre::DtVreChatManager::send ( const std::string & message)
virtual

Sends a message or slash command through the chat window.

Parameters
messageText or /command string

◆ sendChatMessage()

virtual void makVre::DtVreChatManager::sendChatMessage ( const std::string & message,
const std::string & channel,
int force )
virtual

Sends a chat message to a specific channel.

◆ sendToSystemChannel()

virtual void makVre::DtVreChatManager::sendToSystemChannel ( const std::string & message)
virtual

Sends a message to the system notification channel.

◆ isChannelActive()

virtual bool makVre::DtVreChatManager::isChannelActive ( const std::string & channelName,
int force ) const
virtual

Checks whether a channel is currently active.

◆ open()

virtual void makVre::DtVreChatManager::open ( )
virtual

Opens the chat window.

◆ close()

virtual void makVre::DtVreChatManager::close ( )
virtual

Closes the chat window.

◆ openOrFocus()

virtual void makVre::DtVreChatManager::openOrFocus ( )
virtual

Opens the chat window or focuses its input if already open.

◆ togglePinChat()

virtual void makVre::DtVreChatManager::togglePinChat ( )
virtual

Toggles the pinned (always-visible) state of the chat window.

◆ isVisible()

virtual bool makVre::DtVreChatManager::isVisible ( ) const
virtual

Returns true if the chat window root item is visible.

◆ isFullChatVisible()

virtual bool makVre::DtVreChatManager::isFullChatVisible ( ) const
virtual

Returns true if the full chat panel is visible.

◆ isShowingAllowed()

virtual bool makVre::DtVreChatManager::isShowingAllowed ( ) const
virtual

Returns true if the chat window is permitted to be shown.

◆ setShowingAllowed()

virtual void makVre::DtVreChatManager::setShowingAllowed ( bool canShow)
virtual

Sets whether the chat window is permitted to be shown.

◆ updateChatChannelsFromScenario()

virtual bool makVre::DtVreChatManager::updateChatChannelsFromScenario ( const DtFilename & scenario)
virtual

Updates chat channels from a scenario file.

Parameters
scenarioFull path to the scenario file
Returns
True if the configuration changed

◆ updateChatChannelsFromConfigFile()

virtual bool makVre::DtVreChatManager::updateChatChannelsFromConfigFile ( const DtFilename & chatConfigFile)
virtual

Updates chat channels from a configuration file.

Parameters
chatConfigFilePath to the chat channel config (.mtl) file
Returns
True if the configuration changed

◆ getChatConfigFile()

virtual DtFilename makVre::DtVreChatManager::getChatConfigFile ( const DtFilename & scenarioFilename) const
virtual

Returns the chat config file to use for a given scenario.

Parameters
scenarioFilenameFull path to the scenario (may be empty)
Returns
Path to the appropriate chat config file

◆ addCommand()

virtual bool makVre::DtVreChatManager::addCommand ( const std::string & commandString,
std::shared_ptr< DtChatCommand > command,
bool takeOwnership = false )
virtual

Registers a slash command.

Parameters
commandStringTrigger word (without the leading slash)
commandShared pointer to the command implementation
takeOwnershipIf true, manager holds a strong reference
Returns
True if the command was added successfully

◆ removeCommand()

virtual void makVre::DtVreChatManager::removeCommand ( const std::string & commandString)
virtual

Unregisters a slash command by its trigger word.

◆ runCommand()

virtual bool makVre::DtVreChatManager::runCommand ( const std::string & consoleString)
virtual

Executes a slash command from a console input string.

Parameters
consoleStringFull string (e.g. "help" or "username Alice")
Returns
True if a matching command was found and executed

◆ helpText()

virtual std::string makVre::DtVreChatManager::helpText ( const std::string & parameters) const
virtual

Generates formatted help text for all visible commands.

Parameters
parametersOptional filter or context string
Returns
Multi-line help string

◆ handlePlayerCreatedMessage()

virtual DtVreMessageResult makVre::DtVreChatManager::handlePlayerCreatedMessage ( DtVreMessage * msg)
protectedvirtual

Message handlers (moved from DtVreChatWindow)

◆ handlePlayerDestroyedMessage()

virtual DtVreMessageResult makVre::DtVreChatManager::handlePlayerDestroyedMessage ( DtVreMessage * msg)
protectedvirtual

Message handlers (moved from DtVreChatWindow)

◆ handleIncomingChatMessage()

virtual DtVreMessageResult makVre::DtVreChatManager::handleIncomingChatMessage ( DtVreMessage * msg)
protectedvirtual

Message handlers (moved from DtVreChatWindow)

◆ handleVrfSessionStatusMessage()

virtual DtVreMessageResult makVre::DtVreChatManager::handleVrfSessionStatusMessage ( DtVreMessage * msg)
protectedvirtual

Message handlers (moved from DtVreChatWindow)

◆ handleEnterPlayerState()

virtual DtVreMessageResult makVre::DtVreChatManager::handleEnterPlayerState ( DtVreMessage * msg)
protectedvirtual

Message handlers (moved from DtVreChatWindow)

◆ handleExitPlayerState()

virtual DtVreMessageResult makVre::DtVreChatManager::handleExitPlayerState ( DtVreMessage * msg)
protectedvirtual

Message handlers (moved from DtVreChatWindow)

◆ onCurrentStateChanged()

virtual void makVre::DtVreChatManager::onCurrentStateChanged ( std::string state)
protectedvirtual

Message handlers (moved from DtVreChatWindow)

Member Data Documentation

◆ myWindow

DtChatWindowInterface* makVre::DtVreChatManager::myWindow = nullptr
protected

Non-owning pointer to the active chat window; set via setWindow()

◆ myApp

DtPlayerStationApp* makVre::DtVreChatManager::myApp = nullptr
protected

Owning application reference; set in initialize()

◆ myDefaultChatConfigFile

DtFilename makVre::DtVreChatManager::myDefaultChatConfigFile
protected

Configuration file paths (moved from DtVreChatWindow)

◆ myCurrentChatConfigFile

DtFilename makVre::DtVreChatManager::myCurrentChatConfigFile
protected

Configuration file paths (moved from DtVreChatWindow)

◆ myDefaultConfigFilename

DtFilename makVre::DtVreChatManager::myDefaultConfigFilename = DtFilename("defaultChatConfig.mtl")
protected

Configuration file paths (moved from DtVreChatWindow)

◆ myDefaultConfigDirectory

DtFilename makVre::DtVreChatManager::myDefaultConfigDirectory = DtFilename("$(APP_DIR)/settings")
protected

Configuration file paths (moved from DtVreChatWindow)

◆ myDefaultChatConfigUserFilenamePostfix

DtFilename makVre::DtVreChatManager::myDefaultChatConfigUserFilenamePostfix = DtFilename("_ChatConfig.mtl")
protected

Configuration file paths (moved from DtVreChatWindow)

◆ myDefaultChatConfigUserDirectory

DtFilename makVre::DtVreChatManager::myDefaultChatConfigUserDirectory = DtFilename("$(USER_DIR)/chatConfigs")
protected

Configuration file paths (moved from DtVreChatWindow)

◆ myAttributeCallbacks

DtAttributeCallbackManager makVre::DtVreChatManager::myAttributeCallbacks
protected

Tracks attribute change callbacks; ensures cleanup on destruction.

◆ myCommandMap

std::unordered_map<std::string, std::weak_ptr<DtChatCommand> > makVre::DtVreChatManager::myCommandMap
protected

Slash-command registry (absorbed from DtChatCommandsManager)

◆ myOwnedCommandMap

std::unordered_map<std::string, std::shared_ptr<DtChatCommand> > makVre::DtVreChatManager::myOwnedCommandMap
protected

Slash-command registry (absorbed from DtChatCommandsManager)


The documentation for this class was generated from the following file: