Skip to content

Commit

Permalink
Lighting: Fix config.toml load/save logic
Browse files Browse the repository at this point in the history
  • Loading branch information
julianxhokaxhiu committed Sep 12, 2023
1 parent 8cfd6b3 commit 201b183
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- 60FPS: Refactor 60FPS battle menu fix and fix ESUI compatibility ( https://github.com/julianxhokaxhiu/FFNx/pull/597 )
- Ambient: Allow ambient effects to playback in fields that use movies as background
- Core: Add additional main models eye-to-model mapping
- Lighting: Fix [`config.toml`](https://github.com/julianxhokaxhiu/FFNx/blob/master/misc/FFNx.lighting.toml) load/save logic
- Renderer: Fix black color in some field maps (`spipe2` for example) ( https://github.com/julianxhokaxhiu/FFNx/pull/587 )

## FF8
Expand Down
27 changes: 15 additions & 12 deletions src/lighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ auto Lighting::getConfigEntry(char *key)
{
std::string groupKey = getConfigGroup();

if (groupKey.empty())
return config[key];
else if (config.contains(groupKey))
return config[groupKey][key];
else
return toml::v3::node_view<toml::v3::node>();
if (!groupKey.empty() && config.contains(groupKey))
{
auto ret = config[groupKey][key];
if (ret) return ret;
}

return config[key];
}

void Lighting::loadConfig()
Expand All @@ -83,13 +84,15 @@ void Lighting::setConfigEntry(const char *key, auto value)
{
std::string groupKey = getConfigGroup();

if (groupKey.empty())
config.insert_or_assign(key, value);
else if (config.contains(groupKey))
config[groupKey].as_table()->insert_or_assign(key, value);
if (!groupKey.empty())
{
if (config.contains(groupKey))
config[groupKey].as_table()->insert_or_assign(key, value);
else
config.insert_or_assign(groupKey, toml::table{ {key, value} });
}
else
config.insert_or_assign(groupKey, toml::table{
{key, value}});
config.insert_or_assign(key, value);
}

void Lighting::initParamsFromConfig()
Expand Down

0 comments on commit 201b183

Please sign in to comment.