mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 16:30:32 +00:00
fc6fd2e498
- Added common debug config file for module-wide debug symbols and loggers. - Added IMGUI_MODULE_DEVELOPER symbol to enable or disable module developer mode, that is intended to add additional module debug options hidden from normal usage. - ImGui Widget debug is only available in developer mode because in normal usage it adds noise to ImGui console variables while not being very useful. - Merged LogImGuiInputHandler and LogImGuiInputHandlerFactory loggers as they are part of the same feature. - Renamed LogImGuiInputState to LogImGuiInput.
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
#include "ImGuiPrivatePCH.h"
|
|
|
|
#include "ImGuiInputHandlerFactory.h"
|
|
|
|
#include "ImGuiInputHandler.h"
|
|
#include "ImGuiSettings.h"
|
|
|
|
|
|
UImGuiInputHandler* FImGuiInputHandlerFactory::NewHandler(FImGuiModuleManager* ModuleManager, UGameViewportClient* GameViewport, int32 ContextIndex)
|
|
{
|
|
UClass* HandlerClass = nullptr;
|
|
if (UImGuiSettings* Settings = GetMutableDefault<UImGuiSettings>())
|
|
{
|
|
const auto& HandlerClassReference = Settings->GetImGuiInputHandlerClass();
|
|
if (HandlerClassReference.IsValid())
|
|
{
|
|
HandlerClass = HandlerClassReference.TryLoadClass<UImGuiInputHandler>();
|
|
|
|
if (!HandlerClass)
|
|
{
|
|
UE_LOG(LogImGuiInputHandler, Error, TEXT("Couldn't load ImGui Input Handler class '%s'."), *HandlerClassReference.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!HandlerClass)
|
|
{
|
|
HandlerClass = UImGuiInputHandler::StaticClass();
|
|
}
|
|
|
|
UImGuiInputHandler* Handler = NewObject<UImGuiInputHandler>(GameViewport, HandlerClass);
|
|
if (Handler)
|
|
{
|
|
Handler->Initialize(ModuleManager, GameViewport, ContextIndex);
|
|
Handler->AddToRoot();
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogImGuiInputHandler, Error, TEXT("Failed attempt to create Input Handler: HandlerClass = %s."), *GetNameSafe(HandlerClass));
|
|
}
|
|
|
|
return Handler;
|
|
}
|
|
|
|
void FImGuiInputHandlerFactory::ReleaseHandler(UImGuiInputHandler* Handler)
|
|
{
|
|
if (Handler)
|
|
{
|
|
Handler->RemoveFromRoot();
|
|
}
|
|
}
|