Blamite Game Engine - blam!  00272.10.26.20.0001.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 // onCommand() Return Results
9 #define CMD_OK Blam::Console::CommandStatus::Ok;
10 #define CMD_ERR_INVALID_ARGS Blam::Console::CommandStatus::InvalidArguments;
11 #define CMD_ERR_WRONG_ARGS_COUNT Blam::Console::CommandStatus::WrongArgumentCount;
12 
13 #ifndef BLAM
14 #define BLAM
15 #endif
16 
20 namespace Blam::Console
21 {
29  {
30  Ok,
34  };
35 
40  {
45  };
46 
51  {
52  public:
57 
62 
70  virtual CommandStatus onCommand(std::vector<std::string> arguments) { return CommandStatus::Ok; };
71 
72  std::string name;
73  std::string description;
74  std::string syntax;
75  std::vector<std::string> aliases;
76 
78  };
79 
83  namespace Handlers
84  {
97  BLAM CommandStatus BooleanHandler(bool* value, std::vector<std::string> arguments, ConsoleCommand* command);
98  }
99 
107  BLAM std::string RegisterCommand(Blam::Console::ConsoleCommand* command);
108 
116  BLAM void UnregisterCommand(std::string name);
117 
125  BLAM ConsoleCommand* GetCommand(std::string name);
126 
134  BLAM HRESULT RunCommandLine(std::string command_line);
135 
144  BLAM std::map<std::string, ConsoleCommand*> GetCommandList();
145 
150 
154  BLAM void Cleanup();
155 }
Blam::Console::ConsoleCommand::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:75
Blam::Console::RunCommandLine
BLAM HRESULT RunCommandLine(std::string command_line)
Executed the provided string as a console command.
Definition: console.cpp:184
Blam::Console::GetCommandList
BLAM std::map< std::string, ConsoleCommand * > GetCommandList()
Retrieves the list of all loaded console commands.
Definition: console.cpp:150
Blam::Console::ConsoleCommand::description
std::string description
An optional description of the command. Shown when using the classify command.
Definition: console.h:73
Blam::Console::Handlers::BooleanHandler
BLAM CommandStatus BooleanHandler(bool *value, std::vector< std::string > arguments, ConsoleCommand *command)
Handler for boolean commands.
Definition: command_handlers.cpp:9
Blam::Console::ConsoleCommand::type
CommandType type
The type of command this is. See Blam::Console::CommandType for more information.
Definition: console.h:77
Blam::Console::CommandStatus
CommandStatus
Indicates the return state of a console command.
Definition: console.h:28
Blam::Console::Other
@ Other
Currently unused.
Definition: console.h:44
Blam::Console::Global
@ Global
A command that is used to modify a global. No longer serves any use as globals can be modified in con...
Definition: console.h:43
Blam::Console::RegisterCommand
BLAM std::string RegisterCommand(Blam::Console::ConsoleCommand *command)
Register a new command object.
Definition: console.cpp:136
Blam::Console::ConsoleCommand::~ConsoleCommand
~ConsoleCommand()
Unused destructor.
Definition: console.h:61
Blam::Console::Builtin
@ Builtin
A command that is hard-coded into the engine.
Definition: console.h:41
Blam::Console::ConsoleCommand::name
std::string name
The name of the console command.
Definition: console.h:70
Blam::Console::GetCommand
BLAM ConsoleCommand * GetCommand(std::string name)
Retrieves a command with the specified name.
Definition: console.cpp:156
Blam::Console::UnregisterCommand
BLAM void UnregisterCommand(std::string name)
Unregisters the console command with the specified name.
Definition: console.cpp:144
Blam::Console::WrongArgumentCount
@ WrongArgumentCount
Too few or too many arguments were provided.
Definition: console.h:32
Blam::Console::CommandType
CommandType
Used to indicate the type of command.
Definition: console.h:39
Blam::Console::Script
@ Script
A command that originates from a BlamScript.
Definition: console.h:42
Blam::Console::ConsoleCommand::ConsoleCommand
ConsoleCommand()
Unused constructor.
Definition: console.h:56
BLAM
#define BLAM
Definition: console.h:14
Blam::Console
Namespace for things relating to the debug console.
Definition: abort.hpp:5
Blam::Console::RegisterBuiltinCommands
BLAM void RegisterBuiltinCommands()
Registers all hard-coded engine commands.
Definition: console.cpp:324
Blam::Console::Unsupported
@ Unsupported
The command is a legacy command from the original ImGUI-based console that is no longer supported.
Definition: console.h:33
Blam::Console::ConsoleCommand::onCommand
virtual CommandStatus onCommand(std::vector< std::string > arguments)
Called upon command execution.
Definition: console.h:70
Blam::Console::Ok
@ Ok
The command was run without error.
Definition: console.h:30
Blam::Console::ConsoleCommand
Class used to represent a console command.
Definition: console.h:50
Blam::Console::Cleanup
BLAM void Cleanup()
Cleans up all console command data.
Definition: console.cpp:313
Blam::Console::InvalidArguments
@ InvalidArguments
Invalid arguments (or argument types) were specified - such as providing a string in place of an int.
Definition: console.h:31
Blam::Console::ConsoleCommand::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:74