Skip to content

Commit

Permalink
Local Settings - First Commit
Browse files Browse the repository at this point in the history
If you have a copy of config.ini saved at the same folder as the player app, it will load the game settings from it, instead of the global folder.

-------------------------------------

I used std::filesystem, because couldn't figure another way of extracting the apps absolute path.
  • Loading branch information
jetrotal committed Jul 24, 2024
1 parent 4077070 commit 4d528f5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/game_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "input.h"
#include <lcf/inireader.h>
#include <cstring>
#include <filesystem>

#ifdef _WIN32
# include <shlobj.h>
Expand Down Expand Up @@ -94,6 +95,10 @@ Game_Config Game_Config::Create(CmdlineParser& cp) {
if (!config_path.empty()) {
config_file = FileFinder::MakePath(config_path, config_name);
}
else {
std::string localPath = FileFinder::MakePath(std::filesystem::current_path().string(), config_name);
if (std::filesystem::exists(localPath)) config_file = localPath;
}

auto cli_config = FileFinder::Root().OpenOrCreateInputStream(config_file);
if (!cli_config) {
Expand Down

0 comments on commit 4d528f5

Please sign in to comment.