mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 08:02:23 -07:00
CogImGui: rework imgui lib integration
This commit is contained in:
@@ -155,14 +155,14 @@ void FCogEngineWindow_Collisions::RenderContent()
|
||||
//-------------------------------------------------
|
||||
for (int ChannelIndex = 0; ChannelIndex < (int32)ECC_MAX; ++ChannelIndex)
|
||||
{
|
||||
ImGui::PushID(ChannelIndex);
|
||||
|
||||
const FChannel& Channel = Channels[ChannelIndex];
|
||||
if (Channel.IsValid == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ImGui::PushID(ChannelIndex);
|
||||
|
||||
ImColor Color = FCogImguiHelper::ToImColor(Channel.Color);
|
||||
ImGui::ColorEdit4("Color", (float*)&Color.Value, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
|
||||
ImGui::SameLine();
|
||||
|
||||
@@ -164,7 +164,7 @@ void FCogEngineWindow_Metrics::DrawMetricRow(const char* RowTitle, float Mitigat
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Selectable(RowTitle, false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick);
|
||||
ImGui::Selectable(RowTitle, false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(Color, "%.1f", MitigatedValue);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "Engine/Engine.h"
|
||||
#include "Misc/StringBuilder.h"
|
||||
|
||||
char ImGuiTextBuffer::EmptyString[1] = { 0 };
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
// UCogEngineWindow_OutputLog
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -160,11 +160,11 @@ void FCogEngineWindow_Skeleton::RenderBoneEntry(int32 BoneIndex, bool OpenAllChi
|
||||
//------------------------
|
||||
if (BoneInfo.Children.Num() > 0 && Filter.IsActive() == false)
|
||||
{
|
||||
OpenChildren = ImGui::TreeNodeEx("##Bone", ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
OpenChildren = ImGui::TreeNodeEx("##Bone", ImGuiSelectableFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::TreeNodeEx("##Bone", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
ImGui::TreeNodeEx("##Bone", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiSelectableFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
}
|
||||
|
||||
const bool IsControlDown = ImGui::GetCurrentContext()->IO.KeyCtrl;
|
||||
|
||||
@@ -5,61 +5,38 @@ public class CogImgui : ModuleRules
|
||||
{
|
||||
public CogImgui(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
bLegacyPublicIncludePaths = false;
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
Path.Combine(ModuleDirectory, "../ThirdParty/imgui/"),
|
||||
Path.Combine(ModuleDirectory, "../ThirdParty/implot/"),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
"ThirdParty/imgui",
|
||||
"ThirdParty/implot",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Projects"
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"InputCore",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
}
|
||||
);
|
||||
PublicDependencyModuleNames.AddRange(new[]
|
||||
{
|
||||
"Core",
|
||||
"ImGui",
|
||||
"ImPlot",
|
||||
});
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
PrivateDependencyModuleNames.AddRange(new[]
|
||||
{
|
||||
"ApplicationCore",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"InputCore",
|
||||
"Slate",
|
||||
"SlateCore"
|
||||
});
|
||||
|
||||
if (Target.bBuildEditor)
|
||||
{
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"EditorStyle",
|
||||
"Settings",
|
||||
"UnrealEd",
|
||||
}
|
||||
);
|
||||
PrivateDependencyModuleNames.AddRange(new[]
|
||||
{
|
||||
"MainFrame",
|
||||
"EditorStyle",
|
||||
"Settings",
|
||||
"UnrealEd",
|
||||
});
|
||||
}
|
||||
|
||||
PublicDefinitions.Add("IMGUI_USER_CONFIG=\"CogImGuiConfig.h\"");
|
||||
PublicDefinitions.Add("IMGUI_API=COGIMGUI_API");
|
||||
PublicDefinitions.Add("IMPLOT_API=COGIMGUI_API");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "CogImGuiConfig.h"
|
||||
|
||||
THIRD_PARTY_INCLUDES_START
|
||||
#include <imgui.cpp>
|
||||
#include <imgui_demo.cpp>
|
||||
#include <imgui_draw.cpp>
|
||||
#include <imgui_tables.cpp>
|
||||
#include <imgui_widgets.cpp>
|
||||
#include <implot.cpp>
|
||||
#include <implot_demo.cpp>
|
||||
#include <implot_items.cpp>
|
||||
THIRD_PARTY_INCLUDES_END
|
||||
@@ -1,19 +0,0 @@
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#include <Windows/AllowWindowsPlatformTypes.h>
|
||||
#endif // PLATFORM_WINDOWS
|
||||
|
||||
#include "imgui.cpp"
|
||||
#include "imgui_demo.cpp"
|
||||
#include "imgui_draw.cpp"
|
||||
#include "imgui_tables.cpp"
|
||||
#include "imgui_widgets.cpp"
|
||||
|
||||
#include "implot.cpp"
|
||||
#include "implot_demo.cpp"
|
||||
#include "implot_items.cpp"
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#include <Windows/HideWindowsPlatformTypes.h>
|
||||
#endif // PLATFORM_WINDOWS
|
||||
@@ -1,8 +1,11 @@
|
||||
#include "CogImguiModule.h"
|
||||
|
||||
#include "Engine/GameViewportClient.h"
|
||||
#include "Widgets/Layout/SScaleBox.h"
|
||||
#include "CogImguiWidget.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Engine/GameViewportClient.h"
|
||||
#include "HAL/LowLevelMemTracker.h"
|
||||
#include "HAL/UnrealMemory.h"
|
||||
#include "Widgets/Layout/SScaleBox.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FCogImguiModule"
|
||||
|
||||
@@ -10,10 +13,23 @@
|
||||
|
||||
constexpr int32 Cog_ZOrder = 10000;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
static void* ImGui_MemAlloc(size_t Size, void* UserData)
|
||||
{
|
||||
LLM_SCOPE_BYNAME(TEXT("ImGui"));
|
||||
return FMemory::Malloc(Size);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
static void ImGui_MemFree(void* Ptr, void* UserData)
|
||||
{
|
||||
FMemory::Free(Ptr);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogImguiModule::StartupModule()
|
||||
{
|
||||
|
||||
ImGui::SetAllocatorFunctions(ImGui_MemAlloc, ImGui_MemFree);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Misc/AssertionMacros.h"
|
||||
|
||||
#define IM_ASSERT(Expr) ensure(Expr)
|
||||
|
||||
#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
#define IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
#define IMGUI_DISABLE_WIN32_FUNCTIONS
|
||||
#define IMGUI_DISABLE_DEFAULT_ALLOCATORS
|
||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||
|
||||
#define ImTextureID class UTexture2D*
|
||||
@@ -197,7 +197,6 @@ void UCogWindowManager::Render(float DeltaTime)
|
||||
ImGui::SetNextWindowBgAlpha(0.35f);
|
||||
}
|
||||
|
||||
ImGui::DockSpaceOverViewport(0, ImGuiDockNodeFlags_PassthruCentralNode | ImGuiDockNodeFlags_NoDockingInCentralNode | ImGuiDockNodeFlags_AutoHideTabBar);
|
||||
Window->Render(DeltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ bool FCogWindowWidgets::CheckBoxState(const char* Label, ECheckBoxState& State)
|
||||
|
||||
const bool IsPressed = ImGui::CheckboxFlags(Label, &Flags, 3);
|
||||
|
||||
ImGui::PopStyleColor(6);
|
||||
ImGui::PopStyleColor(5);
|
||||
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary))
|
||||
{
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
// DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
|
||||
#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllimport )
|
||||
|
||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names.
|
||||
|
||||
@@ -6,5 +6,6 @@ public class ImGui : ModuleRules
|
||||
public ImGui(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
Type = ModuleType.External;
|
||||
PublicSystemIncludePaths.Add(ModuleDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,6 @@ public class ImPlot : ModuleRules
|
||||
public ImPlot(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
Type = ModuleType.External;
|
||||
PublicSystemIncludePaths.Add(ModuleDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,11 +247,11 @@ void FCogAIWindow_BehaviorTree::RenderNode(UBehaviorTreeComponent& BehaviorTreeC
|
||||
const bool HasChildren = CompositeNode != nullptr && CompositeNode->GetChildrenNum() > 0;
|
||||
if (HasChildren && Filter.IsActive() == false)
|
||||
{
|
||||
OpenChildren = ImGui::TreeNodeEx("##Node", ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
OpenChildren = ImGui::TreeNodeEx("##Node", ImGuiSelectableFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::TreeNodeEx("##Node", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
ImGui::TreeNodeEx("##Node", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiSelectableFlags_AllowOverlap | ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
}
|
||||
|
||||
const bool IsControlDown = ImGui::GetCurrentContext()->IO.KeyCtrl;
|
||||
|
||||
@@ -282,7 +282,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
SelectedIndex = Index;
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectColor(Asset, Effect)));
|
||||
|
||||
if (ImGui::Selectable(EffectName, Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
if (ImGui::Selectable(EffectName, Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
Selected = Index;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ void FCogAbilityWindow_Tags::RenderTagContainer(const UAbilitySystemComponent& A
|
||||
// Name
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*Tag.GetTagName().ToString()), Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*Tag.GetTagName().ToString()), Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
Selected = Index;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user