Create Editor Settings menu

This commit is contained in:
Jordon Brooks 2024-07-08 21:58:14 +01:00
parent 98fb068e29
commit 76654dbe0a
Signed by: jordon
GPG key ID: DBD9758CD53E786A
10 changed files with 461 additions and 3 deletions

View file

@ -64,6 +64,11 @@ UHarmonyLinkGraphics::~UHarmonyLinkGraphics()
FWorldDelegates::OnPreWorldFinishDestroy.RemoveAll(this);
}
const TMap<EProfile, FSettingsProfile>& UHarmonyLinkGraphics::GetProfiles()
{
return _Profiles;
}
void UHarmonyLinkGraphics::LoadConfig(const bool bForceReload)
{
UE_LOG(LogHarmonyLinkSettings, Verbose, TEXT("LoadConfig called."));
@ -259,6 +264,53 @@ UHarmonyLinkGraphics* UHarmonyLinkGraphics::GetSettings()
return _INSTANCE;
}
void UHarmonyLinkGraphics::RenameSetting(EProfile Profile, FName OldName, FName NewName)
{
if (FSettingsProfile* SettingsProfile = _Profiles.Find(Profile))
{
if (SettingsProfile->Settings.Contains(OldName))
{
FHLConfigValue Value = SettingsProfile->Settings[OldName];
SettingsProfile->Settings.Remove(OldName);
SettingsProfile->Settings.Add(NewName, Value);
SaveConfig();
}
}
}
void UHarmonyLinkGraphics::ChangeSettingType(EProfile Profile, FName SettingName, EConfigValueType NewType)
{
if (FSettingsProfile* SettingsProfile = _Profiles.Find(Profile))
{
if (SettingsProfile->Settings.Contains(SettingName))
{
FHLConfigValue OldValue = SettingsProfile->Settings[SettingName];
SettingsProfile->Settings.Remove(SettingName);
FHLConfigValue NewValue;
switch (NewType)
{
case EConfigValueType::Int:
NewValue = FHLConfigValue(0); // Default to conversion from float
break;
case EConfigValueType::Float:
NewValue = FHLConfigValue(0.f); // Default to conversion from int
break;
case EConfigValueType::Bool:
NewValue = FHLConfigValue(false); // Default to conversion from int
break;
case EConfigValueType::String:
NewValue = FHLConfigValue(FString()); // Default to string
break;
default:
return;
}
SettingsProfile->Settings.Add(SettingName, NewValue);
SaveConfig();
}
}
}
FSettingsProfile UHarmonyLinkGraphics::GetSettingProfile(const EProfile Profile)
{
UE_LOG(LogHarmonyLinkSettings, Verbose, TEXT("GetSettingProfile called."));