Interface to the engine console.
struct IConsole { };
IConsole.h
The engine console allow to manipulate the internal engine parameters and to invoke commands. This interface allow external modules to integrate their functionalities into the console as commands or variables.
IMPLEMENTATIONS NOTES: The console takes advantage of the script engine to store the console variables, this mean that all variables visible through script and console.
virtual ~IConsole();
virtual void AddCommand(const char * sCommand, ConsoleCommandFunc func, int nFlags = 0, const char * sHelp = NULL) = 0;
Parameters |
Description |
const char * sCommand |
Command name. |
ConsoleCommandFunc func |
Pointer to the console command function to be called when command is invoked. |
int nFlags = 0 |
Bitfield consist of VF_ flags (e.g. VF_CHEAT) |
const char * sHelp = NULL |
Help string, will be displayed when typing in console "command ?". |
Register a new console command.
virtual void AddCommand(const char * sName, const char * sScriptFunc, int nFlags = 0, const char * sHelp = NULL) = 0;
Parameters |
Description |
const char * sScriptFunc |
Script function to be executed when command is invoked. |
int nFlags = 0 |
Bitfield consist of VF_ flags (e.g. VF_CHEAT) |
const char * sHelp = NULL |
Help string, will be displayed when typing in console "command ?". |
sCommand |
Command name. |
Register a new console command that execute script function. EG "Game.Connect(%1)" the symbol "%1" will be replaced with the command parameter 1 writing in the console "connect 127.0.0.1" will invoke Game.Connect("127.0.0.1")
virtual void AddCommandToHistory(const char * szCommand) = 0;
! param szCommand must not be 0
virtual void AddConsoleVarSink(IConsoleVarSink * pSink) = 0;
Console variable sink. Adds a new console variables sink callback.
virtual void AddOutputPrintSink(IOutputPrintSink * inpSink) = 0;
add output sink (clases which are interested in the output) - order is not guaranteed @param inpSink must not be 0 and is not allowed to be added twice
virtual const char* AutoComplete(const char* substr) = 0;
virtual const char* AutoCompletePrev(const char* substr) = 0;
virtual void CalcCheatVarHash() = 0;
Calculate the hash from current cvars
virtual void Clear() = 0;
Clear the console text
virtual void CreateKeyBind(const char * sCmd, const char * sRes) = 0;
Bind a console command to a key @param sCmd console command that must be executed @param sRes name of the key to invoke the command
virtual void Draw() = 0;
Draw the console
virtual void DumpCVars(ICVarDumpSink * pCallback, unsigned int nFlagsFilter = 0) = 0;
Dump all console-variables to a callback-interface @param Callback callback-interface which needs to be called for each element
virtual void DumpKeyBinds(IKeyBindDumpSink * pCallback) = 0;
Dump all key bindings to a callback-interface @param Callback callback-interface which needs to be called for each element
virtual void EnableActivationKey(bool bEnable) = 0;
Enable or disable the activation key (tilde by default). This is useful when user is in a text field and want to be able to enter the default key. bEnable=true console will show bEnable=false console will no show
virtual void ExecuteString(const char * command, const bool bSilentMode = false, const bool bDeferExecution = false) = 0;
Parameters |
Description |
const char * command |
console command e.g. "map testy" - no leading slash |
const bool bSilentMode = false |
true=suppresses log in error case and logging the command to the console |
const bool bDeferExecution = false |
true=the command is stored in special fifo that allows delayed execution by using wait_seconds and wait_frames commands |
Execute a string in the console
virtual void Exit(const char * command, ...);
Print a message into the log and abort the execution of the application @param message error string to print in the log
virtual const char* FindKeyBind(const char * sCmd) const = 0;
virtual char* GetCheatVarAt(uint32 nOffset) = 0;
virtual uint64 GetCheatVarHash() = 0;
Get the hash calculated
virtual ICVar* GetCVar(const char * name) = 0;
virtual const char* GetHistoryElement(const bool bUpOrDown) = 0;
param bUpOrDown true=after pressed "up", false=after pressed "down" return 0 if there is no history line or pointer to the null terminated history line
virtual ITexture * GetImage() = 0;
Retrieves the background-image @return background-image
virtual int GetLineCount() const = 0;
return current number of lines in the console
virtual bool GetLineNo(const int indwLineNo, char * outszBuffer, const int indwBufferSize) const = 0;
Iterate through the lines - used for dedicated server (truncated if needed) @param indwLineNo 0.. counted from the last printed line on @param outszBuffer pointer to the destination string buffer (zero terminated afterwards), must not be 0 @param indwBufferSize 1.. size of the buffer @return true=line was returned, false=there are no more lines
virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0;
Calculation of the memory used by the whole console system
virtual int GetNumCheatVars() = 0;
Get Number of cvars that can be hashed
virtual int GetNumVars() = 0;
Auto completion.
virtual size_t GetSortedVars(const char ** pszArray, size_t numItems, const char * szPrefix = 0) = 0;
Parameters |
Description |
const char * szPrefix = 0 |
0 or prefix e.g. "sys_spec_" Return used size |
virtual bool GetStatus() = 0;
Retrieve the status of the console (active/not active) @return the variable value(true = active/false = not active)
virtual char * GetVariable(const char * szVarName, const char * szFileName, const char * def_val) = 0;
Read a value from a configuration file (.ini) and return the value @param szVarName variable name @param szFileName source configuration file @param def_val default value (if the variable is not found into the file) @return the variable value
virtual float GetVariable(const char * szVarName, const char * szFileName, float def_val) = 0;
Read a value from a configuration file (.ini) and return the value @param szVarName variable name @param szFileName source configuration file @param def_val default value (if the variable is not found into the file) @return the variable value
virtual bool IsHashCalculated() = 0;
Since hash is calculated async, check if it's completed
virtual bool IsOpened() = 0;
Return true if the console is opened @return the variable value(true = opened/false = closed)
virtual void LoadConfigVar(const char * sVariable, const char * sValue) = 0;
virtual void LoadInternalState(struct IDataReadStream& reader) = 0;
virtual void PrintCheatVars(bool bUseLastHashRange) = 0;
virtual void PrintLine(const char * s) = 0;
Print a string in the console and go to the new line @param s the string to print
virtual void PrintLinePlus(const char * s) = 0;
Append a string in the last console line @param s the string to print
virtual const char * ProcessCompletion(const char * szInputBuffer) = 0;
virtual ICVar * Register(const char * name, const char** src, const char* defaultvalue, int nFlags = 0, const char * help = "", ConsoleVarFunc pChangeFunc = 0, bool allowModify = true) = 0;
Parameters |
Description |
const char** src |
pointer to the memory that will be updated |
int nFlags = 0 |
user defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data) |
const char * help = "" |
help text that is shown when you use ? in the console |
bool allowModify = true |
allow modification through config vars, prevents missing modifications in release mode |
sName |
console variable name |
Return |
pointer to the interface ICVar |
Create a new console variable that will update the user defined pointer to null terminated string
virtual ICVar * Register(const char * name, float * src, float defaultvalue, int nFlags = 0, const char * help = "", ConsoleVarFunc pChangeFunc = 0, bool allowModify = true) = 0;
Parameters |
Description |
float * src |
pointer to the memory that will be updated |
int nFlags = 0 |
user defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data) |
const char * help = "" |
help text that is shown when you use ? in the console |
bool allowModify = true |
allow modification through config vars, prevents missing modifications in release mode |
sName |
console variable name |
Return |
pointer to the interface ICVar |
Create a new console variable that will update the user defined float
virtual ICVar * Register(const char * name, int * src, int defaultvalue, int nFlags = 0, const char * help = "", ConsoleVarFunc pChangeFunc = 0, bool allowModify = true) = 0;
Parameters |
Description |
int * src |
pointer to the memory that will be updated |
int nFlags = 0 |
user defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data) |
const char * help = "" |
help text that is shown when you use ? in the console |
bool allowModify = true |
allow modification through config vars, prevents missing modifications in release mode |
sName |
console variable name |
Return |
pointer to the interface ICVar |
Create a new console variable that will update the user defined integer
virtual void RegisterAutoComplete(const char * sVarOrCommand, IConsoleArgumentAutoComplete * pArgAutoComplete) = 0;
virtual ICVar * RegisterFloat(const char * sName, float fValue, int nFlags, const char * help = "", ConsoleVarFunc pChangeFunc = 0) = 0;
Parameters |
Description |
const char * sName |
console variable name |
float fValue |
default value |
int nFlags |
user defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data) |
const char * help = "" |
help text that is shown when you use ? in the console |
Return |
pointer to the interface ICVar |
Create a new console variable that store the value in a float
virtual ICVar * RegisterInt(const char * sName, int iValue, int nFlags, const char * help = "", ConsoleVarFunc pChangeFunc = 0) = 0;
Parameters |
Description |
const char * sName |
console variable name |
int iValue |
default value |
int nFlags |
user defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data) |
const char * help = "" |
help text that is shown when you use ? in the console |
Return |
pointer to the interface ICVar |
Create a new console variable that store the value in a int
virtual ICVar * RegisterInt64(const char * sName, int64 iValue, int nFlags, const char * help = "", ConsoleVarFunc pChangeFunc = 0) = 0;
Parameters |
Description |
const char * sName |
console variable name |
int64 iValue |
default value |
int nFlags |
user defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data) |
const char * help = "" |
help text that is shown when you use ? in the console |
Return |
pointer to the interface ICVar |
Create a new console variable that store the value in a int64
virtual ICVar * RegisterString(const char * sName, const char * sValue, int nFlags, const char * help = "", ConsoleVarFunc pChangeFunc = 0) = 0;
Parameters |
Description |
const char * sName |
console variable name |
const char * sValue |
default value |
int nFlags |
user defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data) |
const char * help = "" |
help text that is shown when you use ? in the console |
Return |
pointer to the interface ICVar |
Create a new console variable that store the value in a string
virtual void Release() = 0;
Deletes the console
virtual void RemoveCommand(const char * sName) = 0;
Parameters |
Description |
sCommand |
Command name |
Removes a console command which was previously registered with AddCommand.
virtual void RemoveConsoleVarSink(IConsoleVarSink * pSink) = 0;
! Removes a console variables sink callback.
virtual void RemoveOutputPrintSink(IOutputPrintSink * inpSink) = 0;
remove output sink (clases which are interested in the output) - order is not guaranteed @param inpSink must not be 0 and has to be added before
virtual void ResetAutoCompletion() = 0;
virtual void ResetProgressBar(int nProgressRange) = 0;
Function related to progress bar
virtual void SaveInternalState(struct IDataWriteStream& writer) const = 0;
Save/Load internal state (CVars) - used by LiveCreate
virtual void SetCheatVarHashRange(size_t firstVar, size_t lastVar) = 0;
Set the range of cvars
virtual void SetImage(ITexture * pImage, bool bDeleteCurrent) = 0;
Sets the background-image @param pImage background-image
virtual void SetInputLine(const char * szLine) = 0;
Parameters |
Description |
const char * szLine |
must not be 0 |
virtual void SetLoadingImage(const char * szFilename) = 0;
Sets the loading-background-image @param pImage background-image
virtual void SetScrollMax(int value) = 0;
Set the y coordinate where the console will stop to scroll when is dropped @param value y in screen coordinates
virtual void ShowConsole(bool show, const int iRequestScrollMax = -1) = 0;
show/hide the console @param specifies if the window must be (true=show,false=hide) @param specifies iRequestScrollMax <=0 if not used, otherwise it sets SetScrollMax temporary to the given value
virtual void StaticBackground(bool bStatic) = 0;
Sets static/scroll background-mode @param bStatic true if static
virtual void TickProgressBar() = 0;
Function related to progress bar
virtual void UnRegisterAutoComplete(const char * sVarOrCommand) = 0;
virtual void UnregisterVariable(const char * sVarName, bool bDelete = false) = 0;
! Remove a variable from the console @param sVarName console variable name @param bDelete if true the variable is deleted @see ICVar
virtual void Update() = 0;
Update the console