Skip to content

Commit

Permalink
feat: feature-level restore defaults option
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRiverwoodModder committed Jan 24, 2024
1 parent f7bfe06 commit 25b594f
Show file tree
Hide file tree
Showing 19 changed files with 192 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct Feature
virtual void Load(json& o_json);
virtual void Save(json& o_json) = 0;

virtual void RestoreDefaultSettings() = 0;

virtual bool ValidateCache(CSimpleIniA& a_ini);
virtual void WriteDiskCacheInfo(CSimpleIniA& a_ini);
virtual void ClearShaderCache() {}
Expand Down
21 changes: 21 additions & 0 deletions src/Features/DistantTreeLighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ void DistantTreeLighting::DrawSettings()
ImGui::Spacing();
ImGui::TreePop();
}

ImGui::Spacing();
ImGui::Spacing();

if (ImGui::Button("Restore Defaults", { -1, 0 })) {
DistantTreeLighting::GetSingleton()->RestoreDefaultSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::Text(
"Restores the feature's settings back to their default values. "
"You will still need to Save Settings to make these changes permanent. ");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}

enum class DistantTreeShaderTechniques
Expand Down Expand Up @@ -162,6 +178,11 @@ void DistantTreeLighting::Save(json& o_json)
o_json[GetName()] = settings;
}

void DistantTreeLighting::RestoreDefaultSettings()
{
settings = {};
}

void DistantTreeLighting::SetupResources()
{
perPass = new ConstantBuffer(ConstantBufferDesc<PerPass>());
Expand Down
2 changes: 2 additions & 0 deletions src/Features/DistantTreeLighting.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ struct DistantTreeLighting : Feature

virtual void Load(json& o_json);
virtual void Save(json& o_json);

virtual void RestoreDefaultSettings();
};
4 changes: 4 additions & 0 deletions src/Features/DynamicCubemaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,8 @@ void DynamicCubemaps::Load(json& o_json)

void DynamicCubemaps::Save(json&)
{
}

void DynamicCubemaps::RestoreDefaultSettings()
{
}
2 changes: 2 additions & 0 deletions src/Features/DynamicCubemaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ struct DynamicCubemaps : Feature
virtual void Load(json& o_json);
virtual void Save(json& o_json);

virtual void RestoreDefaultSettings();

std::vector<std::string> iniVRCubeMapSettings{
{ "bAutoWaterSilhouetteReflections:Water" }, //IniSettings 0x1eaa018
{ "bForceHighDetailReflections:Water" }, //IniSettings 0x1eaa030
Expand Down
21 changes: 21 additions & 0 deletions src/Features/ExtendedMaterials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ void ExtendedMaterials::DrawSettings()

ImGui::TreePop();
}

ImGui::Spacing();
ImGui::Spacing();

if (ImGui::Button("Restore Defaults", { -1, 0 })) {
ExtendedMaterials::GetSingleton()->RestoreDefaultSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::Text(
"Restores the feature's settings back to their default values. "
"You will still need to Save Settings to make these changes permanent. ");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}

void ExtendedMaterials::ModifyLighting(const RE::BSShader*, const uint32_t)
Expand Down Expand Up @@ -243,6 +259,11 @@ void ExtendedMaterials::Save(json& o_json)
o_json[GetName()] = settings;
}

void ExtendedMaterials::RestoreDefaultSettings()
{
settings = {};
}

bool ExtendedMaterials::HasShaderDefine(RE::BSShader::Type shaderType)
{
switch (shaderType) {
Expand Down
2 changes: 2 additions & 0 deletions src/Features/ExtendedMaterials.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ struct ExtendedMaterials : Feature

virtual void Load(json& o_json);
virtual void Save(json& o_json);

virtual void RestoreDefaultSettings();
};
21 changes: 21 additions & 0 deletions src/Features/GrassCollision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ void GrassCollision::DrawSettings()
ImGui::Text(std::format("Total Collisions : {}", currentCollisionCount).c_str());
ImGui::TreePop();
}

ImGui::Spacing();
ImGui::Spacing();

if (ImGui::Button("Restore Defaults", { -1, 0 })) {
GrassCollision::GetSingleton()->RestoreDefaultSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::Text(
"Restores the feature's settings back to their default values. "
"You will still need to Save Settings to make these changes permanent. ");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}

static bool GetShapeBound(RE::NiAVObject* a_node, RE::NiPoint3& centerPos, float& radius)
Expand Down Expand Up @@ -327,6 +343,11 @@ void GrassCollision::Save(json& o_json)
o_json[GetName()] = settings;
}

void GrassCollision::RestoreDefaultSettings()
{
settings = {};
}

void GrassCollision::SetupResources()
{
perFrame = new ConstantBuffer(ConstantBufferDesc<PerFrame>());
Expand Down
2 changes: 2 additions & 0 deletions src/Features/GrassCollision.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ struct GrassCollision : Feature

virtual void Load(json& o_json);
virtual void Save(json& o_json);

virtual void RestoreDefaultSettings();
};
21 changes: 21 additions & 0 deletions src/Features/GrassLighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ void GrassLighting::DrawSettings()

ImGui::TreePop();
}

ImGui::Spacing();
ImGui::Spacing();

if (ImGui::Button("Restore Defaults", { -1, 0 })) {
GrassLighting::GetSingleton()->RestoreDefaultSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::Text(
"Restores the feature's settings back to their default values. "
"You will still need to Save Settings to make these changes permanent. ");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}

