UnrealImGui/Source/ImGui/Private/ImGuiModuleManager.h
Sebastian 1a6aa98f51 Added support for session reloading and updated contexts and widgets management:
- Added to ImGui Context Proxy a name that is mapped to ini file set in ImGui context.
- ImGui Context Manager generates unique context names from world type and context index.
- Refactored ImGui Context Manager to have a cleaner separation between editor and non-editor bits.
- Fixed context update rules in ImGui Context Manager.
- Changed widgets management in ImGui Module Manager to allow automatic garbage collection after viewports are closed and manual removal when module is shutting down.
- ImGui Widgets are in full control of communication with context proxies.
- Added basic world context utilities.
- Refactored world context index utilities and replaced ambiguous 'default context index' with 'editor' and 'game' ones.
2017-09-27 21:16:54 +01:00

72 lines
1.8 KiB
C++

// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
#pragma once
#include "ImGuiContextManager.h"
#include "SImGuiWidget.h"
#include "TextureManager.h"
// Central manager that implements module logic. It initializes and controls remaining module components.
class FImGuiModuleManager
{
// Allow module to control life-cycle of this class.
friend class FImGuiModule;
public:
// Get ImGui contexts manager.
FImGuiContextManager& GetContextManager() { return ContextManager; }
// Get texture resources manager.
FTextureManager& GetTextureManager() { return TextureManager; }
// Event called right after ImGui is updated, to give other subsystems chance to react.
FSimpleMulticastDelegate& OnPostImGuiUpdate() { return PostImGuiUpdateEvent; }
private:
FImGuiModuleManager();
~FImGuiModuleManager();
FImGuiModuleManager(const FImGuiModuleManager&) = delete;
FImGuiModuleManager& operator=(const FImGuiModuleManager&) = delete;
FImGuiModuleManager(FImGuiModuleManager&&) = delete;
FImGuiModuleManager& operator=(FImGuiModuleManager&&) = delete;
void Initialize();
void Uninitialize();
void LoadTextures();
void RegisterTick();
void UnregisterTick();
bool IsInUpdateThread();
void Tick(float DeltaSeconds);
void OnViewportCreated();
void AddWidgetToViewport(UGameViewportClient* GameViewport);
void AddWidgetToAllViewports();
// Event that we call after ImGui is updated.
FSimpleMulticastDelegate PostImGuiUpdateEvent;
// Manager for ImGui contexts.
FImGuiContextManager ContextManager;
// Manager for textures resources.
FTextureManager TextureManager;
// Slate widgets that we created.
TArray<TWeakPtr<SImGuiWidget>> Widgets;
FDelegateHandle TickDelegateHandle;
FDelegateHandle ViewportCreatedHandle;
bool bInitialized = false;
};