mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-19 00:40:32 +00:00
77bb73dbce
- Added ImGui Context Manager to create and manage ImGui Context Proxies. - Changed ImGui Context Proxy to dynamically create context and allow pairing with input state. - Changed ImGui Module Manager to create one widget per context. - Changed ImGui Widget to work in different input modes. - Changed ImGui Input State to allow partial reset (only mouse or keyboard).
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
#pragma once
|
|
|
|
#include "ImGuiContextProxy.h"
|
|
#include "ImGuiDemo.h"
|
|
#include "Utilities/WorldContextIndex.h"
|
|
|
|
|
|
// Manages ImGui context proxies.
|
|
class FImGuiContextManager
|
|
{
|
|
public:
|
|
|
|
FImGuiContextManager() = default;
|
|
|
|
FImGuiContextManager(const FImGuiContextManager&) = delete;
|
|
FImGuiContextManager& operator=(const FImGuiContextManager&) = delete;
|
|
|
|
FImGuiContextManager(FImGuiContextManager&&) = delete;
|
|
FImGuiContextManager& operator=(FImGuiContextManager&&) = delete;
|
|
|
|
// Get or create default ImGui context proxy. In editor this is the editor context proxy and in standalone game
|
|
// context proxy for the only world and the same value as returned from GetWorldContextProxy.
|
|
//
|
|
// If proxy doesn't exist then it will be created and initialized.
|
|
FImGuiContextProxy& GetDefaultContextProxy() { return FindOrAddContextData(Utilities::DEFAULT_CONTEXT_INDEX).ContextProxy; }
|
|
|
|
// Get or create ImGui context proxy for given world.
|
|
//
|
|
// If proxy doesn't yet exist then it will be created and initialized. If proxy already exists then associated
|
|
// world data will be updated.
|
|
FImGuiContextProxy& GetWorldContextProxy(UWorld& World);
|
|
|
|
// Get context proxy by index, or null if context with that index doesn't exist.
|
|
FORCEINLINE FImGuiContextProxy* GetContextProxy(int32 ContextIndex)
|
|
{
|
|
FContextData* Data = Contexts.Find(ContextIndex);
|
|
return Data ? &(Data->ContextProxy) : nullptr;
|
|
}
|
|
|
|
void Tick(float DeltaSeconds);
|
|
|
|
private:
|
|
|
|
struct FContextData
|
|
{
|
|
TWeakObjectPtr<UWorld> World;
|
|
FImGuiContextProxy ContextProxy;
|
|
};
|
|
|
|
FContextData& FindOrAddContextData(int32 Index);
|
|
|
|
TMap<int32, FContextData> Contexts;
|
|
|
|
FImGuiDemo ImGuiDemo;
|
|
};
|