2018-07-10 16:40:57 +00:00
|
|
|
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
|
|
|
|
#include "ImGuiInputHandlerFactory.h"
|
|
|
|
#include "ImGuiInputHandler.h"
|
|
|
|
|
2020-06-25 09:52:46 +00:00
|
|
|
#include "ImGuiModuleDebug.h"
|
|
|
|
|
2020-06-14 20:50:26 +00:00
|
|
|
#include <Engine/GameViewportClient.h>
|
2020-06-25 09:52:46 +00:00
|
|
|
#include <InputCoreTypes.h>
|
2020-06-14 20:50:26 +00:00
|
|
|
|
2018-07-10 16:40:57 +00:00
|
|
|
|
2022-03-01 18:46:21 +00:00
|
|
|
UImGuiInputHandler* FImGuiInputHandlerFactory::NewHandler(const FSoftClassPath& HandlerClassReference, FImGuiModuleManager* ModuleManager, UGameViewportClient* GameViewport, int32 ContextIndex)
|
2018-07-10 16:40:57 +00:00
|
|
|
{
|
|
|
|
UClass* HandlerClass = nullptr;
|
2018-12-08 21:03:18 +00:00
|
|
|
if (HandlerClassReference.IsValid())
|
2018-07-10 16:40:57 +00:00
|
|
|
{
|
2018-12-08 21:03:18 +00:00
|
|
|
HandlerClass = HandlerClassReference.TryLoadClass<UImGuiInputHandler>();
|
2018-07-10 16:40:57 +00:00
|
|
|
|
2018-12-08 21:03:18 +00:00
|
|
|
if (!HandlerClass)
|
|
|
|
{
|
|
|
|
UE_LOG(LogImGuiInputHandler, Error, TEXT("Couldn't load ImGui Input Handler class '%s'."), *HandlerClassReference.ToString());
|
2018-07-10 16:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!HandlerClass)
|
|
|
|
{
|
|
|
|
HandlerClass = UImGuiInputHandler::StaticClass();
|
|
|
|
}
|
|
|
|
|
|
|
|
UImGuiInputHandler* Handler = NewObject<UImGuiInputHandler>(GameViewport, HandlerClass);
|
|
|
|
if (Handler)
|
|
|
|
{
|
|
|
|
Handler->Initialize(ModuleManager, GameViewport, ContextIndex);
|
|
|
|
Handler->AddToRoot();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-30 22:25:48 +00:00
|
|
|
UE_LOG(LogImGuiInputHandler, Error, TEXT("Failed attempt to create Input Handler: HandlerClass = %s."), *GetNameSafe(HandlerClass));
|
2018-07-10 16:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FImGuiInputHandlerFactory::ReleaseHandler(UImGuiInputHandler* Handler)
|
|
|
|
{
|
|
|
|
if (Handler)
|
|
|
|
{
|
|
|
|
Handler->RemoveFromRoot();
|
|
|
|
}
|
|
|
|
}
|