mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 16:30:32 +00:00
75 lines
2.0 KiB
C++
75 lines
2.0 KiB
C++
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
#include "ImGuiPrivatePCH.h"
|
|
|
|
#include "ImGuiSettings.h"
|
|
#include "Utilities/DebugExecBindings.h"
|
|
|
|
|
|
UImGuiSettings::UImGuiSettings()
|
|
{
|
|
#if WITH_EDITOR
|
|
RegisterPropertyChangedDelegate();
|
|
#endif
|
|
}
|
|
|
|
UImGuiSettings::~UImGuiSettings()
|
|
{
|
|
#if WITH_EDITOR
|
|
UnregisterPropertyChangedDelegate();
|
|
#endif
|
|
}
|
|
|
|
namespace Commands
|
|
{
|
|
extern const TCHAR* SwitchInputMode;
|
|
}
|
|
|
|
void UImGuiSettings::PostInitProperties()
|
|
{
|
|
Super::PostInitProperties();
|
|
|
|
// Instead of saving binding to input config, we manually update DebugExecBindings from here. This has an advantage
|
|
// that there is no ambiguity where settings are stored and more importantly, it works out of the box in packed
|
|
// and staged builds.
|
|
DebugExecBindings::UpdatePlayerInputs(SwitchInputModeKey, Commands::SwitchInputMode);
|
|
}
|
|
|
|
#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;
|
|
|
|
if (UpdatedPropertyName == GET_MEMBER_NAME_CHECKED(UImGuiSettings, ImGuiInputHandlerClass))
|
|
{
|
|
OnImGuiInputHandlerClassChanged.Broadcast();
|
|
}
|
|
else if (UpdatedPropertyName == GET_MEMBER_NAME_CHECKED(UImGuiSettings, SwitchInputModeKey))
|
|
{
|
|
DebugExecBindings::UpdatePlayerInputs(SwitchInputModeKey, Commands::SwitchInputMode);
|
|
}
|
|
else if (UpdatedPropertyName == GET_MEMBER_NAME_CHECKED(UImGuiSettings, bUseSoftwareCursor))
|
|
{
|
|
OnSoftwareCursorChanged.Broadcast();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif // WITH_EDITOR
|