Update StarClientApplication.cpp

This commit is contained in:
Bottinator22 2024-12-18 18:05:55 -08:00 committed by GitHub
parent 7253f40932
commit 209d89a07d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -434,6 +434,8 @@ void ClientApplication::getAudioData(int16_t* sampleData, size_t frameCount) {
}
}
auto postProcessGroupsRoot = "postProcessGroups";
void ClientApplication::renderReload() {
auto assets = m_root->assets();
auto renderer = Application::renderer();
@ -464,18 +466,55 @@ void ClientApplication::renderReload() {
loadEffectConfig("world");
// define post process groups and set them to be enabled/disabled based on config
auto config = m_root->configuration();
if (!config->get(postProcessGroupsRoot).isType(Json::Type::Object))
config->set(postProcessGroupsRoot, JsonObject());
auto groupsConfig = config->get(postProcessGroupsRoot);
m_postProcessGroups.clear();
auto postProcessGroups = assets->json("/client.config:postProcessGroups").toObject();
for (auto& pair : postProcessGroups) {
auto name = pair.first;
auto groupConfig = groupsConfig.opt(name);
auto def = pair.second.getBool("enabledDefault",true);
if (!groupConfig)
config->setPath(strf("{}.{}", postProcessGroupsRoot, name),JsonObject());
m_postProcessGroups.add(name,PostProcessGroup{ groupConfig ? groupConfig.value().getBool("enabled", def) : def });
}
// define post process layers and optionally assign them to groups
m_postProcessLayers.clear();
auto postProcessLayers = assets->json("/client.config:postProcessLayers").toArray();
for (auto& layer : postProcessLayers) {
auto effects = jsonToStringList(layer.getArray("effects"));
for (auto& effect : effects)
loadEffectConfig(effect);
m_postProcessLayers.append(PostProcessLayer{ std::move(effects), (unsigned)layer.getUInt("passes", 1) });
PostProcessGroup* group = nullptr;
auto gname = layer.optString("group");
if (gname) {
group = &m_postProcessGroups.get(gname.value());
}
m_postProcessLayers.append(PostProcessLayer{ std::move(effects), (unsigned)layer.getUInt("passes", 1), group });
}
loadEffectConfig("interface");
}
void ClientApplication::setPostProcessGroupEnabled(String group, bool enabled, Maybe<bool> save) {
m_postProcessGroups.get(group).enabled = enabled;
if (save && save.value())
m_root->configuration()->setPath(strf("{}.{}.enabled", postProcessGroupsRoot, group),enabled);
}
bool ClientApplication::postProcessGroupEnabled(String group) {
return m_postProcessGroups.get(group).enabled;
}
Json ClientApplication::postProcessGroups() {
return m_root->assets()->json("/client.config:postProcessGroups");
}
void ClientApplication::changeState(MainAppState newState) {
MainAppState oldState = m_state;
m_state = newState;