CogAbility: UI improvements

Attribute Window:
 - Fix ID conflicts
 - Add attribute set column (hidden by default)
 - Improve indentation when displaying attribute set or categories
This commit is contained in:
Arnaud Jamin
2025-01-14 23:47:24 -05:00
parent f706ed6637
commit 4a5f7294e1
11 changed files with 292 additions and 176 deletions
@@ -341,7 +341,7 @@ bool FCogDebugPlotEntry::FindValue(float x, float& y) const
Index = (i + ValueOffset) % Values.size();
}
ImVec2 Point = Values[Index];
const ImVec2 Point = Values[Index];
if (Point.x > x)
{
FoundAfter = true;
@@ -14,12 +14,17 @@
#include "InputCoreTypes.h"
//--------------------------------------------------------------------------------------------------------------------------
void FCogWindowWidgets::BeginTableTooltip()
bool FCogWindowWidgets::BeginTableTooltip()
{
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4, 4));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::PushStyleColor(ImGuiCol_PopupBg, IM_COL32(29, 42, 62, 240));
ImGui::BeginTooltip();
if (ImGui::BeginTooltip() == false)
{
EndTableTooltip();
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -30,6 +35,21 @@ void FCogWindowWidgets::EndTableTooltip()
ImGui::PopStyleVar(2);
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogWindowWidgets::BeginItemTableTooltip()
{
if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort) == false)
{ return false; }
return BeginTableTooltip();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogWindowWidgets::EndItemTableTooltip()
{
return EndTableTooltip();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogWindowWidgets::ThinSeparatorText(const char* Label)
{
@@ -1044,4 +1064,39 @@ bool FCogWindowWidgets::InputText(const char* Text, FString& Value)
}
return result;
}
}
//--------------------------------------------------------------------------------------------------------------------------
bool FCogWindowWidgets::BeginRightAlign(const char* Id)
{
if (ImGui::BeginTable(Id, 2, ImGuiTableFlags_SizingFixedFit, ImVec2(-1, 0)))
{
ImGui::TableSetupColumn("a", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableNextColumn();
ImGui::TableNextColumn();
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogWindowWidgets::EndRightAlign()
{
ImGui::EndTable();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogWindowWidgets::MenuItemShortcut(const char* Id, const FString& Text)
{
ImGui::SameLine();
if (BeginRightAlign(Id))
{
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
const auto TextStr = StringCast<ANSICHAR>(*Text);
ImGui::Text("%s", TextStr.Get());
ImGui::PopStyleColor();
EndRightAlign();
}
}
@@ -5,6 +5,7 @@
#include "CogWindowManager.h"
#include "CogWindowWidgets.h"
#include "imgui.h"
#include "imgui.h"
#include "InputCoreTypes.h"
//--------------------------------------------------------------------------------------------------------------------------
@@ -77,17 +78,7 @@ void FCogWindow_Settings::RenderContent()
Context.SetEnableInput(bEnableInput);
}
ImGui::SetItemTooltip("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui.");
const auto ShortcutText = StringCast<ANSICHAR>(*FCogImguiInputHelper::CommandToString(PlayerInput, UCogWindowManager::ToggleInputCommand));
const float ShortcutWidth = (ShortcutText.Get() != nullptr && ShortcutText.Get()[0]) ? ImGui::CalcTextSize(ShortcutText.Get(), NULL).x : 0.0f;
if (ShortcutWidth > 0.0f)
{
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetContentRegionAvail().x - ShortcutWidth);
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
ImGui::Text("%s", ShortcutText.Get());
ImGui::PopStyleColor();
}
FCogWindowWidgets::MenuItemShortcut("EnableInputShortcut", FCogImguiInputHelper::CommandToString(PlayerInput, UCogWindowManager::ToggleInputCommand));
//-------------------------------------------------------------------------------------------
bool bShareKeyboard = Context.GetShareKeyboard();
@@ -23,10 +23,14 @@ class COGWINDOW_API FCogWindowWidgets
{
public:
static void BeginTableTooltip();
static bool BeginTableTooltip();
static void EndTableTooltip();
static bool BeginItemTableTooltip();
static void EndItemTableTooltip();
static void ThinSeparatorText(const char* Label);
static void ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay);
@@ -111,6 +115,11 @@ public:
static bool InputText(const char* Text, FString& Value);
static bool BeginRightAlign(const char* Id);
static void EndRightAlign();
static void MenuItemShortcut(const char* Id, const FString& Text);
};
template<typename EnumType>
@@ -269,68 +269,66 @@ void FCogAIWindow_BehaviorTree::RenderNode(UBehaviorTreeComponent& BehaviorTreeC
//------------------------
// Tooltip
//------------------------
if (ImGui::IsItemHovered())
if (FCogWindowWidgets::BeginItemTableTooltip())
{
FCogWindowWidgets::BeginTableTooltip();
if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders))
{
ImGui::TableSetupColumn("Property");
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders))
{
ImGui::TableSetupColumn("Property");
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
//------------------------
// Name
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Name");
ImGui::TableNextColumn();
ImGui::Text("%s", NodeName.Get());
//------------------------
// Name
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Name");
ImGui::TableNextColumn();
ImGui::Text("%s", NodeName.Get());
//------------------------
// Static Description
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Description");
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*Node->GetStaticDescription()));
//------------------------
// Static Description
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Description");
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*Node->GetStaticDescription()));
//------------------------
// Runtime Values
//------------------------
TArray<FString> RunTimeValues;
uint8* NodeMemory = BehaviorTreeComponent.GetNodeMemory(Node, BehaviorTreeComponent.GetActiveInstanceIdx());
Node->DescribeRuntimeValues(BehaviorTreeComponent, NodeMemory, EBTDescriptionVerbosity::Detailed, RunTimeValues);
//------------------------
// Runtime Values
//------------------------
TArray<FString> RunTimeValues;
uint8* NodeMemory = BehaviorTreeComponent.GetNodeMemory(Node, BehaviorTreeComponent.GetActiveInstanceIdx());
Node->DescribeRuntimeValues(BehaviorTreeComponent, NodeMemory, EBTDescriptionVerbosity::Detailed, RunTimeValues);
for (const FString& RuntimeValue : RunTimeValues)
{
ImGui::TableNextRow();
for (const FString& RuntimeValue : RunTimeValues)
{
ImGui::TableNextRow();
FString Left, Right;
if (RuntimeValue.Split(TEXT(": "), &Left, &Right))
{
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "%s", TCHAR_TO_ANSI(*Left));
FString Left, Right;
if (RuntimeValue.Split(TEXT(": "), &Left, &Right))
{
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "%s", TCHAR_TO_ANSI(*Left));
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*Right));
}
else
{
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Value");
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*RuntimeValue));
}
}
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*Right));
}
else
{
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Value");
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*RuntimeValue));
}
}
ImGui::EndTable();
}
ImGui::EndTable();
}
FCogWindowWidgets::EndTableTooltip();
FCogWindowWidgets::EndItemTableTooltip();
}
//------------------------
@@ -201,13 +201,13 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenuColorSettings()
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Abilities::RenderAbilityActivation(FGameplayAbilitySpec& Spec)
{
FCogWindowWidgets::PushStyleCompact();
bool IsActive = Spec.IsActive();
if (ImGui::Checkbox("##Activation", &IsActive))
{
AbilityHandleToActivate = Spec.Handle;
}
FCogWindowWidgets::PopStyleCompact();
FCogWindowWidgets::PushStyleCompact();
bool IsActive = Spec.IsActive();
if (ImGui::Checkbox("##Activation", &IsActive))
{
AbilityHandleToActivate = Spec.Handle;
}
FCogWindowWidgets::PopStyleCompact();
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -216,15 +216,15 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityName(UAbilitySystem
const ImVec4 Color = GetAbilityColor(AbilitySystemComponent, Spec);
ImGui::PushStyleColor(ImGuiCol_Text, Color);
if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
{
SelectedIndex = Index;
if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
{
SelectedIndex = Index;
if (ImGui::IsMouseDoubleClicked(0))
{
OpenAbility(Spec.Handle);
}
}
if (ImGui::IsMouseDoubleClicked(0))
{
OpenAbility(Spec.Handle);
}
}
ImGui::PopStyleColor(1);
}
@@ -232,26 +232,26 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityName(UAbilitySystem
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityBlocking(UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility* Ability)
{
if (Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false)
{
FGameplayTagContainer OwnedGameplayTags;
AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags);
if (Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false)
{
FGameplayTagContainer OwnedGameplayTags;
AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags);
if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags))
{
FGameplayTagContainer AllBlockingTags;
AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags);
AllBlockingTags.AppendTags(OwnedGameplayTags);
if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags))
{
FGameplayTagContainer AllBlockingTags;
AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags);
AllBlockingTags.AppendTags(OwnedGameplayTags);
FCogAbilityHelper::RenderTagContainer(*ActivationBlockedTags, AllBlockingTags, false, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor));
}
FCogAbilityHelper::RenderTagContainer(*ActivationBlockedTags, AllBlockingTags, false, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor));
}
ImGui::SameLine();
if (const FGameplayTagContainer* ActivationRequiredTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationRequiredTags))
{
FCogAbilityHelper::RenderTagContainer(*ActivationRequiredTags, OwnedGameplayTags, true, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor));
}
}
ImGui::SameLine();
if (const FGameplayTagContainer* ActivationRequiredTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationRequiredTags))
{
FCogAbilityHelper::RenderTagContainer(*ActivationRequiredTags, OwnedGameplayTags, true, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor));
}
}
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -271,8 +271,8 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
if (ShouldShowAbility(AbilitySystemComponent, Spec, Ability) == false)
{
continue;
}
continue;
}
const auto AbilityName = StringCast<ANSICHAR>(*GetAbilityName(Ability));
if (Filter.PassFilter(AbilityName.Get()) == false)
@@ -390,11 +390,10 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableRow(UAbilitySystemComponen
//------------------------
// Popup
//------------------------
if (ImGui::IsItemHovered())
if (FCogWindowWidgets::BeginItemTableTooltip())
{
FCogWindowWidgets::BeginTableTooltip();
RenderAbilityInfo(AbilitySystemComponent, Spec);
FCogWindowWidgets::EndTableTooltip();
FCogWindowWidgets::EndItemTableTooltip();
}
//------------------------
@@ -537,7 +536,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
if (ImGui::BeginTable("Ability", 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");
@@ -665,8 +664,8 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
}
//------------------------
// Additional info
//------------------------
// Additional info
//------------------------
RenderAbilityAdditionalInfo(AbilitySystemComponent, Spec, *Ability, TextColor);
ImGui::EndTable();
@@ -61,10 +61,17 @@ void FCogAbilityWindow_Attributes::RenderContent()
ImGui::Checkbox("Group by Attribute Set", &Config->GroupByAttributeSet);
ImGui::Checkbox("Group by Category", &Config->GroupByCategory);
ImGui::Checkbox("Show Only Modified", &Config->ShowOnlyModified);
FCogWindowWidgets::SetNextItemToShortWidth();
FCogWindowWidgets::InputText("Attribute Set Prefixes", Config->AttributeSetPrefixes);
ImGui::SetItemTooltip("Prefixes to remove from the attribute set name. Separate multiple prefixes with the semicolon character ';'");
ImGui::Separator();
ImGui::ColorEdit4("Positive Color", (float*)&AlignmentConfig->PositiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
ImGui::ColorEdit4("Negative Color", (float*)&AlignmentConfig->NegativeColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
ImGui::ColorEdit4("Neutral Color", (float*)&AlignmentConfig->NeutralColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
ImGui::ColorEdit4("AttributeSet Color", (float*)&Config->AttributeSetColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
ImGui::ColorEdit4("Category Color", (float*)&Config->CategoryColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
ImGui::Separator();
if (ImGui::MenuItem("Reset"))
{
@@ -78,10 +85,12 @@ void FCogAbilityWindow_Attributes::RenderContent()
ImGui::EndMenuBar();
}
bool bGroupByAttributeSetValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByAttributeSet;
bool bGroupByCategoryValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByCategory;
const bool bGroupByAttributeSetValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByAttributeSet;
const bool bGroupByCategoryValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByCategory;
const float bShowGroup = bGroupByAttributeSetValue | bGroupByCategoryValue;
const float FirstColWidth = ((int32)bGroupByAttributeSetValue + (int32)bGroupByCategoryValue) * ImGui::GetFontSize() * 2;
if (ImGui::BeginTable("Attributes", 3, ImGuiTableFlags_SizingFixedFit
if (ImGui::BeginTable("Attributes", 5, ImGuiTableFlags_SizingFixedFit
| ImGuiTableFlags_Resizable
| ImGuiTableFlags_NoBordersInBodyUntilResize
| ImGuiTableFlags_ScrollY
@@ -91,6 +100,8 @@ void FCogAbilityWindow_Attributes::RenderContent()
| ImGuiTableFlags_Hideable))
{
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("-", ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_NoHeaderLabel | ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_WidthFixed, FirstColWidth);
ImGui::TableSetupColumn("Set", bShowGroup ? ImGuiTableColumnFlags_DefaultHide : ImGuiTableColumnFlags_None);
ImGui::TableSetupColumn("Attribute");
ImGui::TableSetupColumn("Base");
ImGui::TableSetupColumn("Current");
@@ -102,23 +113,46 @@ void FCogAbilityWindow_Attributes::RenderContent()
//------------------------------------------------------------------------------------------
// Draw all the attribute sets
//------------------------------------------------------------------------------------------
for (const UAttributeSet* Set : AbilitySystemComponent->GetSpawnedAttributes())
for (const UAttributeSet* AttributeSet : AbilitySystemComponent->GetSpawnedAttributes())
{
ImGui::PushID(TCHAR_TO_ANSI(*AttributeSet->GetName()));
FString AttributeSetName = AttributeSet->GetName();
if (Config->AttributeSetPrefixes.IsEmpty() == false)
{
TArray<FString> Prefixes;
Config->AttributeSetPrefixes.ParseIntoArray(Prefixes, TEXT(";"));
for (const FString& Prefix : Prefixes)
{
if (AttributeSetName.RemoveFromStart(Prefix, ESearchCase::IgnoreCase))
{
break;
}
}
}
const auto AttributeSetNameStr = StringCast<ANSICHAR>(*AttributeSetName);
//------------------------------------------------------------------------------------------
// Add an tree node categories are shown
// Add a tree node with the name of the attribute set if grouping by attribute set
//------------------------------------------------------------------------------------------
bool bOpenAttributeSet = true;
if (bGroupByAttributeSetValue)
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
bOpenAttributeSet = ImGui::TreeNodeEx(TCHAR_TO_ANSI(*Set->GetName()), ImGuiTreeNodeFlags_SpanFullWidth);
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Config->AttributeSetColor));
bOpenAttributeSet = ImGui::TreeNodeEx(AttributeSetNameStr.Get(), ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanAllColumns | ImGuiTreeNodeFlags_LabelSpanAllColumns);
ImGui::PopStyleColor();
}
if (bOpenAttributeSet)
{
TArray<FGameplayAttribute> AllAttributes;
for (TFieldIterator<FProperty> It(Set->GetClass()); It; ++It)
for (TFieldIterator<FProperty> It(AttributeSet->GetClass()); It; ++It)
{
FGameplayAttribute Attribute = *It;
if (Attribute.IsValid())
@@ -176,7 +210,9 @@ void FCogAbilityWindow_Attributes::RenderContent()
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
bOpenCategory = ImGui::TreeNodeEx(TCHAR_TO_ANSI(*It.Key), ImGuiTreeNodeFlags_SpanFullWidth);
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Config->CategoryColor));
bOpenCategory = ImGui::TreeNodeEx(TCHAR_TO_ANSI(*It.Key), ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanAllColumns | ImGuiTreeNodeFlags_LabelSpanAllColumns);
ImGui::PopStyleColor();
}
if (bOpenCategory)
@@ -201,50 +237,55 @@ void FCogAbilityWindow_Attributes::RenderContent()
for (const FGameplayAttribute& Attribute : AttributesInCategory)
{
if (!Attribute.IsValid())
{
continue;
}
{ continue; }
const auto AttributeName = StringCast<ANSICHAR>(*Attribute.GetName());
const auto AttributeNameStr = StringCast<ANSICHAR>(*Attribute.GetName());
if (Filter.PassFilter(AttributeName.Get()) == false)
{
continue;
}
if (Filter.PassFilter(AttributeNameStr.Get()) == false)
{ continue; }
const float BaseValue = AbilitySystemComponent->GetNumericAttributeBase(Attribute);
const float CurrentValue = AbilitySystemComponent->GetNumericAttribute(Attribute);
if (Config->ShowOnlyModified && FMath::IsNearlyEqual(CurrentValue, BaseValue))
{
continue;
}
{ continue; }
ImGui::PushID(AttributeNameStr.Get());
ImGui::TableNextRow();
//------------------------
// Selectable
//------------------------
ImGui::TableNextColumn();
if (ImGui::Selectable("", Selected == Index, ImGuiSelectableFlags_SpanAllColumns))
{
Selected = Index;
}
const ImVec4 Color = FCogImguiHelper::ToImVec4(AlignmentConfig->GetAttributeColor(*AbilitySystemComponent, Attribute));
ImGui::PushStyleColor(ImGuiCol_Text, Color);
//------------------------
// Name
// Attribute Set
//------------------------
ImGui::TableNextColumn();
ImGui::Text("%s", AttributeSetNameStr.Get());
//------------------------
// Attribute Name
//------------------------
ImGui::TableNextColumn();
ImGui::Text("");
ImGui::SameLine();
if (ImGui::Selectable(AttributeName.Get(), Selected == Index, ImGuiSelectableFlags_SpanAllColumns))
{
Selected = Index;
}
ImGui::Text("%s", AttributeNameStr.Get());
ImGui::PopStyleColor(1);
//------------------------
// Popup
//------------------------
if (ImGui::IsItemHovered())
if (FCogWindowWidgets::BeginItemTableTooltip())
{
FCogWindowWidgets::BeginTableTooltip();
DrawAttributeInfo(*AbilitySystemComponent, Attribute);
FCogWindowWidgets::EndTableTooltip();
DrawAttributeInfo(*AbilitySystemComponent, AttributeSetNameStr.Get(), Attribute);
FCogWindowWidgets::EndItemTableTooltip();
}
ImGui::PushStyleColor(ImGuiCol_Text, Color);
@@ -263,6 +304,8 @@ void FCogAbilityWindow_Attributes::RenderContent()
ImGui::PopStyleColor(1);
ImGui::PopID();
Index++;
}
}
@@ -274,10 +317,15 @@ void FCogAbilityWindow_Attributes::RenderContent()
}
}
if (bOpenAttributeSet && bGroupByAttributeSetValue)
if (bGroupByAttributeSetValue)
{
ImGui::TreePop();
if (bOpenAttributeSet)
{
ImGui::TreePop();
}
}
ImGui::PopID();
}
ImGui::EndTable();
@@ -285,11 +333,11 @@ void FCogAbilityWindow_Attributes::RenderContent()
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute)
void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const char* AttributeSetName, const FGameplayAttribute& Attribute)
{
if (ImGui::BeginTable("Attribute", 2, ImGuiTableFlags_Borders))
{
const 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);
@@ -297,6 +345,15 @@ void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone
const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute);
const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute);
//------------------------
// Attribute Set
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Attribute Set");
ImGui::TableNextColumn();
ImGui::Text("%s", AttributeSetName);
//------------------------
// Name
//------------------------
@@ -329,7 +386,7 @@ void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone
//------------------------
// Modifiers
//------------------------
FGameplayEffectQuery Query;
const FGameplayEffectQuery Query;
for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent.GetActiveEffects(Query))
{
const FActiveGameplayEffect* ActiveEffect = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle);
@@ -213,11 +213,10 @@ void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& Ability
//------------------------
// Popup
//------------------------
if (ImGui::IsItemHovered())
if (FCogWindowWidgets::BeginItemTableTooltip())
{
FCogWindowWidgets::BeginTableTooltip();
RenderEffectInfo(AbilitySystemComponent, ActiveEffect, Effect);
FCogWindowWidgets::EndTableTooltip();
FCogWindowWidgets::EndItemTableTooltip();
}
//------------------------
@@ -134,11 +134,10 @@ void FCogAbilityWindow_Tags::RenderTagContainer(const UAbilitySystemComponent& A
//------------------------
// Tooltip
//------------------------
if (ImGui::IsItemHovered())
if (FCogWindowWidgets::BeginItemTableTooltip())
{
FCogWindowWidgets::BeginTableTooltip();
RenderTag(AbilitySystemComponent, Tag);
FCogWindowWidgets::EndTableTooltip();
FCogWindowWidgets::EndItemTableTooltip();
}
ImGui::PopID();
@@ -2,11 +2,8 @@
#include "AbilitySystemGlobals.h"
#include "AbilitySystemComponent.h"
#include "CogAbilityDataAsset.h"
#include "CogAbilityHelper.h"
#include "CogAbilityReplicator.h"
#include "CogImguiHelper.h"
#include "CogWindowHelper.h"
#include "CogWindowWidgets.h"
#include "imgui.h"
@@ -177,7 +174,7 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
continue;
}
FilteredTasks.Add(Task);
FilteredTasks.Add(Task);
}
if (Config->SortByName)
@@ -237,11 +234,10 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
//------------------------
// Popup
//------------------------
if (ImGui::IsItemHovered())
if (FCogWindowWidgets::BeginItemTableTooltip())
{
FCogWindowWidgets::BeginTableTooltip();
RenderTaskInfo(Task);
FCogWindowWidgets::EndTableTooltip();
FCogWindowWidgets::EndItemTableTooltip();
}
//------------------------
@@ -254,7 +250,7 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
// IsTicking
//------------------------
ImGui::TableNextColumn();
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
ImGui::PopID();
}
@@ -275,7 +271,7 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
if (ImGui::BeginTable("Task", 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");
@@ -290,8 +286,8 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetName()).Get());
//------------------------
// Instance Name
//------------------------
// Instance Name
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Instance Name");
@@ -299,8 +295,8 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetInstanceName().ToString()).Get());
//------------------------
// Owner
//------------------------
// Owner
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Ability");
@@ -316,9 +312,9 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::TableNextColumn();
RenderTaskState(Task);
//------------------------
// Priority
//------------------------
//------------------------
// Priority
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Priority");
@@ -326,17 +322,17 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::Text("%d", (int32)Task->GetPriority());
//------------------------
// IsTicking
//------------------------
// IsTicking
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Is Ticking");
ImGui::TableNextColumn();
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
//------------------------
// IsSimulated
//------------------------
//------------------------
// IsSimulated
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Is Simulated");
@@ -344,8 +340,8 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::Text(Task->IsSimulatedTask() ? "Yes" : "No");
//------------------------
// IsSimulating
//------------------------
// IsSimulating
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Is Simulating");
@@ -353,15 +349,15 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::Text(Task->IsSimulating() ? "Yes" : "No");
//------------------------
// Debug
//------------------------
// Debug
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Debug");
ImGui::TableNextColumn();
ImGui::PushTextWrapPos(FCogWindowWidgets::GetFontWidth() * 80);
ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetDebugString()).Get());
ImGui::PopTextWrapPos();
ImGui::PopTextWrapPos();
ImGui::EndTable();
}
@@ -5,6 +5,7 @@
#include "CogWindow.h"
#include "CogAbilityWindow_Attributes.generated.h"
class UAttributeSet;
class UAbilitySystemComponent;
class UCogAbilityConfig_Attributes;
class UCogAbilityConfig_Alignment;
@@ -29,7 +30,7 @@ protected:
virtual void RenderContent() override;
virtual void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute);
virtual void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const char* AttributeSetName, const FGameplayAttribute& Attribute);
private:
@@ -60,6 +61,15 @@ public:
UPROPERTY(Config)
bool ShowOnlyModified = false;
UPROPERTY(Config)
FString AttributeSetPrefixes;
UPROPERTY(Config)
FVector4f CategoryColor = FVector4f(1.0f, 1.0f, 1.0f, 0.5f);
UPROPERTY(Config)
FVector4f AttributeSetColor = FVector4f(1.0f, 1.0f, 1.0f, 0.5f);
virtual void Reset() override
{
Super::Reset();
@@ -68,5 +78,8 @@ public:
GroupByAttributeSet = false;
GroupByCategory = false;
ShowOnlyModified = false;
AttributeSetPrefixes = FString();
CategoryColor = FVector4f(1.0f, 1.0f, 1.0f, 0.5f);
AttributeSetColor = FVector4f(1.0f, 1.0f, 1.0f, 0.5f);
}
};