From 32ca4dc2ba3958c43467e611b0147a3b58bfb5b2 Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Wed, 12 Feb 2025 13:56:06 -0500 Subject: [PATCH] Rename CogWindow plugin to Cog. Fix Config saving not working --- Plugins/Cog/Cog.uplugin | 2 +- .../CogWindow.Build.cs => Cog/Cog.Build.cs} | 4 +- .../Private/CogConsoleCommandManager.cpp} | 35 +- .../Private/CogHelper.cpp} | 10 +- .../Private/CogModule.cpp} | 10 +- .../Private/CogSubsystem.cpp} | 332 ++++++++++-------- .../Private/CogWidgets.cpp} | 184 ++++++---- .../{CogWindow => Cog}/Private/CogWindow.cpp | 13 +- .../Private/CogWindow_Layouts.cpp | 7 +- .../Private/CogWindow_Settings.cpp | 79 +++-- .../Private/CogWindow_Spacing.cpp | 6 + .../Public/CogConsoleCommandManager.h} | 7 +- .../Public/CogHelper.h} | 4 +- Plugins/Cog/Source/Cog/Public/CogModule.h | 16 + .../Public/CogSubsystem.h} | 65 ++-- .../Public/CogWidgets.h} | 16 +- .../{CogWindow => Cog}/Public/CogWindow.h | 20 +- .../Public/CogWindow_Layouts.h | 6 +- .../Public/CogWindow_Settings.h | 4 +- .../Public/CogWindow_Spacing.h | 7 +- .../Cog/Source/CogEngine/CogEngine.Build.cs | 2 +- .../CogEngine/Private/CogEngineHelper.cpp | 8 +- .../Private/CogEngineWindow_BuildInfo.cpp | 12 +- .../Private/CogEngineWindow_Cheats.cpp | 14 +- .../CogEngineWindow_CollisionTester.cpp | 38 +- .../CogEngineWindow_CollisionViewer.cpp | 4 +- .../CogEngineWindow_CommandBindings.cpp | 16 +- .../Private/CogEngineWindow_Console.cpp | 18 +- .../Private/CogEngineWindow_DebugSettings.cpp | 91 ++--- .../Private/CogEngineWindow_Inspector.cpp | 14 +- .../Private/CogEngineWindow_Levels.cpp | 6 +- .../Private/CogEngineWindow_LogCategories.cpp | 10 +- .../Private/CogEngineWindow_Metrics.cpp | 27 +- .../Private/CogEngineWindow_NetEmulation.cpp | 20 +- .../Private/CogEngineWindow_NetImGui.cpp | 56 +-- .../Private/CogEngineWindow_Notifications.cpp | 28 +- .../Private/CogEngineWindow_OutputLog.cpp | 10 +- .../Private/CogEngineWindow_Plots.cpp | 40 +-- .../Private/CogEngineWindow_Scalability.cpp | 26 +- .../Private/CogEngineWindow_Selection.cpp | 27 +- .../Private/CogEngineWindow_Skeleton.cpp | 10 +- .../Private/CogEngineWindow_Spawns.cpp | 8 +- .../Private/CogEngineWindow_Stats.cpp | 14 +- .../Private/CogEngineWindow_TimeScale.cpp | 6 +- .../Private/CogEngineWindow_Transform.cpp | 10 +- .../Public/CogEngineWindow_BuildInfo.h | 2 +- .../Public/CogEngineWindow_Notifications.h | 2 +- .../CogImgui/Private/CogImguiInputHelper.cpp | 66 ++-- .../CogImgui/Private/CogImguiWidget.cpp | 10 +- .../CogImgui/Public/CogImguiInputHelper.h | 12 +- .../Source/CogWindow/Public/CogWindowModule.h | 16 - Plugins/CogAI/Source/CogAI/CogAI.Build.cs | 2 +- .../Private/CogAIWindow_BehaviorTree.cpp | 12 +- .../CogAI/Private/CogAIWindow_Blackboard.cpp | 4 +- .../Source/CogAbility/CogAbility.Build.cs | 2 +- .../CogAbility/Private/CogAbilityHelper.cpp | 6 +- .../Private/CogAbilityReplicator.cpp | 4 +- .../Private/CogAbilityWindow_Abilities.cpp | 20 +- .../Private/CogAbilityWindow_Attributes.cpp | 14 +- .../Private/CogAbilityWindow_Effects.cpp | 14 +- .../Private/CogAbilityWindow_Pools.cpp | 4 +- .../Private/CogAbilityWindow_Tags.cpp | 8 +- .../Private/CogAbilityWindow_Tasks.cpp | 20 +- .../Private/CogAbilityWindow_Tweaks.cpp | 6 +- Plugins/CogAll/Source/CogAll/CogAll.Build.cs | 2 +- .../CogAll/Source/CogAll/Private/CogAll.cpp | 4 +- Plugins/CogAll/Source/CogAll/Public/CogAll.h | 4 +- .../Source/CogCommonUI/CogCommonUI.Build.cs | 2 +- .../Private/CogCommonUI_ActionRouter.cpp | 12 +- .../Source/CogInput/CogInput.Build.cs | 2 +- .../Private/CogInputWindow_Actions.cpp | 14 +- .../Private/CogInputWindow_Gamepad.cpp | 163 +++++---- .../CogInput/Public/CogInputWindow_Gamepad.h | 6 +- Source/CogSample/CogSample.Build.cs | 2 +- Source/CogSample/CogSampleGameInstance.cpp | 6 +- Source/CogSample/CogSampleGameInstance.h | 2 +- Source/CogSample/CogSampleGameState.cpp | 2 +- Source/CogSample/CogSampleGameState.h | 4 +- Source/CogSample/CogSampleWindow_Team.cpp | 4 +- 79 files changed, 993 insertions(+), 802 deletions(-) rename Plugins/Cog/Source/{CogWindow/CogWindow.Build.cs => Cog/Cog.Build.cs} (89%) rename Plugins/Cog/Source/{CogWindow/Private/CogWindowConsoleCommandManager.cpp => Cog/Private/CogConsoleCommandManager.cpp} (59%) rename Plugins/Cog/Source/{CogWindow/Private/CogWindowHelper.cpp => Cog/Private/CogHelper.cpp} (86%) rename Plugins/Cog/Source/{CogWindow/Private/CogWindowModule.cpp => Cog/Private/CogModule.cpp} (59%) rename Plugins/Cog/Source/{CogWindow/Private/CogWindowManager.cpp => Cog/Private/CogSubsystem.cpp} (76%) rename Plugins/Cog/Source/{CogWindow/Private/CogWindowWidgets.cpp => Cog/Private/CogWidgets.cpp} (84%) rename Plugins/Cog/Source/{CogWindow => Cog}/Private/CogWindow.cpp (95%) rename Plugins/Cog/Source/{CogWindow => Cog}/Private/CogWindow_Layouts.cpp (95%) rename Plugins/Cog/Source/{CogWindow => Cog}/Private/CogWindow_Settings.cpp (77%) rename Plugins/Cog/Source/{CogWindow => Cog}/Private/CogWindow_Spacing.cpp (70%) rename Plugins/Cog/Source/{CogWindow/Public/CogWindowConsoleCommandManager.h => Cog/Public/CogConsoleCommandManager.h} (89%) rename Plugins/Cog/Source/{CogWindow/Public/CogWindowHelper.h => Cog/Public/CogHelper.h} (89%) create mode 100644 Plugins/Cog/Source/Cog/Public/CogModule.h rename Plugins/Cog/Source/{CogWindow/Public/CogWindowManager.h => Cog/Public/CogSubsystem.h} (83%) rename Plugins/Cog/Source/{CogWindow/Public/CogWindowWidgets.h => Cog/Public/CogWidgets.h} (93%) rename Plugins/Cog/Source/{CogWindow => Cog}/Public/CogWindow.h (91%) rename Plugins/Cog/Source/{CogWindow => Cog}/Public/CogWindow_Layouts.h (79%) rename Plugins/Cog/Source/{CogWindow => Cog}/Public/CogWindow_Settings.h (97%) rename Plugins/Cog/Source/{CogWindow => Cog}/Public/CogWindow_Spacing.h (69%) delete mode 100644 Plugins/Cog/Source/CogWindow/Public/CogWindowModule.h diff --git a/Plugins/Cog/Cog.uplugin b/Plugins/Cog/Cog.uplugin index cd70be4..882c49d 100644 --- a/Plugins/Cog/Cog.uplugin +++ b/Plugins/Cog/Cog.uplugin @@ -22,7 +22,7 @@ "LoadingPhase": "Default" }, { - "Name": "CogWindow", + "Name": "Cog", "Type": "Runtime", "LoadingPhase": "Default" }, diff --git a/Plugins/Cog/Source/CogWindow/CogWindow.Build.cs b/Plugins/Cog/Source/Cog/Cog.Build.cs similarity index 89% rename from Plugins/Cog/Source/CogWindow/CogWindow.Build.cs rename to Plugins/Cog/Source/Cog/Cog.Build.cs index 6f990d5..128f9ab 100644 --- a/Plugins/Cog/Source/CogWindow/CogWindow.Build.cs +++ b/Plugins/Cog/Source/Cog/Cog.Build.cs @@ -1,8 +1,8 @@ using UnrealBuildTool; -public class CogWindow : ModuleRules +public class Cog : ModuleRules { - public CogWindow(ReadOnlyTargetRules Target) : base(Target) + public Cog(ReadOnlyTargetRules Target) : base(Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowConsoleCommandManager.cpp b/Plugins/Cog/Source/Cog/Private/CogConsoleCommandManager.cpp similarity index 59% rename from Plugins/Cog/Source/CogWindow/Private/CogWindowConsoleCommandManager.cpp rename to Plugins/Cog/Source/Cog/Private/CogConsoleCommandManager.cpp index 0db517a..99afdd3 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowConsoleCommandManager.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogConsoleCommandManager.cpp @@ -1,11 +1,11 @@ -#include "CogWindowConsoleCommandManager.h" +#include "CogConsoleCommandManager.h" #include "Engine/World.h" -TMap FCogWindowConsoleCommandManager::CommandMap; +TMap FCogConsoleCommandManager::CommandMap; //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(const TCHAR* InName, const TCHAR* InHelp, UWorld* InWorld, const FCogWindowConsoleCommandDelegate& InDelegate) +void FCogConsoleCommandManager::RegisterWorldConsoleCommand(const TCHAR* InName, const TCHAR* InHelp, UWorld* InWorld, const FCogWindowConsoleCommandDelegate& InDelegate) { FCogCommandInfo& commandInfo = CommandMap.FindOrAdd(InName); @@ -20,13 +20,15 @@ void FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(const TCHAR* I { FCogCommandInfo* commandInfo = CommandMap.Find(InName); if (commandInfo == nullptr) - { - return; - } + { return; } + FWorldContext* WorldContext = GEngine->GetWorldContextFromWorld(InCommandWorld); + if (WorldContext == nullptr) + { return; } + for (auto& receiver : commandInfo->Receivers) { - if (receiver.World == InCommandWorld) + if (receiver.PIEInstance == WorldContext->PIEInstance) { receiver.Delegate.ExecuteIfBound(Args, InCommandWorld); break; @@ -37,21 +39,28 @@ void FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(const TCHAR* I ); } - FCogCommandReceiver& receiver = commandInfo.Receivers.AddDefaulted_GetRef(); - receiver.World = InWorld; - receiver.Delegate = InDelegate; + if (const FWorldContext* WorldContext = GEngine->GetWorldContextFromWorld(InWorld)) + { + FCogCommandReceiver& receiver = commandInfo.Receivers.AddDefaulted_GetRef(); + receiver.PIEInstance = WorldContext->PIEInstance; + receiver.Delegate = InDelegate; + } } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowConsoleCommandManager::UnregisterAllWorldConsoleCommands(const UWorld* InWorld) +void FCogConsoleCommandManager::UnregisterAllWorldConsoleCommands(const UWorld* InWorld) { + FWorldContext* WorldContext = GEngine->GetWorldContextFromWorld(InWorld); + if (WorldContext == nullptr) + { return; } + for (auto& kv : CommandMap) { FCogCommandInfo& commandInfo = kv.Value; for (int32 i = commandInfo.Receivers.Num() - 1; i >= 0; --i) { - if (commandInfo.Receivers[i].World == InWorld) + if (commandInfo.Receivers[i].PIEInstance == WorldContext->PIEInstance) { commandInfo.Receivers.RemoveAt(i); } @@ -63,4 +72,4 @@ void FCogWindowConsoleCommandManager::UnregisterAllWorldConsoleCommands(const UW commandInfo.ConsoleObject = nullptr; } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowHelper.cpp b/Plugins/Cog/Source/Cog/Private/CogHelper.cpp similarity index 86% rename from Plugins/Cog/Source/CogWindow/Private/CogWindowHelper.cpp rename to Plugins/Cog/Source/Cog/Private/CogHelper.cpp index 273e973..9019cd4 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowHelper.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogHelper.cpp @@ -1,4 +1,4 @@ -#include "CogWindowHelper.h" +#include "CogHelper.h" #include "AssetRegistry/AssetRegistryModule.h" #include "AssetRegistry/IAssetRegistry.h" @@ -7,7 +7,7 @@ #include "imgui.h" //---------------------------------------------------------------------------------------------------------------------- -const UObject* FCogWindowHelper::GetFirstAssetByClass(const TSubclassOf& AssetClass) +const UObject* FCogHelper::GetFirstAssetByClass(const TSubclassOf& AssetClass) { const IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked(TEXT("AssetRegistry")).Get(); @@ -23,7 +23,7 @@ const UObject* FCogWindowHelper::GetFirstAssetByClass(const TSubclassOf } //-------------------------------------------------------------------------------------------------------------------------- -FString FCogWindowHelper::GetActorName(const AActor* Actor) +FString FCogHelper::GetActorName(const AActor* Actor) { if (Actor == nullptr) { @@ -34,7 +34,7 @@ FString FCogWindowHelper::GetActorName(const AActor* Actor) } //-------------------------------------------------------------------------------------------------------------------------- -FString FCogWindowHelper::GetActorName(const AActor& Actor) +FString FCogHelper::GetActorName(const AActor& Actor) { #if WITH_EDITOR @@ -50,7 +50,7 @@ FString FCogWindowHelper::GetActorName(const AActor& Actor) //----------------------------------------------------------------------------------------- -bool FCogWindowHelper::ComputeBoundingBoxScreenPosition(const APlayerController* PlayerController, const FVector& Origin, const FVector& Extent, FVector2D& Min, FVector2D& Max) +bool FCogHelper::ComputeBoundingBoxScreenPosition(const APlayerController* PlayerController, const FVector& Origin, const FVector& Extent, FVector2D& Min, FVector2D& Max) { FVector Corners[8]; Corners[0].Set(-Extent.X, -Extent.Y, -Extent.Z); // - - - diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowModule.cpp b/Plugins/Cog/Source/Cog/Private/CogModule.cpp similarity index 59% rename from Plugins/Cog/Source/CogWindow/Private/CogWindowModule.cpp rename to Plugins/Cog/Source/Cog/Private/CogModule.cpp index 99673c8..7c09c05 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowModule.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogModule.cpp @@ -1,17 +1,17 @@ -#include "CogWindowModule.h" +#include "CogModule.h" -#define LOCTEXT_NAMESPACE "FCogWindowModule" +#define LOCTEXT_NAMESPACE "FCogModule" //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowModule::StartupModule() +void FCogModule::StartupModule() { } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowModule::ShutdownModule() +void FCogModule::ShutdownModule() { } #undef LOCTEXT_NAMESPACE -IMPLEMENT_MODULE(FCogWindowModule, CogWindow) \ No newline at end of file +IMPLEMENT_MODULE(FCogModule, CogWindow) \ No newline at end of file diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/Cog/Source/Cog/Private/CogSubsystem.cpp similarity index 76% rename from Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp rename to Plugins/Cog/Source/Cog/Private/CogSubsystem.cpp index 957a2d4..a46326b 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogSubsystem.cpp @@ -1,4 +1,4 @@ -#include "CogWindowManager.h" +#include "CogSubsystem.h" #include "CogCommon.h" #include "CogDebugDrawImGui.h" @@ -7,9 +7,9 @@ #include "CogWindow_Layouts.h" #include "CogWindow_Settings.h" #include "CogWindow_Spacing.h" -#include "CogWindowConsoleCommandManager.h" -#include "CogWindowHelper.h" -#include "CogWindowWidgets.h" +#include "CogConsoleCommandManager.h" +#include "CogHelper.h" +#include "CogWidgets.h" #include "Engine/Engine.h" #include "GameFramework/PlayerInput.h" #include "HAL/IConsoleManager.h" @@ -17,38 +17,39 @@ #include "Misc/CoreMisc.h" #include "NetImgui_Api.h" -FString UCogWindowManager::ToggleInputCommand = TEXT("Cog.ToggleInput"); -FString UCogWindowManager::DisableInputCommand = TEXT("Cog.DisableInput"); -FString UCogWindowManager::LoadLayoutCommand = TEXT("Cog.LoadLayout"); -FString UCogWindowManager::SaveLayoutCommand = TEXT("Cog.SaveLayout"); -FString UCogWindowManager::ResetLayoutCommand = TEXT("Cog.ResetLayout"); +FString UCogSubsystem::ToggleInputCommand = TEXT("Cog.ToggleInput"); +FString UCogSubsystem::DisableInputCommand = TEXT("Cog.DisableInput"); +FString UCogSubsystem::LoadLayoutCommand = TEXT("Cog.LoadLayout"); +FString UCogSubsystem::SaveLayoutCommand = TEXT("Cog.SaveLayout"); +FString UCogSubsystem::ResetLayoutCommand = TEXT("Cog.ResetLayout"); //-------------------------------------------------------------------------------------------------------------------------- -UCogWindowManager::UCogWindowManager() -{ -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::Initialize(FSubsystemCollectionBase& Collection) +void UCogSubsystem::Initialize(FSubsystemCollectionBase& Collection) { Super::Initialize(Collection); - FWorldDelegates::OnWorldPostActorTick.AddUObject(this, &ThisClass::Tick); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::Deinitialize() +void UCogSubsystem::Deinitialize() { - Super::Deinitialize(); Shutdown(); + + Super::Deinitialize(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::TryInitializeInternal() +void UCogSubsystem::Activate() +{ + FWorldDelegates::OnWorldTickStart.AddUObject(this, &ThisClass::Tick); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogSubsystem::TryInitialize(UWorld* World) { if (IsInitialized) { return; } - FWorldContext* WorldContext = GEngine->GetWorldContextFromWorld(GetWorld()); + FWorldContext* WorldContext = GEngine->GetWorldContextFromWorld(World); if (WorldContext == nullptr) { return; } @@ -70,18 +71,23 @@ void UCogWindowManager::TryInitializeInternal() IniHandler.UserData = this; ImGui::AddSettingsHandler(&IniHandler); - SpaceWindows.Add(AddWindow("Spacing 1", false)); - SpaceWindows.Add(AddWindow("Spacing 2", false)); - SpaceWindows.Add(AddWindow("Spacing 3", false)); - SpaceWindows.Add(AddWindow("Spacing 4", false)); + SpaceWindows.Add(AddWindow("Spacing 1")); + SpaceWindows.Add(AddWindow("Spacing 2")); + SpaceWindows.Add(AddWindow("Spacing 3")); + SpaceWindows.Add(AddWindow("Spacing 4")); Settings = GetConfig(); OnShortcutsDefined(); - LayoutsWindow = AddWindow("Window.Layouts", false); - SettingsWindow = AddWindow("Window.Settings", false); + LayoutsWindow = AddWindow("Window.Layouts"); + SettingsWindow = AddWindow("Window.Settings"); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + for (FCogWindow* Window : Windows) + { + InitializeWindow(Window); + } + + FCogConsoleCommandManager::RegisterWorldConsoleCommand( *ToggleInputCommand, TEXT("Toggle the input focus between the Game and ImGui"), GetWorld(), @@ -90,7 +96,7 @@ void UCogWindowManager::TryInitializeInternal() ToggleInputMode(); })); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( *DisableInputCommand, TEXT("Disable ImGui input"), GetWorld(), @@ -99,7 +105,7 @@ void UCogWindowManager::TryInitializeInternal() DisableInputMode(); })); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( *ResetLayoutCommand, TEXT("Reset the layout."), GetWorld(), @@ -111,7 +117,7 @@ void UCogWindowManager::TryInitializeInternal() } })); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( *LoadLayoutCommand, TEXT("Load the layout. Cog.LoadLayout "), GetWorld(), @@ -123,7 +129,7 @@ void UCogWindowManager::TryInitializeInternal() } })); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( *SaveLayoutCommand, TEXT("Save the layout. Cog.SaveLayout "), GetWorld(), @@ -135,14 +141,40 @@ void UCogWindowManager::TryInitializeInternal() } })); + IsInitialized = true; } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::Shutdown() +void UCogSubsystem::Shutdown() { FCogImGuiContextScope ImGuiContextScope(Context); + //------------------------------------------------------------------ + // Destroy ImGui before destroying the windows to make sure + // imgui serialize their visibility state in imgui.ini + // It also save the Cog Settings, so they are saved regularly. + //------------------------------------------------------------------ + if (IsInitialized) + { + Context.Shutdown(); + } + + for (FCogWindow* Window : Windows) + { + Window->Shutdown(); + delete Window; + } + Windows.Empty(); + + FCogConsoleCommandManager::UnregisterAllWorldConsoleCommands(GetWorld()); + + FWorldDelegates::OnWorldTickStart.RemoveAll(this); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogSubsystem::SaveAllSettings() +{ //------------------------------------------------------------------ // Call PreSaveConfig before destroying imgui context // if PreSaveConfig needs to read ImGui IO for example @@ -151,51 +183,74 @@ void UCogWindowManager::Shutdown() { Window->PreSaveConfig(); } - - //------------------------------------------------------------------ - // Destroy ImGui before destroying the windows to make sure - // imgui serialize their visibility state in imgui.ini - //------------------------------------------------------------------ - if (IsInitialized == true) - { - Context.Shutdown(); - } - - SaveConfig(); - - for (FCogWindow* Window : Windows) - { - Window->Shutdown(); - delete Window; - } - Windows.Empty(); - + for (UCogCommonConfig* Config : Configs) { Config->SaveConfig(); } - - FCogWindowConsoleCommandManager::UnregisterAllWorldConsoleCommands(GetWorld()); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::Tick(UWorld* World, ELevelTick TickType, float DeltaTime) +void UCogSubsystem::ReloadAllSettings() { + for (UCogCommonConfig* Config : Configs) + { + Config->ReloadConfig(); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogSubsystem::Tick(UWorld* InTickedWorld, ELevelTick InTickType, float InDeltaTime) +{ + UWorld* World = GetWorld(); + //---------------------------------------------------------------------------------------------- - // The tick currently gets called from a static tick function, which tick for all PIE worlds. + // The tick currently gets called from a static tick function, which tick for all PIEInstance worlds. // We must not tick for a different world than ours. - // TODO: find a cleaner way to tick only for our world. + // TODO: Find a better way to tick the subsystem only for our world. //---------------------------------------------------------------------------------------------- - if (GetWorld() != World) + if (World != InTickedWorld) { return; } - FCogImGuiContextScope ImGuiContextScope(Context); + //---------------------------------------------------------------------------------------------- + // When changing world the DebugExecBindings can change. + //---------------------------------------------------------------------------------------------- + if (World != CurrentWorld.Get()) + { + NumExecBindingsChecked = INDEX_NONE; + } + CurrentWorld = World; + + if (World == nullptr) + { return; } if (IsInitialized == false) { - TryInitializeInternal(); + TryInitialize(World); return; } + + FCogImGuiContextScope ImGuiContextScope(Context); + + UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*World); + if (PlayerInput != nullptr) + { + HandleInputs(*PlayerInput); + + //------------------------------------------------------------------ + // We must wait for the player input to be valid to disable + // DebugExecBindings conflicting with our shortcuts. + //------------------------------------------------------------------ + const int32 NewNumExecBindings = PlayerInput->DebugExecBindings.Num(); + if (NumExecBindingsChecked != NewNumExecBindings) + { + if (Settings->bDisableConflictingCommands) + { + FCogImguiInputHelper::DisableCommandsConflictingWithShortcuts(*PlayerInput); + } + NumExecBindingsChecked = NewNumExecBindings;; + } + } if (LayoutToLoad != -1) { @@ -206,22 +261,21 @@ void UCogWindowManager::Tick(UWorld* World, ELevelTick TickType, float DeltaTime for (FCogWindow* Window : Windows) { - Window->GameTick(DeltaTime); + Window->GameTick(InDeltaTime); } - const bool shouldSkipRendering = NetImgui::IsConnected() && bIsSelectionModeActive == false; - Context.SetSkipRendering(shouldSkipRendering); + const bool ShouldSkipRendering = NetImgui::IsConnected() && bIsSelectionModeActive == false; + Context.SetSkipRendering(ShouldSkipRendering); - if (Context.BeginFrame(DeltaTime)) + if (Context.BeginFrame(InDeltaTime)) { - HandleInputs(); - Render(DeltaTime); + Render(InDeltaTime); Context.EndFrame(); } } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::Render(float DeltaTime) +void UCogSubsystem::Render(float DeltaTime) { FCogImGuiContextScope ImGuiContextScope(Context); @@ -232,7 +286,7 @@ void UCogWindowManager::Render(float DeltaTime) const bool bCompactSaved = Settings->bCompactMode; if (bCompactSaved) { - FCogWindowWidgets::PushStyleCompact(); + FCogWidgets::PushStyleCompact(); } //---------------------------------------------------------------------- @@ -266,14 +320,14 @@ void UCogWindowManager::Render(float DeltaTime) if (bCompactSaved) { - FCogWindowWidgets::PopStyleCompact(); + FCogWidgets::PopStyleCompact(); } FCogDebugDrawImGui::Draw(); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::AddWindow(FCogWindow* Window, const FString& Name, const bool AddToMainMenu /*= true*/) +void UCogSubsystem::AddWindow(FCogWindow* Window, const FString& Name) { if (Windows.ContainsByPredicate([&](const FCogWindow* w) { return w->GetName() == Name; })) { @@ -284,6 +338,11 @@ void UCogWindowManager::AddWindow(FCogWindow* Window, const FString& Name, const Window->SetFullName(Name); Window->SetOwner(this); Windows.Add(Window); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogSubsystem::InitializeWindow(FCogWindow* Window) +{ Window->Initialize(); if (Window->HasWidget()) @@ -292,7 +351,7 @@ void UCogWindowManager::AddWindow(FCogWindow* Window, const FString& Name, const //Widgets.Sort() } - if (AddToMainMenu) + if (Window->bShowInMainMenu) { if (FMenu* Menu = AddMenu(Window->GetFullName())) { @@ -302,7 +361,7 @@ void UCogWindowManager::AddWindow(FCogWindow* Window, const FString& Name, const } //-------------------------------------------------------------------------------------------------------------------------- -FCogWindow* UCogWindowManager::FindWindowByID(const ImGuiID ID) +FCogWindow* UCogSubsystem::FindWindowByID(const ImGuiID ID) { for (FCogWindow* Window : Windows) { @@ -315,7 +374,7 @@ FCogWindow* UCogWindowManager::FindWindowByID(const ImGuiID ID) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::ResetLayout() +void UCogSubsystem::ResetLayout() { FCogImGuiContextScope ImGuiContextScope(Context); @@ -328,7 +387,7 @@ void UCogWindowManager::ResetLayout() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::CloseAllWindows() +void UCogSubsystem::CloseAllWindows() { for (FCogWindow* Window : Windows) { @@ -337,7 +396,7 @@ void UCogWindowManager::CloseAllWindows() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::LoadLayout(const int32 LayoutIndex) +void UCogSubsystem::LoadLayout(const int32 LayoutIndex) { for (FCogWindow* Window : Windows) { @@ -348,7 +407,7 @@ void UCogWindowManager::LoadLayout(const int32 LayoutIndex) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SaveLayout(const int32 LayoutIndex) +void UCogSubsystem::SaveLayout(const int32 LayoutIndex) { FCogImGuiContextScope ImGuiContextScope(Context); @@ -357,7 +416,7 @@ void UCogWindowManager::SaveLayout(const int32 LayoutIndex) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SortMainMenu() +void UCogSubsystem::SortMainMenu() { MainMenu.SubMenus.Empty(); @@ -374,7 +433,7 @@ void UCogWindowManager::SortMainMenu() } //-------------------------------------------------------------------------------------------------------------------------- -UCogWindowManager::FMenu* UCogWindowManager::AddMenu(const FString& Name) +UCogSubsystem::FMenu* UCogSubsystem::AddMenu(const FString& Name) { TArray Path; Name.ParseIntoArray(Path, TEXT(".")); @@ -400,7 +459,7 @@ UCogWindowManager::FMenu* UCogWindowManager::AddMenu(const FString& Name) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::RenderMainMenu() +void UCogSubsystem::RenderMainMenu() { IsRenderingInMainMenu = true; @@ -456,7 +515,7 @@ void UCogWindowManager::RenderMainMenu() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::RenderWidgets() +void UCogSubsystem::RenderWidgets() { int32 NumVisibleWidgets = 0; for (int i = 0; i < Widgets.Num(); ++i) @@ -563,7 +622,7 @@ void UCogWindowManager::RenderWidgets() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::RenderOptionMenu(FMenu& Menu) +void UCogSubsystem::RenderOptionMenu(FMenu& Menu) { if (Menu.Window != nullptr) { @@ -583,13 +642,13 @@ void UCogWindowManager::RenderOptionMenu(FMenu& Menu) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::RenderMenuItem(FCogWindow& Window, const char* MenuItemName) +void UCogSubsystem::RenderMenuItem(FCogWindow& Window, const char* MenuItemName) { if (Settings->bShowWindowsInMainMenu) { ImGui::SetNextWindowSizeConstraints( - ImVec2(FCogWindowWidgets::GetFontWidth() * 40, ImGui::GetTextLineHeightWithSpacing() * 5), - ImVec2(FCogWindowWidgets::GetFontWidth() * 50, ImGui::GetTextLineHeightWithSpacing() * 60)); + ImVec2(FCogWidgets::GetFontWidth() * 40, ImGui::GetTextLineHeightWithSpacing() * 5), + ImVec2(FCogWidgets::GetFontWidth() * 50, ImGui::GetTextLineHeightWithSpacing() * 60)); if (ImGui::BeginMenu(MenuItemName)) { @@ -617,21 +676,21 @@ void UCogWindowManager::RenderMenuItem(FCogWindow& Window, const char* MenuItemN } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::RenderMenuItemHelp(FCogWindow& Window) +void UCogSubsystem::RenderMenuItemHelp(FCogWindow& Window) { if (Settings->bShowHelp) { ImGui::SameLine(); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() - FCogWindowWidgets::GetFontWidth() * 3.0f); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - FCogWidgets::GetFontWidth() * 3.0f); ImGui::TextDisabled("(?)"); if (ImGui::IsItemHovered()) { ImGui::PushStyleColor(ImGuiCol_PopupBg, IM_COL32(29, 42, 62, 240)); - const float HelpWidth = FCogWindowWidgets::GetFontWidth() * 80; + const float HelpWidth = FCogWidgets::GetFontWidth() * 80; ImGui::SetNextWindowSizeConstraints(ImVec2(HelpWidth / 2.0f, 0.0f), ImVec2(HelpWidth, FLT_MAX)); if (ImGui::BeginTooltip()) { - ImGui::PushTextWrapPos(HelpWidth - 1 * FCogWindowWidgets::GetFontWidth()); + ImGui::PushTextWrapPos(HelpWidth - 1 * FCogWidgets::GetFontWidth()); Window.RenderHelp(); ImGui::Separator(); ImGui::TextDisabled("Help can be hidden in Window/Settings."); @@ -641,30 +700,30 @@ void UCogWindowManager::RenderMenuItemHelp(FCogWindow& Window) ImGui::PopStyleColor(); } ImGui::SameLine(); - ImGui::Dummy(ImVec2(FCogWindowWidgets::GetFontWidth() * 1, 0)); + ImGui::Dummy(ImVec2(FCogWidgets::GetFontWidth() * 1, 0)); } } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SettingsHandler_ClearAll(ImGuiContext* Context, ImGuiSettingsHandler* Handler) +void UCogSubsystem::SettingsHandler_ClearAll(ImGuiContext* Context, ImGuiSettingsHandler* Handler) { } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SettingsHandler_ApplyAll(ImGuiContext* Context, ImGuiSettingsHandler* Handler) +void UCogSubsystem::SettingsHandler_ApplyAll(ImGuiContext* Context, ImGuiSettingsHandler* Handler) { - UCogWindowManager* Manager = static_cast(Handler->UserData); + UCogSubsystem* CogSubsystem = static_cast(Handler->UserData); - Manager->Widgets.Sort([](const FCogWindow& Window1, const FCogWindow& Window2) + CogSubsystem->Widgets.Sort([](const FCogWindow& Window1, const FCogWindow& Window2) { return Window1.GetWidgetOrderIndex() < Window2.GetWidgetOrderIndex(); }); } //-------------------------------------------------------------------------------------------------------------------------- -void* UCogWindowManager::SettingsHandler_ReadOpen(ImGuiContext* Context, ImGuiSettingsHandler* Handler, const char* Name) +void* UCogSubsystem::SettingsHandler_ReadOpen(ImGuiContext* Context, ImGuiSettingsHandler* Handler, const char* Name) { if (strcmp(Name, "Windows") == 0) { @@ -673,8 +732,8 @@ void* UCogWindowManager::SettingsHandler_ReadOpen(ImGuiContext* Context, ImGuiSe if (strcmp(Name, "Widgets") == 0) { - UCogWindowManager* Manager = static_cast(Handler->UserData); - Manager->WidgetsOrderIndex = 0; + UCogSubsystem* CogSubsystem = static_cast(Handler->UserData); + CogSubsystem->WidgetsOrderIndex = 0; return reinterpret_cast(2); } @@ -683,7 +742,7 @@ void* UCogWindowManager::SettingsHandler_ReadOpen(ImGuiContext* Context, ImGuiSe } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SettingsHandler_ReadLine(ImGuiContext* Context, ImGuiSettingsHandler* Handler, void* Entry, const char* Line) +void UCogSubsystem::SettingsHandler_ReadLine(ImGuiContext* Context, ImGuiSettingsHandler* Handler, void* Entry, const char* Line) { //----------------------------------------------------------------------------------- // Load the visibility of windows. @@ -698,8 +757,8 @@ void UCogWindowManager::SettingsHandler_ReadLine(ImGuiContext* Context, ImGuiSet if (sscanf(Line, "0x%08X", &Id) == 1) #endif { - UCogWindowManager* Manager = static_cast(Handler->UserData); - if (FCogWindow* Window = Manager->FindWindowByID(Id)) + UCogSubsystem* CogSubsystem = static_cast(Handler->UserData); + if (FCogWindow* Window = CogSubsystem->FindWindowByID(Id)) { Window->SetIsVisible(true); Window->bShowMenu = (ShowMenu > 0); @@ -719,22 +778,25 @@ void UCogWindowManager::SettingsHandler_ReadLine(ImGuiContext* Context, ImGuiSet if (sscanf(Line, "0x%08X %d", &Id, &Visible) == 2) #endif { - UCogWindowManager* Manager = static_cast(Handler->UserData); - if (FCogWindow* Window = Manager->FindWindowByID(Id)) + UCogSubsystem* CogSubsystem = static_cast(Handler->UserData); + if (FCogWindow* Window = CogSubsystem->FindWindowByID(Id)) { - Window->SetWidgetOrderIndex(Manager->WidgetsOrderIndex); + Window->SetWidgetOrderIndex(CogSubsystem->WidgetsOrderIndex); Window->SetIsWidgetVisible(Visible > 0); } - Manager->WidgetsOrderIndex++; + CogSubsystem->WidgetsOrderIndex++; } } } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SettingsHandler_WriteAll(ImGuiContext* Context, ImGuiSettingsHandler* Handler, ImGuiTextBuffer* Buffer) +void UCogSubsystem::SettingsHandler_WriteAll(ImGuiContext* Context, ImGuiSettingsHandler* Handler, ImGuiTextBuffer* Buffer) { - const UCogWindowManager* Manager = static_cast(Handler->UserData); + UCogSubsystem* CogSubsystem = static_cast(Handler->UserData); + + + CogSubsystem->SaveAllSettings(); //----------------------------------------------------------------------------------- // Save the visibility of windows. Example: @@ -743,7 +805,7 @@ void UCogWindowManager::SettingsHandler_WriteAll(ImGuiContext* Context, ImGuiSet // 0xBF3390B5 //----------------------------------------------------------------------------------- Buffer->appendf("[%s][Windows]\n", Handler->TypeName); - for (const FCogWindow* Window : Manager->Windows) + for (const FCogWindow* Window : CogSubsystem->Windows) { if (Window->GetIsVisible()) { @@ -759,7 +821,7 @@ void UCogWindowManager::SettingsHandler_WriteAll(ImGuiContext* Context, ImGuiSet // 0x52BDE3E0 1 //----------------------------------------------------------------------------------- Buffer->appendf("[%s][Widgets]\n", Handler->TypeName); - for (const FCogWindow* Window : Manager->Widgets) + for (const FCogWindow* Window : CogSubsystem->Widgets) { Buffer->appendf("0x%08X %d\n", Window->GetID(), Window->GetIsWidgetVisible()); } @@ -767,7 +829,7 @@ void UCogWindowManager::SettingsHandler_WriteAll(ImGuiContext* Context, ImGuiSet } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::ResetAllWindowsConfig() +void UCogSubsystem::ResetAllWindowsConfig() { for (FCogWindow* Window : Windows) { @@ -776,7 +838,7 @@ void UCogWindowManager::ResetAllWindowsConfig() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::AddCommand(UPlayerInput* PlayerInput, const FString& Command, const FKey& Key) +void UCogSubsystem::AddCommand(UPlayerInput* PlayerInput, const FString& Command, const FKey& Key) { if (PlayerInput == nullptr) { return; } @@ -815,7 +877,7 @@ void UCogWindowManager::AddCommand(UPlayerInput* PlayerInput, const FString& Com } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SortCommands(UPlayerInput* PlayerInput) +void UCogSubsystem::SortCommands(UPlayerInput* PlayerInput) { PlayerInput->DebugExecBindings.Sort([](const FKeyBind& Key1, const FKeyBind& Key2) { @@ -824,44 +886,38 @@ void UCogWindowManager::SortCommands(UPlayerInput* PlayerInput) } //-------------------------------------------------------------------------------------------------------------------------- -UCogCommonConfig* UCogWindowManager::GetConfig(const TSubclassOf ConfigClass) +UCogCommonConfig* UCogSubsystem::GetConfig(const TSubclassOf ConfigClass) { const UClass* Class = ConfigClass.Get(); for (UCogCommonConfig* Config : Configs) { if (Config && Config->IsA(Class)) - { - return Cast(Config); - } + { return Cast(Config); } } UCogCommonConfig* Config = NewObject(this, Class); - Config->Reset(); - Config->ReloadConfig(); + //Config->Reset(); + //Config->ReloadConfig(); Configs.Add(Config); return Config; } //-------------------------------------------------------------------------------------------------------------------------- -const UObject* UCogWindowManager::GetAsset(const TSubclassOf AssetClass) const +const UObject* UCogSubsystem::GetAsset(const TSubclassOf& AssetClass) const { const UClass* Class = AssetClass.Get(); for (const UObject* Asset : Assets) { if (Asset && Asset->IsA(Class)) - { - return Asset; - } + { return Asset; } } - const UObject* Asset = FCogWindowHelper::GetFirstAssetByClass(AssetClass); + const UObject* Asset = FCogHelper::GetFirstAssetByClass(AssetClass); if (Asset == nullptr) - { - return nullptr; - } + { return nullptr; } Assets.Add(Asset); @@ -869,26 +925,22 @@ const UObject* UCogWindowManager::GetAsset(const TSubclassOf AssetClass } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::ToggleInputMode() +void UCogSubsystem::ToggleInputMode() { - UE_LOG(LogCogImGui, Verbose, TEXT("UCogWindowManager::ToggleInputMode")); + UE_LOG(LogCogImGui, Verbose, TEXT("UCogSubsystem::ToggleInputMode")); Context.SetEnableInput(!Context.GetEnableInput()); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::DisableInputMode() +void UCogSubsystem::DisableInputMode() { - UE_LOG(LogCogImGui, Verbose, TEXT("UCogWindowManager::DisableInputMode")); + UE_LOG(LogCogImGui, Verbose, TEXT("UCogSubsystem::DisableInputMode")); Context.SetEnableInput(false); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::HandleInputs() +void UCogSubsystem::HandleInputs(const UPlayerInput& PlayerInput) { - const UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*GetWorld()); - if (PlayerInput == nullptr) - { return; } - if (Settings->bDisableShortcutsWhenImGuiWantTextInput && ImGui::GetIO().WantTextInput) { return; } @@ -900,17 +952,18 @@ void UCogWindowManager::HandleInputs() { SetActivateSelectionMode(!GetActivateSelectionMode()); } + for (int i = 0; i < Settings->LoadLayoutShortcuts.Num(); ++i) { if (FCogImguiInputHelper::IsKeyInfoPressed(PlayerInput, Settings->LoadLayoutShortcuts[i])) { - LoadLayout(i); + LoadLayout(i + 1); } } } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SetActivateSelectionMode(const bool Value) +void UCogSubsystem::SetActivateSelectionMode(const bool Value) { SelectionModeActiveCounter = FMath::Max(SelectionModeActiveCounter + (Value ? 1 : -1), 0); bIsSelectionModeActive = SelectionModeActiveCounter > 0; @@ -928,21 +981,20 @@ void UCogWindowManager::SetActivateSelectionMode(const bool Value) } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogWindowManager::GetActivateSelectionMode() const +bool UCogSubsystem::GetActivateSelectionMode() const { return SelectionModeActiveCounter > 0; } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::OnShortcutsDefined() const +void UCogSubsystem::OnShortcutsDefined() { - if (GetWorld() == nullptr) - { return; } - TArray Shortcuts = { Settings->ToggleImGuiInputShortcut, Settings->ToggleSelectionShortcut }; Shortcuts.Append(Settings->LoadLayoutShortcuts); Shortcuts.Append(Settings->SaveLayoutShortcuts); - FCogImguiInputHelper::SetShortcuts(*GetWorld(), Shortcuts, Settings->bDisableConflictingCommands); + FCogImguiInputHelper::SetShortcuts(Shortcuts); + + NumExecBindingsChecked = INDEX_NONE; } diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp b/Plugins/Cog/Source/Cog/Private/CogWidgets.cpp similarity index 84% rename from Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp rename to Plugins/Cog/Source/Cog/Private/CogWidgets.cpp index 6c6bb76..2058838 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogWidgets.cpp @@ -1,12 +1,13 @@ -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "CogDebug.h" #include "CogImguiHelper.h" #include "CogImguiInputHelper.h" #include "CogImguiKeyInfo.h" -#include "CogWindowHelper.h" +#include "CogHelper.h" #include "Components/PrimitiveComponent.h" #include "EngineUtils.h" +#include "imgui.h" #include "GameFramework/Pawn.h" #include "GameFramework/PlayerInput.h" #include "imgui.h" @@ -19,7 +20,7 @@ #endif //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::BeginTableTooltip() +bool FCogWidgets::BeginTableTooltip() { ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4, 4)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); @@ -33,7 +34,7 @@ bool FCogWindowWidgets::BeginTableTooltip() } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::EndTableTooltip() +void FCogWidgets::EndTableTooltip() { ImGui::EndTooltip(); ImGui::PopStyleColor(); @@ -41,7 +42,7 @@ void FCogWindowWidgets::EndTableTooltip() } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::BeginItemTooltipWrappedText() +bool FCogWidgets::BeginItemTooltipWrappedText() { const bool result = ImGui::BeginItemTooltip(); if (result == false) @@ -52,14 +53,14 @@ bool FCogWindowWidgets::BeginItemTooltipWrappedText() } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::EndItemTooltipWrappedText() +void FCogWidgets::EndItemTooltipWrappedText() { ImGui::PopTextWrapPos(); ImGui::EndTooltip(); } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ItemTooltipWrappedText(const char* InText) +bool FCogWidgets::ItemTooltipWrappedText(const char* InText) { const bool result = BeginItemTooltipWrappedText(); if (result) @@ -71,7 +72,7 @@ bool FCogWindowWidgets::ItemTooltipWrappedText(const char* InText) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::BeginItemTableTooltip() +bool FCogWidgets::BeginItemTableTooltip() { if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort) == false) { return false; } @@ -80,13 +81,13 @@ bool FCogWindowWidgets::BeginItemTableTooltip() } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::EndItemTableTooltip() +void FCogWidgets::EndItemTableTooltip() { return EndTableTooltip(); } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::ThinSeparatorText(const char* Label) +void FCogWidgets::ThinSeparatorText(const char* Label) { ImGui::PushStyleVar(ImGuiStyleVar_SeparatorTextBorderSize, 2); ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(100, 100, 100, 255)); @@ -98,7 +99,7 @@ void FCogWindowWidgets::ThinSeparatorText(const char* Label) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::DarkCollapsingHeader(const char* InLabel, ImGuiTreeNodeFlags InFlags) +bool FCogWidgets::DarkCollapsingHeader(const char* InLabel, ImGuiTreeNodeFlags InFlags) { ImGui::PushStyleColor(ImGuiCol_Header, IM_COL32(66, 66, 66, 79)); ImGui::PushStyleColor(ImGuiCol_HeaderHovered, IM_COL32(62, 62, 62, 204)); @@ -109,7 +110,7 @@ bool FCogWindowWidgets::DarkCollapsingHeader(const char* InLabel, ImGuiTreeNodeF } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay) +void FCogWidgets::ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay) { ImGuiWindow* window = FCogImguiHelper::GetCurrentWindow(); if (window->SkipItems) @@ -155,7 +156,7 @@ void FCogWindowWidgets::ProgressBarCentered(float Fraction, const ImVec2& Size, } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ToggleMenuButton(bool* Value, const char* Text, const ImVec4& TrueColor) +bool FCogWidgets::ToggleMenuButton(bool* Value, const char* Text, const ImVec4& TrueColor) { bool IsTrue = *Value; if (IsTrue) @@ -188,13 +189,13 @@ bool FCogWindowWidgets::ToggleMenuButton(bool* Value, const char* Text, const Im } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ToggleButton(bool* Value, const char* Text, const ImVec4& TrueColor, const ImVec4& FalseColor, const ImVec2& Size) +bool FCogWidgets::ToggleButton(bool* Value, const char* Text, const ImVec4& TrueColor, const ImVec4& FalseColor, const ImVec2& Size) { return ToggleButton(Value, Text, Text, TrueColor, FalseColor, Size); } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ToggleButton(bool* Value, const char* TextTrue, const char* TextFalse, const ImVec4& TrueColor, const ImVec4& FalseColor, const ImVec2& Size) +bool FCogWidgets::ToggleButton(bool* Value, const char* TextTrue, const char* TextFalse, const ImVec4& TrueColor, const ImVec4& FalseColor, const ImVec2& Size) { bool IsPressed = false; if (*Value) @@ -229,7 +230,7 @@ bool FCogWindowWidgets::ToggleButton(bool* Value, const char* TextTrue, const ch } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::SliderWithReset(const char* Name, float* Value, float Min, float Max, const float& ResetValue, const char* Format) +void FCogWidgets::SliderWithReset(const char* Name, float* Value, float Min, float Max, const float& ResetValue, const char* Format) { ImGui::SliderFloat(Name, Value, Min, Max, Format); @@ -251,7 +252,7 @@ void FCogWindowWidgets::SliderWithReset(const char* Name, float* Value, float Mi } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::HelpMarker(const char* Text) +void FCogWidgets::HelpMarker(const char* Text) { ImGui::TextDisabled("(?)"); if (ImGui::IsItemHovered()) @@ -265,7 +266,7 @@ void FCogWindowWidgets::HelpMarker(const char* Text) } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::PushStyleCompact() +void FCogWidgets::PushStyleCompact() { ImGuiStyle& style = ImGui::GetStyle(); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(style.WindowPadding.x * 0.60f, static_cast(style.WindowPadding.y * 0.60f))); @@ -274,13 +275,13 @@ void FCogWindowWidgets::PushStyleCompact() } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::PopStyleCompact() +void FCogWidgets::PopStyleCompact() { ImGui::PopStyleVar(3); } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::AddTextWithShadow(ImDrawList* DrawList, const ImVec2& Position, ImU32 Color, const char* TextBegin, const char* TextEnd /*= NULL*/) +void FCogWidgets::AddTextWithShadow(ImDrawList* DrawList, const ImVec2& Position, ImU32 Color, const char* TextBegin, const char* TextEnd /*= NULL*/) { float Alpha = ImGui::ColorConvertU32ToFloat4(Color).w; DrawList->AddText(Position + ImVec2(1.0f, 1.0f), ImGui::ColorConvertFloat4ToU32(ImVec4(0, 0, 0, Alpha)), TextBegin, TextEnd); @@ -288,7 +289,7 @@ void FCogWindowWidgets::AddTextWithShadow(ImDrawList* DrawList, const ImVec2& Po } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::SearchBar(const char* InLabel, ImGuiTextFilter& InFilter, float InWidth /*= -1*/) +bool FCogWidgets::SearchBar(const char* InLabel, ImGuiTextFilter& InFilter, float InWidth /*= -1*/) { if (InWidth != 0.0f) { @@ -304,45 +305,84 @@ bool FCogWindowWidgets::SearchBar(const char* InLabel, ImGuiTextFilter& InFilter } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::PushBackColor(const ImVec4& Color) +void FCogWidgets::PushButtonBackColor(const ImVec4& Color) { ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.25f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.3f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.5f)); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWidgets::PopButtonBackColor() +{ + ImGui::PopStyleColor(3); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWidgets::PushFrameBackColor(const ImVec4& Color) +{ ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.25f)); ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.3f)); ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.5f)); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWidgets::PopFrameBackColor() +{ + ImGui::PopStyleColor(3); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWidgets::PushSliderBackColor(const ImVec4& Color) +{ ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.8f)); ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(Color.x, Color.y, Color.z, Color.w * 1.0f)); ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.8f)); } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::PopBackColor() +void FCogWidgets::PopSliderBackColor() { - ImGui::PopStyleColor(9); + ImGui::PopStyleColor(3); } //-------------------------------------------------------------------------------------------------------------------------- -float FCogWindowWidgets::GetShortWidth() +void FCogWidgets::PushBackColor(const ImVec4& Color) +{ + PushButtonBackColor(Color); + PushFrameBackColor(Color); + PushSliderBackColor(Color); +} + + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWidgets::PopBackColor() +{ + PopSliderBackColor(); + PopFrameBackColor(); + PopButtonBackColor(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +float FCogWidgets::GetShortWidth() { return ImGui::GetFontSize() * 10; } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::SetNextItemToShortWidth() +void FCogWidgets::SetNextItemToShortWidth() { ImGui::SetNextItemWidth(GetShortWidth()); } //-------------------------------------------------------------------------------------------------------------------------- -float FCogWindowWidgets::GetFontWidth() +float FCogWidgets::GetFontWidth() { return ImGui::GetFontSize() * 0.5f; } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ComboboxEnum(const char* Label, const UObject* Object, const char* FieldName, uint8* PointerToEnumValue) +bool FCogWidgets::ComboboxEnum(const char* Label, const UObject* Object, const char* FieldName, uint8* PointerToEnumValue) { const FEnumProperty* EnumProperty = CastField(Object->GetClass()->FindPropertyByName(FName(FieldName))); if (EnumProperty == nullptr) @@ -354,7 +394,7 @@ bool FCogWindowWidgets::ComboboxEnum(const char* Label, const UObject* Object, c } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ComboboxEnum(const char* Label, const FEnumProperty* EnumProperty, uint8* PointerToValue) +bool FCogWidgets::ComboboxEnum(const char* Label, const FEnumProperty* EnumProperty, uint8* PointerToValue) { bool HasChanged = false; @@ -372,7 +412,7 @@ bool FCogWindowWidgets::ComboboxEnum(const char* Label, const FEnumProperty* Enu } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ComboboxEnum(const char* Label, const UEnum* Enum, int64 CurrentValue, int64& NewValue) +bool FCogWidgets::ComboboxEnum(const char* Label, const UEnum* Enum, int64 CurrentValue, int64& NewValue) { bool HasChanged = false; @@ -412,7 +452,7 @@ bool FCogWindowWidgets::ComboboxEnum(const char* Label, const UEnum* Enum, int64 } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::CheckBoxState(const char* Label, ECheckBoxState& State, bool ShowTooltip) +bool FCogWidgets::CheckBoxState(const char* Label, ECheckBoxState& State, bool ShowTooltip) { const char* TooltipText = "Invalid"; @@ -475,7 +515,7 @@ bool FCogWindowWidgets::CheckBoxState(const char* Label, ECheckBoxState& State, } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::InputKey(const char* Label, FCogImGuiKeyInfo& KeyInfo) +bool FCogWidgets::InputKey(const char* Label, FCogImGuiKeyInfo& KeyInfo) { ImGui::PushID(Label); @@ -494,7 +534,7 @@ bool FCogWindowWidgets::InputKey(const char* Label, FCogImGuiKeyInfo& KeyInfo) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::InputKey(FCogImGuiKeyInfo& KeyInfo) +bool FCogWidgets::InputKey(FCogImGuiKeyInfo& KeyInfo) { bool HasKeyChanged = false; @@ -552,7 +592,7 @@ bool FCogWindowWidgets::InputKey(FCogImGuiKeyInfo& KeyInfo) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::KeyBind(FKeyBind& KeyBind) +bool FCogWidgets::KeyBind(FKeyBind& KeyBind) { static char Buffer[256] = ""; @@ -607,7 +647,7 @@ bool FCogWindowWidgets::KeyBind(FKeyBind& KeyBind) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ButtonWithTooltip(const char* Text, const char* Tooltip) +bool FCogWidgets::ButtonWithTooltip(const char* Text, const char* Tooltip) { bool IsPressed = ImGui::Button(Text); @@ -620,7 +660,7 @@ bool FCogWindowWidgets::ButtonWithTooltip(const char* Text, const char* Tooltip) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::DeleteArrayItemButton() +bool FCogWidgets::DeleteArrayItemButton() { bool IsPressed = ImGui::Button("x"); @@ -633,7 +673,7 @@ bool FCogWindowWidgets::DeleteArrayItemButton() } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::MultiChoiceButton(const char* Label, bool IsSelected, const ImVec2& Size) +bool FCogWidgets::MultiChoiceButton(const char* Label, bool IsSelected, const ImVec2& Size) { if (IsSelected) { @@ -661,7 +701,7 @@ bool FCogWindowWidgets::MultiChoiceButton(const char* Label, bool IsSelected, co } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::MultiChoiceButtonsInt(TArray& InValues, int32& InCurrentValue, const ImVec2& InSize, bool InInline) +bool FCogWidgets::MultiChoiceButtonsInt(TArray& InValues, int32& InCurrentValue, const ImVec2& InSize, bool InInline) { ImGuiStyle& Style = ImGui::GetStyle(); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(Style.WindowPadding.x * 0.40f, static_cast(Style.WindowPadding.y * 0.60f))); @@ -694,19 +734,19 @@ bool FCogWindowWidgets::MultiChoiceButtonsInt(TArray& InValues, int32& In } //-------------------------------------------------------------------------------------------------------------------------- -FString FCogWindowWidgets::RemoveFirstZero(const FString& InText) +FString FCogWidgets::RemoveFirstZero(const FString& InText) { return InText.Replace(TEXT("0."), TEXT(".")); } //-------------------------------------------------------------------------------------------------------------------------- -FString FCogWindowWidgets::FormatSmallFloat(float InValue) +FString FCogWidgets::FormatSmallFloat(float InValue) { return RemoveFirstZero(FString::Printf(TEXT("%g"), InValue)); } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::MultiChoiceButtonsFloat(TArray& InValues, float& InValue, const ImVec2& InSize, bool InInline) +bool FCogWidgets::MultiChoiceButtonsFloat(TArray& InValues, float& InValue, const ImVec2& InSize, bool InInline) { ImGuiStyle& Style = ImGui::GetStyle(); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(Style.WindowPadding.x * 0.40f, static_cast(Style.WindowPadding.y * 0.60f))); @@ -742,7 +782,7 @@ bool FCogWindowWidgets::MultiChoiceButtonsFloat(TArray& InValues, float& } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ComboCollisionChannel(const char* Label, ECollisionChannel& Channel) +bool FCogWidgets::ComboCollisionChannel(const char* Label, ECollisionChannel& Channel) { FColor ChannelColors[ECC_MAX]; FCogDebug::GetDebugChannelColors(ChannelColors); @@ -790,7 +830,7 @@ bool FCogWindowWidgets::ComboCollisionChannel(const char* Label, ECollisionChann } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::CollisionProfileChannel(const UCollisionProfile& CollisionProfile, const int32 ChannelIndex, FColor& ChannelColor, int32& Channels) +bool FCogWidgets::CollisionProfileChannel(const UCollisionProfile& CollisionProfile, const int32 ChannelIndex, FColor& ChannelColor, int32& Channels) { bool Result = false; @@ -817,7 +857,7 @@ bool FCogWindowWidgets::CollisionProfileChannel(const UCollisionProfile& Collisi } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::CollisionProfileChannels(int32& Channels) +bool FCogWidgets::CollisionProfileChannels(int32& Channels) { const UCollisionProfile* CollisionProfile = UCollisionProfile::Get(); if (CollisionProfile == nullptr) @@ -847,7 +887,7 @@ bool FCogWindowWidgets::CollisionProfileChannels(int32& Channels) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ActorsListWithFilters(AActor*& NewSelection, const UWorld& World, const TArray>& ActorClasses, int32& SelectedActorClassIndex, ImGuiTextFilter* Filter, const APawn* LocalPlayerPawn, const FCogWindowActorContextMenuFunction& ContextMenuFunction) +bool FCogWidgets::ActorsListWithFilters(AActor*& NewSelection, const UWorld& World, const TArray>& ActorClasses, int32& SelectedActorClassIndex, ImGuiTextFilter* Filter, const APawn* LocalPlayerPawn, const FCogWindowActorContextMenuFunction& ContextMenuFunction) { TSubclassOf SelectedClass = AActor::StaticClass(); if (ActorClasses.IsValidIndex(SelectedActorClassIndex)) @@ -903,7 +943,7 @@ bool FCogWindowWidgets::ActorsListWithFilters(AActor*& NewSelection, const UWorl } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ActorsList(AActor*& NewSelection, const UWorld& World, const TSubclassOf& ActorClass, const ImGuiTextFilter* Filter, const APawn* LocalPlayerPawn, const FCogWindowActorContextMenuFunction& ContextMenuFunction) +bool FCogWidgets::ActorsList(AActor*& NewSelection, const UWorld& World, const TSubclassOf& ActorClass, const ImGuiTextFilter* Filter, const APawn* LocalPlayerPawn, const FCogWindowActorContextMenuFunction& ContextMenuFunction) { TArray Actors; for (TActorIterator It(&World, ActorClass); It; ++It) @@ -913,7 +953,7 @@ bool FCogWindowWidgets::ActorsList(AActor*& NewSelection, const UWorld& World, c bool AddActor = true; if (Filter != nullptr && Filter->IsActive()) { - const auto ActorName = StringCast(*FCogWindowHelper::GetActorName(*Actor)); + const auto ActorName = StringCast(*FCogHelper::GetActorName(*Actor)); if (Filter != nullptr && Filter->PassFilter(ActorName.Get()) == false) { AddActor = false; @@ -944,7 +984,7 @@ bool FCogWindowWidgets::ActorsList(AActor*& NewSelection, const UWorld& World, c ImGui::PushStyleColor(ImGuiCol_Text, Actor == LocalPlayerPawn ? IM_COL32(255, 255, 0, 255) : IM_COL32(255, 255, 255, 255)); const bool bIsSelected = Actor == FCogDebug::GetSelection(); - if (ImGui::Selectable(TCHAR_TO_ANSI(*FCogWindowHelper::GetActorName(*Actor)), bIsSelected)) + if (ImGui::Selectable(TCHAR_TO_ANSI(*FCogHelper::GetActorName(*Actor)), bIsSelected)) { //FCogDebug::SetSelection(&World, Actor); NewSelection = Actor; @@ -975,7 +1015,7 @@ bool FCogWindowWidgets::ActorsList(AActor*& NewSelection, const UWorld& World, c } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::MenuActorsCombo(const char* StrID, AActor*& NewSelection, const UWorld& World, const TSubclassOf& ActorClass, const FCogWindowActorContextMenuFunction& ContextMenuFunction) +bool FCogWidgets::MenuActorsCombo(const char* StrID, AActor*& NewSelection, const UWorld& World, const TSubclassOf& ActorClass, const FCogWindowActorContextMenuFunction& ContextMenuFunction) { int32 SelectedActorClassIndex = 0; const TArray ActorClasses = { ActorClass }; @@ -984,7 +1024,7 @@ bool FCogWindowWidgets::MenuActorsCombo(const char* StrID, AActor*& NewSelection } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::MenuActorsCombo(const char* StrID, AActor*& NewSelection, const UWorld& World, const TArray>& ActorClasses, int32& SelectedActorClassIndex, ImGuiTextFilter* Filter, const APawn* LocalPlayerPawn, const FCogWindowActorContextMenuFunction& ContextMenuFunction) +bool FCogWidgets::MenuActorsCombo(const char* StrID, AActor*& NewSelection, const UWorld& World, const TArray>& ActorClasses, int32& SelectedActorClassIndex, ImGuiTextFilter* Filter, const APawn* LocalPlayerPawn, const FCogWindowActorContextMenuFunction& ContextMenuFunction) { bool Result = false; ImGui::PushID(StrID); @@ -1012,7 +1052,7 @@ bool FCogWindowWidgets::MenuActorsCombo(const char* StrID, AActor*& NewSelection Selection = nullptr; } - const FString CurrentSelectionName = FCogWindowHelper::GetActorName(Selection); + const FString CurrentSelectionName = FCogHelper::GetActorName(Selection); if (ImGui::Button(TCHAR_TO_ANSI(*CurrentSelectionName), ImVec2(Width, 0.0f))) { ImGui::OpenPopup("ActorListPopup"); @@ -1056,7 +1096,7 @@ bool FCogWindowWidgets::MenuActorsCombo(const char* StrID, AActor*& NewSelection } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::ActorContextMenu(AActor& Selection, const FCogWindowActorContextMenuFunction& ContextMenuFunction) +void FCogWidgets::ActorContextMenu(AActor& Selection, const FCogWindowActorContextMenuFunction& ContextMenuFunction) { if (ContextMenuFunction == nullptr) { @@ -1072,7 +1112,7 @@ void FCogWindowWidgets::ActorContextMenu(AActor& Selection, const FCogWindowActo } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::ActorFrame(const AActor& Actor) +void FCogWidgets::ActorFrame(const AActor& Actor) { const APlayerController* PlayerController = Actor.GetWorld()->GetFirstPlayerController(); if (PlayerController == nullptr) @@ -1122,19 +1162,19 @@ void FCogWindowWidgets::ActorFrame(const AActor& Actor) } FVector2D ScreenPosMin, ScreenPosMax; - if (FCogWindowHelper::ComputeBoundingBoxScreenPosition(PlayerController, BoxOrigin, BoxExtent, ScreenPosMin, ScreenPosMax)) + if (FCogHelper::ComputeBoundingBoxScreenPosition(PlayerController, BoxOrigin, BoxExtent, ScreenPosMin, ScreenPosMax)) { const ImU32 Color = (&Actor == FCogDebug::GetSelection()) ? IM_COL32(255, 255, 255, 255) : IM_COL32(255, 255, 255, 128); if (ScreenPosMin != ScreenPosMax) { DrawList->AddRect(FCogImguiHelper::ToImVec2(ScreenPosMin) + Viewport->Pos, FCogImguiHelper::ToImVec2(ScreenPosMax) + Viewport->Pos, Color, 0.0f, 0, 1.0f); } - AddTextWithShadow(DrawList, FCogImguiHelper::ToImVec2(ScreenPosMin + FVector2D(0, -14.0f)) + Viewport->Pos, Color, TCHAR_TO_ANSI(*FCogWindowHelper::GetActorName(Actor))); + AddTextWithShadow(DrawList, FCogImguiHelper::ToImVec2(ScreenPosMin + FVector2D(0, -14.0f)) + Viewport->Pos, Color, TCHAR_TO_ANSI(*FCogHelper::GetActorName(Actor))); } } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::SmallButton(const char* Text, const ImVec4& Color) +void FCogWidgets::SmallButton(const char* Text, const ImVec4& Color) { ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.6f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.8f)); @@ -1144,7 +1184,7 @@ void FCogWindowWidgets::SmallButton(const char* Text, const ImVec4& Color) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::InputText(const char* Text, FString& Value, ImGuiInputTextFlags InFlags, ImGuiInputTextCallback InCallback, void* InUserData) +bool FCogWidgets::InputText(const char* Text, FString& Value, ImGuiInputTextFlags InFlags, ImGuiInputTextCallback InCallback, void* InUserData) { static char ValueBuffer[256] = ""; ImStrncpy(ValueBuffer, TCHAR_TO_ANSI(*Value), IM_ARRAYSIZE(ValueBuffer)); @@ -1159,7 +1199,7 @@ bool FCogWindowWidgets::InputText(const char* Text, FString& Value, ImGuiInputTe } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::InputTextWithHint(const char* InText, const char* InHint, FString& InValue, ImGuiInputTextFlags InFlags, ImGuiInputTextCallback InCallback, void* InUserData) +bool FCogWidgets::InputTextWithHint(const char* InText, const char* InHint, FString& InValue, ImGuiInputTextFlags InFlags, ImGuiInputTextCallback InCallback, void* InUserData) { static char ValueBuffer[256] = ""; ImStrncpy(ValueBuffer, TCHAR_TO_ANSI(*InValue), IM_ARRAYSIZE(ValueBuffer)); @@ -1174,7 +1214,7 @@ bool FCogWindowWidgets::InputTextWithHint(const char* InText, const char* InHint } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::BeginRightAlign(const char* Id) +bool FCogWidgets::BeginRightAlign(const char* Id) { if (ImGui::BeginTable(Id, 2, ImGuiTableFlags_SizingFixedFit, ImVec2(-1, 0))) { @@ -1189,13 +1229,13 @@ bool FCogWindowWidgets::BeginRightAlign(const char* Id) } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::EndRightAlign() +void FCogWidgets::EndRightAlign() { ImGui::EndTable(); } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::MenuItemShortcut(const char* Id, const FString& Text) +void FCogWidgets::MenuItemShortcut(const char* Id, const FString& Text) { ImGui::SameLine(); if (BeginRightAlign(Id)) @@ -1210,7 +1250,7 @@ void FCogWindowWidgets::MenuItemShortcut(const char* Id, const FString& Text) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::BrowseToAssetButton(const UObject* InAsset, const ImVec2& InSize) +bool FCogWidgets::BrowseToAssetButton(const UObject* InAsset, const ImVec2& InSize) { #if WITH_EDITOR @@ -1237,7 +1277,7 @@ bool FCogWindowWidgets::BrowseToAssetButton(const UObject* InAsset, const ImVec2 } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::BrowseToAssetButton(const FAssetData& InAssetData, const ImVec2& InSize) +bool FCogWidgets::BrowseToAssetButton(const FAssetData& InAssetData, const ImVec2& InSize) { #if WITH_EDITOR @@ -1255,7 +1295,7 @@ bool FCogWindowWidgets::BrowseToAssetButton(const FAssetData& InAssetData, const } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::BrowseToObjectAssetButton(const UObject* InObject, const ImVec2& InSize) +bool FCogWidgets::BrowseToObjectAssetButton(const UObject* InObject, const ImVec2& InSize) { #if WITH_EDITOR @@ -1274,7 +1314,7 @@ bool FCogWindowWidgets::BrowseToObjectAssetButton(const UObject* InObject, const } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::OpenAssetButton(const UObject* InAsset, const ImVec2& InSize) +bool FCogWidgets::OpenAssetButton(const UObject* InAsset, const ImVec2& InSize) { #if WITH_EDITOR @@ -1305,7 +1345,7 @@ bool FCogWindowWidgets::OpenAssetButton(const UObject* InAsset, const ImVec2& In } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::OpenObjectAssetButton(const UObject* InObject, const ImVec2& InSize) +bool FCogWidgets::OpenObjectAssetButton(const UObject* InObject, const ImVec2& InSize) { #if WITH_EDITOR @@ -1324,19 +1364,19 @@ bool FCogWindowWidgets::OpenObjectAssetButton(const UObject* InObject, const ImV } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::FloatArray(const char* InLabel, TArray& InArray, int32 InMaxEntries, const ImVec2& Size) +void FCogWidgets::FloatArray(const char* InLabel, TArray& InArray, int32 InMaxEntries, const ImVec2& Size) { ScalarArray(InLabel, ImGuiDataType_Float, InArray, InMaxEntries, Size); } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::IntArray(const char* InLabel, TArray& InArray, int32 InMaxEntries, const ImVec2& Size) +void FCogWidgets::IntArray(const char* InLabel, TArray& InArray, int32 InMaxEntries, const ImVec2& Size) { ScalarArray(InLabel, ImGuiDataType_S32, InArray, InMaxEntries, Size); } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::RenderCloseButton(const ImVec2& InPos) +void FCogWidgets::RenderCloseButton(const ImVec2& InPos) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -1353,7 +1393,7 @@ void FCogWindowWidgets::RenderCloseButton(const ImVec2& InPos) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::PickButton(const char* InLabel, const ImVec2& InSize, ImGuiButtonFlags InFlags) +bool FCogWidgets::PickButton(const char* InLabel, const ImVec2& InSize, ImGuiButtonFlags InFlags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = ImGui::GetCurrentWindow(); @@ -1385,13 +1425,13 @@ bool FCogWindowWidgets::PickButton(const char* InLabel, const ImVec2& InSize, Im } //-------------------------------------------------------------------------------------------------------------------------- -ImVec2 FCogWindowWidgets::ComputeScreenCornerLocation(const FVector2f& InAlignment, const FIntVector2& InPadding) +ImVec2 FCogWidgets::ComputeScreenCornerLocation(const FVector2f& InAlignment, const FIntVector2& InPadding) { return ComputeScreenCornerLocation(FCogImguiHelper::ToImVec2(InAlignment), FCogImguiHelper::ToImVec2(InPadding)); } //-------------------------------------------------------------------------------------------------------------------------- -ImVec2 FCogWindowWidgets::ComputeScreenCornerLocation(const ImVec2& InAlignment, const ImVec2& InPadding) +ImVec2 FCogWidgets::ComputeScreenCornerLocation(const ImVec2& InAlignment, const ImVec2& InPadding) { const ImGuiViewport* Viewport = ImGui::GetMainViewport(); if (Viewport == nullptr) diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp b/Plugins/Cog/Source/Cog/Private/CogWindow.cpp similarity index 95% rename from Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp rename to Plugins/Cog/Source/Cog/Private/CogWindow.cpp index 22b27dc..1e854b4 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogWindow.cpp @@ -2,7 +2,7 @@ #include "CogDebug.h" #include "CogWindow_Settings.h" -#include "CogWindowManager.h" +#include "CogSubsystem.h" #include "Engine/World.h" #include "imgui_internal.h" #include "GameFramework/Pawn.h" @@ -84,7 +84,7 @@ void FCogWindow::RenderSettings() ImGui::Checkbox("Show Menu", &bShowMenu); } - if (ImGui::Button("Reset Settings", ImVec2(-1, 0))) + if (ImGui::Button("Reset Settings", ImVec2(ImGui::GetContentRegionAvail().x, 0))) { ResetConfig(); } @@ -111,10 +111,13 @@ void FCogWindow::Render(float DeltaTime) { RenderContent(); - if (ImGui::BeginPopupContextWindow()) + if (bUseCustomContextMenu == false) { - RenderContextMenu(); - ImGui::EndPopup(); + if (ImGui::BeginPopupContextWindow()) + { + RenderContextMenu(); + ImGui::EndPopup(); + } } } ImGui::End(); diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Layouts.cpp b/Plugins/Cog/Source/Cog/Private/CogWindow_Layouts.cpp similarity index 95% rename from Plugins/Cog/Source/CogWindow/Private/CogWindow_Layouts.cpp rename to Plugins/Cog/Source/Cog/Private/CogWindow_Layouts.cpp index 26bb072..1a8efc2 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Layouts.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogWindow_Layouts.cpp @@ -1,15 +1,14 @@ #include "CogWindow_Layouts.h" #include "CogImguiInputHelper.h" -#include "CogWindowManager.h" +#include "CogSubsystem.h" #include "CogWindow_Settings.h" #include "InputCoreTypes.h" //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindow_Layouts::Initialize() +FCogWindow_Layouts::FCogWindow_Layouts() { - Super::Initialize(); - + bShowInMainMenu = false; bHasMenu = false; } diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp b/Plugins/Cog/Source/Cog/Private/CogWindow_Settings.cpp similarity index 77% rename from Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp rename to Plugins/Cog/Source/Cog/Private/CogWindow_Settings.cpp index 9057edc..194d579 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogWindow_Settings.cpp @@ -1,20 +1,25 @@ #include "CogWindow_Settings.h" -#include "CogCommon.h" #include "CogImguiHelper.h" #include "CogImguiInputHelper.h" -#include "CogWindowManager.h" -#include "CogWindowWidgets.h" +#include "CogSubsystem.h" +#include "CogWidgets.h" #include "imgui.h" #include "imgui_internal.h" #include "InputCoreTypes.h" +//-------------------------------------------------------------------------------------------------------------------------- +FCogWindow_Settings::FCogWindow_Settings() +{ + bShowInMainMenu = false; + bHasMenu = false; +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogWindow_Settings::Initialize() { Super::Initialize(); - bHasMenu = false; Config = GetConfig(); @@ -39,6 +44,10 @@ void FCogWindow_Settings::PreSaveConfig() Super::PreSaveConfig(); ImGuiIO& IO = ImGui::GetIO(); + + if (Config == nullptr) + { return; } + Config->bNavEnableKeyboard = IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard; //Config->bNavEnableGamepad = IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad; //Config->bNavNoCaptureInput = IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard; @@ -70,8 +79,8 @@ void FCogWindow_Settings::RenderContent() { Context.SetEnableInput(bEnableInput); } - FCogWindowWidgets::ItemTooltipWrappedText("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui."); - FCogWindowWidgets::MenuItemShortcut("EnableInputShortcut", FCogImguiInputHelper::KeyInfoToString(Config->ToggleImGuiInputShortcut)); + FCogWidgets::ItemTooltipWrappedText("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui."); + FCogWidgets::MenuItemShortcut("EnableInputShortcut", FCogImguiInputHelper::KeyInfoToString(Config->ToggleImGuiInputShortcut)); //------------------------------------------------------------------------------------------- bool bShareKeyboard = Context.GetShareKeyboard(); @@ -79,7 +88,7 @@ void FCogWindow_Settings::RenderContent() { Context.SetShareKeyboard(bShareKeyboard); } - FCogWindowWidgets::ItemTooltipWrappedText("Forward the keyboard inputs to the game when ImGui does not need them."); + FCogWidgets::ItemTooltipWrappedText("Forward the keyboard inputs to the game when ImGui does not need them."); //------------------------------------------------------------------------------------------- bool bShareMouse = Context.GetShareMouse(); @@ -87,7 +96,7 @@ void FCogWindow_Settings::RenderContent() { Context.SetShareMouse(bShareMouse); } - FCogWindowWidgets::ItemTooltipWrappedText("Forward mouse inputs to the game when ImGui does not need them."); + FCogWidgets::ItemTooltipWrappedText("Forward mouse inputs to the game when ImGui does not need them."); //------------------------------------------------------------------------------------------- if (bShareMouse == false) @@ -100,7 +109,7 @@ void FCogWindow_Settings::RenderContent() { Context.SetShareMouseWithGameplay(bShareMouseWithGameplay); } - FCogWindowWidgets::ItemTooltipWrappedText("When disabled, mouse inputs are only forwarded to game menus. " + FCogWidgets::ItemTooltipWrappedText("When disabled, mouse inputs are only forwarded to game menus. " "When enabled, mouse inputs are also forwarded to the gameplay. Note that this mode: \n" " - Force the cursor to be visible.\n" " - Prevent the interaction of Cog's transform gizmos.\n" @@ -113,19 +122,19 @@ void FCogWindow_Settings::RenderContent() //------------------------------------------------------------------------------------------- ImGui::CheckboxFlags("Keyboard Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard); - FCogWindowWidgets::ItemTooltipWrappedText("Use the keyboard to navigate in ImGui windows with the following keys : Tab, Directional Arrows, Space, Enter."); + FCogWidgets::ItemTooltipWrappedText("Use the keyboard to navigate in ImGui windows with the following keys : Tab, Directional Arrows, Space, Enter."); //------------------------------------------------------------------------------------------- //ImGui::CheckboxFlags("Gamepad Navigation", &IO.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad); - //FCogWindowWidgets::ItemTooltipWrappedText("Use the gamepad to navigate in ImGui windows."); + //FCogWidgets::ItemTooltipWrappedText("Use the gamepad to navigate in ImGui windows."); //------------------------------------------------------------------------------------------- ImGui::Checkbox("Disable Conflicting Commands", &Config->bDisableConflictingCommands); - FCogWindowWidgets::ItemTooltipWrappedText("Disable the existing Unreal command shortcuts mapped to same shortcuts Cog is using. Typically, if the F1 shortcut is used to toggle Inputs, the Unreal wireframe command will get disabled."); + FCogWidgets::ItemTooltipWrappedText("Disable the existing Unreal command shortcuts mapped to same shortcuts Cog is using. Typically, if the F1 shortcut is used to toggle Inputs, the Unreal wireframe command will get disabled."); //------------------------------------------------------------------------------------------- ImGui::Checkbox("Disable shortcuts when ImGui want text input", &Config->bDisableShortcutsWhenImGuiWantTextInput); - FCogWindowWidgets::ItemTooltipWrappedText("Disable Cog's shortcuts (ToggleInput, ToggleSelectionMode, LoadLayout, ...) when ImGui want text input." + FCogWidgets::ItemTooltipWrappedText("Disable Cog's shortcuts (ToggleInput, ToggleSelectionMode, LoadLayout, ...) when ImGui want text input." " This can be required if the shortcuts are mapped by keys generating a text input (letters, or Backspace for example)." " This is not required if the shortcuts are set to keys such as F1 or F2."); } @@ -137,26 +146,26 @@ void FCogWindow_Settings::RenderContent() { FCogImguiHelper::SetFlags(IO.ConfigFlags, ImGuiConfigFlags_ViewportsEnable, Config->bEnableViewports); } - FCogWindowWidgets::ItemTooltipWrappedText("Enable moving ImGui windows outside of the main viewport."); + FCogWidgets::ItemTooltipWrappedText("Enable moving ImGui windows outside of the main viewport."); //------------------------------------------------------------------------------------------- ImGui::Checkbox("Compact Mode", &Config->bCompactMode); - FCogWindowWidgets::ItemTooltipWrappedText("Enable compact mode."); + FCogWidgets::ItemTooltipWrappedText("Enable compact mode."); //------------------------------------------------------------------------------------------- ImGui::Checkbox("Transparent Mode", &Config->bTransparentMode); - FCogWindowWidgets::ItemTooltipWrappedText("Enable transparent mode."); + FCogWidgets::ItemTooltipWrappedText("Enable transparent mode."); //------------------------------------------------------------------------------------------- ImGui::Checkbox("Show Windows In Main Menu", &Config->bShowWindowsInMainMenu); - FCogWindowWidgets::ItemTooltipWrappedText("Show the content of the windows when hovering the window menu item."); + FCogWidgets::ItemTooltipWrappedText("Show the content of the windows when hovering the window menu item."); //------------------------------------------------------------------------------------------- ImGui::Checkbox("Show Help", &Config->bShowHelp); - FCogWindowWidgets::ItemTooltipWrappedText("Show windows help on the window menu items."); + FCogWidgets::ItemTooltipWrappedText("Show windows help on the window menu items."); //------------------------------------------------------------------------------------------- - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderFloat("DPI Scale", &Config->DPIScale, 0.5f, 2.0f, "%.1f"); if (ImGui::IsItemDeactivatedAfterEdit()) { @@ -173,14 +182,14 @@ void FCogWindow_Settings::RenderContent() //------------------------------------------------------------------------------------------- if (ImGui::CollapsingHeader("Widgets (?)", ImGuiTreeNodeFlags_DefaultOpen)) { - FCogWindowWidgets::ItemTooltipWrappedText("Widgets appear in the main menu bar."); + FCogWidgets::ItemTooltipWrappedText("Widgets appear in the main menu bar."); ImGui::Checkbox("Show Widget Borders", &Config->ShowWidgetBorders); - FCogWindowWidgets::ItemTooltipWrappedText("Should a border be visible between widgets."); + FCogWidgets::ItemTooltipWrappedText("Should a border be visible between widgets."); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::ComboboxEnum("Widgets Alignment", Config->WidgetAlignment); - FCogWindowWidgets::ItemTooltipWrappedText("How the widgets should be aligned in the main menu bar."); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Widgets Alignment", Config->WidgetAlignment); + FCogWidgets::ItemTooltipWrappedText("How the widgets should be aligned in the main menu bar."); if (ImGui::BeginChild("Widgets", ImVec2(0, ImGui::GetFontSize() * 10), ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_MenuBar)) { @@ -188,7 +197,7 @@ void FCogWindow_Settings::RenderContent() { ImGui::TextUnformatted("Widgets visibility and ordering"); ImGui::SameLine(); - FCogWindowWidgets::HelpMarker("Drag and drop the widget names to reorder them."); + FCogWidgets::HelpMarker("Drag and drop the widget names to reorder them."); ImGui::EndMenuBar(); } @@ -240,7 +249,7 @@ void FCogWindow_Settings::RenderContent() ImGui::Separator(); - char Buffer[32]; + static char Buffer[32]; for (int32 i = 0; i < Config->LoadLayoutShortcuts.Num(); ++i) { @@ -257,12 +266,24 @@ void FCogWindow_Settings::RenderContent() } //------------------------------------------------------------------------------------------- - if (ImGui::CollapsingHeader("Config")) + if (ImGui::CollapsingHeader("Settings", ImGuiTreeNodeFlags_DefaultOpen)) { - if (ImGui::Button("Reset All Windows Config", ImVec2(-1.0f, 0.0f))) + if (ImGui::Button("Save All Settings", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f))) + { + GetOwner()->SaveAllSettings(); + } + + // if (ImGui::Button("Reload All Settings", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f))) + // { + // GetOwner()->ReloadAllSettings(); + // } + + FCogWidgets::PushButtonBackColor(ImVec4(1.0f, 0.0f, 0.0f, 1)); + if (ImGui::Button("Reset All Settings", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f))) { GetOwner()->ResetAllWindowsConfig(); } + FCogWidgets::PopButtonBackColor(); } } @@ -296,7 +317,7 @@ void FCogWindow_Settings::SetDPIScale(float Value) const //-------------------------------------------------------------------------------------------------------------------------- void FCogWindow_Settings::RenderShortcut(const char* Label, FCogImGuiKeyInfo& KeyInfo) { - if (FCogWindowWidgets::InputKey(Label, KeyInfo)) + if (FCogWidgets::InputKey(Label, KeyInfo)) { GetOwner()->OnShortcutsDefined(); } diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Spacing.cpp b/Plugins/Cog/Source/Cog/Private/CogWindow_Spacing.cpp similarity index 70% rename from Plugins/Cog/Source/CogWindow/Private/CogWindow_Spacing.cpp rename to Plugins/Cog/Source/Cog/Private/CogWindow_Spacing.cpp index 605aa64..029731a 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Spacing.cpp +++ b/Plugins/Cog/Source/Cog/Private/CogWindow_Spacing.cpp @@ -1,5 +1,11 @@ #include "CogWindow_Spacing.h" +//-------------------------------------------------------------------------------------------------------------------------- +FCogWindow_Spacing::FCogWindow_Spacing() +{ + bShowInMainMenu = false; +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogWindow_Spacing::PreBegin(ImGuiWindowFlags& WindowFlags) { diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowConsoleCommandManager.h b/Plugins/Cog/Source/Cog/Public/CogConsoleCommandManager.h similarity index 89% rename from Plugins/Cog/Source/CogWindow/Public/CogWindowConsoleCommandManager.h rename to Plugins/Cog/Source/Cog/Public/CogConsoleCommandManager.h index c15a759..a6d2736 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowConsoleCommandManager.h +++ b/Plugins/Cog/Source/Cog/Public/CogConsoleCommandManager.h @@ -2,7 +2,6 @@ #include "CoreMinimal.h" #include "HAL/IConsoleManager.h" -#include "Templates/Function.h" class UWorld; @@ -11,7 +10,7 @@ DECLARE_DELEGATE_TwoParams(FCogWindowConsoleCommandDelegate, const TArray -const T* FCogWindowHelper::GetFirstAssetByClass() +const T* FCogHelper::GetFirstAssetByClass() { return Cast(GetFirstAssetByClass(T::StaticClass())); } diff --git a/Plugins/Cog/Source/Cog/Public/CogModule.h b/Plugins/Cog/Source/Cog/Public/CogModule.h new file mode 100644 index 0000000..d82413d --- /dev/null +++ b/Plugins/Cog/Source/Cog/Public/CogModule.h @@ -0,0 +1,16 @@ +#pragma once + +#include "CoreMinimal.h" +#include "Modules/ModuleManager.h" + +class COG_API FCogModule : public IModuleInterface +{ +public: + + static inline FCogModule& Get() { return FModuleManager::LoadModuleChecked("CogWindow"); } + + virtual void StartupModule() override; + + virtual void ShutdownModule() override; + +}; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h b/Plugins/Cog/Source/Cog/Public/CogSubsystem.h similarity index 83% rename from Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h rename to Plugins/Cog/Source/Cog/Public/CogSubsystem.h index b4d9a4e..d2bfe95 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h +++ b/Plugins/Cog/Source/Cog/Public/CogSubsystem.h @@ -5,7 +5,7 @@ #include "CogWindow_Settings.h" #include "imgui.h" #include "Engine/GameInstance.h" -#include "CogWindowManager.generated.h" +#include "CogSubsystem.generated.h" class UCogCommonConfig; class FCogWindow; @@ -19,31 +19,25 @@ struct ImGuiSettingsHandler; struct ImGuiTextBuffer; struct FKey; -UCLASS(Config = Cog) -class COGWINDOW_API UCogWindowManager : public UGameInstanceSubsystem +UCLASS() +class COG_API UCogSubsystem : public UGameInstanceSubsystem { GENERATED_BODY() public: - UCogWindowManager(); - virtual void Initialize(FSubsystemCollectionBase& Collection) override; virtual void Deinitialize() override; - - virtual void Shutdown(); + + void Activate(); virtual void SortMainMenu(); - virtual void Render(float DeltaTime); - - virtual void Tick(UWorld* World, ELevelTick TickType, float DeltaTime); - - virtual void AddWindow(FCogWindow* Window, const FString& Name, bool AddToMainMenu = true); + virtual void AddWindow(FCogWindow* Window, const FString& Name); template - T* AddWindow(const FString& Name, bool AddToMainMenu = true); + T* AddWindow(const FString& Name); virtual FCogWindow* FindWindowByID(ImGuiID ID); @@ -55,8 +49,6 @@ public: virtual void SaveLayout(int32 LayoutIndex); - virtual bool GetHideAllWindows() const { return bIsSelectionModeActive; } - virtual void SetActivateSelectionMode(bool Value); virtual bool GetActivateSelectionMode() const; @@ -70,7 +62,7 @@ public: template T* GetConfig(); - const UObject* GetAsset(const TSubclassOf AssetClass) const; + const UObject* GetAsset(const TSubclassOf& AssetClass) const; template T* GetAsset(); @@ -79,7 +71,7 @@ public: FCogImguiContext& GetContext() { return Context; } - void OnShortcutsDefined() const; + void OnShortcutsDefined(); bool IsRenderingMainMenu() const { return IsRenderingInMainMenu; } @@ -99,10 +91,18 @@ protected: TArray SubMenus; }; - virtual void TryInitializeInternal(); + virtual void Render(float DeltaTime); + + virtual void Tick(UWorld* InTickedWorld, ELevelTick InTickType, float InDeltaTime); + + virtual void TryInitialize(UWorld* World); + + virtual void InitializeWindow(FCogWindow* Window); + + virtual void Shutdown(); virtual void RenderMainMenu(); - + virtual FMenu* AddMenu(const FString& Name); virtual void RenderOptionMenu(FMenu& Menu); @@ -115,10 +115,14 @@ protected: virtual void DisableInputMode(); - virtual void HandleInputs(); + virtual void HandleInputs(const UPlayerInput& PlayerInput); virtual void RenderWidgets(); + virtual void SaveAllSettings(); + + virtual void ReloadAllSettings(); + static void SettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*); static void SettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*); @@ -129,6 +133,8 @@ protected: static void SettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf); + static FString EnableCommand; + static FString ToggleInputCommand; static FString DisableInputCommand; @@ -139,15 +145,15 @@ protected: static FString ResetLayoutCommand; + UPROPERTY() + TWeakObjectPtr CurrentWorld; + UPROPERTY() mutable TArray> Configs; UPROPERTY() mutable TArray> Assets; - UPROPERTY(Config) - bool bShowMainMenu = false; - FCogImguiContext Context; TArray Windows; @@ -172,25 +178,30 @@ protected: bool bIsInputEnabledBeforeEnteringSelectionMode = false; + bool bEnable = false; + bool bIsSelectionModeActive = false; bool IsInitialized = false; bool IsRenderingInMainMenu = false; + + int32 NumExecBindingsChecked = 0; + }; //-------------------------------------------------------------------------------------------------------------------------- template -T* UCogWindowManager::AddWindow(const FString& Name, bool AddToMainMenu) +T* UCogSubsystem::AddWindow(const FString& Name) { T* Window = new T(); - AddWindow(Window, Name, AddToMainMenu); + AddWindow(Window, Name); return Window; } //-------------------------------------------------------------------------------------------------------------------------- template -T* UCogWindowManager::GetConfig() +T* UCogSubsystem::GetConfig() { static_assert(TPointerIsConvertibleFromTo::Value); return Cast(GetConfig(T::StaticClass())); @@ -198,7 +209,7 @@ T* UCogWindowManager::GetConfig() //-------------------------------------------------------------------------------------------------------------------------- template -T* UCogWindowManager::GetAsset() +T* UCogSubsystem::GetAsset() { return Cast(GetAsset(T::StaticClass())); } \ No newline at end of file diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h b/Plugins/Cog/Source/Cog/Public/CogWidgets.h similarity index 93% rename from Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h rename to Plugins/Cog/Source/Cog/Public/CogWidgets.h index f2c07eb..35278ce 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h +++ b/Plugins/Cog/Source/Cog/Public/CogWidgets.h @@ -20,7 +20,7 @@ struct FKeyBind; using FCogWindowActorContextMenuFunction = TFunction; //-------------------------------------------------------------------------------------------------------------------------- -class COGWINDOW_API FCogWindowWidgets +class COG_API FCogWidgets { public: @@ -68,7 +68,15 @@ public: static bool SearchBar(const char* InLabel, ImGuiTextFilter& InFilter, float InWidth = -1.0f); + static void PushButtonBackColor(const ImVec4& Color); + + static void PopButtonBackColor(); + static void PushFrameBackColor(const ImVec4& Color); + static void PushSliderBackColor(const ImVec4& Color); + static void PushBackColor(const ImVec4& Color); + static void PopSliderBackColor(); + static void PopFrameBackColor(); static void PopBackColor(); @@ -163,7 +171,7 @@ public: }; template -bool FCogWindowWidgets::ComboboxEnum(const char* Label, const EnumType CurrentValue, EnumType& NewValue) +bool FCogWidgets::ComboboxEnum(const char* Label, const EnumType CurrentValue, EnumType& NewValue) { int64 NewValueInt; if (ComboboxEnum(Label, StaticEnum(), static_cast(CurrentValue), NewValueInt)) @@ -176,13 +184,13 @@ bool FCogWindowWidgets::ComboboxEnum(const char* Label, const EnumType CurrentVa } template -bool FCogWindowWidgets::ComboboxEnum(const char* Label, EnumType& Value) +bool FCogWidgets::ComboboxEnum(const char* Label, EnumType& Value) { return ComboboxEnum(Label, Value, Value); } template - bool FCogWindowWidgets::ScalarArray(const char* InLabel, ImGuiDataType InDataType, TArray& InArray, int32 InMaxEntries, const ImVec2& Size) + bool FCogWidgets::ScalarArray(const char* InLabel, ImGuiDataType InDataType, TArray& InArray, int32 InMaxEntries, const ImVec2& Size) { bool Result = false; ImGui::PushID(InLabel); diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h b/Plugins/Cog/Source/Cog/Public/CogWindow.h similarity index 91% rename from Plugins/Cog/Source/CogWindow/Public/CogWindow.h rename to Plugins/Cog/Source/Cog/Public/CogWindow.h index 476b2fb..ba4ea7c 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h +++ b/Plugins/Cog/Source/Cog/Public/CogWindow.h @@ -11,11 +11,11 @@ struct FCogDebugContext; class AActor; class APawn; class APlayerController; -class UCogWindowManager; +class UCogSubsystem; class ULocalPlayer; class UWorld; -class COGWINDOW_API FCogWindow +class COG_API FCogWindow { public: @@ -71,9 +71,9 @@ public: void SetWidgetOrderIndex(int32 Value) { WidgetOrderIndex = Value; } - void SetOwner(UCogWindowManager* InOwner) { Owner = InOwner; } + void SetOwner(UCogSubsystem* InOwner) { Owner = InOwner; } - UCogWindowManager* GetOwner() const { return Owner; } + UCogSubsystem* GetOwner() const { return Owner; } float GetDpiScale() const; @@ -89,7 +89,7 @@ public: protected: - friend class UCogWindowManager; + friend class UCogSubsystem; virtual const FString& GetTitle() const { return Title; } @@ -133,17 +133,21 @@ protected: bool bIsWidgetVisible = false; + bool bShowInMainMenu = true; + + bool bUseCustomContextMenu = false; + int32 WidgetOrderIndex = -1; - ImGuiID ID; + ImGuiID ID = 0; FString FullName; FString Name; FString Title; - - UCogWindowManager* Owner = nullptr; + + UCogSubsystem* Owner = nullptr; mutable TArray> ConfigsToResetOnRequest; }; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Layouts.h b/Plugins/Cog/Source/Cog/Public/CogWindow_Layouts.h similarity index 79% rename from Plugins/Cog/Source/CogWindow/Public/CogWindow_Layouts.h rename to Plugins/Cog/Source/Cog/Public/CogWindow_Layouts.h index 81a41c9..deb4b67 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Layouts.h +++ b/Plugins/Cog/Source/Cog/Public/CogWindow_Layouts.h @@ -5,14 +5,14 @@ class UPlayerInput; -class COGWINDOW_API FCogWindow_Layouts : public FCogWindow +class COG_API FCogWindow_Layouts : public FCogWindow { typedef FCogWindow Super; public: - - virtual void Initialize() override; + FCogWindow_Layouts(); + protected: virtual void RenderContent() override; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h b/Plugins/Cog/Source/Cog/Public/CogWindow_Settings.h similarity index 97% rename from Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h rename to Plugins/Cog/Source/Cog/Public/CogWindow_Settings.h index 48c31fc..894658b 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h +++ b/Plugins/Cog/Source/Cog/Public/CogWindow_Settings.h @@ -9,11 +9,13 @@ class UCogEngineConfig_Settings; //-------------------------------------------------------------------------------------------------------------------------- -class COGWINDOW_API FCogWindow_Settings : public FCogWindow +class COG_API FCogWindow_Settings : public FCogWindow { typedef FCogWindow Super; public: + + FCogWindow_Settings(); virtual void Initialize() override; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Spacing.h b/Plugins/Cog/Source/Cog/Public/CogWindow_Spacing.h similarity index 69% rename from Plugins/Cog/Source/CogWindow/Public/CogWindow_Spacing.h rename to Plugins/Cog/Source/Cog/Public/CogWindow_Spacing.h index 22f6d6a..3a27f78 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Spacing.h +++ b/Plugins/Cog/Source/Cog/Public/CogWindow_Spacing.h @@ -3,14 +3,15 @@ #include "CoreMinimal.h" #include "CogWindow.h" -class COGWINDOW_API FCogWindow_Spacing : public FCogWindow +class COG_API FCogWindow_Spacing : public FCogWindow { typedef FCogWindow Super; -protected: +public: + + FCogWindow_Spacing(); virtual void PreBegin(ImGuiWindowFlags& WindowFlags) override; virtual void PostBegin() override; - }; diff --git a/Plugins/Cog/Source/CogEngine/CogEngine.Build.cs b/Plugins/Cog/Source/CogEngine/CogEngine.Build.cs index 49de904..078030c 100644 --- a/Plugins/Cog/Source/CogEngine/CogEngine.Build.cs +++ b/Plugins/Cog/Source/CogEngine/CogEngine.Build.cs @@ -18,7 +18,7 @@ public class CogEngine : ModuleRules "ApplicationCore", "CogCommon", "CogImgui", - "CogWindow", + "Cog", "Core", "CoreUObject", "Engine", diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineHelper.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineHelper.cpp index ccea503..5532b0d 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineHelper.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineHelper.cpp @@ -1,7 +1,7 @@ #include "CogEngineHelper.h" #include "CogEngineReplicator.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "imgui.h" #include "GameFramework/Actor.h" #include "GameFramework/Pawn.h" @@ -14,10 +14,10 @@ //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineHelper::ActorContextMenu(AActor& Actor) { - FCogWindowWidgets::ThinSeparatorText("Object"); + FCogWidgets::ThinSeparatorText("Object"); #if WITH_EDITOR - FCogWindowWidgets::OpenObjectAssetButton(&Actor, ImVec2(-1, 0)); + FCogWidgets::OpenObjectAssetButton(&Actor, ImVec2(-1, 0)); #endif if (ImGui::Button("Delete", ImVec2(-1, 0))) @@ -30,7 +30,7 @@ void FCogEngineHelper::ActorContextMenu(AActor& Actor) if (APawn* Pawn = Cast(&Actor)) { - FCogWindowWidgets::ThinSeparatorText("Pawn"); + FCogWidgets::ThinSeparatorText("Pawn"); if (ImGui::Button("Possess", ImVec2(-1, 0))) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_BuildInfo.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_BuildInfo.cpp index 84acc02..8feb7a7 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_BuildInfo.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_BuildInfo.cpp @@ -44,7 +44,7 @@ void FCogEngineWindow_BuildInfo::RenderTick(float DeltaTime) const ImVec2 WindowPadding = ImGui::GetStyle().WindowPadding; const ImVec2 TextSize = ImGui::CalcTextSize(TextStr.Get(), nullptr, false); const ImVec2 RectSize = TextSize + WindowPadding * 2; - const ImVec2 Pos = FCogWindowWidgets::ComputeScreenCornerLocation(Config->Alignment, Config->Padding); + const ImVec2 Pos = FCogWidgets::ComputeScreenCornerLocation(Config->Alignment, Config->Padding); const ImVec2 AlignedPos = Pos - (FCogImguiHelper::ToImVec2(Config->Alignment) * RectSize); DrawList->AddRectFilled(AlignedPos, AlignedPos + RectSize, FCogImguiHelper::ToImU32(Config->BackgroundColor), Config->Rounding); @@ -57,7 +57,7 @@ void FCogEngineWindow_BuildInfo::RenderContent() { Super::RenderContent(); - FCogWindowWidgets::ThinSeparatorText("Build Properties"); + FCogWidgets::ThinSeparatorText("Build Properties"); if (ImGui::BeginChild("Settings", ImVec2(-1, 100 * GetDpiScale()), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeY)) { @@ -72,19 +72,19 @@ void FCogEngineWindow_BuildInfo::RenderContent() } ImGui::EndChild(); - FCogWindowWidgets::ThinSeparatorText("Display"); + FCogWidgets::ThinSeparatorText("Display"); ImGui::Checkbox("Show In Editor", &Config->ShowInEditor); ImGui::Checkbox("Show In Package", &Config->ShowInPackage); ImGui::Checkbox("Show In Foreground", &Config->ShowInForeground); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderFloat2("Alignment", &Config->Alignment.X, 0, 1.0f, "%.2f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderInt2("Padding", &Config->Padding.X, 0, 100); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderInt("Rounding", &Config->Rounding, 0, 12); constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf; diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Cheats.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Cheats.cpp index cd8e798..ca1ae50 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Cheats.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Cheats.cpp @@ -5,8 +5,8 @@ #include "CogCommonAllegianceActorInterface.h" #include "CogEngineHelper.h" #include "CogImguiHelper.h" -#include "CogWindowConsoleCommandManager.h" -#include "CogWindowWidgets.h" +#include "CogConsoleCommandManager.h" +#include "CogWidgets.h" #include "EngineUtils.h" #include "GameFramework/Character.h" #include "imgui.h" @@ -36,7 +36,7 @@ void FCogEngineWindow_Cheats::Initialize() Asset = GetAsset(); Config = GetConfig(); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( TEXT("Cog.Cheat"), TEXT("Apply a cheat to the selection. Cog.Cheat -Allies -Enemies -Controlled"), GetWorld(), @@ -250,7 +250,7 @@ void FCogEngineWindow_Cheats::RenderContent() ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } @@ -273,7 +273,7 @@ void FCogEngineWindow_Cheats::RenderContent() bool Open = true; if (Config->bGroupByCategories) { - Open = FCogWindowWidgets::DarkCollapsingHeader(CategoryStr.Get(), ImGuiTreeNodeFlags_DefaultOpen); + Open = FCogWidgets::DarkCollapsingHeader(CategoryStr.Get(), ImGuiTreeNodeFlags_DefaultOpen); if (Open && Config->bUseTwoColumns) { @@ -351,7 +351,7 @@ bool FCogEngineWindow_Cheats::AddCheat(ACogEngineReplicator& Replicator, const i ImGui::PushID(Index); - FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Cheat.CustomColor)); + FCogWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Cheat.CustomColor)); const bool IsShiftDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Shift) != 0; const bool IsAltDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Alt) != 0; @@ -387,7 +387,7 @@ bool FCogEngineWindow_Cheats::AddCheat(ACogEngineReplicator& Replicator, const i ImGui::EndTooltip(); } - FCogWindowWidgets::PopBackColor(); + FCogWidgets::PopBackColor(); ImGui::PopID(); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp index 347d76f..b876d00 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp @@ -2,7 +2,7 @@ #include "CogDebug.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Components/PrimitiveComponent.h" #include "Components/SceneComponent.h" #include "Engine/CollisionProfile.h" @@ -77,7 +77,7 @@ void FCogEngineWindow_CollisionTester::RenderContent() ImGui::SetNextItemWidth(-1); AActor* NewSelection = nullptr; - if (FCogWindowWidgets::MenuActorsCombo("CollisionTesters", NewSelection, *GetWorld(), ACogEngineCollisionTester::StaticClass())) + if (FCogWidgets::MenuActorsCombo("CollisionTesters", NewSelection, *GetWorld(), ACogEngineCollisionTester::StaticClass())) { FCogDebug::SetSelection(NewSelection); } @@ -106,23 +106,23 @@ void FCogEngineWindow_CollisionTester::RenderContent() EndGizmo.Draw("CollisionTesterEndGizmo", *LocalPlayerController, *CollisionTester->EndComponent, ECogDebug_GizmoFlags::NoRotation | ECogDebug_GizmoFlags::NoScale); } - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::ComboboxEnum("Type", CollisionTester->Type); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Type", CollisionTester->Type); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::ComboboxEnum("Mode", CollisionTester->Mode); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Mode", CollisionTester->Mode); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::ComboboxEnum("By", CollisionTester->By); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("By", CollisionTester->By); //------------------------------------------------- // Channel //------------------------------------------------- if (CollisionTester->By == ECogEngine_CollisionQueryBy::Channel) { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ECollisionChannel Channel = CollisionTester->Channel.GetValue(); - if (FCogWindowWidgets::ComboCollisionChannel("Channel", Channel)) + if (FCogWidgets::ComboCollisionChannel("Channel", Channel)) { CollisionTester->Channel = Channel; } @@ -135,7 +135,7 @@ void FCogEngineWindow_CollisionTester::RenderContent() const FCollisionResponseTemplate* SelectedProfile = CollisionProfile->GetProfileByIndex(CollisionTester->ProfileIndex); const FName SelectedProfileName = SelectedProfile != nullptr ? SelectedProfile->Name : FName("Custom"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("Profile", TCHAR_TO_ANSI(*SelectedProfileName.ToString()), ImGuiComboFlags_HeightLargest)) { for (int i = 0; i < CollisionProfile->GetNumOfProfiles(); ++i) @@ -171,31 +171,31 @@ void FCogEngineWindow_CollisionTester::RenderContent() if (CollisionTester->Type != ECogEngine_CollisionQueryType::LineTrace) { - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::ComboboxEnum("Shape", CollisionTester->Shape); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Shape", CollisionTester->Shape); switch (CollisionTester->Shape) { case ECogEngine_CollisionQueryShape::Sphere: { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); FCogImguiHelper::DragDouble("Sphere Radius", &CollisionTester->ShapeExtent.X, 1.0f, 0, FLT_MAX, "%.1f"); break; } case ECogEngine_CollisionQueryShape::Box: { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); FCogImguiHelper::DragFVector("Box Extent", CollisionTester->ShapeExtent, 1.0f, 0, FLT_MAX, "%.1f"); break; } case ECogEngine_CollisionQueryShape::Capsule: { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); FCogImguiHelper::DragDouble("Capsule Radius", &CollisionTester->ShapeExtent.X, 1.0f, 0, FLT_MAX, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); FCogImguiHelper::DragDouble("Capsule Half Height", &CollisionTester->ShapeExtent.Z, 1.0f, 0, FLT_MAX, "%.1f"); break; } @@ -209,12 +209,12 @@ void FCogEngineWindow_CollisionTester::RenderContent() { ImGui::Separator(); ImGui::BeginDisabled(); - FCogWindowWidgets::CollisionProfileChannels(CollisionTester->ObjectTypesToQuery); + FCogWidgets::CollisionProfileChannels(CollisionTester->ObjectTypesToQuery); ImGui::EndDisabled(); } else if (CollisionTester->By == ECogEngine_CollisionQueryBy::ObjectType) { ImGui::Separator(); - FCogWindowWidgets::CollisionProfileChannels(CollisionTester->ObjectTypesToQuery); + FCogWidgets::CollisionProfileChannels(CollisionTester->ObjectTypesToQuery); } } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp index 5fbcc21..0aad8fe 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp @@ -3,7 +3,7 @@ #include "CogDebugDrawHelper.h" #include "CogDebug.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Components/PrimitiveComponent.h" #include "Components/SceneComponent.h" #include "DrawDebugHelpers.h" @@ -132,7 +132,7 @@ void FCogEngineWindow_CollisionViewer::RenderContent() } ImGui::Separator(); - FCogWindowWidgets::CollisionProfileChannels(Config->ObjectTypesToQuery); + FCogWidgets::CollisionProfileChannels(Config->ObjectTypesToQuery); //------------------------------------------------- // Perform Query diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp index 4786fa0..b141445 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp @@ -1,7 +1,7 @@ #include "CogEngineWindow_CommandBindings.h" -#include "CogWindowManager.h" -#include "CogWindowWidgets.h" +#include "CogSubsystem.h" +#include "CogWidgets.h" #include "GameFramework/PlayerController.h" #include "GameFramework/PlayerInput.h" #include "imgui.h" @@ -35,21 +35,21 @@ void FCogEngineWindow_CommandBindings::RenderContent() int32 Index = 0; int32 IndexToRemove = INDEX_NONE; - if (FCogWindowWidgets::ButtonWithTooltip("Add", "Add a new item in the array")) + if (FCogWidgets::ButtonWithTooltip("Add", "Add a new item in the array")) { PlayerInput->DebugExecBindings.AddDefaulted(); PlayerInput->SaveConfig(); } ImGui::SameLine(); - if (FCogWindowWidgets::ButtonWithTooltip("Sort", "Sort the array")) + if (FCogWidgets::ButtonWithTooltip("Sort", "Sort the array")) { - UCogWindowManager::SortCommands(PlayerInput); + UCogSubsystem::SortCommands(PlayerInput); PlayerInput->SaveConfig(); } ImGui::SameLine(); - if (FCogWindowWidgets::ButtonWithTooltip( + if (FCogWidgets::ButtonWithTooltip( "Disable Conflicting Commands", "Disable the existing Unreal command shortcuts mapped to same shortcuts Cog is using. Typically, if the F1 shortcut is used to toggle Inputs, the Unreal wireframe command will get disabled." )) @@ -61,14 +61,14 @@ void FCogEngineWindow_CommandBindings::RenderContent() { ImGui::PushID(Index); - if (FCogWindowWidgets::DeleteArrayItemButton()) + if (FCogWidgets::DeleteArrayItemButton()) { IndexToRemove = Index; } ImGui::SameLine(); - if (FCogWindowWidgets::KeyBind(KeyBind)) + if (FCogWidgets::KeyBind(KeyBind)) { PlayerInput->SaveConfig(); } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Console.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Console.cpp index 238c60a..faba536 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Console.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Console.cpp @@ -1,8 +1,8 @@ #include "CogEngineWindow_Console.h" #include "CogImguiHelper.h" -#include "CogWindowManager.h" -#include "CogWindowWidgets.h" +#include "CogSubsystem.h" +#include "CogWidgets.h" #include "imgui.h" #include "imgui_internal.h" @@ -175,7 +175,7 @@ void FCogEngineWindow_Console::RenderMenu() { if (ImGui::BeginMenu("Options")) { - FCogWindowWidgets::ThinSeparatorText("General"); + FCogWidgets::ThinSeparatorText("General"); ImGui::Checkbox("Show Help", &Config->ShowHelp); @@ -189,13 +189,13 @@ void FCogEngineWindow_Console::RenderMenu() // RefreshCommandList(); // } - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Completion Minimum Characters", &Config->CompletionMinimumCharacters, 0, 3)) { RefreshCommandList(); } - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Num History Commands", &Config->NumHistoryCommands, 0, 100)) { RefreshCommandList(); @@ -203,21 +203,21 @@ void FCogEngineWindow_Console::RenderMenu() ImGui::ColorEdit4("History Color", &Config->HistoryColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); - FCogWindowWidgets::ThinSeparatorText("Window"); + FCogWidgets::ThinSeparatorText("Window"); if (ImGui::Checkbox("Dock Input in Menu Bar", &Config->DockInputInMenuBar)) { RefreshCommandList(); } - FCogWindowWidgets::ThinSeparatorText("Widget"); + FCogWidgets::ThinSeparatorText("Widget"); if (ImGui::Checkbox("Focus Console Widget When Appearing", &Config->FocusWidgetWhenAppearing)) { RefreshCommandList(); } - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderInt("Widget Width", &Config->WidgetWidth, 0, 1000); ImGui::EndMenu(); @@ -243,7 +243,7 @@ void FCogEngineWindow_Console::RenderInput() | ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_CallbackAlways; - const bool IsEnterPressed = FCogWindowWidgets::InputTextWithHint("##Command", "Command", CurrentUserInput, InputFlags, &OnTextInputCallbackStub, this); + const bool IsEnterPressed = FCogWidgets::InputTextWithHint("##Command", "Command", CurrentUserInput, InputFlags, &OnTextInputCallbackStub, this); InputTextId = ImGui::GetItemID(); if (IsEnterPressed) diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp index b138c94..0c2c091 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp @@ -2,7 +2,7 @@ #include "CogDebug.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/CollisionProfile.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -32,6 +32,9 @@ void FCogEngineWindow_DebugSettings::PreSaveConfig() { Super::PreSaveConfig(); + if (Config == nullptr) + { return; } + Config->Data = FCogDebug::Settings; } @@ -83,53 +86,53 @@ void FCogEngineWindow_DebugSettings::RenderContent() ImGui::Checkbox("Text Shadow", &Settings.TextShadow); ImGui::SetItemTooltip("Show a shadow below debug text."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::Checkbox("Fade 2D", &Settings.Fade2D); ImGui::SetItemTooltip("Does the 2D debug is fading out."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Duration", &Settings.Duration, 0.01f, 0.0f, 100.0f, "%.1f"); ImGui::SetItemTooltip("The duration of debug elements."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Thickness", &Settings.Thickness, 0.05f, 0.0f, 5.0f, "%.1f"); ImGui::SetItemTooltip("The thickness of debug lines."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Server Thickness", &Settings.ServerThickness, 0.05f, 0.0f, 5.0f, "%.1f"); ImGui::SetItemTooltip("The thickness the server debug lines."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Server Color Mult", &Settings.ServerColorMultiplier, 0.01f, 0.0f, 1.0f, "%.1f"); ImGui::SetItemTooltip("The color multiplier applied to the server debug lines."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragInt("Depth Priority", &Settings.DepthPriority, 0.1f, 0, 100); ImGui::SetItemTooltip("The depth priority of debug elements."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragInt("Segments", &Settings.Segments, 0.1f, 4, 20.0f); ImGui::SetItemTooltip("The number of segments used for circular shapes."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Axes Scale", &Settings.AxesScale, 0.1f, 0, 10.0f, "%.1f"); ImGui::SetItemTooltip("The scaling debug axis."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Arrow Size", &Settings.ArrowSize, 1.0f, 0.0f, 200.0f, "%.0f"); ImGui::SetItemTooltip("The size of debug arrows."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Text Size", &Settings.TextSize, 0.1f, 0.1f, 5.0f, "%.1f"); ImGui::SetItemTooltip("The size of the debug texts."); } if (ImGui::CollapsingHeader("Recolor", ImGuiTreeNodeFlags_DefaultOpen)) { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ECogDebugRecolorMode Mode = Settings.RecolorMode; - if (FCogWindowWidgets::ComboboxEnum("Recolor mode", Mode)) + if (FCogWidgets::ComboboxEnum("Recolor mode", Mode)) { Settings.RecolorMode = Mode; } @@ -137,7 +140,7 @@ void FCogEngineWindow_DebugSettings::RenderContent() if (Settings.RecolorMode != ECogDebugRecolorMode::None) { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Recolor Intensity", &Settings.RecolorIntensity, 0.01f, 0.0f, 1.0f, "%.2f"); ImGui::SetItemTooltip("How much the debug elements color should be changed."); } @@ -148,13 +151,13 @@ void FCogEngineWindow_DebugSettings::RenderContent() } else if (Settings.RecolorMode == ECogDebugRecolorMode::HueOverTime) { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Recolor Speed", &Settings.RecolorTimeSpeed, 0.1f, 0.0f, 10.0f, "%.1f"); ImGui::SetItemTooltip("The speed of the recolor."); } else if (Settings.RecolorMode == ECogDebugRecolorMode::HueOverFrames) { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragInt("Recolor Cycle", &Settings.RecolorFrameCycle, 1, 2, 100); ImGui::SetItemTooltip("How many frames are used to perform a full hue cycle."); } @@ -166,92 +169,92 @@ void FCogEngineWindow_DebugSettings::RenderContent() ImGui::Checkbox("Use Local Space", &Settings.GizmoUseLocalSpace); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Gizmo Scale", &Settings.GizmoScale, 0.1f, 0.1f, 10.0f, "%.1f"); ImGui::SetItemTooltip("The scale of the gizmo."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragInt("Z Low", &Settings.GizmoZLow, 0.5f, 0, 1000); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragInt("Z High", &Settings.GizmoZHigh, 0.5f, 0, 1000); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Thickness Z Low", &Settings.GizmoThicknessZLow, 0.1f, 0.0f, 10.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Thickness Z High", &Settings.GizmoThicknessZHigh, 0.1f, 0.0f, 10.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Mouse Max Distance", &Settings.GizmoCursorSelectionThreshold, 0.1f, 0.0f, 50.0f, "%.1f"); ImGui::SeparatorText("Translation"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::Checkbox("Translation Snap Enable", &Settings.GizmoTranslationSnapEnable); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Translation Snap", &Settings.GizmoTranslationSnapValue, 0.1f, 0.0f, 1000.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Translation Axis Length", &Settings.GizmoTranslationAxisLength, 0.1f, 0.1f, 500.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Translation Plane Offset", &Settings.GizmoTranslationPlaneOffset, 0.1f, 0.0f, 500.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Translation Plane Extent", &Settings.GizmoTranslationPlaneExtent, 0.1f, 0.0f, 100.0f, "%.1f"); ImGui::SeparatorText("Rotation"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::Checkbox("Rotation Snap Enable", &Settings.GizmoRotationSnapEnable); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Rotation Snap", &Settings.GizmoRotationSnapValue, 0.1f, 0.0f, 360.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Rotation Speed", &Settings.GizmoRotationSpeed, 0.01f, 0.01f, 100.0f, "%.2f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Rotation Radius", &Settings.GizmoRotationRadius, 0.1f, 0.1f, 500.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragInt("Rotation Segments", &Settings.GizmoRotationSegments, 0.5f, 2, 12); ImGui::SeparatorText("Scale"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::Checkbox("Scale Snap Enable", &Settings.GizmoScaleSnapEnable); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Scale Snap", &Settings.GizmoScaleSnapValue, 0.1f, 0.0f, 10.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Scale Box Offset", &Settings.GizmoScaleBoxOffset, 0.0f, 0.0f, 500.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Scale Box Extent", &Settings.GizmoScaleBoxExtent, 0.1f, 0.0f, 100.0f, "%.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Scale Speed", &Settings.GizmoScaleSpeed, 0.01f, 0.01f, 100.0f, "%.2f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Scale Min", &Settings.GizmoScaleMin, 0.001f, 0.001f, 1.0f, "%.3f"); ImGui::SeparatorText("Ground Raycast"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Ground Raycast Length", &Settings.GizmoGroundRaycastLength, 10.0f, 0.0f, 1000000.0f, "%.0f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ECollisionChannel Channel = Settings.GizmoGroundRaycastChannel.GetValue(); - if (FCogWindowWidgets::ComboCollisionChannel("Channel", Channel)) + if (FCogWidgets::ComboCollisionChannel("Channel", Channel)) { Settings.GizmoGroundRaycastChannel = Channel; } - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Ground Raycast Circle Radius", &Settings.GizmoGroundRaycastCircleRadius, 0.1f, 0.1f, 1000.0f, "%.1f"); FCogImguiHelper::ColorEdit4("Ground Raycast Color", Settings.GizmoGroundRaycastColor, ColorEditFlags); @@ -342,11 +345,11 @@ void FCogEngineWindow_DebugSettings::RenderContent() ImGui::Checkbox("Draw Hit Impact Normals", &Settings.CollisionQueryDrawHitImpactNormals); ImGui::SetItemTooltip("Draw the hit impact normal of hit results."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Primitive Actors Name Size", &Settings.CollisionQueryHitPrimitiveActorsNameSize, 0.1f, 0.5f, 10.0f, "%0.1f"); ImGui::SetItemTooltip("Size of the actor name of the primitives that have been hit."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Hit Point Size", &Settings.CollisionQueryHitPointSize, 0.5f, 0.0f, 100.0f, "%0.1f"); ImGui::SetItemTooltip("Size of the hit result location and impact point."); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp index 5fbb518..6f1c3ae 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp @@ -1,6 +1,6 @@ #include "CogEngineWindow_Inspector.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Containers/SortedMap.h" #include "Engine/Engine.h" #include "imgui_internal.h" @@ -166,7 +166,7 @@ void FCogEngineWindow_Inspector::RenderMenu() ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); ImGui::SameLine(); - if (ImGui::Button(InspectedObjectName.Get(), ImVec2(FCogWindowWidgets::GetFontWidth() * 20, 0))) + if (ImGui::Button(InspectedObjectName.Get(), ImVec2(FCogWidgets::GetFontWidth() * 20, 0))) { ImGui::OpenPopup("SelectionPopup"); } @@ -187,7 +187,7 @@ void FCogEngineWindow_Inspector::RenderMenu() ImGui::SetNextWindowPos(Pos + ImVec2(0, ImGui::GetFrameHeight())); if (ImGui::BeginPopup("SelectionPopup")) { - ImGui::BeginChild("Popup", ImVec2(FCogWindowWidgets::GetFontWidth() * 30, FCogWindowWidgets::GetFontWidth() * 40), false); + ImGui::BeginChild("Popup", ImVec2(FCogWidgets::GetFontWidth() * 30, FCogWidgets::GetFontWidth() * 40), false); //----------------------------------- // FAVORITES @@ -251,7 +251,7 @@ void FCogEngineWindow_Inspector::RenderMenu() //----------------------------------- // Search //----------------------------------- - FCogWindowWidgets::SearchBar("##Filter", Filter, -FCogWindowWidgets::GetFontWidth() * 9); + FCogWidgets::SearchBar("##Filter", Filter, -FCogWidgets::GetFontWidth() * 9); //----------------------------------- // Options @@ -376,7 +376,7 @@ bool FCogEngineWindow_Inspector::RenderInspector() //-------------------------------------------------------------------------------------------------------------------------- bool FCogEngineWindow_Inspector::RenderBegin() { - FCogWindowWidgets::PushStyleCompact(); + FCogWidgets::PushStyleCompact(); ImGuiTableFlags TableFlags = ImGuiTableFlags_Resizable; if ((Config->bShowBorders) != 0) @@ -407,7 +407,7 @@ bool FCogEngineWindow_Inspector::RenderBegin() void FCogEngineWindow_Inspector::RenderEnd() { ImGui::EndTable(); - FCogWindowWidgets::PopStyleCompact(); + FCogWidgets::PopStyleCompact(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -787,7 +787,7 @@ bool FCogEngineWindow_Inspector::RenderDouble(const FDoubleProperty* DoublePrope //-------------------------------------------------------------------------------------------------------------------------- bool FCogEngineWindow_Inspector::RenderEnum(const FEnumProperty* EnumProperty, uint8* PointerToValue) { - return FCogWindowWidgets::ComboboxEnum("##Enum", EnumProperty, PointerToValue); + return FCogWidgets::ComboboxEnum("##Enum", EnumProperty, PointerToValue); } //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Levels.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Levels.cpp index a8a6d1d..97b0fcf 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Levels.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Levels.cpp @@ -1,7 +1,7 @@ #include "CogEngineWindow_Levels.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "AssetRegistry/AssetRegistryModule.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -71,7 +71,7 @@ void FCogEngineWindow_Levels::RenderMenu() ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } @@ -169,7 +169,7 @@ void FCogEngineWindow_Levels::RenderLevelContextMenu(int Index, const FAssetData { if (ImGui::BeginPopupContextItem()) { - FCogWindowWidgets::BrowseToAssetButton(Asset); + FCogWidgets::BrowseToAssetButton(Asset); ImGui::EndPopup(); } } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp index 9758980..42f1cbb 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp @@ -2,7 +2,7 @@ #include "CogDebugHelper.h" #include "CogDebug.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "CogDebugLog.h" #include "DrawDebugHelpers.h" #include "Engine/World.h" @@ -76,12 +76,12 @@ void FCogEngineWindow_LogCategories::RenderContent() bool bIsFilteringBySelection = FCogDebug::GetIsFilteringBySelection(); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2); - FCogWindowWidgets::PushStyleCompact(); + FCogWidgets::PushStyleCompact(); if (ImGui::Checkbox("Filter", &bIsFilteringBySelection)) { FCogDebug::SetIsFilteringBySelection(GetWorld(), bIsFilteringBySelection); } - FCogWindowWidgets::PopStyleCompact(); + FCogWidgets::PopStyleCompact(); if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) { @@ -219,7 +219,7 @@ void FCogEngineWindow_LogCategories::RenderContent() if (IsClient) { const ELogVerbosity::Type CurrentVerbosity = FCogDebugLog::GetServerVerbosity(CategoryName); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("##Server", FCogDebugHelper::VerbosityToString(CurrentVerbosity))) { for (int32 i = ELogVerbosity::Error; i <= static_cast(ELogVerbosity::VeryVerbose); ++i) @@ -249,7 +249,7 @@ void FCogEngineWindow_LogCategories::RenderContent() { const ELogVerbosity::Type CurrentVerbosity = Category->GetVerbosity(); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("##Local", FCogDebugHelper::VerbosityToString(CurrentVerbosity))) { for (int32 i = ELogVerbosity::Error; i <= static_cast(ELogVerbosity::VeryVerbose); ++i) diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp index 6d70ac4..8dac6f0 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp @@ -1,7 +1,7 @@ #include "CogEngineWindow_Metrics.h" #include "CogDebugMetric.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "imgui.h" #include "Engine/World.h" @@ -32,6 +32,9 @@ void FCogEngineWindow_Metrics::PreSaveConfig() { Super::PreSaveConfig(); + if (Config == nullptr) + { return; } + Config->MaxDurationSetting = FCogDebugMetric::MaxDurationSetting; Config->RestartDelaySetting = FCogDebugMetric::RestartDelaySetting; } @@ -54,13 +57,13 @@ void FCogEngineWindow_Metrics::RenderContent() { if (ImGui::BeginMenu("Options")) { - FCogWindowWidgets::PushStyleCompact(); + FCogWidgets::PushStyleCompact(); ImGui::DragFloat("Auto Restart Delay", &FCogDebugMetric::RestartDelaySetting, 0.1f, 0.0f, FLT_MAX, "%0.1f"); - FCogWindowWidgets::PopStyleCompact(); + FCogWidgets::PopStyleCompact(); - FCogWindowWidgets::PushStyleCompact(); + FCogWidgets::PushStyleCompact(); ImGui::DragFloat("Max Time", &FCogDebugMetric::MaxDurationSetting, 0.1f, 0.0f, FLT_MAX, "%0.1f"); - FCogWindowWidgets::PopStyleCompact(); + FCogWidgets::PopStyleCompact(); ImGui::EndMenu(); } @@ -100,7 +103,7 @@ void FCogEngineWindow_Metrics::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Metrics::DrawMetric(FCogDebugMetricEntry& Metric) { - FCogWindowWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1.0f)); + FCogWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1.0f)); if (ImGui::BeginTable("MetricTable", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg)) { @@ -120,25 +123,25 @@ void FCogEngineWindow_Metrics::DrawMetric(FCogDebugMetricEntry& Metric) } ImGui::Text("Crits"); - ImGui::SameLine(FCogWindowWidgets::GetFontWidth() * 20); - FCogWindowWidgets::ProgressBarCentered(Metric.Count == 0 ? 0.0f : Metric.Crits / static_cast(Metric.Count), ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), Metric.Crits, Metric.Count))); + ImGui::SameLine(FCogWidgets::GetFontWidth() * 20); + FCogWidgets::ProgressBarCentered(Metric.Count == 0 ? 0.0f : Metric.Crits / static_cast(Metric.Count), ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), Metric.Crits, Metric.Count))); if (FCogDebugMetric::MaxDurationSetting > 0.0f) { ImGui::Text("Timer"); - ImGui::SameLine(FCogWindowWidgets::GetFontWidth() * 20); - FCogWindowWidgets::ProgressBarCentered(Metric.Timer / (float)FCogDebugMetric::MaxDurationSetting, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%0.1f / %0.1f"), Metric.Timer, FCogDebugMetric::MaxDurationSetting))); + ImGui::SameLine(FCogWidgets::GetFontWidth() * 20); + FCogWidgets::ProgressBarCentered(Metric.Timer / (float)FCogDebugMetric::MaxDurationSetting, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%0.1f / %0.1f"), Metric.Timer, FCogDebugMetric::MaxDurationSetting))); } else { ImGui::Text("Timer"); - ImGui::SameLine(FCogWindowWidgets::GetFontWidth() * 20); + ImGui::SameLine(FCogWidgets::GetFontWidth() * 20); ImGui::Text("%0.1f", Metric.Timer); } ImGui::Spacing(); - FCogWindowWidgets::PopBackColor(); + FCogWidgets::PopBackColor(); if (ImGui::Button("Restart")) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp index 759f4e6..6d4e916 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp @@ -2,7 +2,7 @@ #include "CogEngineWindow_Stats.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/Engine.h" #include "Engine/NetConnection.h" #include "Engine/NetDriver.h" @@ -102,7 +102,7 @@ void FCogEngineWindow_NetEmulation::DrawControls() return; } - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("Driver", TCHAR_TO_ANSI(*SelectedNetDriver->NetDriver->GetName()))) { int i = 0; @@ -133,7 +133,7 @@ void FCogEngineWindow_NetEmulation::DrawControls() FPacketSimulationSettings Settings = SelectedNetDriver->NetDriver->PacketSimulationSettings; //------------------------------------------------------------------------------------------- - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::DragInt("Lag Min", &Settings.PktLagMin, 5.0f, 0, INT_MAX, "%d ms")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -145,7 +145,7 @@ void FCogEngineWindow_NetEmulation::DrawControls() } //------------------------------------------------------------------------------------------- - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::DragInt("Lag Max", &Settings.PktLagMax, 5.0f, 0, INT_MAX, "%d ms")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -157,7 +157,7 @@ void FCogEngineWindow_NetEmulation::DrawControls() } - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Packet Loss", &Settings.PktLoss, 0, 100, "%d%%")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -173,7 +173,7 @@ void FCogEngineWindow_NetEmulation::DrawControls() } //------------------------------------------------------------------------------------------- - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Packet Order", &Settings.PktOrder, 0, 100, "%d%%")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -188,7 +188,7 @@ void FCogEngineWindow_NetEmulation::DrawControls() } //------------------------------------------------------------------------------------------- - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Packet Dup", &Settings.PktDup, 0, 100, "%d%%")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -206,7 +206,7 @@ void FCogEngineWindow_NetEmulation::DrawControls() ImGui::Separator(); //------------------------------------------------------------------------------------------- - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::DragInt("Incoming Lag Min", &Settings.PktIncomingLagMin, 5.0f, 0, INT_MAX, "%d ms")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -218,7 +218,7 @@ void FCogEngineWindow_NetEmulation::DrawControls() } //------------------------------------------------------------------------------------------- - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::DragInt("Incoming Lag Max", &Settings.PktIncomingLagMax, 5.0f, 0, INT_MAX, "%d ms")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -230,7 +230,7 @@ void FCogEngineWindow_NetEmulation::DrawControls() } //------------------------------------------------------------------------------------------- - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Incoming Packet Loss", &Settings.PktIncomingLoss, 0, 100, "%d%%")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetImGui.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetImGui.cpp index 6bb42d0..b1642e1 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetImGui.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetImGui.cpp @@ -2,9 +2,9 @@ #include "CogImguiContext.h" #include "CogImguiHelper.h" -#include "CogWindowConsoleCommandManager.h" -#include "CogWindowManager.h" -#include "CogWindowWidgets.h" +#include "CogConsoleCommandManager.h" +#include "CogSubsystem.h" +#include "CogWidgets.h" #include "Engine/EngineBaseTypes.h" #include "Engine/World.h" #include "imgui.h" @@ -26,7 +26,7 @@ void FCogEngineWindow_NetImgui::Initialize() Config = GetConfig(); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( TEXT("Cog.NetImgui.Connect"), TEXT("Connect to NetImgui server"), GetWorld(), @@ -35,7 +35,7 @@ void FCogEngineWindow_NetImgui::Initialize() ConnectTo(); })); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( TEXT("Cog.NetImgui.Listen"), TEXT("Listen for NetImgui server connection"), GetWorld(), @@ -44,7 +44,7 @@ void FCogEngineWindow_NetImgui::Initialize() ConnectFrom(); })); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( TEXT("Cog.NetImgui.Disconnect"), TEXT("Disconnect from NetImgui server"), GetWorld(), @@ -53,7 +53,7 @@ void FCogEngineWindow_NetImgui::Initialize() Disconnect(); })); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( TEXT("Cog.NetImgui.RunServer"), TEXT("Run NetImgui server application"), GetWorld(), @@ -62,7 +62,7 @@ void FCogEngineWindow_NetImgui::Initialize() RunServer(); })); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( TEXT("Cog.NetImgui.CloseServer"), TEXT("Close NetImgui server application"), GetWorld(), @@ -214,38 +214,38 @@ void FCogEngineWindow_NetImgui::RenderContent() { ImGui::SeparatorText("Connection"); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::InputText("Server Address", Config->ServerAddress); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::InputText("Server Address", Config->ServerAddress); ImGui::SetItemTooltip("NetImgui server application address."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::InputInt("Server Port", &Config->ServerPort); ImGui::SetItemTooltip("Port of the NetImgui Server application to connect to."); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::InputText("Client Name", Config->ClientName); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::InputText("Client Name", Config->ClientName); ImGui::SetItemTooltip("Client name displayed in the server's clients list."); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::InputInt("Client Port", &Config->ClientPort); ImGui::SetItemTooltip("Port this client should wait for connection from server application."); ImGui::SeparatorText("Auto-Connect"); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::ComboboxEnum("Dedicated Server", Config->AutoConnectOnDedicatedServer); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Dedicated Server", Config->AutoConnectOnDedicatedServer); ImGui::SetItemTooltip("Auto-connect mode to the NetImgui server when launching on dedicated server mode."); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::ComboboxEnum("Listen Server", Config->AutoConnectOnListenServer); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Listen Server", Config->AutoConnectOnListenServer); ImGui::SetItemTooltip("Auto-connect mode to the NetImgui server when launching on listen server mode."); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::ComboboxEnum("Client", Config->AutoConnectOnClient); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Client", Config->AutoConnectOnClient); ImGui::SetItemTooltip("Auto-connect mode to the NetImgui server when launching on client mode."); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::ComboboxEnum("Standalone", Config->AutoConnectOnStandalone); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::ComboboxEnum("Standalone", Config->AutoConnectOnStandalone); ImGui::SetItemTooltip("Auto-connect mode to the NetImgui server when launching on standalone mode."); ImGui::SeparatorText("Server App"); @@ -253,16 +253,16 @@ void FCogEngineWindow_NetImgui::RenderContent() ImGui::Checkbox("Auto Run Server", &Config->AutoRunServer); ImGui::SetItemTooltip("Automatically run the NetImgui server executable at startup."); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::InputText("Server Executable", Config->ServerExecutable); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::InputText("Server Executable", Config->ServerExecutable); ImGui::SetItemTooltip("Filename of the NetImgui server executable."); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::InputText("Server Directory", Config->ServerDirectory); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::InputText("Server Directory", Config->ServerDirectory); ImGui::SetItemTooltip("Directory of the NetImgui server executable."); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::InputText("Server Arguments", Config->ServerArguments); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::InputText("Server Arguments", Config->ServerArguments); ImGui::SetItemTooltip("Argument used when launching the NetImgui server executable."); } #endif diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Notifications.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Notifications.cpp index f6c26c8..2f3c317 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Notifications.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Notifications.cpp @@ -3,7 +3,7 @@ #include "CogCommon.h" #include "CogCommonLogCategory.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/Engine.h" #include "Misc/StringBuilder.h" @@ -97,7 +97,7 @@ void FCogEngineWindow_Notifications::RenderNotifications() const float DpiScale = GetDpiScale(); - ImVec2 WindowPos = FCogWindowWidgets::ComputeScreenCornerLocation(Config->Alignment, Config->Padding); + ImVec2 WindowPos = FCogWidgets::ComputeScreenCornerLocation(Config->Alignment, Config->Padding); const ImVec2 WindowPadding = ImGui::GetStyle().WindowPadding; const ImVec2 ItemSpacing = ImGui::GetStyle().ItemSpacing; const float MaxHeight = Config->MaxHeight * DpiScale + WindowPadding.y * 2; @@ -199,7 +199,7 @@ void FCogEngineWindow_Notifications::RenderContent() Notifications.Empty(); } - FCogWindowWidgets::ThinSeparatorText("Notification Test"); + FCogWidgets::ThinSeparatorText("Notification Test"); if (ImGui::Button("Notify Normal", ImVec2(-1, 0))) { @@ -222,7 +222,7 @@ void FCogEngineWindow_Notifications::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Notifications::RenderSettings() { - FCogWindowWidgets::ThinSeparatorText("Filtering"); + FCogWidgets::ThinSeparatorText("Filtering"); ImGui::Checkbox("Disable Notifications", &Config->DisableNotifications); @@ -232,36 +232,36 @@ void FCogEngineWindow_Notifications::RenderSettings() ImGui::Checkbox("Notify All Errors", &Config->NotifyAllErrors); - FCogWindowWidgets::ThinSeparatorText("Location & Size"); + FCogWidgets::ThinSeparatorText("Location & Size"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderFloat2("Alignment", &Config->Alignment.X, 0, 1.0f, "%.2f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderInt2("Padding", &Config->Padding.X, 0, 100); ImGui::Checkbox("Use Fixed Width", &Config->UseFixedWidth); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderInt("Text Wrapping", &Config->TextWrapping, 1, 500); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderInt("Max Height", &Config->MaxHeight, 0, 500); - FCogWindowWidgets::ThinSeparatorText("Display"); + FCogWidgets::ThinSeparatorText("Display"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderFloat("Duration", &Config->Duration, 1, 10, "%0.1f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderFloat("Fade Out", &Config->FadeOut, 0, 3, "%0.1f"); ImGui::Checkbox("Show Border", &Config->ShowBorder); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderInt("Rounding", &Config->Rounding, 0, 12); - FCogWindowWidgets::ThinSeparatorText("Colors"); + FCogWidgets::ThinSeparatorText("Colors"); constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf; diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp index 1f336f4..fcaba01 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp @@ -4,7 +4,7 @@ #include "CogCommonLogCategory.h" #include "CogDebugHelper.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/Engine.h" #include "HAL/PlatformApplicationMisc.h" #include "Misc/StringBuilder.h" @@ -239,7 +239,7 @@ void FCogEngineWindow_OutputLog::RenderContent() ImGui::EndCombo(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } @@ -258,17 +258,17 @@ void FCogEngineWindow_OutputLog::RenderContent() IsTableShown = true; if (Config->ShowFrame) { - ImGui::TableSetupColumn("Frame", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 4); + ImGui::TableSetupColumn("Frame", ImGuiTableColumnFlags_WidthFixed, FCogWidgets::GetFontWidth() * 4); } if (Config->ShowCategory) { - ImGui::TableSetupColumn("Category", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 10); + ImGui::TableSetupColumn("Category", ImGuiTableColumnFlags_WidthFixed, FCogWidgets::GetFontWidth() * 10); } if (Config->ShowVerbosity) { - ImGui::TableSetupColumn("Verbosity", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 10); + ImGui::TableSetupColumn("Verbosity", ImGuiTableColumnFlags_WidthFixed, FCogWidgets::GetFontWidth() * 10); } ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_WidthStretch); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp index 96af673..179df8b 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp @@ -3,8 +3,8 @@ #include "CogDebug.h" #include "CogDebugTracker.h" #include "CogImguiHelper.h" -#include "CogWindowManager.h" -#include "CogWindowWidgets.h" +#include "CogSubsystem.h" +#include "CogWidgets.h" #include "Engine/World.h" #include "imgui.h" #include "implot_internal.h" @@ -81,7 +81,7 @@ void FCogEngineWindow_Plots::RenderContent() | ImGuiTableFlags_NoPadOuterX)) { - ImGui::TableSetupColumn("PlotsList", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 20.0f); + ImGui::TableSetupColumn("PlotsList", ImGuiTableColumnFlags_WidthFixed, FCogWidgets::GetFontWidth() * 20.0f); ImGui::TableSetupColumn("Plots", ImGuiTableColumnFlags_WidthStretch, 0.0f); ImGui::TableNextRow(); @@ -128,19 +128,19 @@ void FCogEngineWindow_Plots::RenderMenu(FCogDebugTracker& InTracker) if (ImGui::BeginMenu("Options")) { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderInt("Num graphs", &Config->NumGraphs, 1, UCogEngineConfig_Plots::MaxNumGraphs); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderInt("Num Y axis", &Config->NumYAxis, 1, 3); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::SliderFloat("Time range", &Config->TimeRange, 1.0f, 100.0f, "%0.0f")) { bApplyTimeScale = true; } - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Num recorded values", &Config->NumRecordedValues, 100, 10000)) { Config->NumRecordedValues = (Config->NumRecordedValues / 100) * 100; @@ -151,10 +151,10 @@ void FCogEngineWindow_Plots::RenderMenu(FCogDebugTracker& InTracker) RefreshPlotSettings(); } - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderFloat("Auto-fit padding", &Config->AutoFitPadding, 0.0f, 0.2f, "%0.2f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::SliderFloat("Drag pause sensitivity", &Config->DragPauseSensitivity, 1.0f, 50.0f, "%0.0f"); ImGui::Checkbox("Record values when paused", &Config->RecordValuesWhenPaused); @@ -163,16 +163,16 @@ void FCogEngineWindow_Plots::RenderMenu(FCogDebugTracker& InTracker) RefreshPlotSettings(); } - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::Checkbox("Show time bar at game time", &Config->ShowTimeBarAtGameTime); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::Checkbox("Show time bar at cursor", &Config->ShowTimeBarAtCursor); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::Checkbox("Show value at cursor", &Config->ShowValueAtCursor); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::Checkbox("Dock entries", &Config->DockEntries); constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf; @@ -197,7 +197,7 @@ void FCogEngineWindow_Plots::RenderMenu(FCogDebugTracker& InTracker) InTracker.Clear(); } - FCogWindowWidgets::ToggleMenuButton(&InTracker.Pause, "Pause", ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); + FCogWidgets::ToggleMenuButton(&InTracker.Pause, "Pause", ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); ImGui::EndMenuBar(); } @@ -252,7 +252,7 @@ void FCogEngineWindow_Plots::RenderAllEntriesNames(FCogDebugTracker& InTracker, { int Index = 0; - if (FCogWindowWidgets::DarkCollapsingHeader("Events", ImGuiTreeNodeFlags_DefaultOpen)) + if (FCogWidgets::DarkCollapsingHeader("Events", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Indent(Indent); if (InTracker.Events.IsEmpty()) @@ -270,7 +270,7 @@ void FCogEngineWindow_Plots::RenderAllEntriesNames(FCogDebugTracker& InTracker, ImGui::Unindent(Indent); } - if (FCogWindowWidgets::DarkCollapsingHeader("Plots", ImGuiTreeNodeFlags_DefaultOpen)) + if (FCogWidgets::DarkCollapsingHeader("Plots", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Indent(Indent); if (InTracker.Values.IsEmpty()) @@ -579,7 +579,7 @@ void FCogEngineWindow_Plots::RenderValues(FCogDebugPlotTrack& Timeline, const ch float Value; if (Timeline.FindValue(ImPlot::GetPlotMousePos().x, Value)) { - if (FCogWindowWidgets::BeginTableTooltip()) + if (FCogWidgets::BeginTableTooltip()) { if (ImGui::BeginTable("Params", 2, ImGuiTableFlags_Borders)) { @@ -590,7 +590,7 @@ void FCogEngineWindow_Plots::RenderValues(FCogDebugPlotTrack& Timeline, const ch ImGui::Text("%0.2f", Value); ImGui::EndTable(); } - FCogWindowWidgets::EndTableTooltip(); + FCogWidgets::EndTableTooltip(); } } } @@ -691,7 +691,7 @@ void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugEvent* HoveredEve { if (ImPlot::IsPlotHovered() && HoveredEvent != nullptr) { - if (FCogWindowWidgets::BeginTableTooltip()) + if (FCogWidgets::BeginTableTooltip()) { if (ImGui::BeginTable("Params", 2, ImGuiTableFlags_Borders)) { @@ -758,7 +758,7 @@ void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugEvent* HoveredEve } ImGui::EndTable(); } - FCogWindowWidgets::EndTableTooltip(); + FCogWidgets::EndTableTooltip(); } } } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp index 18beba8..6360b73 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp @@ -1,7 +1,7 @@ #include "CogEngineWindow_Scalability.h" #include "imgui.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/Engine.h" #include "Scalability.h" @@ -22,7 +22,7 @@ void FCogEngineWindow_Scalability::RenderContent() Scalability::FQualityLevels Levels = Scalability::GetQualityLevels(); const FString CurrentQualityName = Scalability::GetQualityLevelText(Levels.GetMinQualityLevel(), SCALABILITY_NUM_LEVELS).ToString(); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("Scalability", TCHAR_TO_ANSI(*CurrentQualityName))) { for (int32 i = 0; i < SCALABILITY_NUM_LEVELS; ++i) @@ -45,37 +45,37 @@ void FCogEngineWindow_Scalability::RenderContent() bool Modified = false; - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderFloat("Resolution", &Levels.ResolutionQuality, 10.0f, 100.0f, "%0.f"); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("View Distance", &Levels.ViewDistanceQuality, 0, SCALABILITY_NUM_LEVELS - 1); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("Anti Aliasing", &Levels.AntiAliasingQuality, 0, SCALABILITY_NUM_LEVELS - 1); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("Shadow", &Levels.ShadowQuality, 0, SCALABILITY_NUM_LEVELS - 1); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("Global Illumination", &Levels.GlobalIlluminationQuality, 0, SCALABILITY_NUM_LEVELS - 1); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("Reflection", &Levels.ReflectionQuality, 0, SCALABILITY_NUM_LEVELS - 1); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("Post Process", &Levels.PostProcessQuality, 0, SCALABILITY_NUM_LEVELS - 1); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("Texture", &Levels.TextureQuality, 0, SCALABILITY_NUM_LEVELS - 1); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("Effects", &Levels.EffectsQuality, 0, SCALABILITY_NUM_LEVELS - 1); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("Foliage", &Levels.FoliageQuality, 0, SCALABILITY_NUM_LEVELS - 1); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); Modified |= ImGui::SliderInt("Shading", &Levels.ShadingQuality, 0, SCALABILITY_NUM_LEVELS - 1); if (Modified) diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp index 18584aa..a5d586e 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp @@ -6,9 +6,9 @@ #include "CogEngineWindow_ImGui.h" #include "CogImguiHelper.h" #include "CogImguiInputHelper.h" -#include "CogWindowConsoleCommandManager.h" -#include "CogWindowManager.h" -#include "CogWindowWidgets.h" +#include "CogConsoleCommandManager.h" +#include "CogSubsystem.h" +#include "CogWidgets.h" #include "CogWindow_Settings.h" #include "Components/PrimitiveComponent.h" #include "EngineUtils.h" @@ -32,7 +32,7 @@ void FCogEngineWindow_Selection::Initialize() Asset = GetAsset(); - FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand( + FCogConsoleCommandManager::RegisterWorldConsoleCommand( *ToggleSelectionModeCommand, TEXT("Toggle the actor selection mode"), GetWorld(), @@ -65,6 +65,9 @@ void FCogEngineWindow_Selection::PreSaveConfig() { Super::PreSaveConfig(); + if (Config == nullptr) + { return; } + Config->SelectionName = GetNameSafe(GetSelection()); } @@ -145,7 +148,7 @@ void FCogEngineWindow_Selection::RenderTick(float DeltaTime) { if (Actor != GetLocalPlayerPawn()) { - FCogWindowWidgets::ActorFrame(*Actor); + FCogWidgets::ActorFrame(*Actor); } } } @@ -189,7 +192,7 @@ void FCogEngineWindow_Selection::RenderContent() bool FCogEngineWindow_Selection::DrawSelectionCombo() { AActor* NewSelection = nullptr; - const bool result = FCogWindowWidgets::ActorsListWithFilters(NewSelection, *GetWorld(), GetSelectionFilters(), Config->SelectedClassIndex, &Filter, GetLocalPlayerPawn()); + const bool result = FCogWidgets::ActorsListWithFilters(NewSelection, *GetWorld(), GetSelectionFilters(), Config->SelectedClassIndex, &Filter, GetLocalPlayerPawn()); if (result) { SetGlobalSelection(NewSelection); @@ -216,7 +219,7 @@ bool FCogEngineWindow_Selection::TickSelectionMode() const ImVec2 ViewportSize = Viewport->Size; ImDrawList* DrawList = ImGui::GetBackgroundDrawList(Viewport); DrawList->AddRect(ViewportPos, ViewportPos + ViewportSize, IM_COL32(255, 0, 0, 128), 0.0f, 0, 20.0f); - FCogWindowWidgets::AddTextWithShadow(DrawList, ViewportPos + ImVec2(20, 20), IM_COL32(255, 255, 255, 255), "Picking Mode. \n[LMB] Pick \n[RMB] Cancel"); + FCogWidgets::AddTextWithShadow(DrawList, ViewportPos + ImVec2(20, 20), IM_COL32(255, 255, 255, 255), "Picking Mode. \n[LMB] Pick \n[RMB] Cancel"); TSubclassOf SelectedActorClass = GetSelectedActorClass(); @@ -259,7 +262,7 @@ bool FCogEngineWindow_Selection::TickSelectionMode() if (HoveredActor != nullptr) { - FCogWindowWidgets::ActorFrame(*HoveredActor); + FCogWidgets::ActorFrame(*HoveredActor); } if (GetOwner()->GetActivateSelectionMode()) @@ -290,7 +293,7 @@ void FCogEngineWindow_Selection::RenderMainMenuWidget() { ImGui::PushStyleVarX(ImGuiStyleVar_ItemSpacing, 0); ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0)); - if (FCogWindowWidgets::PickButton("##Pick", ImVec2(ImGui::GetFrameHeight(), ImGui::GetFrameHeight()))) + if (FCogWidgets::PickButton("##Pick", ImVec2(ImGui::GetFrameHeight(), ImGui::GetFrameHeight()))) { GetOwner()->SetActivateSelectionMode(true); HackWaitInputRelease(); @@ -305,7 +308,7 @@ void FCogEngineWindow_Selection::RenderMainMenuWidget() AActor* NewSelection = nullptr; //TODO: Could be replaced by a BeginMenu - if (FCogWindowWidgets::MenuActorsCombo( + if (FCogWidgets::MenuActorsCombo( "MenuActorSelection", NewSelection, *GetWorld(), @@ -334,12 +337,12 @@ void FCogEngineWindow_Selection::SetGlobalSelection(AActor* Value) const //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Selection::RenderPickButtonTooltip() { - if (FCogWindowWidgets::BeginItemTooltipWrappedText()) + if (FCogWidgets::BeginItemTooltipWrappedText()) { const FString Shortcut = FCogImguiInputHelper::KeyInfoToString(GetOwner()->GetSettings()->ToggleSelectionShortcut); ImGui::Text("Enter selection mode to select an actor on screen. Change which actor type is selectable by clicking the selection combobox\n" "%s", TCHAR_TO_ANSI(*Shortcut)); - FCogWindowWidgets::EndItemTooltipWrappedText(); + FCogWidgets::EndItemTooltipWrappedText(); } } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp index a9391c2..a81294f 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp @@ -1,7 +1,7 @@ #include "CogEngineWindow_Skeleton.h" #include "CogDebug.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Components/SkeletalMeshComponent.h" #include "DrawDebugHelpers.h" #include "Engine/SkeletalMesh.h" @@ -111,12 +111,12 @@ void FCogEngineWindow_Skeleton::RenderContent() ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } - ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, FCogWindowWidgets::GetFontWidth()); + ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, FCogWidgets::GetFontWidth()); HoveredBoneIndex = INDEX_NONE; RenderBoneEntry(0, false); @@ -207,7 +207,7 @@ void FCogEngineWindow_Skeleton::RenderBoneEntry(int32 BoneIndex, bool OpenAllChi // Checkbox //------------------------ ImGui::SameLine(); - FCogWindowWidgets::PushStyleCompact(); + FCogWidgets::PushStyleCompact(); if (ImGui::Checkbox("##Visible", &BoneInfo.ShowBone)) { if (IsControlDown) @@ -223,7 +223,7 @@ void FCogEngineWindow_Skeleton::RenderBoneEntry(int32 BoneIndex, bool OpenAllChi BoneInfo.ShowTrajectory = false; } } - FCogWindowWidgets::PopStyleCompact(); + FCogWidgets::PopStyleCompact(); const bool HasCustomVisibility = BoneInfo.ShowName || BoneInfo.ShowAxes || BoneInfo.ShowLocalVelocity || BoneInfo.ShowTrajectory; if (HasCustomVisibility) diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp index 17c4562..c409be8 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp @@ -3,7 +3,7 @@ #include "CogEngineDataAsset.h" #include "CogEngineReplicator.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Spawns::RenderHelp() @@ -58,14 +58,14 @@ void FCogEngineWindow_Spawns::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Spawns::RenderSpawnGroup(ACogEngineReplicator& Replicator, const FCogEngineSpawnGroup& SpawnGroup, int32 GroupIndex) { - if (FCogWindowWidgets::DarkCollapsingHeader(TCHAR_TO_ANSI(*SpawnGroup.Name), ImGuiTreeNodeFlags_DefaultOpen)) + if (FCogWidgets::DarkCollapsingHeader(TCHAR_TO_ANSI(*SpawnGroup.Name), ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::PushID(GroupIndex); const bool PushColor = (SpawnGroup.Color != FColor::Transparent); if (PushColor) { - FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(SpawnGroup.Color)); + FCogWidgets::PushBackColor(FCogImguiHelper::ToImVec4(SpawnGroup.Color)); } static int32 SelectedAssetIndex = -1; @@ -83,7 +83,7 @@ void FCogEngineWindow_Spawns::RenderSpawnGroup(ACogEngineReplicator& Replicator, if (PushColor) { - FCogWindowWidgets::PopBackColor(); + FCogWidgets::PopBackColor(); } ImGui::PopID(); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp index 9c384ca..246afdb 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp @@ -1,7 +1,7 @@ #include "CogEngineWindow_Stats.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/Engine.h" #include "Engine/NetConnection.h" #include "Engine/NetDriver.h" @@ -121,7 +121,7 @@ void FCogEngineWindow_Stats::RenderMainMenuWidgetFrameRate() { ImGui::PushID(i); const float Value = Config->FrameRates[i]; - const auto ValueText = StringCast(*FCogWindowWidgets::FormatSmallFloat(Value)); + const auto ValueText = StringCast(*FCogWidgets::FormatSmallFloat(Value)); if (ImGui::Selectable(ValueText.Get(), Value == MaxFps, ImGuiSelectableFlags_None, ImVec2(Width, 0))) { GEngine->SetMaxFPS(Value); @@ -174,7 +174,7 @@ void FCogEngineWindow_Stats::RenderMainMenuWidgetPing() { ImGui::PushID(i); const float Value = Config->Pings[i]; - const auto ValueText = StringCast(*FCogWindowWidgets::FormatSmallFloat(Value)); + const auto ValueText = StringCast(*FCogWidgets::FormatSmallFloat(Value)); if (ImGui::Selectable(ValueText.Get(), Value == Settings.PktIncomingLagMin, ImGuiSelectableFlags_None, ImVec2(Width, 0))) { Settings.PktIncomingLagMin = Value; @@ -232,7 +232,7 @@ void FCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss() { ImGui::PushID(i); const float Value = Config->PacketLosses[i]; - const auto ValueText = StringCast(*FCogWindowWidgets::FormatSmallFloat(Value)); + const auto ValueText = StringCast(*FCogWidgets::FormatSmallFloat(Value)); if (ImGui::Selectable(ValueText.Get(), Value == Settings.PktIncomingLagMin, ImGuiSelectableFlags_None, ImVec2(Width, 0))) { Settings.PktIncomingLoss = Value; @@ -318,7 +318,7 @@ void UCogEngineWindowConfig_Stats::RenderFrameRateConfig() { ImGui::InputInt("Good Frame Rate", &GoodFrameRate); ImGui::InputInt("Medium Frame Rate", &MediumFrameRate); - FCogWindowWidgets::IntArray("Max Frame Rate", FrameRates, 10, ImVec2(0, ImGui::GetFontSize() * 10)); + FCogWidgets::IntArray("Max Frame Rate", FrameRates, 10, ImVec2(0, ImGui::GetFontSize() * 10)); } } @@ -329,7 +329,7 @@ void UCogEngineWindowConfig_Stats::RenderPingConfig() { ImGui::InputInt("Good Ping", &GoodPing); ImGui::InputInt("Medium Ping", &MediumPing); - FCogWindowWidgets::IntArray("Ping Emulation", Pings, 10, ImVec2(0, ImGui::GetFontSize() * 10)); + FCogWidgets::IntArray("Ping Emulation", Pings, 10, ImVec2(0, ImGui::GetFontSize() * 10)); } } @@ -340,6 +340,6 @@ void UCogEngineWindowConfig_Stats::RenderPacketLossConfig() { ImGui::InputInt("Good Packet Loss", &GoodPacketLoss); ImGui::InputInt("Medium Packet Loss", &MediumPacketLoss); - FCogWindowWidgets::IntArray("Packet Loss Emulation", PacketLosses, 10, ImVec2(0, ImGui::GetFontSize() * 10)); + FCogWidgets::IntArray("Packet Loss Emulation", PacketLosses, 10, ImVec2(0, ImGui::GetFontSize() * 10)); } } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp index 125392f..8e785e7 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp @@ -2,7 +2,7 @@ #include "CogEngineReplicator.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/Engine.h" #include "Engine/World.h" @@ -52,7 +52,7 @@ void FCogEngineWindow_TimeScale::RenderContextMenu() FCogImguiHelper::ColorEdit4("Time Scale Modified Color", Config->TimeScaleModifiedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::SetItemTooltip("Color of the current time scale, in widget mode, when the time scale in not 1."); - FCogWindowWidgets::FloatArray("Time Scales", Config->TimeScales, 10, ImVec2(0, ImGui::GetFontSize() * 10)); + FCogWidgets::FloatArray("Time Scales", Config->TimeScales, 10, ImVec2(0, ImGui::GetFontSize() * 10)); ImGui::Separator(); FCogWindow::RenderContextMenu(); @@ -115,7 +115,7 @@ void FCogEngineWindow_TimeScale::RenderMainMenuWidget() void FCogEngineWindow_TimeScale::RenderTimeScaleChoices(ACogEngineReplicator* Replicator) { float Value = Replicator->GetTimeDilation(); - if (FCogWindowWidgets::MultiChoiceButtonsFloat(Config->TimeScales, Value, ImVec2(3.5f * FCogWindowWidgets::GetFontWidth(), 0), Config->Inline)) + if (FCogWidgets::MultiChoiceButtonsFloat(Config->TimeScales, Value, ImVec2(3.5f * FCogWidgets::GetFontWidth(), 0), Config->Inline)) { Replicator->SetTimeDilation(Value); } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Transform.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Transform.cpp index d611ba0..5e673e3 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Transform.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Transform.cpp @@ -2,7 +2,7 @@ #include "CogDebug.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "GameFramework/Actor.h" #include "imgui.h" #include "imgui_internal.h" @@ -39,13 +39,13 @@ void FCogEngineWindow_Transform::RenderContent() { if (ImGui::BeginMenu("Options")) { - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Drag Speed Location", &Config->LocationSpeed, 0.1f, 0.1f, 100.0f); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Drag Speed Rotation", &Config->RotationSpeed, 0.1f, 0.1f, 100.0f); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Drag Speed Scale", &Config->ScaleSpeed, 0.1f, 0.1f, 100.0f); ImGui::SeparatorText("Gizmo"); @@ -113,7 +113,7 @@ void FCogEngineWindow_Transform::RenderSnap(const char* CheckboxLabel, const cha ImGui::Checkbox(CheckboxLabel, SnapEnable); ImGui::SameLine(); - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWidgets::SetNextItemToShortWidth(); ImGui::DragFloat(InputLabel, Snap, 0.1f, 0.1f, 1000.0f, "%.1f"); } diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_BuildInfo.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_BuildInfo.h index 14a02ee..0969dd1 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_BuildInfo.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_BuildInfo.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "CogEngineWindow_BuildInfo.generated.h" class UCogEngineConfig_BuildInfo; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Notifications.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Notifications.h index 6674772..2e4c8c4 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Notifications.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Notifications.h @@ -3,7 +3,7 @@ #include "CoreMinimal.h" #include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "imgui.h" #include "Misc/OutputDevice.h" #include "CogEngineWindow_Notifications.generated.h" diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp index e2e7d27..79c1184 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp @@ -48,14 +48,14 @@ UPlayerInput* FCogImguiInputHelper::GetPlayerInput(const UWorld& World) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogImguiInputHelper::IsTopPriorityKey(const UWorld* InWorld, const FKey& InKey) +bool FCogImguiInputHelper::IsTopPriorityKey(const UPlayerInput& PlayerInput, const FKey& InKey) { FKeyEvent KeyEvent(InKey, FModifierKeysState(), 0, false, 0, 0); - return IsTopPriorityKeyEvent(InWorld, KeyEvent); + return IsTopPriorityKeyEvent(PlayerInput, KeyEvent); } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogImguiInputHelper::IsTopPriorityKeyEvent(const UWorld* InWorld, const FKeyEvent& InKeyEvent) +bool FCogImguiInputHelper::IsTopPriorityKeyEvent(const UPlayerInput& PlayerInput, const FKeyEvent& InKeyEvent) { //------------------------------------------------------------------------------------------------ // We want the user to be able to use Cog shortcuts when imgui has the input. @@ -92,7 +92,7 @@ bool FCogImguiInputHelper::IsTopPriorityKeyEvent(const UWorld* InWorld, const FK //------------------------------------------------------------------------------------------------ // We want the user to be able to use command bindings, even when imgui has the input. //------------------------------------------------------------------------------------------------ - if (IsKeyBoundToCommand(InWorld, InKeyEvent)) + if (IsKeyBoundToCommand(PlayerInput, InKeyEvent)) { return true; } return false; @@ -190,7 +190,9 @@ void FCogImguiInputHelper::KeyInfoToKeyBind(const FCogImGuiKeyInfo& KeyInfo, FKe //-------------------------------------------------------------------------------------------------------------------------- bool FCogImguiInputHelper::IsKeyBindMatchingKeyInfo(const FKeyBind& InKeyBind, const FCogImGuiKeyInfo& InKeyInfo) { - const bool Result = (InKeyInfo.Key == InKeyBind.Key) + const bool Result = + InKeyBind.bDisabled == false + && (InKeyInfo.Key == InKeyBind.Key) && IsCheckBoxStateMatchingKeyBindModifier(InKeyInfo.Shift, InKeyBind.Shift, InKeyBind.bIgnoreShift) && IsCheckBoxStateMatchingKeyBindModifier(InKeyInfo.Ctrl, InKeyBind.Control, InKeyBind.bIgnoreCtrl) && IsCheckBoxStateMatchingKeyBindModifier(InKeyInfo.Alt, InKeyBind.Alt, InKeyBind.bIgnoreAlt) @@ -219,20 +221,9 @@ bool FCogImguiInputHelper::WasKeyInfoJustPressed(const APlayerController& Player } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogImguiInputHelper::IsKeyBoundToCommand(const UWorld* World, const FKeyEvent& KeyEvent) +bool FCogImguiInputHelper::IsKeyBoundToCommand(const UPlayerInput& PlayerInput, const FKeyEvent& KeyEvent) { - if (World == nullptr) - { - return false; - } - - const UPlayerInput* PlayerInput = GetPlayerInput(*World); - if (PlayerInput == nullptr) - { - return false; - } - - for (const FKeyBind& KeyBind : PlayerInput->DebugExecBindings) + for (const FKeyBind& KeyBind : PlayerInput.DebugExecBindings) { if (IsKeyEventMatchingKeyBind(KeyEvent, KeyBind)) { @@ -413,16 +404,16 @@ bool FCogImguiInputHelper::IsKeyEventMatchingKeyBind(const FKeyEvent& KeyEvent, } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogImguiInputHelper::IsKeyInfoPressed(const UPlayerInput* PlayerInput, const FCogImGuiKeyInfo& InKeyInfo) +bool FCogImguiInputHelper::IsKeyInfoPressed(const UPlayerInput& PlayerInput, const FCogImGuiKeyInfo& InKeyInfo) { - const bool bKeyPressed = PlayerInput->WasJustPressed(InKeyInfo.Key); + const bool bKeyPressed = PlayerInput.WasJustPressed(InKeyInfo.Key); if (bKeyPressed == false) { return false; } - if (IsCheckBoxStateMatchingValue(InKeyInfo.Ctrl, PlayerInput->IsCtrlPressed()) - && IsCheckBoxStateMatchingValue(InKeyInfo.Shift, PlayerInput->IsShiftPressed()) - && IsCheckBoxStateMatchingValue(InKeyInfo.Alt, PlayerInput->IsAltPressed()) - && IsCheckBoxStateMatchingValue(InKeyInfo.Cmd, PlayerInput->IsCmdPressed())) + if (IsCheckBoxStateMatchingValue(InKeyInfo.Ctrl, PlayerInput.IsCtrlPressed()) + && IsCheckBoxStateMatchingValue(InKeyInfo.Shift, PlayerInput.IsShiftPressed()) + && IsCheckBoxStateMatchingValue(InKeyInfo.Alt, PlayerInput.IsAltPressed()) + && IsCheckBoxStateMatchingValue(InKeyInfo.Cmd, PlayerInput.IsCmdPressed())) { return true; } return false; @@ -461,29 +452,34 @@ bool FCogImguiInputHelper::IsMouseInsideMainViewport() } //-------------------------------------------------------------------------------------------------------------------------- -void FCogImguiInputHelper::SetShortcuts(const UWorld& World, const TArray& InShortcuts, bool InDisableCommandsConflictingWithShortcuts) +bool FCogImguiInputHelper::DisableCommandsConflictingWithShortcuts(UPlayerInput& PlayerInput) { - CogShortcuts = InShortcuts; - - if (InDisableCommandsConflictingWithShortcuts == false ) - { return; } - - UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(World); - if (PlayerInput == nullptr) - { return; } + bool HasDisabled = false; for (const FCogImGuiKeyInfo& Shortcut : CogShortcuts) { - for (FKeyBind& KeyBind : PlayerInput->DebugExecBindings) + for (FKeyBind& KeyBind : PlayerInput.DebugExecBindings) { if (IsKeyBindMatchingKeyInfo(KeyBind, Shortcut)) { KeyBind.bDisabled = true; + HasDisabled = false; } } } - PlayerInput->SaveConfig(); + if (HasDisabled) + { + PlayerInput.SaveConfig(); + } + + return false; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogImguiInputHelper::SetShortcuts(const TArray& InShortcuts) +{ + CogShortcuts = InShortcuts; } //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp index 37996df..1a0584c 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp @@ -153,9 +153,15 @@ FReply SCogImguiWidget::HandleKeyEvent(const FKeyEvent& KeyEvent, bool Down) con return FReply::Unhandled(); } - if (FCogImguiInputHelper::IsTopPriorityKeyEvent(Context->GetGameViewport()->GetWorld(), KeyEvent)) + if (const UWorld* World = Context->GetGameViewport()->GetWorld()) { - return FReply::Unhandled(); + if (const UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*World)) + { + if (FCogImguiInputHelper::IsTopPriorityKeyEvent(*PlayerInput, KeyEvent)) + { + return FReply::Unhandled(); + } + } } ImGuiIO& IO = ImGui::GetIO(); diff --git a/Plugins/Cog/Source/CogImgui/Public/CogImguiInputHelper.h b/Plugins/Cog/Source/CogImgui/Public/CogImguiInputHelper.h index f2b128f..5033d58 100644 --- a/Plugins/Cog/Source/CogImgui/Public/CogImguiInputHelper.h +++ b/Plugins/Cog/Source/CogImgui/Public/CogImguiInputHelper.h @@ -22,9 +22,9 @@ public: static UPlayerInput* GetPlayerInput(const UWorld& World); - static bool IsTopPriorityKey(const UWorld* InWorld, const FKey& InKey); + static bool IsTopPriorityKey(const UPlayerInput& PlayerInput, const FKey& InKey); - static bool IsTopPriorityKeyEvent(const UWorld* InWorld, const FKeyEvent& InKeyEvent); + static bool IsTopPriorityKeyEvent(const UPlayerInput& PlayerInput, const FKeyEvent& InKeyEvent); static bool WasKeyInfoJustPressed(const APlayerController& PlayerController, const FCogImGuiKeyInfo& KeyInfo); @@ -38,7 +38,7 @@ public: static bool IsKeyEventMatchingKeyBind(const FKeyEvent& KeyEvent, const FKeyBind& KeyBind); - static bool IsKeyInfoPressed(const UPlayerInput* PlayerInput, const FCogImGuiKeyInfo& InKeyInfo); + static bool IsKeyInfoPressed(const UPlayerInput& PlayerInput, const FCogImGuiKeyInfo& InKeyInfo); static ECheckBoxState MakeCheckBoxState(uint8 RequireValue, uint8 IgnoreValue); @@ -48,7 +48,7 @@ public: static bool IsConsoleEvent(const FKeyEvent& KeyEvent); - static bool IsKeyBoundToCommand(const UWorld* World, const FKeyEvent& KeyEvent); + static bool IsKeyBoundToCommand(const UPlayerInput& PlayerInput, const FKeyEvent& KeyEvent); static bool IsStopPlaySessionEvent(const FKeyEvent& KeyEvent); @@ -70,7 +70,9 @@ public: static bool IsKeyBoundToCommand(const UPlayerInput* InPlayerInput, const FKeyEvent& KeyEvent); - static void SetShortcuts(const UWorld& World, const TArray& InShortcuts, bool InDisableCommandsConflictingWithShortcuts); + static void SetShortcuts(const TArray& InShortcuts); + + static bool DisableCommandsConflictingWithShortcuts(UPlayerInput& PlayerInput); template* = nullptr> static ImWchar CastInputChar(T Char) diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowModule.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowModule.h deleted file mode 100644 index b194dc7..0000000 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowModule.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "Modules/ModuleManager.h" - -class COGWINDOW_API FCogWindowModule : public IModuleInterface -{ -public: - - static inline FCogWindowModule& Get() { return FModuleManager::LoadModuleChecked("CogWindow"); } - - virtual void StartupModule() override; - - virtual void ShutdownModule() override; - -}; diff --git a/Plugins/CogAI/Source/CogAI/CogAI.Build.cs b/Plugins/CogAI/Source/CogAI/CogAI.Build.cs index 5227c1f..2857b83 100644 --- a/Plugins/CogAI/Source/CogAI/CogAI.Build.cs +++ b/Plugins/CogAI/Source/CogAI/CogAI.Build.cs @@ -25,7 +25,7 @@ public class CogAI : ModuleRules "CogCommon", "CogImgui", "CogDebug", - "CogWindow", + "Cog", } ); diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp index 65cb6a0..abb1761 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp @@ -8,7 +8,7 @@ #include "CogAIModule.h" #include "CogDebugDraw.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "GameFramework/Pawn.h" #include "imgui_internal.h" #include "Navigation/PathFollowingComponent.h" @@ -140,7 +140,7 @@ void FCogAIWindow_BehaviorTree::RenderContent() ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } @@ -269,7 +269,7 @@ void FCogAIWindow_BehaviorTree::RenderNode(UBehaviorTreeComponent& BehaviorTreeC //------------------------ // Tooltip //------------------------ - if (FCogWindowWidgets::BeginItemTableTooltip()) + if (FCogWidgets::BeginItemTableTooltip()) { if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders)) { @@ -328,14 +328,14 @@ void FCogAIWindow_BehaviorTree::RenderNode(UBehaviorTreeComponent& BehaviorTreeC ImGui::EndTable(); } - FCogWindowWidgets::EndItemTableTooltip(); + FCogWidgets::EndItemTableTooltip(); } //------------------------ // Checkbox //------------------------ ImGui::SameLine(); - FCogWindowWidgets::PushStyleCompact(); + FCogWidgets::PushStyleCompact(); if (IsActive == false) { ImGui::BeginDisabled(); @@ -347,7 +347,7 @@ void FCogAIWindow_BehaviorTree::RenderNode(UBehaviorTreeComponent& BehaviorTreeC { ImGui::EndDisabled(); } - FCogWindowWidgets::PopStyleCompact(); + FCogWidgets::PopStyleCompact(); //------------------------ // Name diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp index 714ebf8..0725f54 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp @@ -1,7 +1,7 @@ #include "CogAIWindow_Blackboard.h" #include "AIController.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "BrainComponent.h" #include "GameFramework/Pawn.h" #include "BehaviorTree/BlackboardComponent.h" @@ -50,7 +50,7 @@ void FCogAIWindow_Blackboard::RenderContent() ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } diff --git a/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs b/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs index b81d069..e1d1db2 100644 --- a/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs +++ b/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs @@ -26,7 +26,7 @@ public class CogAbility : ModuleRules "CogCommon", "CogDebug", "CogEngine", - "CogWindow", + "Cog", "GameplayAbilities", "GameplayTags", "NetCore", diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp index 8a47bcd..c589de6 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp @@ -1,7 +1,7 @@ #include "CogAbilityHelper.h" #include "CogAbilityDataAsset.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "GameplayTagContainer.h" #include "imgui.h" @@ -20,7 +20,7 @@ void FCogAbilityHelper::RenderTagContainer(const FGameplayTagContainer& Containe Container.GetGameplayTagArray(GameplayTags); for (const FGameplayTag& Tag : GameplayTags) { - FCogWindowWidgets::SmallButton(StringCast(*Tag.ToString()).Get(), Color); + FCogWidgets::SmallButton(StringCast(*Tag.ToString()).Get(), Color); if (Inline) { ImGui::SameLine(); @@ -51,7 +51,7 @@ void FCogAbilityHelper::RenderTagContainer( } const ImVec4 Color = hasTag ? MatchColor : NormalColor; - FCogWindowWidgets::SmallButton(StringCast(*Tag.ToString()).Get(), Color); + FCogWidgets::SmallButton(StringCast(*Tag.ToString()).Get(), Color); if (Inline) { ImGui::SameLine(); diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp index 213f803..fd29a9d 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp @@ -4,7 +4,7 @@ #include "AbilitySystemGlobals.h" #include "CogAbilityDataAsset.h" #include "CogImguiHelper.h" -#include "CogWindowHelper.h" +#include "CogHelper.h" #include "Components/SceneComponent.h" #include "Engine/World.h" #include "EngineUtils.h" @@ -59,7 +59,7 @@ ACogAbilityReplicator::ACogAbilityReplicator(const FObjectInitializer& ObjectIni bReplicates = true; bOnlyRelevantToOwner = true; - AbilityAsset = FCogWindowHelper::GetFirstAssetByClass(); + AbilityAsset = FCogHelper::GetFirstAssetByClass(); #endif // !UE_BUILD_SHIPPING } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp index ddcfe69..f4121b8 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp @@ -6,7 +6,7 @@ #include "CogAbilityHelper.h" #include "CogAbilityReplicator.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "CogDebugRob.h" #include "imgui.h" @@ -178,7 +178,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenu(AActor* Selection) ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } @@ -207,13 +207,13 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenuColorSettings() //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Abilities::RenderAbilityActivation(FGameplayAbilitySpec& Spec) { - FCogWindowWidgets::PushStyleCompact(); + FCogWidgets::PushStyleCompact(); bool IsActive = Spec.IsActive(); if (ImGui::Checkbox("##Activation", &IsActive)) { AbilityHandleToActivate = Spec.Handle; } - FCogWindowWidgets::PopStyleCompact(); + FCogWidgets::PopStyleCompact(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -396,10 +396,10 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableRow(UAbilitySystemComponen //------------------------ // Popup //------------------------ - if (FCogWindowWidgets::BeginItemTableTooltip()) + if (FCogWidgets::BeginItemTableTooltip()) { RenderAbilityInfo(AbilitySystemComponent, Spec); - FCogWindowWidgets::EndItemTableTooltip(); + FCogWidgets::EndItemTableTooltip(); } //------------------------ @@ -470,7 +470,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityInputPressed(FGameplayAbilitySpec { if (Spec.InputPressed) { - FCogWindowWidgets::SmallButton("Pressed", FCogImguiHelper::ToImVec4(Config->ActiveAbilityColor)); + FCogWidgets::SmallButton("Pressed", FCogImguiHelper::ToImVec4(Config->ActiveAbilityColor)); } } @@ -505,7 +505,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityContextMenu(UAbilitySystemCompone AbilityHandleToRemove = Spec.Handle; } - FCogWindowWidgets::OpenObjectAssetButton(Spec.Ability, ButtonsSize); + FCogWidgets::OpenObjectAssetButton(Spec.Ability, ButtonsSize); ImGui::EndPopup(); } @@ -576,13 +576,13 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen ImGui::TableNextColumn(); ImGui::TextColored(TextColor, "Activation"); ImGui::TableNextColumn(); - FCogWindowWidgets::PushStyleCompact(); + FCogWidgets::PushStyleCompact(); bool IsActive = Spec.IsActive(); if (ImGui::Checkbox("##Activation", &IsActive)) { AbilityHandleToActivate = Spec.Handle; } - FCogWindowWidgets::PopStyleCompact(); + FCogWidgets::PopStyleCompact(); //------------------------ // Active Count diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp index 9d87281..2415c78 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp @@ -6,7 +6,7 @@ #include "CogAbilityDataAsset.h" #include "CogAbilityHelper.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "AttributeSet.h" #include "CogAbilityWindow_Abilities.h" #include "imgui_internal.h" @@ -93,8 +93,8 @@ void FCogAbilityWindow_Attributes::RenderContent() ImGui::Checkbox("Group by Category", &Config->GroupByCategory); ImGui::Checkbox("Show Only Modified", &Config->ShowOnlyModified); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::InputText("Attribute Set Prefixes", Config->AttributeSetPrefixes); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::InputText("Attribute Set Prefixes", Config->AttributeSetPrefixes); ImGui::SetItemTooltip("Prefixes to remove from the attribute set name. Separate multiple prefixes with the semicolon character ';'"); ImGui::Separator(); @@ -111,7 +111,7 @@ void FCogAbilityWindow_Attributes::RenderContent() ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } @@ -292,10 +292,10 @@ void FCogAbilityWindow_Attributes::RenderContent() //------------------------ // Popup //------------------------ - if (FCogWindowWidgets::BeginItemTableTooltip()) + if (FCogWidgets::BeginItemTableTooltip()) { RenderAttributeDetails(*AbilitySystemComponent, AttributeSetNameStr.Get(), Attribute, true); - FCogWindowWidgets::EndItemTableTooltip(); + FCogWidgets::EndItemTableTooltip(); } //------------------------ @@ -449,7 +449,7 @@ void FCogAbilityWindow_Attributes::RenderAttributeDetails(const UAbilitySystemCo char Buffer[128]; ImFormatString(Buffer, IM_ARRAYSIZE(Buffer), "Modifier %d", ModifierIndex); - if (FCogWindowWidgets::DarkCollapsingHeader(Buffer, ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen)) + if (FCogWidgets::DarkCollapsingHeader(Buffer, ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen)) { if (ImGui::BeginTable("Details", 2, TableFlags)) { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp index 6176bb4..9d573b6 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp @@ -7,7 +7,7 @@ #include "CogAbilityDataAsset.h" #include "CogAbilityHelper.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/World.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -77,7 +77,7 @@ void FCogAbilityWindow_Effects::RenderContent() ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } @@ -217,10 +217,10 @@ void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& Ability //------------------------ // Popup //------------------------ - if (FCogWindowWidgets::BeginItemTableTooltip()) + if (FCogWidgets::BeginItemTableTooltip()) { RenderEffectInfo(AbilitySystemComponent, ActiveEffect, Effect); - FCogWindowWidgets::EndItemTableTooltip(); + FCogWidgets::EndItemTableTooltip(); } //------------------------ @@ -250,7 +250,7 @@ void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& Ability ImGui::CloseCurrentPopup(); } - FCogWindowWidgets::OpenObjectAssetButton(EffectPtr, ButtonsSize); + FCogWidgets::OpenObjectAssetButton(EffectPtr, ButtonsSize); ImGui::EndPopup(); } @@ -458,7 +458,7 @@ void FCogAbilityWindow_Effects::RenderStacks(const FActiveGameplayEffect& Active ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255)); ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 100)); ImGui::SetNextItemWidth(-1); - ImGui::ProgressBar(CurrentStackCount / (float)Effect.StackLimitCount, ImVec2(FCogWindowWidgets::GetFontWidth() * 15, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), CurrentStackCount, Effect.StackLimitCount))); + ImGui::ProgressBar(CurrentStackCount / (float)Effect.StackLimitCount, ImVec2(FCogWidgets::GetFontWidth() * 15, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), CurrentStackCount, Effect.StackLimitCount))); ImGui::PopStyleColor(2); } } @@ -491,7 +491,7 @@ void FCogAbilityWindow_Effects::RenderInhibition(const FActiveGameplayEffect& Ac { if (ActiveEffect.bIsInhibited) { - FCogWindowWidgets::SmallButton("Yes", ImVec4(1, 0, 0, 1)); + FCogWidgets::SmallButton("Yes", ImVec4(1, 0, 0, 1)); } else { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp index 2753a99..264cd4c 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp @@ -5,7 +5,7 @@ #include "CogAbilityDataAsset.h" #include "CogAbilityHelper.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "imgui_internal.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -98,6 +98,6 @@ void FCogAbilityWindow_Pools::DrawPool(const UAbilitySystemComponent* AbilitySys ImGui::TableNextColumn(); ImGui::PushStyleColor(ImGuiCol_PlotHistogram, FCogImguiHelper::ToImVec4(Pool.Color)); ImGui::PushStyleColor(ImGuiCol_FrameBg, FCogImguiHelper::ToImVec4(Pool.BackColor)); - FCogWindowWidgets::ProgressBarCentered(Ratio, ImVec2(-1, 0), Buffer); + FCogWidgets::ProgressBarCentered(Ratio, ImVec2(-1, 0), Buffer); ImGui::PopStyleColor(2); } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp index 5cae09e..5c05b4b 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp @@ -3,7 +3,7 @@ #include "AbilitySystemComponent.h" #include "AbilitySystemGlobals.h" #include "CogAbilityHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Tags::Initialize() @@ -70,7 +70,7 @@ void FCogAbilityWindow_Tags::RenderMenu() ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } @@ -137,10 +137,10 @@ void FCogAbilityWindow_Tags::RenderTagContainer(const UAbilitySystemComponent& A //------------------------ // Tooltip //------------------------ - if (FCogWindowWidgets::BeginItemTableTooltip()) + if (FCogWidgets::BeginItemTableTooltip()) { RenderTag(AbilitySystemComponent, Tag); - FCogWindowWidgets::EndItemTableTooltip(); + FCogWidgets::EndItemTableTooltip(); } ImGui::PopID(); diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp index 40d331c..99c81a6 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp @@ -4,7 +4,7 @@ #include "AbilitySystemComponent.h" #include "CogAbilityHelper.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "imgui.h" class UCogAbilityConfig_Tasks; @@ -95,7 +95,7 @@ void FCogAbilityWindow_Tasks::RenderTaskMenu(AActor* Selection) ImGui::EndMenu(); } - FCogWindowWidgets::SearchBar("##Filter", Filter); + FCogWidgets::SearchBar("##Filter", Filter); ImGui::EndMenuBar(); } @@ -229,10 +229,10 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS //------------------------ // Popup //------------------------ - if (FCogWindowWidgets::BeginItemTableTooltip()) + if (FCogWidgets::BeginItemTableTooltip()) { RenderTaskInfo(Task); - FCogWindowWidgets::EndItemTableTooltip(); + FCogWidgets::EndItemTableTooltip(); } //------------------------ @@ -350,7 +350,7 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task) ImGui::TableNextColumn(); ImGui::TextColored(TextColor, "Debug"); ImGui::TableNextColumn(); - ImGui::PushTextWrapPos(FCogWindowWidgets::GetFontWidth() * 80); + ImGui::PushTextWrapPos(FCogWidgets::GetFontWidth() * 80); ImGui::Text("%s", StringCast(*Task->GetDebugString()).Get()); ImGui::PopTextWrapPos(); @@ -383,23 +383,23 @@ void FCogAbilityWindow_Tasks::RenderTaskState(const UGameplayTask* Task) switch (Task->GetState()) { case EGameplayTaskState::Uninitialized: - FCogWindowWidgets::SmallButton("Uninitialized", FCogImguiHelper::ToImVec4(Config->UninitializedColor)); + FCogWidgets::SmallButton("Uninitialized", FCogImguiHelper::ToImVec4(Config->UninitializedColor)); break; case EGameplayTaskState::AwaitingActivation: - FCogWindowWidgets::SmallButton("Awaiting Activation", FCogImguiHelper::ToImVec4(Config->AwaitingActivationColor)); + FCogWidgets::SmallButton("Awaiting Activation", FCogImguiHelper::ToImVec4(Config->AwaitingActivationColor)); break; case EGameplayTaskState::Active: - FCogWindowWidgets::SmallButton("Active", FCogImguiHelper::ToImVec4(Config->ActiveColor)); + FCogWidgets::SmallButton("Active", FCogImguiHelper::ToImVec4(Config->ActiveColor)); break; case EGameplayTaskState::Paused: - FCogWindowWidgets::SmallButton("Paused", FCogImguiHelper::ToImVec4(Config->PausedColor)); + FCogWidgets::SmallButton("Paused", FCogImguiHelper::ToImVec4(Config->PausedColor)); break; case EGameplayTaskState::Finished: - FCogWindowWidgets::SmallButton("Finished", FCogImguiHelper::ToImVec4(Config->FinishedColor)); + FCogWidgets::SmallButton("Finished", FCogImguiHelper::ToImVec4(Config->FinishedColor)); break; } } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp index 7477ce9..e750912 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp @@ -4,7 +4,7 @@ #include "CogAbilityHelper.h" #include "CogAbilityReplicator.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Tweaks::Initialize() @@ -142,11 +142,11 @@ void FCogAbilityWindow_Tweaks::DrawTweak(ACogAbilityReplicator* Replicator, int3 const FCogAbilityTweakCategory& Category = Asset->TweaksCategories[TweakCategoryIndex]; - FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Category.Color)); + FCogWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Category.Color)); ImGui::PushItemWidth(-1); ImGui::SliderFloat("##Value", Value, Asset->TweakMinValue, Asset->TweakMaxValue, "%+0.0f%%", 1.0f); ImGui::PopItemWidth(); - FCogWindowWidgets::PopBackColor(); + FCogWidgets::PopBackColor(); bool bUpdateValue = ImGui::IsItemDeactivatedAfterEdit(); diff --git a/Plugins/CogAll/Source/CogAll/CogAll.Build.cs b/Plugins/CogAll/Source/CogAll/CogAll.Build.cs index bdadfe4..5543517 100644 --- a/Plugins/CogAll/Source/CogAll/CogAll.Build.cs +++ b/Plugins/CogAll/Source/CogAll/CogAll.Build.cs @@ -16,7 +16,7 @@ public class CogAll : ModuleRules "CogAI", "CogEngine", "CogInput", - "CogWindow", + "Cog", "Engine", } ); diff --git a/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp b/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp index a569e3f..4269960 100644 --- a/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp +++ b/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp @@ -36,13 +36,13 @@ #include "CogEngineWindow_Transform.h" #include "CogInputWindow_Actions.h" #include "CogInputWindow_Gamepad.h" -#include "CogWindowManager.h" +#include "CogSubsystem.h" #include "Engine/Engine.h" #include "GameFramework/GameUserSettings.h" //-------------------------------------------------------------------------------------------------------------------------- -void Cog::AddAllWindows(UCogWindowManager& CogWindowManager) +void Cog::AddAllWindows(UCogSubsystem& CogWindowManager) { //--------------------------------------- // Engine diff --git a/Plugins/CogAll/Source/CogAll/Public/CogAll.h b/Plugins/CogAll/Source/CogAll/Public/CogAll.h index 8cc3c82..44c2f8f 100644 --- a/Plugins/CogAll/Source/CogAll/Public/CogAll.h +++ b/Plugins/CogAll/Source/CogAll/Public/CogAll.h @@ -2,9 +2,9 @@ #include "CoreMinimal.h" -class UCogWindowManager; +class UCogSubsystem; namespace Cog { - void COGALL_API AddAllWindows(UCogWindowManager& CogWindowManager); + void COGALL_API AddAllWindows(UCogSubsystem& CogWindowManager); } diff --git a/Plugins/CogCommonUI/Source/CogCommonUI/CogCommonUI.Build.cs b/Plugins/CogCommonUI/Source/CogCommonUI/CogCommonUI.Build.cs index 9190b4a..3868fc0 100644 --- a/Plugins/CogCommonUI/Source/CogCommonUI/CogCommonUI.Build.cs +++ b/Plugins/CogCommonUI/Source/CogCommonUI/CogCommonUI.Build.cs @@ -25,7 +25,7 @@ public class CogCommonUI : ModuleRules "CogCommon", "CogImgui", "CogDebug", - "CogWindow", + "Cog", "CommonUI", "InputCore", } diff --git a/Plugins/CogCommonUI/Source/CogCommonUI/Private/CogCommonUI_ActionRouter.cpp b/Plugins/CogCommonUI/Source/CogCommonUI/Private/CogCommonUI_ActionRouter.cpp index dfd76e1..a2e0e84 100644 --- a/Plugins/CogCommonUI/Source/CogCommonUI/Private/CogCommonUI_ActionRouter.cpp +++ b/Plugins/CogCommonUI/Source/CogCommonUI/Private/CogCommonUI_ActionRouter.cpp @@ -4,11 +4,15 @@ ERouteUIInputResult UCogCommonUI_ActionRouter::ProcessInput(FKey Key, EInputEvent InputEvent) const { - UWorld* World = GetWorld(); - - if (FCogImguiInputHelper::IsTopPriorityKey(World, Key)) + if (const UWorld* World = GetWorld()) { - return ERouteUIInputResult::Unhandled; + if (const UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*World)) + { + if (FCogImguiInputHelper::IsTopPriorityKey(*PlayerInput, Key)) + { + return ERouteUIInputResult::Unhandled; + } + } } return UCommonUIActionRouterBase::ProcessInput(Key, InputEvent); diff --git a/Plugins/CogInput/Source/CogInput/CogInput.Build.cs b/Plugins/CogInput/Source/CogInput/CogInput.Build.cs index 4fa3374..6f19a42 100644 --- a/Plugins/CogInput/Source/CogInput/CogInput.Build.cs +++ b/Plugins/CogInput/Source/CogInput/CogInput.Build.cs @@ -25,7 +25,7 @@ public class CogInput : ModuleRules "CogCommon", "CogImgui", "CogDebug", - "CogWindow", + "Cog", "EnhancedInput", "InputCore", } diff --git a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp index 41b6111..25fa387 100644 --- a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp +++ b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp @@ -1,6 +1,6 @@ #include "CogInputWindow_Actions.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/LocalPlayer.h" #include "Engine/World.h" #include "EnhancedInputSubsystems.h" @@ -196,16 +196,16 @@ void FCogInputWindow_Actions::RenderContent() ImGui::TableNextColumn(); ImGui::BeginDisabled(); bool Value = ActionValue.Get(); - FCogWindowWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1)); + FCogWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1)); ImGui::Checkbox("##Current", &Value); - FCogWindowWidgets::PopBackColor(); + FCogWidgets::PopBackColor(); ImGui::EndDisabled(); ImGui::TableNextColumn(); ECheckBoxState State = ActionInfo.bRepeat ? ECheckBoxState::Undetermined : ActionInfo.bPressed ? ECheckBoxState::Checked : ECheckBoxState::Unchecked; - if (FCogWindowWidgets::CheckBoxState("##Inject", State, false)) + if (FCogWidgets::CheckBoxState("##Inject", State, false)) { if (IsControlDown) { @@ -320,13 +320,13 @@ void FCogInputWindow_Actions::DrawAxis(const char* Format, const char* ActionNam ImGui::TableNextColumn(); ImGui::SetNextItemWidth(-1); ImGui::BeginDisabled(); - FCogWindowWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1)); + FCogWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1)); ImGui::SliderFloat("##Value", &CurrentValue, -1.0f, 1.0f, "%0.2f"); - FCogWindowWidgets::PopBackColor(); + FCogWidgets::PopBackColor(); ImGui::EndDisabled(); ImGui::TableNextColumn(); ImGui::SetNextItemWidth(-1); - FCogWindowWidgets::SliderWithReset("##Inject", InjectValue, -1.0f, 1.0f, 0.0f, "%0.2f"); + FCogWidgets::SliderWithReset("##Inject", InjectValue, -1.0f, 1.0f, 0.0f, "%0.2f"); ImGui::PopID(); } diff --git a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp index 9e53f1e..5ed3416 100644 --- a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp +++ b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp @@ -1,7 +1,7 @@ #include "CogInputWindow_Gamepad.h" #include "CogImguiHelper.h" -#include "CogWindowWidgets.h" +#include "CogWidgets.h" #include "Engine/LocalPlayer.h" #include "Engine/World.h" #include "EnhancedInputSubsystems.h" @@ -13,20 +13,60 @@ void FCogInputWindow_Gamepad::Initialize() { Super::Initialize(); + bUseCustomContextMenu = true; + Config = GetConfig(); + + Actions.FindOrAdd(EKeys::Gamepad_Left2D); + Actions.FindOrAdd(EKeys::Gamepad_LeftX); + Actions.FindOrAdd(EKeys::Gamepad_LeftY); + Actions.FindOrAdd(EKeys::Gamepad_Right2D); + Actions.FindOrAdd(EKeys::Gamepad_RightX); + Actions.FindOrAdd(EKeys::Gamepad_RightY); + Actions.FindOrAdd(EKeys::Gamepad_LeftTriggerAxis); + Actions.FindOrAdd(EKeys::Gamepad_RightTriggerAxis); + Actions.FindOrAdd(EKeys::Gamepad_LeftThumbstick); + Actions.FindOrAdd(EKeys::Gamepad_RightThumbstick); + Actions.FindOrAdd(EKeys::Gamepad_Special_Left); + Actions.FindOrAdd(EKeys::Gamepad_Special_Left_X); + Actions.FindOrAdd(EKeys::Gamepad_Special_Left_Y); + Actions.FindOrAdd(EKeys::Gamepad_Special_Right); + Actions.FindOrAdd(EKeys::Gamepad_FaceButton_Bottom); + Actions.FindOrAdd(EKeys::Gamepad_FaceButton_Right); + Actions.FindOrAdd(EKeys::Gamepad_FaceButton_Left); + Actions.FindOrAdd(EKeys::Gamepad_FaceButton_Top); + Actions.FindOrAdd(EKeys::Gamepad_LeftShoulder); + Actions.FindOrAdd(EKeys::Gamepad_RightShoulder); + Actions.FindOrAdd(EKeys::Gamepad_LeftTrigger); + Actions.FindOrAdd(EKeys::Gamepad_RightTrigger); + Actions.FindOrAdd(EKeys::Gamepad_DPad_Up); + Actions.FindOrAdd(EKeys::Gamepad_DPad_Down); + Actions.FindOrAdd(EKeys::Gamepad_DPad_Right); + Actions.FindOrAdd(EKeys::Gamepad_DPad_Left); } //-------------------------------------------------------------------------------------------------------------------------- void FCogInputWindow_Gamepad::PreBegin(ImGuiWindowFlags& WindowFlags) { + Super::PreBegin(WindowFlags); + if (Config->bShowAsOverlay) { WindowFlags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse - | ImGuiWindowFlags_NoBackground - | ImGuiWindowFlags_NoResize; + | ImGuiWindowFlags_NoBackground; + //| ImGuiWindowFlags_NoResize; } + + ImGui::PushStyleColor(ImGuiCol_ResizeGrip, IM_COL32_BLACK_TRANS); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogInputWindow_Gamepad::PostBegin() +{ + Super::PostBegin(); + ImGui::PopStyleColor(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -39,16 +79,16 @@ void FCogInputWindow_Gamepad::RenderButtonContextMenu(const FKey& Key, FCogInput ImGui::Checkbox("Pressed", &ActionInfoButton->bPressed); ImGui::Checkbox("##Repeat", &ActionInfoButton->bRepeat); ImGui::SameLine(); - ImGui::SetNextItemWidth(FCogWindowWidgets::GetShortWidth() - ImGui::GetCursorPosX() + ImGui::GetStyle().ItemSpacing.x); - FCogWindowWidgets::SliderWithReset("Repeat", &Config->RepeatPeriod, 0.0f, 10.0f, 0.5f, "%0.1fs"); + ImGui::SetNextItemWidth(FCogWidgets::GetShortWidth() - ImGui::GetCursorPosX() + ImGui::GetStyle().ItemSpacing.x); + FCogWidgets::SliderWithReset("Repeat", &Config->RepeatPeriod, 0.0f, 10.0f, 0.5f, "%0.1fs"); } if (ActionInfoButton != nullptr && ActionInfoButton->Action != nullptr && ActionInfoButton->Action->ValueType == EInputActionValueType::Axis1D) { ImGui::Separator(); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::SliderWithReset("X", &ActionInfoButton->X, -1.0f, 1.0f, 0.0f, "%0.2f"); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::SliderWithReset("X", &ActionInfoButton->X, -1.0f, 1.0f, 0.0f, "%0.2f"); } } @@ -59,13 +99,13 @@ void FCogInputWindow_Gamepad::RenderStickContextMenu(const FKey& Key, FCogInputA { ImGui::Separator(); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::SliderWithReset("X", &ActionInfo2D->X, -1.0f, 1.0f, 0.0f, "%0.2f"); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::SliderWithReset("Y", &ActionInfo2D->Y, -1.0f, 1.0f, 0.0f, "%0.2f"); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::SliderWithReset("X", &ActionInfo2D->X, -1.0f, 1.0f, 0.0f, "%0.2f"); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::SliderWithReset("Y", &ActionInfo2D->Y, -1.0f, 1.0f, 0.0f, "%0.2f"); ImGui::Checkbox("Invert Stick Y", &InvertY); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::SliderWithReset("Sensitivity", &Sensitivity, 0.0f, 10.0f, 5.0f, "%0.1f"); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::SliderWithReset("Sensitivity", &Sensitivity, 0.0f, 10.0f, 5.0f, "%0.1f"); } } @@ -73,9 +113,7 @@ void FCogInputWindow_Gamepad::RenderStickContextMenu(const FKey& Key, FCogInputA void FCogInputWindow_Gamepad::OnButtonClicked(FCogInputActionInfo* ActionInfo) { if (ActionInfo == nullptr) - { - return; - } + { return; } if (ActionInfo->bRepeat) { @@ -97,8 +135,6 @@ void FCogInputWindow_Gamepad::RenderButton(const FKey& Key, const ImVec2& Relati { ImGui::PushID((void*)(&Key)); - const float Value = Input->GetKeyValue(Key); - const ImVec2& Size = RelativeSize * CanvasSize.x; const ImVec2 Position = (CanvasMin + CanvasSize * RelativePosition) - Alignment * Size; @@ -248,6 +284,29 @@ void FCogInputWindow_Gamepad::RenderStick(const FKey& Key2D, const FKey& KeyBool ImGui::PopID(); } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogInputWindow_Gamepad::TryRefreshActions() +{ + const CogInputMappingContextMap* AppliedMappingContexts = &PRIVATE_ACCESS_PTR(Input, UEnhancedPlayerInput_AppliedInputContexts); + + if (AppliedMappingContexts == nullptr) + { return; } + + if (AppliedMappingContexts->Num() == 0) + { return; } + + for (auto& kv : *AppliedMappingContexts) + { + for (const FEnhancedActionKeyMapping& Mapping : kv.Key->GetMappings()) + { + if (Mapping.Action != nullptr) + { + FCogInputActionInfo& ActionInfo = Actions.FindOrAdd(Mapping.Key); + ActionInfo.Action = Mapping.Action; + } + } + } +} //-------------------------------------------------------------------------------------------------------------------------- void FCogInputWindow_Gamepad::RenderContent() @@ -275,50 +334,7 @@ void FCogInputWindow_Gamepad::RenderContent() return; } - if (Actions.Num() == 0) - { - Actions.FindOrAdd(EKeys:: Gamepad_Left2D); - Actions.FindOrAdd(EKeys:: Gamepad_LeftX); - Actions.FindOrAdd(EKeys:: Gamepad_LeftY); - Actions.FindOrAdd(EKeys:: Gamepad_Right2D); - Actions.FindOrAdd(EKeys:: Gamepad_RightX); - Actions.FindOrAdd(EKeys:: Gamepad_RightY); - Actions.FindOrAdd(EKeys:: Gamepad_LeftTriggerAxis); - Actions.FindOrAdd(EKeys:: Gamepad_RightTriggerAxis); - Actions.FindOrAdd(EKeys:: Gamepad_LeftThumbstick); - Actions.FindOrAdd(EKeys:: Gamepad_RightThumbstick); - Actions.FindOrAdd(EKeys:: Gamepad_Special_Left); - Actions.FindOrAdd(EKeys:: Gamepad_Special_Left_X); - Actions.FindOrAdd(EKeys:: Gamepad_Special_Left_Y); - Actions.FindOrAdd(EKeys:: Gamepad_Special_Right); - Actions.FindOrAdd(EKeys:: Gamepad_FaceButton_Bottom); - Actions.FindOrAdd(EKeys:: Gamepad_FaceButton_Right); - Actions.FindOrAdd(EKeys:: Gamepad_FaceButton_Left); - Actions.FindOrAdd(EKeys:: Gamepad_FaceButton_Top); - Actions.FindOrAdd(EKeys:: Gamepad_LeftShoulder); - Actions.FindOrAdd(EKeys:: Gamepad_RightShoulder); - Actions.FindOrAdd(EKeys:: Gamepad_LeftTrigger); - Actions.FindOrAdd(EKeys:: Gamepad_RightTrigger); - Actions.FindOrAdd(EKeys:: Gamepad_DPad_Up); - Actions.FindOrAdd(EKeys:: Gamepad_DPad_Down); - Actions.FindOrAdd(EKeys:: Gamepad_DPad_Right); - Actions.FindOrAdd(EKeys:: Gamepad_DPad_Left); - - if (const CogInputMappingContextMap* AppliedMappingContexts = &PRIVATE_ACCESS_PTR(Input, UEnhancedPlayerInput_AppliedInputContexts)) - { - for (auto& kv : *AppliedMappingContexts) - { - for (const FEnhancedActionKeyMapping& Mapping : kv.Key->GetMappings()) - { - if (Mapping.Action != nullptr) - { - FCogInputActionInfo& ActionInfo = Actions.FindOrAdd(Mapping.Key); - ActionInfo.Action = Mapping.Action; - } - } - } - } - } + TryRefreshActions(); constexpr float AspectRatio = 0.55f; constexpr float StickAmplitude = 0.04f; @@ -431,21 +447,15 @@ void FCogInputWindow_Gamepad::RenderTick(float DeltaSeconds) Super::RenderTick(DeltaSeconds); if (GetWorld() == nullptr) - { - return; - } + { return; } const ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); if (LocalPlayer == nullptr) - { - return; - } + { return; } UEnhancedInputLocalPlayerSubsystem* EnhancedInput = ULocalPlayer::GetSubsystem(LocalPlayer); if (EnhancedInput == nullptr) - { - return; - } + { return; } bool IsTimeToRepeat = false; const float WorldTime = GetWorld()->GetTimeSeconds(); @@ -472,7 +482,12 @@ void FCogInputWindow_Gamepad::RenderMainContextMenu() SetIsVisible(false); } - if (ImGui::MenuItem("Reset")) + if (ImGui::MenuItem("Reset Actions")) + { + Actions.Empty(); + } + + if (ImGui::MenuItem("Reset Settings")) { ResetConfig(); } @@ -487,8 +502,8 @@ void FCogInputWindow_Gamepad::RenderMainContextMenu() ImGui::ColorEdit4("Pressed Color", (float*)&Config->PressedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::ColorEdit4("Hovered Color", (float*)&Config->HoveredColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::ColorEdit4("Inject Color", (float*)&Config->InjectColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); - FCogWindowWidgets::SetNextItemToShortWidth(); - FCogWindowWidgets::SliderWithReset("Border", &Config->Border, 0.0f, 0.1f, 0.02f, "%0.3f"); + FCogWidgets::SetNextItemToShortWidth(); + FCogWidgets::SliderWithReset("Border", &Config->Border, 0.0f, 0.1f, 0.02f, "%0.3f"); ImGui::EndMenu(); } } \ No newline at end of file diff --git a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h index 3100885..ae02f33 100644 --- a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h +++ b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h @@ -27,6 +27,8 @@ protected: virtual void PreBegin(ImGuiWindowFlags& WindowFlags) override; + virtual void PostBegin() override; + virtual void RenderContent() override; virtual void RenderTick(float DeltaSeconds) override; @@ -34,7 +36,7 @@ protected: virtual void RenderButton(const FKey& Key, const ImVec2& Position, const ImVec2& Size, const ImVec2& Alignment, float Rounding, ImDrawFlags Flags = 0); virtual void RenderStick(const FKey& Key2D, const FKey& KeyBool, bool& InvertY, float& Sensitivity, float Amplitude, const ImVec2& Position, float Radius); - + virtual void OnButtonClicked(FCogInputActionInfo* ActionInfo); virtual void RenderMainContextMenu(); @@ -43,6 +45,8 @@ protected: virtual void RenderStickContextMenu(const FKey& Key, FCogInputActionInfo* ActionInfo2D, bool& InvertY, float& Sensitivity); + virtual void TryRefreshActions(); + TObjectPtr Config; TMap Actions; diff --git a/Source/CogSample/CogSample.Build.cs b/Source/CogSample/CogSample.Build.cs index 9118ff5..201c920 100644 --- a/Source/CogSample/CogSample.Build.cs +++ b/Source/CogSample/CogSample.Build.cs @@ -33,7 +33,7 @@ public class CogSample : ModuleRules "CogEngine", "CogImgui", "CogInput", - "CogWindow", + "Cog", }); } } diff --git a/Source/CogSample/CogSampleGameInstance.cpp b/Source/CogSample/CogSampleGameInstance.cpp index e9d4a79..6b3fbbb 100644 --- a/Source/CogSample/CogSampleGameInstance.cpp +++ b/Source/CogSample/CogSampleGameInstance.cpp @@ -5,7 +5,7 @@ #if ENABLE_COG #include "CogAll.h" #include "CogSampleWindow_Team.h" -#include "CogWindowManager.h" +#include "CogSubsystem.h" #endif //-------------------------------------------------------------------------------------------------------------------------- @@ -14,10 +14,12 @@ void UCogSampleGameInstance::Init() Super::Init(); #if ENABLE_COG - if (UCogWindowManager* CogSubSystem = GetSubsystem()) + if (UCogSubsystem* CogSubSystem = GetSubsystem()) { Cog::AddAllWindows(*CogSubSystem); CogSubSystem->AddWindow("Gameplay.Team"); + + CogSubSystem->Activate(); } #endif } diff --git a/Source/CogSample/CogSampleGameInstance.h b/Source/CogSample/CogSampleGameInstance.h index 869b3da..60a738c 100644 --- a/Source/CogSample/CogSampleGameInstance.h +++ b/Source/CogSample/CogSampleGameInstance.h @@ -3,7 +3,7 @@ #include "CoreMinimal.h" #include "CogSampleGameInstance.generated.h" -class UCogWindowManager; +class UCogSubsystem; class UCogSampleAbilitySystemComponent; UCLASS() diff --git a/Source/CogSample/CogSampleGameState.cpp b/Source/CogSample/CogSampleGameState.cpp index 74365e0..73bccaf 100644 --- a/Source/CogSample/CogSampleGameState.cpp +++ b/Source/CogSample/CogSampleGameState.cpp @@ -9,7 +9,7 @@ #if ENABLE_COG #include "CogAll.h" #include "CogSampleWindow_Team.h" -#include "CogWindowManager.h" +#include "CogSubsystem.h" #endif //ENABLE_COG //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Source/CogSample/CogSampleGameState.h b/Source/CogSample/CogSampleGameState.h index 26a1fce..dfd0a7e 100644 --- a/Source/CogSample/CogSampleGameState.h +++ b/Source/CogSample/CogSampleGameState.h @@ -5,7 +5,7 @@ #include "GameFramework/GameStateBase.h" #include "CogSampleGameState.generated.h" -class UCogWindowManager; +class UCogSubsystem; class UCogSampleAbilitySystemComponent; UCLASS() @@ -42,7 +42,7 @@ protected: #if ENABLE_COG - TObjectPtr CogWindowManager = nullptr; + TObjectPtr CogWindowManager = nullptr; float _ClientFramerateSmooth = 0.0f; diff --git a/Source/CogSample/CogSampleWindow_Team.cpp b/Source/CogSample/CogSampleWindow_Team.cpp index afc8a07..9dc01d8 100644 --- a/Source/CogSample/CogSampleWindow_Team.cpp +++ b/Source/CogSample/CogSampleWindow_Team.cpp @@ -3,8 +3,8 @@ #if ENABLE_COG #include "CogImguiHelper.h" -#include "CogWindowHelper.h" -#include "CogWindowWidgets.h" +#include "CogHelper.h" +#include "CogWidgets.h" #include "CogSampleTeamInterface.h" //--------------------------------------------------------------------------------------------------------------------------