Rework how ImGui input toggle is triggered

Add a new window CommandBindings to configure the shortcuts of console commands
The first time it is created, this window add the bindings to control cog:

[Tab]  Cog.ToggleInput
[F1]   Cog.LoadLayout 1
[F2]   Cog.LoadLayout 2
[F3]   Cog.LoadLayout 3
[F4]   Cog.LoadLayout 4
[F5]   Cog.ToggleSelectionMode

The selection window can now uses the Actor Label instead of Name (simpler to read)
Fix Blackboard sorting
This commit is contained in:
Arnaud Jamin
2023-10-19 17:28:42 -04:00
parent c32efe88f5
commit 1b5d63b0af
18 changed files with 705 additions and 165 deletions
@@ -3,10 +3,11 @@
#include "CogDebugDrawImGui.h"
#include "CogImguiModule.h"
#include "CogImguiWidget.h"
#include "CogWindow_Spacing.h"
#include "CogWindow_Settings.h"
#include "CogWindow_Spacing.h"
#include "CogWindowWidgets.h"
#include "Engine/Engine.h"
#include "HAL/IConsoleManager.h"
#include "imgui_internal.h"
//--------------------------------------------------------------------------------------------------------------------------
@@ -36,6 +37,25 @@ void UCogWindowManager::InitializeInternal()
SpaceWindows.Add(CreateWindow<UCogWindow_Spacing>("Spacing 4", false));
SettingsWindow = CreateWindow<UCogWindow_Settings>("Window.Settings", false);
ConsoleCommands.Add(IConsoleManager::Get().RegisterConsoleCommand(
TEXT("Cog.ToggleInput"),
TEXT("Toggle the input focus between the Game and ImGui"),
FConsoleCommandWithArgsDelegate::CreateLambda([](const TArray<FString>& Args) { FCogImguiModule::Get().ToggleEnableInput(); }),
ECVF_Cheat));
ConsoleCommands.Add(IConsoleManager::Get().RegisterConsoleCommand(
TEXT("Cog.LoadLayout"),
TEXT("Load the layout. Cog.LoadLayout <Index>"),
FConsoleCommandWithArgsDelegate::CreateLambda([this](const TArray<FString>& Args) { if (Args.Num() > 0) { LoadLayout(FCString::Atoi(*Args[0])); }}),
ECVF_Cheat));
ConsoleCommands.Add(IConsoleManager::Get().RegisterConsoleCommand(
TEXT("Cog.SaveLayout"),
TEXT("Save the layout. Cog.SaveLayout <Index>"),
FConsoleCommandWithArgsDelegate::CreateLambda([this](const TArray<FString>& Args) { if (Args.Num() > 0) { SaveLayout(FCString::Atoi(*Args[0])); }}),
ECVF_Cheat));
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -47,6 +67,11 @@ void UCogWindowManager::Shutdown()
Window->SaveConfig();
}
for (IConsoleObject* ConsoleCommand : ConsoleCommands)
{
IConsoleManager::Get().UnregisterConsoleObject(ConsoleCommand);
}
SaveConfig();
}
@@ -190,7 +215,7 @@ void UCogWindowManager::CloseAllWindows()
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogWindowManager::LoadLayout(int LayoutIndex)
void UCogWindowManager::LoadLayout(int32 LayoutIndex)
{
for (UCogWindow* Window : Windows)
{
@@ -201,7 +226,7 @@ void UCogWindowManager::LoadLayout(int LayoutIndex)
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogWindowManager::SaveLayout(int LayoutIndex)
void UCogWindowManager::SaveLayout(int32 LayoutIndex)
{
FString Filename = *FCogImguiHelper::GetIniFilePath(FString::Printf(TEXT("imgui_layout_%d"), LayoutIndex));
ImGui::SaveIniSettingsToDisk(TCHAR_TO_ANSI(*Filename));