Skip to content
Closed
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
5 changes: 3 additions & 2 deletions src/SettingsOverrideManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "SettingsOverrideManager.h"

#include "FeatureIssues.h"
#include "Util.h"

#include <algorithm>
#include <ctime>
Expand Down Expand Up @@ -279,7 +280,7 @@ void SettingsOverrideManager::RefreshOverrides()

std::filesystem::path SettingsOverrideManager::GetOverridesDirectory() const
{
return std::filesystem::path(OVERRIDES_DIR);
return Util::PathHelpers::GetOverridesPath();
}

json SettingsOverrideManager::LoadAppliedOverridesTracking() const
Expand Down Expand Up @@ -403,7 +404,7 @@ void SettingsOverrideManager::SaveAppliedOverridesTracking(const json& appliedOv

std::filesystem::path SettingsOverrideManager::GetAppliedOverridesTrackingPath() const
{
return std::filesystem::path(APPLIED_OVERRIDES_TRACKING_FILE);
return Util::PathHelpers::GetAppliedOverridesPath();
}

size_t SettingsOverrideManager::ApplyNewOverrides(json& baseSettings, json& appliedOverrides)
Expand Down
2 changes: 0 additions & 2 deletions src/SettingsOverrideManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ class SettingsOverrideManager
bool enabled = true;
bool discovered = false;

static constexpr const char* OVERRIDES_DIR = "Data\\SKSE\\Plugins\\CommunityShaders\\Overrides";
static constexpr const char* GLOBAL_SUFFIX = "_Global.json";
static constexpr const char* APPLIED_OVERRIDES_TRACKING_FILE = "Data\\SKSE\\Plugins\\CommunityShaders\\AppliedOverrides.json";

// Security limits for JSON validation
static constexpr size_t MAX_JSON_DEPTH = 10;
Expand Down
29 changes: 23 additions & 6 deletions src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,18 @@ void State::Setup()
globals::deferred->SetupResources();
}

static const std::string& GetConfigPath(State::ConfigMode a_configMode)
static std::string GetConfigPath(State::ConfigMode a_configMode)
{
switch (a_configMode) {
case State::ConfigMode::USER:
return globals::state->userConfigPath;
return Util::PathHelpers::GetSettingsUserPath().string();
case State::ConfigMode::TEST:
return globals::state->testConfigPath;
return Util::PathHelpers::GetSettingsTestPath().string();
case State::ConfigMode::THEME:
return Util::PathHelpers::GetSettingsThemePath().string();
case State::ConfigMode::DEFAULT:
default:
return globals::state->defaultConfigPath;
return Util::PathHelpers::GetSettingsDefaultPath().string();
}
}

Expand Down Expand Up @@ -395,10 +397,11 @@ void State::Save(ConfigMode a_configMode)
std::string configPath = GetConfigPath(a_configMode);
std::ofstream o{ configPath };

auto configFolderPath = std::filesystem::path(configPath).parent_path().string();
try {
std::filesystem::create_directories(folderPath);
std::filesystem::create_directories(configFolderPath);
} catch (const std::filesystem::filesystem_error& e) {
logger::warn("Error creating directory during Save ({}) : {}\n", folderPath, e.what());
logger::warn("Error creating directory during Save ({}) : {}\n", configFolderPath, e.what());
return;
}

Expand Down Expand Up @@ -458,6 +461,20 @@ void State::Save(ConfigMode a_configMode)
}
}

void State::LoadTheme()
{
// Stub implementation for PR #1
// Full implementation will be added in PR #4 (Theme System Core)
logger::debug("LoadTheme called (stub)");
}

void State::SaveTheme()
{
// Stub implementation for PR #1
// Full implementation will be added in PR #4 (Theme System Core)
logger::debug("SaveTheme called (stub)");
}

