mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07:00
Mutiple fixes
Fix shipping build by reworking Cog integration (now use a subsystem) Fix crash when stopping and restarting in the editor
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
GameDefaultMap=/Game/Maps/L_Level1.L_Level1
|
||||
EditorStartupMap=/Game/Maps/L_Level1.L_Level1
|
||||
GlobalDefaultGameMode="/Script/CogSample.CogSampleGameMode"
|
||||
GameInstanceClass=/Script/CogSample.CogSampleGameInstance
|
||||
GameInstanceClass=/Script/Engine.GameInstance
|
||||
|
||||
[/Script/Engine.RendererSettings]
|
||||
r.ReflectionMethod=1
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -25,9 +25,22 @@ FString UCogSubsystem::SaveLayoutCommand = TEXT("Cog.SaveLayout");
|
||||
FString UCogSubsystem::ResetLayoutCommand = TEXT("Cog.ResetLayout");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
bool UCogSubsystem::ShouldCreateSubsystem(UObject* Outer) const
|
||||
{
|
||||
Super::Initialize(Collection);
|
||||
if (Super::ShouldCreateSubsystem(Outer) == false)
|
||||
{ return false; }
|
||||
|
||||
#if ENABLE_COG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TStatId UCogSubsystem::GetStatId() const
|
||||
{
|
||||
RETURN_QUICK_DECLARE_CYCLE_STAT(UCogSubsystemBase, STATGROUP_Tickables);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -38,12 +51,6 @@ void UCogSubsystem::Deinitialize()
|
||||
Super::Deinitialize();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSubsystem::Activate()
|
||||
{
|
||||
FWorldDelegates::OnWorldTickStart.AddUObject(this, &ThisClass::Tick);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSubsystem::TryInitialize(UWorld& World)
|
||||
{
|
||||
@@ -60,7 +67,7 @@ void UCogSubsystem::TryInitialize(UWorld& World)
|
||||
Context.Initialize(WorldContext->GameViewport.Get());
|
||||
|
||||
FCogImGuiContextScope ImGuiContextScope(Context);
|
||||
|
||||
|
||||
ImGuiSettingsHandler IniHandler;
|
||||
IniHandler.TypeName = "Cog";
|
||||
IniHandler.TypeHash = ImHashStr("Cog");
|
||||
@@ -71,14 +78,14 @@ void UCogSubsystem::TryInitialize(UWorld& World)
|
||||
IniHandler.WriteAllFn = SettingsHandler_WriteAll;
|
||||
IniHandler.UserData = this;
|
||||
ImGui::AddSettingsHandler(&IniHandler);
|
||||
|
||||
|
||||
SpaceWindows.Add(AddWindow<FCogWindow_Spacing>("Spacing 1"));
|
||||
SpaceWindows.Add(AddWindow<FCogWindow_Spacing>("Spacing 2"));
|
||||
SpaceWindows.Add(AddWindow<FCogWindow_Spacing>("Spacing 3"));
|
||||
SpaceWindows.Add(AddWindow<FCogWindow_Spacing>("Spacing 4"));
|
||||
|
||||
Settings = GetConfig<UCogWindowConfig_Settings>();
|
||||
|
||||
|
||||
Settings = GetConfig<UCogWindowConfig_Settings>();
|
||||
|
||||
UCogWindowConfig_Settings* SettingsPtr = Settings.Get();
|
||||
AddShortcut(SettingsPtr, &UCogWindowConfig_Settings::Shortcut_ToggleImguiInput).BindLambda([this] () { ToggleInputMode(); });
|
||||
AddShortcut(SettingsPtr, &UCogWindowConfig_Settings::Shortcut_LoadLayout1).BindLambda([this] (){ LoadLayout(1); });
|
||||
@@ -91,14 +98,14 @@ void UCogSubsystem::TryInitialize(UWorld& World)
|
||||
AddShortcut(SettingsPtr, &UCogWindowConfig_Settings::Shortcut_SaveLayout4).BindLambda([this] (){ SaveLayout(4); });
|
||||
AddShortcut(SettingsPtr, &UCogWindowConfig_Settings::Shortcut_ResetLayout).BindLambda([this] (){ ResetLayout(); });
|
||||
|
||||
LayoutsWindow = AddWindow<FCogWindow_Layouts>("Window.Layouts");
|
||||
SettingsWindow = AddWindow<FCogWindow_Settings>("Window.Settings");
|
||||
LayoutsWindow = AddWindow<FCogWindow_Layouts>("Window.Layouts");
|
||||
SettingsWindow = AddWindow<FCogWindow_Settings>("Window.Settings");
|
||||
|
||||
for (FCogWindow* Window : Windows)
|
||||
{
|
||||
InitializeWindow(Window);
|
||||
}
|
||||
|
||||
|
||||
FCogConsoleCommandManager::RegisterWorldConsoleCommand(
|
||||
*ToggleInputCommand,
|
||||
TEXT("Toggle the input focus between the Game and ImGui"),
|
||||
@@ -107,7 +114,7 @@ void UCogSubsystem::TryInitialize(UWorld& World)
|
||||
{
|
||||
ToggleInputMode();
|
||||
}));
|
||||
|
||||
|
||||
FCogConsoleCommandManager::RegisterWorldConsoleCommand(
|
||||
*DisableInputCommand,
|
||||
TEXT("Disable ImGui input"),
|
||||
@@ -116,7 +123,7 @@ void UCogSubsystem::TryInitialize(UWorld& World)
|
||||
{
|
||||
DisableInputMode();
|
||||
}));
|
||||
|
||||
|
||||
FCogConsoleCommandManager::RegisterWorldConsoleCommand(
|
||||
*ResetLayoutCommand,
|
||||
TEXT("Reset the layout."),
|
||||
@@ -128,7 +135,7 @@ void UCogSubsystem::TryInitialize(UWorld& World)
|
||||
ResetLayout();
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
FCogConsoleCommandManager::RegisterWorldConsoleCommand(
|
||||
*LoadLayoutCommand,
|
||||
TEXT("Load the layout. Cog.LoadLayout <Index>"),
|
||||
@@ -140,7 +147,7 @@ void UCogSubsystem::TryInitialize(UWorld& World)
|
||||
LoadLayout(FCString::Atoi(*InArgs[0]));
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
FCogConsoleCommandManager::RegisterWorldConsoleCommand(
|
||||
*SaveLayoutCommand,
|
||||
TEXT("Save the layout. Cog.SaveLayout <Index>"),
|
||||
@@ -167,10 +174,6 @@ void UCogSubsystem::Shutdown()
|
||||
// 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)
|
||||
{
|
||||
@@ -179,9 +182,12 @@ void UCogSubsystem::Shutdown()
|
||||
}
|
||||
Windows.Empty();
|
||||
|
||||
if (IsInitialized)
|
||||
{
|
||||
Context.Shutdown();
|
||||
}
|
||||
|
||||
FCogConsoleCommandManager::UnregisterAllWorldConsoleCommands(GetWorld());
|
||||
|
||||
FWorldDelegates::OnWorldTickStart.RemoveAll(this);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -212,18 +218,10 @@ void UCogSubsystem::ReloadAllSettings()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSubsystem::Tick(UWorld* InTickedWorld, ELevelTick InTickType, float InDeltaTime)
|
||||
void UCogSubsystem::Tick(float InDeltaTime)
|
||||
{
|
||||
UWorld* World = GetWorld();
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
// 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 better way to tick the subsystem only for our world.
|
||||
//----------------------------------------------------------------------------------------------
|
||||
if (World != InTickedWorld)
|
||||
{ return; }
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
// When changing world the DebugExecBindings can change.
|
||||
//----------------------------------------------------------------------------------------------
|
||||
@@ -315,11 +313,6 @@ void UCogSubsystem::SetLocalPlayerController(APlayerController& PlayerController
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSubsystem::UpdatePlayerControllers(UWorld& World)
|
||||
{
|
||||
if (APlayerController* PlayerController = GetGameInstance()->GetFirstLocalPlayerController())
|
||||
{
|
||||
SetLocalPlayerController(*PlayerController);
|
||||
}
|
||||
|
||||
TArray<UCogDebugPluginSubsystem*> PluginSubsystems;
|
||||
|
||||
ServerPlayerControllers.RemoveAll([] (TWeakObjectPtr<APlayerController> PlayerController)
|
||||
@@ -330,9 +323,14 @@ void UCogSubsystem::UpdatePlayerControllers(UWorld& World)
|
||||
for (FConstPlayerControllerIterator It = World.GetPlayerControllerIterator(); It; ++It)
|
||||
{
|
||||
APlayerController* PlayerController = It->Get();
|
||||
if (PlayerController == nullptr)
|
||||
if (IsValid(PlayerController) == false)
|
||||
{ continue; }
|
||||
|
||||
if (PlayerController->IsLocalController())
|
||||
{
|
||||
SetLocalPlayerController(*PlayerController);
|
||||
}
|
||||
|
||||
if (World.GetNetMode() != NM_Client)
|
||||
{
|
||||
if (ServerPlayerControllers.Contains(PlayerController))
|
||||
@@ -342,7 +340,7 @@ void UCogSubsystem::UpdatePlayerControllers(UWorld& World)
|
||||
|
||||
if (PluginSubsystems.IsEmpty())
|
||||
{
|
||||
PluginSubsystems = GetOuterUGameInstance()->GetSubsystemArrayCopy<UCogDebugPluginSubsystem>();
|
||||
PluginSubsystems = World.GetGameInstance()->GetSubsystemArrayCopy<UCogDebugPluginSubsystem>();
|
||||
}
|
||||
|
||||
for (UCogDebugPluginSubsystem* PluginSubsystem : PluginSubsystems)
|
||||
@@ -874,7 +872,6 @@ void UCogSubsystem::SettingsHandler_WriteAll(ImGuiContext* Context, ImGuiSetting
|
||||
{
|
||||
UCogSubsystem* CogSubsystem = static_cast<UCogSubsystem*>(Handler->UserData);
|
||||
|
||||
|
||||
CogSubsystem->SaveAllSettings();
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include "CogImguiContext.h"
|
||||
#include "CogWindow_Settings.h"
|
||||
#include "imgui.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "Subsystems/WorldSubsystem.h"
|
||||
|
||||
#include "CogSubsystem.generated.h"
|
||||
|
||||
class UCogCommonConfig;
|
||||
@@ -22,25 +23,26 @@ struct FKey;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS()
|
||||
class COG_API UCogSubsystem : public UGameInstanceSubsystem
|
||||
class COG_API UCogSubsystem : public UTickableWorldSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
|
||||
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
virtual TStatId GetStatId() const override;
|
||||
|
||||
virtual void Deinitialize() override;
|
||||
|
||||
void Activate();
|
||||
|
||||
virtual void SortMainMenu();
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
virtual void AddWindow(FCogWindow* Window, const FString& Name);
|
||||
|
||||
template<class T>
|
||||
T* AddWindow(const FString& Name);
|
||||
|
||||
|
||||
virtual void SortMainMenu();
|
||||
|
||||
virtual FCogWindow* FindWindowByID(ImGuiID ID);
|
||||
|
||||
virtual void CloseAllWindows();
|
||||
@@ -113,8 +115,6 @@ protected:
|
||||
|
||||
virtual void Render(float DeltaTime);
|
||||
|
||||
virtual void Tick(UWorld* InTickedWorld, ELevelTick InTickType, float InDeltaTime);
|
||||
|
||||
virtual void TryInitialize(UWorld& World);
|
||||
|
||||
virtual void UpdatePlayerControllers(UWorld& World);
|
||||
|
||||
@@ -60,6 +60,13 @@ void FCogImguiContext::Initialize(UGameViewportClient* InGameViewport)
|
||||
|
||||
GameViewport = InGameViewport;
|
||||
|
||||
// ImGui Context must be created before creating widgets as widgets can receive events that uses the ImGui context right away.
|
||||
Context = ImGui::CreateContext();
|
||||
PlotContext = ImPlot::CreateContext();
|
||||
ImGui::SetCurrentContext(Context);
|
||||
ImPlot::SetImGuiContext(Context);
|
||||
ImPlot::SetCurrentContext(PlotContext);
|
||||
|
||||
if (GameViewport != nullptr)
|
||||
{
|
||||
SAssignNew(MainWidget, SCogImguiWidget).Context(this);
|
||||
@@ -69,12 +76,6 @@ void FCogImguiContext::Initialize(UGameViewportClient* InGameViewport)
|
||||
GameViewport->AddViewportWidgetContent(InputCatcherWidget.ToSharedRef(), -TNumericLimits<int32>::Max());
|
||||
}
|
||||
|
||||
Context = ImGui::CreateContext();
|
||||
PlotContext = ImPlot::CreateContext();
|
||||
ImGui::SetCurrentContext(Context);
|
||||
ImPlot::SetImGuiContext(Context);
|
||||
ImPlot::SetCurrentContext(PlotContext);
|
||||
|
||||
ImGuiIO& IO = ImGui::GetIO();
|
||||
IO.UserData = this;
|
||||
|
||||
@@ -209,12 +210,20 @@ void FCogImguiContext::Shutdown()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogImguiContext::OnImGuiWidgetFocusLost()
|
||||
{
|
||||
FCogImGuiContextScope ImGuiContextScope(Context, PlotContext);
|
||||
if (bEnableInput == false)
|
||||
{ return; }
|
||||
|
||||
if (GameViewport == nullptr)
|
||||
{ return; }
|
||||
|
||||
if (bEnableInput && GameViewport->GetGameViewportWidget()->HasUserFocus(0))
|
||||
{
|
||||
bRetakeFocus = true;
|
||||
}
|
||||
const SViewport* ViewportWidget = GameViewport->GetGameViewportWidget().Get();
|
||||
if (ViewportWidget == nullptr)
|
||||
{ return; }
|
||||
|
||||
if (!ViewportWidget->HasUserFocus(0))
|
||||
{ return; }
|
||||
|
||||
bRetakeFocus = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -42,26 +42,26 @@
|
||||
#include "GameFramework/GameUserSettings.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void Cog::AddAllWindows(UCogSubsystem& CogWindowManager)
|
||||
void Cog::AddAllWindows(UCogSubsystem& CogSubsystem)
|
||||
{
|
||||
//---------------------------------------
|
||||
// Engine
|
||||
//---------------------------------------
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_BuildInfo>("Engine.Build Info");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_BuildInfo>("Engine.Build Info");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_CollisionTester>("Engine.Collision Tester");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_CollisionTester>("Engine.Collision Tester");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_CollisionViewer>("Engine.Collision Viewer");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_CollisionViewer>("Engine.Collision Viewer");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_CommandBindings>("Engine.Command Bindings");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_CommandBindings>("Engine.Command Bindings");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Console>("Engine.Console");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Console>("Engine.Console");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_DebugSettings>("Engine.Debug Settings");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_DebugSettings>("Engine.Debug Settings");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_ImGui>("Engine.ImGui");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_ImGui>("Engine.ImGui");
|
||||
|
||||
FCogEngineWindow_Inspector* Inspector = CogWindowManager.AddWindow<FCogEngineWindow_Inspector>("Engine.Inspector");
|
||||
FCogEngineWindow_Inspector* Inspector = CogSubsystem.AddWindow<FCogEngineWindow_Inspector>("Engine.Inspector");
|
||||
Inspector->AddFavorite(GEngine->GetGameUserSettings(), [](UObject* Object)
|
||||
{
|
||||
if (UGameUserSettings* UserSettings = Cast<UGameUserSettings>(Object))
|
||||
@@ -70,70 +70,70 @@ void Cog::AddAllWindows(UCogSubsystem& CogWindowManager)
|
||||
}
|
||||
});
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Levels>("Engine.Levels");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Levels>("Engine.Levels");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_LogCategories>("Engine.Log Categories");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_LogCategories>("Engine.Log Categories");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Metrics>("Engine.Metrics");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Metrics>("Engine.Metrics");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_NetEmulation>("Engine.Net Emulation");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_NetEmulation>("Engine.Net Emulation");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_NetImgui>("Engine.Net ImGui");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_NetImgui>("Engine.Net ImGui");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Notifications>("Engine.Notifications");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Notifications>("Engine.Notifications");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_OutputLog>("Engine.Output Log");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_OutputLog>("Engine.Output Log");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Plots>("Engine.Plots");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Plots>("Engine.Plots");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Selection>("Engine.Selection");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Selection>("Engine.Selection");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Scalability>("Engine.Scalability");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Scalability>("Engine.Scalability");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Skeleton>("Engine.Skeleton");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Skeleton>("Engine.Skeleton");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Slate>("Engine.Slate");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Slate>("Engine.Slate");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Spawns>("Engine.Spawns");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Spawns>("Engine.Spawns");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Stats>("Engine.Stats");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Stats>("Engine.Stats");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_TimeScale>("Engine.Time Scale");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_TimeScale>("Engine.Time Scale");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Transform>("Engine.Transform");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Transform>("Engine.Transform");
|
||||
|
||||
//---------------------------------------
|
||||
// Abilities
|
||||
//---------------------------------------
|
||||
CogWindowManager.AddWindow<FCogAbilityWindow_Abilities>("Gameplay.Abilities");
|
||||
CogSubsystem.AddWindow<FCogAbilityWindow_Abilities>("Gameplay.Abilities");
|
||||
|
||||
CogWindowManager.AddWindow<FCogAbilityWindow_Attributes>("Gameplay.Attributes");
|
||||
CogSubsystem.AddWindow<FCogAbilityWindow_Attributes>("Gameplay.Attributes");
|
||||
|
||||
CogWindowManager.AddWindow<FCogAbilityWindow_BlockedTags>("Gameplay.Blocking Tags");
|
||||
CogSubsystem.AddWindow<FCogAbilityWindow_BlockedTags>("Gameplay.Blocking Tags");
|
||||
|
||||
CogWindowManager.AddWindow<FCogEngineWindow_Cheats>("Gameplay.Cheats");
|
||||
CogSubsystem.AddWindow<FCogEngineWindow_Cheats>("Gameplay.Cheats");
|
||||
|
||||
CogWindowManager.AddWindow<FCogAbilityWindow_Effects>("Gameplay.Effects");
|
||||
CogSubsystem.AddWindow<FCogAbilityWindow_Effects>("Gameplay.Effects");
|
||||
|
||||
CogWindowManager.AddWindow<FCogAbilityWindow_Pools>("Gameplay.Pools");
|
||||
CogSubsystem.AddWindow<FCogAbilityWindow_Pools>("Gameplay.Pools");
|
||||
|
||||
CogWindowManager.AddWindow<FCogAbilityWindow_OwnedTags>("Gameplay.Owned Tags");
|
||||
CogSubsystem.AddWindow<FCogAbilityWindow_OwnedTags>("Gameplay.Owned Tags");
|
||||
|
||||
CogWindowManager.AddWindow<FCogAbilityWindow_Tasks>("Gameplay.Tasks");
|
||||
CogSubsystem.AddWindow<FCogAbilityWindow_Tasks>("Gameplay.Tasks");
|
||||
|
||||
CogWindowManager.AddWindow<FCogAbilityWindow_Tweaks>("Gameplay.Tweaks");
|
||||
CogSubsystem.AddWindow<FCogAbilityWindow_Tweaks>("Gameplay.Tweaks");
|
||||
|
||||
//---------------------------------------
|
||||
// AI
|
||||
//---------------------------------------
|
||||
CogWindowManager.AddWindow<FCogAIWindow_BehaviorTree>("AI.Behavior Tree");
|
||||
CogSubsystem.AddWindow<FCogAIWindow_BehaviorTree>("AI.Behavior Tree");
|
||||
|
||||
CogWindowManager.AddWindow<FCogAIWindow_Blackboard>("AI.Blackboard");
|
||||
CogSubsystem.AddWindow<FCogAIWindow_Blackboard>("AI.Blackboard");
|
||||
|
||||
//---------------------------------------
|
||||
// Input
|
||||
//---------------------------------------
|
||||
CogWindowManager.AddWindow<FCogInputWindow_Actions>("Input.Actions");
|
||||
CogSubsystem.AddWindow<FCogInputWindow_Actions>("Input.Actions");
|
||||
|
||||
CogWindowManager.AddWindow<FCogInputWindow_Gamepad>("Input.Gamepad");
|
||||
CogSubsystem.AddWindow<FCogInputWindow_Gamepad>("Input.Gamepad");
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ class UCogSubsystem;
|
||||
|
||||
namespace Cog
|
||||
{
|
||||
void COGALL_API AddAllWindows(UCogSubsystem& CogWindowManager);
|
||||
void COGALL_API AddAllWindows(UCogSubsystem& CogSubsystem);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
> [!IMPORTANT]
|
||||
> The way Cog integrates in your project has been simplified. If you update Cog, please read the [integration guide](#Integrating-Cog-in-your-project).
|
||||
|
||||
|
||||
# Cog
|
||||
Cog is a set of debug tools for Unreal Engine built on top of [Dear ImGui](https://github.com/ocornut/imgui)
|
||||
|
||||
@@ -12,7 +11,7 @@ Cog is a set of debug tools for Unreal Engine built on top of [Dear ImGui](https
|
||||
|
||||
Cog provides:
|
||||
- ImGui windows to inspect and configure various Unreal systems (Core Engine, Enhanced Inputs, Gameplay Abilities, AI)
|
||||
- Window mangement with persistent configuration and layouts.
|
||||
- Window management with persistent configuration and layouts.
|
||||
- C++ and Blueprint functions to log and debug draw within Log Categories.
|
||||
- Control over the server regarding debug draw, logging, spawning, cheats.
|
||||
- NetImgui support to ease the debugging of game server.
|
||||
@@ -21,7 +20,7 @@ General Info:
|
||||
- Cog can be used both in editor and package builds. It is disabled by default on shipping builds.
|
||||
- Press the `[F1]` key or use the `Cog.ToggleInput` console command to open the ImGui Main Menu.
|
||||
- Many windows display their contents based on a selected actor. The selector actor can be chosen using the `Engine/Selection` window or widget.
|
||||
- Widgets such as Stats (FPS, Ping), Time Scale, Actor Selection, Console, can be added in the main menu bar from the 'Window/Widgets" menu.
|
||||
- Widgets such as Stats (FPS, Ping), Time Scale, Actor Selection, Console, can be added in the main menu bar from the `Window/Widgets` menu.
|
||||
|
||||
## Cog Windows
|
||||
|
||||
@@ -31,7 +30,7 @@ Displays the gameplay abilities of the selected actor.
|
||||
|
||||

|
||||
- Click the ability checkbox to force its activation or deactivation.
|
||||
- Right click an ability to remove it, or open/close the ability separate window.
|
||||
- Right-click an ability to remove it, or open/close the ability separate window.
|
||||
- Use the 'Give Ability' menu to manually give an ability from a list defined in a Data Asset.
|
||||
|
||||
---
|
||||
@@ -87,7 +86,7 @@ Used to apply cheats to the selected actor.
|
||||
- `[CTRL]` Apply the cheat to the controlled actor
|
||||
- `[ALT]` Apply the cheat to the allies of the selected actor
|
||||
- `[SHIFT]` Apply the cheat to the enemies of the selected actor
|
||||
- Optionaly, cheats applied to the local player character are automatically reapplied.
|
||||
- Optionally, cheats applied to the local player character are automatically reapplied.
|
||||
|
||||

|
||||
|
||||
@@ -129,9 +128,9 @@ Used as a replacement of the Unreal console command.
|
||||
|
||||

|
||||
- The console exist as a window and a widget (placed in main menu bar).
|
||||
- The console widget can optionaly get the keyboard focus when the main menu bar is shown.
|
||||
- Use the Keys Up/Down or Tab/Shift-Tab to nagivate in the command list.
|
||||
- The console settings can be change in the console window menu, or by right clicking the widget.
|
||||
- The console widget can optionally get the keyboard focus when the main menu bar is shown.
|
||||
- Use the Keys Up/Down or Tab/Shift-Tab to navigate in the command list.
|
||||
- The console settings can be changed in the console window menu, or by right-clicking the widget.
|
||||
|
||||

|
||||
|
||||
@@ -226,7 +225,7 @@ Use to display and configure notifications
|
||||

|
||||
|
||||
- Notification can be added by using the following macros: `COG_NOTIFY`, `COG_NOTIFY_WARNING`, or `COG_NOTIFY_ERROR`.
|
||||
- Notification settings can used to adjust the filtering, their location, their size, etc.
|
||||
- Notification settings can be used to adjust the filtering, their location, their size, etc.
|
||||
|
||||

|
||||
|
||||
@@ -281,7 +280,7 @@ Used to configure the rendering quality.
|
||||
Used to select an actor either by picking an actor in the world or by selecting an actor in the actor list.
|
||||
|
||||

|
||||
- The actor list can be filtered by actor type (Actor, Character, etc).
|
||||
- The actor list can be filtered by actor type (Actor, Character, etc.).
|
||||
- The current selection is used by various debug windows to filter out their content.
|
||||
|
||||
---
|
||||
@@ -291,8 +290,8 @@ Configure the settings of Cog.
|
||||
|
||||

|
||||
- Configure how ImGui behaves
|
||||
- Change the visibility and ordeing of the widgets appearing in the main menu bar
|
||||
- Change Cog Shorctuts
|
||||
- Change the visibility and ordering of the widgets appearing in the main menu bar
|
||||
- Change Cog Shortcuts
|
||||
- Change the DPI Scaling. Use `[Ctrl][MouseWheel]` to change the DPI.
|
||||
|
||||
---
|
||||
@@ -302,7 +301,7 @@ Display the bone hierarchy and the skeleton debug draw of the selected actor if
|
||||
|
||||

|
||||
- Mouse over a bone to highlight it.
|
||||
- Right click a bone to access more debug display.
|
||||
- Right-click a bone to access more debug display.
|
||||
- Use the `[Ctrl]` key to toggle the bone debug draw recursively.
|
||||
|
||||
---
|
||||
@@ -320,8 +319,8 @@ Displays engine stats such as FPS, Ping, Packet Loss.
|
||||

|
||||
|
||||
- Stats can be viewed as a widget in the main menu bar.
|
||||
- Clicking on the stat povide a menu to force the stat to a reach a specific value.
|
||||
- Right cliking the stat display the settings, where the specific stat values can be defined.
|
||||
- Clicking on the stat provide a menu to force the stat to a reach a specific value.
|
||||
- Right-clicking the stat display the settings, where the specific stat values can be defined.
|
||||
|
||||

|
||||
|
||||
@@ -335,12 +334,12 @@ Displays the gameplay tags of the selected actor.
|
||||
---
|
||||
|
||||
### Time Scale
|
||||
Used to change the game global time scale.
|
||||
Used to change the game global timescale.
|
||||
|
||||

|
||||
- If changed on a client the time scale is also modified on the game server, and replicated to the other clients.
|
||||
- If changed on a client the timescale is also modified on the game server, and replicated to the other clients.
|
||||
- Time Scale can be viewed as a widget in the main menu bar.
|
||||
- Right clicking the Time Scale display the settings, where the specific Time Scale values can be defined.
|
||||
- Right-clicking the Time Scale display the settings, where the specific Time Scale values can be defined.
|
||||
|
||||

|
||||
|
||||
@@ -393,7 +392,7 @@ You must have Unreal 5.5 or greater and Visual Studio to launch the sample
|
||||
### Integrating Cog in your project
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The way Cog integrates in your project has been simplified. If you didn't modify Cog sources, you should remove all your existing Cog source files before updating. If you did modify Cog sources and stil have a `CogWindow` folder, consider deleting it before updating.
|
||||
> The way Cog integrates in your project has been simplified. If you didn't modify Cog sources, you should remove all your existing Cog source files before updating. If you did modify Cog sources and still have a `CogWindow` folder, consider deleting it before updating.
|
||||
|
||||
The Cog repository has the following structure:
|
||||
- `CogSample` - A Sample that demonstrate various Cog functionalities. The project was saved in Unreal 5.5
|
||||
@@ -407,7 +406,7 @@ The Cog repository has the following structure:
|
||||
- `CogEngine` - ImGui windows for the core unreal engine functionalities (Log, Stats, Time, Collisions, Skeleton, ...)
|
||||
- `CogImGui` - Cog own integration of Imgui for Unreal, inspired by [UnrealImGui](https://github.com/segross/UnrealImGui)
|
||||
- `Plugins/CogAll` - Only contains a utility function to easily add all the built-in windows from all the Cog plugins. Useful for projects that do not need to exclude some plugins.
|
||||
- `Plugins/CogCommonUI` - Contains an implementation of CommonUIActionRouterBase to let the Cog shorcuts work while in a CommonUI menu. Only use this plugin if you use CommonUI.
|
||||
- `Plugins/CogCommonUI` - Contains an implementation of CommonUIActionRouterBase to let the Cog shortcuts work while in a CommonUI menu. Only use this plugin if you use CommonUI.
|
||||
|
||||
Cog has multiple plugins to ease the integration for projects that do not use the `Ability System Component` or `Enhanced Input`. For the next steps, it is assumed all the plugins are used.
|
||||
|
||||
@@ -455,31 +454,34 @@ public class CogSample : ModuleRules
|
||||
}
|
||||
```
|
||||
|
||||
- Override the Unreal GameInstance:
|
||||
- Add a world subsystem to your project to configure which windows to add in the main menu. Use `CogSampleConfigurationSubsystem` as a template.
|
||||
|
||||
`CogSampleConfigurationSubsystem.h`
|
||||
```cpp
|
||||
#pragma once
|
||||
|
||||
#include "CogSampleGameInstance.generated.h"
|
||||
#include "Subsystems/WorldSubsystem.h"
|
||||
#include "CogSampleConfigurationSubsystem.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class UCogSampleGameInstance : public UGameInstance
|
||||
class UCogSampleConfigurationSubsystem : public UWorldSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
virtual void PostInitialize() override;
|
||||
|
||||
void Init() override;
|
||||
private:
|
||||
UPROPERTY()
|
||||
TWeakObjectPtr<USubsystem> CogSubsystem;
|
||||
};
|
||||
```
|
||||
|
||||
- Set your own game instance in the Unreal project settings:
|
||||
|
||||

|
||||
|
||||
- In your GameInstance Init:
|
||||
- Add the windows you want to the CogSubsystem. In the sample we add all the built-in windows by calling Cog::AddAllWindows and we also add a custom window from the sample itself, showcasing that you can add your own windows.
|
||||
- Activate Cog
|
||||
|
||||
`CogSampleConfigurationSubsystem.cpp`
|
||||
```cpp
|
||||
#include "CogSampleGameInstance.h"
|
||||
#include "CogSampleConfigurationSubsystem.h"
|
||||
|
||||
#include "CogCommon.h"
|
||||
|
||||
@@ -487,29 +489,49 @@ class UCogSampleGameInstance : public UGameInstance
|
||||
#include "CogAll.h"
|
||||
#include "CogSampleWindow_Team.h"
|
||||
#include "CogSubsystem.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void UCogSampleGameInstance::Init()
|
||||
bool UCogSampleConfigurationSubsystem::ShouldCreateSubsystem(UObject* Outer) const
|
||||
{
|
||||
Super::Init();
|
||||
if (Super::ShouldCreateSubsystem(Outer) == false)
|
||||
{ return false; }
|
||||
|
||||
#if ENABLE_COG
|
||||
// Get the cog subsystem
|
||||
if (UCogSubsystem* CogSubSystem = GetSubsystem<UCogSubsystem>())
|
||||
{
|
||||
// Add all the built-in windows. You copy paste this function code to organize the menu differently.
|
||||
Cog::AddAllWindows(*CogSubSystem);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Add a custom window
|
||||
CogSubSystem->AddWindow<FCogSampleWindow_Team>("Gameplay.Team");
|
||||
void UCogSampleConfigurationSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
Super::Initialize(Collection);
|
||||
#if ENABLE_COG
|
||||
CogSubsystem = Collection.InitializeDependency<UCogSubsystem>();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Activate Cog
|
||||
CogSubSystem->Activate();
|
||||
}
|
||||
#endif
|
||||
void UCogSampleConfigurationSubsystem::PostInitialize()
|
||||
{
|
||||
Super::PostInitialize();
|
||||
|
||||
#if ENABLE_COG
|
||||
UCogSubsystem* CogSubsystemPtr = Cast<UCogSubsystem>(CogSubsystem.Get());
|
||||
if (IsValid(CogSubsystemPtr) == false)
|
||||
{ return; }
|
||||
|
||||
// Add all the built-in windows. You can copy and paste this function code to organize the main menu differently.
|
||||
Cog::AddAllWindows(*CogSubsystemPtr);
|
||||
|
||||
// Add a custom window
|
||||
CogSubsystemPtr->AddWindow<FCogSampleWindow_Team>("Gameplay.Team");
|
||||
#endif
|
||||
}
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> The reason you need to manually add this code is because all Cog code appart from CogCommon is stripped in `Shipping` build.
|
||||
|
||||
- Implement Cog Interfaces on your desired actor classes:
|
||||
```cpp
|
||||
// CogSampleCharacter.h
|
||||
@@ -537,7 +559,7 @@ class ACogSamplePlayerController
|
||||
|
||||

|
||||
|
||||
- Reference the added Data Assets in the projet Asset Manager for them to be found in package mode:
|
||||
- Reference the added Data Assets in the project Asset Manager for them to be found in package mode:
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "CogSampleConfigurationSubsystem.h"
|
||||
|
||||
#include "CogCommon.h"
|
||||
|
||||
#if ENABLE_COG
|
||||
#include "CogAll.h"
|
||||
#include "CogSampleWindow_Team.h"
|
||||
#include "CogSubsystem.h"
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool UCogSampleConfigurationSubsystem::ShouldCreateSubsystem(UObject* Outer) const
|
||||
{
|
||||
if (Super::ShouldCreateSubsystem(Outer) == false)
|
||||
{ return false; }
|
||||
|
||||
#if ENABLE_COG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSampleConfigurationSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
Super::Initialize(Collection);
|
||||
#if ENABLE_COG
|
||||
CogSubsystem = Collection.InitializeDependency<UCogSubsystem>();
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSampleConfigurationSubsystem::PostInitialize()
|
||||
{
|
||||
Super::PostInitialize();
|
||||
|
||||
#if ENABLE_COG
|
||||
UCogSubsystem* CogSubsystemPtr = Cast<UCogSubsystem>(CogSubsystem.Get());
|
||||
if (IsValid(CogSubsystemPtr) == false)
|
||||
{ return; }
|
||||
|
||||
// Add all the built-in windows. You can copy and paste this function code to organize the main menu differently.
|
||||
Cog::AddAllWindows(*CogSubsystemPtr);
|
||||
|
||||
// Add a custom window
|
||||
CogSubsystemPtr->AddWindow<FCogSampleWindow_Team>("Gameplay.Team");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "Subsystems/WorldSubsystem.h"
|
||||
#include "CogSampleConfigurationSubsystem.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class UCogSampleConfigurationSubsystem : public UWorldSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
virtual void PostInitialize() override;
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TWeakObjectPtr<USubsystem> CogSubsystem;
|
||||
};
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "CogSampleGameInstance.h"
|
||||
|
||||
#include "CogCommon.h"
|
||||
|
||||
#if ENABLE_COG
|
||||
#include "CogAll.h"
|
||||
#include "CogSampleWindow_Team.h"
|
||||
#include "CogSubsystem.h"
|
||||
#endif
|
||||
|
||||
|
||||
void UCogSampleGameInstance::Init()
|
||||
{
|
||||
Super::Init();
|
||||
|
||||
#if ENABLE_COG
|
||||
|
||||
// Get the cog subsystem
|
||||
if (UCogSubsystem* CogSubSystem = GetSubsystem<UCogSubsystem>())
|
||||
{
|
||||
// Add all the built-in windows. You copy paste this function code to organize the menu differently.
|
||||
Cog::AddAllWindows(*CogSubSystem);
|
||||
|
||||
// Add a custom window
|
||||
CogSubSystem->AddWindow<FCogSampleWindow_Team>("Gameplay.Team");
|
||||
|
||||
// Activate Cog
|
||||
CogSubSystem->Activate();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CogSampleGameInstance.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class UCogSampleGameInstance : public UGameInstance
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
void Init() override;
|
||||
};
|
||||
@@ -9,7 +9,6 @@
|
||||
#if ENABLE_COG
|
||||
#include "CogAll.h"
|
||||
#include "CogSampleWindow_Team.h"
|
||||
#include "CogSubsystem.h"
|
||||
#endif //ENABLE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user