Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add feature-level restore defaults option #158

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
};
Loading