bool State::ValidateCache(CSimpleIniA& a_ini)
{
bool valid = true;
Expand Down
10 changes: 5 additions & 5 deletions src/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ class State
spdlog::level::level_enum logLevel = spdlog::level::info;
std::string shaderDefinesString = "";
std::vector<std::pair<std::string, std::string>> shaderDefines{}; // data structure to parse string into; needed to avoid dangling pointers
const std::string folderPath = "Data\\SKSE\\Plugins\\CommunityShaders";
const std::string testConfigPath = "Data\\SKSE\\Plugins\\CommunityShaders\\SettingsTest.json";
const std::string userConfigPath = "Data\\SKSE\\Plugins\\CommunityShaders\\SettingsUser.json";
const std::string defaultConfigPath = "Data\\SKSE\\Plugins\\CommunityShaders\\SettingsDefault.json";

float timer = 0;
double smoothDrawCalls[RE::BSShader::Type::Total + 1];
Expand All @@ -73,7 +69,8 @@ class State
{
DEFAULT,
USER,
TEST
TEST,
THEME
};

void Draw();
Expand All @@ -84,6 +81,9 @@ class State
void Load(ConfigMode a_configMode = ConfigMode::USER, bool a_allowReload = true);
void Save(ConfigMode a_configMode = ConfigMode::USER);

void LoadTheme();
void SaveTheme();

bool ValidateCache(CSimpleIniA& a_ini);
void WriteDiskCacheInfo(CSimpleIniA& a_ini);

Expand Down
49 changes: 30 additions & 19 deletions src/Utils/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,25 @@ namespace Util
return GetCommunityShaderPath() / "SettingsTest.json";
}

std::filesystem::path GetSettingsDefaultPath()
{
return GetCommunityShaderPath() / "SettingsDefault.json";
}
std::filesystem::path GetSettingsDefaultPath()
{
return GetCommunityShaderPath() / "SettingsDefault.json";
}

std::filesystem::path GetOverridesPath()
{
return GetCommunityShaderPath() / "Overrides";
}
std::filesystem::path GetSettingsThemePath()
{
return GetCommunityShaderPath() / "SettingsTheme.json";
}

std::filesystem::path GetThemesPath()
{
return GetCommunityShaderPath() / "Themes";
}

std::filesystem::path GetAppliedOverridesPath()
std::filesystem::path GetOverridesPath()
{
return GetCommunityShaderPath() / "Overrides";
} std::filesystem::path GetAppliedOverridesPath()
Comment on lines +81 to +84

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix formatting: separate function definitions.

Line 84 has GetOverridesPath()'s closing brace immediately followed by GetAppliedOverridesPath() on the same line, reducing readability.

Apply this diff:

 	std::filesystem::path GetOverridesPath()
 	{
 		return GetCommunityShaderPath() / "Overrides";
-	}		std::filesystem::path GetAppliedOverridesPath()
+	}
+
+	std::filesystem::path GetAppliedOverridesPath()
 		{
 			return GetCommunityShaderPath() / "AppliedOverrides.json";
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
std::filesystem::path GetOverridesPath()
{
return GetCommunityShaderPath() / "Overrides";
} std::filesystem::path GetAppliedOverridesPath()
std::filesystem::path GetOverridesPath()
{
return GetCommunityShaderPath() / "Overrides";
}
std::filesystem::path GetAppliedOverridesPath()
{
return GetCommunityShaderPath() / "AppliedOverrides.json";
}
🤖 Prompt for AI Agents
In src/Utils/FileSystem.cpp around lines 81 to 84, the closing brace of
GetOverridesPath() is immediately followed by the next function signature on the
same line; separate the function definitions by moving the
GetAppliedOverridesPath() declaration to its own line (add a newline between the
closing brace of GetOverridesPath() and the start of GetAppliedOverridesPath()),
preserving existing indentation and line endings to restore readability and
consistent formatting.

{
return GetCommunityShaderPath() / "AppliedOverrides.json";
}
Expand Down Expand Up @@ -129,20 +137,23 @@ namespace Util
return dllPath.parent_path().parent_path().parent_path();
}();
return cachedPath;
}
}

std::filesystem::path GetShadersRealPath()
{
return GetRootRealPath() / "Shaders";
}
std::filesystem::path GetShadersRealPath()
{
return GetRootRealPath() / "Shaders";
}

