mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-24 00:00:13 +00:00
feat: support SavedVariablesPerCharacter for per-character addon data
Implement the SavedVariablesPerCharacter TOC directive that many addons use to store different settings per character (Bartender, Dominos, MoveAnything, WeakAuras, etc.). Without this, all characters share the same addon data file. Per-character files are stored as <AddonName>.<CharacterName>.lua.saved alongside the existing account-wide <AddonName>.lua.saved files. The character name is resolved from the player GUID at world entry time. Changes: - TocFile::getSavedVariablesPerCharacter() parses the TOC directive - AddonManager loads/saves per-character vars alongside account-wide vars - Character name set from game handler before addon loading
This commit is contained in:
parent
0d2fd02dca
commit
e21f808714
5 changed files with 51 additions and 6 deletions
|
|
@ -19,17 +19,12 @@ bool TocFile::isLoadOnDemand() const {
|
|||
return (it != directives.end()) && it->second == "1";
|
||||
}
|
||||
|
||||
std::vector<std::string> TocFile::getSavedVariables() const {
|
||||
static std::vector<std::string> parseVarList(const std::string& val) {
|
||||
std::vector<std::string> result;
|
||||
auto it = directives.find("SavedVariables");
|
||||
if (it == directives.end()) return result;
|
||||
// Parse comma-separated variable names
|
||||
std::string val = it->second;
|
||||
size_t pos = 0;
|
||||
while (pos <= val.size()) {
|
||||
size_t comma = val.find(',', pos);
|
||||
std::string name = (comma != std::string::npos) ? val.substr(pos, comma - pos) : val.substr(pos);
|
||||
// Trim whitespace
|
||||
size_t start = name.find_first_not_of(" \t");
|
||||
size_t end = name.find_last_not_of(" \t");
|
||||
if (start != std::string::npos)
|
||||
|
|
@ -40,6 +35,16 @@ std::vector<std::string> TocFile::getSavedVariables() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> TocFile::getSavedVariables() const {
|
||||
auto it = directives.find("SavedVariables");
|
||||
return (it != directives.end()) ? parseVarList(it->second) : std::vector<std::string>{};
|
||||
}
|
||||
|
||||
std::vector<std::string> TocFile::getSavedVariablesPerCharacter() const {
|
||||
auto it = directives.find("SavedVariablesPerCharacter");
|
||||
return (it != directives.end()) ? parseVarList(it->second) : std::vector<std::string>{};
|
||||
}
|
||||
|
||||
std::optional<TocFile> parseTocFile(const std::string& tocPath) {
|
||||
std::ifstream f(tocPath);
|
||||
if (!f.is_open()) return std::nullopt;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue