Moved ImGui Module Properties to public directory and added to ImGui Module interface allowing access their instance.

This commit is contained in:
Sebastian 2018-11-26 20:20:53 +00:00
parent a8ba10d074
commit 62d26f4ee5
3 changed files with 40 additions and 17 deletions

View File

@ -185,6 +185,16 @@ ImGuiContext** FImGuiModule::GetImGuiContextHandle()
} }
#endif #endif
FImGuiModuleProperties& FImGuiModule::GetProperties()
{
return ImGuiModuleManager->GetProperties();
}
const FImGuiModuleProperties& FImGuiModule::GetProperties() const
{
return ImGuiModuleManager->GetProperties();
}
bool FImGuiModule::IsInputMode() const bool FImGuiModule::IsInputMode() const
{ {
return ImGuiModuleManager && ImGuiModuleManager->GetProperties().IsInputEnabled(); return ImGuiModuleManager && ImGuiModuleManager->GetProperties().IsInputEnabled();

View File

@ -3,6 +3,7 @@
#pragma once #pragma once
#include "ImGuiDelegates.h" #include "ImGuiDelegates.h"
#include "ImGuiModuleProperties.h"
#include "ImGuiTextureHandle.h" #include "ImGuiTextureHandle.h"
#include <ModuleManager.h> #include <ModuleManager.h>
@ -104,6 +105,15 @@ public:
virtual void ReleaseTexture(const FImGuiTextureHandle& Handle); virtual void ReleaseTexture(const FImGuiTextureHandle& Handle);
/** /**
* Get ImGui module properties.
*
* @returns Reference to an instance of ImGui module properties that allows to read and/or modify module state.
*/
virtual FImGuiModuleProperties& GetProperties();
virtual const FImGuiModuleProperties& GetProperties() const;
/**
* DEPRECIATED: Please use GetProperties() as this function is scheduled for removal.
* Check whether Input Mode is enabled (tests ImGui.InputEnabled console variable). * Check whether Input Mode is enabled (tests ImGui.InputEnabled console variable).
* *
* @returns True, if Input Mode is enabled (ImGui.InputEnabled != 0) and false otherwise. * @returns True, if Input Mode is enabled (ImGui.InputEnabled != 0) and false otherwise.
@ -111,6 +121,7 @@ public:
virtual bool IsInputMode() const; virtual bool IsInputMode() const;
/** /**
* DEPRECIATED: Please use GetProperties() as this function is scheduled for removal.
* Set Input Mode state (sets ImGui.InputEnabled console variable, so it can be used together with a console). * Set Input Mode state (sets ImGui.InputEnabled console variable, so it can be used together with a console).
* *
* @param bEnabled - Whether Input Mode should be enabled (ImGui.InputEnabled = 1) or not (ImGui.InputEnabled = 0). * @param bEnabled - Whether Input Mode should be enabled (ImGui.InputEnabled = 1) or not (ImGui.InputEnabled = 0).
@ -118,11 +129,13 @@ public:
virtual void SetInputMode(bool bEnabled); virtual void SetInputMode(bool bEnabled);
/** /**
* DEPRECIATED: Please use GetProperties() as this function is scheduled for removal.
* Toggle Input Mode state (changes ImGui.InputEnabled console variable). * Toggle Input Mode state (changes ImGui.InputEnabled console variable).
*/ */
virtual void ToggleInputMode(); virtual void ToggleInputMode();
/** /**
* DEPRECIATED: Please use GetProperties() as this function is scheduled for removal.
* Check whether ImGui Demo is shown (tests ImGui.ShowDemo console variable). * Check whether ImGui Demo is shown (tests ImGui.ShowDemo console variable).
* *
* @returns True, if demo is shown (ImGui.ShowDemo != 0) and false otherwise. * @returns True, if demo is shown (ImGui.ShowDemo != 0) and false otherwise.
@ -130,6 +143,7 @@ public:
virtual bool IsShowingDemo() const; virtual bool IsShowingDemo() const;
/** /**
* DEPRECIATED: Please use GetProperties() as this function is scheduled for removal.
* Set whether to show ImGui Demo (sets ImGui.ShowDemo console variable, so it can be used together with a console). * Set whether to show ImGui Demo (sets ImGui.ShowDemo console variable, so it can be used together with a console).
* *
* @param bShow - Whether to show ImGui Demo (ImGui.ShowDemo = 1) or not (ImGui.ShowDemo = 0). * @param bShow - Whether to show ImGui Demo (ImGui.ShowDemo = 1) or not (ImGui.ShowDemo = 0).
@ -137,6 +151,7 @@ public:
virtual void SetShowDemo(bool bShow); virtual void SetShowDemo(bool bShow);
/** /**
* DEPRECIATED: Please use GetProperties() as this function is scheduled for removal.
* Toggle ImGui Demo (changes ImGui.ShowDemo console variable). * Toggle ImGui Demo (changes ImGui.ShowDemo console variable).
*/ */
virtual void ToggleShowDemo(); virtual void ToggleShowDemo();
@ -148,7 +163,7 @@ public:
private: private:
#if WITH_EDITOR #if WITH_EDITOR
virtual void SetProperties(const class FImGuiModuleProperties& Properties); virtual void SetProperties(const FImGuiModuleProperties& Properties);
virtual struct ImGuiContext** GetImGuiContextHandle(); virtual struct ImGuiContext** GetImGuiContextHandle();
#endif #endif
}; };

