RigsofRods
Soft-body Physics Simulation
Data Structures | Public Types | Public Member Functions | Private Member Functions | Private Attributes
RoR::Console Class Reference

Global game console backend. More...

#include <Console.h>

+ Inheritance diagram for RoR::Console:
+ Collaboration diagram for RoR::Console:

Data Structures

struct  Message
 
struct  MsgLockGuard
 

Public Types

enum  MessageType {
  CONSOLE_HELP, CONSOLE_TITLE, CONSOLE_SYSTEM_NOTICE, CONSOLE_SYSTEM_ERROR,
  CONSOLE_SYSTEM_WARNING, CONSOLE_SYSTEM_REPLY, CONSOLE_SYSTEM_NETCHAT
}
 
enum  MessageArea {
  CONSOLE_MSGTYPE_INFO, CONSOLE_MSGTYPE_LOG, CONSOLE_MSGTYPE_SCRIPT, CONSOLE_MSGTYPE_ACTOR,
  CONSOLE_MSGTYPE_TERRN
}
 
typedef std::unordered_map< std::string, CVar * > CVarPtrMap
 
typedef std::unordered_map< std::string, ConsoleCmd * > CommandPtrMap
 

Public Member Functions

void putMessage (MessageArea area, MessageType type, std::string const &msg, std::string icon="")
 
void putNetMessage (int user_id, MessageType type, const char *text)
 
void forwardLogMessage (MessageArea area, std::string const &msg, Ogre::LogMessageLevel lml)
 
unsigned long queryMessageTimer ()
 
void regBuiltinCommands ()
 Register builtin commands. More...
 
void doCommand (std::string msg)
 Identify and execute any console line. More...
 
CVarcVarCreate (std::string const &name, std::string const &long_name, int flags, std::string const &val=std::string())
 Add CVar and parse default value if specified. More...
 
void cVarAssign (CVar *cvar, std::string const &value)
 Parse value by cvar type. More...
 
CVarcVarFind (std::string const &input_name)
 Find cvar by short/long name. More...
 
CVarcVarSet (std::string const &input_name, std::string const &input_val)
 Set existing cvar by short/long name. Return the modified cvar (or NULL if not found) More...
 
CVarcVarGet (std::string const &input_name, int flags)
 Get cvar by short/long name, or create new one using input as short name. More...
 
void cVarSetupBuiltins ()
 Create builtin vars and set defaults. More...
 
CVarPtrMapgetCVars ()
 
CommandPtrMapgetCommands ()
 
void processCommandLine (int argc, char *argv[])
 
void showCommandLineUsage ()
 
void showCommandLineVersion ()
 
void loadConfig ()
 
void saveConfig ()
 

Private Member Functions

virtual void messageLogged (const Ogre::String &message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName, bool &skipThisMessage) override
 
void handleMessage (MessageArea area, MessageType type, std::string const &msg, int net_id=0, std::string icon="")
 

Private Attributes

std::vector< Messagem_messages
 
std::mutex m_messages_mutex
 
Ogre::Timer m_msg_timer
 
CVarPtrMap m_cvars
 
CVarPtrMap m_cvars_longname
 
CommandPtrMap m_commands
 

Detailed Description

Global game console backend.

Frontend is RoR::GUI::ConsoleView.

Remarks
Singleton; use App::GetConsole() to fetch instance.

Definition at line 40 of file Console.h.

Member Typedef Documentation

◆ CommandPtrMap

typedef std::unordered_map<std::string, ConsoleCmd*> RoR::Console::CommandPtrMap

Definition at line 44 of file Console.h.

◆ CVarPtrMap

typedef std::unordered_map<std::string, CVar*> RoR::Console::CVarPtrMap

Definition at line 43 of file Console.h.

Member Enumeration Documentation

◆ MessageArea

Enumerator
CONSOLE_MSGTYPE_INFO 

Generic message.

CONSOLE_MSGTYPE_LOG 

Logfile echo.

CONSOLE_MSGTYPE_SCRIPT 

Messages sent from scripts.

CONSOLE_MSGTYPE_ACTOR 

Parsing/spawn/simulation messages for actors.

CONSOLE_MSGTYPE_TERRN 

Parsing/spawn/simulation messages for terrain.

Definition at line 58 of file Console.h.

◆ MessageType

Enumerator
CONSOLE_HELP 
CONSOLE_TITLE 
CONSOLE_SYSTEM_NOTICE 
CONSOLE_SYSTEM_ERROR 
CONSOLE_SYSTEM_WARNING 
CONSOLE_SYSTEM_REPLY 

