IConsole

#include

Public Member Functions

virtual void Release ()=0
Deletes the console.
virtual void UnregisterVariable (const char *sVarName, bool bDelete=false)=0
virtual void SetScrollMax (int value)=0
virtual void AddOutputPrintSink (IOutputPrintSink *inpSink)=0
virtual void RemoveOutputPrintSink (IOutputPrintSink *inpSink)=0
virtual void ShowConsole (bool show, const int iRequestScrollMax=-1)=0
virtual void DumpCVars (ICVarDumpSink *pCallback, unsigned int nFlagsFilter=0)=0
virtual void CreateKeyBind (const char *sCmd, const char *sRes)=0
virtual void SetImage (ITexture *pImage, bool bDeleteCurrent)=0
virtual ITexture * GetImage ()=0
virtual void StaticBackground (bool bStatic)=0
virtual void SetLoadingImage (const char *szFilename)=0
virtual bool GetLineNo (const int indwLineNo, char *outszBuffer, const int indwBufferSize) const =0
virtual int GetLineCount () const =0
virtual ICVar * GetCVar (const char *name)=0
virtual char * GetVariable (const char *szVarName, const char *szFileName, const char *def_val)=0
virtual float GetVariable (const char *szVarName, const char *szFileName, float def_val)=0
virtual void PrintLine (const char *s)=0
virtual void PrintLinePlus (const char *s)=0
virtual bool GetStatus ()=0
virtual void Clear ()=0
Clear the console text.
virtual void Update ()=0
Update the console.
virtual void Draw ()=0
Draw the console.
virtual void RegisterListener (IManagedConsoleCommandListener *pListener, const char *name)=0
virtual void UnregisterListener (IManagedConsoleCommandListener *pListener)=0
virtual void RemoveCommand (const char *sName)=0
virtual void ExecuteString (const char *command, const bool bSilentMode=false, const bool bDeferExecution=false)=0
virtual void Exit (const char *command,...) PRINTF_PARAMS(2
virtual void virtual bool IsOpened ()=0
virtual size_t GetNumVars (bool bIncludeCommands=false) const =0
Auto completion.
virtual size_t GetSortedVars (const char **pszArray, size_t numItems, const char *szPrefix=0, int nListTypes=0) const =0
virtual const char * AutoComplete (const char *substr)=0
virtual const char * AutoCompletePrev (const char *substr)=0
virtual const char * ProcessCompletion (const char *szInputBuffer)=0
virtual void RegisterAutoComplete (const char *sVarOrCommand, IConsoleArgumentAutoComplete *pArgAutoComplete)=0
virtual void UnRegisterAutoComplete (const char *sVarOrCommand)=0
virtual void ResetAutoCompletion ()=0
virtual void GetMemoryUsage (ICrySizer *pSizer) const =0
Calculation of the memory used by the whole console system.
virtual void ResetProgressBar (int nProgressRange)=0
Function related to progress bar.
virtual void TickProgressBar ()=0
Function related to progress bar.
virtual void SetInputLine (const char *szLine)=0
virtual void SetReadOnly (bool readonly)=0
Set Console Editable.
virtual bool IsReadOnly ()=0
virtual void DumpKeyBinds (IKeyBindDumpSink *pCallback)=0
virtual const char * FindKeyBind (const char *sCmd) const =0
virtual int GetNumCheatVars ()=0
Get Number of cvars that can be hashed.
virtual void SetCheatVarHashRange (size_t firstVar, size_t lastVar)=0
Set the range of cvars.
virtual void CalcCheatVarHash ()=0
Calculate the hash from current cvars.
virtual bool IsHashCalculated ()=0
Since hash is calculated async, check if it's completed.
virtual uint64 GetCheatVarHash ()=0
Get the hash calculated.
virtual void PrintCheatVars (bool bUseLastHashRange)=0
virtual char * GetCheatVarAt (uint32 nOffset)=0
virtual void AddConsoleVarSink (IConsoleVarSink *pSink)=0
virtual void RemoveConsoleVarSink (IConsoleVarSink *pSink)=0
Removes a console variables sink callback.
virtual const char * GetHistoryElement (const bool bUpOrDown)=0
virtual void AddCommandToHistory (const char *szCommand)=0
virtual void LoadConfigVar (const char *sVariable, const char *sValue)=0
virtual void LoadConfigCommand (const char *szCommand, const char *szArguments=nullptr)=0
virtual ELoadConfigurationType SetCurrentConfigType (ELoadConfigurationType configType)=0
virtual void EnableActivationKey (bool bEnable)=0
virtual void SaveInternalState (struct IDataWriteStream &writer) const =0
Save/Load internal state (CVars) - used by LiveCreate.
virtual void LoadInternalState (struct IDataReadStream &reader)=0

Protected Member Functions

virtual void AddCommand (const char *sCommand, ConsoleCommandFunc func, int nFlags=0, const char *sHelp=NULL, bool bIsManaged=false)=0
virtual void AddCommand (const char *sName, const char *sScriptFunc, int nFlags=0, const char *sHelp=NULL)=0
virtual ICVar * RegisterString (const char *sName, const char *sValue, int nFlags, const char *help="", ConsoleVarFunc pChangeFunc=0)=0
virtual ICVar * RegisterInt (const char *sName, int iValue, int nFlags, const char *help="", ConsoleVarFunc pChangeFunc=0)=0
virtual ICVar * RegisterInt64 (const char *sName, int64 iValue, int nFlags, const char *help="", ConsoleVarFunc pChangeFunc=0)=0
virtual ICVar * RegisterFloat (const char *sName, float fValue, int nFlags, const char *help="", ConsoleVarFunc pChangeFunc=0)=0
virtual ICVar * Register (const char *name, float *src, float defaultvalue, int nFlags=0, const char *help="", ConsoleVarFunc pChangeFunc=0, bool allowModify=true)=0
virtual ICVar * Register (const char *name, int *src, int defaultvalue, int nFlags=0, const char *help="", ConsoleVarFunc pChangeFunc=0, bool allowModify=true)=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
virtual ICVar * Register (ICVar *pVar)=0

Friends

struct ConsoleRegistrationHelper

Detailed Description

Interface to the engine console. 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.

Note
The console takes advantage of the script engine to store the console variables, this mean that all variables visible through script and console.

Member Function Documentation

◆ AddCommand() [1/2]

virtual void IConsole::AddCommand ( const char * sCommand,
ConsoleCommandFunc func,
int nFlags = 0,
const char * sHelp = NULL,
bool bIsManaged = false
)
protected
pure virtual

Register a new console command.

Parameters
sCommandCommand name.
funcPointer to the console command function to be called when command is invoked.
nFlagsBitfield consisting of VF_ flags (e.g. VF_CHEAT).
sHelpHelp string, will be displayed when typing in console "command ?".
#include 

// The function that will be executed with the command
void MyCommand(IConsoleCmdArgs* pArgs)
{
    // The first argument is always the name of the command
    const char* szCommand = pArgs->GetArg(0);
    if (pArgs->GetArgCount() > 1)
    {
        // Get the first argument, if any
        const char* szFirstArgument = pArgs->GetArg(1);

        /* Handle the command, and its argument here */
    }
}

void RegisterCommand()
{
    // Specify bit flags that define the CCommand's behavior, see EVarFlags
    const int variableFlags = VF_NULL;

    // Register the command in the console
    REGISTER_COMMAND("myCommand", MyCommand, variableFlags, "Executes the MyCommand function!");
}

void UnregisterCommand()
{
    // Make sure to unregister the command once we are done
    gEnv->pConsole->RemoveCommand("myCommand");
}

void ExecuteCommand()
{
    // Do not silence execution of the command from logs
    const bool silent = false;
    // Execute the command immediately, instead of the next frame
    const bool deferExecution = false;

    gEnv->pConsole->ExecuteString("myCommand", silent, deferExecution);
}

◆ AddCommand() [2/2]

virtual void IConsole::AddCommand ( const char * sName,
const char * sScriptFunc,
int nFlags = 0,
const char * sHelp = NULL
)
protected
pure virtual

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").

Parameters
sCommandCommand name.
sScriptFuncScript function to be executed when command is invoked.
nFlagsBitfield consist of VF_ flags (e.g. VF_CHEAT).
sHelpHelp string, will be displayed when typing in console "command ?".
#include 

// The function that will be executed with the command
void MyCommand(IConsoleCmdArgs* pArgs)
{
    // The first argument is always the name of the command
    const char* szCommand = pArgs->GetArg(0);
    if (pArgs->GetArgCount() > 1)
    {
        // Get the first argument, if any
        const char* szFirstArgument = pArgs->GetArg(1);

        /* Handle the command, and its argument here */
    }
}

void RegisterCommand()
{
    // Specify bit flags that define the CCommand's behavior, see EVarFlags
    const int variableFlags = VF_NULL;

    // Register the command in the console
    REGISTER_COMMAND("myCommand", MyCommand, variableFlags, "Executes the MyCommand function!");
}

void UnregisterCommand()
{
    // Make sure to unregister the command once we are done
    gEnv->pConsole->RemoveCommand("myCommand");
}

void ExecuteCommand()
{
    // Do not silence execution of the command from logs
    const bool silent = false;
    // Execute the command immediately, instead of the next frame
    const bool deferExecution = false;

    gEnv->pConsole->ExecuteString("myCommand", silent, deferExecution);
}

◆ AddCommandToHistory()

virtual void IConsole::AddCommandToHistory ( const char * szCommand)
pure virtual
Parameters
szCommandMust not be 0.

◆ AddConsoleVarSink()

virtual void IConsole::AddConsoleVarSink ( IConsoleVarSink * pSink)
pure virtual

Console variable sink. Adds a new console variables sink callback.

◆ AddOutputPrintSink()

virtual void IConsole::AddOutputPrintSink ( IOutputPrintSink * inpSink)
pure virtual

Add output sink (clases which are interested in the output) - order is not guaranteed.

Parameters
inpSinkMust not be 0 and is not allowed to be added twice.

◆ CreateKeyBind()

virtual void IConsole::CreateKeyBind ( const char * sCmd,
const char * sRes
)
pure virtual

Bind a console command to a key.

Parameters
sCmdconsole command that must be executed.
sResname of the key to invoke the command.

◆ DumpCVars()

virtual void IConsole::DumpCVars ( ICVarDumpSink * pCallback,
unsigned int nFlagsFilter = 0
)
pure virtual

Dump all console-variables to a callback-interface.

Parameters
CallbackCallback-interface which needs to be called for each element.

◆ DumpKeyBinds()

virtual void IConsole::DumpKeyBinds ( IKeyBindDumpSink * pCallback)
pure virtual

Dump all key bindings to a callback-interface.

Parameters
Callbackcallback-interface which needs to be called for each element.

◆ EnableActivationKey()

virtual void IConsole::EnableActivationKey ( bool bEnable)
pure virtual

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.

Parameters
BEnableIf true, console will show.

◆ ExecuteString()

virtual void IConsole::ExecuteString ( const char * command,
const bool bSilentMode = false,
const bool bDeferExecution = false
)
pure virtual

Execute a string in the console.

Parameters
commandConsole command e.g. "map testy" - no leading slash
bSilentModetrue=suppresses log in error case and logging the command to the console
bDeferExecutiontrue=the command is stored in special fifo that allows delayed execution by using wait_seconds and wait_frames commands
#include 

// The function that will be executed with the command
void MyCommand(IConsoleCmdArgs* pArgs)
{
    // The first argument is always the name of the command
    const char* szCommand = pArgs->GetArg(0);
    if (pArgs->GetArgCount() > 1)
    {
        // Get the first argument, if any
        const char* szFirstArgument = pArgs->GetArg(1);

        /* Handle the command, and its argument here */
    }
}

void RegisterCommand()
{
    // Specify bit flags that define the CCommand's behavior, see EVarFlags
    const int variableFlags = VF_NULL;

    // Register the command in the console
    REGISTER_COMMAND("myCommand", MyCommand, variableFlags, "Executes the MyCommand function!");
}

void UnregisterCommand()
{
    // Make sure to unregister the command once we are done
    gEnv->pConsole->RemoveCommand("myCommand");
}

void ExecuteCommand()
{
    // Do not silence execution of the command from logs
    const bool silent = false;
    // Execute the command immediately, instead of the next frame
    const bool deferExecution = false;

    gEnv->pConsole->ExecuteString("myCommand", silent, deferExecution);
}

◆ Exit()

virtual void IConsole::Exit ( const char * command,
...
)
virtual

Print a message into the log and abort the execution of the application.

Parameters
messageerror string to print in the log.

◆ GetCVar()

virtual ICVar* IConsole::GetCVar ( const char * name)
pure virtual

Retrieve a console variable by name - not case sensitive.

Parameters
namevariable name.
Returns
a pointer to the ICVar interface, NULL if is not found.
See also
ICVar.
#include 

// Minimal example of how a console variable can be implemented and used
// In this case we create a system, and a variable that determines whether or not the system should be currently updated
class CMySystem
{
    CMySystem()
    {
        // Specify bit flags that define the CVar's behavior, see EVarFlags
        const int variableFlags = VF_NULL;

        // Register the "g_mySystem_enable" command into the console, allowing modification by designers and code at run-time
        REGISTER_CVAR2("g_mySystem_enable", &m_enabled, m_enabled, variableFlags, "Determines whether or not the system should run");

        // Retrieve an ICVar instance for the variable from the console
        ICVar* pCVar = gEnv->pConsole->GetCVar("g_mySystem_enable");
        /* If necessary, utilize pCVar here */
    }

    ~CMySystem()
    {
        // Make sure to unregister the variable once we go out of scope
        gEnv->pConsole->UnregisterVariable("g_mySystem_enable");
    }

    void Update()
    {
        // If the system was disabled via the console, skip update
        if (m_enabled == 0)
        {
            return;
        }

        /* Update system here */
    }

protected:
    // Store the variable locally here, the console takes a reference that will update the variable in place
    // We start off by setting this value to 1.
    int m_enabled = 1;
};

◆ GetHistoryElement()

virtual const char* IConsole::GetHistoryElement ( const bool bUpOrDown)
pure virtual
Parameters
bUpOrDowntrue=after pressed "up", false=after pressed "down".
Returns
0 if there is no history line or pointer to the null terminated history line.

◆ GetImage()

virtual ITexture* IConsole::GetImage ( )
pure virtual

Retrieves the background-image.

Returns
background-image.

◆ GetLineCount()

virtual int IConsole::GetLineCount ( ) const
pure virtual
Returns
Current number of lines in the console.

◆ GetLineNo()

virtual bool IConsole::GetLineNo ( const int indwLineNo,
char * outszBuffer,
const int indwBufferSize
) const
pure virtual

Iterate through the lines - used for dedicated server (truncated if needed).

Parameters
indwLineNo0.. counted from the last printed line on.
outszBufferPointer to the destination string buffer (zero terminated afterwards), must not be 0.
indwBufferSize1.. size of the buffer.
Returns
true if line was returned, false=there are no more lines.

◆ GetSortedVars()

virtual size_t IConsole::GetSortedVars ( const char ** pszArray,
size_t numItems,
const char * szPrefix = 0,
int nListTypes = 0
) const
pure virtual
Parameters
szPrefix- 0 or prefix e.g. "sys_spec_".
Returns
Used size. nListType = 0 get all values, nListTypes=1 return only cvars, nListTypes=2 return only console commands

◆ GetStatus()

virtual bool IConsole::GetStatus ( )
pure virtual

Retrieve the status of the console (active/not active).

Returns
the variable value(true = active/false = not active).

◆ GetVariable() [1/2]

virtual char* IConsole::GetVariable ( const char * szVarName,
const char * szFileName,
const char * def_val
)
pure virtual

Read a value from a configuration file (.ini) and return the value.

Parameters
szVarNameVariable name.
szFileNameSource configuration file.
def_valDefault value (if the variable is not found into the file).
Returns
The variable value.

◆ GetVariable() [2/2]

virtual float IConsole::GetVariable ( const char * szVarName,
const char * szFileName,
float def_val
)
pure virtual

Read a value from a configuration file (.ini) and return the value.

Parameters
szVarNamevariable name.
szFileNamesource configuration file.
def_valdefault value (if the variable is not found into the file).
Returns
the variable value.

◆ IsOpened()

virtual void virtual bool IConsole::IsOpened ( )
pure virtual

Return true if the console is opened.

Returns
the variable value(true = opened/false = closed).

◆ LoadConfigCommand()

virtual void IConsole::LoadConfigCommand ( const char * szCommand,
const char * szArguments = nullptr
)
pure virtual

Executes a command with optional arguments Will defer setting of the value until the command is registered if it hasn't been already

◆ LoadConfigVar()

virtual void IConsole::LoadConfigVar ( const char * sVariable,
const char * sValue
)
pure virtual

Sets the value of a CVar as loaded from a config Will defer setting of the value until the CVar is registered if it hasn't been already

◆ PrintLine()

virtual void IConsole::PrintLine ( const char * s)
pure virtual

Print a string in the console and go to the new line.

Parameters
sThe string to print.

◆ PrintLinePlus()

virtual void IConsole::PrintLinePlus ( const char * s)
pure virtual

Append a string in the last console line.

Parameters
sThe string to print.

◆ Register() [1/4]

virtual ICVar* IConsole::Register ( const char * name,
float * src,
float defaultvalue,
int nFlags = 0,
const char * help = "",
ConsoleVarFunc pChangeFunc = 0,
bool allowModify = true
)
protected
pure virtual

Create a new console variable that will update the user defined float.

Parameters
sNameConsole variable name.
srcPointer to the memory that will be updated.
nFlagsUser defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data).
helpHelp text that is shown when you use " ?" in the console.
allowModifyAllow modification through config vars, prevents missing modifications in release mode.
Returns
pointer to the interface ICVar.
#include 

