2019-04-10 19:19:11 +00:00
|
|
|
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Containers/Map.h>
|
|
|
|
#include <Delegates/Delegate.h>
|
|
|
|
|
|
|
|
|
2020-08-26 21:31:30 +00:00
|
|
|
#if WITH_EDITOR
|
2020-07-31 09:24:53 +00:00
|
|
|
struct FImGuiDelegatesContainerHandle;
|
2020-08-26 21:31:30 +00:00
|
|
|
#endif
|
2020-07-31 09:24:53 +00:00
|
|
|
|
2019-04-10 19:19:11 +00:00
|
|
|
struct FImGuiDelegatesContainer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Get the current instance (can change during hot-reloading).
|
2020-07-31 09:24:53 +00:00
|
|
|
static FImGuiDelegatesContainer& Get();
|
|
|
|
|
2020-08-26 21:31:30 +00:00
|
|
|
#if WITH_EDITOR
|
2020-07-31 09:24:53 +00:00
|
|
|
// Get the handle to the container instance (can attach to other handles in hot-reloaded modules).
|
|
|
|
static FImGuiDelegatesContainerHandle& GetHandle();
|
2019-04-10 19:19:11 +00:00
|
|
|
|
2020-07-31 09:24:53 +00:00
|
|
|
// Redirect to the other container and if this one is still active move its data to the other one.
|
|
|
|
static void MoveContainer(FImGuiDelegatesContainerHandle& OtherContainerHandle);
|
2020-08-26 21:31:30 +00:00
|
|
|
#endif
|
2019-04-10 19:19:11 +00:00
|
|
|
|
2019-04-14 11:16:15 +00:00
|
|
|
// Get delegate to ImGui world early debug event from known world instance.
|
|
|
|
FSimpleMulticastDelegate& OnWorldEarlyDebug(UWorld* World) { return OnWorldEarlyDebug(GetContextIndex(World)); }
|
|
|
|
|
|
|
|
// Get delegate to ImGui world early debug event from known context index.
|
|
|
|
FSimpleMulticastDelegate& OnWorldEarlyDebug(int32 ContextIndex) { return WorldEarlyDebugDelegates.FindOrAdd(ContextIndex); }
|
|
|
|
|
|
|
|
// Get delegate to ImGui multi-context early debug event.
|
|
|
|
FSimpleMulticastDelegate& OnMultiContextEarlyDebug() { return MultiContextEarlyDebugDelegate; }
|
|
|
|
|
2019-04-10 19:19:11 +00:00
|
|
|
// Get delegate to ImGui world debug event from known world instance.
|
2019-04-14 11:16:15 +00:00
|
|
|
FSimpleMulticastDelegate& OnWorldDebug(UWorld* World) { return OnWorldDebug(GetContextIndex(World)); }
|
2019-04-10 19:19:11 +00:00
|
|
|
|
|
|
|
// Get delegate to ImGui world debug event from known context index.
|
2019-04-14 11:16:15 +00:00
|
|
|
FSimpleMulticastDelegate& OnWorldDebug(int32 ContextIndex) { return WorldDebugDelegates.FindOrAdd(ContextIndex); }
|
2019-04-10 19:19:11 +00:00
|
|
|
|
|
|
|
// Get delegate to ImGui multi-context debug event.
|
2019-04-14 11:16:15 +00:00
|
|
|
FSimpleMulticastDelegate& OnMultiContextDebug() { return MultiContextDebugDelegate; }
|
2019-04-10 19:19:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2019-04-14 11:16:15 +00:00
|
|
|
int32 GetContextIndex(UWorld* World);
|
|
|
|
|
2019-04-10 19:19:11 +00:00
|
|
|
void Clear();
|
|
|
|
|
2019-04-14 11:16:15 +00:00
|
|
|
TMap<int32, FSimpleMulticastDelegate> WorldEarlyDebugDelegates;
|
|
|
|
TMap<int32, FSimpleMulticastDelegate> WorldDebugDelegates;
|
|
|
|
FSimpleMulticastDelegate MultiContextEarlyDebugDelegate;
|
|
|
|
FSimpleMulticastDelegate MultiContextDebugDelegate;
|
2019-04-10 19:19:11 +00:00
|
|
|
};
|