mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Add AddonManager::reload() which saves all SavedVariables, shuts down the Lua VM, re-initializes it, rescans .toc files, and reloads all addons. Wire /reload, /reloadui, /rl slash commands that call reload() and fire VARIABLES_LOADED + PLAYER_LOGIN + PLAYER_ENTERING_WORLD lifecycle events. Essential for addon development and troubleshooting.
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "addons/lua_engine.hpp"
|
|
#include "addons/toc_parser.hpp"
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace wowee::addons {
|
|
|
|
class AddonManager {
|
|
public:
|
|
AddonManager();
|
|
~AddonManager();
|
|
|
|
bool initialize(game::GameHandler* gameHandler);
|
|
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(); }
|
|
|
|
void saveAllSavedVariables();
|
|
|
|
/// 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;
|
|
std::string addonsPath_;
|
|
|
|
bool loadAddon(const TocFile& addon);
|
|
std::string getSavedVariablesPath(const TocFile& addon) const;
|
|
};
|
|
|
|
} // namespace wowee::addons
|