From 901b92e70c71f0a7fb696550f4799930a6c10b85 Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Wed, 4 Oct 2023 09:37:35 -0400 Subject: [PATCH] Add help --- Content/Core/Debug/DA_Debug_Collisions.uasset | Bin 3044 -> 3044 bytes .../Private/CogAbilityWindow_Abilities.cpp | 13 +- .../Private/CogAbilityWindow_Attributes.cpp | 196 +++++++++--------- .../Private/CogAbilityWindow_Cheats.cpp | 14 ++ .../Private/CogAbilityWindow_Effects.cpp | 13 +- .../Private/CogAbilityWindow_Pools.cpp | 88 ++++---- .../Private/CogAbilityWindow_Tags.cpp | 91 +++----- .../Private/CogAbilityWindow_Tweaks.cpp | 95 +++++---- .../Public/CogAbilityWindow_Abilities.h | 2 + .../Public/CogAbilityWindow_Attributes.h | 10 +- .../Public/CogAbilityWindow_Cheats.h | 8 +- .../Public/CogAbilityWindow_Effects.h | 2 + .../Public/CogAbilityWindow_Pools.h | 13 +- .../CogAbility/Public/CogAbilityWindow_Tags.h | 9 +- .../Public/CogAbilityWindow_Tweaks.h | 11 +- .../Private/CogEngineWindow_Collisions.cpp | 152 ++++++++------ .../Private/CogEngineWindow_DebugSettings.cpp | 32 +-- .../Private/CogEngineWindow_LogCategories.cpp | 17 +- .../Private/CogEngineWindow_Metrics.cpp | 14 +- .../Private/CogEngineWindow_NetEmulation.cpp | 104 ++++++---- .../Private/CogEngineWindow_OutputLog.cpp | 22 +- .../Private/CogEngineWindow_Plots.cpp | 7 +- .../Private/CogEngineWindow_Scalability.cpp | 93 ++++----- .../Private/CogEngineWindow_Selection.cpp | 18 +- .../Private/CogEngineWindow_Skeleton.cpp | 2 +- .../Private/CogEngineWindow_Spawns.cpp | 14 +- .../Private/CogEngineWindow_Stats.cpp | 10 +- ...Time.cpp => CogEngineWindow_TimeScale.cpp} | 69 +++--- .../Public/CogEngineWindow_Collisions.h | 29 ++- .../Public/CogEngineWindow_DebugSettings.h | 2 +- .../Public/CogEngineWindow_LogCategories.h | 3 + .../Public/CogEngineWindow_Metrics.h | 4 +- .../Public/CogEngineWindow_NetEmulation.h | 8 +- .../Public/CogEngineWindow_OutputLog.h | 5 + .../CogEngine/Public/CogEngineWindow_Plots.h | 7 +- .../Public/CogEngineWindow_Scalability.h | 2 +- .../Public/CogEngineWindow_Selection.h | 39 ++-- .../CogEngine/Public/CogEngineWindow_Spawns.h | 6 +- .../CogEngine/Public/CogEngineWindow_Stats.h | 13 +- .../CogEngine/Public/CogEngineWindow_Time.h | 21 -- .../Public/CogEngineWindow_TimeScale.h | 28 +++ .../Private/CogInputWindow_Actions.cpp | 52 +++-- .../CogInput/Public/CogInputWindow_Actions.h | 15 +- .../Source/CogWindow/Private/CogWindow.cpp | 45 +++- .../CogWindow/Private/CogWindowManager.cpp | 12 +- .../CogWindow/Private/CogWindowWidgets.cpp | 19 +- .../Source/CogWindow/Public/CogWindow.h | 2 + .../CogWindow/Public/CogWindowManager.h | 5 + .../CogWindow/Public/CogWindowWidgets.h | 8 +- Source/CogSample/CogSampleGameState.cpp | 9 +- 50 files changed, 861 insertions(+), 592 deletions(-) rename Plugins/CogEngine/Source/CogEngine/Private/{CogEngineWindow_Time.cpp => CogEngineWindow_TimeScale.cpp} (69%) delete mode 100644 Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Time.h create mode 100644 Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_TimeScale.h diff --git a/Content/Core/Debug/DA_Debug_Collisions.uasset b/Content/Core/Debug/DA_Debug_Collisions.uasset index 3e9322d55d80d10af82586659befb5b77a695276..942f177dad65fdb54e13210d4ebaa18080cea8e4 100644 GIT binary patch delta 56 zcmaDN{zQDjApxsB9Fi=#>pj-3XW?YF?O@+{=_4Bl0}z}&bH;YEBB$o$FYNA25a#AI Hjyh%lOEwdO delta 49 zcmV-10M7s97vvX^!VnW9Kv^TXg-5H?rdiKa4B)ZS@dgCg*LppZ0SYaX^an?i0}3m% HW(a-*A;T0+ diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp index a0e22f6..b07bf00 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp @@ -9,6 +9,17 @@ ImVec4 ActiveColor(1.0f, 0.8f, 0.0f, 1.0f); ImVec4 DeactiveColor(1.0f, 1.0f, 1.0f, 1.0f); +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAbilityWindow_Abilities::RenderHelp() +{ + ImGui::Text( + "This window displays the gameplay abilities of the selected actor. " + "Click the ability check box to force its activation or deactivation. " + "Right click an ability to open or close the ability separate window. " + "Use the 'Give Ability' menu to manually give an ability from a list defined in the '%s' data asset. " + , TCHAR_TO_ANSI(*GetNameSafe(AbilitiesAsset.Get()))); +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogAbilityWindow_Abilities::PreRender(ImGuiWindowFlags& WindowFlags) { @@ -107,7 +118,7 @@ void UCogAbilityWindow_Abilities::RenderAbiltiesMenu(AActor* Selection) { if (ImGui::BeginMenuBar()) { - if (ImGui::BeginMenu("Add")) + if (ImGui::BeginMenu("Give Ability")) { if (AbilitiesAsset != nullptr) { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp index 53d9696..9f09afa 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp @@ -9,8 +9,15 @@ #include "GameFramework/Character.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Attributes::UCogAbilityWindow_Attributes() +void UCogAbilityWindow_Attributes::RenderHelp() { + ImGui::Text( + "This window display the gameplay attributes of the selected actor. " + "Attributes can be sorted by name, category or attribute set. " + "Attributes with the Current value greater than the Base value are displayed in green. " + "Attributes with the Current value lower than the Base value are displayed in red. " + "Use the options 'Show Only Modified' to only show the attributes that have modifiers. " + ); } //-------------------------------------------------------------------------------------------------------------------------- @@ -19,98 +26,6 @@ void UCogAbilityWindow_Attributes::PreRender(ImGuiWindowFlags& WindowFlags) WindowFlags = ImGuiWindowFlags_MenuBar; } -//-------------------------------------------------------------------------------------------------------------------------- -static void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) -{ - if (ImGui::BeginTable("Attribute", 2, ImGuiTableFlags_Borders)) - { - const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); - - ImGui::TableSetupColumn("Property"); - ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch); - - const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute); - const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute); - - ImVec4 Color; - if (CurrentValue > BaseValue) - { - Color = ImVec4(0.0f, 1.0f, 0.0f, 1.0f); - } - else if (CurrentValue < BaseValue) - { - Color = ImVec4(1.0f, 0.0f, 0.0f, 1.0f); - } - else - { - Color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); - } - - //------------------------ - // Name - //------------------------ - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::TextColored(TextColor, "Name"); - ImGui::TableNextColumn(); - ImGui::Text("%s", TCHAR_TO_ANSI(*Attribute.GetName())); - - //------------------------ - // Base Value - //------------------------ - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::TextColored(TextColor, "Base Value"); - ImGui::TableNextColumn(); - ImGui::Text("%0.2f", BaseValue); - - //------------------------ - // Current Value - //------------------------ - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::TextColored(TextColor, "Current Value"); - ImGui::TableNextColumn(); - ImGui::PushStyleColor(ImGuiCol_Text, Color); - ImGui::Text("%0.2f", CurrentValue); - ImGui::PopStyleColor(1); - - //------------------------ - // Modifiers - //------------------------ - FGameplayEffectQuery Query; - for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent.GetActiveEffects(Query)) - { - const FActiveGameplayEffect* ActiveEffect = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle); - if (ActiveEffect == nullptr) - { - continue; - } - - for (int32 i = 0; i < ActiveEffect->Spec.Modifiers.Num(); ++i) - { - const FModifierSpec& ModSpec = ActiveEffect->Spec.Modifiers[i]; - const FGameplayModifierInfo& ModInfo = ActiveEffect->Spec.Def->Modifiers[i]; - - if (ModInfo.Attribute == Attribute) - { - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::TextColored(TextColor, "Effect"); - ImGui::TextColored(TextColor, "Operation"); - ImGui::TextColored(TextColor, "Magnitude"); - ImGui::TableNextColumn(); - ImGui::Text("%s", TCHAR_TO_ANSI(*FCogAbilityHelper::CleanupName(GetNameSafe(ActiveEffect->Spec.Def)))); - ImGui::Text("%s", TCHAR_TO_ANSI(*EGameplayModOpToString(ModInfo.ModifierOp))); - ImGui::Text("%0.2f", ModSpec.GetEvaluatedMagnitude()); - } - } - } - - ImGui::EndTable(); - } -} - //-------------------------------------------------------------------------------------------------------------------------- void UCogAbilityWindow_Attributes::RenderContent() { @@ -348,4 +263,97 @@ void UCogAbilityWindow_Attributes::RenderContent() ImGui::EndTable(); } -} \ No newline at end of file +} + + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) +{ + if (ImGui::BeginTable("Attribute", 2, ImGuiTableFlags_Borders)) + { + const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); + + ImGui::TableSetupColumn("Property"); + ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch); + + const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute); + const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute); + + ImVec4 Color; + if (CurrentValue > BaseValue) + { + Color = ImVec4(0.0f, 1.0f, 0.0f, 1.0f); + } + else if (CurrentValue < BaseValue) + { + Color = ImVec4(1.0f, 0.0f, 0.0f, 1.0f); + } + else + { + Color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); + } + + //------------------------ + // Name + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Name"); + ImGui::TableNextColumn(); + ImGui::Text("%s", TCHAR_TO_ANSI(*Attribute.GetName())); + + //------------------------ + // Base Value + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Base Value"); + ImGui::TableNextColumn(); + ImGui::Text("%0.2f", BaseValue); + + //------------------------ + // Current Value + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Current Value"); + ImGui::TableNextColumn(); + ImGui::PushStyleColor(ImGuiCol_Text, Color); + ImGui::Text("%0.2f", CurrentValue); + ImGui::PopStyleColor(1); + + //------------------------ + // Modifiers + //------------------------ + FGameplayEffectQuery Query; + for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent.GetActiveEffects(Query)) + { + const FActiveGameplayEffect* ActiveEffect = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle); + if (ActiveEffect == nullptr) + { + continue; + } + + for (int32 i = 0; i < ActiveEffect->Spec.Modifiers.Num(); ++i) + { + const FModifierSpec& ModSpec = ActiveEffect->Spec.Modifiers[i]; + const FGameplayModifierInfo& ModInfo = ActiveEffect->Spec.Def->Modifiers[i]; + + if (ModInfo.Attribute == Attribute) + { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Effect"); + ImGui::TextColored(TextColor, "Operation"); + ImGui::TextColored(TextColor, "Magnitude"); + ImGui::TableNextColumn(); + ImGui::Text("%s", TCHAR_TO_ANSI(*FCogAbilityHelper::CleanupName(GetNameSafe(ActiveEffect->Spec.Def)))); + ImGui::Text("%s", TCHAR_TO_ANSI(*EGameplayModOpToString(ModInfo.ModifierOp))); + ImGui::Text("%0.2f", ModSpec.GetEvaluatedMagnitude()); + } + } + } + + ImGui::EndTable(); + } +} diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp index 806c31c..f772342 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp @@ -9,6 +9,20 @@ #include "imgui.h" #include "imgui_internal.h" +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAbilityWindow_Cheats::RenderHelp() +{ + ImGui::Text( + "This window can be used to apply cheats to the selected actor (by default). " + "The cheats can be configured in the '%s' data asset. " + "When clicking a cheat button, press:\n" + " [CTRL] to apply the cheat to controlled actor\n" + " [ALT] to apply the cheat to the allies of the selected actor\n" + " [SHIFT] to apply the cheat to the enemies of the selected actor\n" + , TCHAR_TO_ANSI(*GetNameSafe(CheatsAsset.Get())) + ); +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogAbilityWindow_Cheats::RenderContent() { diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp index 2e33d5f..fd18185 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp @@ -8,6 +8,15 @@ #include "EngineUtils.h" #include "GameFramework/Character.h" +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAbilityWindow_Effects::RenderHelp() +{ + ImGui::Text( + "This window displays the gameplay effects of the selected actor. " + "Mouse over an effect to see its details such as its modifiers and the gameplay tags it grants" + ); +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogAbilityWindow_Effects::PreRender(ImGuiWindowFlags& WindowFlags) { @@ -300,7 +309,7 @@ void UCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponen ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255)); ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 100)); - ImGui::ProgressBar(RemainingTime / Duration, ImVec2(FCogWindowWidgets::TextBaseWidth * 15, FCogWindowWidgets::TextBaseHeight * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%.2f / %.2f"), RemainingTime, Duration))); + ImGui::ProgressBar(RemainingTime / Duration, ImVec2(FCogWindowWidgets::GetFontWidth() * 15, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%.2f / %.2f"), RemainingTime, Duration))); ImGui::PopStyleColor(2); } } @@ -318,7 +327,7 @@ void UCogAbilityWindow_Effects::RenderStacks(const FActiveGameplayEffect& Active ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255)); ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 100)); ImGui::SetNextItemWidth(-1); - ImGui::ProgressBar(CurrentStackCount / (float)Effect.StackLimitCount, ImVec2(FCogWindowWidgets::TextBaseWidth * 15, FCogWindowWidgets::TextBaseHeight * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), CurrentStackCount, Effect.StackLimitCount))); + ImGui::ProgressBar(CurrentStackCount / (float)Effect.StackLimitCount, ImVec2(FCogWindowWidgets::GetFontWidth() * 15, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), CurrentStackCount, Effect.StackLimitCount))); ImGui::PopStyleColor(2); } } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp index f9f337e..f7f13b3 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp @@ -4,48 +4,13 @@ #include "CogImguiHelper.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Pools::UCogAbilityWindow_Pools() +void UCogAbilityWindow_Pools::RenderHelp() { -} - -//-------------------------------------------------------------------------------------------------------------------------- -void DrawPool(const UAbilitySystemComponent* AbilitySystemComponent, const FCogAbilityPool& Pool) -{ - if (AbilitySystemComponent->HasAttributeSetForAttribute(Pool.Max) == false) - { - return; - } - - if (AbilitySystemComponent->HasAttributeSetForAttribute(Pool.Value) == false) - { - return; - } - - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::Text("%s", TCHAR_TO_ANSI(*Pool.Name)); - - const float Value = AbilitySystemComponent->GetNumericAttribute(Pool.Value); - const float Max = AbilitySystemComponent->GetNumericAttribute(Pool.Max); - - //------------------------------------------------------------------------------------------- - // Use a different format base on max value for all pools to be nicely aligned at the center - //------------------------------------------------------------------------------------------- - const char* format = nullptr; - if (Max >= 100) { format = "%3.0f / %3.0f"; } // |200 / 200| |__1 / 200| 3 characters with 0 floating point - else if (Max >= 10) { format = "%4.1f / %4.1f"; } // |20.0 / 20.0| |_1.1 / 20.0| 4 characters with 1 floating point - else { format = "%3.2f / %3.2f"; } // |2.00 / 2.00| |1.11 / 2.00| 3 characters with 2 floating points - - char Buffer[64]; - ImFormatString(Buffer, IM_ARRAYSIZE(Buffer), format, Value, Max); - - const float Ratio = Max > 0.0f ? Value / Max : 0.0f; - - ImGui::TableNextColumn(); - ImGui::PushStyleColor(ImGuiCol_PlotHistogram, FCogImguiHelper::ToImVec4(Pool.Color)); - ImGui::PushStyleColor(ImGuiCol_FrameBg, FCogImguiHelper::ToImVec4(Pool.BackColor)); - FCogWindowWidgets::ProgressBarCentered(Ratio, ImVec2(-1, 0), Buffer); - ImGui::PopStyleColor(2); + ImGui::Text( + "This window displays attributes of the selected actor as pools. " + "The pools can be configured in the '%s' data asset." + , TCHAR_TO_ANSI(*GetNameSafe(PoolsAsset.Get())) + ); } //-------------------------------------------------------------------------------------------------------------------------- @@ -77,3 +42,44 @@ void UCogAbilityWindow_Pools::RenderContent() ImGui::EndTable(); } } + + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAbilityWindow_Pools::DrawPool(const UAbilitySystemComponent* AbilitySystemComponent, const FCogAbilityPool& Pool) +{ + if (AbilitySystemComponent->HasAttributeSetForAttribute(Pool.Max) == false) + { + return; + } + + if (AbilitySystemComponent->HasAttributeSetForAttribute(Pool.Value) == false) + { + return; + } + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("%s", TCHAR_TO_ANSI(*Pool.Name)); + + const float Value = AbilitySystemComponent->GetNumericAttribute(Pool.Value); + const float Max = AbilitySystemComponent->GetNumericAttribute(Pool.Max); + + //------------------------------------------------------------------------------------------- + // Use a different format base on max value for all pools to be nicely aligned at the center + //------------------------------------------------------------------------------------------- + const char* format = nullptr; + if (Max >= 100) { format = "%3.0f / %3.0f"; } // |200 / 200| |__1 / 200| 3 characters with 0 floating point + else if (Max >= 10) { format = "%4.1f / %4.1f"; } // |20.0 / 20.0| |_1.1 / 20.0| 4 characters with 1 floating point + else { format = "%3.2f / %3.2f"; } // |2.00 / 2.00| |1.11 / 2.00| 3 characters with 2 floating points + + char Buffer[64]; + ImFormatString(Buffer, IM_ARRAYSIZE(Buffer), format, Value, Max); + + const float Ratio = Max > 0.0f ? Value / Max : 0.0f; + + ImGui::TableNextColumn(); + ImGui::PushStyleColor(ImGuiCol_PlotHistogram, FCogImguiHelper::ToImVec4(Pool.Color)); + ImGui::PushStyleColor(ImGuiCol_FrameBg, FCogImguiHelper::ToImVec4(Pool.BackColor)); + FCogWindowWidgets::ProgressBarCentered(Ratio, ImVec2(-1, 0), Buffer); + ImGui::PopStyleColor(2); +} diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp index c0e478b..725de4f 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp @@ -5,7 +5,37 @@ #include "CogWindowWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- -static void DrawTagInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag) +void UCogAbilityWindow_Tags::RenderHelp() +{ + ImGui::Text("This window displays gameplay tags of the selected actor. "); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAbilityWindow_Tags::PreRender(ImGuiWindowFlags& WindowFlags) +{ + Super::PreRender(WindowFlags); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAbilityWindow_Tags::RenderContent() +{ + Super::RenderContent(); + + UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); + if (AbilitySystemComponent == nullptr) + { + return; + } + + FGameplayTagContainer OwnedTags, BlockedTags; + AbilitySystemComponent->GetOwnedGameplayTags(OwnedTags); + AbilitySystemComponent->GetBlockedAbilityTags(BlockedTags); + + DrawTagContainer("Owned Tags", *AbilitySystemComponent, OwnedTags); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAbilityWindow_Tags::DrawTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag) { if (ImGui::BeginTable("Tag", 2, ImGuiTableFlags_Borders)) { @@ -33,27 +63,6 @@ static void DrawTagInfo(const UAbilitySystemComponent& AbilitySystemComponent, c const int32 TagCount = AbilitySystemComponent.GetTagCount(Tag); ImGui::TextColored(TagCount > 1 ? ImVec4(1.0f, 1.0f, 0.0f, 1.0f) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f), "%d", TagCount); - //------------------------ - // Abilities - //------------------------ - //ImGui::TableNextRow(); - //ImGui::TableNextColumn(); - //ImGui::TextColored(TextColor, "Abilities"); - //ImGui::TableNextColumn(); - //for (FGameplayAbilitySpec AbilitySpec : AbilitySystemComponent.GetActivatableAbilities()) - //{ - // UGameplayAbility* Ability = AbilitySpec.GetPrimaryInstance() != nullptr ? AbilitySpec.GetPrimaryInstance() : AbilitySpec.Ability; - // if (Ability == nullptr) - // { - // continue; - // } - - // if (Ability->ActivationOwnedTags GetActivationOwnedTags().HasTagExact(Tag)) - // { - // ImGui::Text("%s", TCHAR_TO_ANSI(*FCogAbilityHelper::CleanupName(GetNameSafe(Ability)))); - // } - //} - //------------------------ // Effects //------------------------ @@ -83,9 +92,8 @@ static void DrawTagInfo(const UAbilitySystemComponent& AbilitySystemComponent, c } } - //-------------------------------------------------------------------------------------------------------------------------- -static void DrawTags(const FString& Title, UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer) +void UCogAbilityWindow_Tags::DrawTagContainer(const FString& Title, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer) { if (ImGui::BeginTable(TCHAR_TO_ANSI(*Title), 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_BordersOuterV)) { @@ -122,50 +130,19 @@ static void DrawTags(const FString& Title, UAbilitySystemComponent& AbilitySyste } //------------------------ - // Popup + // Tooltip //------------------------ if (ImGui::IsItemHovered()) { FCogWindowWidgets::BeginTableTooltip(); - DrawTagInfo(AbilitySystemComponent, Tag); + DrawTag(AbilitySystemComponent, Tag); FCogWindowWidgets::EndTableTooltip(); } - ImGui::PopID(); index++; } ImGui::EndTable(); } -} - -//-------------------------------------------------------------------------------------------------------------------------- - -UCogAbilityWindow_Tags::UCogAbilityWindow_Tags() -{ -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Tags::PreRender(ImGuiWindowFlags& WindowFlags) -{ - WindowFlags = ImGuiWindowFlags_MenuBar; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Tags::RenderContent() -{ - Super::RenderContent(); - - UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); - if (AbilitySystemComponent == nullptr) - { - return; - } - - FGameplayTagContainer OwnedTags, BlockedTags; - AbilitySystemComponent->GetOwnedGameplayTags(OwnedTags); - AbilitySystemComponent->GetBlockedAbilityTags(BlockedTags); - - DrawTags("Owned Tags", *AbilitySystemComponent, OwnedTags); } \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp index 5508f7e..b7888af 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp @@ -3,48 +3,14 @@ #include "AbilitySystemComponent.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogAbilityWindow_Tweaks::UCogAbilityWindow_Tweaks() +void UCogAbilityWindow_Tweaks::RenderHelp() { -} - -//-------------------------------------------------------------------------------------------------------------------------- -void DrawTweak(ACogAbilityReplicator* Replicator, const UCogAbilityDataAsset_Tweaks* TweaksAsset, int32 TweakIndex, int32 TweakCategoryIndex) -{ - if (TweaksAsset->TweaksCategories.IsValidIndex(TweakCategoryIndex) == false) - { - return; - } - - float* Value = Replicator->GetTweakCurrentValuePtr(TweaksAsset, TweakIndex, TweakCategoryIndex); - if (Value == nullptr) - { - return; - } - - const FCogAbilityTweakCategory& Category = TweaksAsset->TweaksCategories[TweakCategoryIndex]; - - FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Category.Color)); - ImGui::PushItemWidth(-1); - ImGui::SliderFloat("##Value", Value, TweaksAsset->TweakMinValue, TweaksAsset->TweakMaxValue, "%+0.0f%%", 1.0f); - ImGui::PopItemWidth(); - FCogWindowWidgets::PopBackColor(); - - bool bUpdateValue = ImGui::IsItemDeactivatedAfterEdit(); - - if (ImGui::BeginPopupContextItem()) - { - if (ImGui::Button("Reset")) - { - *Value = 0.f; - bUpdateValue = true; - } - ImGui::EndPopup(); - } - - if (bUpdateValue) - { - Replicator->SetTweakValue(TweaksAsset, TweakIndex, TweakCategoryIndex, *Value); - } + ImGui::Text( + "This window can be used to apply tweaks to all the loaded actors. " + "The tweaks are used to test various gameplay settings by actor category. " + "The tweaks can be configured in the '%s' data asset. " + , TCHAR_TO_ANSI(*GetNameSafe(TweaksAsset.Get())) + ); } //-------------------------------------------------------------------------------------------------------------------------- @@ -52,6 +18,11 @@ void UCogAbilityWindow_Tweaks::RenderContent() { Super::RenderContent(); + if (TweaksAsset == nullptr) + { + return; + } + FCogAbilityModule& Module = FCogAbilityModule::Get(); ACogAbilityReplicator* Replicator = Module.GetLocalReplicator(); if (Replicator == nullptr) @@ -127,7 +98,7 @@ void UCogAbilityWindow_Tweaks::RenderContent() { ImGui::TableNextColumn(); ImGui::PushID(TweakCategoryIndex); - DrawTweak(Replicator, TweaksAsset.Get(), TweakIndex, TweakCategoryIndex); + DrawTweak(Replicator, TweakIndex, TweakCategoryIndex); ImGui::PopID(); } @@ -139,3 +110,43 @@ void UCogAbilityWindow_Tweaks::RenderContent() ImGui::EndTable(); } } + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogAbilityWindow_Tweaks::DrawTweak(ACogAbilityReplicator* Replicator, int32 TweakIndex, int32 TweakCategoryIndex) +{ + if (TweaksAsset->TweaksCategories.IsValidIndex(TweakCategoryIndex) == false) + { + return; + } + + float* Value = Replicator->GetTweakCurrentValuePtr(TweaksAsset.Get(), TweakIndex, TweakCategoryIndex); + if (Value == nullptr) + { + return; + } + + const FCogAbilityTweakCategory& Category = TweaksAsset->TweaksCategories[TweakCategoryIndex]; + + FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Category.Color)); + ImGui::PushItemWidth(-1); + ImGui::SliderFloat("##Value", Value, TweaksAsset->TweakMinValue, TweaksAsset->TweakMaxValue, "%+0.0f%%", 1.0f); + ImGui::PopItemWidth(); + FCogWindowWidgets::PopBackColor(); + + bool bUpdateValue = ImGui::IsItemDeactivatedAfterEdit(); + + if (ImGui::BeginPopupContextItem()) + { + if (ImGui::Button("Reset")) + { + *Value = 0.f; + bUpdateValue = true; + } + ImGui::EndPopup(); + } + + if (bUpdateValue) + { + Replicator->SetTweakValue(TweaksAsset.Get(), TweakIndex, TweakCategoryIndex, *Value); + } +} \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h index ac781c6..6681dc4 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h @@ -19,6 +19,8 @@ public: protected: + virtual void RenderHelp() override; + virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; virtual void RenderTick(float DetlaTime) override; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h index e3f6db4..ee99857 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h @@ -9,12 +9,18 @@ class COGABILITY_API UCogAbilityWindow_Attributes : public UCogWindow { GENERATED_BODY() -public: - UCogAbilityWindow_Attributes(); +protected: + + virtual void RenderHelp() override; virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; + virtual void RenderContent() override; + virtual void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute); + +private: + UPROPERTY(Config) bool bSortByNameSetting = true; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h index 312f02b..786e85b 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h @@ -15,10 +15,14 @@ class COGABILITY_API UCogAbilityWindow_Cheats : public UCogWindow public: - virtual void RenderContent() override; - TWeakObjectPtr CheatsAsset; +protected: + + virtual void RenderHelp() override; + + virtual void RenderContent() override; + private: void AddCheat(AActor* InstigatorActor, 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 56c0596..e8e1a6d 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h @@ -18,6 +18,8 @@ public: protected: + virtual void RenderHelp() override; + virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; virtual void RenderContent() override; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Pools.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Pools.h index 825b19e..e57f00f 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Pools.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Pools.h @@ -6,6 +6,8 @@ #include "CogAbilityWindow_Pools.generated.h" class UCogAbilityDataAsset_Pools; +class UAbilitySystemComponent; +struct FCogAbilityPool; UCLASS() class COGABILITY_API UCogAbilityWindow_Pools : public UCogWindow @@ -13,8 +15,15 @@ class COGABILITY_API UCogAbilityWindow_Pools : public UCogWindow GENERATED_BODY() public: - UCogAbilityWindow_Pools(); + + TWeakObjectPtr PoolsAsset; + +protected: + + virtual void RenderHelp() override; + virtual void RenderContent() override; - TWeakObjectPtr PoolsAsset; + virtual void DrawPool(const UAbilitySystemComponent* AbilitySystemComponent, const FCogAbilityPool& Pool); + }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h index c95a535..d59f690 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h @@ -9,9 +9,14 @@ class COGABILITY_API UCogAbilityWindow_Tags : public UCogWindow { GENERATED_BODY() -public: - UCogAbilityWindow_Tags(); +protected: + virtual void RenderHelp() override; virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; + virtual void RenderContent() override; + + virtual void DrawTagContainer(const FString& Title, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer); + + virtual void DrawTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag); }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tweaks.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tweaks.h index a7bd53f..ea5d7c5 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tweaks.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tweaks.h @@ -4,9 +4,7 @@ #include "CogWindow.h" #include "CogAbilityWindow_Tweaks.generated.h" -class AActor; class UCogAbilityDataAsset_Tweaks; -class ACogAbilityReplicator; UCLASS() class COGABILITY_API UCogAbilityWindow_Tweaks : public UCogWindow @@ -14,10 +12,15 @@ class COGABILITY_API UCogAbilityWindow_Tweaks : public UCogWindow GENERATED_BODY() public: - UCogAbilityWindow_Tweaks(); + TWeakObjectPtr TweaksAsset; + +protected: + + virtual void RenderHelp() override; + virtual void RenderContent() override; - TWeakObjectPtr TweaksAsset; + virtual void DrawTweak(ACogAbilityReplicator* Replicator, int32 TweakIndex, int32 TweakCategoryIndex); private: }; diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp index 10586fe..a17ed64 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp @@ -12,30 +12,19 @@ #include "Kismet/GameplayStatics.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Collisions::UCogEngineWindow_Collisions() +void UCogEngineWindow_Collisions::RenderHelp() { - ObjectTypesToQuery = 0; + ImGui::Text("This window is used to inspect collisions by performing a collision query with the selected channels. " + "The query can be configured in the options. " + "The displayed collision channels can be configured in the '%s' data asset. " + , TCHAR_TO_ANSI(*GetNameSafe(CollisionsAsset.Get())) + ); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Collisions::SetCollisionsAsset(const UCogEngineDataAsset_Collisions* Asset) +void UCogEngineWindow_Collisions::PreRender(ImGuiWindowFlags& WindowFlags) { - if (Asset == nullptr) - { - return; - } - - for (FChannel& Channel : Channels) - { - Channel.IsValid = false; - } - - for (const FCogCollisionChannel& AssetChannel : Asset->Channels) - { - FChannel& Channel = Channels[(uint8)AssetChannel.Channel]; - Channel.IsValid = true; - Channel.Color = AssetChannel.Color.ToFColor(true); - } + WindowFlags = ImGuiWindowFlags_MenuBar; } //-------------------------------------------------------------------------------------------------------------------------- @@ -60,6 +49,60 @@ void UCogEngineWindow_Collisions::RenderContent() return; } + //------------------------------------------------- + // Menu + //------------------------------------------------- + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("Options")) + { + //------------------------------------------------- + // Query Mode + //------------------------------------------------- + ImGui::Combo("Query", &QueryType, + "Sphere\0" + "Raycast Crosshair\0" + "Raycast Cursor\0" + "\0" + ); + + //------------------------------------------------- + // Query Distance + //------------------------------------------------- + ImGui::SliderFloat("Distance", &QueryDistance, 0.0f, 20000.0f, "%0.f"); + + //------------------------------------------------- + // Query Thickness + //------------------------------------------------- + if (QueryType == 1 || QueryType == 2) + { + ImGui::SliderFloat("Thickness", &QueryThickness, 0.0f, 1000.0f, "%0.f"); + } + + //------------------------------------------------- + // Query Use Complex Collisions + //------------------------------------------------- + ImGui::Checkbox("Use Complex Collisions", &UseComplexCollisions); + + //------------------------------------------------- + // Show Names + //------------------------------------------------- + ImGui::Checkbox("Show Actors Names", &ShowActorsNames); + + //------------------------------------------------- + // Show Query + //------------------------------------------------- + ImGui::Checkbox("Show Query", &ShowQuery); + + ImGui::EndMenu(); + } + + ImGui::EndMenuBar(); + } + + //------------------------------------------------- + // Profile + //------------------------------------------------- const FCollisionResponseTemplate* SelectedProfile = CollisionProfile->GetProfileByIndex(ProfileIndex); FName SelectedProfileName = SelectedProfile != nullptr ? SelectedProfile->Name : FName("Custom"); @@ -89,7 +132,6 @@ void UCogEngineWindow_Collisions::RenderContent() } ImGui::EndCombo(); } - ImGui::Separator(); //------------------------------------------------- @@ -128,52 +170,6 @@ void UCogEngineWindow_Collisions::RenderContent() ImGui::PopID(); } - ImGui::Separator(); - - //------------------------------------------------- - // Query Mode - //------------------------------------------------- - static int QueryType = 0; - ImGui::Combo("Query", &QueryType, - "Sphere\0" - "Raycast Crosshair\0" - "Raycast Cursor\0" - "\0" - ); - - //------------------------------------------------- - // Query Distance - //------------------------------------------------- - static float QueryDistance = 5000.0f; - ImGui::SliderFloat("Distance", &QueryDistance, 0.0f, 20000.0f, "%0.f"); - - //------------------------------------------------- - // Query Thickness - //------------------------------------------------- - static float QueryThickness = 0.0f; - if (QueryType == 1 || QueryType == 2) - { - ImGui::SliderFloat("Thickness", &QueryThickness, 0.0f, 1000.0f, "%0.f"); - } - - //------------------------------------------------- - // Query Use Complex Collisions - //------------------------------------------------- - static bool UseComplexCollisions = false; - ImGui::Checkbox("Use Complex Collisions", &UseComplexCollisions); - - //------------------------------------------------- - // Show Names - //------------------------------------------------- - static bool ShowActorsNames = false; - ImGui::Checkbox("Show Actors Names", &ShowActorsNames); - - //------------------------------------------------- - // Show Query - //------------------------------------------------- - static bool ShowQuery = false; - ImGui::Checkbox("Show Query", &ShowQuery); - //------------------------------------------------- // Perform Query //------------------------------------------------- @@ -182,8 +178,6 @@ void UCogEngineWindow_Collisions::RenderContent() return; } - UWorld* World = GetWorld(); - FVector QueryStart; FVector QueryEnd; float QueryRadius = 0.0f; @@ -235,6 +229,7 @@ void UCogEngineWindow_Collisions::RenderContent() QueryShape.SetSphere(QueryRadius); TArray QueryHits; + UWorld* World = GetWorld(); World->SweepMultiByObjectType( QueryHits, QueryStart, @@ -371,3 +366,24 @@ void UCogEngineWindow_Collisions::RenderContent() } } } + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Collisions::SetCollisionsAsset(const UCogEngineDataAsset_Collisions* Asset) +{ + if (Asset == nullptr) + { + return; + } + + for (FChannel& Channel : Channels) + { + Channel.IsValid = false; + } + + for (const FCogCollisionChannel& AssetChannel : Asset->Channels) + { + FChannel& Channel = Channels[(uint8)AssetChannel.Channel]; + Channel.IsValid = true; + Channel.Color = AssetChannel.Color.ToFColor(true); + } +} \ No newline at end of file diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp index 2b0d903..fd1d74d 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp @@ -4,8 +4,12 @@ #include "CogWindowWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_DebugSettings::UCogEngineWindow_DebugSettings() +void UCogEngineWindow_DebugSettings::RenderHelp() { + ImGui::Text( + "This window can be used to setup how the debug display is drawn. " + "Check each item for more info. " + ); } //-------------------------------------------------------------------------------------------------------------------------- @@ -41,64 +45,62 @@ void UCogEngineWindow_DebugSettings::RenderContent() ImGui::SameLine(); FCogWindowWidgets::HelpMarker("Show a shadow below debug text."); - const float ItemsWidth = FCogWindowWidgets::TextBaseWidth * 10; - - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::Checkbox("Fade 2D", &FCogDebugSettings::Fade2D); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("Does the 2D debug is fading out."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Duration", &FCogDebugSettings::Duration, 0.01f, 0.0f, 100.0f, "%.1f"); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The duration of debug elements."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Thickness", &FCogDebugSettings::Thickness, 0.05f, 0.0f, 5.0f, "%.1f"); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The thickness of debug lines."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Server Thickness", &FCogDebugSettings::ServerThickness, 0.05f, 0.0f, 5.0f, "%.1f"); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The thickness the server debug lines."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Server Color Mult", &FCogDebugSettings::ServerColorMultiplier, 0.01f, 0.0f, 1.0f, "%.1f"); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The color multiplier applied to the server debug lines."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragInt("Depth Priority", &FCogDebugSettings::DepthPriority, 0.1f, 0, 100); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The depth priority of debug elements."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragInt("Segments", &FCogDebugSettings::Segments, 0.1f, 4, 20.0f); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The number of segments used for circular shapes."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Axes Scale", &FCogDebugSettings::AxesScale, 0.1f, 0, 10.0f, "%.1f"); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The scaling debug axis."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Arrow Size", &FCogDebugSettings::ArrowSize, 1.0f, 0.0f, 200.0f, "%.0f"); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The size of debug arrows."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Gradient Intensity", &FCogDebugSettings::GradientColorIntensity, 0.01f, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("How much the debug elements color should be changed by a gradient color over time."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Gradient Speed", &FCogDebugSettings::GradientColorSpeed, 0.1f, 0.0f, 10.0f, "%.1f"); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The speed of the gradient color change."); - ImGui::SetNextItemWidth(ItemsWidth); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Text Size", &FCogDebugSettings::TextSize, 0.1f, 0.1f, 5.0f, "%.1f"); ImGui::SameLine(); FCogWindowWidgets::HelpMarker("The size of the debug texts."); diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp index 717396c..e6bfd90 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp @@ -4,6 +4,19 @@ #include "CogWindowWidgets.h" #include "CogDebugLogCategoryManager.h" +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_LogCategories::RenderHelp() +{ + ImGui::Text( + "This window can be used to activate and deactivate log categories." + "Activating a log category set its verbosity to VeryVerbose. " + "Deactivating a log category set its verbosity to Warning. " + "The detailed verbosity of each log category can shown by using the Option menu. " + "On a client, both the client and the server verbosity can be modified. " + "The log categories are used to display both output log and debug display in the world. " + ); +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogEngineWindow_LogCategories::PreRender(ImGuiWindowFlags& WindowFlags) { @@ -145,7 +158,7 @@ void UCogEngineWindow_LogCategories::RenderContent() if (IsClient) { ELogVerbosity::Type CurrentVerbosity = FCogDebugLogCategoryManager::GetServerVerbosity(CategoryName); - ImGui::SetNextItemWidth(FCogWindowWidgets::TextBaseWidth * 12); + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("##Server", FCogDebugHelper::VerbosityToString(CurrentVerbosity))) { for (int32 i = (int32)ELogVerbosity::Error; i <= (int32)ELogVerbosity::VeryVerbose; ++i) @@ -173,7 +186,7 @@ void UCogEngineWindow_LogCategories::RenderContent() { ELogVerbosity::Type CurrentVerbosity = Category->GetVerbosity(); - ImGui::SetNextItemWidth(FCogWindowWidgets::TextBaseWidth * 12); + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("##Local", FCogDebugHelper::VerbosityToString(CurrentVerbosity))) { for (int32 i = (int32)ELogVerbosity::Error; i <= (int32)ELogVerbosity::VeryVerbose; ++i) diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp index b2b6005..4e35bbb 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp @@ -4,6 +4,14 @@ #include "CogImguiHelper.h" #include "imgui.h" +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Metrics::RenderHelp() +{ + ImGui::Text( + "This window gather events generated by the selected actor to compute how much output it produces or receives per second. " + "This is typically useful to compute the damage dealt per second, the damage received per second, etc. " + ); +} //-------------------------------------------------------------------------------------------------------------------------- void UCogEngineWindow_Metrics::PostLoad() @@ -107,19 +115,19 @@ void UCogEngineWindow_Metrics::DrawMetric(FCogDebugMetricEntry& Metric) } ImGui::Text("Crits"); - ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20); + ImGui::SameLine(FCogWindowWidgets::GetFontWidth() * 20); FCogWindowWidgets::ProgressBarCentered(Metric.Count == 0 ? 0.0f : Metric.Crits / (float)Metric.Count, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), Metric.Crits, Metric.Count))); if (FCogDebugMetric::MaxDurationSetting > 0.0f) { ImGui::Text("Timer"); - ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20); + ImGui::SameLine(FCogWindowWidgets::GetFontWidth() * 20); FCogWindowWidgets::ProgressBarCentered(Metric.Timer / (float)FCogDebugMetric::MaxDurationSetting, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%0.1f / %0.1f"), Metric.Timer, FCogDebugMetric::MaxDurationSetting))); } else { ImGui::Text("Timer"); - ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20); + ImGui::SameLine(FCogWindowWidgets::GetFontWidth() * 20); ImGui::Text("%0.1f", Metric.Timer); } diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp index c8f8643..6669f95 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_NetEmulation.cpp @@ -8,9 +8,58 @@ #include "GameFramework/PlayerState.h" //-------------------------------------------------------------------------------------------------------------------------- -void DrawControls(UWorld* World) +void UCogEngineWindow_NetEmulation::RenderHelp() { - FWorldContext& WorldContext = GEngine->GetWorldContextFromWorldChecked(World); + ImGui::Text("This window is used to configure the network emulation."); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_NetEmulation::RenderContent() +{ + Super::RenderContent(); + + DrawStats(); + + ImGui::Separator(); + + DrawControls(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_NetEmulation::DrawStats() +{ + const APlayerController* PlayerController = GetLocalPlayerController(); + if (PlayerController == nullptr) + { + return; + } + + if (const APlayerState* PlayerState = PlayerController->GetPlayerState()) + { + const float Ping = PlayerState->GetPingInMilliseconds(); + ImGui::Text("Ping "); + ImGui::SameLine(); + ImGui::TextColored(UCogEngineWindow_Stats::GetPingColor(Ping), "%0.0fms", Ping); + } + + if (UNetConnection* Connection = PlayerController->GetNetConnection()) + { + const float OutPacketLost = Connection->GetOutLossPercentage().GetAvgLossPercentage() * 100.0f; + ImGui::Text("Packet Loss Out "); + ImGui::SameLine(); + ImGui::TextColored(UCogEngineWindow_Stats::GetPacketLossColor(OutPacketLost), "%0.0f%%", OutPacketLost); + + const float InPacketLost = Connection->GetInLossPercentage().GetAvgLossPercentage() * 100.0f; + ImGui::Text("Packet Loss In "); + ImGui::SameLine(); + ImGui::TextColored(UCogEngineWindow_Stats::GetPacketLossColor(InPacketLost), "%0.0f%%", InPacketLost); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_NetEmulation::DrawControls() +{ + FWorldContext& WorldContext = GEngine->GetWorldContextFromWorldChecked(GetWorld()); if (WorldContext.ActiveNetDrivers.Num() == 0) { @@ -30,6 +79,7 @@ void DrawControls(UWorld* World) return; } + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("Driver", TCHAR_TO_ANSI(*SelectedNetDriver->NetDriver->GetName()))) { int i = 0; @@ -60,6 +110,7 @@ void DrawControls(UWorld* World) FPacketSimulationSettings Settings = SelectedNetDriver->NetDriver->PacketSimulationSettings; //------------------------------------------------------------------------------------------- + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::DragInt("Lag Min", &Settings.PktLagMin, 1.0f, 0, INT_MAX, "%d ms")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -71,6 +122,7 @@ void DrawControls(UWorld* World) } //------------------------------------------------------------------------------------------- + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::DragInt("Lag Max", &Settings.PktLagMax, 1.0f, 0, INT_MAX, "%d ms")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -81,6 +133,8 @@ void DrawControls(UWorld* World) "If set lag values will randomly fluctuate between Min and Max."); } + + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Packet Loss", &Settings.PktLoss, 0, 100, "%d%%")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -96,6 +150,7 @@ void DrawControls(UWorld* World) } //------------------------------------------------------------------------------------------- + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Packet Order", &Settings.PktOrder, 0, 100, "%d%%")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -110,6 +165,7 @@ void DrawControls(UWorld* World) } //------------------------------------------------------------------------------------------- + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Packet Dup", &Settings.PktDup, 0, 100, "%d%%")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -127,6 +183,7 @@ void DrawControls(UWorld* World) ImGui::Separator(); //------------------------------------------------------------------------------------------- + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::DragInt("Incoming Lag Min", &Settings.PktIncomingLagMin, 1.0f, 0, INT_MAX, "%d ms")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -138,6 +195,7 @@ void DrawControls(UWorld* World) } //------------------------------------------------------------------------------------------- + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::DragInt("Incoming Lag Max", &Settings.PktIncomingLagMax, 1.0f, 0, INT_MAX, "%d ms")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -149,6 +207,7 @@ void DrawControls(UWorld* World) } //------------------------------------------------------------------------------------------- + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::SliderInt("Incoming Packet Loss", &Settings.PktIncomingLoss, 0, 100, "%d%%")) { SelectedNetDriver->NetDriver->SetPacketSimulationSettings(Settings); @@ -159,43 +218,4 @@ void DrawControls(UWorld* World) "The ratio of incoming packets that will be dropped to simulate packet loss"); } -#endif //DO_ENABLE_NET_TEST - -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_NetEmulation::RenderContent() -{ - Super::RenderContent(); - - const APlayerController* PlayerController = GetLocalPlayerController(); - if (PlayerController == nullptr) - { - return; - } - - if (const APlayerState* PlayerState = PlayerController->GetPlayerState()) - { - const float Ping = PlayerState->GetPingInMilliseconds(); - ImGui::Text("Ping "); - ImGui::SameLine(); - ImGui::TextColored(UCogEngineWindow_Stats::GetPingColor(Ping), "%0.0fms", Ping); - } - - if (UNetConnection* Connection = PlayerController->GetNetConnection()) - { - const float OutPacketLost = Connection->GetOutLossPercentage().GetAvgLossPercentage() * 100.0f; - ImGui::Text("Packet Loss Out "); - ImGui::SameLine(); - ImGui::TextColored(UCogEngineWindow_Stats::GetPacketLossColor(OutPacketLost), "%0.0f%%", OutPacketLost); - - const float InPacketLost = Connection->GetInLossPercentage().GetAvgLossPercentage() * 100.0f; - ImGui::Text("Packet Loss In "); - ImGui::SameLine(); - ImGui::TextColored(UCogEngineWindow_Stats::GetPacketLossColor(InPacketLost), "%0.0f%%", InPacketLost); - } - - ImGui::Separator(); - - DrawControls(GetWorld()); -} \ No newline at end of file +#endif //DO_ENABLE_NET_TEST \ No newline at end of file diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp index 1246520..11a3ab9 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp @@ -40,6 +40,15 @@ UCogEngineWindow_OutputLog::UCogEngineWindow_OutputLog() OutputDevice.OutputLog = this; } +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_OutputLog::RenderHelp() +{ + ImGui::Text( + "This window output the log based on each log categories verbosity. " + "The verbosity of each log category can be configured in the 'Log Categories' window. " + ); +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogEngineWindow_OutputLog::Clear() { @@ -169,13 +178,6 @@ void UCogEngineWindow_OutputLog::RenderContent() ImGui::Checkbox("Show Verbosity", &ShowVerbosity); ImGui::Checkbox("Show As Table", &ShowAsTable); - //if (ImGui::SmallButton("Add Log")) - //{ - // AddLog(TEXT("ABCD"), ELogVerbosity::Verbose, FName("Test")); - // AddLog(TEXT("EFGH"), ELogVerbosity::Warning, FName("Test")); - // AddLog(TEXT("WXYZ"), ELogVerbosity::Error, FName("Test")); - //} - ImGui::EndMenu(); } @@ -222,17 +224,17 @@ void UCogEngineWindow_OutputLog::RenderContent() IsTableShown = true; if (ShowFrame) { - ImGui::TableSetupColumn("Frame", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::TextBaseWidth * 4); + ImGui::TableSetupColumn("Frame", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 4); } if (ShowCategory) { - ImGui::TableSetupColumn("Category", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::TextBaseWidth * 10); + ImGui::TableSetupColumn("Category", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 10); } if (ShowVerbosity) { - ImGui::TableSetupColumn("Verbosity", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::TextBaseWidth * 10); + ImGui::TableSetupColumn("Verbosity", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 10); } ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_WidthStretch); diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Plots.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Plots.cpp index 13b9b60..33f68f8 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Plots.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Plots.cpp @@ -8,8 +8,11 @@ #include "Kismet/GameplayStatics.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Plots::UCogEngineWindow_Plots() +void UCogEngineWindow_Plots::RenderHelp() { + ImGui::Text( + "This window plots values overtime. When applicable, only the values of the selected actor are displayed." + ); } //-------------------------------------------------------------------------------------------------------------------------- @@ -29,7 +32,7 @@ void UCogEngineWindow_Plots::RenderContent() if (ImGui::BeginTable("PlotTable", 2, ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable)) { - ImGui::TableSetupColumn("Settings", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::TextBaseWidth * 20.0f); + ImGui::TableSetupColumn("Settings", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 20.0f); ImGui::TableSetupColumn("Graph", ImGuiTableColumnFlags_WidthStretch, 0.0f); ImGui::TableNextRow(); diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp index cd16bc8..7cedf98 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp @@ -6,9 +6,13 @@ #define SCALABILITY_NUM_LEVELS 5 + //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Scalability::UCogEngineWindow_Scalability() +void UCogEngineWindow_Scalability::RenderHelp() { + ImGui::Text( + "This window can be used to configure the rendering quality." + ); } //-------------------------------------------------------------------------------------------------------------------------- @@ -18,6 +22,7 @@ void UCogEngineWindow_Scalability::RenderContent() Scalability::FQualityLevels Levels = Scalability::GetQualityLevels(); FString CurrentQualityName = Scalability::GetQualityLevelText(Levels.GetMinQualityLevel(), SCALABILITY_NUM_LEVELS).ToString(); + FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("Scalability", TCHAR_TO_ANSI(*CurrentQualityName))) { for (int32 i = 0; i < SCALABILITY_NUM_LEVELS; ++i) @@ -38,58 +43,44 @@ void UCogEngineWindow_Scalability::RenderContent() ImGui::Separator(); - if (ImGui::SliderFloat("Resolution", &Levels.ResolutionQuality, 10.0f, 100.0f, "%0.f")) + bool Modified = false; + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderFloat("Resolution", &Levels.ResolutionQuality, 10.0f, 100.0f, "%0.f"); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("View Distance", &Levels.ViewDistanceQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("Anti Aliasing", &Levels.AntiAliasingQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("Shadow", &Levels.ShadowQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("Global Illumination", &Levels.GlobalIlluminationQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("Reflection", &Levels.ReflectionQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("Post Process", &Levels.PostProcessQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("Texture", &Levels.TextureQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("Effects", &Levels.EffectsQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("Foliage", &Levels.FoliageQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + FCogWindowWidgets::SetNextItemToShortWidth(); + Modified |= ImGui::SliderInt("Shading", &Levels.ShadingQuality, 0, SCALABILITY_NUM_LEVELS - 1); + + if (Modified) { Scalability::SetQualityLevels(Levels); } - if (ImGui::SliderInt("View Distance", &Levels.ViewDistanceQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } - - if (ImGui::SliderInt("Anti Aliasing", &Levels.AntiAliasingQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } - - if (ImGui::SliderInt("Shadow", &Levels.ShadowQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } - - if (ImGui::SliderInt("Global Illumination", &Levels.GlobalIlluminationQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } - - if (ImGui::SliderInt("Reflection", &Levels.ReflectionQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } - - if (ImGui::SliderInt("Post Process", &Levels.PostProcessQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } - - if (ImGui::SliderInt("Texture", &Levels.TextureQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } - - if (ImGui::SliderInt("Effects", &Levels.EffectsQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } - - if (ImGui::SliderInt("Foliage", &Levels.FoliageQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } - - if (ImGui::SliderInt("Shading", &Levels.ShadingQuality, 0, SCALABILITY_NUM_LEVELS - 1)) - { - Scalability::SetQualityLevels(Levels); - } } diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Selection.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Selection.cpp index faf3536..3c5dc23 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Selection.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Selection.cpp @@ -9,8 +9,14 @@ #include "Kismet/GameplayStatics.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Selection::UCogEngineWindow_Selection() +void UCogEngineWindow_Selection::RenderHelp() { + ImGui::Text( + "This window can be used to select an actor either by picking an actor in the world, " + "or by selecting an actor in the actor list. " + "The actor list can be filtered by actor type (Actor, Character, etc). " + "The current selection is used by various debug windows to filter out their content" + ); } //-------------------------------------------------------------------------------------------------------------------------- @@ -200,7 +206,7 @@ void UCogEngineWindow_Selection::DrawActorContextMenu(AActor* Actor) //------------------------ // ContextMenu //------------------------ - ImGui::SetNextWindowSize(ImVec2(FCogWindowWidgets::TextBaseWidth * 20, 0)); + ImGui::SetNextWindowSize(ImVec2(FCogWindowWidgets::GetFontWidth() * 20, 0)); if (ImGui::BeginPopupContextItem()) { if (ImGui::Button("Reset Selection", ImVec2(-1, 0))) @@ -387,9 +393,9 @@ bool UCogEngineWindow_Selection::ComputeBoundingBoxScreenPosition(const APlayerC //-------------------------------------------------------------------------------------------------------------------------- void UCogEngineWindow_Selection::DrawMainMenuWidget(bool Draw, float& Width) { - const float PickButtonWidth = FCogWindowWidgets::TextBaseWidth * 5; - const float SelectionButtonWidth = FCogWindowWidgets::TextBaseWidth * 30; - const float ResetButtonWidth = FCogWindowWidgets::TextBaseWidth * 2; + const float PickButtonWidth = FCogWindowWidgets::GetFontWidth() * 5; + const float SelectionButtonWidth = FCogWindowWidgets::GetFontWidth() * 30; + const float ResetButtonWidth = FCogWindowWidgets::GetFontWidth() * 2; Width = PickButtonWidth + SelectionButtonWidth + ResetButtonWidth; if (Draw == false) @@ -399,7 +405,7 @@ void UCogEngineWindow_Selection::DrawMainMenuWidget(bool Draw, float& Width) if (ImGui::BeginPopup("SelectionPopup")) { - ImGui::BeginChild("Popup", ImVec2(Width, FCogWindowWidgets::TextBaseWidth * 40), false); + ImGui::BeginChild("Popup", ImVec2(Width, FCogWindowWidgets::GetFontWidth() * 40), false); if (DrawSelectionCombo()) { diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp index d494df0..53a25d4 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp @@ -105,7 +105,7 @@ void UCogEngineWindow_Skeleton::RenderContent() ImGui::EndMenuBar(); } - ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, FCogWindowWidgets::TextBaseWidth); + ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, FCogWindowWidgets::GetFontWidth()); HoveredBoneIndex = INDEX_NONE; DrawBoneEntry(0, false); diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp index bc62032..d7bfc06 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp @@ -1,5 +1,15 @@ #include "CogEngineWindow_Spawns.h" +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Spawns::RenderHelp() +{ + ImGui::Text( + "This window can be used to spawn new actors in the world. " + "The spawn list can be configured in the '%s' data asset. " + , TCHAR_TO_ANSI(*GetNameSafe(SpawnAsset)) + ); +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogEngineWindow_Spawns::PreRender(ImGuiWindowFlags& WindowFlags) { @@ -11,12 +21,12 @@ void UCogEngineWindow_Spawns::RenderContent() { Super::RenderContent(); - if (Asset == nullptr) + if (SpawnAsset == nullptr) { return; } - for (const FCogEngineSpawnGroup& SpawnGroup : Asset->SpawnGroups) + for (const FCogEngineSpawnGroup& SpawnGroup : SpawnAsset->SpawnGroups) { RenderSpawnGroup(SpawnGroup); } diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Stats.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Stats.cpp index 96ce3c5..becd9be 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Stats.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Stats.cpp @@ -8,6 +8,14 @@ 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 UCogEngineWindow_Stats::RenderHelp() +{ + ImGui::Text( + "This window display engine stats such as FPS, Ping, Packet Loss. " + ); +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogEngineWindow_Stats::RenderContent() { @@ -46,7 +54,7 @@ void UCogEngineWindow_Stats::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- void UCogEngineWindow_Stats::DrawMainMenuWidget(bool Draw, float& Width) { - Width = FCogWindowWidgets::TextBaseWidth * 25; + Width = FCogWindowWidgets::GetFontWidth() * 25; if (Draw == false) { diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Time.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp similarity index 69% rename from Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Time.cpp rename to Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp index 192beec..6738624 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Time.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp @@ -1,42 +1,20 @@ -#include "CogEngineWindow_Time.h" +#include "CogEngineWindow_TimeScale.h" #include "CogEngineReplicator.h" #include "Engine/Engine.h" #include "Engine/World.h" //-------------------------------------------------------------------------------------------------------------------------- -void DrawTimeButton(ACogEngineReplicator* Replicator, float Value) +void UCogEngineWindow_TimeScale::RenderHelp() { - const bool IsSelected = FMath::IsNearlyEqual(Replicator->GetTimeDilation(), Value, 0.0001f); - if (IsSelected) - { - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); - } - else - { - ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(128, 128, 128, 50)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(128, 128, 128, 100)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(128, 128, 128, 150)); - } - - const char* Text = TCHAR_TO_ANSI(*FString::Printf(TEXT("%g"), Value).Replace(TEXT("0."), TEXT("."))); - if (ImGui::Button(Text, ImVec2(3.5f * FCogWindowWidgets::TextBaseWidth, 0))) - { - Replicator->Server_SetTimeDilation(Value); - } - - if (IsSelected) - { - ImGui::PopStyleVar(); - } - else - { - ImGui::PopStyleColor(3); - } + ImGui::Text( + "This window can be used to change the game global time scale. " + "If changed on a client the time scale is also modified on the game server. " + ); } //-------------------------------------------------------------------------------------------------------------------------- -UCogEngineWindow_Time::UCogEngineWindow_Time() +UCogEngineWindow_TimeScale::UCogEngineWindow_TimeScale() { TimingScales.Add(0.00f); TimingScales.Add(0.01f); @@ -49,7 +27,7 @@ UCogEngineWindow_Time::UCogEngineWindow_Time() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Time::RenderContent() +void UCogEngineWindow_TimeScale::RenderContent() { Super::RenderContent(); @@ -74,3 +52,34 @@ void UCogEngineWindow_Time::RenderContent() ImGui::PopStyleColor(1); ImGui::PopStyleVar(3); } + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_TimeScale::DrawTimeButton(ACogEngineReplicator* Replicator, float Value) +{ + const bool IsSelected = FMath::IsNearlyEqual(Replicator->GetTimeDilation(), Value, 0.0001f); + if (IsSelected) + { + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + } + else + { + ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(128, 128, 128, 50)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, IM_COL32(128, 128, 128, 100)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, IM_COL32(128, 128, 128, 150)); + } + + const char* Text = TCHAR_TO_ANSI(*FString::Printf(TEXT("%g"), Value).Replace(TEXT("0."), TEXT("."))); + if (ImGui::Button(Text, ImVec2(3.5f * FCogWindowWidgets::GetFontWidth(), 0))) + { + Replicator->Server_SetTimeDilation(Value); + } + + if (IsSelected) + { + ImGui::PopStyleVar(); + } + else + { + ImGui::PopStyleColor(3); + } +} diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Collisions.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Collisions.h index 34379dd..3dd6b1c 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Collisions.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Collisions.h @@ -12,14 +12,17 @@ class COGENGINE_API UCogEngineWindow_Collisions : public UCogWindow GENERATED_BODY() public: - UCogEngineWindow_Collisions(); - - virtual void RenderContent() override; void SetCollisionsAsset(const UCogEngineDataAsset_Collisions* Asset); private: + virtual void RenderHelp() override; + + virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; + + virtual void RenderContent() override; + struct FChannel { bool IsValid = false; @@ -31,8 +34,26 @@ private: FChannel Channels[ECC_MAX]; UPROPERTY(Config) - int32 ObjectTypesToQuery; + int32 ObjectTypesToQuery = 0; UPROPERTY(Config) int32 ProfileIndex = 0; + + UPROPERTY(Config) + int QueryType = 0; + + UPROPERTY(Config) + float QueryDistance = 5000.0f; + + UPROPERTY(Config) + float QueryThickness = 0.0f; + + UPROPERTY(Config) + bool UseComplexCollisions = false; + + UPROPERTY(Config) + bool ShowActorsNames = false; + + UPROPERTY(Config) + bool ShowQuery = false; }; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h index 7da13a9..4bbf95b 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h @@ -10,7 +10,7 @@ class COGENGINE_API UCogEngineWindow_DebugSettings : public UCogWindow GENERATED_BODY() public: - UCogEngineWindow_DebugSettings(); + virtual void RenderHelp()override; virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_LogCategories.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_LogCategories.h index cb727f3..cd7d83f 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_LogCategories.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_LogCategories.h @@ -10,6 +10,9 @@ class COGENGINE_API UCogEngineWindow_LogCategories : public UCogWindow GENERATED_BODY() public: + + virtual void RenderHelp() override; + virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; virtual void RenderContent() override; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h index 71c022c..14e42de 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h @@ -15,7 +15,9 @@ class COGENGINE_API UCogEngineWindow_Metrics : public UCogWindow public: protected: - + + virtual void RenderHelp() override; + virtual void PostLoad() override; virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h index ddcd5d7..b2923c4 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_NetEmulation.h @@ -9,10 +9,16 @@ class COGENGINE_API UCogEngineWindow_NetEmulation : public UCogWindow { GENERATED_BODY() -public: +protected: + + virtual void RenderHelp() override; virtual void RenderContent() override; + virtual void DrawStats(); + + virtual void DrawControls(); + private: }; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_OutputLog.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_OutputLog.h index ef7152a..6fbe8a7 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_OutputLog.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_OutputLog.h @@ -27,8 +27,13 @@ class COGENGINE_API UCogEngineWindow_OutputLog : public UCogWindow GENERATED_BODY() public: + UCogEngineWindow_OutputLog(); +protected: + + virtual void RenderHelp() override; + virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; virtual void RenderContent() override; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Plots.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Plots.h index ca13338..36e193f 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Plots.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Plots.h @@ -4,15 +4,14 @@ #include "CogWindow.h" #include "CogEngineWindow_Plots.generated.h" -class UCogEngineDataAsset_Collisions; - UCLASS() class COGENGINE_API UCogEngineWindow_Plots : public UCogWindow { GENERATED_BODY() -public: - UCogEngineWindow_Plots(); +protected: + + virtual void RenderHelp() override; virtual void RenderTick(float DeltaTime) override; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Scalability.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Scalability.h index 2bfa1f5..3f963ff 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Scalability.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Scalability.h @@ -10,7 +10,7 @@ class COGENGINE_API UCogEngineWindow_Scalability : public UCogWindow GENERATED_BODY() public: - UCogEngineWindow_Scalability(); + virtual void RenderHelp() override; virtual void RenderContent() override; }; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Selection.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Selection.h index 58d9c4e..3c2296e 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Selection.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Selection.h @@ -11,23 +11,6 @@ class COGENGINE_API UCogEngineWindow_Selection : public UCogWindow GENERATED_BODY() public: - UCogEngineWindow_Selection(); - - virtual void RenderTick(float DeltaTime); - - virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; - - virtual void RenderContent() override; - - virtual void DrawMainMenuWidget(bool Draw, float& Width) override; - - bool DrawSelectionCombo(); - - void DrawActorContextMenu(AActor* Actor); - - void ActivateSelectionMode(); - - void HackWaitInputRelease(); bool GetIsSelecting() const { return bSelectionModeActive; } @@ -43,6 +26,26 @@ public: void SetTraceType(ETraceTypeQuery Value) { TraceType = Value; } +protected: + + virtual void RenderHelp() override; + + virtual void RenderTick(float DeltaTime) override; + + virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; + + virtual void RenderContent() override; + + virtual void DrawMainMenuWidget(bool Draw, float& Width) override; + + bool DrawSelectionCombo(); + + void DrawActorContextMenu(AActor* Actor); + + void ActivateSelectionMode(); + + void HackWaitInputRelease(); + private: void TickSelectionMode(); @@ -53,8 +56,6 @@ private: void DrawActorFrame(const AActor* Actor); - //void DrawActorDebug(const AActor* Actor); - bool ComputeBoundingBoxScreenPosition(const APlayerController* PlayerController, const FVector& Origin, const FVector& Extent, FVector2D& Min, FVector2D& Max); FVector LastSelectedActorLocation = FVector::ZeroVector; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawns.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawns.h index f8b718d..2f86a2a 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawns.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawns.h @@ -14,9 +14,9 @@ class COGENGINE_API UCogEngineWindow_Spawns : public UCogWindow public: - const UCogEngineDataAsset_Spawns* GetSpawnsAsset() const { return Asset; } + const UCogEngineDataAsset_Spawns* GetSpawnsAsset() const { return SpawnAsset; } - void SetSpawnsAsset(const UCogEngineDataAsset_Spawns* Value) { Asset = Value; } + void SetSpawnsAsset(const UCogEngineDataAsset_Spawns* Value) { SpawnAsset = Value; } protected: @@ -30,5 +30,5 @@ protected: private: - const UCogEngineDataAsset_Spawns* Asset = nullptr; + const UCogEngineDataAsset_Spawns* SpawnAsset = nullptr; }; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Stats.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Stats.h index 92de91d..84bb4a4 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Stats.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Stats.h @@ -11,10 +11,17 @@ class COGENGINE_API UCogEngineWindow_Stats : public UCogWindow public: - virtual void RenderContent() override; - virtual void DrawMainMenuWidget(bool Draw, float& Width) override; - 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 RenderHelp() override; + + virtual void RenderContent() override; + + virtual void DrawMainMenuWidget(bool Draw, float& Width) override; }; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Time.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Time.h deleted file mode 100644 index fa6a499..0000000 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Time.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "CogWindow.h" -#include "CogEngineWindow_Time.generated.h" - -UCLASS() -class COGENGINE_API UCogEngineWindow_Time : public UCogWindow -{ - GENERATED_BODY() - -public: - UCogEngineWindow_Time(); - - virtual void RenderContent() override; - - TArray TimingScales; - -private: - -}; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_TimeScale.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_TimeScale.h new file mode 100644 index 0000000..2a62084 --- /dev/null +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_TimeScale.h @@ -0,0 +1,28 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogWindow.h" +#include "CogEngineWindow_TimeScale.generated.h" + +UCLASS() +class COGENGINE_API UCogEngineWindow_TimeScale : public UCogWindow +{ + GENERATED_BODY() + +public: + + UCogEngineWindow_TimeScale(); + +protected: + + virtual void RenderHelp() override; + + virtual void RenderContent() override; + + virtual void DrawTimeButton(ACogEngineReplicator* Replicator, float Value); + + TArray TimingScales; + +private: + +}; diff --git a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp index 572e459..85d60a3 100644 --- a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp +++ b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp @@ -9,8 +9,14 @@ #include "InputMappingContext.h" //-------------------------------------------------------------------------------------------------------------------------- -UCogInputWindow_Actions::UCogInputWindow_Actions() +void UCogInputWindow_Actions::RenderHelp() { + ImGui::Text( + "This window display the current state of each Input Action. " + "It can also be used to inject inputs to help debugging. " + "The input action are read from a Input Mapping Context defined in '%s' data asset. " + , TCHAR_TO_ANSI(*GetNameSafe(ActionAsset)) + ); } //-------------------------------------------------------------------------------------------------------------------------- @@ -19,27 +25,6 @@ void UCogInputWindow_Actions::PreRender(ImGuiWindowFlags& WindowFlags) WindowFlags = ImGuiWindowFlags_MenuBar; } -//-------------------------------------------------------------------------------------------------------------------------- -void DrawAxis(const char* Format, const char* ActionName, float CurrentValue, float* InjectValue) -{ - ImGui::PushID(Format); - ImGui::TableNextRow(); - - ImGui::TableNextColumn(); - ImGui::Text(Format, ActionName); - - ImGui::TableNextColumn(); - ImGui::SetNextItemWidth(-1); - ImGui::BeginDisabled(); - ImGui::SliderFloat("##Value", &CurrentValue, -1.0f, 1.0f, "%0.2f"); - ImGui::EndDisabled(); - - ImGui::TableNextColumn(); - ImGui::SetNextItemWidth(-1); - FCogWindowWidgets::SliderWithReset("##Inject", InjectValue, -1.0f, 1.0f, 0.0f, "%0.2f"); - ImGui::PopID(); -} - //-------------------------------------------------------------------------------------------------------------------------- void UCogInputWindow_Actions::RenderContent() { @@ -120,7 +105,7 @@ void UCogInputWindow_Actions::RenderContent() const ImVec4 ActiveColor(1, 0.8f, 0, 1); const ImVec4 InnactiveColor(0.3f, 0.3f, 0.3f, 1); - const ImVec2 ButtonWidth(FCogWindowWidgets::TextBaseWidth * 10, 0); + const ImVec2 ButtonWidth(FCogWindowWidgets::GetFontWidth() * 10, 0); ImGui::TableNextColumn(); ImGui::BeginDisabled(); @@ -202,3 +187,24 @@ void UCogInputWindow_Actions::RenderTick(float DeltaSeconds) ActionInfo.Inject(*EnhancedInput, IsTimeToRepeat); } } + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogInputWindow_Actions::DrawAxis(const char* Format, const char* ActionName, float CurrentValue, float* InjectValue) +{ + ImGui::PushID(Format); + ImGui::TableNextRow(); + + ImGui::TableNextColumn(); + ImGui::Text(Format, ActionName); + + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(-1); + ImGui::BeginDisabled(); + ImGui::SliderFloat("##Value", &CurrentValue, -1.0f, 1.0f, "%0.2f"); + ImGui::EndDisabled(); + + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(-1); + FCogWindowWidgets::SliderWithReset("##Inject", InjectValue, -1.0f, 1.0f, 0.0f, "%0.2f"); + ImGui::PopID(); +} \ No newline at end of file diff --git a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h index a759c4a..9f07b73 100644 --- a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h +++ b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h @@ -8,23 +8,32 @@ class UInputAction; class UCogInputDataAsset_Actions; -UCLASS() +UCLASS(Config = Cog) class COGINPUT_API UCogInputWindow_Actions : public UCogWindow { GENERATED_BODY() -public: - UCogInputWindow_Actions(); +protected: + + void RenderHelp() virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; + virtual void RenderContent() override; + virtual void RenderTick(float DeltaSeconds) override; + virtual void DrawAxis(const char* Format, const char* ActionName, float CurrentValue, float* InjectValue); + TWeakObjectPtr ActionsAsset; private: + UPROPERTY(Config) float RepeatPeriod = 0.5f; + + UPROPERTY(Config) float RepeatTime = 0.0f; + TArray Actions; }; diff --git a/Plugins/CogWindow/Source/CogWindow/Private/CogWindow.cpp b/Plugins/CogWindow/Source/CogWindow/Private/CogWindow.cpp index bc8f6ed..3f383ce 100644 --- a/Plugins/CogWindow/Source/CogWindow/Private/CogWindow.cpp +++ b/Plugins/CogWindow/Source/CogWindow/Private/CogWindow.cpp @@ -54,13 +54,40 @@ void UCogWindow::Render(float DeltaTime) ImGuiWindowFlags WindowFlags = 0; PreRender(WindowFlags); - if (ImGui::Begin(TCHAR_TO_ANSI(*GetTitle()), &bIsVisible, WindowFlags)) + const FString WindowTitle = GetTitle() + "##" + Name; + + if (ImGui::Begin(TCHAR_TO_ANSI(*WindowTitle), &bIsVisible, WindowFlags)) { + if (Owner->GetShowHelp()) + { + if (ImGui::IsItemHovered()) + { + ImGui::PushStyleColor(ImGuiCol_PopupBg, IM_COL32(29, 42, 62, 240)); + const float HelpWidth = FCogWindowWidgets::GetFontWidth() * 80; + ImGui::SetNextWindowSizeConstraints(ImVec2(HelpWidth / 2.0f, 0.0f), + ImVec2(HelpWidth, FLT_MAX)); + if (ImGui::BeginTooltip()) + { + ImGui::PushTextWrapPos(HelpWidth - 1 * FCogWindowWidgets::GetFontWidth()); + RenderHelp(); + ImGui::PopTextWrapPos(); + ImGui::EndTooltip(); + } + ImGui::PopStyleColor(); + } + } + RenderContent(); ImGui::End(); } } +//-------------------------------------------------------------------------------------------------------------------------- +void UCogWindow::RenderHelp() +{ + ImGui::Text("No help available."); +} + //-------------------------------------------------------------------------------------------------------------------------- void UCogWindow::RenderTick(float DeltaTime) { @@ -75,20 +102,20 @@ void UCogWindow::GameTick(float DeltaTime) //-------------------------------------------------------------------------------------------------------------------------- void UCogWindow::DrawMenuItem(const FString& MenuItemName) { - if (bShowInsideMenu && bIsVisible == false) + if (bShowInsideMenu) { - ImGui::SetNextWindowSizeConstraints(ImVec2(FCogWindowWidgets::TextBaseWidth * 40, FCogWindowWidgets::TextBaseHeight * 1), - ImVec2(FCogWindowWidgets::TextBaseWidth * 50, FCogWindowWidgets::TextBaseHeight * 60)); + ImGui::SetNextWindowSizeConstraints(ImVec2(FCogWindowWidgets::GetFontWidth() * 40, ImGui::GetTextLineHeightWithSpacing() * 1), + ImVec2(FCogWindowWidgets::GetFontWidth() * 50, ImGui::GetTextLineHeightWithSpacing() * 60)); if (ImGui::BeginMenu(TCHAR_TO_ANSI(*MenuItemName))) { RenderContent(); ImGui::EndMenu(); - - if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) - { - bIsVisible = !bIsVisible; - } + } + + if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) + { + bIsVisible = !bIsVisible; } } else diff --git a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp index 005078c..c674f71 100644 --- a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp @@ -66,9 +66,6 @@ void UCogWindowManager::Tick(float DeltaTime) //-------------------------------------------------------------------------------------------------------------------------- void UCogWindowManager::Render(float DeltaTime) { - FCogWindowWidgets::TextBaseWidth = ImGui::CalcTextSize("A").x; - FCogWindowWidgets::TextBaseHeight = ImGui::GetTextLineHeightWithSpacing(); - ImGui::DockSpaceOverViewport(0, ImGuiDockNodeFlags_PassthruCentralNode | ImGuiDockNodeFlags_NoDockingInCentralNode); bool bCompactSaved = bCompactMode; @@ -272,6 +269,7 @@ void UCogWindowManager::DrawMainMenu() ImGui::Text("DPI Scale"); ImGui::SameLine(); FCogWindowWidgets::PushStyleCompact(); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::SliderFloat("", &DPIScale, 0.5f, 2.0f, "%.1f"); if (ImGui::IsItemDeactivatedAfterEdit()) { @@ -287,7 +285,15 @@ void UCogWindowManager::DrawMainMenu() ImGui::EndTooltip(); } + ImGui::Separator(); + ImGui::MenuItem("Show Window Help", nullptr, &bShowHelp); + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::TextUnformatted("Should some help be displayed when the mouse is over a window title ?"); + ImGui::EndTooltip(); + } ImGui::EndMenu(); } diff --git a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowWidgets.cpp b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowWidgets.cpp index 769c165..26c1833 100644 --- a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowWidgets.cpp +++ b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowWidgets.cpp @@ -5,10 +5,6 @@ #include "imgui.h" #include "imgui_internal.h" -//-------------------------------------------------------------------------------------------------------------------------- -float FCogWindowWidgets::TextBaseWidth = 0.0f; -float FCogWindowWidgets::TextBaseHeight = 0.0f; - //-------------------------------------------------------------------------------------------------------------------------- void FCogWindowWidgets::BeginTableTooltip() { @@ -196,4 +192,17 @@ void FCogWindowWidgets::PushBackColor(const ImVec4& Color) void FCogWindowWidgets::PopBackColor() { ImGui::PopStyleColor(9); -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWindowWidgets::SetNextItemToShortWidth() +{ + ImGui::SetNextItemWidth(ImGui::GetFontSize() * 10); +} + +//-------------------------------------------------------------------------------------------------------------------------- +float FCogWindowWidgets::GetFontWidth() +{ + return ImGui::GetFontSize() * 0.5f; +} + diff --git a/Plugins/CogWindow/Source/CogWindow/Public/CogWindow.h b/Plugins/CogWindow/Source/CogWindow/Public/CogWindow.h index 69af966..bf726fa 100644 --- a/Plugins/CogWindow/Source/CogWindow/Public/CogWindow.h +++ b/Plugins/CogWindow/Source/CogWindow/Public/CogWindow.h @@ -59,6 +59,8 @@ protected: virtual const FString& GetTitle() const { return Name; } + virtual void RenderHelp(); + virtual void PreRender(ImGuiWindowFlags& WindowFlags) {} virtual void RenderContent() {} diff --git a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h index a8e4f31..996c7da 100644 --- a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h +++ b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h @@ -57,6 +57,8 @@ public: bool GetCompactMode() const { return bCompactMode; } + bool GetShowHelp() const { return bShowHelp; } + private: struct FMenu @@ -97,6 +99,9 @@ private: UPROPERTY(Config) float DPIScale = 1.0f; + UPROPERTY(Config) + bool bShowHelp = true; + TSharedPtr ImGuiWidget; TWeakObjectPtr World; diff --git a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowWidgets.h b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowWidgets.h index 148c8e6..c816b23 100644 --- a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowWidgets.h +++ b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowWidgets.h @@ -25,13 +25,13 @@ public: static void AddTextWithShadow(ImDrawList* DrawList, const ImVec2& Position, ImU32 Color, const char* TextBegin, const char* TextEnd = NULL); - static float TextBaseWidth; - - static float TextBaseHeight; - static void MenuSearchBar(ImGuiTextFilter& Filter); static void PushBackColor(const ImVec4& Color); static void PopBackColor(); + + static void SetNextItemToShortWidth(); + + static float GetFontWidth(); }; diff --git a/Source/CogSample/CogSampleGameState.cpp b/Source/CogSample/CogSampleGameState.cpp index aae5739..313c9ce 100644 --- a/Source/CogSample/CogSampleGameState.cpp +++ b/Source/CogSample/CogSampleGameState.cpp @@ -39,7 +39,7 @@ #include "CogEngineWindow_Skeleton.h" #include "CogEngineWindow_Spawns.h" #include "CogEngineWindow_Stats.h" -#include "CogEngineWindow_Time.h" +#include "CogEngineWindow_TimeScale.h" #include "CogImguiModule.h" #include "CogInputDataAsset_Actions.h" #include "CogInputWindow_Actions.h" @@ -158,6 +158,8 @@ void ACogSampleGameState::InitializeCog() CogWindowManager->CreateWindow("Engine.Output Log"); + CogWindowManager->CreateWindow("Engine.Metrics"); + CogWindowManager->CreateWindow("Engine.Plots"); UCogEngineWindow_Selection* SelectionWindow = CogWindowManager->CreateWindow("Engine.Selection"); @@ -174,7 +176,7 @@ void ACogSampleGameState::InitializeCog() UCogEngineWindow_Stats* StatsWindow = CogWindowManager->CreateWindow("Engine.Stats"); - CogWindowManager->CreateWindow("Engine.Time"); + CogWindowManager->CreateWindow("Engine.Time Scale"); //--------------------------------------- // Abilities @@ -186,9 +188,6 @@ void ACogSampleGameState::InitializeCog() UCogAbilityWindow_Cheats* CheatsWindow = CogWindowManager->CreateWindow("Gameplay.Cheats"); CheatsWindow->CheatsAsset = GetFirstAssetByClass(); - - CogWindowManager->CreateWindow("Gameplay.Metrics"); - UCogAbilityWindow_Effects* EffectsWindow = CogWindowManager->CreateWindow("Gameplay.Effects"); EffectsWindow->NegativeEffectTag = Tag_Effect_Alignment_Negative; EffectsWindow->PositiveEffectTag = Tag_Effect_Alignment_Positive;