From 9bf32b2d8623c87bd27114eb669651186e673566 Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Tue, 4 Feb 2025 01:26:19 -0500 Subject: [PATCH] CogEngine: Improve various windows widgets usability - Implement ImGui Copy Paste, and OpenInShell backend. - Fix ColorEdit4 - Fix Hand and NotAllowed cursors - Make the reset of windows configuration automatic (but optional) when getting a config. - Console Window: Improve usability - Stat Window: Add configuration of of MaxFPS, Pings, and PacketLoss. Improve widget usability. - Time Scale Window: Add configuration of time scale. Improve widget usability. - Output Log Window: Fix the Copy. - Selection Window: The Pick button now uses an icon --- .../Source/CogCommon/Public/CogCommonConfig.h | 1 - .../Cog/Source/CogEngine/CogEngine.Build.cs | 1 + .../Private/CogEngineWindow_Cheats.cpp | 8 - .../CogEngineWindow_CollisionTester.cpp | 8 - .../CogEngineWindow_CollisionViewer.cpp | 8 - .../Private/CogEngineWindow_Console.cpp | 316 +++++++++++------- .../Private/CogEngineWindow_DebugSettings.cpp | 8 - .../Private/CogEngineWindow_Metrics.cpp | 8 - .../Private/CogEngineWindow_NetEmulation.cpp | 26 +- .../Private/CogEngineWindow_NetImGui.cpp | 7 - .../Private/CogEngineWindow_OutputLog.cpp | 62 +++- .../Private/CogEngineWindow_Plots.cpp | 2 - .../Private/CogEngineWindow_Selection.cpp | 28 +- .../Private/CogEngineWindow_Stats.cpp | 302 +++++++++++------ .../Private/CogEngineWindow_TimeScale.cpp | 93 +++++- .../CogEngine/Public/CogEngineWindow_Cheats.h | 2 - .../Public/CogEngineWindow_CollisionTester.h | 2 - .../Public/CogEngineWindow_CollisionViewer.h | 2 - .../Public/CogEngineWindow_Console.h | 39 ++- .../Public/CogEngineWindow_DebugSettings.h | 2 - .../Public/CogEngineWindow_Metrics.h | 2 - .../Public/CogEngineWindow_NetEmulation.h | 9 +- .../Public/CogEngineWindow_NetImGui.h | 6 +- .../Public/CogEngineWindow_OutputLog.h | 21 +- .../Public/CogEngineWindow_Selection.h | 2 - .../CogEngine/Public/CogEngineWindow_Stats.h | 103 +++++- .../Public/CogEngineWindow_TimeScale.h | 46 ++- .../CogImgui/Private/CogImguiContext.cpp | 72 +++- .../CogImgui/Private/CogImguiHelper.cpp | 12 +- .../CogImgui/Private/CogImguiInputHelper.cpp | 22 +- .../Source/CogImgui/Public/CogImguiContext.h | 15 +- .../Source/CogImgui/Public/CogImguiHelper.h | 2 + .../Source/CogWindow/Private/CogWindow.cpp | 55 ++- .../CogWindow/Private/CogWindowManager.cpp | 20 +- .../CogWindow/Private/CogWindowWidgets.cpp | 142 +++++--- .../CogWindow/Private/CogWindow_Settings.cpp | 8 - .../Cog/Source/CogWindow/Public/CogWindow.h | 12 +- .../CogWindow/Public/CogWindowWidgets.h | 62 +++- .../CogWindow/Public/CogWindow_Settings.h | 2 - .../CogAI/Private/CogAIWindow_Blackboard.cpp | 8 - .../CogAI/Public/CogAIWindow_Blackboard.h | 2 - .../Private/CogAbilityWindow_Abilities.cpp | 8 - .../Private/CogAbilityWindow_Attributes.cpp | 8 - .../Private/CogAbilityWindow_Cheats.cpp | 9 - .../Private/CogAbilityWindow_Effects.cpp | 9 - .../Private/CogAbilityWindow_Tags.cpp | 8 - .../Private/CogAbilityWindow_Tasks.cpp | 8 - .../Public/CogAbilityWindow_Abilities.h | 2 - .../Public/CogAbilityWindow_Attributes.h | 4 +- .../Public/CogAbilityWindow_Cheats.h | 5 +- .../Public/CogAbilityWindow_Effects.h | 2 - .../CogAbility/Public/CogAbilityWindow_Tags.h | 2 - .../Public/CogAbilityWindow_Tasks.h | 2 - .../Private/CogInputWindow_Actions.cpp | 8 - .../Private/CogInputWindow_Gamepad.cpp | 11 - .../CogInput/Public/CogInputWindow_Actions.h | 2 - .../CogInput/Public/CogInputWindow_Gamepad.h | 2 - 57 files changed, 1056 insertions(+), 582 deletions(-) diff --git a/Plugins/Cog/Source/CogCommon/Public/CogCommonConfig.h b/Plugins/Cog/Source/CogCommon/Public/CogCommonConfig.h index d555f89..8f262ec 100644 --- a/Plugins/Cog/Source/CogCommon/Public/CogCommonConfig.h +++ b/Plugins/Cog/Source/CogCommon/Public/CogCommonConfig.h @@ -12,7 +12,6 @@ public: UCogCommonConfig() { - Reset(); } virtual void Reset() diff --git a/Plugins/Cog/Source/CogEngine/CogEngine.Build.cs b/Plugins/Cog/Source/CogEngine/CogEngine.Build.cs index 360db8c..9950a53 100644 --- a/Plugins/Cog/Source/CogEngine/CogEngine.Build.cs +++ b/Plugins/Cog/Source/CogEngine/CogEngine.Build.cs @@ -15,6 +15,7 @@ public class CogEngine : ModuleRules PrivateDependencyModuleNames.AddRange( new [] { + "ApplicationCore", "CogCommon", "CogImgui", "CogWindow", diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Cheats.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Cheats.cpp index 1a58fd5..17af666 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Cheats.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Cheats.cpp @@ -90,14 +90,6 @@ void FCogEngineWindow_Cheats::UpdateCheatColor(const FCogEngineCheat& Cheat) con } } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Cheats::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Cheats::GameTick(float DeltaTime) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp index d4abc26..eaf4046 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionTester.cpp @@ -25,14 +25,6 @@ void FCogEngineWindow_CollisionTester::RenderHelp() ImGui::Text("This window is used to test a collision query."); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_CollisionTester::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_CollisionTester::RenderContent() { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp index 45e7e4a..54f1582 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CollisionViewer.cpp @@ -32,14 +32,6 @@ void FCogEngineWindow_CollisionViewer::RenderHelp() ); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_CollisionViewer::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_CollisionViewer::RenderContent() { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Console.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Console.cpp index 12e0135..97be8f8 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Console.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Console.cpp @@ -4,6 +4,10 @@ #include "CogWindowManager.h" #include "CogWindowWidgets.h" #include "imgui.h" +#include "imgui.h" +#include "imgui.h" +#include "imgui.h" +#include "imgui.h" #include "imgui_internal.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -28,6 +32,12 @@ void FCogEngineWindow_Console::Initialize() RefreshCommandList(); } +//-------------------------------------------------------------------------------------------------------------------------- + void FCogEngineWindow_Console::PreRender(ImGuiWindowFlags& WindowFlags) +{ + WindowFlags |= ImGuiWindowFlags_NoScrollbar; +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Console::RenderContent() { @@ -57,39 +67,16 @@ void FCogEngineWindow_Console::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Console::RenderMainMenuWidget() +void FCogEngineWindow_Console::RenderTick(float DeltaTime) { - bIsRenderingWidget = true; - - const ImGuiContext& g = *GImGui; - const ImGuiStyle& Style = g.Style; - const ImGuiWindow* Window = ImGui::GetCurrentWindow(); - ImVec2 TooltipPos = Window->DC.CursorPos; - TooltipPos.y += Window->MenuBarHeight; - - ImGui::SetNextItemWidth(Config->WidgetWidth); - - RenderInput(); - const bool IsTextInputActive = ImGui::IsItemActive(); - - if (Config->FocusWidgetWhenAppearing && ImGui::IsWindowAppearing()) - { - SelectedCommandIndex = -1; - RefreshCommandList(); - ImGui::ActivateItemByID(InputIdOnWidgetMode); - } - - if (ImGui::BeginPopupContextItem()) - { - RenderMenu(); - ImGui::EndPopup(); - } - - if (bPopupCommandListOnWidgetMode) + if (WidgetMode_OpenCommandList) { + bIsWidgetMode = true; + + const ImGuiContext& g = *GImGui; ImGui::SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.90f); ImGui::SetNextWindowSize(ImVec2(Config->WidgetWidth, ImGui::GetFontSize() * 30), ImGuiCond_FirstUseEver); - ImGui::SetNextWindowPos(TooltipPos, ImGuiCond_Always); + ImGui::SetNextWindowPos(WidgetMode_CommandListPosition, ImGuiCond_Always); ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar @@ -97,28 +84,83 @@ void FCogEngineWindow_Console::RenderMainMenuWidget() | ImGuiWindowFlags_NoFocusOnAppearing; // We want the console input text to keep the focus. ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); - if (ImGui::Begin("ConsoleTooltip", nullptr, flags)) + const bool IsCommandListWindowVisible = ImGui::Begin("ConsoleCommandList", nullptr, flags); + ImGui::PopStyleVar(); + + if (IsCommandListWindowVisible) { + ImGui::Spacing(); RenderCommandList(); - if (ImGui::BeginPopupContextWindow()) + if (ImGui::BeginPopupContextWindow("ConsoleCommandListPopup")) { RenderMenu(); ImGui::EndPopup(); } const bool IsWindowFocused = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); - - if (IsTextInputActive == false && IsWindowFocused == false && bRequestInputFocus == false) + if (IsWindowFocused) { - bPopupCommandListOnWidgetMode = false; + if (ImGui::IsKeyPressed(ImGuiKey_DownArrow)) + { + SelectNextCommand(); + ActivateInputText(); + } + else if (ImGui::IsKeyPressed(ImGuiKey_UpArrow)) + { + SelectPreviousCommand(); + ActivateInputText(); + } + else if (ImGui::IsKeyPressed(ImGuiKey_Tab)) + { + SelectNextCommand(); + ActivateInputText(); + } + else if (ImGui::IsKeyPressed(ImGuiKey_Escape)) + { + WidgetMode_OpenCommandList = false; + } + } + + if (IsWindowFocused == false && WidgetMode_IsTextInputActive == false) + { + WidgetMode_OpenCommandList = false; } } ImGui::End(); - ImGui::PopStyleVar(); + + bIsWidgetMode = false; + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Console::RenderMainMenuWidget() +{ + bIsWidgetMode = true; + + const ImGuiWindow* Window = ImGui::GetCurrentWindow(); + WidgetMode_CommandListPosition = Window->DC.CursorPos; + WidgetMode_CommandListPosition.y += Window->MenuBarHeight; + + ImGui::SetNextItemWidth(Config->WidgetWidth); + + RenderInput(); + WidgetMode_IsTextInputActive = ImGui::IsItemActive(); + + if (Config->FocusWidgetWhenAppearing && ImGui::IsWindowAppearing()) + { + SelectedCommandIndex = -1; + RefreshCommandList(); + ActivateInputText(); } - bIsRenderingWidget = false; + if (ImGui::BeginPopupContextItem()) + { + RenderMenu(); + ImGui::EndPopup(); + } + + bIsWidgetMode = false; } //-------------------------------------------------------------------------------------------------------------------------- @@ -127,6 +169,8 @@ void FCogEngineWindow_Console::RenderMenu() if (ImGui::BeginMenu("Options")) { FCogWindowWidgets::ThinSeparatorText("General"); + + ImGui::Checkbox("Show Help", &Config->ShowHelp); if (ImGui::Checkbox("Sort Commands", &Config->SortCommands)) { @@ -172,7 +216,7 @@ void FCogEngineWindow_Console::RenderMenu() ImGui::EndMenu(); } - if (bIsRenderingWidget == false && Config->DockInputInMenuBar) + if (bIsWidgetMode == false && Config->DockInputInMenuBar) { ImGui::SetNextItemWidth(-1); RenderInput(); @@ -192,17 +236,15 @@ void FCogEngineWindow_Console::RenderInput() | ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_CallbackAlways; - if (FCogWindowWidgets::InputTextWithHint("##Command", "Command", CurrentUserInput, InputFlags, &OnTextInputCallbackStub, this)) + const bool IsEnterPressed = FCogWindowWidgets::InputTextWithHint("##Command", "Command", CurrentUserInput, InputFlags, &OnTextInputCallbackStub, this); + InputTextId = ImGui::GetItemID(); + + if (IsEnterPressed) { ExecuteCommand(CurrentUserInput); - bRequestInputFocus = true; + ActivateInputText(); } - if (bIsRenderingWidget) - { - InputIdOnWidgetMode = ImGui::GetItemID(); - } - ImGui::SetItemDefaultFocus(); //------------------------------------------------------------------------------------------------- @@ -211,19 +253,33 @@ void FCogEngineWindow_Console::RenderInput() // we want the text input to always have focus so the user can directly type text if he wants to, // but if he doesn't the command list should not clutter the screen. //------------------------------------------------------------------------------------------------- - if (bIsRenderingWidget && ImGui::IsItemActive() && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) + if (bIsWidgetMode && ImGui::IsItemActive() && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { - bPopupCommandListOnWidgetMode = true; - } - - if (ImGui::IsItemActive() == false && bRequestInputFocus) - { - ImGui::SetKeyboardFocusHere(-1); + WidgetMode_OpenCommandList = true; } +} - if (ImGui::IsItemActive()) +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Console::SelectNextCommand() +{ + SelectedCommandIndex += 1; + bScroll = true; + + if (SelectedCommandIndex >= CommandList.Num()) { - bRequestInputFocus = false; + SelectedCommandIndex = 0; + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Console::SelectPreviousCommand() +{ + SelectedCommandIndex -= 1; + bScroll = true; + + if (SelectedCommandIndex < 0) + { + SelectedCommandIndex = CommandList.Num() - 1; } } @@ -233,43 +289,32 @@ int FCogEngineWindow_Console::OnTextInputCallback(ImGuiInputTextCallbackData* In bool DoCompletion = false; if (InData->EventFlag == ImGuiInputTextFlags_CallbackHistory) { - DoCompletion = true; - if (InData->EventKey == ImGuiKey_UpArrow) { - SelectedCommandIndex -= 1; - bScroll = true; - - if (SelectedCommandIndex < 0) - { - SelectedCommandIndex = CommandList.Num() - 1; - } + SelectPreviousCommand(); } else if (InData->EventKey == ImGuiKey_DownArrow) { - SelectedCommandIndex += 1; - bScroll = true; - - if (SelectedCommandIndex >= CommandList.Num()) - { - SelectedCommandIndex = 0; - } + SelectNextCommand(); } + + DoCompletion = true; } else if (InData->EventFlag == ImGuiInputTextFlags_CallbackCompletion) { + SelectNextCommand(); DoCompletion = true; } else if (InData->EventFlag == ImGuiInputTextFlags_CallbackEdit) { CurrentUserInput = FString(InData->Buf); - RefreshCommandList(); + RefreshCommandList(); - if (bIsRenderingWidget) + if (bIsWidgetMode) { - bPopupCommandListOnWidgetMode = true; + WidgetMode_OpenCommandList = true; } - } + } else if (InData->EventFlag == ImGuiInputTextFlags_CallbackAlways) { if (bSetBufferToSelectedCommand) @@ -288,9 +333,9 @@ int FCogEngineWindow_Console::OnTextInputCallback(ImGuiInputTextCallbackData* In InData->InsertChars(0, CommandStr.Get()); InData->InsertChars(InData->CursorPos, " "); - if (bIsRenderingWidget) + if (bIsWidgetMode) { - bPopupCommandListOnWidgetMode = true; + WidgetMode_OpenCommandList = true; } } @@ -304,25 +349,39 @@ int FCogEngineWindow_Console::OnTextInputCallbackStub(ImGuiInputTextCallbackData return ConsoleWindow.OnTextInputCallback(InData); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Console::RenderCommandHelp() -{ - -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Console::RenderCommandList() { - const float HelpHeight = ImGui::GetFontSize() * 5; + const float HelpHeight = Config->ShowHelp ? ImGui::GetFontSize() * 5 : 0.0f; const float Indent = ImGui::GetFontSize() * 0.5f; + const ImVec2 Size = IsWindowRenderedInMainMenu() ? ImVec2(0, ImGui::GetFontSize() * 20) : ImVec2(0.0f, ImGui::GetContentRegionAvail().y - HelpHeight); - const ImVec2 Size = IsWindowRenderedInMainMenu() ? ImVec2(0, ImGui::GetFontSize() * 20) : ImVec2(0.0f, -HelpHeight); - if (ImGui::BeginChild("Commands", Size, ImGuiChildFlags_NavFlattened | ImGuiChildFlags_ResizeY)) + if (ImGui::BeginChild("Commands", Size, ImGuiChildFlags_None)) { ImGui::Indent(Indent); + //-------------------------------------------------------------------- + // Gather the child window region min max so we can check if the + // selected command is clipped to know if we should scroll. + //-------------------------------------------------------------------- + const float RegionMinY = ImGui::GetItemRectMin().y; + const float RegionMaxY = RegionMinY + ImGui::GetContentRegionAvail().y; + + //-------------------------------------------------------------------- + // Reset the scroll when the command list reappear, otherwise we + // keep the previous scroll which can be confusing. + //-------------------------------------------------------------------- + if (ImGui::IsWindowAppearing()) + { + ImGui::SetScrollHereY(0.0f); + SelectedCommandIndex = -1; + } + int32 Index = 0; + //-------------------------------------------------------------------- + // TODO: The Clipper is currently not working correctly + //-------------------------------------------------------------------- ImGuiListClipper Clipper; Clipper.Begin(CommandList.Num()); while (Clipper.Step()) @@ -336,7 +395,7 @@ void FCogEngineWindow_Console::RenderCommandList() { ImGui::PushID(Index); const FString& CommandName = CommandList[Index]; - RenderCommand(CommandName, Index); + RenderCommand(CommandName, Index, RegionMinY, RegionMaxY); ImGui::PopID(); } } @@ -346,13 +405,16 @@ void FCogEngineWindow_Console::RenderCommandList() } Clipper.End(); - // If any is available, draw an additional command below the clipper to be able to scroll when pressing bottom + //-------------------------------------------------------------------- + // If any is available, draw an additional command below the clipper + // to be able to scroll when pressing bottom + //-------------------------------------------------------------------- if (CommandList.IsValidIndex(Index + 1)) { const FString& Command = CommandList[Index + 1]; - RenderCommand(Command, Index); + RenderCommand(Command, Index, RegionMinY, RegionMaxY); } - + ImGui::Unindent(Indent); } ImGui::EndChild(); @@ -360,29 +422,31 @@ void FCogEngineWindow_Console::RenderCommandList() //-------------------------------------------------------------------- // Render Help //-------------------------------------------------------------------- - ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.2f, 0.2f, 0.2f, 0.5f)); - if (ImGui::BeginChild("Help", ImVec2(0.0f, ImGui::GetContentRegionAvail().y))) + if (Config->ShowHelp) { - ImGui::Spacing(); - ImGui::BeginDisabled(); - ImGui::Indent(Indent); - - if (CommandList.IsValidIndex(SelectedCommandIndex)) + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.2f, 0.2f, 0.2f, 0.5f)); + if (ImGui::BeginChild("Help", ImVec2(0.0f, ImGui::GetContentRegionAvail().y))) { - const FString SelectedCommand = CommandList[SelectedCommandIndex]; - const FString Help = GetConsoleCommandHelp(SelectedCommand); - const auto& HelpStr = StringCast(*Help); - ImGui::TextWrapped(HelpStr.Get()); + ImGui::Spacing(); + ImGui::BeginDisabled(); + ImGui::Indent(Indent); + + if (CommandList.IsValidIndex(SelectedCommandIndex)) + { + const FString SelectedCommand = CommandList[SelectedCommandIndex]; + const FString Help = GetConsoleCommandHelp(SelectedCommand); + const auto& HelpStr = StringCast(*Help); + ImGui::TextWrapped(HelpStr.Get()); + } + + ImGui::Unindent(Indent); + ImGui::EndDisabled(); } - - ImGui::Unindent(Indent); - ImGui::EndDisabled(); + ImGui::EndChild(); + ImGui::PopStyleColor(); } - ImGui::EndChild(); - ImGui::PopStyleColor(); } - //-------------------------------------------------------------------------------------------------------------------------- FString FCogEngineWindow_Console::GetConsoleCommandHelp(const FString& InCommandName) { @@ -404,7 +468,7 @@ FString FCogEngineWindow_Console::GetConsoleCommandHelp(const FString& InCommand } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Console::RenderCommand(const FString& CommandName, const int32 Index) +void FCogEngineWindow_Console::RenderCommand(const FString& CommandName, const int32 Index, float RegionMinY, float RegionMaxY) { const auto& CommandNameStr = StringCast(*CommandName); @@ -421,17 +485,25 @@ void FCogEngineWindow_Console::RenderCommand(const FString& CommandName, const i ImGuiSelectableFlags Flags = ImGuiSelectableFlags_AllowDoubleClick // Double click executes the selected command | ImGuiSelectableFlags_SelectOnClick; // Need to focus the console text input right away, otherwise the Selectable take back the focus on mouse release - - if (ImGui::Selectable(CommandNameStr.Get(), &IsSelected, Flags)) + + const bool Pressed = ImGui::Selectable(CommandNameStr.Get(), &IsSelected, Flags); + const int32 IsClippedTop = ImGui::GetItemRectMin().y < RegionMinY; + const int32 IsClippedBottom = ImGui::GetItemRectMax().y > RegionMaxY; + + if (Pressed) { SelectedCommandIndex = Index; - bRequestInputFocus = true; - bSetBufferToSelectedCommand = true; if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { ExecuteCommand(CommandName); } + else + { + bSetBufferToSelectedCommand = true; + } + + ActivateInputText(); } if (ImGui::BeginItemTooltip()) @@ -455,13 +527,19 @@ void FCogEngineWindow_Console::RenderCommand(const FString& CommandName, const i ImGui::Separator(); } - if (IsSelected) - { - if (bScroll) + if (IsSelected && bScroll) + { + if (IsClippedBottom) { ImGui::SetScrollHereY(1.0f); - bScroll = false; } + + if (IsClippedTop) + { + ImGui::SetScrollHereY(0.0f); + } + + bScroll = false; } } @@ -530,6 +608,12 @@ void FCogEngineWindow_Console::RefreshCommandList() SelectedCommandIndex = -1; } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Console::ActivateInputText() const +{ + return ImGui::ActivateItemByID(InputTextId); +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Console::ExecuteCommand(const FString& InCommand) { @@ -540,9 +624,9 @@ void FCogEngineWindow_Console::ExecuteCommand(const FString& InCommand) GEngine->DeferredCommands.Add(CleanupCommand); } - if (bIsRenderingWidget) + if (bIsWidgetMode) { - bPopupCommandListOnWidgetMode = false; + WidgetMode_OpenCommandList = false; } CurrentUserInput = FString(); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp index d612c10..b138c94 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp @@ -27,14 +27,6 @@ void FCogEngineWindow_DebugSettings::Initialize() FCogDebug::SetIsFilteringBySelection(GetWorld(), Config->Data.bIsFilteringBySelection); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_DebugSettings::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_DebugSettings::PreSaveConfig() { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp index d9d4059..1f8b8d7 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp @@ -27,14 +27,6 @@ void FCogEngineWindow_Metrics::RenderHelp() ); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Metrics::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Metrics::PreSaveConfig() { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp index 3b8f4c7..759f4e6 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp @@ -1,6 +1,7 @@ #include "CogEngineWindow_NetEmulation.h" #include "CogEngineWindow_Stats.h" +#include "CogImguiHelper.h" #include "CogWindowWidgets.h" #include "Engine/Engine.h" #include "Engine/NetConnection.h" @@ -16,6 +17,25 @@ void FCogEngineWindow_NetEmulation::RenderHelp() ImGui::Text("This window is used to configure the network emulation."); } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_NetEmulation::Initialize() +{ + Super::Initialize(); + + Config = GetConfig(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_NetEmulation::RenderContextMenu() +{ + Config->RenderColorConfig(); + Config->RenderPingConfig(); + Config->RenderPacketLossConfig(); + + ImGui::Separator(); + FCogWindow::RenderContextMenu(); +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_NetEmulation::RenderContent() { @@ -42,7 +62,7 @@ void FCogEngineWindow_NetEmulation::DrawStats() const float Ping = PlayerState->GetPingInMilliseconds(); ImGui::Text("Ping "); ImGui::SameLine(); - ImGui::TextColored(FCogEngineWindow_Stats::GetPingColor(Ping), "%0.0fms", Ping); + ImGui::TextColored(Config->GetPingColor(Ping), "%0.0fms", Ping); } if (UNetConnection* Connection = PlayerController->GetNetConnection()) @@ -50,12 +70,12 @@ void FCogEngineWindow_NetEmulation::DrawStats() const float OutPacketLost = Connection->GetOutLossPercentage().GetAvgLossPercentage() * 100.0f; ImGui::Text("Packet Loss Out "); ImGui::SameLine(); - ImGui::TextColored(FCogEngineWindow_Stats::GetPacketLossColor(OutPacketLost), "%0.0f%%", OutPacketLost); + ImGui::TextColored(Config->GetPacketLossColor(OutPacketLost), "%0.0f%%", OutPacketLost); const float InPacketLost = Connection->GetInLossPercentage().GetAvgLossPercentage() * 100.0f; ImGui::Text("Packet Loss In "); ImGui::SameLine(); - ImGui::TextColored(FCogEngineWindow_Stats::GetPacketLossColor(InPacketLost), "%0.0f%%", InPacketLost); + ImGui::TextColored(Config->GetPacketLossColor(InPacketLost), "%0.0f%%", InPacketLost); } } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetImGui.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetImGui.cpp index 225d22d..3733926 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetImGui.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_NetImGui.cpp @@ -76,13 +76,6 @@ void FCogEngineWindow_NetImgui::Shutdown() CloseServer(); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_NetImgui::ResetConfig() -{ - Super::ResetConfig(); - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_NetImgui::RenderHelp() { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp index 06f105d..ab1b21e 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp @@ -1,8 +1,10 @@ #include "CogEngineWindow_OutputLog.h" #include "CogDebugHelper.h" +#include "CogImguiHelper.h" #include "CogWindowWidgets.h" #include "Engine/Engine.h" +#include "HAL/PlatformApplicationMisc.h" #include "Misc/StringBuilder.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -25,14 +27,6 @@ void FCogEngineWindow_OutputLog::RenderHelp() ); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_OutputLog::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_OutputLog::Clear() { @@ -61,7 +55,6 @@ void FCogEngineWindow_OutputLog::AddLog(const TCHAR* Message, ELogVerbosity::Typ TextBuffer.append(Format.GetData(), Format.GetData() + Format.Len()); LineInfo.End = TextBuffer.size(); - } //-------------------------------------------------------------------------------------------------------------------------- @@ -70,9 +63,9 @@ void FCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInf ImU32 Color; switch (LineInfo.Verbosity) { - case ELogVerbosity::Error: Color = IM_COL32(255, 0, 0, 255); break; - case ELogVerbosity::Warning: Color = IM_COL32(255, 200, 0, 255); break; - default: Color = IM_COL32(200, 200, 200, 255); break; + case ELogVerbosity::Error: Color = FCogImguiHelper::ToImColor(Config->ErrorColor); break; + case ELogVerbosity::Warning: Color = FCogImguiHelper::ToImColor(Config->WarningColor); break; + default: Color = FCogImguiHelper::ToImColor(Config->DefaultColor); break; } ImGui::PushStyleColor(ImGuiCol_Text, Color); @@ -132,21 +125,37 @@ void FCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInf ImGui::PopStyleColor(); } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_OutputLog::Copy() const +{ + const auto Buffer = StringCast(TextBuffer.c_str()); + const wchar_t* BufferData = Buffer.Get(); + if (BufferData == nullptr) + { return; } + + FStringBuilderBase StringBuilder; + for (const FLineInfo& LineInfo : LineInfos) + { + StringBuilder.Append(FString::Printf(TEXT("[%3d] [%s] [%s] "), LineInfo.Frame, *LineInfo.Category.ToString(), ToString(LineInfo.Verbosity))); + StringBuilder.Append(BufferData + LineInfo.Start, LineInfo.End - LineInfo.Start); + StringBuilder.Append("\n"); + }; + + FPlatformApplicationMisc::ClipboardCopy(StringBuilder.ToString()); +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_OutputLog::RenderContent() { Super::RenderContent(); - bool ClearPressed = false; - bool CopyPressed = false; - if (ImGui::BeginMenuBar()) { if (ImGui::BeginMenu("Options")) { if (ImGui::MenuItem("Copy")) { - ImGui::LogToClipboard(); + Copy(); } ImGui::Separator(); @@ -156,6 +165,20 @@ void FCogEngineWindow_OutputLog::RenderContent() ImGui::Checkbox("Show Verbosity", &Config->ShowVerbosity); ImGui::Checkbox("Show As Table", &Config->ShowAsTable); + ImGui::Separator(); + + constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf; + FCogImguiHelper::ColorEdit4("Default Color", Config->DefaultColor, ColorEditFlags); + FCogImguiHelper::ColorEdit4("Warning Color", Config->WarningColor, ColorEditFlags); + FCogImguiHelper::ColorEdit4("Error Color", Config->ErrorColor, ColorEditFlags); + + ImGui::Separator(); + + if (ImGui::Button("Reset Settings", ImVec2(-1, 0))) + { + ResetConfig(); + } + ImGui::EndMenu(); } @@ -247,8 +270,6 @@ void FCogEngineWindow_OutputLog::RenderContent() if (LineInfo.Verbosity <= (ELogVerbosity::Type)Config->VerbosityFilter) { - const char* LineStart = BufferStart + LineInfo.Start; - const char* LineEnd = BufferStart + LineInfo.End; DrawRow(BufferStart, LineInfo, IsTableShown); } } @@ -292,6 +313,11 @@ void FCogEngineWindow_OutputLog::RenderContent() Clear(); } + if (ImGui::MenuItem("Copy")) + { + Copy(); + } + ImGui::EndPopup(); } } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp index 937a066..dc3e344 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp @@ -38,8 +38,6 @@ void FCogEngineWindow_Plots::ResetConfig() { Super::ResetConfig(); - Config->Reset(); - RefreshPlotSettings(); } diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp index bbfa680..836dca4 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp @@ -60,14 +60,6 @@ void FCogEngineWindow_Selection::Shutdown() { } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Selection::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Selection::PreSaveConfig() { @@ -298,17 +290,23 @@ void FCogEngineWindow_Selection::TickSelectionMode() //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Selection::RenderMainMenuWidget() { - if (ImGui::MenuItem("Pick")) + ImGui::PushStyleVarX(ImGuiStyleVar_ItemSpacing, 0); + ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0)); + if (FCogWindowWidgets::PickButton("##Pick", ImVec2(20, 20))) { GetOwner()->SetActivateSelectionMode(true); HackWaitInputRelease(); } - RenderPickButtonTooltip(); - //TODO: Could be replaced by a BeginMenu + ImGui::PopStyleColor(); + ImGui::PopStyleVar(); + + RenderPickButtonTooltip(); ImGui::SetNextItemWidth(ImGui::GetFontSize() * 15); AActor* NewSelection = nullptr; + + //TODO: Could be replaced by a BeginMenu if (FCogWindowWidgets::MenuActorsCombo( "MenuActorSelection", NewSelection, @@ -317,7 +315,7 @@ void FCogEngineWindow_Selection::RenderMainMenuWidget() Config->SelectedClassIndex, &Filter, GetLocalPlayerPawn(), - [this](AActor& Actor) { RenderActorContextMenu(Actor); })) + [this](AActor& Actor) { RenderActorContextMenu(Actor); })) { SetGlobalSelection(NewSelection); } @@ -338,9 +336,11 @@ void FCogEngineWindow_Selection::SetGlobalSelection(AActor* Value) const //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Selection::RenderPickButtonTooltip() { - if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) + if (FCogWindowWidgets::BeginItemTooltipWrappedText()) { const FString Shortcut = FCogImguiInputHelper::KeyInfoToString(GetOwner()->GetSettings()->ToggleSelectionShortcut); - ImGui::SetTooltip("Enter picking mode to pick an actor on screen. %s", TCHAR_TO_ANSI(*Shortcut)); + 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(); } } \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp index e913edc..ac3ee81 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp @@ -1,5 +1,6 @@ #include "CogEngineWindow_Stats.h" +#include "CogImguiHelper.h" #include "CogWindowWidgets.h" #include "Engine/Engine.h" #include "Engine/NetConnection.h" @@ -8,9 +9,7 @@ #include "GameFramework/PlayerController.h" #include "GameFramework/PlayerState.h" -ImVec4 StatRedColor(1.0f, 0.4f, 0.3f, 1.0f); -ImVec4 StatOrangeColor(1.0f, 0.7f, 0.4f, 1.0f); -ImVec4 StatGreenColor(0.5f, 1.0f, 0.6f, 1.0f); + //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Stats::Initialize() @@ -19,6 +18,8 @@ void FCogEngineWindow_Stats::Initialize() bHasWidget = true; bIsWidgetVisible = true; + + Config = GetConfig(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -29,6 +30,15 @@ void FCogEngineWindow_Stats::RenderHelp() ); } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_Stats::RenderContextMenu() +{ + Config->RenderAllConfigs(); + + ImGui::Separator(); + FCogWindow::RenderContextMenu(); +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Stats::RenderContent() { @@ -37,7 +47,7 @@ void FCogEngineWindow_Stats::RenderContent() extern ENGINE_API float GAverageFPS; ImGui::Text("FPS "); ImGui::SameLine(); - ImGui::TextColored(GetFpsColor(GAverageFPS), "%0.0f", GAverageFPS); + ImGui::TextColored(Config->GetFpsColor(GAverageFPS), "%0.0f", GAverageFPS); if (const APlayerController* PlayerController = GetLocalPlayerController()) { @@ -46,7 +56,7 @@ void FCogEngineWindow_Stats::RenderContent() const float Ping = PlayerState->GetPingInMilliseconds(); ImGui::Text("Ping "); ImGui::SameLine(); - ImGui::TextColored(GetPingColor(Ping), "%0.0fms", Ping); + ImGui::TextColored(Config->GetPingColor(Ping), "%0.0fms", Ping); } if (const UNetConnection* Connection = PlayerController->GetNetConnection()) @@ -54,12 +64,12 @@ void FCogEngineWindow_Stats::RenderContent() const float OutPacketLost = Connection->GetOutLossPercentage().GetAvgLossPercentage() * 100.0f; ImGui::Text("Packet Loss Out "); ImGui::SameLine(); - ImGui::TextColored(GetPacketLossColor(OutPacketLost), "%0.0f%%", OutPacketLost); + ImGui::TextColored(Config->GetPacketLossColor(OutPacketLost), "%0.0f%%", OutPacketLost); const float InPacketLost = Connection->GetInLossPercentage().GetAvgLossPercentage() * 100.0f; ImGui::Text("Packet Loss In "); ImGui::SameLine(); - ImGui::TextColored(GetPacketLossColor(InPacketLost), "%0.0f%%", InPacketLost); + ImGui::TextColored(Config->GetPacketLossColor(InPacketLost), "%0.0f%%", InPacketLost); } } } @@ -68,129 +78,169 @@ void FCogEngineWindow_Stats::RenderContent() void FCogEngineWindow_Stats::RenderMainMenuWidget() { const APlayerController* PlayerController = GetLocalPlayerController(); - const UNetConnection* Connection = PlayerController != nullptr ? PlayerController->GetNetConnection() : nullptr; - RenderMainMenuWidgetFramerate(FCogWindowWidgets::GetFontWidth() * 8); - RenderMainMenuWidgetPing(Connection != nullptr ? FCogWindowWidgets::GetFontWidth() * 7 : 0.0f); - RenderMainMenuWidgetPacketLoss(Connection != nullptr ? FCogWindowWidgets::GetFontWidth() * 7 : 0.0f); + RenderMainMenuWidgetFrameRate(); + + const UNetConnection* Connection = PlayerController != nullptr ? PlayerController->GetNetConnection() : nullptr; + if (Connection != nullptr) + { + RenderMainMenuWidgetPing(); + + RenderMainMenuWidgetPacketLoss(); + } } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Stats::RenderMainMenuWidgetFramerate(const float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidgetFrameRate() { extern ENGINE_API float GAverageFPS; - const int32 Fps = (int32)GAverageFPS; + const int32 Fps = static_cast(GAverageFPS); - ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0)); - ImGui::PushStyleColor(ImGuiCol_Text, GetFpsColor(Fps)); - const bool Open = ImGui::BeginMenu(TCHAR_TO_ANSI(*FString::Printf(TEXT("%3dfps###FramerateButton"), Fps))); - ImGui::PopStyleColor(2); + ImGui::PushStyleColor(ImGuiCol_Text, Config->GetFpsColor(Fps)); + const bool Open = ImGui::BeginMenu(TCHAR_TO_ANSI(*FString::Printf(TEXT("%3dfps###FrameRateButton"), Fps))); + const float Width = ImGui::GetItemRectSize().x; + ImGui::PopStyleColor(1); - if (Open) + if (ImGui::BeginPopupContextItem()) { - ImGui::Text("Fps"); - ImGui::SameLine(); - - int32 MaxFps = GEngine->GetMaxFPS(); - TArray Values{ 0, 10, 20, 30, 60, 120 }; - if (FCogWindowWidgets::MultiChoiceButtonsInt(Values, MaxFps, ImVec2(3.5f * FCogWindowWidgets::GetFontWidth(), 0))) - { - GEngine->SetMaxFPS(MaxFps); - } - - ImGui::EndMenu(); + Config->RenderColorConfig(); + Config->RenderFrameRateConfig(); + Super::RenderContextMenu(); + ImGui::EndPopup(); } - ImGui::SetItemTooltip("Framerate"); + if (Open == false) + { + ImGui::SetItemTooltip("Frame Rate"); + } + + if (Open) + { + const int32 MaxFps = GEngine->GetMaxFPS(); + for (int32 i = 0; i < Config->FrameRates.Num(); ++i) + { + ImGui::PushID(i); + const float Value = Config->FrameRates[i]; + const auto ValueText = StringCast(*FCogWindowWidgets::FormatSmallFloat(Value)); + if (ImGui::Selectable(ValueText.Get(), Value == MaxFps, ImGuiSelectableFlags_None, ImVec2(Width, 0))) + { + GEngine->SetMaxFPS(Value); + } + ImGui::PopID(); + } + + ImGui::EndMenu(); + } } + //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Stats::RenderMainMenuWidgetPing(const float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidgetPing() { const APlayerController* PlayerController = GetLocalPlayerController(); const APlayerState* PlayerState = PlayerController != nullptr ? PlayerController->GetPlayerState() : nullptr; if (PlayerState == nullptr) + { return; } + + const int32 Ping = static_cast(PlayerState->GetPingInMilliseconds()); + ImGui::PushStyleColor(ImGuiCol_Text, Config->GetPingColor(Ping)); + const bool Open = ImGui::BeginMenu(TCHAR_TO_ANSI(*FString::Printf(TEXT("%3dms###PingButton"), Ping))); + const float Width = ImGui::GetItemRectSize().x; + ImGui::PopStyleColor(1); + + if (ImGui::BeginPopupContextItem()) { - return; + Config->RenderColorConfig(); + Config->RenderPingConfig(); + Super::RenderContextMenu(); + ImGui::EndPopup(); } - const float Ping = PlayerState->GetPingInMilliseconds(); - ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0)); - ImGui::PushStyleColor(ImGuiCol_Text, GetPingColor(Ping)); - const bool Open = ImGui::BeginMenu(TCHAR_TO_ANSI(*FString::Printf(TEXT("%3dms###PingButton"), (int32)Ping))); - ImGui::PopStyleColor(2); - ImGui::SetItemTooltip("Ping"); - + if (Open == false) + { + ImGui::SetItemTooltip("Ping"); + } + #if DO_ENABLE_NET_TEST if (Open) { FWorldContext& WorldContext = GEngine->GetWorldContextFromWorldChecked(GetWorld()); if (WorldContext.ActiveNetDrivers.Num() > 0) { - ImGui::Text("Ping"); - ImGui::SameLine(); - const FNamedNetDriver* SelectedNetDriver = &WorldContext.ActiveNetDrivers[0]; FPacketSimulationSettings Settings = SelectedNetDriver->NetDriver->PacketSimulationSettings; - TArray Values{ 0, 50, 100, 200, 500, 1000 }; - if (FCogWindowWidgets::MultiChoiceButtonsInt(Values, Settings.PktIncomingLagMin, ImVec2(4.5f * FCogWindowWidgets::GetFontWidth(), 0))) + + for (int32 i = 0; i < Config->Pings.Num(); ++i) { - SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); + ImGui::PushID(i); + const float Value = Config->Pings[i]; + const auto ValueText = StringCast(*FCogWindowWidgets::FormatSmallFloat(Value)); + if (ImGui::Selectable(ValueText.Get(), Value == Settings.PktIncomingLagMin, ImGuiSelectableFlags_None, ImVec2(Width, 0))) + { + Settings.PktIncomingLagMin = Value; + SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); + } + + ImGui::PopID(); } } - ImGui::EndMenu(); } #endif //DO_ENABLE_NET_TEST - } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss(const float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss() { const APlayerController* PlayerController = GetLocalPlayerController(); const UNetConnection* Connection = PlayerController != nullptr ? PlayerController->GetNetConnection() : nullptr; if (Connection == nullptr) - { - return; - } + { return; } const float OutPacketLost = Connection->GetOutLossPercentage().GetAvgLossPercentage() * 100.0f; const float InPacketLost = Connection->GetInLossPercentage().GetAvgLossPercentage() * 100.0f; const float TotalPacketLost = (OutPacketLost + InPacketLost) / 2; - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); - ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0)); - ImGui::PushStyleColor(ImGuiCol_Text, GetPacketLossColor(TotalPacketLost)); + ImGui::PushStyleColor(ImGuiCol_Text, Config->GetPacketLossColor(TotalPacketLost)); + const bool Open = ImGui::BeginMenu(TCHAR_TO_ANSI(*FString::Printf(TEXT("%2d%% ###PacketLossButton"), (int32)TotalPacketLost))); + const float Width = ImGui::GetItemRectSize().x; + ImGui::PopStyleColor(1); - if (ImGui::Button(TCHAR_TO_ANSI(*FString::Printf(TEXT("%2d%%###PacketLossButton"), (int32)TotalPacketLost)), ImVec2(Width, 0.0f))) + if (ImGui::BeginPopupContextItem()) { - ImGui::OpenPopup("PacketLossPopup"); + Config->RenderColorConfig(); + Config->RenderPacketLossConfig(); + Super::RenderContextMenu(); + ImGui::EndPopup(); } - - ImGui::PopStyleColor(2); - ImGui::PopStyleVar(2); - - ImGui::SetItemTooltip("Packet Loss"); - + + if (Open == false) + { + ImGui::SetItemTooltip("Packet Loss"); + } + #if DO_ENABLE_NET_TEST - if (ImGui::BeginPopup("PacketLossPopup")) + if (Open) { FWorldContext& WorldContext = GEngine->GetWorldContextFromWorldChecked(GetWorld()); if (WorldContext.ActiveNetDrivers.Num() > 0) { - ImGui::Text("Packet Loss"); - ImGui::SameLine(); - const FNamedNetDriver* SelectedNetDriver = &WorldContext.ActiveNetDrivers[0]; FPacketSimulationSettings Settings = SelectedNetDriver->NetDriver->PacketSimulationSettings; - TArray Values{ 0, 5, 10, 20, 30, 40, 50 }; - if (FCogWindowWidgets::MultiChoiceButtonsInt(Values, Settings.PktIncomingLoss, ImVec2(3.5f * FCogWindowWidgets::GetFontWidth(), 0))) + for (int32 i = 0; i < Config->PacketLosses.Num(); ++i) { - Settings.PktLoss = Settings.PktIncomingLoss; - SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); + ImGui::PushID(i); + const float Value = Config->PacketLosses[i]; + const auto ValueText = StringCast(*FCogWindowWidgets::FormatSmallFloat(Value)); + if (ImGui::Selectable(ValueText.Get(), Value == Settings.PktIncomingLagMin, ImGuiSelectableFlags_None, ImVec2(Width, 0))) + { + Settings.PktIncomingLoss = Value; + Settings.PktLoss = Settings.PktIncomingLoss; + SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); + } + + ImGui::PopID(); } } ImGui::EndPopup(); @@ -198,50 +248,98 @@ void FCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss(const float Width) #endif //DO_ENABLE_NET_TEST } + //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogEngineWindow_Stats::GetFpsColor(const float Value, const float Good /*= 50.0f*/, const float Medium /*= 30.0f*/) +ImVec4 UCogEngineWindowConfig_Stats::GetFpsColor(const float Value) const { - if (Value > Good) - { - return StatGreenColor; - } + if (Value > GoodFrameRate) + { return FCogImguiHelper::ToImVec4(GoodColor); } - if (Value > Medium) - { - return StatOrangeColor; - } + if (Value > MediumFrameRate) + { return FCogImguiHelper::ToImVec4(MediumColor); } - return StatRedColor; + return FCogImguiHelper::ToImVec4(BadColor); } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogEngineWindow_Stats::GetPingColor(const float Value, const float Good /*= 100.0f*/, const float Medium /*= 200.0f*/) +ImVec4 UCogEngineWindowConfig_Stats::GetPingColor(const float Value) const { - if (Value > Medium) - { - return StatRedColor; - } + if (Value > MediumPing) + { return FCogImguiHelper::ToImVec4(BadColor); } - if (Value > Good) - { - return StatOrangeColor; - } + if (Value > GoodPing) + { return FCogImguiHelper::ToImVec4(MediumColor); } - return StatGreenColor; + return FCogImguiHelper::ToImVec4(GoodColor); } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogEngineWindow_Stats::GetPacketLossColor(const float Value, const float Good /*= 10.0f*/, const float Medium /*= 20.0f*/) +ImVec4 UCogEngineWindowConfig_Stats::GetPacketLossColor(const float Value) const { - if (Value > Medium) - { - return StatRedColor; - } + if (Value > MediumPacketLoss) + { return FCogImguiHelper::ToImVec4(BadColor); } - if (Value > Good) - { - return StatOrangeColor; - } + if (Value > GoodPacketLoss) + { return FCogImguiHelper::ToImVec4(MediumColor); } - return StatGreenColor; -} \ No newline at end of file + return FCogImguiHelper::ToImVec4(GoodColor); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindowConfig_Stats::RenderAllConfigs() +{ + RenderColorConfig(); + RenderFrameRateConfig(); + RenderPingConfig(); + RenderPacketLossConfig(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindowConfig_Stats::RenderColorConfig() +{ + if (ImGui::CollapsingHeader("Display", ImGuiTreeNodeFlags_DefaultOpen)) + { + constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf; + FCogImguiHelper::ColorEdit4("Good Color", GoodColor, ColorEditFlags); + ImGui::SetItemTooltip("Color of a stat with a good value."); + + FCogImguiHelper::ColorEdit4("Medium Color", MediumColor, ColorEditFlags); + ImGui::SetItemTooltip("Color of a stat with a medium value."); + + FCogImguiHelper::ColorEdit4("Bad Color", BadColor, ColorEditFlags); + ImGui::SetItemTooltip("Color of a stat with a bad value."); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindowConfig_Stats::RenderFrameRateConfig() +{ + if (ImGui::CollapsingHeader("Frame Rate", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::InputInt("Good Frame Rate", &GoodFrameRate); + ImGui::InputInt("Medium Frame Rate", &MediumFrameRate); + FCogWindowWidgets::IntArray("Max Frame Rate", FrameRates, 10, ImVec2(0, ImGui::GetFontSize() * 10)); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindowConfig_Stats::RenderPingConfig() +{ + if (ImGui::CollapsingHeader("Ping", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::InputInt("Good Ping", &GoodPing); + ImGui::InputInt("Medium Ping", &MediumPing); + FCogWindowWidgets::IntArray("Ping Emulation", Pings, 10, ImVec2(0, ImGui::GetFontSize() * 10)); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindowConfig_Stats::RenderPacketLossConfig() +{ + if (ImGui::CollapsingHeader("Packet Loss", ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::InputInt("Good Packet Loss", &GoodPacketLoss); + ImGui::InputInt("Medium Packet Loss", &MediumPacketLoss); + FCogWindowWidgets::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 6f36ffd..fb34b0d 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp @@ -1,6 +1,7 @@ #include "CogEngineWindow_TimeScale.h" #include "CogEngineReplicator.h" +#include "CogImguiHelper.h" #include "CogWindowWidgets.h" #include "Engine/Engine.h" #include "Engine/World.h" @@ -10,14 +11,10 @@ void FCogEngineWindow_TimeScale::Initialize() { Super::Initialize(); - TimingScales.Add(0.00f); - TimingScales.Add(0.01f); - TimingScales.Add(0.10f); - TimingScales.Add(0.50f); - TimingScales.Add(1.00f); - TimingScales.Add(2.00f); - TimingScales.Add(5.00f); - TimingScales.Add(10.0f); + bHasWidget = true; + bIsWidgetVisible = true; + + Config = GetConfig(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -41,10 +38,84 @@ void FCogEngineWindow_TimeScale::RenderContent() return; } + RenderTimeScaleChoices(Replicator); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_TimeScale::RenderContextMenu() +{ + if (IsWindowRenderedInMainMenu() == false) + { + ImGui::Checkbox("Inline", &Config->Inline); + } + + 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)); + + ImGui::Separator(); + FCogWindow::RenderContextMenu(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_TimeScale::RenderMainMenuWidget() +{ + Super::RenderMainMenuWidget(); + + ACogEngineReplicator* Replicator = ACogEngineReplicator::GetLocalReplicator(*GetWorld()); + if (Replicator == nullptr) + { + ImGui::TextDisabled("Invalid Replicator"); + return; + } + + const float CurrentValue = Replicator->GetTimeDilation(); + if (CurrentValue != 1.0f) + { + ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Config->TimeScaleModifiedColor)); + } + + const auto CurrentValueText = StringCast(*FString::Printf(TEXT("x%g"), CurrentValue)); + const bool Open = ImGui::BeginMenu(CurrentValueText.Get()); + + if (CurrentValue != 1) + { + ImGui::PopStyleColor(); + } + + if (ImGui::BeginPopupContextItem()) + { + RenderContextMenu(); + ImGui::EndPopup(); + } + + if (Open) + { + for (int32 i = 0; i < Config->TimeScales.Num(); ++i) + { + const float Value = Config->TimeScales[i]; + const auto ValueText = StringCast(*FString::Printf(TEXT("%g"), Value)); + if (ImGui::Selectable(ValueText.Get(), Value == Replicator->GetTimeDilation())) + { + Replicator->SetTimeDilation(Value); + } + } + + ImGui::EndMenu(); + } + else + { + ImGui::SetItemTooltip("Time Scale"); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogEngineWindow_TimeScale::RenderTimeScaleChoices(ACogEngineReplicator* Replicator) +{ float Value = Replicator->GetTimeDilation(); - if (FCogWindowWidgets::MultiChoiceButtonsFloat(TimingScales, Value, ImVec2(3.5f * FCogWindowWidgets::GetFontWidth(), 0))) + if (FCogWindowWidgets::MultiChoiceButtonsFloat(Config->TimeScales, Value, ImVec2(3.5f * FCogWindowWidgets::GetFontWidth(), 0), Config->Inline)) { Replicator->SetTimeDilation(Value); } - -} +} \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Cheats.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Cheats.h index 712c04d..0ebc474 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Cheats.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Cheats.h @@ -23,8 +23,6 @@ protected: virtual void GameTick(float DeltaTime) override; - virtual void ResetConfig() override; - virtual void RenderHelp() override; virtual void RenderContent() override; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h index 9cca48b..d459b4e 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h @@ -25,8 +25,6 @@ public: protected: - virtual void ResetConfig() override; - virtual void RenderHelp() override; virtual void RenderContent() override; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionViewer.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionViewer.h index aea5efa..1c21937 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionViewer.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionViewer.h @@ -20,8 +20,6 @@ public: protected: - virtual void ResetConfig() override; - virtual void RenderHelp() override; virtual void RenderContent() override; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Console.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Console.h index 0748bca..277ff01 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Console.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Console.h @@ -11,18 +11,20 @@ class COGENGINE_API FCogEngineWindow_Console : public FCogWindow { typedef FCogWindow Super; -public: - protected: virtual void RenderHelp() override; virtual void Initialize() override; + virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; + virtual void RenderMainMenuWidget() override; virtual void RenderContent() override; + virtual void RenderTick(float DeltaTime) override; + private: @@ -31,6 +33,8 @@ private: void RenderMenu(); void RenderInput(); + void SelectNextCommand(); + void SelectPreviousCommand(); int OnTextInputCallback(ImGuiInputTextCallbackData* InData); @@ -38,15 +42,15 @@ private: void RenderCommandList(); - void RenderCommand(const FString& CommandName, int32 Index); + void RenderCommand(const FString& CommandName, int32 Index, float RegionMinY, float RegionMaxY); void RefreshCommandList(); - - void RenderCommandHelp(); + + void ActivateInputText() const; void ExecuteCommand(const FString& InCommand); - int32 SelectedCommandIndex = -1; + int32 SelectedCommandIndex = INDEX_NONE; TArray CommandList; @@ -56,18 +60,20 @@ private: bool bScroll = false; - bool bRequestInputFocus = false; - bool bIsWindowFocused = false; - bool bPopupCommandListOnWidgetMode = false; - - ImGuiID InputIdOnWidgetMode = 0; - - bool bIsRenderingWidget = false; - bool bSetBufferToSelectedCommand = false; - + + bool bIsWidgetMode = false; + + ImGuiID InputTextId = 0; + + bool WidgetMode_OpenCommandList = false; + + ImVec2 WidgetMode_CommandListPosition = ImVec2(0, 0); + + bool WidgetMode_IsTextInputActive = false; + TWeakObjectPtr Config; }; @@ -93,6 +99,9 @@ public: UPROPERTY(Config) bool UseClipper = false; + + UPROPERTY(Config) + bool ShowHelp = true; UPROPERTY(Config) int32 NumHistoryCommands = 10; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h index f56fd9d..324fb29 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h @@ -17,8 +17,6 @@ public: protected: - virtual void ResetConfig() override; - virtual void RenderHelp() override; virtual void PreSaveConfig() override; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h index 6d97def..1646b26 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h @@ -19,8 +19,6 @@ public: protected: - virtual void ResetConfig() override; - virtual void PreSaveConfig() override; virtual void RenderHelp() override; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h index 8651c59..7e94d1e 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h @@ -3,6 +3,8 @@ #include "CoreMinimal.h" #include "CogWindow.h" +class UCogEngineWindowConfig_Stats; + class COGENGINE_API FCogEngineWindow_NetEmulation : public FCogWindow { typedef FCogWindow Super; @@ -11,12 +13,15 @@ protected: virtual void RenderHelp() override; + virtual void Initialize() override; + + virtual void RenderContextMenu() override; + virtual void RenderContent() override; virtual void DrawStats(); virtual void DrawControls(); -private: - + TWeakObjectPtr Config; }; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetImGui.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetImGui.h index 07e7db7..b326296 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetImGui.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_NetImGui.h @@ -27,13 +27,11 @@ public: protected: - virtual void ResetConfig() override; - virtual void RenderHelp() override; virtual void RenderContent() override; - virtual void RenderTick(float DeltaTime); + virtual void RenderTick(float DeltaTime) override; void ConnectTo(); @@ -41,8 +39,6 @@ protected: void Disconnect(); - void TryStartup(); - void RunServer(); void CloseServer(); diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h index 3cb9f9a..0df835e 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h @@ -7,7 +7,6 @@ #include "Misc/OutputDevice.h" #include "CogEngineWindow_OutputLog.generated.h" -class FCogEngineWindow_OutputLog; class UCogEngineConfig_OutputLog; //-------------------------------------------------------------------------------------------------------------------------- @@ -17,7 +16,7 @@ public: friend class FCogEngineWindow_OutputLog; FCogLogOutputDevice(); - ~FCogLogOutputDevice(); + virtual ~FCogLogOutputDevice() override; virtual void Serialize(const TCHAR* Message, ELogVerbosity::Type Verbosity, const FName& Category) override; @@ -37,12 +36,12 @@ public: void Clear(); + void Copy() const; + protected: virtual void RenderHelp() override; - virtual void ResetConfig() override; - virtual void RenderContent() override; private: @@ -66,7 +65,7 @@ private: FCogLogOutputDevice OutputDevice; - TObjectPtr Config = nullptr; + TWeakObjectPtr Config = nullptr; }; //-------------------------------------------------------------------------------------------------------------------------- @@ -95,6 +94,15 @@ public: UPROPERTY(Config) int32 VerbosityFilter = ELogVerbosity::VeryVerbose; + UPROPERTY(Config) + FColor DefaultColor = FColor::White; + + UPROPERTY(Config) + FColor WarningColor = FColor::White; + + UPROPERTY(Config) + FColor ErrorColor = FColor::White; + virtual void Reset() override { Super::Reset(); @@ -105,5 +113,8 @@ public: ShowVerbosity = false; ShowAsTable = false; VerbosityFilter = ELogVerbosity::VeryVerbose; + DefaultColor = FColor(200, 200, 200, 255); + WarningColor = FColor(255, 200, 0, 255); + ErrorColor = FColor(255, 0, 0, 255); } }; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h index 949c22e..d478301 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h @@ -35,8 +35,6 @@ protected: virtual void TryReapplySelection() const; - virtual void ResetConfig() override; - virtual void PreSaveConfig() override; virtual void RenderHelp() override; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Stats.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Stats.h index 6beee65..e8909f1 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Stats.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Stats.h @@ -2,32 +2,113 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogEngineWindow_Stats.generated.h" +class UCogEngineWindowConfig_Stats; + +//-------------------------------------------------------------------------------------------------------------------------- class COGENGINE_API FCogEngineWindow_Stats : public FCogWindow { typedef FCogWindow Super; -public: - - static ImVec4 GetFpsColor(float Value, float Good = 50.0f, float Medium = 30.0f); - - static ImVec4 GetPingColor(float Value, float Good = 100.0f, float Medium = 200.0f); - - static ImVec4 GetPacketLossColor(float Value, float Good = 10.0f, float Medium = 20.0f); - protected: virtual void Initialize() override; virtual void RenderHelp() override; + virtual void RenderContextMenu() override; + virtual void RenderContent() override; virtual void RenderMainMenuWidget() override; - virtual void RenderMainMenuWidgetPacketLoss(float Width); + virtual void RenderMainMenuWidgetPacketLoss(); - virtual void RenderMainMenuWidgetPing(float Width); + virtual void RenderMainMenuWidgetPing(); - virtual void RenderMainMenuWidgetFramerate(float Width); + virtual void RenderMainMenuWidgetFrameRate(); + + TWeakObjectPtr Config; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogEngineWindowConfig_Stats : public UCogCommonConfig +{ + GENERATED_BODY() + +public: + + virtual void Reset() override + { + UCogCommonConfig::Reset(); + + GoodColor = FColor(30, 255, 60, 255); + MediumColor = FColor(255, 200,0, 255); + BadColor = FColor(255, 80, 80, 255); + + FrameRates = { 0, 10, 20, 30, 60, 120 }; + Pings = { 0, 50, 100, 200, 500, 1000 }; + PacketLosses = { 0, 5, 10, 20, 30, 40, 50 }; + + GoodFrameRate = 60; + MediumFrameRate = 30; + GoodPing = 100; + MediumPing = 200; + GoodPacketLoss = 5; + MediumPacketLoss = 10; + } + + ImVec4 GetFpsColor(float Value) const; + + ImVec4 GetPingColor(float Value) const; + + ImVec4 GetPacketLossColor(float Value) const; + + void RenderAllConfigs(); + + void RenderColorConfig(); + + void RenderFrameRateConfig(); + + void RenderPingConfig(); + + void RenderPacketLossConfig(); + + UPROPERTY(Config) + TArray FrameRates; + + UPROPERTY(Config) + int GoodFrameRate = 0; + + UPROPERTY(Config) + int MediumFrameRate = 0; + + UPROPERTY(Config) + TArray Pings; + + UPROPERTY(Config) + int GoodPing = 0; + + UPROPERTY(Config) + int MediumPing = 0; + + UPROPERTY(Config) + TArray PacketLosses; + + UPROPERTY(Config) + int GoodPacketLoss = 0; + + UPROPERTY(Config) + int MediumPacketLoss = 0; + + UPROPERTY(Config) + FColor GoodColor = FColor(); + + UPROPERTY(Config) + FColor MediumColor = FColor(); + + UPROPERTY(Config) + FColor BadColor = FColor(); }; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_TimeScale.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_TimeScale.h index 9c0b152..c84aa2f 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_TimeScale.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_TimeScale.h @@ -1,24 +1,62 @@ #pragma once #include "CoreMinimal.h" +#include "CogEngineReplicator.h" #include "CogWindow.h" +#include "CogEngineWindow_TimeScale.generated.h" +class UCogEngineWindowConfig_TimeScale; + +//-------------------------------------------------------------------------------------------------------------------------- class COGENGINE_API FCogEngineWindow_TimeScale : public FCogWindow { typedef FCogWindow Super; public: - - void Initialize(); + virtual void Initialize() override; protected: virtual void RenderHelp() override; virtual void RenderContent() override; + + virtual void RenderContextMenu() override; - TArray TimingScales; + virtual void RenderMainMenuWidget() override; -private: + virtual void RenderTimeScaleChoices(ACogEngineReplicator* Replicator); + TWeakObjectPtr Config; }; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogEngineWindowConfig_TimeScale : public UCogCommonConfig +{ + GENERATED_BODY() + +public: + + virtual void Reset() override + { + UCogCommonConfig::Reset(); + + TimeScale = 1.0f; + Inline = true; + TimeScales = { 0.00f, 0.01f, 0.10f, 0.50f, 1.00f, 2.00f, 5.00f, 10.0f }; + TimeScaleModifiedColor = FColor(255, 30, 210, 255); + } + + UPROPERTY(Config) + float TimeScale = 1.0f; + + UPROPERTY(Config) + TArray TimeScales; + + UPROPERTY(Config) + bool Inline = true; + + UPROPERTY(Config) + FColor TimeScaleModifiedColor = FColor(); +}; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImguiContext.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImguiContext.cpp index 182ba5e..fd8adf0 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImguiContext.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImguiContext.cpp @@ -14,6 +14,7 @@ #include "Framework/Application/SlateUser.h" #include "GameFramework/PlayerController.h" #include "GameFramework/PlayerInput.h" +#include "HAL/PlatformApplicationMisc.h" #include "imgui.h" #include "imgui_internal.h" #include "implot.h" @@ -31,7 +32,7 @@ FCogImGuiContextScope::FCogImGuiContextScope(FCogImguiContext& CogImguiContext) PrevContext = ImGui::GetCurrentContext(); PrevPlotContext = ImPlot::GetCurrentContext(); - ImGui::SetCurrentContext(CogImguiContext.ImGuiContext); + ImGui::SetCurrentContext(CogImguiContext.Context); ImPlot::SetCurrentContext(CogImguiContext.PlotContext); } @@ -53,7 +54,7 @@ FCogImGuiContextScope::~FCogImGuiContextScope() } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogImguiContext::bIsNetImguiInitialized = false; +bool FCogImguiContext::bIsNetImGuiInitialized = false; //-------------------------------------------------------------------------------------------------------------------------- void FCogImguiContext::Initialize() @@ -71,10 +72,10 @@ void FCogImguiContext::Initialize() GameViewport->AddViewportWidgetContent(InputCatcherWidget.ToSharedRef(), -TNumericLimits::Max()); } - ImGuiContext = ImGui::CreateContext(); + Context = ImGui::CreateContext(); PlotContext = ImPlot::CreateContext(); - ImGui::SetCurrentContext(ImGuiContext); - ImPlot::SetImGuiContext(ImGuiContext); + ImGui::SetCurrentContext(Context); + ImPlot::SetImGuiContext(Context); ImPlot::SetCurrentContext(PlotContext); ImGuiIO& IO = ImGui::GetIO(); @@ -121,6 +122,11 @@ void FCogImguiContext::Initialize() PlatformIO.Platform_SetWindowTitle = ImGui_SetWindowTitle; PlatformIO.Platform_SetWindowAlpha = ImGui_SetWindowAlpha; PlatformIO.Platform_RenderWindow = ImGui_RenderWindow; + + PlatformIO.Platform_ClipboardUserData = &ClipboardBuffer; + PlatformIO.Platform_GetClipboardTextFn = ImGui_GetClipboardTextFn; + PlatformIO.Platform_SetClipboardTextFn = ImGui_SetClipboardTextFn; + PlatformIO.Platform_OpenInShellFn = ImGui_OpenInShell; if (FSlateApplication::IsInitialized()) { @@ -143,10 +149,10 @@ void FCogImguiContext::Initialize() } #if NETIMGUI_ENABLED - if (bIsNetImguiInitialized == false) + if (bIsNetImGuiInitialized == false) { NetImgui::Startup(); - bIsNetImguiInitialized = true; + bIsNetImGuiInitialized = true; } #endif } @@ -154,16 +160,16 @@ void FCogImguiContext::Initialize() //-------------------------------------------------------------------------------------------------------------------------- void FCogImguiContext::Shutdown() { - FCogImGuiContextScope ImGuiContextScope(ImGuiContext, PlotContext); + FCogImGuiContextScope ImGuiContextScope(Context, PlotContext); //------------------------------------------------------------------ // NetImgui must be shutdown before imgui as it uses context hooks //------------------------------------------------------------------ #if NETIMGUI_ENABLED - if (bIsNetImguiInitialized) + if (bIsNetImGuiInitialized) { NetImgui::Shutdown(); - bIsNetImguiInitialized = false; + bIsNetImGuiInitialized = false; } #endif @@ -196,17 +202,17 @@ void FCogImguiContext::Shutdown() PlotContext = nullptr; } - if (ImGuiContext) + if (Context) { - ImGui::DestroyContext(ImGuiContext); - ImGuiContext = nullptr; + ImGui::DestroyContext(Context); + Context = nullptr; } } //-------------------------------------------------------------------------------------------------------------------------- void FCogImguiContext::OnDisplayMetricsChanged(const FDisplayMetrics& DisplayMetrics) const { - FCogImGuiContextScope ImGuiContextScope(ImGuiContext, PlotContext); + FCogImGuiContextScope ImGuiContextScope(Context, PlotContext); ImGuiPlatformIO& PlatformIO = ImGui::GetPlatformIO(); PlatformIO.Monitors.resize(0); @@ -234,7 +240,7 @@ void FCogImguiContext::OnDisplayMetricsChanged(const FDisplayMetrics& DisplayMet //-------------------------------------------------------------------------------------------------------------------------- bool FCogImguiContext::BeginFrame(float InDeltaTime) { - FCogImGuiContextScope ImGuiContextScope(ImGuiContext, PlotContext); + FCogImGuiContextScope ImGuiContextScope(Context, PlotContext); //------------------------------------------------------------------------------------------------------- // Skip the first frame, to let the main widget update its TickSpaceGeometry which is returned by the @@ -376,7 +382,7 @@ ImVec2 FCogImguiContext::GetImguiMousePos() //-------------------------------------------------------------------------------------------------------------------------- void FCogImguiContext::EndFrame() { - FCogImGuiContextScope ImGuiContextScope(ImGuiContext, PlotContext); + FCogImGuiContextScope ImGuiContextScope(Context, PlotContext); ImGui::Render(); //NetImgui::EndFrame(); @@ -646,6 +652,36 @@ void FCogImguiContext::ImGui_RenderWindow(ImGuiViewport* Viewport, void* Data) } } +//-------------------------------------------------------------------------------------------------------------------------- +const char* FCogImguiContext::ImGui_GetClipboardTextFn(ImGuiContext* InImGuiContext) +{ + TArray* ClipboardBuffer = static_cast*>(InImGuiContext->PlatformIO.Platform_ClipboardUserData); + if (ClipboardBuffer) + { + FString ClipboardText; + FPlatformApplicationMisc::ClipboardPaste(ClipboardText); + + ClipboardBuffer->SetNumUninitialized(FPlatformString::ConvertedLength(*ClipboardText)); + FPlatformString::Convert(reinterpret_cast(ClipboardBuffer->GetData()), ClipboardBuffer->Num(), *ClipboardText, ClipboardText.Len() + 1); + + return ClipboardBuffer->GetData(); + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogImguiContext::ImGui_SetClipboardTextFn(ImGuiContext* InImGuiContext, const char* ClipboardText) +{ + FPlatformApplicationMisc::ClipboardCopy(UTF8_TO_TCHAR(ClipboardText)); +} + +//-------------------------------------------------------------------------------------------------------------------------- + bool FCogImguiContext::ImGui_OpenInShell(ImGuiContext* Context, const char* Path) +{ + return FPlatformProcess::LaunchFileInDefaultExternalApplication(UTF8_TO_TCHAR(Path)); +} + //-------------------------------------------------------------------------------------------------------------------------- static APlayerController* GetLocalPlayerController(const UWorld* World) { @@ -688,7 +724,7 @@ static UPlayerInput* GetPlayerInput(const UWorld* World) //-------------------------------------------------------------------------------------------------------------------------- void FCogImguiContext::SetEnableInput(bool Value) { - FCogImGuiContextScope ImGuiContextScope(ImGuiContext, PlotContext); + FCogImGuiContextScope ImGuiContextScope(Context, PlotContext); bEnableInput = Value; @@ -805,7 +841,7 @@ void FCogImguiContext::SetDPIScale(float Value) //-------------------------------------------------------------------------------------------------------------------------- void FCogImguiContext::BuildFont() { - FCogImGuiContextScope ImGuiContextScope(ImGuiContext, PlotContext); + FCogImGuiContextScope ImGuiContextScope(Context, PlotContext); if (FontAtlasTexture != nullptr) { diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImguiHelper.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImguiHelper.cpp index 956bef6..b829150 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImguiHelper.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImguiHelper.cpp @@ -243,8 +243,14 @@ bool FCogImguiHelper::DragFVector2D(const char* Label, FVector2D& Vector, float //-------------------------------------------------------------------------------------------------------------------------- bool FCogImguiHelper::ColorEdit4(const char* Label, FColor& Color, ImGuiColorEditFlags Flags) { - FLinearColor Linear(Color); - const bool Result = ImGui::ColorEdit4(Label, &Linear.R, Flags); - Color = Linear.ToFColor(true); + ImColor c = ToImColor(Color); + const bool Result = ImGui::ColorEdit4(Label, &c.Value.x, Flags); + Color = ToFColor(c); return Result; } + +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogImguiHelper::ColorEdit4(const char* Label, FLinearColor& Color, ImGuiColorEditFlags Flags) +{ + return ImGui::ColorEdit4(Label, &Color.R, Flags); +} diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp index 341f918..291a0ad 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp @@ -287,17 +287,19 @@ EMouseCursor::Type FCogImguiInputHelper::ToSlateMouseCursor(ImGuiMouseCursor Mou { switch (MouseCursor) { - case ImGuiMouseCursor_Arrow: return EMouseCursor::Default; - case ImGuiMouseCursor_TextInput: return EMouseCursor::TextEditBeam; - case ImGuiMouseCursor_ResizeAll: return EMouseCursor::CardinalCross; - case ImGuiMouseCursor_ResizeNS: return EMouseCursor::ResizeUpDown; - case ImGuiMouseCursor_ResizeEW: return EMouseCursor::ResizeLeftRight; - case ImGuiMouseCursor_ResizeNESW: return EMouseCursor::ResizeSouthWest; - case ImGuiMouseCursor_ResizeNWSE: return EMouseCursor::ResizeSouthEast; + case ImGuiMouseCursor_Arrow: return EMouseCursor::Default; + case ImGuiMouseCursor_TextInput: return EMouseCursor::TextEditBeam; + case ImGuiMouseCursor_ResizeAll: return EMouseCursor::CardinalCross; + case ImGuiMouseCursor_ResizeNS: return EMouseCursor::ResizeUpDown; + case ImGuiMouseCursor_ResizeEW: return EMouseCursor::ResizeLeftRight; + case ImGuiMouseCursor_ResizeNESW: return EMouseCursor::ResizeSouthWest; + case ImGuiMouseCursor_ResizeNWSE: return EMouseCursor::ResizeSouthEast; + case ImGuiMouseCursor_Hand: return EMouseCursor::Hand; + case ImGuiMouseCursor_NotAllowed: return EMouseCursor::SlashedCircle; - case ImGuiMouseCursor_None: - default: - return EMouseCursor::None; + case ImGuiMouseCursor_None: + default: + return EMouseCursor::None; } } diff --git a/Plugins/Cog/Source/CogImgui/Public/CogImguiContext.h b/Plugins/Cog/Source/CogImgui/Public/CogImguiContext.h index 66a9d1b..e7687b1 100644 --- a/Plugins/Cog/Source/CogImgui/Public/CogImguiContext.h +++ b/Plugins/Cog/Source/CogImgui/Public/CogImguiContext.h @@ -83,7 +83,7 @@ public: TSharedPtr GetMainWidget() const { return MainWidget; } - static bool GetIsNetImguiInitialized() { return bIsNetImguiInitialized; } + static bool GetIsNetImguiInitialized() { return bIsNetImGuiInitialized; } private: @@ -127,7 +127,12 @@ private: static void ImGui_RenderWindow(ImGuiViewport* Viewport, void* Data); - UPROPERTY() + static const char* ImGui_GetClipboardTextFn(ImGuiContext* InImGuiContext); + + static void ImGui_SetClipboardTextFn(ImGuiContext* InImGuiContext, const char* Arg); + + static bool ImGui_OpenInShell(ImGuiContext* Context, const char* Path); + UTexture2D* FontAtlasTexture = nullptr; TMap, ImGuiID> WindowToViewportMap; @@ -144,12 +149,14 @@ private: TObjectPtr GameViewport = nullptr; - ImGuiContext* ImGuiContext = nullptr; + ImGuiContext* Context = nullptr; ImPlotContext* PlotContext = nullptr; char IniFilename[512] = {}; + TArray ClipboardBuffer; + bool bEnableInput = false; bool bShareMouse = false; @@ -174,6 +181,6 @@ private: bool bSkipRendering = false; - static bool bIsNetImguiInitialized; + static bool bIsNetImGuiInitialized; }; diff --git a/Plugins/Cog/Source/CogImgui/Public/CogImguiHelper.h b/Plugins/Cog/Source/CogImgui/Public/CogImguiHelper.h index e1d7cf6..8ea9ed2 100644 --- a/Plugins/Cog/Source/CogImgui/Public/CogImguiHelper.h +++ b/Plugins/Cog/Source/CogImgui/Public/CogImguiHelper.h @@ -73,4 +73,6 @@ public: static bool DragFVector2D(const char* Label, FVector2D& Vector, float Speed = 1.0f, double Min = 0.0f, double Max = 0.0f, const char* Format = "%.3f", ImGuiSliderFlags Flags = 0); static bool ColorEdit4(const char* Label, FColor& Color, ImGuiColorEditFlags Flags = 0); + + static bool ColorEdit4(const char* Label, FLinearColor& Color, ImGuiColorEditFlags Flags = 0); }; diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp index 0dddce3..f6e2c9a 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp @@ -52,6 +52,25 @@ bool FCogWindow::CheckEditorVisibility() return true; } +//-------------------------------------------------------------------------------------------------------------------------- + void FCogWindow::RenderMainMenuWidget() +{ +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWindow::RenderContextMenu() +{ + if (bHasMenu) + { + ImGui::Checkbox("Show Menu", &bShowMenu); + } + + if (ImGui::Button("Reset Settings", ImVec2(-1, 0))) + { + ResetConfig(); + } +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogWindow::Render(float DeltaTime) { @@ -79,16 +98,7 @@ void FCogWindow::Render(float DeltaTime) if (ImGui::BeginPopupContextWindow()) { - if (bHasMenu) - { - ImGui::Checkbox("Show Menu", &bShowMenu); - } - - if (ImGui::Button("Reset Settings")) - { - ResetConfig(); - } - + RenderContextMenu(); ImGui::EndPopup(); } @@ -139,7 +149,6 @@ void FCogWindow::SetSelection(AActor* NewSelection) } //-------------------------------------------------------------------------------------------------------------------------- - void FCogWindow::SetIsVisible(const bool Value) { if (bIsVisible == Value) @@ -189,9 +198,28 @@ ULocalPlayer* FCogWindow::GetLocalPlayer() const } //-------------------------------------------------------------------------------------------------------------------------- -UCogCommonConfig* FCogWindow::GetConfig(const TSubclassOf ConfigClass) const +UCogCommonConfig* FCogWindow::GetConfig(const TSubclassOf& InConfigClass, bool InResetConfigOnRequest) const { - return GetOwner()->GetConfig(ConfigClass); + UCogCommonConfig* Config = GetOwner()->GetConfig(InConfigClass); + + if (Config != nullptr && InResetConfigOnRequest) + { + ConfigsToResetOnRequest.AddUnique(Config); + } + + return Config; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWindow::ResetConfig() +{ + for (auto& Config : ConfigsToResetOnRequest) + { + if (Config != nullptr) + { + Config->Reset(); + } + } } //-------------------------------------------------------------------------------------------------------------------------- @@ -211,3 +239,4 @@ bool FCogWindow::IsWindowRenderedInMainMenu() { return Owner->IsRenderingMainMenu(); } + diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp index da604b1..fd42750 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp @@ -475,7 +475,7 @@ void UCogWindowManager::RenderWidgets() } } - ImGui::PushStyleVarX(ImGuiStyleVar_CellPadding, 0.0f); + //ImGui::PushStyleVarX(ImGuiStyleVar_CellPadding, 0.0f); if (ImGui::BeginTable("Widgets", NumColumns, Flags)) { @@ -501,9 +501,14 @@ void UCogWindowManager::RenderWidgets() ImGui::TableNextColumn(); } - for (int i = 0; i < Widgets.Num(); ++i) + //--------------------------------------------------------------------- + // Widgets + //--------------------------------------------------------------------- + for (int column = 0; column < Widgets.Num(); ++column) { - FCogWindow* Window = Widgets[i]; + ImGui::PushID(column); + + FCogWindow* Window = Widgets[column]; if (Window->GetIsWidgetVisible() == false) { continue; } @@ -511,17 +516,17 @@ void UCogWindowManager::RenderWidgets() ImGui::AlignTextToFramePadding(); ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 2); Window->RenderMainMenuWidget(); + ImGui::PopID(); } if (AddRightColumn) { ImGui::TableNextColumn(); } - + ImGui::EndTable(); } - - ImGui::PopStyleVar(); + //ImGui::PopStyleVar(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -801,6 +806,9 @@ UCogCommonConfig* UCogWindowManager::GetConfig(const TSubclassOf(this, Class); + Config->Reset(); + Config->ReloadConfig(); + Configs.Add(Config); return Config; } diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp index 692a302..200b605 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp @@ -41,17 +41,33 @@ void FCogWindowWidgets::EndTableTooltip() } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::ItemTooltipWrappedText(const char* InText) +bool FCogWindowWidgets::BeginItemTooltipWrappedText() { - bool result = ImGui::BeginItemTooltip(); + const bool result = ImGui::BeginItemTooltip(); if (result == false) { return false; } ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); - ImGui::TextUnformatted(InText); + return true; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWindowWidgets::EndItemTooltipWrappedText() +{ ImGui::PopTextWrapPos(); ImGui::EndTooltip(); - return true; +} + +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogWindowWidgets::ItemTooltipWrappedText(const char* InText) +{ + const bool result = BeginItemTooltipWrappedText(); + if (result) + { + ImGui::TextUnformatted(InText); + EndItemTooltipWrappedText(); + } + return result; } //-------------------------------------------------------------------------------------------------------------------------- @@ -647,7 +663,7 @@ bool FCogWindowWidgets::MultiChoiceButton(const char* Label, bool IsSelected, co } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::MultiChoiceButtonsInt(TArray& Values, int32& Value, const ImVec2& Size) +bool FCogWindowWidgets::MultiChoiceButtonsInt(TArray& InValues, int32& InCurrentValue, const ImVec2& InSize, bool InInline) { ImGuiStyle& Style = ImGui::GetStyle(); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(Style.WindowPadding.x * 0.40f, (float)(int)(Style.WindowPadding.y * 0.60f))); @@ -656,18 +672,18 @@ bool FCogWindowWidgets::MultiChoiceButtonsInt(TArray& Values, int32& Valu ImGui::PushStyleColor(ImGuiCol_Border, IM_COL32(255, 255, 255, 180)); bool IsPressed = false; - for (int32 i = 0; i < Values.Num(); ++i) + for (int32 i = 0; i < InValues.Num(); ++i) { - int32 ButtonValue = Values[i]; + int32 ButtonValue = InValues[i]; const auto Text = StringCast(*FString::Printf(TEXT("%d"), ButtonValue)); - if (MultiChoiceButton(Text.Get(), ButtonValue == Value, Size)) + if (MultiChoiceButton(Text.Get(), ButtonValue == InCurrentValue, InSize)) { IsPressed = true; - Value = ButtonValue; + InCurrentValue = ButtonValue; } - if (i < Values.Num() - 1) + if (InInline && i < InValues.Num() - 1) { ImGui::SameLine(); } @@ -680,7 +696,19 @@ bool FCogWindowWidgets::MultiChoiceButtonsInt(TArray& Values, int32& Valu } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogWindowWidgets::MultiChoiceButtonsFloat(TArray& Values, float& Value, const ImVec2& Size) +FString FCogWindowWidgets::RemoveFirstZero(const FString& InText) +{ + return InText.Replace(TEXT("0."), TEXT(".")); +} + +//-------------------------------------------------------------------------------------------------------------------------- +FString FCogWindowWidgets::FormatSmallFloat(float InValue) +{ + return RemoveFirstZero(FString::Printf(TEXT("%g"), InValue)); +} + +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogWindowWidgets::MultiChoiceButtonsFloat(TArray& InValues, float& InValue, const ImVec2& InSize, bool InInline) { ImGuiStyle& Style = ImGui::GetStyle(); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(Style.WindowPadding.x * 0.40f, (float)(int)(Style.WindowPadding.y * 0.60f))); @@ -689,18 +717,21 @@ bool FCogWindowWidgets::MultiChoiceButtonsFloat(TArray& Values, float& Va ImGui::PushStyleColor(ImGuiCol_Border, IM_COL32(255, 255, 255, 180)); bool IsPressed = false; - for (int32 i = 0; i < Values.Num(); ++i) + for (int32 i = 0; i < InValues.Num(); ++i) { - float ButtonValue = Values[i]; + float ButtonValue = InValues[i]; - const auto Text = StringCast(*FString::Printf(TEXT("%g"), ButtonValue).Replace(TEXT("0."), TEXT("."))); - if (MultiChoiceButton(Text.Get(), ButtonValue == Value, Size)) + const auto Text = StringCast(*FormatSmallFloat(ButtonValue)); + + ImGui::PushID(i); + if (MultiChoiceButton(Text.Get(), ButtonValue == InValue, InSize)) { IsPressed = true; - Value = ButtonValue; + InValue = ButtonValue; } + ImGui::PopID(); - if (i < Values.Num() - 1) + if (InInline && i < InValues.Num() - 1) { ImGui::SameLine(); } @@ -1278,7 +1309,19 @@ bool FCogWindowWidgets::OpenObjectAssetButton(const UObject* InObject, const ImV } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindowWidgets::RenderClosebutton(const ImVec2& InPos) +void FCogWindowWidgets::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) +{ + ScalarArray(InLabel, ImGuiDataType_S32, InArray, InMaxEntries, Size); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWindowWidgets::RenderCloseButton(const ImVec2& InPos) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -1294,31 +1337,38 @@ void FCogWindowWidgets::RenderClosebutton(const ImVec2& InPos) window->DrawList->AddLine(cross_center + ImVec2(+cross_extent, -cross_extent), cross_center + ImVec2(-cross_extent, +cross_extent), cross_col, 1.0f); } -// //-------------------------------------------------------------------------------------------------------------------------- -// bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiButtonFlags flags) -// { -// ImGuiContext& g = *GImGui; -// ImGuiWindow* window = GetCurrentWindow(); -// if (window->SkipItems) -// return false; -// -// const ImGuiID id = window->GetID(str_id); -// const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); -// const float default_size = GetFrameHeight(); -// ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f); -// if (!ItemAdd(bb, id)) -// return false; -// -// bool hovered, held; -// bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); -// -// // Render -// const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); -// const ImU32 text_col = GetColorU32(ImGuiCol_Text); -// RenderNavCursor(bb, id); -// RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding); -// RenderArrow(window->DrawList, bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), text_col, dir); -// -// IMGUI_TEST_ENGINE_ITEM_INFO(id, str_id, g.LastItemData.StatusFlags); -// return pressed; -// } \ No newline at end of file +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogWindowWidgets::PickButton(const char* InLabel, const ImVec2& InSize, ImGuiButtonFlags InFlags) +{ + ImGuiContext& g = *GImGui; + ImGuiWindow* window = ImGui::GetCurrentWindow(); + if (window->SkipItems) + return false; + + const ImGuiID id = window->GetID(InLabel); + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + InSize); + const float default_size = ImGui::GetFrameHeight(); + ImGui::ItemSize(InSize, (InSize.y >= default_size) ? g.Style.FramePadding.y : -1.0f); + if (!ImGui::ItemAdd(bb, id)) + return false; + + bool hovered, held; + bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held, InFlags); + + // Render + const ImU32 bg_col = ImGui::GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + const ImU32 text_col = ImGui::GetColorU32(ImGuiCol_Text); + ImGui::RenderNavCursor(bb, id); + ImGui::RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding); + + ImVec2 pos = bb.Min + ImVec2(ImMax(0.0f, (InSize.x - g.FontSize) * 0.5f), ImMax(0.0f, (InSize.y - g.FontSize) * 0.5f)); + float scale = 1.0f; + + const float h = window->DrawList->_Data->FontSize * 1.00f; + float r = h * 0.40f * scale; + ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale); + window->DrawList->AddCircle(center, r, text_col, 0, 1); + window->DrawList->AddCircleFilled(center, r * 0.3f, text_col); + + return pressed; +} \ No newline at end of file diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp index d72949a..a5cf00d 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp @@ -49,14 +49,6 @@ void FCogWindow_Settings::PreSaveConfig() Config->bShareMouseWithGameplay = Context.GetShareMouseWithGameplay(); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogWindow_Settings::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogWindow_Settings::RenderContent() { diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h b/Plugins/Cog/Source/CogWindow/Public/CogWindow.h index 46e8d29..750e7ac 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindow.h @@ -24,7 +24,7 @@ public: virtual void Shutdown() {} - virtual void ResetConfig() {} + virtual void ResetConfig(); virtual void PreSaveConfig() {} @@ -38,7 +38,7 @@ public: virtual void GameTick(float DeltaTime); /** */ - virtual void RenderMainMenuWidget() {} + virtual void RenderMainMenuWidget(); ImGuiID GetID() const { return ID; } @@ -73,9 +73,9 @@ public: UCogWindowManager* GetOwner() const { return Owner; } template - T* GetConfig() const { return Cast(GetConfig(T::StaticClass())); } + T* GetConfig(bool InResetConfigOnRequest = true) const { return Cast(GetConfig(T::StaticClass(), InResetConfigOnRequest)); } - UCogCommonConfig* GetConfig(const TSubclassOf ConfigClass) const; + UCogCommonConfig* GetConfig(const TSubclassOf& InConfigClass, bool InResetConfigOnRequest = true) const; template const T* GetAsset() const { return Cast(GetAsset(T::StaticClass())); } @@ -100,6 +100,8 @@ protected: virtual bool CheckEditorVisibility(); + virtual void RenderContextMenu(); + virtual void OnWindowVisibilityChanged(bool NewVisibility) { } virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) {} @@ -141,5 +143,7 @@ protected: TWeakObjectPtr CurrentSelection; TWeakObjectPtr OverridenSelection; + + mutable TArray> ConfigsToResetOnRequest; }; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h index 1d9468e..2d47f33 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h @@ -28,6 +28,10 @@ public: static void EndTableTooltip(); static bool ItemTooltipWrappedText(const char* InText); + + static bool BeginItemTooltipWrappedText(); + + static void EndItemTooltipWrappedText(); static bool BeginItemTableTooltip(); @@ -47,9 +51,9 @@ public: static bool MultiChoiceButton(const char* Label, bool IsSelected, const ImVec2& Size = ImVec2(0, 0)); - static bool MultiChoiceButtonsInt(TArray& Values, int32& Value, const ImVec2& Size = ImVec2(0, 0)); + static bool MultiChoiceButtonsInt(TArray& Values, int32& Value, const ImVec2& Size = ImVec2(0, 0), bool InInline = true); - static bool MultiChoiceButtonsFloat(TArray& Values, float& Value, const ImVec2& Size = ImVec2(0, 0)); + static bool MultiChoiceButtonsFloat(TArray& InValues, float& InValue, const ImVec2& InSize = ImVec2(0, 0), bool InInline = true); static void SliderWithReset(const char* Name, float* Value, float Min, float Max, const float& ResetValue, const char* Format); @@ -135,8 +139,20 @@ public: static bool OpenObjectAssetButton(const UObject* InObject, const ImVec2& InSize = ImVec2(0, 0)); - static void RenderClosebutton(const ImVec2& InPos); + static void RenderCloseButton(const ImVec2& InPos); + static bool PickButton(const char* InLabel, const ImVec2& InSize, ImGuiButtonFlags InFlags = ImGuiButtonFlags_None); + + static FString RemoveFirstZero(const FString& InText); + + static FString FormatSmallFloat(float InValue); + + static void FloatArray(const char* InLabel, TArray& InArray, int32 InMaxEntries = 0, const ImVec2& Size = ImVec2(0, 0)); + + static void IntArray(const char* InLabel, TArray& InArray, int32 InMaxEntries = 0, const ImVec2& Size = ImVec2(0, 0)); + + template + static bool ScalarArray(const char* InLabel, ImGuiDataType InDataType, TArray& InArray, int32 InMaxEntries = 0, const ImVec2& Size = ImVec2(0, 0)); }; template @@ -156,4 +172,44 @@ template bool FCogWindowWidgets::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 Result = false; + ImGui::PushID(InLabel); + + if (ImGui::BeginChild("##Entries", Size, ImGuiChildFlags_Borders | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_MenuBar)) + { + if (ImGui::BeginMenuBar()) + { + ImGui::TextUnformatted(InLabel); + + int32 NumEntries = InArray.Num(); + SetNextItemToShortWidth(); + if (ImGui::SliderInt("##Size", &NumEntries, 0, InMaxEntries)) + { + InArray.SetNum(NumEntries); + Result = true; + } + ImGui::EndMenuBar(); + } + + for (int32 i = 0; i < InArray.Num(); i++) + { + ImGui::PushID(i); + ImGui::SetNextItemWidth(-1); + if (ImGui::InputScalar("##Entry", InDataType, &InArray[i])) + { + Result = true; + } + ImGui::PopID(); + } + } + ImGui::EndChild(); + + ImGui::PopID(); + + return Result; } \ No newline at end of file diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h index 893b340..54bf835 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h @@ -30,8 +30,6 @@ protected: virtual void PreSaveConfig() override; - virtual void ResetConfig() override; - virtual void RenderShortcut(const char* Label, FCogImGuiKeyInfo& KeyInfo); TObjectPtr Config = nullptr; diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp index ef674fe..8937db2 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp @@ -25,14 +25,6 @@ void FCogAIWindow_Blackboard::RenderHelp() ); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogAIWindow_Blackboard::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogAIWindow_Blackboard::RenderContent() { diff --git a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h index 166818c..46d1146 100644 --- a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h +++ b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h @@ -18,8 +18,6 @@ public: protected: - virtual void ResetConfig() override; - virtual void RenderHelp() override; virtual void RenderContent() override; diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp index 5d017dc..a9ad30d 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp @@ -36,14 +36,6 @@ void FCogAbilityWindow_Abilities::RenderHelp() , TCHAR_TO_ANSI(*GetNameSafe(Asset.Get()))); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityWindow_Abilities::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Abilities::RenderTick(float DeltaTime) { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp index 3c25853..99af1aa 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp @@ -35,14 +35,6 @@ void FCogAbilityWindow_Attributes::RenderHelp() ); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityWindow_Attributes::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Attributes::RenderTick(float DeltaTime) { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp index 7deccd2..99915c6 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp @@ -38,15 +38,6 @@ void FCogAbilityWindow_Cheats::RenderHelp() ); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityWindow_Cheats::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); - AlignmentConfig->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Cheats::GameTick(float DeltaTime) { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp index aae8194..0d0e031 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp @@ -32,15 +32,6 @@ void FCogAbilityWindow_Effects::RenderHelp() ); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityWindow_Effects::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); - AlignmentConfig->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderTick(float DeltaTime) { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp index f67424d..a35e319 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp @@ -14,14 +14,6 @@ void FCogAbilityWindow_Tags::Initialize() bNoPadding = true; } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityWindow_Tags::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Tags::RenderHelp() { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp index f02d27f..e88e98e 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp @@ -26,14 +26,6 @@ void FCogAbilityWindow_Tasks::RenderHelp() "This window displays the gameplay tasks. "); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityWindow_Tasks::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Tasks::RenderTick(float DetlaTime) { diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h index 868a820..35fab3d 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h @@ -22,8 +22,6 @@ public: protected: - virtual void ResetConfig() override; - virtual void RenderHelp() override; virtual void RenderTick(float DeltaTime) override; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h index 0b7980e..4dd1af2 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h @@ -24,11 +24,9 @@ public: protected: - virtual void ResetConfig() override; - virtual void RenderHelp() override; - virtual void RenderTick(float DeltaTime); + virtual void RenderTick(float DeltaTime) override; virtual void RenderContent() override; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h index dafa15b..4404b7f 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h @@ -22,15 +22,14 @@ public: protected: - virtual void GameTick(float DeltaTime); - - virtual void ResetConfig() override; + virtual void GameTick(float DeltaTime) override; virtual void RenderHelp() override; virtual void RenderContent() override; virtual void TryReapplyCheats(); + APawn* GetCheatInstigator(); virtual bool AddCheat(AActor* ControlledActor, AActor* TargetActor, const FCogAbilityCheat& CheatEffect, bool IsPersistent); diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h index afcd673..96fc8f1 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h @@ -34,8 +34,6 @@ protected: virtual void RenderTick(float DeltaTime) override; - virtual void ResetConfig() override; - virtual void RenderEffectsTable(); virtual void RenderEffectRow(UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected); diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h index 010ecf1..8a12abc 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h @@ -23,8 +23,6 @@ protected: virtual void GetTagContainer(FGameplayTagContainer& TagContainer) {} - virtual void ResetConfig(); - virtual void RenderHelp() override; virtual void RenderContent() override; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tasks.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tasks.h index b0519df..38d9001 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tasks.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tasks.h @@ -19,8 +19,6 @@ public: protected: - virtual void ResetConfig() override; - virtual void RenderHelp() override; virtual void RenderTick(float DetlaTime) override; diff --git a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp index 747643f..41b6111 100644 --- a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp +++ b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp @@ -27,14 +27,6 @@ void FCogInputWindow_Actions::RenderHelp() "It can also be used to inject inputs to help debugging."); } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogInputWindow_Actions::ResetConfig() -{ - Super::ResetConfig(); - - Config->Reset(); -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogInputWindow_Actions::RenderContent() { diff --git a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp index d8f81a8..b9ca0db 100644 --- a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp +++ b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp @@ -29,17 +29,6 @@ void FCogInputWindow_Gamepad::PreRender(ImGuiWindowFlags& WindowFlags) } } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogInputWindow_Gamepad::ResetConfig() -{ - Super::ResetConfig(); - - if (Config != nullptr) - { - Config->Reset(); - } -} - //-------------------------------------------------------------------------------------------------------------------------- void FCogInputWindow_Gamepad::RenderButtonContextMenu(const FKey& Key, FCogInputActionInfo* ActionInfoButton) { diff --git a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h index a13835e..08de29e 100644 --- a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h +++ b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h @@ -20,8 +20,6 @@ public: protected: - virtual void ResetConfig() override; - virtual void RenderHelp() override; virtual void RenderContent() override; diff --git a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h index cbab139..b63eaa6 100644 --- a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h +++ b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h @@ -25,8 +25,6 @@ public: protected: - virtual void ResetConfig() override; - virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; virtual void RenderContent() override;