mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-07-31 09:49:53 -04:00
Add an AddOns button to the character-select footer that opens a window listing every installed addon (title, version, author, notes) with a per-addon enable/disable checkbox. Enabled state persists to <config>/addons.cfg and is honored by loadAllAddons (disabled addons are skipped and hidden from the Lua VM); /reload picks up changes. Toggles apply on the next world enter, matching retail behavior.
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include "addons/lua_engine.hpp"
|
|
#include "addons/toc_parser.hpp"
|
|
#include <memory>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
namespace wowee::addons {
|
|
|
|
class AddonManager {
|
|
public:
|
|
AddonManager();
|
|
~AddonManager();
|
|
|
|
bool initialize(game::GameHandler* gameHandler, const LuaServices& services = {});
|
|
void scanAddons(const std::string& addonsPath);
|
|
void loadAllAddons();
|
|
bool runScript(const std::string& code);
|
|
void fireEvent(const std::string& event, const std::vector<std::string>& args = {});
|
|
void update(float deltaTime);
|
|
void shutdown();
|
|
|
|
const std::vector<TocFile>& getAddons() const { return addons_; }
|
|
LuaEngine* getLuaEngine() { return &luaEngine_; }
|
|
bool isInitialized() const { return luaEngine_.isInitialized(); }
|
|
|
|
// Per-addon enable/disable (persisted). Disabled addons are skipped by
|
|
// loadAllAddons; changes take effect on the next load (world enter or /reload).
|
|
bool isAddonEnabled(const std::string& addonName) const;
|
|
void setAddonEnabled(const std::string& addonName, bool enabled);
|
|
// True once any addon has been loaded this session (so the UI can note that a
|
|
// toggle only applies after the next reload).
|
|
bool addonsLoaded() const { return addonsLoaded_; }
|
|
|
|
void saveAllSavedVariables();
|
|
void setCharacterName(const std::string& name) { characterName_ = name; }
|
|
|
|
/// Re-initialize the Lua VM and reload all addons (used by /reload).
|
|
bool reload();
|
|
|
|
private:
|
|
LuaEngine luaEngine_;
|
|
std::vector<TocFile> addons_;
|
|
game::GameHandler* gameHandler_ = nullptr;
|
|
LuaServices luaServices_;
|
|
std::string addonsPath_;
|
|
|
|
bool loadAddon(const TocFile& addon);
|
|
std::string getSavedVariablesPath(const TocFile& addon) const;
|
|
std::string getSavedVariablesPerCharacterPath(const TocFile& addon) const;
|
|
std::string characterName_;
|
|
|
|
// addonName -> enabled. Absent means enabled (default on).
|
|
std::unordered_map<std::string, bool> addonEnabled_;
|
|
bool addonsLoaded_ = false;
|
|
static std::string enabledStatePath();
|
|
void loadEnabledState();
|
|
void saveEnabledState() const;
|
|
};
|
|
|
|
} // namespace wowee::addons
|