diff --git a/CMakeLists.txt b/CMakeLists.txt index 66ece75326..558ac470ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set(CMAKE_POLICY_WARNING_CMP0116 OFF) project( # gersemi: ignore CommunityShaders - VERSION 1.4.10 + VERSION 1.4.11 LANGUAGES CXX ) diff --git a/src/Features/LightLimitFix.cpp b/src/Features/LightLimitFix.cpp index 9312e6dab8..b3cc18c6e9 100644 --- a/src/Features/LightLimitFix.cpp +++ b/src/Features/LightLimitFix.cpp @@ -8,6 +8,11 @@ static constexpr uint CLUSTER_MAX_LIGHTS = 128; static constexpr uint MAX_LIGHTS = 1024; +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( + LightLimitFix::Settings, + EnableContactShadows, + LightsVisualisationMode) + void LightLimitFix::DrawSettings() { auto shaderCache = globals::shaderCache; @@ -165,16 +170,19 @@ void LightLimitFix::SetupResources() } } -void LightLimitFix::LoadSettings(json&) +void LightLimitFix::LoadSettings(json& o_json) { + settings = o_json; } -void LightLimitFix::SaveSettings(json&) +void LightLimitFix::SaveSettings(json& o_json) { + o_json = settings; } void LightLimitFix::RestoreDefaultSettings() { + settings = {}; } RE::NiNode* GetParentRoomNode(RE::NiAVObject* object) diff --git a/src/Features/LightLimitFix.h b/src/Features/LightLimitFix.h index 17d0893615..92822e21c8 100644 --- a/src/Features/LightLimitFix.h +++ b/src/Features/LightLimitFix.h @@ -176,6 +176,7 @@ struct LightLimitFix : OverlayFeature struct Settings { + bool EnableContactShadows = false; bool EnableLightsVisualisation = false; uint LightsVisualisationMode = 0; }; diff --git a/src/State.cpp b/src/State.cpp index 1163a532e1..d5a76dd2ae 100644 --- a/src/State.cpp +++ b/src/State.cpp @@ -407,6 +407,12 @@ void State::SaveToJson(nlohmann::json& settings) auto& upscalingJson = settings[upscaling.GetShortName()]; upscaling.SaveSettings(upscalingJson); + json originalShaders; + ForEachShaderTypeWithIndex([&](auto type, int classIndex) { + originalShaders[magic_enum::enum_name(type)] = enabledClasses[classIndex]; + }); + settings["Replace Original Shaders"] = originalShaders; + json disabledFeaturesJson; for (const auto& [featureName, isDisabled] : disabledFeatures) { disabledFeaturesJson[featureName] = isDisabled; @@ -473,6 +479,18 @@ void State::LoadFromJson(nlohmann::json& settings) shaderCache->SetAsync(general["Enable Async"]); } + if (settings.contains("Replace Original Shaders") && settings["Replace Original Shaders"].is_object()) { + json& originalShaders = settings["Replace Original Shaders"]; + ForEachShaderTypeWithIndex([&](auto type, int classIndex) { + auto name = magic_enum::enum_name(type); + if (originalShaders.contains(name) && originalShaders[name].is_boolean()) { + enabledClasses[classIndex] = originalShaders[name]; + } else { + logger::warn("Invalid entry for shader class '{}', using current value", name); + } + }); + } + // Load feature settings (only for already-loaded features) for (auto* feature : Feature::GetFeatureList()) { if (feature->loaded) { diff --git a/src/State.h b/src/State.h index e8a9de3477..4f358f6c55 100644 --- a/src/State.h +++ b/src/State.h @@ -24,6 +24,7 @@ class State for (auto& v : drawCalls) v = 0; for (auto& v : frameTimePerType) v = 0.0f; for (auto& v : smoothFrameTimePerType) v = 0.0f; + for (auto& v : enabledClasses) v = true; // Initialize QueryPerformanceCounter frequency frameTimingFrequency.QuadPart = 0;