// Minimal example of how a console variable can be implemented and used
// In this case we create a system, and a variable that determines whether or not the system should be currently updated
class CMySystem
{
    CMySystem()
    {
        // Specify bit flags that define the CVar's behavior, see EVarFlags
        const int variableFlags = VF_NULL;

        // Register the "g_mySystem_enable" command into the console, allowing modification by designers and code at run-time
        REGISTER_CVAR2("g_mySystem_enable", &m_enabled, m_enabled, variableFlags, "Determines whether or not the system should run");

        // Retrieve an ICVar instance for the variable from the console
        ICVar* pCVar = gEnv->pConsole->GetCVar("g_mySystem_enable");
        /* If necessary, utilize pCVar here */
    }

    ~CMySystem()
    {
        // Make sure to unregister the variable once we go out of scope
        gEnv->pConsole->UnregisterVariable("g_mySystem_enable");
    }

    void Update()
    {
        // If the system was disabled via the console, skip update
        if (m_enabled == 0)
        {
            return;
        }

        /* Update system here */
    }

protected:
    // Store the variable locally here, the console takes a reference that will update the variable in place
    // We start off by setting this value to 1.
    int m_enabled = 1;
};

◆ Register() [2/4]

virtual ICVar* IConsole::Register ( const char * name,
int * src,
int defaultvalue,
int nFlags = 0,
const char * help = "",
ConsoleVarFunc pChangeFunc = 0,
bool allowModify = true
)
protected
pure virtual

