// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved. #pragma once #include "ImGuiInputHandler.h" #include #include // Select right soft class reference header to avoid warning. #if ENGINE_COMPATIBILITY_LEGACY_STRING_CLASS_REF #include #else #include #endif #include "ImGuiSettings.generated.h" /** * Struct containing key information that can be used for key binding. Using 'Undetermined' value for modifier keys * means that those keys should be ignored when testing for a match. */ USTRUCT() struct FImGuiKeyInfo { GENERATED_BODY() UPROPERTY(EditAnywhere) FKey Key; UPROPERTY(EditAnywhere) ECheckBoxState Shift = ECheckBoxState::Undetermined; UPROPERTY(EditAnywhere) ECheckBoxState Ctrl = ECheckBoxState::Undetermined; UPROPERTY(EditAnywhere) ECheckBoxState Alt = ECheckBoxState::Undetermined; UPROPERTY(EditAnywhere) ECheckBoxState Cmd = ECheckBoxState::Undetermined; }; // Settings for ImGui module. UCLASS(config=ImGui, defaultconfig) class UImGuiSettings : public UObject { GENERATED_BODY() public: // Delegate raised when settings instance is loaded. static FSimpleMulticastDelegate& OnSettingsLoaded(); UImGuiSettings(); ~UImGuiSettings(); // Path to custom implementation of ImGui Input Handler. const FStringClassReference& GetImGuiInputHandlerClass() const { return ImGuiInputHandlerClass; } // Get the shortcut key info for 'ImGui.ToggleInput' command. const FImGuiKeyInfo& GetToggleInputKey() const { return ToggleInput; } // Check whether ImGui should draw its own software cursor. bool UseSoftwareCursor() const { return bUseSoftwareCursor; } // Delegate raised when ImGuiInputHandlerClass is changed. FSimpleMulticastDelegate OnImGuiInputHandlerClassChanged; // Delegate raised when ToggleInput key is changed. FSimpleMulticastDelegate OnToggleInputKeyChanged; // Delegate raised when SoftwareCursorEnabled property is changed. FSimpleMulticastDelegate OnSoftwareCursorChanged; virtual void PostInitProperties() override; virtual void BeginDestroy() override; protected: // Path to own implementation of ImGui Input Handler allowing to customize handling of keyboard and gamepad input. // If not set then default handler is used. UPROPERTY(EditAnywhere, config, Category = "Extensions", meta = (MetaClass = "ImGuiInputHandler")) FStringClassReference ImGuiInputHandlerClass; // Define a shortcut key to 'ImGui.ToggleInput' command. Binding is only set if the key field is valid. // Note that modifier key properties can be set to one of the three values: undetermined means that state of the given // modifier is not important, checked means that it needs to be pressed and unchecked means that it cannot be pressed. // // This binding is using Player Input's DebugExecBindings which only works in non-shipment builds. UPROPERTY(EditAnywhere, config, Category = "Keyboard Shortcuts") FImGuiKeyInfo ToggleInput; // Deprecated name for ToggleInput. Kept temporarily to automatically move old configuration. UPROPERTY(config) FImGuiKeyInfo SwitchInputModeKey_DEPRECATED; // If true, then in input mode ImGui will draw its own cursor in place of the hardware one. // When disabled (default) there is a noticeable difference between cursor position seen by ImGui and position on // the screen. Enabling this option removes that effect but with lower frame-rates UI becomes quickly unusable. UPROPERTY(EditAnywhere, config, Category = "Input") bool bUseSoftwareCursor = false; private: #if WITH_EDITOR void RegisterPropertyChangedDelegate(); void UnregisterPropertyChangedDelegate(); void OnPropertyChanged(class UObject* ObjectBeingModified, struct FPropertyChangedEvent& PropertyChangedEvent); #endif // WITH_EDITOR }; // Pointer to the settings instance (default class object) assigned right after it is initialized and valid until // it is destroyed. extern UImGuiSettings* GImGuiSettings;