Blamite Game Engine - blam!  00285.12.18.20.1411.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 
23 namespace Blam::Console
24 {
32  {
33  Ok,
37  };
38 
43  {
48  };
49 
54  {
55  public:
60 
65 
73  virtual CommandStatus onCommand(std::vector<std::string> arguments) { return CommandStatus::Ok; };
74 
75  std::string name;
76  std::string description;
77  std::string syntax;
78  std::vector<std::string> aliases;
79 
81  };
82 
86  namespace Handlers
87  {
100  BLAM CommandStatus BooleanHandler(bool* value, std::vector<std::string> arguments, ConsoleCommand* command);
101  }
102 
110  BLAM std::string RegisterCommand(Blam::Console::ConsoleCommand* command);
111 
119  BLAM void UnregisterCommand(std::string name);
120 
128  BLAM ConsoleCommand* GetCommand(std::string name);
129 
137  BLAM HRESULT RunCommandLine(std::string command_line);
138 
147  BLAM std::map<std::string, ConsoleCommand*> GetCommandList();
148 
153 
157  BLAM void Cleanup();
158 }
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:78
Blam::Console::RunCommandLine
BLAM HRESULT RunCommandLine(std::string command_line)
Executed the provided string as a console command.
Definition: console.cpp:204
Blam::Console::GetCommandList
BLAM std::map< std::string, ConsoleCommand * > GetCommandList()
Retrieves the list of all loaded console commands.
Definition: console.cpp:170
Blam::Console::ConsoleCommand::description
std::string description
An optional description of the command. Shown when using the classify command.
Definition: console.h:76
Blam::Console::Handlers::BooleanHandler
BLAM CommandStatus BooleanHandler(bool *value, std::vector< std::string > arguments, ConsoleCommand *command)
Handler for boolean commands.
Definition: command_handlers.cpp:11
Blam::Console::ConsoleCommand::type
CommandType type
The type of command this is. See Blam::Console::CommandType for more information.
Definition: console.h:80
Blam::Console::CommandStatus
CommandStatus
Indicates the return state of a console command.
Definition: console.h:31
Blam::Console::Other
@ Other
Currently unused.
Definition: console.h:47
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:46
Blam::Console::RegisterCommand
BLAM std::string RegisterCommand(Blam::Console::ConsoleCommand *command)
Register a new command object.
Definition: console.cpp:156
Blam::Console::ConsoleCommand::~ConsoleCommand
~ConsoleCommand()
Unused destructor.
Definition: console.h:64
Blam::Console::Builtin
@ Builtin
A command that is hard-coded into the engine.
Definition: console.h:44
Blam::Console::ConsoleCommand::name
std::string name
The name of the console command.
Definition: console.h:73
Blam::Console::GetCommand
BLAM ConsoleCommand * GetCommand(std::string name)
Retrieves a command with the specified name.
Definition: console.cpp:176
Blam::Console::UnregisterCommand
BLAM void UnregisterCommand(std::string name)
Unregisters the console command with the specified name.
Definition: console.cpp:164
Blam::Console::WrongArgumentCount
@ WrongArgumentCount
Too few or too many arguments were provided.
Definition: console.h:35
Blam::Console::CommandType
CommandType
Used to indicate the type of command.
Definition: console.h:42
Blam::Console::Script
@ Script
A command that originates from a BlamScript.
Definition: console.h:45
Blam::Console::ConsoleCommand::ConsoleCommand
ConsoleCommand()
Unused constructor.
Definition: console.h:59
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:353
Blam::Console::Unsupported
@ Unsupported
The command is a legacy command from the original ImGUI-based console that is no longer supported.
Definition: console.h:36
Blam::Console::ConsoleCommand::onCommand
virtual CommandStatus onCommand(std::vector< std::string > arguments)
Called upon command execution.
Definition: console.h:73
Blam::Console::Ok
@ Ok
The command was run without error.
Definition: console.h:33
Blam::Console::ConsoleCommand
Class used to represent a console command.
Definition: console.h:53
Blam::Console::Cleanup
BLAM void Cleanup()
Cleans up all console command data.
Definition: console.cpp:342
Blam::Console::InvalidArguments
@ InvalidArguments
Invalid arguments (or argument types) were specified - such as providing a string in place of an int.
Definition: console.h:34
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:77