Skip to content

Commit

Permalink
feat: allow user specific configs
Browse files Browse the repository at this point in the history
closes doodlum#66
  • Loading branch information
alandtse committed Aug 31, 2023
1 parent 727d779 commit 11d1684
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ void State::Load()
{
auto& shaderCache = SIE::ShaderCache::Instance();

std::string configPath = "Data\\SKSE\\Plugins\\CommunityShaders.json";

std::string configPath = userConfigPath;
std::ifstream i(configPath);
if (!i.is_open()) {
logger::error("Error opening config file ({})\n", configPath);
return;
logger::info("Unable to open user config file ({}); trying default ({})", configPath, defaultConfigPath);
configPath = defaultConfigPath;
i.open(configPath);
if (!i.is_open()) {
logger::error("Error opening config file ({})\n", configPath);
return;
}
}
logger::info("Loading config file ({})", configPath);

json settings;
try {
Expand Down Expand Up @@ -115,7 +120,7 @@ void State::Load()
void State::Save()
{
auto& shaderCache = SIE::ShaderCache::Instance();
std::ofstream o(L"Data\\SKSE\\Plugins\\CommunityShaders.json");
std::ofstream o(userConfigPath);
json settings;

Menu::GetSingleton()->Save(settings);
Expand Down
2 changes: 2 additions & 0 deletions src/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ 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 userConfigPath = "Data\\SKSE\\Plugins\\CommunityShadersUSER.json";
const std::string defaultConfigPath = "Data\\SKSE\\Plugins\\CommunityShaders.json";

void Draw();
void Reset();
Expand Down

0 comments on commit 11d1684

Please sign in to comment.