iw4x-client/src/Components/Modules/UIScript.hpp
momo5502 82e9f3864c [General] Refactor all the code
This is the actual refactoring, the last commit was broken
2017-01-20 22:41:03 +01:00

46 lines
1.1 KiB
C++

#pragma once
namespace Components
{
class UIScript : public Component
{
public:
UIScript();
~UIScript();
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
const char* getName() override { return "UIScript"; };
#endif
class Token
{
public:
Token() : token(nullptr) {};
Token(const char** args) : token(nullptr) { this->parse(args); };
Token(const Token &obj) { this->token = obj.token; };
template<typename T> T get();
bool isValid();
private:
char* token;
void parse(const char** args);
};
typedef void(Callback)(Token token);
typedef void(CallbackRaw)();
static void Add(std::string name, Utils::Slot<Callback> callback);
static void AddOwnerDraw(int ownerdraw, Utils::Slot<CallbackRaw> callback);
private:
static void OwnerDrawHandleKeyStub(int ownerDraw, int flags, float *special, int key);
static bool RunMenuScript(const char* name, const char** args);
static void RunMenuScriptStub();
static std::unordered_map<std::string, Utils::Slot<Callback>> UIScripts;
static std::unordered_map<int, Utils::Slot<CallbackRaw>> UIOwnerDraws;
};
}