Create a new console variable that will update the user defined float.

Parameters
sNameConsole variable name.
srcPointer to the memory that will be updated.
nFlagsUser defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data).
helpHelp text that is shown when you use " ?" in the console.
allowModifyAllow modification through config vars, prevents missing modifications in release mode.
Returns
pointer to the interface ICVar.
#include 

// Minimal example of how a console variable can be implemented and used
// In this case we create a system, and a variable that determines whether or not the system should be currently updated
class CMySystem
{
    CMySystem()
    {
        // Specify bit flags that define the CVar's behavior, see EVarFlags
        const int variableFlags = VF_NULL;

        // Register the "g_mySystem_enable" command into the console, allowing modification by designers and code at run-time
        REGISTER_CVAR2("g_mySystem_enable", &m_enabled, m_enabled, variableFlags, "Determines whether or not the system should run");

        // Retrieve an ICVar instance for the variable from the console
        ICVar* pCVar = gEnv->pConsole->GetCVar("g_mySystem_enable");
        /* If necessary, utilize pCVar here */
    }

    ~CMySystem()
    {
        // Make sure to unregister the variable once we go out of scope
        gEnv->pConsole->UnregisterVariable("g_mySystem_enable");
    }

    void Update()
    {
        // If the system was disabled via the console, skip update
        if (m_enabled == 0)
        {
            return;
        }

        /* Update system here */
    }

protected:
    // Store the variable locally here, the console takes a reference that will update the variable in place
    // We start off by setting this value to 1.
    int m_enabled = 1;
};

