2017-01-20 08:36:52 -05:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class UIScript : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UIScript();
|
|
|
|
~UIScript();
|
|
|
|
|
|
|
|
class Token
|
|
|
|
{
|
|
|
|
public:
|
2017-01-20 16:41:03 -05:00
|
|
|
Token() : token(nullptr) {};
|
|
|
|
Token(const char** args) : token(nullptr) { this->parse(args); };
|
2017-01-19 16:23:59 -05:00
|
|
|
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)();
|
|
|
|
|
2018-12-17 08:29:18 -05:00
|
|
|
static void Add(const std::string& name, Utils::Slot<Callback> callback);
|
2017-01-19 16:23:59 -05:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|