IConsoleManager
- Module
- Core
- Header
#include "Core/IConsoleManager.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
using FConsoleCommandHandler = std::function<void(const std::vector<std::string>& args)> | Console COMMANDS, as opposed to variables: log LogRender Verbose, stat unit. A command owns its arguments — the manager only splits the line on whitespace and hands the tail over. |
Public functions
| Returns | Name | Description |
|---|---|---|
IConsoleManager& | Get | |
TConsoleVariable<T> | MakeConsoleVar | |
void | SetCheatsAllowed | Off in release, on everywhere else. |
bool | AreCheatsAllowed | |
bool | IsSettableFromOutside | Whether the console and the command line may write this cvar right now. |
const char* | DescribeSetBy | |
IConsoleVariable* | FindByName | nullptr if not registered. |
bool | SetByName | Parses value according to the cvar's runtime type, as setBy. |
bool | ResetToDefaultByName | Restore the cvar to the default it registered with, and its source to Constructor, whoever set it. |
void | ForEach | |
void | ApplyCommandLineArgs | Apply --cvar key=value entries from FCommandLine. |
bool | HasCommandLineCVar | Whether the command line carries an explicit --cvar=<name>=.... |
void | ApplyConfig | Apply every entry under the config's "cvars" section (dotted CVar names are reassembled from nested section nodes), plus [ConsoleVariables] and [ScalabilityGroups], as setBy. |
void | Register | Called by the cvar's ctor. |
size_t | GetRememberedValueCount | How many remembered settings values wait for (or were replayed to) a cvar of this name. |
void | Unregister | |
void | RegisterCommand | owner names the registering module (see FModuleAnchor): its commands leave with it on unload instead of dangling into freed code. |
void | UnregisterCommand | |
size_t | RemoveCommandsInModule | |
bool | HasCommand | |
void | ForEachCommand | |
bool | Execute | Run one console line. |
Function details
Get
static IConsoleManager& Get()MakeConsoleVar
template<typename T> static TConsoleVariable<T> MakeConsoleVar(const char* name, T defaultValue, const char* helpText, EConsoleVariableFlags flags = EConsoleVariableFlags::None)SetCheatsAllowed
static void SetCheatsAllowed(bool allowed)Off in release, on everywhere else. A game can turn cheats on for a local session or an admin; the test harness turns them off to check the refusal on a build that is not release.
AreCheatsAllowed
static bool AreCheatsAllowed()IsSettableFromOutside
static bool IsSettableFromOutside(const IConsoleVariable& var)Whether the console and the command line may write this cvar right now. Execute and the command-line pass answer false for one that may not; a console UI asks here to say why.
DescribeSetBy
static const char* DescribeSetBy(ECVarSetBy setBy)FindByName
IConsoleVariable* FindByName(std::string_view name) constnullptr if not registered.
SetByName
bool SetByName(std::string_view name, std::string_view value, ECVarSetBy setBy = ECVarSetBy::Code)Parses value according to the cvar's runtime type, as setBy. False if the cvar isn't registered, the value does not parse, or a higher source holds the cvar. A settings source (Scalability, DeviceProfile, GameSetting, ProjectSetting) is also remembered, registered or not, and replayed when a cvar of that name registers — that is how a plugin's or a game module's cvar gets its INI value.
ResetToDefaultByName
bool ResetToDefaultByName(std::string_view name)Restore the cvar to the default it registered with, and its source to Constructor, whoever set it. False if the cvar isn't registered. Used when a settings tier drops an override so the live value follows, and by anything that hands a cvar back to automatic control ("-1 = follow the tier"). The remembered settings values for it are forgotten too.
ForEach
void ForEach(const std::function<void(const std::string&, IConsoleVariable*)>& visitor) constApplyCommandLineArgs
void ApplyCommandLineArgs()Apply --cvar key=value entries from FCommandLine. Call after FCommandLine::Set + after every cvar has registered (typically late in Engine::Initialize).
HasCommandLineCVar
static bool HasCommandLineCVar(std::string_view name)Whether the command line carries an explicit --cvar=<name>=.... For code that force-sets a cvar after the command line has already been applied and must not silently outrank an explicit request. Answering this by re-running ApplyCommandLineArgs would work but re-fires every OTHER cvar's change callback at a point in startup it was not written for, which is a much bigger hammer than the question deserves.
ApplyConfig
void ApplyConfig(const class Config& config, ECVarSetBy setBy = ECVarSetBy::ProjectSetting)Apply every entry under the config's "cvars" section (dotted CVar names are reassembled from nested section nodes), plus [ConsoleVariables] and [ScalabilityGroups], as setBy.
Register
void Register(const std::string& name, IConsoleVariable* var)Called by the cvar's ctor. The caller retains ownership. Registration replays the remembered settings values for the name (lowest source first), then any --cvar=<name>=... the command line carries: a cvar created after the INI pass or ApplyCommandLineArgs — every plugin, the game module, the lazily registered sg.* groups — otherwise ignored both and said nothing about it.
GetRememberedValueCount
size_t GetRememberedValueCount(std::string_view name) constHow many remembered settings values wait for (or were replayed to) a cvar of this name. Diagnostics and tests.
Unregister
void Unregister(IConsoleVariable* var)RegisterCommand
void RegisterCommand(const std::string& name, const std::string& helpText, FConsoleCommandHandler handler, const void* owner = FModuleAnchor::Here())owner names the registering module (see FModuleAnchor): its commands leave with it on unload instead of dangling into freed code.
UnregisterCommand
void UnregisterCommand(std::string_view name)RemoveCommandsInModule
size_t RemoveCommandsInModule(void* moduleHandle)HasCommand
bool HasCommand(std::string_view name) constForEachCommand
void ForEachCommand(const std::function<void(const std::string&, const std::string&)>& visitor) constExecute
bool Execute(std::string_view line)Run one console line. A registered command wins; otherwise the line is read as name value (or bare name to print) against the cvars, so the two namespaces stay reachable through a single entry point. False when nothing matched.