mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 08:20:32 +00:00
Added interface to modify from code console variables that control whether to enable ImGui Input Mode and show ImGui Demo.
This commit is contained in:
parent
19b9502e24
commit
933b7f1b3b
@ -12,6 +12,12 @@
|
||||
#define LOCTEXT_NAMESPACE "FImGuiModule"
|
||||
|
||||
|
||||
namespace CVars
|
||||
{
|
||||
extern TAutoConsoleVariable<int32> InputEnabled;
|
||||
extern TAutoConsoleVariable<int32> ShowDemo;
|
||||
}
|
||||
|
||||
struct EDelegateCategory
|
||||
{
|
||||
enum
|
||||
@ -100,6 +106,38 @@ void FImGuiModule::ShutdownModule()
|
||||
ModuleManager = nullptr;
|
||||
}
|
||||
|
||||
bool FImGuiModule::IsInputMode() const
|
||||
{
|
||||
return CVars::InputEnabled.GetValueOnAnyThread() > 0;
|
||||
}
|
||||
|
||||
void FImGuiModule::SetInputMode(bool bEnabled)
|
||||
{
|
||||
// This function is for supporting shortcut or subsitiute for console command, so we are using the same priority.
|
||||
CVars::InputEnabled->Set(bEnabled ? 1 : 0, ECVF_SetByConsole);
|
||||
}
|
||||
|
||||
void FImGuiModule::ToggleInputMode()
|
||||
{
|
||||
SetInputMode(!IsInputMode());
|
||||
}
|
||||
|
||||
bool FImGuiModule::IsShowingDemo() const
|
||||
{
|
||||
return CVars::ShowDemo.GetValueOnAnyThread() > 0;
|
||||
}
|
||||
|
||||
void FImGuiModule::SetShowDemo(bool bShow)
|
||||
{
|
||||
// This function is for supporting shortcut or subsitiute for console command, so we are using the same priority.
|
||||
CVars::ShowDemo->Set(bShow ? 1 : 0, ECVF_SetByConsole);
|
||||
}
|
||||
|
||||
void FImGuiModule::ToggleShowDemo()
|
||||
{
|
||||
SetShowDemo(!IsShowingDemo());
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FImGuiModule, ImGui)
|
||||
|
@ -69,6 +69,44 @@ public:
|
||||
*/
|
||||
virtual void RemoveImGuiDelegate(const FImGuiDelegateHandle& Handle);
|
||||
|
||||
/**
|
||||
* Check whether Input Mode is enabled (tests ImGui.InputEnabled console variable).
|
||||
*
|
||||
* @returns True, if Input Mode is enabled (ImGui.InputEnabled != 0) and false otherwise.
|
||||
*/
|
||||
virtual bool IsInputMode() const;
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*/
|
||||
virtual void SetInputMode(bool bEnabled);
|
||||
|
||||
/**
|
||||
* Toggle Input Mode state (changes ImGui.InputEnabled console variable).
|
||||
*/
|
||||
virtual void ToggleInputMode();
|
||||
|
||||
/**
|
||||
* Check whether ImGui Demo is shown (tests ImGui.ShowDemo console variable).
|
||||
*
|
||||
* @returns True, if demo is shown (ImGui.ShowDemo != 0) and false otherwise.
|
||||
*/
|
||||
virtual bool IsShowingDemo() const;
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*/
|
||||
virtual void SetShowDemo(bool bShow);
|
||||
|
||||
/**
|
||||
* Toggle ImGui Demo (changes ImGui.ShowDemo console variable).
|
||||
*/
|
||||
virtual void ToggleShowDemo();
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
Loading…
Reference in New Issue
Block a user