◆ Register() [3/4]

virtual ICVar* IConsole::Register ( const char * name,
const char ** src,
const char * defaultvalue,
int nFlags = 0,
const char * help = "",
ConsoleVarFunc pChangeFunc = 0,
bool allowModify = true
)
protected
pure virtual

Create a new console variable that will update the user defined float.

Parameters
sNameConsole variable name.
srcPointer to the memory that will be updated.
nFlagsUser defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data).
helpHelp text that is shown when you use " ?" in the console.
allowModifyAllow modification through config vars, prevents missing modifications in release mode.
Returns
pointer to the interface ICVar.
#include 

// Minimal example of how a console variable can be implemented and used
// In this case we create a system, and a variable that determines whether or not the system should be currently updated
class CMySystem
{
    CMySystem()
    {
        // Specify bit flags that define the CVar's behavior, see EVarFlags
        const int variableFlags = VF_NULL;

        // Register the "g_mySystem_enable" command into the console, allowing modification by designers and code at run-time
        REGISTER_CVAR2("g_mySystem_enable", &m_enabled, m_enabled, variableFlags, "Determines whether or not the system should run");

        // Retrieve an ICVar instance for the variable from the console
        ICVar* pCVar = gEnv->pConsole->GetCVar("g_mySystem_enable");
        /* If necessary, utilize pCVar here */
    }

