Runtime save console commands as user settings?

Does anyone know how to best handle this? I’m trying to implement a graphic option that lets users change anti aliasing method, bloom, ambient occlusion, turn off lumen, etc.. None of these have GetGameUserSettings values. I can retrieve and set the values using console commands, which works fine, but that has no functionality for saving. So how and where would I save these command results?

So for example “r.AntiAliasingMethod 0” would turn off anti aliasing, but how would I go about saving that so that on restart it still is applied.

If you are making custom settings on the frontend side, you can simply save the selected values yourself.

For example, save AA method, bloom, Lumen on/off, etc. into a SaveGame object. On game/session start, load that SaveGame object and re-apply those settings with console commands.

So when the player changes the option AntiAliasing you execute the command, save 0 as the selected AA method, then apply it again on next startup.

Also this below can help just in case sending.

It is also possible to read/write config/ini values and parse those into your settings menu, but for Blueprint/frontend settings, SaveGame + reapplying console commands is usually the simpler route.

I was doing that method in my last work on an options menu, it was working nice, read write ini with userconfig sharing this if helps you or somebody else in the future.

FString UMGSaveGameSubsystem::GetConfigIni(EMGIniConfigType IniType)
{
	FString ConfigFile;
	
	switch (IniType)
	{
	case EMGIniConfigType::EGameIni:
		ConfigFile = GGameIni;
		break;
	case EMGIniConfigType::EGameUserIni:
		ConfigFile = GGameUserSettingsIni;
		break; 
	case EMGIniConfigType::EEngineIni:
		ConfigFile = GEngineIni;
		break;
	case EMGIniConfigType::EInputIni:
		ConfigFile = GInputIni;
		break;
	case EMGIniConfigType::ESaveGameIni:
	
		ConfigFile = FConfigCacheIni::NormalizeConfigIniPath(FPaths::ProjectConfigDir() + TEXT("/DefaultGame.ini"));
		break;
	default: break; 
	}
	
	return ConfigFile;
}

FString UMGSaveGameSubsystem::ReadIniValue(EMGIniConfigType IniType, const FString SectionName, const FString PropertyName)
{
	FString Value;
	GConfig->GetString(*SectionName, *PropertyName, Value, GetConfigIni(IniType));
	return Value;
}

void UMGSaveGameSubsystem::WriteIniValue(EMGIniConfigType IniType, const FString SectionName, const FString PropertyName, const FString Value)
{
	GConfig->SetString(*SectionName, *PropertyName, *Value, GetConfigIni(IniType));
}

void UMGSaveGameSubsystem::RemoveIniValue(EMGIniConfigType IniType, const FString SectionName, const FString PropertyName, const FString Value)
{
	GConfig->RemoveFromSection(*SectionName, *PropertyName, *Value, GetConfigIni(IniType));
}
TArray<FString> UMGSaveGameSubsystem::ReadIniSection(EMGIniConfigType IniType, const FString SectionName)
{
	TArray<FString> SectionArray;
	FString Config = GetConfigIni(IniType);
	GConfig->GetSection(*SectionName, SectionArray, Config);

	//Maybe we can write a parser ? but this time values can vary in many terms?
	return SectionArray;
}

The GameUserSettings class is meant to be derived from so that you can add project specific settings to it.

So you create your own class derived from UGameUserSettings and there is a project setting (very similar to how you configure the GameInstance type your project should create when run).