void GrassLighting::ModifyGrass(const RE::BSShader*, const uint32_t descriptor)
Expand Down Expand Up @@ -156,6 +172,11 @@ void GrassLighting::Save(json& o_json)
o_json[GetName()] = settings;
}

void GrassLighting::RestoreDefaultSettings()
{
settings = {};
}

void GrassLighting::SetupResources()
{
perFrame = new ConstantBuffer(ConstantBufferDesc<PerFrame>());
Expand Down
2 changes: 2 additions & 0 deletions src/Features/GrassLighting.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ struct GrassLighting : Feature

virtual void Load(json& o_json);
virtual void Save(json& o_json);

virtual void RestoreDefaultSettings();
};
21 changes: 21 additions & 0 deletions src/Features/LightLimitFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ void LightLimitFix::DrawSettings()

ImGui::TreePop();
}

ImGui::Spacing();
ImGui::Spacing();

if (ImGui::Button("Restore Defaults", { -1, 0 })) {
LightLimitFix::GetSingleton()->RestoreDefaultSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::Text(
"Restores the feature's settings back to their default values. "
"You will still need to Save Settings to make these changes permanent. ");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}

void LightLimitFix::SetupResources()
Expand Down Expand Up @@ -287,6 +303,11 @@ void LightLimitFix::Save(json& o_json)
o_json[GetName()] = settings;
}

void LightLimitFix::RestoreDefaultSettings()
{
settings = {};
}

void LightLimitFix::BSLightingShader_SetupGeometry_Before(RE::BSRenderPass*)
{
strictLightDataTemp.NumLights = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/Features/LightLimitFix.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ struct LightLimitFix : Feature
virtual void Load(json& o_json);
virtual void Save(json& o_json);

virtual void RestoreDefaultSettings();

virtual void DrawSettings();
virtual void Draw(const RE::BSShader* shader, const uint32_t descriptor);

Expand Down
21 changes: 21 additions & 0 deletions src/Features/ScreenSpaceShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ void ScreenSpaceShadows::DrawSettings()

ImGui::TreePop();
}

ImGui::Spacing();
ImGui::Spacing();

if (ImGui::Button("Restore Defaults", { -1, 0 })) {
ScreenSpaceShadows::GetSingleton()->RestoreDefaultSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::Text(
"Restores the feature's settings back to their default values. "
"You will still need to Save Settings to make these changes permanent. ");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}

enum class GrassShaderTechniques
Expand Down Expand Up @@ -500,6 +516,11 @@ void ScreenSpaceShadows::Save(json& o_json)
o_json[GetName()] = settings;
}

void ScreenSpaceShadows::RestoreDefaultSettings()
{
settings = {};
}

void ScreenSpaceShadows::SetupResources()
{
perPass = new ConstantBuffer(ConstantBufferDesc<PerPass>());
Expand Down
2 changes: 2 additions & 0 deletions src/Features/ScreenSpaceShadows.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,6 @@ struct ScreenSpaceShadows : Feature

virtual void Load(json& o_json);
virtual void Save(json& o_json);

virtual void RestoreDefaultSettings();
};
21 changes: 21 additions & 0 deletions src/Features/WaterBlending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ void WaterBlending::DrawSettings()

ImGui::TreePop();
}

ImGui::Spacing();
ImGui::Spacing();

if (ImGui::Button("Restore Defaults", { -1, 0 })) {
WaterBlending::GetSingleton()->RestoreDefaultSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::Text(
"Restores the feature's settings back to their default values. "
"You will still need to Save Settings to make these changes permanent. ");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}

void WaterBlending::Draw(const RE::BSShader* shader, const uint32_t)
Expand Down Expand Up @@ -113,6 +129,11 @@ void WaterBlending::Save(json& o_json)
o_json[GetName()] = settings;
}

void WaterBlending::RestoreDefaultSettings()
{
settings = {};
}

bool WaterBlending::HasShaderDefine(RE::BSShader::Type)
{
return true;
Expand Down
2 changes: 2 additions & 0 deletions src/Features/WaterBlending.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ struct WaterBlending : Feature

virtual void Load(json& o_json);
virtual void Save(json& o_json);

virtual void RestoreDefaultSettings();
};
21 changes: 21 additions & 0 deletions src/Features/WetnessEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ void WetnessEffects::DrawSettings()

ImGui::TreePop();
}

ImGui::Spacing();
ImGui::Spacing();

if (ImGui::Button("Restore Defaults", { -1, 0 })) {
WetnessEffects::GetSingleton()->RestoreDefaultSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::Text(
"Restores the feature's settings back to their default values. "
"You will still need to Save Settings to make these changes permanent. ");
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}

float WetnessEffects::CalculateWeatherTransitionPercentage(RE::TESWeather* weather, float skyCurrentWeatherPct, float beginFade)
Expand Down Expand Up @@ -169,4 +185,9 @@ void WetnessEffects::Load(json& o_json)
void WetnessEffects::Save(json& o_json)
{
o_json[GetName()] = settings;
}

void WetnessEffects::RestoreDefaultSettings()
{
settings = {};
}
2 changes: 2 additions & 0 deletions src/Features/WetnessEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ struct WetnessEffects : Feature
virtual void Load(json& o_json);
virtual void Save(json& o_json);

virtual void RestoreDefaultSettings();

float CalculateWeatherTransitionPercentage(RE::TESWeather* weather, float skyCurrentWeatherPct, float beginFade);
float CalculateWetness(RE::TESWeather* weather, RE::Sky* sky);
};

0 comments on commit 25b594f

Please sign in to comment.