    ~CMySystem()
    {
        // Make sure to unregister the variable once we go out of scope
        gEnv->pConsole->UnregisterVariable("g_mySystem_enable");
    }

    void Update()
    {
        // If the system was disabled via the console, skip update
        if (m_enabled == 0)
        {
            return;
        }

        /* Update system here */
    }

protected:
    // Store the variable locally here, the console takes a reference that will update the variable in place
    // We start off by setting this value to 1.
    int m_enabled = 1;
};

◆ Register() [4/4]

virtual ICVar* IConsole::Register ( ICVar * pVar)
protected
pure virtual

Registers an existing console variable. Should only be used with static duration objects, object is never freed.

Parameters
pVarThe existing console variable.
Returns
Pointer to the interface ICVar (that was passed in)

◆ RegisterFloat()

virtual ICVar* IConsole::RegisterFloat ( const char * sName,
float fValue,
int nFlags,
const char * help = "",
ConsoleVarFunc pChangeFunc = 0
)
protected
pure virtual

Create a new console variable that store the value in a float.

Parameters
sNameConsole variable name.
fValueDefault value.
nFlagsUser defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data).
helphelp text that is shown when you use " ?" in the console.
Returns
Pointer to the interface ICVar.
#include 

// Minimal example of how a console variable can be implemented and used
// In this case we create a system, and a variable that determines whether or not the system should be currently updated
class CMySystem
{
    CMySystem()
    {
        // Specify bit flags that define the CVar's behavior, see EVarFlags
        const int variableFlags = VF_NULL;

        // Register the "g_mySystem_enable" command into the console, allowing modification by designers and code at run-time
        REGISTER_CVAR2("g_mySystem_enable", &m_enabled, m_enabled, variableFlags, "Determines whether or not the system should run");

        // Retrieve an ICVar instance for the variable from the console
        ICVar* pCVar = gEnv->pConsole->GetCVar("g_mySystem_enable");
        /* If necessary, utilize pCVar here */
    }

