Skip to content

Commit

Permalink
move unreal panel to another module
Browse files Browse the repository at this point in the history
  • Loading branch information
Eragon-Brisingr committed Apr 16, 2024
1 parent 701bcc3 commit 9c67cd7
Show file tree
Hide file tree
Showing 81 changed files with 408 additions and 211 deletions.
20 changes: 15 additions & 5 deletions ImGui_WS.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
"Type": "DeveloperTool",
"LoadingPhase": "Default"
},
{
"Name": "ImGui_WorldDebugger",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "Incppect",
"Type": "Runtime",
Expand All @@ -49,6 +44,21 @@
"Name": "ImGui_Blueprint",
"Type": "UncookedOnly",
"LoadingPhase": "Default"
},
{
"Name": "ImGui_UnrealLayout",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "ImGui_UnrealPanels",
"Type": "Runtime",
"LoadingPhase": "Default"
},
{
"Name": "ImGui_WorldDebugger",
"Type": "Runtime",
"LoadingPhase": "Default"
}
]
}
6 changes: 1 addition & 5 deletions Source/ImGui/ImGui.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ public ImGui(ReadOnlyTargetRules Target) : base(Target)
PrivateDependencyModuleNames.AddRange(new string[]
{
"Projects",
"EngineSettings",
"Slate",
"Navmesh",
"NavigationSystem",
"DeveloperSettings",
"RenderCore",
"RHI",
Expand All @@ -37,8 +34,7 @@ public ImGui(ReadOnlyTargetRules Target) : base(Target)
PublicIncludePaths.AddRange(new string[] {
Path.Combine(ModuleDirectory, "ImGuiLibrary/Public"),
Path.Combine(ModuleDirectory, "ImPlotLibrary/Public"),
Path.Combine(ModuleDirectory, "UnrealContext/Public"),
Path.Combine(ModuleDirectory, "UnrealWidget/Public"),
Path.Combine(ModuleDirectory, "UnrealCore/Public"),
Path.Combine(ModuleDirectory, "WidgetsLibrary/Public"),
});

Expand Down
20 changes: 1 addition & 19 deletions Source/ImGui/ImGuiModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,11 @@

#include "ImGuiModule.h"

#include "UnrealImGuiLogDevice.h"
#include "UnrealImGuiPropertyDetails.h"
#include "Misc/CoreDelegates.h"

#define LOCTEXT_NAMESPACE "ImGui_WS"

void FImGuiModule::StartupModule()
{
FCoreDelegates::OnPostEngineInit.AddLambda([]
{
UnrealImGui::UnrealPropertyCustomizeFactory::InitialDefaultCustomizer();
});
if (ensure(GLog))
{
GLog->AddOutputDevice(&UnrealImGui::GUnrealImGuiOutputDevice);
FCoreDelegates::OnPreExit.AddLambda([]
{
if (GLog)
{
GLog->RemoveOutputDevice(&UnrealImGui::GUnrealImGuiOutputDevice);
}
});
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "ImGuiUnrealContextManager.h"

#include "imgui.h"
#include "ImGuiEditorDefaultLayout.h"
#include "imgui_notify.h"
#include "Engine/Engine.h"
#include "UObject/Package.h"
Expand Down Expand Up @@ -129,16 +128,9 @@ void UImGuiUnrealContextManager::DrawViewport(int32& ContextIndex, float DeltaSe
const FImGuiUnrealEditorContext& DrawContext = EditorContext;
if (DrawContext.bAlwaysDrawDefaultLayout || DrawContext.OnDraw.IsBound() == false)
{
if (GWorld)
if (GWorld && EditorDrawer)
{
static UImGuiEditorDefaultDebugger* DefaultDebugger = []
{
UImGuiEditorDefaultDebugger* Debugger = NewObject<UImGuiEditorDefaultDebugger>();
Debugger->AddToRoot();
Debugger->Register();
return Debugger;
}();
DefaultDebugger->Draw(DeltaSeconds);
EditorDrawer(DeltaSeconds);
}
}
DrawContext.OnDraw.Broadcast(DeltaSeconds);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "Engine/DeveloperSettings.h"
#include "ImGuiSettings.generated.h"

class UUnrealImGuiPanelBase;

UENUM()
enum class EImGuiFontGlyphRanges : uint8
{
Expand Down Expand Up @@ -72,6 +70,6 @@ class IMGUI_API UImGuiSettings : public UDeveloperSettings
UPROPERTY(EditAnywhere, Config, Category = "ImGui WS", meta = (ConfigRestartRequired = true))
float ServerTickInterval = 1 / 120.f;

UPROPERTY(EditAnywhere, Config, Category = "ImGui WS")
TArray<TSoftClassPtr<UUnrealImGuiPanelBase>> BlueprintPanels;
UPROPERTY(EditAnywhere, Config, Category = "ImGui WS", meta = (AllowedClasses = "/Script/ImGui_UnrealLayout.UnrealImGuiPanelBase"))
TArray<TSoftClassPtr<UObject>> BlueprintPanels;
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "Subsystems/WorldSubsystem.h"
#include "ImGuiUnrealContextManager.generated.h"

class UUnrealImGuiPanelBuilder;

DECLARE_MULTICAST_DELEGATE_OneParam(FOnImGui_WS_Draw, float);

USTRUCT()
Expand Down Expand Up @@ -40,9 +38,6 @@ class IMGUI_API UImGuiUnrealContextWorldSubsystem : public UWorldSubsystem

UPROPERTY()
FImGuiUnrealContext Context;

UPROPERTY()
TArray<TObjectPtr<UUnrealImGuiPanelBuilder>> PanelBuilders;
};

UCLASS()
Expand All @@ -59,6 +54,10 @@ class IMGUI_API UImGuiUnrealContextManager : public UEngineSubsystem
void DrawViewport(int32& ContextIndex, float DeltaSeconds);
const TArray<UImGuiUnrealContextWorldSubsystem*>& GetWorldSubsystems() const { return WorldSubsystems; }
static constexpr int32 EditorContextIndex = INDEX_NONE;

#if WITH_EDITOR
TFunction<void(float)> EditorDrawer;
#endif
private:
#if WITH_EDITORONLY_DATA
UPROPERTY()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#include "UnrealImGuiString.h"
#include "Framework/Application/SlateApplication.h"

namespace UnrealImGui
namespace ImGui
{
#if PLATFORM_WINDOWS
TArray<char, TInlineAllocator<26>> GetDrivesBitMask();
#endif

void ShowFileDialog(const char* name, FFileDialogState& FileDialogState, FUTF8String& Path, const char* Ext, FileDialogType Type)
void ShowFileDialog(const char* name, FFileDialogState& FileDialogState, UnrealImGui::FUTF8String& Path, const char* Ext, FileDialogType Type)
{
if (ImGui::BeginPopupModal(name, nullptr, ImGuiWindowFlags_NoResize))
{
Expand Down Expand Up @@ -361,7 +361,7 @@ void ShowFileDialog(const char* name, FFileDialogState& FileDialogState, FUTF8St
ImGui::CloseCurrentPopup();
};

FUTF8String SelectedFilePath = *(FileDialogState.CurrentPath + (FileDialogState.CurrentPath.IsEmpty() || FileDialogState.CurrentPath[FileDialogState.CurrentPath.Len() - 1] == TEXT('/') ? TEXT("") : TEXT("/")) + (FileDialogState.FileDialogCurrentFolder.Len() > 0 ? FileDialogState.FileDialogCurrentFolder : FileDialogState.CurrentFile));
UnrealImGui::FUTF8String SelectedFilePath = *(FileDialogState.CurrentPath + (FileDialogState.CurrentPath.IsEmpty() || FileDialogState.CurrentPath[FileDialogState.CurrentPath.Len() - 1] == TEXT('/') ? TEXT("") : TEXT("/")) + (FileDialogState.FileDialogCurrentFolder.Len() > 0 ? FileDialogState.FileDialogCurrentFolder : FileDialogState.CurrentFile));
ImGui::PushItemWidth(ImGui::GetWindowWidth() - 130);
ImGui::InputText("##SelectedFilePath", SelectedFilePath, ImGuiInputTextFlags_ReadOnly);
ImGui::SameLine();
Expand Down Expand Up @@ -431,7 +431,7 @@ void ShowFileDialog(const char* name, FFileDialogState& FileDialogState, FUTF8St
if (ImGui::BeginPopup("NewFolderPopup", ImGuiWindowFlags_Modal))
{
ImGui::Text("Enter a name for the new folder");
static FUTF8String NewFolderName;
static UnrealImGui::FUTF8String NewFolderName;
ImGui::InputText("##newfolder", NewFolderName, sizeof(NewFolderName));
if (ImGui::Button("Create##1"))
{
Expand Down Expand Up @@ -520,7 +520,7 @@ void ShowFileDialog(const char* name, FFileDialogState& FileDialogState, FUTF8St
#include <windows.h>
#include "Windows/HideWindowsPlatformTypes.h"

TArray<char, TInlineAllocator<26>> UnrealImGui::GetDrivesBitMask()
TArray<char, TInlineAllocator<26>> ImGui::GetDrivesBitMask()
{
const DWORD Mask = GetLogicalDrives();
TArray<char, TInlineAllocator<26>> Drives;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include "CoreMinimal.h"

namespace UnrealImGui
{
struct FUTF8String;
}

namespace ImGui
{
enum class FileDialogType : uint8
{
Expand Down Expand Up @@ -33,6 +38,5 @@ namespace UnrealImGui
bool InitialPathSet = false;
};

struct FUTF8String;
IMGUI_API void ShowFileDialog(const char* name, FFileDialogState& FileDialogState, FUTF8String& Path, const char* Ext, FileDialogType Type = FileDialogType::OpenFile);
IMGUI_API void ShowFileDialog(const char* name, FFileDialogState& FileDialogState, UnrealImGui::FUTF8String& Path, const char* Ext, FileDialogType Type = FileDialogType::OpenFile);
}
1 change: 0 additions & 1 deletion Source/ImGui_Editor/ImGui_Editor.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public ImGui_Editor(ReadOnlyTargetRules Target) : base(Target)

"ImGui",
"ImGui_WS",
"ImGui_WorldDebugger",
// ... add private dependencies that you statically link with here ...
}
);
Expand Down
44 changes: 0 additions & 44 deletions Source/ImGui_Editor/Private/ImGui_Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "ImGui_Editor.h"

#include "Editor.h"
#include "ImGuiWorldDebuggerBase.h"
#include "ImGuiWorldDebuggerViewportPanel.h"
#include "ImGui_WS_Manager.h"
#include "Selection.h"
#include "ToolMenus.h"
Expand All @@ -17,8 +15,6 @@

void FImGui_EditorModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module

if (GIsEditor == false || IsRunningCommandlet())
{
return;
Expand Down Expand Up @@ -77,42 +73,6 @@ void FImGui_EditorModule::StartupModule()
]
], LOCTEXT("IMGUI_Label", "IMGUI")));

SelectObjectEventHandle = USelection::SelectObjectEvent.AddLambda([](UObject* Object)
{
if (Object->IsA<AActor>())
{
TArray<AActor*> SelectedActors;
for (FSelectionIterator It = GEditor->GetSelectedActorIterator(); It; ++It)
{
if (AActor* Actor = Cast<AActor>(*It))
{
SelectedActors.Add(Actor);
}
}
UImGuiWorldDebuggerViewportActorExtent::WhenEditorSelectionChanged(SelectedActors);
}
});
SelectNoneEventHandle = USelection::SelectNoneEvent.AddLambda([]()
{
UImGuiWorldDebuggerViewportActorExtent::WhenEditorSelectionChanged(TArray<AActor*>{});
});

UImGuiWorldDebuggerViewportActorExtent::EditorSelectActors.BindLambda([](UWorld* World, const TSet<TWeakObjectPtr<AActor>>& SelectedMetaEntities)
{
USelection* SelectedActors = GEditor->GetSelectedActors();
SelectedActors->BeginBatchSelectOperation();
GEditor->SelectNone(false, true, true);
for (const TWeakObjectPtr<AActor>& ActorPtr : SelectedMetaEntities)
{
if (AActor* Actor = ActorPtr.Get())
{
GEditor->SelectActor(Actor, true, false, true);
}
}
SelectedActors->EndBatchSelectOperation(false);
GEditor->NoteSelectionChange();
});

static TWeakPtr<SNotificationItem> NotificationPtr;
if (GetDefault<UEditorPerformanceSettings>()->bThrottleCPUWhenNotForeground)
{
Expand Down Expand Up @@ -154,11 +114,7 @@ void FImGui_EditorModule::StartupModule()

void FImGui_EditorModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.

USelection::SelectObjectEvent.Remove(SelectObjectEventHandle);
USelection::SelectNoneEvent.Remove(SelectNoneEventHandle);
}

#undef LOCTEXT_NAMESPACE
Expand Down
4 changes: 0 additions & 4 deletions Source/ImGui_Editor/Public/ImGui_Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
class FImGui_EditorModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
void StartupModule() override;
void ShutdownModule() override;
private:
FDelegateHandle SelectObjectEventHandle;
FDelegateHandle SelectNoneEventHandle;
};
28 changes: 28 additions & 0 deletions Source/ImGui_UnrealLayout/ImGui_UnrealLayout.Build.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using UnrealBuildTool;

public class ImGui_UnrealLayout : ModuleRules
{
public ImGui_UnrealLayout(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
}
);

PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",

"ImGui",
}
);
}
}
46 changes: 46 additions & 0 deletions Source/ImGui_UnrealLayout/Private/ImGui_UnrealLayoutModule.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "ImGui_UnrealLayoutModule.h"

#include "ImGuiEditorDefaultLayout.h"
#include "ImGuiUnrealContextManager.h"
#include "Engine/Engine.h"
#include "Misc/CoreDelegates.h"

#define LOCTEXT_NAMESPACE "FImGui_UnrealLayoutModule"

void FImGui_UnrealLayoutModule::StartupModule()
{
#if WITH_EDITOR
FCoreDelegates::OnPostEngineInit.AddLambda([]
{
UImGuiUnrealContextManager* Manager = GEngine->GetEngineSubsystem<UImGuiUnrealContextManager>();
if (Manager == nullptr)
{
return;
}
if (Manager->EditorDrawer)
{
return;
}
Manager->EditorDrawer = [](float DeltaSeconds)
{
static UImGuiEditorDefaultDebugger* DefaultDebugger = []
{
UImGuiEditorDefaultDebugger* Debugger = NewObject<UImGuiEditorDefaultDebugger>();
Debugger->AddToRoot();
Debugger->Register();
return Debugger;
}();
DefaultDebugger->Draw(DeltaSeconds);
};
});
#endif
}

void FImGui_UnrealLayoutModule::ShutdownModule()
{

}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FImGui_UnrealLayoutModule, ImGui_UnrealLayout)
Loading

0 comments on commit 9c67cd7

Please sign in to comment.