std::filesystem::path GetFeaturesRealPath()
{
return GetShadersRealPath() / "Features";
}
std::filesystem::path GetThemesRealPath()
{
return GetRootRealPath() / "SKSE" / "Plugins" / "CommunityShaders" / "Themes";
}

// File system utilities implementation
std::filesystem::path GetFeaturesRealPath()
{
return GetShadersRealPath() / "Features";
}
} // File system utilities implementation
namespace FileHelpers
{
DeletionResult SafeDelete(const std::string& path, const std::string& description)
Expand Down
58 changes: 36 additions & 22 deletions src/Utils/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,29 @@ namespace Util
*/
std::filesystem::path GetSettingsTestPath();

/**
* Gets the SettingsDefault.json file path
* @return CommunityShaderPath / "SettingsDefault.json"
*/
std::filesystem::path GetSettingsDefaultPath();
/**
* Gets the SettingsDefault.json file path
* @return CommunityShaderPath / "SettingsDefault.json"
*/
std::filesystem::path GetSettingsDefaultPath();

/**
* Gets the Overrides directory path
* @return CommunityShaderPath / "Overrides"
*/
std::filesystem::path GetOverridesPath();
/**
* Gets the SettingsTheme.json file path
* @return CommunityShaderPath / "SettingsTheme.json"
*/
std::filesystem::path GetSettingsThemePath();

/**
/**
* Gets the Themes directory path
* @return CommunityShaderPath / "Themes"
*/
std::filesystem::path GetThemesPath();

/**
* Gets the Overrides directory path
* @return CommunityShaderPath / "Overrides"
*/
std::filesystem::path GetOverridesPath(); /**
Comment on lines +95 to +99

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix formatting: separate function declaration from comment block.

The closing brace of GetOverridesPath() and the opening of the comment block for GetAppliedOverridesPath() are on the same line, making the code harder to read.

Apply this diff:

-	std::filesystem::path GetOverridesPath();		/**
+	std::filesystem::path GetOverridesPath();
+
+	/**
 		 * Gets the AppliedOverrides.json file path
 		 * @return CommunityShaderPath / "AppliedOverrides.json"
 		 */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Gets the Overrides directory path
* @return CommunityShaderPath / "Overrides"
*/
std::filesystem::path GetOverridesPath(); /**
/**
* Gets the Overrides directory path
* @return CommunityShaderPath / "Overrides"
*/
std::filesystem::path GetOverridesPath();
/**
* Gets the AppliedOverrides.json file path
* @return CommunityShaderPath / "AppliedOverrides.json"
*/
🤖 Prompt for AI Agents
In src/Utils/FileSystem.h around lines 95 to 99, the declaration of
GetOverridesPath() and the next comment block are run together on one line;
separate them by placing the function declaration (closing semicolon) on its own
line and start the following comment block on the next line so the comment and
declaration are not concatenated. Update formatting to ensure
GetOverridesPath(); ends the line, then add a newline before the /** comment for
GetAppliedOverridesPath().

* Gets the AppliedOverrides.json file path
* @return CommunityShaderPath / "AppliedOverrides.json"
*/
Expand Down Expand Up @@ -136,19 +146,23 @@ namespace Util
*/
std::filesystem::path GetRootRealPath();

/**
* Returns the real path to the Shaders directory located in the mod's root folder.
* @return <mod_root> / "Shaders"
*/
std::filesystem::path GetShadersRealPath();
/**
* Returns the real path to the Shaders directory located in the mod's root folder.
* @return <mod_root> / "Shaders"
*/
std::filesystem::path GetShadersRealPath();

/**
* Returns the real path to the Features directory containing feature INI files.
* @return <mod_root> / "Shaders" / "Features"
*/
std::filesystem::path GetFeaturesRealPath();
/**
* Returns the real path to the Themes directory containing theme JSON files.
* @return <mod_root> / "SKSE" / "Plugins" / "CommunityShaders" / "Themes"
*/
std::filesystem::path GetThemesRealPath();

}
/**
* Returns the real path to the Features directory containing feature INI files.
* @return <mod_root> / "Shaders" / "Features"
*/
std::filesystem::path GetFeaturesRealPath(); }

/**
* File system utilities for safe file operations
Expand Down