Create Editor Settings menu
This commit is contained in:
parent
98fb068e29
commit
76654dbe0a
10 changed files with 461 additions and 3 deletions
|
@ -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."));
|
||||
|
|
|
@ -195,6 +195,11 @@ public:
|
|||
*/
|
||||
static void DestroySettings();
|
||||
|
||||
protected:
|
||||
static const TMap<EProfile, FSettingsProfile>& GetProfiles();
|
||||
void RenameSetting(EProfile Profile, FName OldName, FName NewName);
|
||||
void ChangeSettingType(EProfile Profile, FName SettingName, EConfigValueType NewType);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Initializes the UHarmonyLinkGraphics settings.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
UENUM(BlueprintType)
|
||||
enum class EConfigValueType : uint8
|
||||
{
|
||||
None,
|
||||
Int,
|
||||
Float,
|
||||
Bool,
|
||||
|
@ -42,11 +43,13 @@ private:
|
|||
public:
|
||||
FHLConfigValue() : Type(EConfigValueType::String), IntValue(0), FloatValue(0.0f), BoolValue(false), StringValue(TEXT("")) {}
|
||||
|
||||
FHLConfigValue(int32 Value) : Type(EConfigValueType::Int), IntValue(Value), FloatValue(0.0f), BoolValue(false), StringValue(TEXT("")) {}
|
||||
FHLConfigValue(const EConfigValueType Type) : Type(Type), IntValue(0), FloatValue(0.0f), BoolValue(false), StringValue(TEXT("")) {}
|
||||
|
||||
FHLConfigValue(float Value) : Type(EConfigValueType::Float), IntValue(0), FloatValue(Value), BoolValue(false), StringValue(TEXT("")) {}
|
||||
FHLConfigValue(const int32 Value) : Type(EConfigValueType::Int), IntValue(Value), FloatValue(0.0f), BoolValue(false), StringValue(TEXT("")) {}
|
||||
|
||||
FHLConfigValue(bool Value) : Type(EConfigValueType::Bool), IntValue(0), FloatValue(0.0f), BoolValue(Value), StringValue(TEXT("")) {}
|
||||
FHLConfigValue(const float Value) : Type(EConfigValueType::Float), IntValue(0), FloatValue(Value), BoolValue(false), StringValue(TEXT("")) {}
|
||||
|
||||
FHLConfigValue(const bool Value) : Type(EConfigValueType::Bool), IntValue(0), FloatValue(0.0f), BoolValue(Value), StringValue(TEXT("")) {}
|
||||
|
||||
FHLConfigValue(const FString& Value) : Type(EConfigValueType::String), IntValue(0), FloatValue(0.0f), BoolValue(false), StringValue(Value) {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue