From 69ef005a1e7746201b435799515ea336bc8717ca Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Fri, 10 May 2024 00:57:19 -0400 Subject: [PATCH] Display inhibition of gameplay effects --- .../Private/CogAbilityWindow_Effects.cpp | 42 +++++++++++++++---- .../Public/CogAbilityWindow_Effects.h | 2 + 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp index 770fe42..38c657d 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp @@ -85,14 +85,14 @@ void FCogAbilityWindow_Effects::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderEffectsTable() { - const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); + const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); if (AbilitySystemComponent == nullptr) { ImGui::TextDisabled("Selection has no ability system component"); return; } - if (ImGui::BeginTable("Effects", 4, ImGuiTableFlags_SizingFixedFit + if (ImGui::BeginTable("Effects", 5, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_ScrollY @@ -107,6 +107,7 @@ void FCogAbilityWindow_Effects::RenderEffectsTable() ImGui::TableSetupColumn("Remaining Time"); ImGui::TableSetupColumn("Stacks"); ImGui::TableSetupColumn("Prediction"); + ImGui::TableSetupColumn("Inhibited"); ImGui::TableHeadersRow(); static int SelectedIndex = -1; @@ -258,6 +259,11 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A ImGui::TableNextColumn(); RenderPrediction(ActiveEffect, true); + //------------------------ + // Inhibited + //------------------------ + ImGui::TableNextColumn(); + RenderInhibition(ActiveEffect, true); } @@ -266,7 +272,7 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& { if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders)) { - constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); + constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); ImGui::TableSetupColumn("Property"); ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch); @@ -325,6 +331,15 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& ImGui::TableNextColumn(); RenderPrediction(ActiveEffect, false); + //------------------------ + // Inhibited + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Inhibited"); + ImGui::TableNextColumn(); + RenderInhibition(ActiveEffect, false); + //------------------------ // Dynamic Asset Tags //------------------------ @@ -406,7 +421,7 @@ void FCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponen if (Duration >= 0) { - const UWorld* World = AbilitySystemComponent.GetWorld(); + const UWorld* World = AbilitySystemComponent.GetWorld(); const float RemainingTime = StartTime + Duration - World->GetTimeSeconds(); ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255)); @@ -457,6 +472,19 @@ void FCogAbilityWindow_Effects::RenderPrediction(const FActiveGameplayEffect& Ac ImGui::Text("%s", TCHAR_TO_ANSI(*PredictionString)); } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Effects::RenderInhibition(const FActiveGameplayEffect& ActiveEffect, bool Short) +{ + if (ActiveEffect.bIsInhibited) + { + FCogWindowWidgets::SmallButton("Yes", ImVec4(1, 0, 0, 1)); + } + else + { + ImGui::Text("No"); + } +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::OpenEffect(const FActiveGameplayEffectHandle& Handle) { @@ -472,13 +500,13 @@ void FCogAbilityWindow_Effects::CloseEffect(const FActiveGameplayEffectHandle& H //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderOpenEffects() { - const AActor* Selection = GetSelection(); + const AActor* Selection = GetSelection(); if (Selection == nullptr) { return; } - const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true); + const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true); if (AbilitySystemComponent == nullptr) { return; @@ -486,7 +514,7 @@ void FCogAbilityWindow_Effects::RenderOpenEffects() for (int i = OpenedEffects.Num() - 1; i >= 0; --i) { - const FActiveGameplayEffectHandle Handle = OpenedEffects[i]; + const FActiveGameplayEffectHandle Handle = OpenedEffects[i]; const FActiveGameplayEffect* ActiveEffectPtr = AbilitySystemComponent->GetActiveGameplayEffect(Handle); if (ActiveEffectPtr == nullptr) diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h index 9f5de61..f033e34 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h @@ -48,6 +48,8 @@ protected: virtual void RenderPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short); + virtual void RenderInhibition(const FActiveGameplayEffect& ActiveEffect, bool Short); + virtual FString GetEffectName(const UGameplayEffect& Effect); virtual FString GetEffectNameSafe(const UGameplayEffect* Effect);