I can’t quite figure out why this is happening, but whenever I call GConfig->SetInt (presumably also an issue with other similar methods), it writes a duplicate line in the file, and not even in the right place.
Here is what my custom method looks like:
void UCustomSettingsHandler::SaveSettings()
{
UE_LOG(LogTemp, Log, TEXT("UCustomSettingsHandler SaveSettings start"));
GConfig->SetInt(TEXT("Upscaler Settings"), TEXT("Upscaler"), Upscaler, CustomConfigFilePath);
GConfig->SetInt(TEXT("Upscaler Settings | Nvidia"), TEXT("DLSSMode"), DlssMode, CustomConfigFilePath);
GConfig->SetInt(TEXT("Upscaler Settings | Nvidia"), TEXT("DLSSFrameGen"), DlssFrameGen, CustomConfigFilePath);
GConfig->SetInt(TEXT("Upscaler Settings | Nvidia"), TEXT("ReflexMode"), ReflexMode, CustomConfigFilePath);
GConfig->SetInt(TEXT("Upscaler Settings | AMD"), TEXT("FSRMode"), FsrMode, CustomConfigFilePath);
GConfig->SetInt(TEXT("Upscaler Settings | AMD"), TEXT("FSRFrameGen"), bFsrFrameGen, CustomConfigFilePath);
UE_LOG(LogTemp, Log, TEXT("UCustomSettingsHandler SaveSettings end"));
}
And here is what my CustomSettings.ini looks like after launching the packaged game 3 times:
[Upscaler Settings]
Upscaler=0
DlssMode=7
DlssMode=7
DlssFrameGen=2
DlssFrameGen=2
ReflexMode=0
ReflexMode=0
FsrMode=5
FsrMode=5
FSRFrameGen=0
FSRFrameGen=0
[Upscaler Settings | Nvidia]
DlssMode=7
DlssFrameGen=2
ReflexMode=0
[Upscaler Settings | AMD]
FsrMode=5
FSRFrameGen=0
Currently, all I do in blueprint is load the settings at launch, apply some things, and then save them back using the above method.
After the first launch, the ini looks right, apart from DLSSMode being called DlssMode and FSRMode being called FsrMode in the ini, even though I explicitly set them to be named TEXT(“DLSSMode”) and TEXT(“FSRMode”)).
Then after a second launch, for whatever reason, it saves duplicates of all the settings under the [Upscaler Settings] section, even though I’m calling the SetInt method with TEXT(“Upscaler Settings | Nvidia”) as the section.
What gives?
Any idea what I’m doing wrong?
If I can’t figure this out, I guess I’ll have to write my own file reader/writer and give up on the whole GConfig system…