Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
console.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <map>
5 #include <vector>
6 #include <Windows.h>
7 
8 #define CMD_OK BlamCommandResult::Ok;
9 #define CMD_ERR_INVALID_ARGS BlamCommandResult::InvalidArguments;
10 #define CMD_ERR_WRONG_ARGS_COUNT BlamCommandResult::WrongArgumentCount;
11 
12 #ifndef BLAM
13 #define BLAM
14 #endif
15 
23 {
24  Ok,
28 };
29 
33 enum class BlamCommandType
34 {
35  Builtin,
36  Script,
37 
43  Global,
44  Other
45 };
46 
55 {
56  std::string name;
57  std::string description;
58  std::string syntax;
59  std::vector<std::string> aliases;
60 
62 
70  virtual BlamCommandResult onCommand(std::vector<std::string> arguments) { return BlamCommandResult::Ok; };
71 };
72 
77 {
81  namespace Handlers
82  {
95  BLAM BlamCommandResult BooleanHandler(bool* value, std::vector<std::string> arguments, BlamConsoleCommand* command);
96  }
97 
105  BLAM std::string RegisterCommand(BlamConsoleCommand* command);
106 
114  BLAM void UnregisterCommand(std::string name);
115 
123  BLAM BlamConsoleCommand* GetCommand(std::string name);
124 
132  BLAM HRESULT RunCommandLine(std::string command_line);
133 
142  BLAM std::map<std::string, BlamConsoleCommand*> GetCommandList();
143 
148 
152  BLAM void Cleanup();
153 }
Blam::Resources::Console::UnregisterCommand
BLAM void UnregisterCommand(std::string name)
Unregisters the console command with the specified name.
Definition: console.cpp:164
Blam::Resources::Console::RegisterBuiltinCommands
BLAM void RegisterBuiltinCommands()
Registers all hard-coded engine commands.
Definition: console.cpp:353
Blam::Resources::Console::Handlers::BooleanHandler
BLAM BlamCommandResult BooleanHandler(bool *value, std::vector< std::string > arguments, BlamConsoleCommand *command)
Handler for boolean commands.
Definition: command_handlers.cpp:11
BlamConsoleCommand::description
std::string description
An optional description of the command. Shown when using the classify command.
Definition: console.h:57
BlamCommandType
BlamCommandType
Used to indicate the type of command.
Definition: console.h:33
BlamCommandResult::Ok
@ Ok
The command was run without error.
BlamConsoleCommand
Class used to represent a console command.
Definition: console.h:54
BlamCommandType::Other
@ Other
Currently unused.
BlamCommandType::Script
@ Script
A command that originates from a BlamScript.
BlamCommandType::Global
@ Global
A command that is used to modify a global.
Blam::Resources::Console::GetCommand
BLAM BlamConsoleCommand * GetCommand(std::string name)
Retrieves a command with the specified name.
Definition: console.cpp:176
BlamConsoleCommand::onCommand
virtual BlamCommandResult onCommand(std::vector< std::string > arguments)
Called upon command execution.
Definition: console.h:70
Blam::Resources::Console::RunCommandLine
BLAM HRESULT RunCommandLine(std::string command_line)
Executed the provided string as a console command.
Definition: console.cpp:204
BlamCommandResult::WrongArgumentCount
@ WrongArgumentCount
Too few or too many arguments were provided.
BlamConsoleCommand::name
std::string name
The name of the console command.
Definition: console.h:56
BlamCommandResult::InvalidArguments
@ InvalidArguments
Invalid arguments (or argument types) were specified - such as providing a string in place of an int.
Blam::Resources::Console::GetCommandList
BLAM std::map< std::string, BlamConsoleCommand * > GetCommandList()
Retrieves the list of all loaded console commands.
Definition: console.cpp:170
BLAM
#define BLAM
Definition: console.h:13
BlamConsoleCommand::syntax
std::string syntax
The syntax information for the command. Shown to the user when using the help command with an argumen...
Definition: console.h:58
BlamConsoleCommand::type
BlamCommandType type
The type of command this is. See #Blam::Resources::Console::BlamCommandType for more information.
Definition: console.h:61
BlamCommandType::Builtin
@ Builtin
A command that is hard-coded into the engine.
BlamCommandResult::Unsupported
@ Unsupported
The command is a legacy command from the original ImGUI-based console that is no longer supported.
BlamCommandResult
BlamCommandResult
Indicates the return state of a console command.
Definition: console.h:22
BlamConsoleCommand::aliases
std::vector< std::string > aliases
A list of aliases for the command. Executing any of these instead of the command name will behave the...
Definition: console.h:59
Blam::Resources::Console
Namespace for things relating to the debug console.
Definition: abort.hpp:5
Blam::Resources::Console::Cleanup
BLAM void Cleanup()
Cleans up all console command data.
Definition: console.cpp:342
Blam::Resources::Console::RegisterCommand
BLAM std::string RegisterCommand(BlamConsoleCommand *command)
Register a new command object.
Definition: console.cpp:156