Added to ImGui Context Manager an event raised when a new context proxy is created.

This commit is contained in:
Sebastian 2018-11-27 20:54:26 +00:00
parent b1d000f696
commit e05cea2789
2 changed files with 17 additions and 0 deletions

View File

@ -122,6 +122,7 @@ FImGuiContextManager::FContextData& FImGuiContextManager::GetEditorContextData()
if (UNLIKELY(!Data)) if (UNLIKELY(!Data))
{ {
Data = &Contexts.Emplace(Utilities::EDITOR_CONTEXT_INDEX, FContextData{ GetEditorContextName(), Utilities::EDITOR_CONTEXT_INDEX, DrawMultiContextEvent, FontAtlas, -1 }); Data = &Contexts.Emplace(Utilities::EDITOR_CONTEXT_INDEX, FContextData{ GetEditorContextName(), Utilities::EDITOR_CONTEXT_INDEX, DrawMultiContextEvent, FontAtlas, -1 });
ContextProxyCreatedEvent.Broadcast(Utilities::EDITOR_CONTEXT_INDEX, Data->ContextProxy);
} }
return *Data; return *Data;
@ -136,6 +137,7 @@ FImGuiContextManager::FContextData& FImGuiContextManager::GetStandaloneWorldCont
if (UNLIKELY(!Data)) if (UNLIKELY(!Data))
{ {
Data = &Contexts.Emplace(Utilities::STANDALONE_GAME_CONTEXT_INDEX, FContextData{ GetWorldContextName(), Utilities::STANDALONE_GAME_CONTEXT_INDEX, DrawMultiContextEvent, FontAtlas }); Data = &Contexts.Emplace(Utilities::STANDALONE_GAME_CONTEXT_INDEX, FContextData{ GetWorldContextName(), Utilities::STANDALONE_GAME_CONTEXT_INDEX, DrawMultiContextEvent, FontAtlas });
ContextProxyCreatedEvent.Broadcast(Utilities::STANDALONE_GAME_CONTEXT_INDEX, Data->ContextProxy);
} }
return *Data; return *Data;
@ -176,6 +178,7 @@ FImGuiContextManager::FContextData& FImGuiContextManager::GetWorldContextData(co
if (UNLIKELY(!Data)) if (UNLIKELY(!Data))
{ {
Data = &Contexts.Emplace(Index, FContextData{ GetWorldContextName(World), Index, DrawMultiContextEvent, FontAtlas, WorldContext->PIEInstance }); Data = &Contexts.Emplace(Index, FContextData{ GetWorldContextName(World), Index, DrawMultiContextEvent, FontAtlas, WorldContext->PIEInstance });
ContextProxyCreatedEvent.Broadcast(Index, Data->ContextProxy);
} }
else else
{ {
@ -186,6 +189,7 @@ FImGuiContextManager::FContextData& FImGuiContextManager::GetWorldContextData(co
if (UNLIKELY(!Data)) if (UNLIKELY(!Data))
{ {
Data = &Contexts.Emplace(Index, FContextData{ GetWorldContextName(World), Index, DrawMultiContextEvent, FontAtlas }); Data = &Contexts.Emplace(Index, FContextData{ GetWorldContextName(World), Index, DrawMultiContextEvent, FontAtlas });
ContextProxyCreatedEvent.Broadcast(Index, Data->ContextProxy);
} }
#endif #endif

View File

@ -5,6 +5,14 @@
#include "ImGuiContextProxy.h" #include "ImGuiContextProxy.h"
// TODO: It might be useful to broadcast FContextProxyCreatedDelegate to users, to support similar cases to our ImGui
// demo, but we would need to remove from that interface internal classes.
// Delegate called when new context proxy is created.
// @param ContextIndex - Index for that world
// @param ContextProxy - Created context proxy
DECLARE_MULTICAST_DELEGATE_TwoParams(FContextProxyCreatedDelegate, int32, FImGuiContextProxy&);
// Manages ImGui context proxies. // Manages ImGui context proxies.
class FImGuiContextManager class FImGuiContextManager
{ {
@ -51,6 +59,9 @@ public:
// draw the same content to multiple contexts. // draw the same content to multiple contexts.
FSimpleMulticastDelegate& OnDrawMultiContext() { return DrawMultiContextEvent; } FSimpleMulticastDelegate& OnDrawMultiContext() { return DrawMultiContextEvent; }
// Delegate called when new context proxy is created.
FContextProxyCreatedDelegate& OnContextProxyCreated() { return ContextProxyCreatedEvent; }
void Tick(float DeltaSeconds); void Tick(float DeltaSeconds);
private: private:
@ -107,5 +118,7 @@ private:
FSimpleMulticastDelegate DrawMultiContextEvent; FSimpleMulticastDelegate DrawMultiContextEvent;
FContextProxyCreatedDelegate ContextProxyCreatedEvent;
ImFontAtlas FontAtlas; ImFontAtlas FontAtlas;
}; };