iw4x-client/src/Components/Modules/UIScript.hpp

43 lines
1.1 KiB
C++
Raw Normal View History

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:
2022-08-24 10:38:14 -04:00
Token() : token(nullptr) {}
Token(const char** args) : token(nullptr) { this->parse(args); }
Token(const Token &obj) { this->token = obj.token; }
2017-01-19 16:23:59 -05:00
2022-08-24 10:38:14 -04:00
template<typename T> T get() const;
bool isValid() const;
2017-01-19 16:23:59 -05:00
private:
char* token;
void parse(const char** args);
};
2022-08-24 17:46:07 -04:00
using UIScriptHandler = std::function<void(const Token& token, const Game::uiInfo_s* info)>;
2017-01-19 16:23:59 -05:00
2022-08-24 10:38:14 -04:00
static Game::uiInfo_s* UI_GetClientInfo(int localClientNum);
2022-08-24 17:46:07 -04:00
static void Add(const std::string& name, const UIScriptHandler& callback);
static void AddOwnerDraw(int ownerdraw, const std::function<void()>& callback);
2017-01-19 16:23:59 -05:00
private:
static void OwnerDrawHandleKeyStub(int ownerDraw, int flags, float *special, int key);
static bool RunMenuScript(const char* name, const char** args);
static void RunMenuScriptStub();
2022-08-24 17:46:07 -04:00
static std::unordered_map<std::string, UIScriptHandler> UIScripts;
static std::unordered_map<int, std::function<void()>> UIOwnerDraws;
2017-01-19 16:23:59 -05:00
};
}