64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "Common.h"
|
|
|
|
enum class ModuleCategory : uint8_t {
|
|
Player,
|
|
ESP,
|
|
World,
|
|
Visual,
|
|
Internal,
|
|
};
|
|
|
|
class BaseModule {
|
|
public:
|
|
BaseModule(std::string module_name, std::string tab_label, ModuleCategory category)
|
|
: name_(std::move(module_name)),
|
|
tab_label_(std::move(tab_label)),
|
|
category_(category) {}
|
|
|
|
virtual ~BaseModule() = default;
|
|
|
|
virtual void RegisterTab() = 0;
|
|
virtual void Render() = 0;
|
|
virtual void Update() = 0;
|
|
virtual void OnHotkey() {}
|
|
|
|
const std::string& Name() const { return name_; }
|
|
const std::string& TabLabel() const { return tab_label_; }
|
|
ModuleCategory Category() const { return category_; }
|
|
|
|
bool Enabled() const { return enabled_; }
|
|
void SetEnabled(bool value) { enabled_ = value; }
|
|
|
|
protected:
|
|
std::string name_;
|
|
std::string tab_label_;
|
|
ModuleCategory category_;
|
|
bool enabled_ = false;
|
|
};
|
|
|
|
using ModuleFactory = std::function<std::unique_ptr<BaseModule>()>;
|
|
|
|
class ModuleManager final {
|
|
public:
|
|
void AddRegistrar(const std::string& name, ModuleFactory factory);
|
|
void Init();
|
|
|
|
void DispatchRenderByTab(MainTab tab);
|
|
void DispatchUpdate();
|
|
void DispatchHotkeys();
|
|
|
|
BaseModule* FindModule(const std::string& name);
|
|
std::vector<BaseModule*> GetModulesByCategory(ModuleCategory category);
|
|
bool Initialized() const { return initialized_; }
|
|
|
|
private:
|
|
std::vector<std::pair<std::string, ModuleFactory>> registrars_;
|
|
std::vector<std::unique_ptr<BaseModule>> modules_;
|
|
bool initialized_ = false;
|
|
};
|
|
|
|
ModuleManager& GetModuleManager();
|
|
void RegisterDefaultModules();
|