mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 08:20:32 +00:00
Fixed non-unity compile errors and warnings.
This commit is contained in:
parent
eba312e20b
commit
6643958586
@ -39,13 +39,26 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FImGuiContextProxy::FImGuiContextPtr::~FImGuiContextPtr()
|
||||||
|
{
|
||||||
|
if (Context)
|
||||||
|
{
|
||||||
|
// Setting this as a current context. is still required in the current framework version to properly shutdown
|
||||||
|
// and save data.
|
||||||
|
ImGui::SetCurrentContext(Context);
|
||||||
|
|
||||||
|
// Save context data and destroy.
|
||||||
|
ImGui::DestroyContext(Context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FImGuiContextProxy::FImGuiContextProxy(const FString& InName, FSimpleMulticastDelegate* InSharedDrawEvent, ImFontAtlas* InFontAtlas)
|
FImGuiContextProxy::FImGuiContextProxy(const FString& InName, FSimpleMulticastDelegate* InSharedDrawEvent, ImFontAtlas* InFontAtlas)
|
||||||
: Name(InName)
|
: Name(InName)
|
||||||
, SharedDrawEvent(InSharedDrawEvent)
|
, SharedDrawEvent(InSharedDrawEvent)
|
||||||
, IniFilename(TCHAR_TO_ANSI(*GetIniFile(InName)))
|
, IniFilename(TCHAR_TO_ANSI(*GetIniFile(InName)))
|
||||||
{
|
{
|
||||||
// Create context.
|
// Create context.
|
||||||
Context = TUniquePtr<ImGuiContext>(ImGui::CreateContext(InFontAtlas));
|
Context = FImGuiContextPtr(ImGui::CreateContext(InFontAtlas));
|
||||||
|
|
||||||
// Set this context in ImGui for initialization (any allocations will be tracked in this context).
|
// Set this context in ImGui for initialization (any allocations will be tracked in this context).
|
||||||
SetAsCurrent();
|
SetAsCurrent();
|
||||||
@ -68,19 +81,6 @@ FImGuiContextProxy::FImGuiContextProxy(const FString& InName, FSimpleMulticastDe
|
|||||||
BeginFrame();
|
BeginFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
FImGuiContextProxy::~FImGuiContextProxy()
|
|
||||||
{
|
|
||||||
if (Context)
|
|
||||||
{
|
|
||||||
// Setting this as a current context is still required in the current framework version to properly shutdown
|
|
||||||
// and save data.
|
|
||||||
SetAsCurrent();
|
|
||||||
|
|
||||||
// Save context data and destroy.
|
|
||||||
ImGui::DestroyContext(Context.Release());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FImGuiContextProxy::Draw()
|
void FImGuiContextProxy::Draw()
|
||||||
{
|
{
|
||||||
if (bIsFrameStarted && !bIsDrawCalled)
|
if (bIsFrameStarted && !bIsDrawCalled)
|
||||||
|
@ -17,16 +17,37 @@ class FImGuiInputState;
|
|||||||
// broadcasts draw events to allow listeners draw their controls. After update it stores draw data.
|
// broadcasts draw events to allow listeners draw their controls. After update it stores draw data.
|
||||||
class FImGuiContextProxy
|
class FImGuiContextProxy
|
||||||
{
|
{
|
||||||
|
class FImGuiContextPtr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
FImGuiContextPtr() = default;
|
||||||
|
FImGuiContextPtr(ImGuiContext* InContext) : Context(InContext) {}
|
||||||
|
|
||||||
|
FImGuiContextPtr(const FImGuiContextPtr&) = delete;
|
||||||
|
FImGuiContextPtr& operator=(const FImGuiContextPtr&) = delete;
|
||||||
|
|
||||||
|
FImGuiContextPtr(FImGuiContextPtr&& Other) : Context(Other.Context) { Other.Context = nullptr; }
|
||||||
|
FImGuiContextPtr& operator=(FImGuiContextPtr&& Other) { std::swap(Context, Other.Context); return *this; }
|
||||||
|
|
||||||
|
~FImGuiContextPtr();
|
||||||
|
|
||||||
|
ImGuiContext* Get() const { return Context; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
ImGuiContext* Context = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FImGuiContextProxy(const FString& Name, FSimpleMulticastDelegate* InSharedDrawEvent, ImFontAtlas* InFontAtlas);
|
FImGuiContextProxy(const FString& Name, FSimpleMulticastDelegate* InSharedDrawEvent, ImFontAtlas* InFontAtlas);
|
||||||
~FImGuiContextProxy();
|
|
||||||
|
|
||||||
FImGuiContextProxy(const FImGuiContextProxy&) = delete;
|
FImGuiContextProxy(const FImGuiContextProxy&) = delete;
|
||||||
FImGuiContextProxy& operator=(const FImGuiContextProxy&) = delete;
|
FImGuiContextProxy& operator=(const FImGuiContextProxy&) = delete;
|
||||||
|
|
||||||
FImGuiContextProxy(FImGuiContextProxy&& Other) = default;
|
FImGuiContextProxy(FImGuiContextProxy&&) = default;
|
||||||
FImGuiContextProxy& operator=(FImGuiContextProxy&& Other) = default;
|
FImGuiContextProxy& operator=(FImGuiContextProxy&&) = default;
|
||||||
|
|
||||||
// Get the name of this context.
|
// Get the name of this context.
|
||||||
const FString& GetName() const { return Name; }
|
const FString& GetName() const { return Name; }
|
||||||
@ -75,7 +96,7 @@ private:
|
|||||||
|
|
||||||
void UpdateDrawData(ImDrawData* DrawData);
|
void UpdateDrawData(ImDrawData* DrawData);
|
||||||
|
|
||||||
TUniquePtr<ImGuiContext> Context;
|
FImGuiContextPtr Context;
|
||||||
|
|
||||||
FVector2D DisplaySize = FVector2D::ZeroVector;
|
FVector2D DisplaySize = FVector2D::ZeroVector;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace Utilities
|
|||||||
return WorldContext ? GetWorldContextIndex(*WorldContext) : INVALID_CONTEXT_INDEX;
|
return WorldContext ? GetWorldContextIndex(*WorldContext) : INVALID_CONTEXT_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 GetWorldContextIndex(const UWorld& World)
|
FORCEINLINE int32 GetWorldContextIndex(const UWorld& World)
|
||||||
{
|
{
|
||||||
return (World.WorldType == EWorldType::Editor) ? EDITOR_CONTEXT_INDEX : GetWorldContextIndex(World.GetGameInstance());
|
return (World.WorldType == EWorldType::Editor) ? EDITOR_CONTEXT_INDEX : GetWorldContextIndex(World.GetGameInstance());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user