mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-19 00:40:32 +00:00
f57a73b91b
- Split tick and textures initializations. - Supporting deferred tick initialization, if Slate application is not ready during module startup. - Textures are lazy-loaded before the first use. - ImGui Context Manager initializes font atlas to make sure that ImGui resources are always initialized.
74 lines
1.9 KiB
C++
74 lines
1.9 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 LoadTextures();
|
|
|
|
bool IsTickRegistered() { return TickDelegateHandle.IsValid(); }
|
|
void RegisterTick();
|
|
void UnregisterTick();
|
|
|
|
void CreateTickInitializer();
|
|
void ReleaseTickInitializer();
|
|
|
|
bool IsInUpdateThread();
|
|
|
|
void Tick(float DeltaSeconds);
|
|
|
|
void OnViewportCreated();
|
|
|
|
void AddWidgetToViewport(UGameViewportClient* GameViewport);
|
|
void AddWidgetsToActiveViewports();
|
|
|
|
// 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 TickInitializerHandle;
|
|
FDelegateHandle TickDelegateHandle;
|
|
FDelegateHandle ViewportCreatedHandle;
|
|
|
|
bool bTexturesLoaded = false;
|
|
};
|