Success.

CONSOLE_SYSTEM_NETCHAT 

Definition at line 46 of file Console.h.

Member Function Documentation

◆ cVarAssign()

void Console::cVarAssign ( CVar cvar,
std::string const &  value 
)

Parse value by cvar type.

Definition at line 229 of file CVar.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cVarCreate()

CVar * Console::cVarCreate ( std::string const &  name,
std::string const &  long_name,
int  flags,
std::string const &  val = std::string() 
)

Add CVar and parse default value if specified.

Definition at line 205 of file CVar.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cVarFind()

CVar * Console::cVarFind ( std::string const &  input_name)

Find cvar by short/long name.

Definition at line 247 of file CVar.cpp.

+ Here is the caller graph for this function:

◆ cVarGet()

CVar * Console::cVarGet ( std::string const &  input_name,
int  flags 
)

Get cvar by short/long name, or create new one using input as short name.

Definition at line 275 of file CVar.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cVarSet()

CVar * Console::cVarSet ( std::string const &  input_name,
std::string const &  input_val 
)

Set existing cvar by short/long name. Return the modified cvar (or NULL if not found)

Definition at line 264 of file CVar.cpp.

+ Here is the call graph for this function:

◆ cVarSetupBuiltins()

void Console::cVarSetupBuiltins ( )

Create builtin vars and set defaults.

Definition at line 29 of file CVar.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ forwardLogMessage()

void Console::forwardLogMessage ( MessageArea  area,
std::string const &  msg,
Ogre::LogMessageLevel  lml 
)

Definition at line 40 of file Console.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCommands()

CommandPtrMap& RoR::Console::getCommands ( )
inline

Definition at line 133 of file Console.h.

◆ getCVars()

CVarPtrMap& RoR::Console::getCVars ( )
inline

Definition at line 131 of file Console.h.

◆ handleMessage()

void Console::handleMessage ( MessageArea  area,
MessageType  type,
std::string const &  msg,
int  net_id = 0,
std::string  icon = "" 
)
private

Definition at line 58 of file Console.cpp.

+ Here is the call graph for this function:

◆ loadConfig()

void Console::loadConfig ( )

Definition at line 342 of file AppConfig.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ messageLogged()

void Console::messageLogged ( const Ogre::String &  message,
Ogre::LogMessageLevel  lml,
bool  maskDebug,
const Ogre::String &  logName,
bool &  skipThisMessage 
)
overrideprivatevirtual

Definition at line 32 of file Console.cpp.

◆ processCommandLine()

void Console::processCommandLine ( int  argc,
char *  argv[] 
)

Definition at line 71 of file AppCommandLine.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ putMessage()

void Console::putMessage ( MessageArea  area,
MessageType  type,
std::string const &  msg,
std::string  icon = "" 
)

Definition at line 97 of file Console.cpp.

+ Here is the caller graph for this function:

◆ putNetMessage()

void Console::putNetMessage ( int  user_id,
MessageType  type,
const char *  text 
)

Definition at line 102 of file Console.cpp.

+ Here is the caller graph for this function:

◆ queryMessageTimer()

unsigned long RoR::Console::queryMessageTimer ( )
inline

Definition at line 98 of file Console.h.

+ Here is the caller graph for this function:

◆ saveConfig()

void Console::saveConfig ( )

Definition at line 407 of file AppConfig.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showCommandLineUsage()

void Console::showCommandLineUsage ( )

Definition at line 162 of file AppCommandLine.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showCommandLineVersion()

void Console::showCommandLineVersion ( )

Definition at line 181 of file AppCommandLine.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ m_commands

CommandPtrMap RoR::Console::m_commands
private

Definition at line 161 of file Console.h.

◆ m_cvars

CVarPtrMap RoR::Console::m_cvars
private

Definition at line 159 of file Console.h.

◆ m_cvars_longname

CVarPtrMap RoR::Console::m_cvars_longname
private

Definition at line 160 of file Console.h.

◆ m_messages

std::vector<Message> RoR::Console::m_messages
private

Definition at line 156 of file Console.h.

◆ m_messages_mutex

std::mutex RoR::Console::m_messages_mutex
private

Definition at line 157 of file Console.h.

◆ m_msg_timer

Ogre::Timer RoR::Console::m_msg_timer
private

Definition at line 158 of file Console.h.


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