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(); Index = (i + ValueOffset) % Values.size();
} }
ImVec2 Point = Values[Index]; const ImVec2 Point = Values[Index];
if (Point.x > x) if (Point.x > x)
{ {
FoundAfter = true; FoundAfter = true;
@@ -14,12 +14,17 @@
#include "InputCoreTypes.h" #include "InputCoreTypes.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogWindowWidgets::BeginTableTooltip() bool FCogWindowWidgets::BeginTableTooltip()
{ {
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4, 4)); ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4, 4));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::PushStyleColor(ImGuiCol_PopupBg, IM_COL32(29, 42, 62, 240)); 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); 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) void FCogWindowWidgets::ThinSeparatorText(const char* Label)
{ {
@@ -1045,3 +1065,38 @@ bool FCogWindowWidgets::InputText(const char* Text, FString& Value)
return result; 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 "CogWindowManager.h"
#include "CogWindowWidgets.h" #include "CogWindowWidgets.h"
#include "imgui.h" #include "imgui.h"
#include "imgui.h"
#include "InputCoreTypes.h" #include "InputCoreTypes.h"
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -77,17 +78,7 @@ void FCogWindow_Settings::RenderContent()
Context.SetEnableInput(bEnableInput); Context.SetEnableInput(bEnableInput);
} }
ImGui::SetItemTooltip("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui."); ImGui::SetItemTooltip("Enable ImGui inputs. When enabled the ImGui menu is shown and inputs are forwarded to ImGui.");
FCogWindowWidgets::MenuItemShortcut("EnableInputShortcut", FCogImguiInputHelper::CommandToString(PlayerInput, UCogWindowManager::ToggleInputCommand));
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();
}
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
bool bShareKeyboard = Context.GetShareKeyboard(); bool bShareKeyboard = Context.GetShareKeyboard();
@@ -23,10 +23,14 @@ class COGWINDOW_API FCogWindowWidgets
{ {
public: public:
static void BeginTableTooltip(); static bool BeginTableTooltip();
static void EndTableTooltip(); static void EndTableTooltip();
static bool BeginItemTableTooltip();
static void EndItemTableTooltip();
static void ThinSeparatorText(const char* Label); static void ThinSeparatorText(const char* Label);
static void ProgressBarCentered(float Fraction, const ImVec2& Size, const char* Overlay); 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 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> template<typename EnumType>
@@ -269,68 +269,66 @@ void FCogAIWindow_BehaviorTree::RenderNode(UBehaviorTreeComponent& BehaviorTreeC
//------------------------ //------------------------
// Tooltip // 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)) const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
{
ImGui::TableSetupColumn("Property");
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
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 // Static Description
//------------------------ //------------------------
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Name"); ImGui::TextColored(TextColor, "Description");
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%s", NodeName.Get()); ImGui::Text("%s", TCHAR_TO_ANSI(*Node->GetStaticDescription()));
//------------------------ //------------------------
// Static Description // Runtime Values
//------------------------ //------------------------
ImGui::TableNextRow(); TArray<FString> RunTimeValues;
ImGui::TableNextColumn(); uint8* NodeMemory = BehaviorTreeComponent.GetNodeMemory(Node, BehaviorTreeComponent.GetActiveInstanceIdx());
ImGui::TextColored(TextColor, "Description"); Node->DescribeRuntimeValues(BehaviorTreeComponent, NodeMemory, EBTDescriptionVerbosity::Detailed, RunTimeValues);
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*Node->GetStaticDescription()));
//------------------------ for (const FString& RuntimeValue : RunTimeValues)
// Runtime Values {
//------------------------ ImGui::TableNextRow();
TArray<FString> RunTimeValues;
uint8* NodeMemory = BehaviorTreeComponent.GetNodeMemory(Node, BehaviorTreeComponent.GetActiveInstanceIdx());
Node->DescribeRuntimeValues(BehaviorTreeComponent, NodeMemory, EBTDescriptionVerbosity::Detailed, RunTimeValues);
for (const FString& RuntimeValue : RunTimeValues) FString Left, Right;
{ if (RuntimeValue.Split(TEXT(": "), &Left, &Right))
ImGui::TableNextRow(); {
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "%s", TCHAR_TO_ANSI(*Left));
FString Left, Right; ImGui::TableNextColumn();
if (RuntimeValue.Split(TEXT(": "), &Left, &Right)) ImGui::Text("%s", TCHAR_TO_ANSI(*Right));
{ }
ImGui::TableNextColumn(); else
ImGui::TextColored(TextColor, "%s", TCHAR_TO_ANSI(*Left)); {
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Value");
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*RuntimeValue));
}
}
ImGui::TableNextColumn(); ImGui::EndTable();
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(); FCogWindowWidgets::EndItemTableTooltip();
}
FCogWindowWidgets::EndTableTooltip();
} }
//------------------------ //------------------------
@@ -201,13 +201,13 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenuColorSettings()
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Abilities::RenderAbilityActivation(FGameplayAbilitySpec& Spec) void FCogAbilityWindow_Abilities::RenderAbilityActivation(FGameplayAbilitySpec& Spec)
{ {
FCogWindowWidgets::PushStyleCompact(); FCogWindowWidgets::PushStyleCompact();
bool IsActive = Spec.IsActive(); bool IsActive = Spec.IsActive();
if (ImGui::Checkbox("##Activation", &IsActive)) if (ImGui::Checkbox("##Activation", &IsActive))
{ {
AbilityHandleToActivate = Spec.Handle; AbilityHandleToActivate = Spec.Handle;
} }
FCogWindowWidgets::PopStyleCompact(); FCogWindowWidgets::PopStyleCompact();
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
@@ -216,15 +216,15 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityName(UAbilitySystem
const ImVec4 Color = GetAbilityColor(AbilitySystemComponent, Spec); const ImVec4 Color = GetAbilityColor(AbilitySystemComponent, Spec);
ImGui::PushStyleColor(ImGuiCol_Text, Color); ImGui::PushStyleColor(ImGuiCol_Text, Color);
if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick)) if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
{ {
SelectedIndex = Index; SelectedIndex = Index;
if (ImGui::IsMouseDoubleClicked(0)) if (ImGui::IsMouseDoubleClicked(0))
{ {
OpenAbility(Spec.Handle); OpenAbility(Spec.Handle);
} }
} }
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);
} }
@@ -232,26 +232,26 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityName(UAbilitySystem
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityBlocking(UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility* Ability) void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityBlocking(UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility* Ability)
{ {
if (Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false) if (Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false)
{ {
FGameplayTagContainer OwnedGameplayTags; FGameplayTagContainer OwnedGameplayTags;
AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags); AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags);
if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags)) if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags))
{ {
FGameplayTagContainer AllBlockingTags; FGameplayTagContainer AllBlockingTags;
AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags); AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags);
AllBlockingTags.AppendTags(OwnedGameplayTags); 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(); ImGui::SameLine();
if (const FGameplayTagContainer* ActivationRequiredTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationRequiredTags)) 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)); 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) if (ShouldShowAbility(AbilitySystemComponent, Spec, Ability) == false)
{ {
continue; continue;
} }
const auto AbilityName = StringCast<ANSICHAR>(*GetAbilityName(Ability)); const auto AbilityName = StringCast<ANSICHAR>(*GetAbilityName(Ability));
if (Filter.PassFilter(AbilityName.Get()) == false) if (Filter.PassFilter(AbilityName.Get()) == false)
@@ -390,11 +390,10 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableRow(UAbilitySystemComponen
//------------------------ //------------------------
// Popup // Popup
//------------------------ //------------------------
if (ImGui::IsItemHovered()) if (FCogWindowWidgets::BeginItemTableTooltip())
{ {
FCogWindowWidgets::BeginTableTooltip();
RenderAbilityInfo(AbilitySystemComponent, Spec); RenderAbilityInfo(AbilitySystemComponent, Spec);
FCogWindowWidgets::EndTableTooltip(); FCogWindowWidgets::EndItemTableTooltip();
} }
//------------------------ //------------------------
@@ -537,7 +536,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
if (ImGui::BeginTable("Ability", 2, ImGuiTableFlags_Borders)) 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("Property");
ImGui::TableSetupColumn("Value"); ImGui::TableSetupColumn("Value");
@@ -665,8 +664,8 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
} }
//------------------------ //------------------------
// Additional info // Additional info
//------------------------ //------------------------
RenderAbilityAdditionalInfo(AbilitySystemComponent, Spec, *Ability, TextColor); RenderAbilityAdditionalInfo(AbilitySystemComponent, Spec, *Ability, TextColor);
ImGui::EndTable(); ImGui::EndTable();
@@ -61,10 +61,17 @@ void FCogAbilityWindow_Attributes::RenderContent()
ImGui::Checkbox("Group by Attribute Set", &Config->GroupByAttributeSet); ImGui::Checkbox("Group by Attribute Set", &Config->GroupByAttributeSet);
ImGui::Checkbox("Group by Category", &Config->GroupByCategory); ImGui::Checkbox("Group by Category", &Config->GroupByCategory);
ImGui::Checkbox("Show Only Modified", &Config->ShowOnlyModified); 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::Separator();
ImGui::ColorEdit4("Positive Color", (float*)&AlignmentConfig->PositiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); ImGui::ColorEdit4("Positive Color", (float*)&AlignmentConfig->PositiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
ImGui::ColorEdit4("Negative Color", (float*)&AlignmentConfig->NegativeColor, 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("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(); ImGui::Separator();
if (ImGui::MenuItem("Reset")) if (ImGui::MenuItem("Reset"))
{ {
@@ -78,10 +85,12 @@ void FCogAbilityWindow_Attributes::RenderContent()
ImGui::EndMenuBar(); ImGui::EndMenuBar();
} }
bool bGroupByAttributeSetValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByAttributeSet; const bool bGroupByAttributeSetValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByAttributeSet;
bool bGroupByCategoryValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByCategory; 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_Resizable
| ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_NoBordersInBodyUntilResize
| ImGuiTableFlags_ScrollY | ImGuiTableFlags_ScrollY
@@ -91,6 +100,8 @@ void FCogAbilityWindow_Attributes::RenderContent()
| ImGuiTableFlags_Hideable)) | ImGuiTableFlags_Hideable))
{ {
ImGui::TableSetupScrollFreeze(0, 1); 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("Attribute");
ImGui::TableSetupColumn("Base"); ImGui::TableSetupColumn("Base");
ImGui::TableSetupColumn("Current"); ImGui::TableSetupColumn("Current");
@@ -102,23 +113,46 @@ void FCogAbilityWindow_Attributes::RenderContent()
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------
// Draw all the attribute sets // 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; bool bOpenAttributeSet = true;
if (bGroupByAttributeSetValue) if (bGroupByAttributeSetValue)
{ {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); 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) if (bOpenAttributeSet)
{ {
TArray<FGameplayAttribute> AllAttributes; TArray<FGameplayAttribute> AllAttributes;
for (TFieldIterator<FProperty> It(Set->GetClass()); It; ++It) for (TFieldIterator<FProperty> It(AttributeSet->GetClass()); It; ++It)
{ {
FGameplayAttribute Attribute = *It; FGameplayAttribute Attribute = *It;
if (Attribute.IsValid()) if (Attribute.IsValid())
@@ -176,7 +210,9 @@ void FCogAbilityWindow_Attributes::RenderContent()
{ {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); 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) if (bOpenCategory)
@@ -201,50 +237,55 @@ void FCogAbilityWindow_Attributes::RenderContent()
for (const FGameplayAttribute& Attribute : AttributesInCategory) for (const FGameplayAttribute& Attribute : AttributesInCategory)
{ {
if (!Attribute.IsValid()) 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) if (Filter.PassFilter(AttributeNameStr.Get()) == false)
{ { continue; }
continue;
}
const float BaseValue = AbilitySystemComponent->GetNumericAttributeBase(Attribute); const float BaseValue = AbilitySystemComponent->GetNumericAttributeBase(Attribute);
const float CurrentValue = AbilitySystemComponent->GetNumericAttribute(Attribute); const float CurrentValue = AbilitySystemComponent->GetNumericAttribute(Attribute);
if (Config->ShowOnlyModified && FMath::IsNearlyEqual(CurrentValue, BaseValue)) if (Config->ShowOnlyModified && FMath::IsNearlyEqual(CurrentValue, BaseValue))
{ { continue; }
continue;
} ImGui::PushID(AttributeNameStr.Get());
ImGui::TableNextRow(); ImGui::TableNextRow();
//------------------------
// Selectable
//------------------------
ImGui::TableNextColumn();
if (ImGui::Selectable("", Selected == Index, ImGuiSelectableFlags_SpanAllColumns))
{
Selected = Index;
}
const ImVec4 Color = FCogImguiHelper::ToImVec4(AlignmentConfig->GetAttributeColor(*AbilitySystemComponent, Attribute)); const ImVec4 Color = FCogImguiHelper::ToImVec4(AlignmentConfig->GetAttributeColor(*AbilitySystemComponent, Attribute));
ImGui::PushStyleColor(ImGuiCol_Text, Color); ImGui::PushStyleColor(ImGuiCol_Text, Color);
//------------------------ //------------------------
// Name // Attribute Set
//------------------------
ImGui::TableNextColumn();
ImGui::Text("%s", AttributeSetNameStr.Get());
//------------------------
// Attribute Name
//------------------------ //------------------------
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text(""); ImGui::Text("%s", AttributeNameStr.Get());
ImGui::SameLine();
if (ImGui::Selectable(AttributeName.Get(), Selected == Index, ImGuiSelectableFlags_SpanAllColumns))
{
Selected = Index;
}
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);
//------------------------ //------------------------
// Popup // Popup
//------------------------ //------------------------
if (ImGui::IsItemHovered()) if (FCogWindowWidgets::BeginItemTableTooltip())
{ {
FCogWindowWidgets::BeginTableTooltip(); DrawAttributeInfo(*AbilitySystemComponent, AttributeSetNameStr.Get(), Attribute);
DrawAttributeInfo(*AbilitySystemComponent, Attribute); FCogWindowWidgets::EndItemTableTooltip();
FCogWindowWidgets::EndTableTooltip();
} }
ImGui::PushStyleColor(ImGuiCol_Text, Color); ImGui::PushStyleColor(ImGuiCol_Text, Color);
@@ -263,6 +304,8 @@ void FCogAbilityWindow_Attributes::RenderContent()
ImGui::PopStyleColor(1); ImGui::PopStyleColor(1);
ImGui::PopID();
Index++; Index++;
} }
} }
@@ -274,10 +317,15 @@ void FCogAbilityWindow_Attributes::RenderContent()
} }
} }
if (bOpenAttributeSet && bGroupByAttributeSetValue) if (bGroupByAttributeSetValue)
{ {
ImGui::TreePop(); if (bOpenAttributeSet)
{
ImGui::TreePop();
}
} }
ImGui::PopID();
} }
ImGui::EndTable(); 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)) 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("Property");
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
@@ -297,6 +345,15 @@ void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone
const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute); const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute);
const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(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 // Name
//------------------------ //------------------------
@@ -329,7 +386,7 @@ void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone
//------------------------ //------------------------
// Modifiers // Modifiers
//------------------------ //------------------------
FGameplayEffectQuery Query; const FGameplayEffectQuery Query;
for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent.GetActiveEffects(Query)) for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent.GetActiveEffects(Query))
{ {
const FActiveGameplayEffect* ActiveEffect = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle); const FActiveGameplayEffect* ActiveEffect = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle);
@@ -213,11 +213,10 @@ void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& Ability
//------------------------ //------------------------
// Popup // Popup
//------------------------ //------------------------
if (ImGui::IsItemHovered()) if (FCogWindowWidgets::BeginItemTableTooltip())
{ {
FCogWindowWidgets::BeginTableTooltip();
RenderEffectInfo(AbilitySystemComponent, ActiveEffect, Effect); RenderEffectInfo(AbilitySystemComponent, ActiveEffect, Effect);
FCogWindowWidgets::EndTableTooltip(); FCogWindowWidgets::EndItemTableTooltip();
} }
//------------------------ //------------------------
@@ -134,11 +134,10 @@ void FCogAbilityWindow_Tags::RenderTagContainer(const UAbilitySystemComponent& A
//------------------------ //------------------------
// Tooltip // Tooltip
//------------------------ //------------------------
if (ImGui::IsItemHovered()) if (FCogWindowWidgets::BeginItemTableTooltip())
{ {
FCogWindowWidgets::BeginTableTooltip();
RenderTag(AbilitySystemComponent, Tag); RenderTag(AbilitySystemComponent, Tag);
FCogWindowWidgets::EndTableTooltip(); FCogWindowWidgets::EndItemTableTooltip();
} }
ImGui::PopID(); ImGui::PopID();
@@ -2,11 +2,8 @@
#include "AbilitySystemGlobals.h" #include "AbilitySystemGlobals.h"
#include "AbilitySystemComponent.h" #include "AbilitySystemComponent.h"
#include "CogAbilityDataAsset.h"
#include "CogAbilityHelper.h" #include "CogAbilityHelper.h"
#include "CogAbilityReplicator.h"
#include "CogImguiHelper.h" #include "CogImguiHelper.h"
#include "CogWindowHelper.h"
#include "CogWindowWidgets.h" #include "CogWindowWidgets.h"
#include "imgui.h" #include "imgui.h"
@@ -177,7 +174,7 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
continue; continue;
} }
FilteredTasks.Add(Task); FilteredTasks.Add(Task);
} }
if (Config->SortByName) if (Config->SortByName)
@@ -237,11 +234,10 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
//------------------------ //------------------------
// Popup // Popup
//------------------------ //------------------------
if (ImGui::IsItemHovered()) if (FCogWindowWidgets::BeginItemTableTooltip())
{ {
FCogWindowWidgets::BeginTableTooltip();
RenderTaskInfo(Task); RenderTaskInfo(Task);
FCogWindowWidgets::EndTableTooltip(); FCogWindowWidgets::EndItemTableTooltip();
} }
//------------------------ //------------------------
@@ -254,7 +250,7 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
// IsTicking // IsTicking
//------------------------ //------------------------
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No"); ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
ImGui::PopID(); ImGui::PopID();
} }
@@ -275,7 +271,7 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
if (ImGui::BeginTable("Task", 2, ImGuiTableFlags_Borders)) 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("Property");
ImGui::TableSetupColumn("Value"); ImGui::TableSetupColumn("Value");
@@ -290,8 +286,8 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetName()).Get()); ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetName()).Get());
//------------------------ //------------------------
// Instance Name // Instance Name
//------------------------ //------------------------
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Instance Name"); 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()); ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetInstanceName().ToString()).Get());
//------------------------ //------------------------
// Owner // Owner
//------------------------ //------------------------
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Ability"); ImGui::TextColored(TextColor, "Ability");
@@ -316,9 +312,9 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::TableNextColumn(); ImGui::TableNextColumn();
RenderTaskState(Task); RenderTaskState(Task);
//------------------------ //------------------------
// Priority // Priority
//------------------------ //------------------------
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Priority"); ImGui::TextColored(TextColor, "Priority");
@@ -326,17 +322,17 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::Text("%d", (int32)Task->GetPriority()); ImGui::Text("%d", (int32)Task->GetPriority());
//------------------------ //------------------------
// IsTicking // IsTicking
//------------------------ //------------------------
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Is Ticking"); ImGui::TextColored(TextColor, "Is Ticking");
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No"); ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
//------------------------ //------------------------
// IsSimulated // IsSimulated
//------------------------ //------------------------
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Is Simulated"); ImGui::TextColored(TextColor, "Is Simulated");
@@ -344,8 +340,8 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::Text(Task->IsSimulatedTask() ? "Yes" : "No"); ImGui::Text(Task->IsSimulatedTask() ? "Yes" : "No");
//------------------------ //------------------------
// IsSimulating // IsSimulating
//------------------------ //------------------------
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Is Simulating"); ImGui::TextColored(TextColor, "Is Simulating");
@@ -353,15 +349,15 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
ImGui::Text(Task->IsSimulating() ? "Yes" : "No"); ImGui::Text(Task->IsSimulating() ? "Yes" : "No");
//------------------------ //------------------------
// Debug // Debug
//------------------------ //------------------------
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Debug"); ImGui::TextColored(TextColor, "Debug");
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::PushTextWrapPos(FCogWindowWidgets::GetFontWidth() * 80); ImGui::PushTextWrapPos(FCogWindowWidgets::GetFontWidth() * 80);
ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetDebugString()).Get()); ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetDebugString()).Get());
ImGui::PopTextWrapPos(); ImGui::PopTextWrapPos();
ImGui::EndTable(); ImGui::EndTable();
} }
@@ -5,6 +5,7 @@
#include "CogWindow.h" #include "CogWindow.h"
#include "CogAbilityWindow_Attributes.generated.h" #include "CogAbilityWindow_Attributes.generated.h"
class UAttributeSet;
class UAbilitySystemComponent; class UAbilitySystemComponent;
class UCogAbilityConfig_Attributes; class UCogAbilityConfig_Attributes;
class UCogAbilityConfig_Alignment; class UCogAbilityConfig_Alignment;
@@ -29,7 +30,7 @@ protected:
virtual void RenderContent() override; 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: private:
@@ -60,6 +61,15 @@ public:
UPROPERTY(Config) UPROPERTY(Config)
bool ShowOnlyModified = false; 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 virtual void Reset() override
{ {
Super::Reset(); Super::Reset();
@@ -68,5 +78,8 @@ public:
GroupByAttributeSet = false; GroupByAttributeSet = false;
GroupByCategory = false; GroupByCategory = false;
ShowOnlyModified = 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);
} }
}; };