iw4x-client/iw4/Components/Command.hpp

36 lines
744 B
C++
Raw Normal View History

2015-12-23 08:45:53 -05:00
namespace Components
{
class Command : public Component
{
public:
class Params
{
public:
Params(DWORD id) : CommandId(id) {};
Params(const Params &obj) { this->CommandId = obj.CommandId; };
2015-12-23 16:21:03 -05:00
char* operator[](size_t index);
2015-12-23 08:45:53 -05:00
size_t Length();
private:
DWORD CommandId;
};
typedef void(*Callback)(Command::Params params);
Command();
~Command();
const char* GetName() { return "Command"; };
static void Add(const char* name, Callback callback);
2015-12-25 15:42:35 -05:00
static void Execute(std::string command, bool sync = true);
2015-12-23 08:45:53 -05:00
private:
static Game::cmd_function_t* Allocate();
static std::vector<Game::cmd_function_t*> Functions;
static std::map<std::string, Callback> FunctionMap;
static void MainCallback();
};
}