Display inhibition of gameplay effects

This commit is contained in:
Arnaud Jamin
2024-05-10 00:57:19 -04:00
parent 5cd88b2f86
commit 69ef005a1e
2 changed files with 37 additions and 7 deletions
@@ -85,14 +85,14 @@ void FCogAbilityWindow_Effects::RenderContent()
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Effects::RenderEffectsTable() void FCogAbilityWindow_Effects::RenderEffectsTable()
{ {
const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
if (AbilitySystemComponent == nullptr) if (AbilitySystemComponent == nullptr)
{ {
ImGui::TextDisabled("Selection has no ability system component"); ImGui::TextDisabled("Selection has no ability system component");
return; return;
} }
if (ImGui::BeginTable("Effects", 4, ImGuiTableFlags_SizingFixedFit if (ImGui::BeginTable("Effects", 5, ImGuiTableFlags_SizingFixedFit
| ImGuiTableFlags_Resizable | ImGuiTableFlags_Resizable
| ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_NoBordersInBodyUntilResize
| ImGuiTableFlags_ScrollY | ImGuiTableFlags_ScrollY
@@ -107,6 +107,7 @@ void FCogAbilityWindow_Effects::RenderEffectsTable()
ImGui::TableSetupColumn("Remaining Time"); ImGui::TableSetupColumn("Remaining Time");
ImGui::TableSetupColumn("Stacks"); ImGui::TableSetupColumn("Stacks");
ImGui::TableSetupColumn("Prediction"); ImGui::TableSetupColumn("Prediction");
ImGui::TableSetupColumn("Inhibited");
ImGui::TableHeadersRow(); ImGui::TableHeadersRow();
static int SelectedIndex = -1; static int SelectedIndex = -1;
@@ -258,6 +259,11 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A
ImGui::TableNextColumn(); ImGui::TableNextColumn();
RenderPrediction(ActiveEffect, true); 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)) 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("Property");
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
@@ -325,6 +331,15 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent&
ImGui::TableNextColumn(); ImGui::TableNextColumn();
RenderPrediction(ActiveEffect, false); RenderPrediction(ActiveEffect, false);
//------------------------
// Inhibited
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Inhibited");
ImGui::TableNextColumn();
RenderInhibition(ActiveEffect, false);
//------------------------ //------------------------
// Dynamic Asset Tags // Dynamic Asset Tags
//------------------------ //------------------------
@@ -406,7 +421,7 @@ void FCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponen
if (Duration >= 0) if (Duration >= 0)
{ {
const UWorld* World = AbilitySystemComponent.GetWorld(); const UWorld* World = AbilitySystemComponent.GetWorld();
const float RemainingTime = StartTime + Duration - World->GetTimeSeconds(); const float RemainingTime = StartTime + Duration - World->GetTimeSeconds();
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255)); 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)); 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) void FCogAbilityWindow_Effects::OpenEffect(const FActiveGameplayEffectHandle& Handle)
{ {
@@ -472,13 +500,13 @@ void FCogAbilityWindow_Effects::CloseEffect(const FActiveGameplayEffectHandle& H
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Effects::RenderOpenEffects() void FCogAbilityWindow_Effects::RenderOpenEffects()
{ {
const AActor* Selection = GetSelection(); const AActor* Selection = GetSelection();
if (Selection == nullptr) if (Selection == nullptr)
{ {
return; return;
} }
const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true); const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true);
if (AbilitySystemComponent == nullptr) if (AbilitySystemComponent == nullptr)
{ {
return; return;
@@ -486,7 +514,7 @@ void FCogAbilityWindow_Effects::RenderOpenEffects()
for (int i = OpenedEffects.Num() - 1; i >= 0; --i) 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); const FActiveGameplayEffect* ActiveEffectPtr = AbilitySystemComponent->GetActiveGameplayEffect(Handle);
if (ActiveEffectPtr == nullptr) if (ActiveEffectPtr == nullptr)
@@ -48,6 +48,8 @@ protected:
virtual void RenderPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short); virtual void RenderPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short);
virtual void RenderInhibition(const FActiveGameplayEffect& ActiveEffect, bool Short);
virtual FString GetEffectName(const UGameplayEffect& Effect); virtual FString GetEffectName(const UGameplayEffect& Effect);
virtual FString GetEffectNameSafe(const UGameplayEffect* Effect); virtual FString GetEffectNameSafe(const UGameplayEffect* Effect);