    ~CMySystem()
    {
        // Make sure to unregister the variable once we go out of scope
        gEnv->pConsole->UnregisterVariable("g_mySystem_enable");
    }

    void Update()
    {
        // If the system was disabled via the console, skip update
        if (m_enabled == 0)
        {
            return;
        }

        /* Update system here */
    }

protected:
    // Store the variable locally here, the console takes a reference that will update the variable in place
    // We start off by setting this value to 1.
    int m_enabled = 1;
};

◆ RegisterInt()

virtual ICVar* IConsole::RegisterInt ( const char * sName,
int iValue,
int nFlags,
const char * help = "",
ConsoleVarFunc pChangeFunc = 0
)
protected
pure virtual

Create a new console variable that store the value in a int.

Parameters
sNameConsole variable name.
iValueDefault value.
nFlagsUser defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data).
Helphelp text that is shown when you use " ?" in the console.
Returns
Pointer to the interface ICVar.
#include 

// Minimal example of how a console variable can be implemented and used
// In this case we create a system, and a variable that determines whether or not the system should be currently updated
class CMySystem
{
    CMySystem()
    {
        // Specify bit flags that define the CVar's behavior, see EVarFlags
        const int variableFlags = VF_NULL;

        // Register the "g_mySystem_enable" command into the console, allowing modification by designers and code at run-time
        REGISTER_CVAR2("g_mySystem_enable", &m_enabled, m_enabled, variableFlags, "Determines whether or not the system should run");

        // Retrieve an ICVar instance for the variable from the console
        ICVar* pCVar = gEnv->pConsole->GetCVar("g_mySystem_enable");
        /* If necessary, utilize pCVar here */
    }

