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();
|
|
|
|
|
|
|
|
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-07-30 21:05:59 +00:00
|
|
|
else if (UpdatedPropertyName == GET_MEMBER_NAME_CHECKED(UImGuiSettings, SwitchInputModeKey))
|
|
|
|
{
|
2018-11-24 19:54:01 +00:00
|
|
|
OnSwitchInputModeKeyChanged.Broadcast();
|
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-07-10 16:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // WITH_EDITOR
|