2018-07-10 16:40:57 +00:00
|
|
|
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
|
|
|
|
#include "ImGuiPrivatePCH.h"
|
|
|
|
|
|
|
|
#include "ImGuiSettings.h"
|
2018-11-24 19:54:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
UImGuiSettings* GImGuiSettings = nullptr;
|
|
|
|
|
|
|
|
FSimpleMulticastDelegate& UImGuiSettings::OnSettingsLoaded()
|
|
|
|
{
|
|
|
|
static FSimpleMulticastDelegate Instance;
|
|
|
|
return Instance;
|
|
|
|
}
|
2018-07-10 16:40:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
UImGuiSettings::UImGuiSettings()
|
|
|
|
{
|
|
|
|
#if WITH_EDITOR
|
|
|
|
RegisterPropertyChangedDelegate();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
UImGuiSettings::~UImGuiSettings()
|
|
|
|
{
|
|
|
|
#if WITH_EDITOR
|
|
|
|
UnregisterPropertyChangedDelegate();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-11-24 19:54:01 +00:00
|
|
|
void UImGuiSettings::PostInitProperties()
|
2018-07-30 21:05:59 +00:00
|
|
|
{
|
2018-11-24 19:54:01 +00:00
|
|
|
Super::PostInitProperties();
|
|
|
|
|
2018-11-24 21:16:25 +00:00
|
|
|
if (SwitchInputModeKey_DEPRECATED.Key.IsValid() && !ToggleInput.Key.IsValid())
|
|
|
|
{
|
|
|
|
const FString ConfigFileName = GetDefaultConfigFilename();
|
|
|
|
|
|
|
|
// Move value to the new property.
|
|
|
|
ToggleInput = MoveTemp(SwitchInputModeKey_DEPRECATED);
|
|
|
|
|
|
|
|
// Remove from configuration file entry for obsolete property.
|
|
|
|
if (FConfigFile* ConfigFile = GConfig->Find(ConfigFileName, false))
|
|
|
|
{
|
|
|
|
if (FConfigSection* Section = ConfigFile->Find(TEXT("/Script/ImGui.ImGuiSettings")))
|
|
|
|
{
|
|
|
|
if (Section->Remove(TEXT("SwitchInputModeKey")))
|
|
|
|
{
|
|
|
|
ConfigFile->Dirty = true;
|
|
|
|
GConfig->Flush(false, ConfigFileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add to configuration file entry for new property.
|
|
|
|
UpdateSinglePropertyInConfigFile(
|
|
|
|
UImGuiSettings::StaticClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(UImGuiSettings, ToggleInput)),
|
|
|
|
ConfigFileName);
|
|
|
|
}
|
|
|
|
|
2018-11-24 19:54:01 +00:00
|
|
|
if (IsTemplate())
|
|
|
|
{
|
|
|
|
GImGuiSettings = this;
|
|
|
|
OnSettingsLoaded().Broadcast();
|
|
|
|
}
|
2018-07-30 21:05:59 +00:00
|
|
|
}
|
|
|
|
|
2018-11-24 19:54:01 +00:00
|
|
|
void UImGuiSettings::BeginDestroy()
|
2018-07-30 21:05:59 +00:00
|
|
|
{
|
2018-11-24 19:54:01 +00:00
|
|
|
Super::BeginDestroy();
|
2018-07-30 21:05:59 +00:00
|
|
|
|
2018-11-24 19:54:01 +00:00
|
|
|
if (GImGuiSettings == this)
|
|
|
|
{
|
|
|
|
GImGuiSettings = nullptr;
|
|
|
|
}
|
2018-07-30 21:05:59 +00:00
|
|
|
}
|
|
|
|
|
2018-07-10 16:40:57 +00:00
|
|
|
#if WITH_EDITOR
|
|
|
|
|
|
|
|
void UImGuiSettings::RegisterPropertyChangedDelegate()
|
|
|
|
{
|
|
|
|
if (!FCoreUObjectDelegates::OnObjectPropertyChanged.IsBoundToObject(this))
|
|
|
|
{
|
|
|
|
FCoreUObjectDelegates::OnObjectPropertyChanged.AddUObject(this, &UImGuiSettings::OnPropertyChanged);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UImGuiSettings::UnregisterPropertyChangedDelegate()
|
|
|
|
{
|
|
|
|
FCoreUObjectDelegates::OnObjectPropertyChanged.RemoveAll(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UImGuiSettings::OnPropertyChanged(class UObject* ObjectBeingModified, struct FPropertyChangedEvent& PropertyChangedEvent)
|
|
|
|
{
|
|
|
|
if (ObjectBeingModified == this)
|
|
|
|
{
|
|
|
|
const FName UpdatedPropertyName = PropertyChangedEvent.MemberProperty ? PropertyChangedEvent.MemberProperty->GetFName() : NAME_None;
|
2018-07-30 21:05:59 +00:00
|
|
|
|
|
|
|
if (UpdatedPropertyName == GET_MEMBER_NAME_CHECKED(UImGuiSettings, ImGuiInputHandlerClass))
|
2018-07-10 16:40:57 +00:00
|
|
|
{
|
|
|
|
OnImGuiInputHandlerClassChanged.Broadcast();
|
|
|
|
}
|
2018-12-02 20:32:42 +00:00
|
|
|
else if (UpdatedPropertyName == GET_MEMBER_NAME_CHECKED(UImGuiSettings, bShareKeyboardInput))
|
2018-07-30 21:05:59 +00:00
|
|
|
{
|
2018-12-02 20:32:42 +00:00
|
|
|
OnShareKeyboardInputChanged.Broadcast(bShareKeyboardInput);
|
|
|
|
}
|
|
|
|
else if (UpdatedPropertyName == GET_MEMBER_NAME_CHECKED(UImGuiSettings, bShareGamepadInput))
|
|
|
|
{
|
|
|
|
OnShareGamepadInputChanged.Broadcast(bShareGamepadInput);
|
2018-07-30 21:05:59 +00:00
|
|
|
}
|
2018-10-28 21:15:02 +00:00
|
|
|
else if (UpdatedPropertyName == GET_MEMBER_NAME_CHECKED(UImGuiSettings, bUseSoftwareCursor))
|
|
|
|
{
|
|
|
|
OnSoftwareCursorChanged.Broadcast();
|
|
|
|
}
|
2018-12-02 20:32:42 +00:00
|
|
|
else if (UpdatedPropertyName == GET_MEMBER_NAME_CHECKED(UImGuiSettings, ToggleInput))
|
|
|
|
{
|
|
|
|
OnToggleInputKeyChanged.Broadcast();
|
|
|
|
}
|
2018-07-10 16:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // WITH_EDITOR
|