iw4x-client/src/Components/Modules/Command.hpp
momo5502 4f458b40c3 Use slots instead of simple callbacks.
Need to wait till my second pull request gets accepted though, to be able to compile the code.
2016-02-12 00:01:13 +01:00

36 lines
795 B
C++

namespace Components
{
class Command : public Component
{
public:
class Params
{
public:
Params(DWORD id) : CommandId(id) {};
Params(const Params &obj) { this->CommandId = obj.CommandId; };
Params() : Params(*Game::cmd_id) {};
char* operator[](size_t index);
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);
static void Execute(std::string command, bool sync = true);
private:
static Game::cmd_function_t* Allocate();
static std::vector<Game::cmd_function_t*> Functions;
static std::map<std::string, wink::slot<Callback>> FunctionMap;
static void MainCallback();
};
}