Skip to content

Commit f154cc2

Browse files
committed
BaseINI: allow loading a specified base INI, eg for global configuration
1 parent 5ffc79d commit f154cc2

4 files changed

Lines changed: 33 additions & 3 deletions

File tree

dlsstweaks.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,13 @@ DisableIniMonitoring = false
164164
; So in case game doesn't seem to apply DLSSPresets section for you at all, you can try seeing if OverrideAppId can still help
165165
; (in majority of cases this likely won't be needed however)
166166
OverrideAppId = false
167+
168+
[DLSSTweaks]
169+
; BaseINI: if set, DLSSTweaks will try reading INI settings from the specified file path before processing any settings from this INI
170+
; In effect this allows the use of a "global configuration" file, you can populate this central INI file with your desired settings, update all your game INI files to reference it, and any changes made to the central INI will then get applied to all your games
171+
; (for best results it's recommended to comment/remove all settings from the game INI file except for BaseINI setting, then selectively add back settings you wish to override)
172+
;
173+
; Notes:
174+
; - ConfigTool likely won't work that well with game INIs which make use of BaseINI, but the tool should work fine on the actual BaseINI itself
175+
; - INI monitoring during gameplay only monitors the main game INI, changes to BaseINI won't be detected, as a workaround you can make a small edit to the game INI for monitoring to notice & reload settings, which will then reload BaseINI too
176+
;BaseINI = C:\DLSS\DLSSTweaks.ini

src/DLSSTweaks.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct UserSettings
7373
int dynamicResolutionMinOffset = -1;
7474
bool disableIniMonitoring = false;
7575

76-
bool read(const std::filesystem::path& iniPath);
76+
bool read(const std::filesystem::path& iniPath, int numInisRead = 0);
7777
void print_to_log();
7878
};
7979

src/DllMain.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void UserSettings::print_to_log()
271271
}
272272
}
273273

274-
bool UserSettings::read(const std::filesystem::path& iniPath)
274+
bool UserSettings::read(const std::filesystem::path& iniPath, int numInisRead)
275275
{
276276
using namespace utility;
277277

@@ -285,6 +285,26 @@ bool UserSettings::read(const std::filesystem::path& iniPath)
285285
inih::INIReader ini(iniFile);
286286
fclose(iniFile);
287287

288+
// [DLSSTweaks]
289+
290+
// BaseINI: specifies an INI file which will be read in before the rest of the INI
291+
// acting as a sort of global config file if the path has been set up
292+
auto baseIni = utility::ini_get_string_safe(ini, "DLSSTweaks", "BaseINI", "");
293+
if (!baseIni.empty())
294+
{
295+
// make sure we aren't trying to read in the current INI that we're reading...
296+
if (std::filesystem::absolute(iniPath) != std::filesystem::absolute(baseIni))
297+
{
298+
if (numInisRead > 10)
299+
spdlog::error("BaseINI: followed too many base INIs, might be caught in a loop, skipping further base INIs..");
300+
else
301+
{
302+
if (read(baseIni, numInisRead + 1))
303+
spdlog::info("Config read from {}", baseIni);
304+
}
305+
}
306+
}
307+
288308
// [DLSS]
289309
forceDLAA = ini.Get<bool>("DLSS", "ForceDLAA", std::move(forceDLAA));
290310
overrideAutoExposure = ini.Get<int>("DLSS", "OverrideAutoExposure", std::move(overrideAutoExposure));

src/resource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define TWEAKS_VER_MAJOR 0
1717
#define TWEAKS_VER_MINOR 200
1818
#define TWEAKS_VER_BUILD 8
19-
#define TWEAKS_VER_REVISION 1
19+
#define TWEAKS_VER_REVISION 2
2020

2121
#define STR(value) #value
2222
#define STRINGIZE(value) STR(value)

0 commit comments

Comments
 (0)