    ~CMySystem()
    {
        // Make sure to unregister the variable once we go out of scope
        gEnv->pConsole->UnregisterVariable("g_mySystem_enable");
    }

    void Update()
    {
        // If the system was disabled via the console, skip update
        if (m_enabled == 0)
        {
            return;
        }

        /* Update system here */
    }

protected:
    // Store the variable locally here, the console takes a reference that will update the variable in place
    // We start off by setting this value to 1.
    int m_enabled = 1;
};

◆ RegisterInt64()

virtual ICVar* IConsole::RegisterInt64 ( const char * sName,
int64 iValue,
int nFlags,
const char * help = "",
ConsoleVarFunc pChangeFunc = 0
)
protected
pure virtual

Create a new console variable that store the value in a int64.

Parameters
sNameConsole variable name.
iValueDefault value.
nFlagsHer defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data).
help- help text that is shown when you use " ?" in the console.
Returns
Pointer to the interface ICVar.
#include 

// Minimal example of how a console variable can be implemented and used
// In this case we create a system, and a variable that determines whether or not the system should be currently updated
class CMySystem
{
    CMySystem()
    {
        // Specify bit flags that define the CVar's behavior, see EVarFlags
        const int variableFlags = VF_NULL;

        // Register the "g_mySystem_enable" command into the console, allowing modification by designers and code at run-time
        REGISTER_CVAR2("g_mySystem_enable", &m_enabled, m_enabled, variableFlags, "Determines whether or not the system should run");

        // Retrieve an ICVar instance for the variable from the console
        ICVar* pCVar = gEnv->pConsole->GetCVar("g_mySystem_enable");
        /* If necessary, utilize pCVar here */
    }

    ~CMySystem()
    {
        // Make sure to unregister the variable once we go out of scope
        gEnv->pConsole->UnregisterVariable("g_mySystem_enable");
    }

    void Update()
    {
        // If the system was disabled via the console, skip update
        if (m_enabled == 0)
        {
            return;
        }

        /* Update system here */
    }

protected:
    // Store the variable locally here, the console takes a reference that will update the variable in place
    // We start off by setting this value to 1.
    int m_enabled = 1;
};

◆ RegisterString()

virtual ICVar* IConsole::RegisterString ( const char * sName,
const char * sValue,
int nFlags,
const char * help = "",
ConsoleVarFunc pChangeFunc = 0
)
protected
pure virtual

Create a new console variable that store the value in a string.

Parameters
sNameConsole variable name.
sValueDefault value.
nFlagsUser defined flag, this parameter is used by other subsystems and doesn't affect the console variable (basically of user data).
helpHelp text that is shown when you use " ?" in the console.
Returns
Pointer to the interface ICVar.

◆ RemoveCommand()

virtual void IConsole::RemoveCommand ( const char * sName)
pure virtual

Removes a console command which was previously registered with AddCommand.