View File

@ -2,48 +2,46 @@
#pragma once #pragma once
#include <IConsoleManager.h>
/** Properties that define state of the ImGui module. */
// Collects and give access to module properties. class IMGUI_API FImGuiModuleProperties
class FImGuiModuleProperties
{ {
public: public:
// Check whether input is enabled. /** Check whether input is enabled. */
bool IsInputEnabled() const { return bInputEnabled; } bool IsInputEnabled() const { return bInputEnabled; }
// Enable or disable ImGui input. /** Enable or disable ImGui input. */
void SetInputEnabled(bool bEnabled) { bInputEnabled = bEnabled; } void SetInputEnabled(bool bEnabled) { bInputEnabled = bEnabled; }
// Toggle ImGui input. /** Toggle ImGui input. */
void ToggleInput() { SetInputEnabled(!IsInputEnabled()); } void ToggleInput() { SetInputEnabled(!IsInputEnabled()); }
// Check whether keyboard navigation is enabled. /** Check whether keyboard navigation is enabled. */
bool IsKeyboardNavigationEnabled() const { return bKeyboardNavigationEnabled; } bool IsKeyboardNavigationEnabled() const { return bKeyboardNavigationEnabled; }
// Enable or disable keyboard navigation. /** Enable or disable keyboard navigation. */
void SetKeyboardNavigationEnabled(bool bEnabled) { bKeyboardNavigationEnabled = bEnabled; } void SetKeyboardNavigationEnabled(bool bEnabled) { bKeyboardNavigationEnabled = bEnabled; }
// Toggle keyboard navigation. /** Toggle keyboard navigation. */
void ToggleKeyboardNavigation() { SetKeyboardNavigationEnabled(!IsKeyboardNavigationEnabled()); } void ToggleKeyboardNavigation() { SetKeyboardNavigationEnabled(!IsKeyboardNavigationEnabled()); }
// Check whether gamepad navigation is enabled. /** Check whether gamepad navigation is enabled. */
bool IsGamepadNavigationEnabled() const { return bGamepadNavigationEnabled; } bool IsGamepadNavigationEnabled() const { return bGamepadNavigationEnabled; }
// Enable or disable gamepad navigation. /** Enable or disable gamepad navigation. */
void SetGamepadNavigationEnabled(bool bEnabled) { bGamepadNavigationEnabled = bEnabled; } void SetGamepadNavigationEnabled(bool bEnabled) { bGamepadNavigationEnabled = bEnabled; }
// Toggle gamepad navigation. /** Toggle gamepad navigation. */
void ToggleGamepadNavigation() { SetGamepadNavigationEnabled(!IsGamepadNavigationEnabled()); } void ToggleGamepadNavigation() { SetGamepadNavigationEnabled(!IsGamepadNavigationEnabled()); }
// Check whether ImGui demo is visible. /** Check whether ImGui demo is visible. */
bool ShowDemo() const { return bShowDemo; } bool ShowDemo() const { return bShowDemo; }
// Show or hide ImGui demo. /** Show or hide ImGui demo. */
void SetShowDemo(bool bShow) { bShowDemo = bShow; } void SetShowDemo(bool bShow) { bShowDemo = bShow; }
// Toggle ImGui demo. /** Toggle ImGui demo. */
void ToggleDemo() { SetShowDemo(!ShowDemo()); } void ToggleDemo() { SetShowDemo(!ShowDemo()); }
private: private: