From 9eeaec254a03bfda628d592d83ac68713d1357b7 Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Tue, 3 Oct 2023 12:04:56 -0400 Subject: [PATCH] moved metric to CogDebug --- .../Private/CogAbilityWindow_Metrics.cpp | 280 ------------------ .../Public/CogAbilityWindow_Metrics.h | 99 ------- .../CogDebug/Private/CogDebugMetric.cpp | 163 ++++++++++ .../Source/CogDebug/Public/CogDebugMetric.h | 95 ++++++ .../Private/CogEngineWindow_Metrics.cpp | 152 ++++++++++ ...w_Spawn.cpp => CogEngineWindow_Spawns.cpp} | 10 +- .../Public/CogEngineWindow_Metrics.h | 38 +++ ...indow_Spawn.h => CogEngineWindow_Spawns.h} | 4 +- .../Public/CogInterfaceFilteredActor.h | 2 - .../Public/CogInterfaceMetricActor.h | 38 --- .../Source/CogWindow/Private/CogWindow.cpp | 5 +- .../CogWindow/Private/CogWindowManager.cpp | 27 +- .../CogWindow/Public/CogWindowManager.h | 8 +- Source/CogSample/CogSampleCharacter.cpp | 17 +- Source/CogSample/CogSampleCharacter.h | 43 ++- Source/CogSample/CogSampleGameState.cpp | 36 +-- 16 files changed, 531 insertions(+), 486 deletions(-) delete mode 100644 Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Metrics.cpp delete mode 100644 Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Metrics.h create mode 100644 Plugins/CogDebug/Source/CogDebug/Private/CogDebugMetric.cpp create mode 100644 Plugins/CogDebug/Source/CogDebug/Public/CogDebugMetric.h create mode 100644 Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp rename Plugins/CogEngine/Source/CogEngine/Private/{CogEngineWindow_Spawn.cpp => CogEngineWindow_Spawns.cpp} (88%) create mode 100644 Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h rename Plugins/CogEngine/Source/CogEngine/Public/{CogEngineWindow_Spawn.h => CogEngineWindow_Spawns.h} (86%) delete mode 100644 Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceMetricActor.h diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Metrics.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Metrics.cpp deleted file mode 100644 index 38f3ded..0000000 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Metrics.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#include "CogAbilityWindow_Metrics.h" - -#include "CogInterfaceMetricActor.h" -#include "CogImguiHelper.h" -#include "imgui.h" - -//-------------------------------------------------------------------------------------------------------------------------- -void FCogMetricInstance::Restart() -{ - Last = 0.0f; - Min = 0.0f; - Max = 0.0f; - PerSecond = 0.0f; - PerFrame = 0.0f; - Total = 0.0f; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void FCogMetricInstance::AddMetric(const float Metric) -{ - Last = Metric; - Min = Min == 0.0f ? Metric : FMath::Min(Min, Metric); - Max = FMath::Max(Max, Metric); - PerFrame += Metric; - Total += Metric; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void FCogMetricInstance::UpdateMetricPerSecond(const float Duration) -{ - PerSecond = Duration > 1.0f ? Total / Duration : Total; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void FCogMetricInfo::Restart() -{ - Count = 0; - Crits = 0; - TotalCritChances = 0.0f; - - IsInProgress = false; - Timer = 0.0f; - RestartTimer = 0.0f; - - Mitigated.Restart(); - Unmitigated.Restart(); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void FCogMetricInfo::AddEvent(const FCogInterfaceMetricEventParams& Params) -{ - // If the max duration is reached, stop adding - if (MaxDurationSetting != 0 && Timer >= MaxDurationSetting) - { - return; - } - - IsInProgress = true; - Count++; - Crits += Params.IsCritical ? 1 : 0; - - Mitigated.AddMetric(Params.MitigatedValue); - Unmitigated.AddMetric(Params.UnmitigatedValue); - Mitigated.UpdateMetricPerSecond(Timer); - Unmitigated.UpdateMetricPerSecond(Timer); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void FCogMetricInfo::Tick(const float DeltaSeconds) -{ - if (IsInProgress) - { - // If the max duration is reached, stop increasing time. - if (MaxDurationSetting <= 0 || Timer < MaxDurationSetting) - { - Timer += DeltaSeconds; - } - else - { - IsInProgress = false; - Timer = MaxDurationSetting; - Mitigated.UpdateMetricPerSecond(Timer); - Unmitigated.UpdateMetricPerSecond(Timer); - } - } - - if (RestartDelaySetting > 0.0f) - { - if (Unmitigated.PerFrame == 0.0f) - { - RestartTimer += DeltaSeconds; - if (RestartTimer > RestartDelaySetting) - { - Restart(); - } - } - else - { - RestartTimer = 0.0f; - } - } - - Mitigated.PerFrame = 0.0f; - Unmitigated.PerFrame = 0.0f; -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Metrics::DrawMetricRow(const char* Title, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color) -{ - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::Selectable(Title, false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick); - ImGui::TableNextColumn(); - ImGui::TextColored(Color, "%.1f", MitigatedValue); - ImGui::TableNextColumn(); - ImGui::Text("%.1f", UnmitigatedValue); - ImGui::TableNextColumn(); - ImGui::Text("%.0f%%", UnmitigatedValue <= 0 ? 0.0 : 100.0f * (1.0f - (MitigatedValue / UnmitigatedValue))); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Metrics::DrawMetrics(FCogMetricInfo& Metric) -{ - FCogWindowWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1.0f)); - - if (ImGui::BeginTable("MetricTable", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg)) - { - ImGui::TableSetupColumn(""); - ImGui::TableSetupColumn("Mitigated"); - ImGui::TableSetupColumn("Unmitigated"); - ImGui::TableSetupColumn("Mitigation %"); - ImGui::TableHeadersRow(); - - DrawMetricRow("Per Second", Metric.Mitigated.PerSecond, Metric.Unmitigated.PerSecond, ImVec4(1.0f, 1.0, 0.0f, 1.0f)); - DrawMetricRow("Total", Metric.Mitigated.Total, Metric.Unmitigated.Total, ImVec4(1.0f, 1.0, 1.0f, 1.0f)); - DrawMetricRow("Last", Metric.Mitigated.Last, Metric.Unmitigated.Last, ImVec4(1.0f, 1.0, 1.0f, 1.0f)); - DrawMetricRow("Min", Metric.Mitigated.Min, Metric.Unmitigated.Min, ImVec4(1.0f, 1.0, 1.0f, 1.0f)); - DrawMetricRow("Min", Metric.Mitigated.Max, Metric.Unmitigated.Max, ImVec4(1.0f, 1.0, 1.0f, 1.0f)); - - ImGui::EndTable(); - } - - ImGui::Text("Crits"); - ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 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 (Metric.MaxDurationSetting > 0.0f) - { - ImGui::Text("Timer"); - ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20); - FCogWindowWidgets::ProgressBarCentered(Metric.Timer / (float)Metric.MaxDurationSetting, ImVec2(-1, 0), TCHAR_TO_ANSI(*FString::Printf(TEXT("%0.1f / %0.1f"), Metric.Timer, Metric.MaxDurationSetting))); - } - else - { - ImGui::Text("Timer"); - ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20); - ImGui::Text("%0.1f", Metric.Timer); - } - - ImGui::Spacing(); - - if (ImGui::Button("Restart")) - { - Metric.Restart(); - } - - FCogWindowWidgets::PopBackColor(); - - ImGui::Spacing(); - ImGui::Spacing(); -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Metrics::RenderContent() -{ - Super::RenderContent(); - - AActor* Selection = GetSelection(); - if (Selection == nullptr) - { - return; - } - - int32 Index = 0; - for (auto& Entry : Metrics) - { - FName MetricName = Entry.Key; - FCogMetricInfo& Metric = Entry.Value; - - if (ImGui::CollapsingHeader(TCHAR_TO_ANSI(*MetricName.ToString()))) - { - ImGui::PushID(Index); - DrawMetrics(Metric); - ImGui::PopID(); - } - - Index++; - } - - if (ImGui::CollapsingHeader("Settings")) - { - ImGui::PushItemWidth(-1); - - bool Reset = false; - - ImGui::Text("Auto Restart"); - ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20); - bool AutoRestart = RestartDelaySetting > 0; - if (ImGui::Checkbox("##Auto Restart", &AutoRestart)) - { - RestartDelaySetting = AutoRestart ? 5.0f : 0.0f; - Reset = true; - } - - if (AutoRestart) - { - ImGui::Text("Auto Restart Delay"); - ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20); - if (ImGui::InputFloat("##Auto Restart Delay", &RestartDelaySetting)) - { - Reset = true; - } - } - - ImGui::Text("Max Time"); - ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 20); - if (ImGui::InputFloat("##Max Time", &MaxDurationSetting, 0.0f, 0.0f, "%0.1f")) - { - Reset = true; - } - - if (Reset) - { - for (auto& Entry : Metrics) - { - FCogMetricInfo& Metric = Entry.Value; - - Metric.MaxDurationSetting = MaxDurationSetting; - Metric.RestartDelaySetting = RestartDelaySetting; - Metric.Restart(); - } - } - - ImGui::PopItemWidth(); - } -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Metrics::OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) -{ - if (ICogInterfaceMetricActor* DamageActor = Cast(OldSelection)) - { - DamageActor->OnMetricEvent().Remove(OnMetricDelegate); - } - - if (ICogInterfaceMetricActor* DamageActor = Cast(NewSelection)) - { - OnMetricDelegate = DamageActor->OnMetricEvent().AddUObject(this, &UCogAbilityWindow_Metrics::OnEvent); - } -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Metrics::GameTick(float DeltaSeconds) -{ - Super::GameTick(DeltaSeconds); - - for (auto& Entry : Metrics) - { - FCogMetricInfo& Metric = Entry.Value; - Metric.Tick(DeltaSeconds); - } -} - -//-------------------------------------------------------------------------------------------------------------------------- -void UCogAbilityWindow_Metrics::OnEvent(const FCogInterfaceMetricEventParams& Params) -{ - FCogMetricInfo& MetricInfo = Metrics.FindOrAdd(Params.Name); - - MetricInfo.AddEvent(Params); -} \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Metrics.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Metrics.h deleted file mode 100644 index 04e0969..0000000 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Metrics.h +++ /dev/null @@ -1,99 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "CogWindow.h" -#include "CogAbilityWindow_Metrics.generated.h" - -struct FCogInterfaceMetricEventParams; - -//-------------------------------------------------------------------------------------------------------------------------- -class FCogMetricInstance -{ -public: - void Restart(); - - void AddMetric(const float Damage); - - void UpdateMetricPerSecond(const float Duration); - - float Last = 0.0f; - - float Min = 0.0f; - - float Max = 0.0f; - - float PerFrame = 0.0f; - - float PerSecond = 0.0f; - - float Total = 0.0f; -}; - -//-------------------------------------------------------------------------------------------------------------------------- -class FCogMetricInfo -{ -public: - void AddEvent(const FCogInterfaceMetricEventParams& Params); - - void Tick(const float DeltaSeconds); - - void Restart(); - - FName Name; - - int Count = 0; - - int Crits = 0; - - bool IsInProgress = false; - - float TotalCritChances = 0.0f; - - float Timer = 0.0f; - - float RestartTimer = 0.0f; - - FCogMetricInstance Mitigated; - - FCogMetricInstance Unmitigated; - - float MaxDurationSetting = 0.0f; - - float RestartDelaySetting = 0.0f; -}; - -//-------------------------------------------------------------------------------------------------------------------------- -UCLASS(Config = Cog) -class COGABILITY_API UCogAbilityWindow_Metrics : public UCogWindow -{ - GENERATED_BODY() - -public: - -protected: - - virtual void RenderContent() override; - - virtual void GameTick(float DeltaSeconds) override; - - virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) override; - - virtual void DrawMetrics(FCogMetricInfo& Metric); - - virtual void DrawMetricRow(const char* Title, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color); - -private: - - UFUNCTION() - void OnEvent(const FCogInterfaceMetricEventParams& Params); - - UPROPERTY(Config) - float MaxDurationSetting = 0.0f; - - UPROPERTY(Config) - float RestartDelaySetting = 5.0f; - - TMap Metrics; - - FDelegateHandle OnMetricDelegate; -}; diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugMetric.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugMetric.cpp new file mode 100644 index 0000000..bcf6963 --- /dev/null +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugMetric.cpp @@ -0,0 +1,163 @@ +#include "CogDebugMetric.h" + +#include "CogDebugSettings.h" +#include "CogInterfaceFilteredActor.h" + +//-------------------------------------------------------------------------------------------------------------------------- +float FCogDebugMetric::MaxDurationSetting = 0.0f; +float FCogDebugMetric::RestartDelaySetting = 5.0f; +bool FCogDebugMetric::IsVisible = false; +TMap FCogDebugMetric::Metrics; + +//-------------------------------------------------------------------------------------------------------------------------- +// FCogDebugMetric +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetric::AddMetric(const FCogDebugMetricParams& Params) +{ + if (Cast(Params.WorldContextObject)) + { + if (Params.WorldContextObject != FCogDebugSettings::GetSelection()) + { + return; + } + } + + FCogDebugMetricEntry& Entry = Metrics.FindOrAdd(Params.Name); + Entry.Add(Params); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetric::AddMetric(const UObject* WorldContextObject, FName Name, float MitigatedValue, float UnmitigatedValue, bool IsCritical) +{ + FCogDebugMetricParams Params; + Params.WorldContextObject = WorldContextObject; + Params.Name = Name; + Params.MitigatedValue = MitigatedValue; + Params.UnmitigatedValue = UnmitigatedValue; + Params.IsCritical = IsCritical; + AddMetric(Params); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetric::Tick(float DeltaSeconds) +{ + for (auto& Entry : Metrics) + { + FCogDebugMetricEntry& Metric = Entry.Value; + Metric.Tick(DeltaSeconds); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetric::Reset() +{ + for (auto& Entry : Metrics) + { + FCogDebugMetricEntry& Metric = Entry.Value; + Metric.Reset(); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +// FCogMetricInstance +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetricValue::Reset() +{ + Last = 0.0f; + Min = 0.0f; + Max = 0.0f; + PerSecond = 0.0f; + PerFrame = 0.0f; + Total = 0.0f; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetricValue::AddMetric(const float Metric) +{ + Last = Metric; + Min = Min == 0.0f ? Metric : FMath::Min(Min, Metric); + Max = FMath::Max(Max, Metric); + PerFrame += Metric; + Total += Metric; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetricValue::UpdateMetricPerSecond(const float Duration) +{ + PerSecond = Duration > 1.0f ? Total / Duration : Total; +} + +//-------------------------------------------------------------------------------------------------------------------------- +// +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetricEntry::Reset() +{ + Count = 0; + Crits = 0; + TotalCritChances = 0.0f; + + IsInProgress = false; + Timer = 0.0f; + RestartTimer = 0.0f; + + Mitigated.Reset(); + Unmitigated.Reset(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetricEntry::Add(const FCogDebugMetricParams& Params) +{ + // If the max duration is reached, stop adding + if (FCogDebugMetric::MaxDurationSetting != 0 && Timer >= FCogDebugMetric::MaxDurationSetting) + { + return; + } + + IsInProgress = true; + Count++; + Crits += Params.IsCritical ? 1 : 0; + + Mitigated.AddMetric(Params.MitigatedValue); + Unmitigated.AddMetric(Params.UnmitigatedValue); + Mitigated.UpdateMetricPerSecond(Timer); + Unmitigated.UpdateMetricPerSecond(Timer); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogDebugMetricEntry::Tick(const float DeltaSeconds) +{ + if (IsInProgress) + { + // If the max duration is reached, stop increasing time. + if (FCogDebugMetric::MaxDurationSetting <= 0 || Timer < FCogDebugMetric::MaxDurationSetting) + { + Timer += DeltaSeconds; + } + else + { + IsInProgress = false; + Timer = FCogDebugMetric::MaxDurationSetting; + Mitigated.UpdateMetricPerSecond(Timer); + Unmitigated.UpdateMetricPerSecond(Timer); + } + } + + if (FCogDebugMetric::RestartDelaySetting > 0.0f) + { + if (Unmitigated.PerFrame == 0.0f) + { + RestartTimer += DeltaSeconds; + if (RestartTimer > FCogDebugMetric::RestartDelaySetting) + { + Reset(); + } + } + else + { + RestartTimer = 0.0f; + } + } + + Mitigated.PerFrame = 0.0f; + Unmitigated.PerFrame = 0.0f; +} \ No newline at end of file diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugMetric.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugMetric.h new file mode 100644 index 0000000..c79e5b3 --- /dev/null +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugMetric.h @@ -0,0 +1,95 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogDebugDefines.h" + +#ifdef ENABLE_COG + +//-------------------------------------------------------------------------------------------------------------------------- +struct COGDEBUG_API FCogDebugMetricParams +{ + TObjectPtr WorldContextObject = nullptr; + + FName Name; + + float MitigatedValue = 0; + + float UnmitigatedValue = 0; + + bool IsCritical = false; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +struct COGDEBUG_API FCogDebugMetricValue +{ + void Reset(); + + void AddMetric(const float Damage); + + void UpdateMetricPerSecond(const float Duration); + + float Last = 0.0f; + + float Min = 0.0f; + + float Max = 0.0f; + + float PerFrame = 0.0f; + + float PerSecond = 0.0f; + + float Total = 0.0f; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +struct COGDEBUG_API FCogDebugMetricEntry +{ +public: + + void Add(const FCogDebugMetricParams& Params); + + void Tick(const float DeltaSeconds); + + void Reset(); + + int Count = 0; + + int Crits = 0; + + bool IsInProgress = false; + + float TotalCritChances = 0.0f; + + float Timer = 0.0f; + + float RestartTimer = 0.0f; + + FCogDebugMetricValue Mitigated; + + FCogDebugMetricValue Unmitigated; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +class COGDEBUG_API FCogDebugMetric +{ +public: + + static void Tick(float DeltaSeconds); + + static void AddMetric(const FCogDebugMetricParams& Params); + + static void AddMetric(const UObject* WorldContextObject, FName Name, float MitigatedValue, float UnmitigatedValue, bool IsCritical); + + static void Reset(); + + static bool IsVisible; + + static float MaxDurationSetting; + + static float RestartDelaySetting; + + static TMap Metrics; +}; + +#endif //ENABLE_COG + diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp new file mode 100644 index 0000000..b2b6005 --- /dev/null +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp @@ -0,0 +1,152 @@ +#include "CogEngineWindow_Metrics.h" + +#include "CogDebugMetric.h" +#include "CogImguiHelper.h" +#include "imgui.h" + + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Metrics::PostLoad() +{ + FCogDebugMetric::MaxDurationSetting = MaxDurationSetting; + FCogDebugMetric::RestartDelaySetting = RestartDelaySetting; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Metrics::PreRender(ImGuiWindowFlags& WindowFlags) +{ + WindowFlags = ImGuiWindowFlags_MenuBar; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Metrics::RenderTick(float DeltaTime) +{ + Super::RenderTick(DeltaTime); + FCogDebugMetric::IsVisible = GetIsVisible(); + + FCogDebugMetric::Tick(DeltaTime); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Metrics::RenderContent() +{ + Super::RenderContent(); + + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("Options")) + { + bool bSettingModified = false; + + FCogWindowWidgets::PushStyleCompact(); + if (ImGui::DragFloat("Auto Restart Delay", &RestartDelaySetting, 0.1f, 0.0f, FLT_MAX, "%0.1f")) + { + FCogDebugMetric::RestartDelaySetting = RestartDelaySetting; + } + FCogWindowWidgets::PopStyleCompact(); + + FCogWindowWidgets::PushStyleCompact(); + if (ImGui::DragFloat("Max Time", &MaxDurationSetting, 0.1f, 0.0f, FLT_MAX, "%0.1f")) + { + FCogDebugMetric::MaxDurationSetting = MaxDurationSetting; + } + FCogWindowWidgets::PopStyleCompact(); + + ImGui::EndMenu(); + } + + ImGui::EndMenuBar(); + } + + if (FCogDebugMetric::Metrics.IsEmpty()) + { + ImGui::BeginDisabled(); + ImGui::Text("No metric received yet"); + ImGui::EndDisabled(); + } + else + { + int32 Index = 0; + for (auto& Entry : FCogDebugMetric::Metrics) + { + FName MetricName = Entry.Key; + FCogDebugMetricEntry& Metric = Entry.Value; + + if (ImGui::CollapsingHeader(TCHAR_TO_ANSI(*MetricName.ToString()), ImGuiTreeNodeFlags_DefaultOpen)) + { + ImGui::PushID(Index); + DrawMetric(Metric); + ImGui::PopID(); + } + + Index++; + } + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Metrics::DrawMetric(FCogDebugMetricEntry& Metric) +{ + FCogWindowWidgets::PushBackColor(ImVec4(0.8f, 0.8f, 0.8f, 1.0f)); + + if (ImGui::BeginTable("MetricTable", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg)) + { + ImGui::TableSetupColumn(""); + ImGui::TableSetupColumn("Mitigated"); + ImGui::TableSetupColumn("Unmitigated"); + ImGui::TableSetupColumn("Mitigation %"); + ImGui::TableHeadersRow(); + + DrawMetricRow("Per Second", Metric.Mitigated.PerSecond, Metric.Unmitigated.PerSecond, ImVec4(1.0f, 1.0, 0.0f, 1.0f)); + DrawMetricRow("Total", Metric.Mitigated.Total, Metric.Unmitigated.Total, ImVec4(1.0f, 1.0, 1.0f, 1.0f)); + DrawMetricRow("Last", Metric.Mitigated.Last, Metric.Unmitigated.Last, ImVec4(1.0f, 1.0, 1.0f, 1.0f)); + DrawMetricRow("Min", Metric.Mitigated.Min, Metric.Unmitigated.Min, ImVec4(1.0f, 1.0, 1.0f, 1.0f)); + DrawMetricRow("Min", Metric.Mitigated.Max, Metric.Unmitigated.Max, ImVec4(1.0f, 1.0, 1.0f, 1.0f)); + + ImGui::EndTable(); + } + + ImGui::Text("Crits"); + ImGui::SameLine(FCogWindowWidgets::TextBaseWidth * 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); + 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::Text("%0.1f", Metric.Timer); + } + + ImGui::Spacing(); + + FCogWindowWidgets::PopBackColor(); + + if (ImGui::Button("Restart")) + { + Metric.Reset(); + } + + ImGui::Spacing(); + ImGui::Spacing(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void UCogEngineWindow_Metrics::DrawMetricRow(const char* Title, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color) +{ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Selectable(Title, false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick); + ImGui::TableNextColumn(); + ImGui::TextColored(Color, "%.1f", MitigatedValue); + ImGui::TableNextColumn(); + ImGui::Text("%.1f", UnmitigatedValue); + ImGui::TableNextColumn(); + ImGui::Text("%.0f%%", UnmitigatedValue <= 0 ? 0.0 : 100.0f * (1.0f - (MitigatedValue / UnmitigatedValue))); +} + diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawn.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp similarity index 88% rename from Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawn.cpp rename to Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp index bfb6694..bc62032 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawn.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp @@ -1,13 +1,13 @@ -#include "CogEngineWindow_Spawn.h" +#include "CogEngineWindow_Spawns.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Spawn::PreRender(ImGuiWindowFlags& WindowFlags) +void UCogEngineWindow_Spawns::PreRender(ImGuiWindowFlags& WindowFlags) { Super::PreRender(WindowFlags); } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Spawn::RenderContent() +void UCogEngineWindow_Spawns::RenderContent() { Super::RenderContent(); @@ -23,7 +23,7 @@ void UCogEngineWindow_Spawn::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogEngineWindow_Spawn::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup) +void UCogEngineWindow_Spawns::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup) { int32 GroupIndex = 0; @@ -67,7 +67,7 @@ void UCogEngineWindow_Spawn::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnG } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogEngineWindow_Spawn::RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected) +bool UCogEngineWindow_Spawns::RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected) { bool IsPressed = false; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h new file mode 100644 index 0000000..71c022c --- /dev/null +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Metrics.h @@ -0,0 +1,38 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogWindow.h" +#include "CogEngineWindow_Metrics.generated.h" + +struct FCogDebugMetricEntry; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class COGENGINE_API UCogEngineWindow_Metrics : public UCogWindow +{ + GENERATED_BODY() + +public: + +protected: + + virtual void PostLoad() override; + + virtual void PreRender(ImGuiWindowFlags& WindowFlags) override; + + virtual void RenderContent() override; + + virtual void RenderTick(float DeltaTime) override; + + virtual void DrawMetric(FCogDebugMetricEntry& Metric); + + virtual void DrawMetricRow(const char* Title, float MitigatedValue, float UnmitigatedValue, const ImVec4& Color); + +private: + + UPROPERTY(Config) + float MaxDurationSetting = 0.0f; + + UPROPERTY(Config) + float RestartDelaySetting = 5.0f; +}; diff --git a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawn.h b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawns.h similarity index 86% rename from Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawn.h rename to Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawns.h index f54173f..f8b718d 100644 --- a/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawn.h +++ b/Plugins/CogEngine/Source/CogEngine/Public/CogEngineWindow_Spawns.h @@ -2,13 +2,13 @@ #include "CoreMinimal.h" #include "CogWindow.h" -#include "CogEngineWindow_Spawn.generated.h" +#include "CogEngineWindow_Spawns.generated.h" class UCogEngineDataAsset_Spawns; struct FCogEngineSpawnGroup; UCLASS() -class COGENGINE_API UCogEngineWindow_Spawn : public UCogWindow +class COGENGINE_API UCogEngineWindow_Spawns : public UCogWindow { GENERATED_BODY() diff --git a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceFilteredActor.h b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceFilteredActor.h index de13c0f..808a1ed 100644 --- a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceFilteredActor.h +++ b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceFilteredActor.h @@ -12,6 +12,4 @@ class UCogInterfacesFilteredActor : public UInterface class ICogInterfacesFilteredActor { GENERATED_BODY() - - virtual bool IsActorFilteringDebug() const { return true; } }; diff --git a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceMetricActor.h b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceMetricActor.h deleted file mode 100644 index 51248c9..0000000 --- a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceMetricActor.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "CogInterfaceMetricActor.generated.h" - -//-------------------------------------------------------------------------------------------------------------------------- -USTRUCT() -struct FCogInterfaceMetricEventParams -{ - GENERATED_BODY() - - FName Name; - - float MitigatedValue = 0; - - float UnmitigatedValue = 0; - - bool IsCritical = false; -}; - -//-------------------------------------------------------------------------------------------------------------------------- -DECLARE_MULTICAST_DELEGATE_OneParam(FCogInterfaceOnMetricEvent, const FCogInterfaceMetricEventParams&); - -//-------------------------------------------------------------------------------------------------------------------------- -UINTERFACE(MinimalAPI, Blueprintable) -class UCogInterfaceMetricActor : public UInterface -{ - GENERATED_BODY() -}; - -//-------------------------------------------------------------------------------------------------------------------------- -class ICogInterfaceMetricActor -{ - GENERATED_BODY() - -public: - virtual FCogInterfaceOnMetricEvent& OnMetricEvent() = 0; -}; \ No newline at end of file diff --git a/Plugins/CogWindow/Source/CogWindow/Private/CogWindow.cpp b/Plugins/CogWindow/Source/CogWindow/Private/CogWindow.cpp index 33db8fc..bc8f6ed 100644 --- a/Plugins/CogWindow/Source/CogWindow/Private/CogWindow.cpp +++ b/Plugins/CogWindow/Source/CogWindow/Private/CogWindow.cpp @@ -77,9 +77,8 @@ void UCogWindow::DrawMenuItem(const FString& MenuItemName) { if (bShowInsideMenu && bIsVisible == false) { - static const ImVec2 TEXT_BASE_SIZE = ImGui::CalcTextSize("A"); - ImGui::SetNextWindowSizeConstraints(ImVec2(TEXT_BASE_SIZE.x * 40, TEXT_BASE_SIZE.y * 1), - ImVec2(TEXT_BASE_SIZE.x * 50, TEXT_BASE_SIZE.y * 60)); + ImGui::SetNextWindowSizeConstraints(ImVec2(FCogWindowWidgets::TextBaseWidth * 40, FCogWindowWidgets::TextBaseHeight * 1), + ImVec2(FCogWindowWidgets::TextBaseWidth * 50, FCogWindowWidgets::TextBaseHeight * 60)); if (ImGui::BeginMenu(TCHAR_TO_ANSI(*MenuItemName))) { diff --git a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp index 007d318..005078c 100644 --- a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp @@ -108,10 +108,18 @@ void UCogWindowManager::Render(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::AddWindow(UCogWindow* Window) +void UCogWindowManager::AddWindow(UCogWindow* Window, bool AddToMainMenu /*= true*/) { Window->SetOwner(this); Windows.Add(Window); + + if (AddToMainMenu) + { + if (FMenu* Menu = AddMenu(Window->GetFullName())) + { + Menu->Window = Window; + } + } } //-------------------------------------------------------------------------------------------------------------------------- @@ -169,16 +177,21 @@ void UCogWindowManager::SaveLayout(int LayoutIndex) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::RebuildMenu() +void UCogWindowManager::SortMainMenu() { MainMenu.SubMenus.Empty(); - for (UCogWindow* Window : Windows) - { - check(Window); + Windows.Sort(); - FMenu* NewMenu = AddMenu(Window->GetFullName()); - NewMenu->Window = Window; + TArray SortedWindows = Windows; + SortedWindows.Sort([](UCogWindow& Lhs, UCogWindow& Rhs) { return Lhs.GetFullName() < Rhs.GetFullName(); }); + + for (UCogWindow* Window : SortedWindows) + { + if (FMenu* Menu = AddMenu(Window->GetFullName())) + { + Menu->Window = Window; + } } } diff --git a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h index 1d0e3e7..a8e4f31 100644 --- a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h +++ b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h @@ -23,23 +23,23 @@ public: void Shutdown(); - void RebuildMenu(); + void SortMainMenu(); void Render(float DeltaTime); void Tick(float DeltaTime); template - T* CreateWindow(const FString& Name) + T* CreateWindow(const FString& Name, bool AddToMainMenu = true) { T* Window = NewObject(this); Window->SetFullName(Name); Window->Initialize(); - AddWindow(Window); + AddWindow(Window, AddToMainMenu); return Window; } - void AddWindow(UCogWindow* Window); + void AddWindow(UCogWindow* Window, bool AddToMainMenu = true); void AddMainMenuWidget(UCogWindow* Window); diff --git a/Source/CogSample/CogSampleCharacter.cpp b/Source/CogSample/CogSampleCharacter.cpp index af9bb93..6237c54 100644 --- a/Source/CogSample/CogSampleCharacter.cpp +++ b/Source/CogSample/CogSampleCharacter.cpp @@ -2,6 +2,7 @@ #include "Camera/CameraComponent.h" #include "CogDebugLogMacros.h" +#include "CogDebugMetric.h" #include "CogSampleAttributeSet_Health.h" #include "CogSampleAttributeSet_Misc.h" #include "CogSampleCharacterMovementComponent.h" @@ -345,26 +346,18 @@ void ACogSampleCharacter::Look(const FInputActionValue& Value) } //-------------------------------------------------------------------------------------------------------------------------- -void ACogSampleCharacter::OnDamageReceived(float ReceivedDamage, float IncomingDamage, AActor* DamageDealer, const FGameplayEffectSpec& EffectSpec) +void ACogSampleCharacter::OnDamageReceived(float MitigatedDamage, float UnmitigatedDamage, AActor* DamageDealer, const FGameplayEffectSpec& EffectSpec) { #if USE_COG - FCogInterfaceMetricEventParams Params; - Params.Name = "Damage Received"; - Params.MitigatedValue = ReceivedDamage; - Params.UnmitigatedValue = IncomingDamage; - OnMetricEventDelegate.Broadcast(Params); + FCogDebugMetric::AddMetric(this, "Damage Received", MitigatedDamage, UnmitigatedDamage, false); #endif //USE_COG } //-------------------------------------------------------------------------------------------------------------------------- -void ACogSampleCharacter::OnDamageDealt(float ReceivedDamage, float IncomingDamage, AActor* DamageReceiver, const FGameplayEffectSpec& EffectSpec) +void ACogSampleCharacter::OnDamageDealt(float MitigatedDamage, float UnmitigatedDamage, AActor* DamageReceiver, const FGameplayEffectSpec& EffectSpec) { #if USE_COG - FCogInterfaceMetricEventParams Params; - Params.Name = "Damage Dealt"; - Params.MitigatedValue = ReceivedDamage; - Params.UnmitigatedValue = IncomingDamage; - OnMetricEventDelegate.Broadcast(Params); + FCogDebugMetric::AddMetric(this, "Damage Dealt", MitigatedDamage, UnmitigatedDamage, false); #endif //USE_COG } diff --git a/Source/CogSample/CogSampleCharacter.h b/Source/CogSample/CogSampleCharacter.h index ff1fffa..b8c393b 100644 --- a/Source/CogSample/CogSampleCharacter.h +++ b/Source/CogSample/CogSampleCharacter.h @@ -5,7 +5,6 @@ #include "ActiveGameplayEffectHandle.h" #include "AttributeSet.h" #include "CogDefines.h" -#include "CogInterfaceMetricActor.h" #include "CogInterfaceFilteredActor.h" #include "GameFramework/Character.h" #include "GameplayAbilitySpecHandle.h" @@ -59,7 +58,6 @@ UCLASS(config=Game) class ACogSampleCharacter : public ACharacter , public IAbilitySystemInterface , public ICogInterfacesFilteredActor - , public ICogInterfaceMetricActor { GENERATED_BODY() @@ -70,14 +68,22 @@ public: // ACharacter overrides //---------------------------------------------------------------------------------------------------------------------- virtual void BeginPlay(); + virtual void EndPlay(const EEndPlayReason::Type EndPlayReason); + virtual void MarkComponentsAsPendingKill() override; + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + virtual void PossessedBy(AController* NewController) override; - virtual FCogInterfaceOnMetricEvent& OnMetricEvent() override { return OnMetricEventDelegate; } - virtual bool IsActorFilteringDebug() const override { return true; } + //---------------------------------------------------------------------------------------------------------------------- + // IAbilitySystemInterface overrides + //---------------------------------------------------------------------------------------------------------------------- + UFUNCTION(BlueprintPure) + UAbilitySystemComponent* GetAbilitySystemComponent() const override; + //---------------------------------------------------------------------------------------------------------------------- void OnAcknowledgePossession(APlayerController* InController); void OnDamageReceived(float DamageAmount, float UnmitigatedDamageAmount, AActor* DamageDealer, const FGameplayEffectSpec& EffectSpec); @@ -92,9 +98,8 @@ public: UCameraComponent* GetFollowCamera() const { return FollowCamera; } - UFUNCTION(BlueprintPure) - UAbilitySystemComponent* GetAbilitySystemComponent() const override; - + //---------------------------------------------------------------------------------------------------------------------- + // Camera //---------------------------------------------------------------------------------------------------------------------- /** Camera boom positioning the camera behind the character */ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) @@ -104,6 +109,9 @@ public: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true")) UCameraComponent* FollowCamera; + //---------------------------------------------------------------------------------------------------------------------- + // Input + //---------------------------------------------------------------------------------------------------------------------- /** MappingContext */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) UInputMappingContext* DefaultMappingContext; @@ -131,6 +139,9 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) TArray ItemActions; + //---------------------------------------------------------------------------------------------------------------------- + // Ability + //---------------------------------------------------------------------------------------------------------------------- UPROPERTY(BlueprintReadOnly, Category = Ability, meta = (AllowPrivateAccess = "true")) UAbilitySystemComponent* AbilitySystem = nullptr; @@ -146,31 +157,45 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Ability) TArray> Effects; - FCogInterfaceOnMetricEvent OnMetricEventDelegate; - private: void InitializeAbilitySystem(); + void ShutdownAbilitySystem(); + void Move(const FInputActionValue& Value); + void MoveZ(const FInputActionValue& Value); + void Look(const FInputActionValue& Value); + void OnAbilityInputStarted(const FInputActionValue& Value, int32 Index); + void OnAbilityInputCompleted(const FInputActionValue& Value, int32 Index); + void ActivateItem(const FInputActionValue& Value, int32 Index); + void OnGameplayEffectAdded(UAbilitySystemComponent* AbilitySystemComponent, const FGameplayEffectSpec& GameplayEffectSpec, FActiveGameplayEffectHandle Handle); + void OnGameplayEffectRemoved(const FActiveGameplayEffect& RemovedGameplayEffect); + void OnGhostTagNewOrRemoved(const FGameplayTag InTag, int32 NewCount); + void OnScaleAttributeChanged(const FOnAttributeChangeData& Data); UPROPERTY(Replicated, Transient) TArray ActiveAbilityHandles; FDelegateHandle GameplayEffectAddedHandle; + FDelegateHandle GameplayEffectRemovedHandle; + FDelegateHandle GhostTagDelegateHandle; + FDelegateHandle ScaleAttributeDelegateHandle; + bool bIsGhost = false; + bool bIsInitialized = false; }; diff --git a/Source/CogSample/CogSampleGameState.cpp b/Source/CogSample/CogSampleGameState.cpp index 9bb72d8..aae5739 100644 --- a/Source/CogSample/CogSampleGameState.cpp +++ b/Source/CogSample/CogSampleGameState.cpp @@ -18,7 +18,6 @@ #include "CogAbilityWindow_Attributes.h" #include "CogAbilityWindow_Cheats.h" #include "CogAbilityWindow_Effects.h" -#include "CogAbilityWindow_Metrics.h" #include "CogAbilityWindow_Pools.h" #include "CogAbilityWindow_Tags.h" #include "CogAbilityWindow_Tweaks.h" @@ -33,11 +32,12 @@ #include "CogEngineWindow_LogCategories.h" #include "CogEngineWindow_NetEmulation.h" #include "CogEngineWindow_OutputLog.h" +#include "CogEngineWindow_Metrics.h" #include "CogEngineWindow_Plots.h" #include "CogEngineWindow_Scalability.h" #include "CogEngineWindow_Selection.h" #include "CogEngineWindow_Skeleton.h" -#include "CogEngineWindow_Spawn.h" +#include "CogEngineWindow_Spawns.h" #include "CogEngineWindow_Stats.h" #include "CogEngineWindow_Time.h" #include "CogImguiModule.h" @@ -160,29 +160,22 @@ void ACogSampleGameState::InitializeCog() CogWindowManager->CreateWindow("Engine.Plots"); + UCogEngineWindow_Selection* SelectionWindow = CogWindowManager->CreateWindow("Engine.Selection"); + SelectionWindow->SetActorSubClasses({ AActor::StaticClass(), AGameModeBase::StaticClass(), AGameStateBase::StaticClass(), ACharacter::StaticClass() }); + SelectionWindow->SetCurrentActorSubClass(ACharacter::StaticClass()); + SelectionWindow->SetTraceType(UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Pawn)); + CogWindowManager->CreateWindow("Engine.Scalability"); CogWindowManager->CreateWindow("Engine.Skeleton"); - UCogEngineWindow_Spawn* SpawnWindow =CogWindowManager->CreateWindow("Engine.Spawn"); + UCogEngineWindow_Spawns* SpawnWindow =CogWindowManager->CreateWindow("Engine.Spawns"); SpawnWindow->SetSpawnsAsset(GetFirstAssetByClass()); - CogWindowManager->CreateWindow("Engine.Time"); - - UCogEngineWindow_Selection* SelectionWindow = CogWindowManager->CreateWindow("Engine.Selection"); - TArray> SubClasses - { - AActor::StaticClass(), - AGameModeBase::StaticClass(), - AGameStateBase::StaticClass(), - ACharacter::StaticClass() - }; - SelectionWindow->SetActorSubClasses(SubClasses); - SelectionWindow->SetCurrentActorSubClass(ACharacter::StaticClass()); - SelectionWindow->SetTraceType(UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Pawn)); - UCogEngineWindow_Stats* StatsWindow = CogWindowManager->CreateWindow("Engine.Stats"); + CogWindowManager->CreateWindow("Engine.Time"); + //--------------------------------------- // Abilities //--------------------------------------- @@ -194,7 +187,7 @@ void ACogSampleGameState::InitializeCog() UCogAbilityWindow_Cheats* CheatsWindow = CogWindowManager->CreateWindow("Gameplay.Cheats"); CheatsWindow->CheatsAsset = GetFirstAssetByClass(); - CogWindowManager->CreateWindow("Gameplay.Metrics"); + CogWindowManager->CreateWindow("Gameplay.Metrics"); UCogAbilityWindow_Effects* EffectsWindow = CogWindowManager->CreateWindow("Gameplay.Effects"); EffectsWindow->NegativeEffectTag = Tag_Effect_Alignment_Negative; @@ -222,18 +215,11 @@ void ACogSampleGameState::InitializeCog() //--------------------------------------- CogWindowManager->AddMainMenuWidget(SelectionWindow); CogWindowManager->AddMainMenuWidget(StatsWindow); - - CogWindowManager->RebuildMenu(); } //-------------------------------------------------------------------------------------------------------------------------- void ACogSampleGameState::RenderCog(float DeltaTime) { - static bool ShowImGuiDemo = false; - if (ShowImGuiDemo) - { - ImGui::ShowDemoWindow(&ShowImGuiDemo); - } CogWindowManager->Render(DeltaTime); }