Parameters
sCommandCommand name.
#include 

// The function that will be executed with the command
void MyCommand(IConsoleCmdArgs* pArgs)
{
    // The first argument is always the name of the command
    const char* szCommand = pArgs->GetArg(0);
    if (pArgs->GetArgCount() > 1)
    {
        // Get the first argument, if any
        const char* szFirstArgument = pArgs->GetArg(1);

        /* Handle the command, and its argument here */
    }
}

void RegisterCommand()
{
    // Specify bit flags that define the CCommand's behavior, see EVarFlags
    const int variableFlags = VF_NULL;

    // Register the command in the console
    REGISTER_COMMAND("myCommand", MyCommand, variableFlags, "Executes the MyCommand function!");
}

void UnregisterCommand()
{
    // Make sure to unregister the command once we are done
    gEnv->pConsole->RemoveCommand("myCommand");
}

void ExecuteCommand()
{
    // Do not silence execution of the command from logs
    const bool silent = false;
    // Execute the command immediately, instead of the next frame
    const bool deferExecution = false;

    gEnv->pConsole->ExecuteString("myCommand", silent, deferExecution);
}

◆ RemoveOutputPrintSink()

virtual void IConsole::RemoveOutputPrintSink ( IOutputPrintSink * inpSink)
pure virtual

Remove output sink (clases which are interested in the output) - order is not guaranteed.

Parameters
inpSinkMust not be 0 and has to be added before.

◆ SetImage()

virtual void IConsole::SetImage ( ITexture * pImage,
bool bDeleteCurrent
)
pure virtual

Sets the background-image.

Parameters
pImagebackground-image.

◆ SetInputLine()

virtual void IConsole::SetInputLine ( const char * szLine)
pure virtual
Parameters
szLineMust not be 0.

◆ SetLoadingImage()

virtual void IConsole::SetLoadingImage ( const char * szFilename)
pure virtual

Sets the loading-background-image.

Parameters
pImageBackground image.

◆ SetScrollMax()

virtual void IConsole::SetScrollMax ( int value)
pure virtual

Set the y coordinate where the console will stop to scroll when is dropped.

Parameters
valueY in screen coordinates.

◆ ShowConsole()

virtual void IConsole::ShowConsole ( bool show,
const int iRequestScrollMax = -1
)
pure virtual

Show/hide the console.

Parameters
specifiesif the window must be (true=show,false=hide).
specifiesiRequestScrollMax <=0 if not used, otherwise it sets SetScrollMax temporary to the given value.

◆ StaticBackground()

virtual void IConsole::StaticBackground ( bool bStatic)
pure virtual

Sets static/scroll background-mode.

Parameters
bStatictrue if static.

◆ UnregisterVariable()

virtual void IConsole::UnregisterVariable ( const char * sVarName,
bool bDelete = false
)
pure virtual

Remove a variable from the console.

Parameters
sVarNameConsole variable name.
bDeleteIf true, the variable is deleted.
See also
ICVar.
#include 

// Minimal example of how a console variable can be implemented and used
// In this case we create a system, and a variable that determines whether or not the system should be currently updated
class CMySystem
{
    CMySystem()
    {
        // Specify bit flags that define the CVar's behavior, see EVarFlags
        const int variableFlags = VF_NULL;

        // Register the "g_mySystem_enable" command into the console, allowing modification by designers and code at run-time
        REGISTER_CVAR2("g_mySystem_enable", &m_enabled, m_enabled, variableFlags, "Determines whether or not the system should run");

        // Retrieve an ICVar instance for the variable from the console
        ICVar* pCVar = gEnv->pConsole->GetCVar("g_mySystem_enable");
        /* If necessary, utilize pCVar here */
    }

    ~CMySystem()
    {
        // Make sure to unregister the variable once we go out of scope
        gEnv->pConsole->UnregisterVariable("g_mySystem_enable");
    }

    void Update()
    {
        // If the system was disabled via the console, skip update
        if (m_enabled == 0)
        {
            return;
        }

        /* Update system here */
    }

protected:
    // Store the variable locally here, the console takes a reference that will update the variable in place
    // We start off by setting this value to 1.
    int m_enabled = 1;
};