Fixed non-unity compile errors and warnings.

This commit is contained in:
Sebastian 2019-03-11 19:19:32 +00:00
parent eba312e20b
commit 6643958586
3 changed files with 40 additions and 19 deletions

View File

@ -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)
: Name(InName)
, SharedDrawEvent(InSharedDrawEvent)
, IniFilename(TCHAR_TO_ANSI(*GetIniFile(InName)))
{
// 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).
SetAsCurrent();
@ -68,19 +81,6 @@ FImGuiContextProxy::FImGuiContextProxy(const FString& InName, FSimpleMulticastDe
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()
{
if (bIsFrameStarted && !bIsDrawCalled)

View File

@ -17,16 +17,37 @@ class FImGuiInputState;
// broadcasts draw events to allow listeners draw their controls. After update it stores draw data.
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:
FImGuiContextProxy(const FString& Name, FSimpleMulticastDelegate* InSharedDrawEvent, ImFontAtlas* InFontAtlas);
~FImGuiContextProxy();
FImGuiContextProxy(const FImGuiContextProxy&) = delete;
FImGuiContextProxy& operator=(const FImGuiContextProxy&) = delete;
FImGuiContextProxy(FImGuiContextProxy&& Other) = default;
FImGuiContextProxy& operator=(FImGuiContextProxy&& Other) = default;
FImGuiContextProxy(FImGuiContextProxy&&) = default;
FImGuiContextProxy& operator=(FImGuiContextProxy&&) = default;
// Get the name of this context.
const FString& GetName() const { return Name; }
@ -75,7 +96,7 @@ private:
void UpdateDrawData(ImDrawData* DrawData);
TUniquePtr<ImGuiContext> Context;
FImGuiContextPtr Context;
FVector2D DisplaySize = FVector2D::ZeroVector;

View File

@ -51,7 +51,7 @@ namespace Utilities
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());
}