mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 16:30:32 +00:00
867a34e640
- Added new FImGuiDelegates interface for ImGui debug delegates. - Added FImGuiDelegatesContainer for ImGui delegates. - Added code preserving delegates during hot-reloading and moving them to a new module. - Depreciated old FImGuiModule delegates interface and FImGuiDelegateHandle. - Delegates registered with depreciated interface are redirected and get benefit of being preserved during hot-reloading. This can be controlled with IMGUI_REDIRECT_OBSOLETE_DELEGATES. - Added IMGUI_WITH_OBSOLETE_DELEGATES allowing to strip depreciated interface from builds. - Modified context manager and context proxy to work with FImGuiDelegatesContainer.
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
#pragma once
|
|
|
|
#include <Containers/Map.h>
|
|
#include <Delegates/Delegate.h>
|
|
|
|
|
|
struct FImGuiDelegatesContainer
|
|
{
|
|
public:
|
|
|
|
// Get the current instance (can change during hot-reloading).
|
|
static FImGuiDelegatesContainer& Get() { return *InstancePtr; }
|
|
|
|
// If this is an active container move its data to a destination and redirect all future calls to that instance.
|
|
static void MoveContainer(FImGuiDelegatesContainer& Dst);
|
|
|
|
// Get delegate to ImGui world debug event from known world instance.
|
|
FSimpleMulticastDelegate& OnWorldDebug(UWorld* World);
|
|
|
|
// Get delegate to ImGui world debug event from known context index.
|
|
FSimpleMulticastDelegate& OnWorldDebug(int32 ContextIndex) { return WorldDelegates.FindOrAdd(ContextIndex); }
|
|
|
|
// Get delegate to ImGui multi-context debug event.
|
|
FSimpleMulticastDelegate& OnMultiContextDebug() { return MultiContextDelegate; }
|
|
|
|
private:
|
|
|
|
void Clear();
|
|
|
|
TMap<int32, FSimpleMulticastDelegate> WorldDelegates;
|
|
FSimpleMulticastDelegate MultiContextDelegate;
|
|
|
|
// Default container instance.
|
|
static FImGuiDelegatesContainer DefaultInstance;
|
|
|
|
// Pointer to the container instance that can be overwritten during hot-reloading.
|
|
static FImGuiDelegatesContainer* InstancePtr;
|
|
};
|