Kelsidavis-WoWee/include/addons/toc_parser.hpp
Kelsi 062cfd1e4a feat: add SavedVariables persistence for Lua addons
Addons can now persist data across sessions using the standard WoW
SavedVariables pattern:

1. Declare in .toc: ## SavedVariables: MyAddonDB
2. Use the global in Lua: MyAddonDB = MyAddonDB or {default = true}
3. Data is automatically saved on logout and restored on next login

Implementation:
- TocFile::getSavedVariables() parses comma-separated variable names
- LuaEngine::loadSavedVariables() executes saved .lua file to restore globals
- LuaEngine::saveSavedVariables() serializes Lua tables/values to valid Lua
- Serializer handles tables (nested), strings, numbers, booleans, nil
- Save triggered on PLAYER_LEAVING_WORLD and AddonManager::shutdown()
- Files stored as <AddonDir>/<AddonName>.lua.saved

Updated HelloWorld addon to track login count across sessions.
2026-03-20 12:22:50 -07:00

25 lines
552 B
C++

#pragma once
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
namespace wowee::addons {
struct TocFile {
std::string addonName;
std::string basePath;
std::unordered_map<std::string, std::string> directives;
std::vector<std::string> files;
std::string getTitle() const;
std::string getInterface() const;
bool isLoadOnDemand() const;
std::vector<std::string> getSavedVariables() const;
};
std::optional<TocFile> parseTocFile(const std::string& tocPath);
} // namespace wowee::addons