From d0034be4884d100c64687f39215d943809fc56ca Mon Sep 17 00:00:00 2001 From: WiggleWizard <1405402+WiggleWizard@users.noreply.github.com> Date: Fri, 25 Feb 2022 11:59:49 +0000 Subject: [PATCH] Added the ability to latch specific world's debug frame. Also moved ImGui's internal headers (with required supporting headers) to be public facing so devs have access to ImGui vec math and other luxuries to make their own widgets under the ImGui namespace --- Source/ImGui/Private/ImGuiModule.cpp | 6 ++++++ Source/ImGui/Public/ImGuiModule.h | 10 ++++++++++ .../ImGuiLibrary/{Private => Include}/imgui_internal.h | 0 .../ImGuiLibrary/{Private => Include}/imstb_textedit.h | 0 4 files changed, 16 insertions(+) rename Source/ThirdParty/ImGuiLibrary/{Private => Include}/imgui_internal.h (100%) rename Source/ThirdParty/ImGuiLibrary/{Private => Include}/imstb_textedit.h (100%) diff --git a/Source/ImGui/Private/ImGuiModule.cpp b/Source/ImGui/Private/ImGuiModule.cpp index ea12089..3534aeb 100644 --- a/Source/ImGui/Private/ImGuiModule.cpp +++ b/Source/ImGui/Private/ImGuiModule.cpp @@ -53,6 +53,12 @@ FImGuiDelegateHandle FImGuiModule::AddWorldImGuiDelegate(const FImGuiDelegate& D return { FImGuiDelegatesContainer::Get().OnWorldDebug(ContextIndex).Add(Delegate), EDelegateCategory::Default, ContextIndex }; } +FImGuiDelegateHandle FImGuiModule::AddWorldImGuiDelegate(const UWorld* World, const FImGuiDelegate& Delegate) +{ + const int32 ContextIndex = Utilities::GetWorldContextIndex(World); + return { FImGuiDelegatesContainer::Get().OnWorldDebug(ContextIndex).Add(Delegate), EDelegateCategory::Default, ContextIndex }; +} + FImGuiDelegateHandle FImGuiModule::AddMultiContextImGuiDelegate(const FImGuiDelegate& Delegate) { return { FImGuiDelegatesContainer::Get().OnMultiContextDebug().Add(Delegate), EDelegateCategory::MultiContext }; diff --git a/Source/ImGui/Public/ImGuiModule.h b/Source/ImGui/Public/ImGuiModule.h index ec2ac4a..8e63e60 100644 --- a/Source/ImGui/Public/ImGuiModule.h +++ b/Source/ImGui/Public/ImGuiModule.h @@ -57,6 +57,16 @@ public: */ virtual FImGuiDelegateHandle AddWorldImGuiDelegate(const FImGuiDelegate& Delegate); + /** + * Add a delegate called at the end of a specific world's debug frame to draw debug controls in its ImGui context, + * creating that context on demand. + * + * @param World - A specific world to add the delegate to to + * @param Delegate - Delegate that we want to add (@see FImGuiDelegate::Create...) + * @returns Returns handle that can be used to remove delegate (@see RemoveImGuiDelegate) + */ + virtual FImGuiDelegateHandle AddWorldImGuiDelegate(const UWorld* World, const FImGuiDelegate& Delegate); + /** * Add shared delegate called for each ImGui context at the end of debug frame, after calling context specific * delegate. This delegate will be used for any ImGui context, created before or after it is registered. diff --git a/Source/ThirdParty/ImGuiLibrary/Private/imgui_internal.h b/Source/ThirdParty/ImGuiLibrary/Include/imgui_internal.h similarity index 100% rename from Source/ThirdParty/ImGuiLibrary/Private/imgui_internal.h rename to Source/ThirdParty/ImGuiLibrary/Include/imgui_internal.h diff --git a/Source/ThirdParty/ImGuiLibrary/Private/imstb_textedit.h b/Source/ThirdParty/ImGuiLibrary/Include/imstb_textedit.h similarity index 100% rename from Source/ThirdParty/ImGuiLibrary/Private/imstb_textedit.h rename to Source/ThirdParty/ImGuiLibrary/Include/imstb_textedit.h