mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-05 23:28:46 +00:00
CogAbility: Add menu to sort and filter Tags window
This commit is contained in:
@@ -238,7 +238,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
|
|||||||
| ImGuiTableFlags_Reorderable
|
| ImGuiTableFlags_Reorderable
|
||||||
| ImGuiTableFlags_Hideable))
|
| ImGuiTableFlags_Hideable))
|
||||||
{
|
{
|
||||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed);
|
ImGui::TableSetupColumn("##Activation", ImGuiTableColumnFlags_WidthFixed);
|
||||||
ImGui::TableSetupScrollFreeze(0, 1);
|
ImGui::TableSetupScrollFreeze(0, 1);
|
||||||
ImGui::TableSetupColumn("Ability");
|
ImGui::TableSetupColumn("Ability");
|
||||||
ImGui::TableSetupColumn("Level");
|
ImGui::TableSetupColumn("Level");
|
||||||
|
|||||||
@@ -10,7 +10,17 @@ void FCogAbilityWindow_Tags::Initialize()
|
|||||||
{
|
{
|
||||||
Super::Initialize();
|
Super::Initialize();
|
||||||
|
|
||||||
bHasMenu = false;
|
bHasMenu = true;
|
||||||
|
|
||||||
|
Config = GetConfig<UCogAbilityConfig_Tags>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tags::ResetConfig()
|
||||||
|
{
|
||||||
|
Super::ResetConfig();
|
||||||
|
|
||||||
|
Config->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -24,6 +34,8 @@ void FCogAbilityWindow_Tags::RenderContent()
|
|||||||
{
|
{
|
||||||
Super::RenderContent();
|
Super::RenderContent();
|
||||||
|
|
||||||
|
RenderMenu();
|
||||||
|
|
||||||
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
|
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
|
||||||
if (AbilitySystemComponent == nullptr)
|
if (AbilitySystemComponent == nullptr)
|
||||||
{
|
{
|
||||||
@@ -34,11 +46,113 @@ void FCogAbilityWindow_Tags::RenderContent()
|
|||||||
AbilitySystemComponent->GetOwnedGameplayTags(OwnedTags);
|
AbilitySystemComponent->GetOwnedGameplayTags(OwnedTags);
|
||||||
AbilitySystemComponent->GetBlockedAbilityTags(BlockedTags);
|
AbilitySystemComponent->GetBlockedAbilityTags(BlockedTags);
|
||||||
|
|
||||||
DrawTagContainer("Owned Tags", *AbilitySystemComponent, OwnedTags);
|
RenderTagContainer("Owned Tags", *AbilitySystemComponent, OwnedTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogAbilityWindow_Tags::DrawTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag)
|
void FCogAbilityWindow_Tags::RenderMenu()
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenuBar())
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenu("Options"))
|
||||||
|
{
|
||||||
|
ImGui::Checkbox("Sort by Name", &Config->SortByName);
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("Reset"))
|
||||||
|
{
|
||||||
|
ResetConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
FCogWindowWidgets::MenuSearchBar(Filter);
|
||||||
|
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tags::RenderTagContainer(const FString& TagContainerName, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer)
|
||||||
|
{
|
||||||
|
if (ImGui::BeginTable(TCHAR_TO_ANSI(*TagContainerName), 2, ImGuiTableFlags_SizingFixedFit
|
||||||
|
| ImGuiTableFlags_Resizable
|
||||||
|
| ImGuiTableFlags_NoBordersInBodyUntilResize
|
||||||
|
| ImGuiTableFlags_ScrollY
|
||||||
|
| ImGuiTableFlags_RowBg
|
||||||
|
| ImGuiTableFlags_BordersOuter
|
||||||
|
| ImGuiTableFlags_BordersV
|
||||||
|
| ImGuiTableFlags_Reorderable
|
||||||
|
| ImGuiTableFlags_Hideable))
|
||||||
|
{
|
||||||
|
ImGui::TableSetupScrollFreeze(0, 1);
|
||||||
|
ImGui::TableSetupColumn("Count");
|
||||||
|
ImGui::TableSetupColumn(TCHAR_TO_ANSI(*TagContainerName));
|
||||||
|
ImGui::TableHeadersRow();
|
||||||
|
|
||||||
|
TArray<FGameplayTag> Tags;
|
||||||
|
TagContainer.GetGameplayTagArray(Tags);
|
||||||
|
|
||||||
|
Tags.RemoveAll([&](const FGameplayTag& Tag)
|
||||||
|
{
|
||||||
|
return Filter.PassFilter(TCHAR_TO_ANSI(*Tag.GetTagName().ToString())) == false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Config->SortByName)
|
||||||
|
{
|
||||||
|
Tags.Sort([](const FGameplayTag& Tag1, const FGameplayTag& Tag2)
|
||||||
|
{
|
||||||
|
return Tag1.GetTagName().Compare(Tag2.GetTagName()) < 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Selected = -1;
|
||||||
|
int Index = 0;
|
||||||
|
|
||||||
|
for (const FGameplayTag& Tag : Tags)
|
||||||
|
{
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
|
ImGui::PushID(Index);
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Count
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
const int32 TagCount = AbilitySystemComponent.GetTagCount(Tag);
|
||||||
|
ImGui::TextColored(TagCount > 1 ? ImVec4(1.0f, 1.0f, 0.0f, 1.0f) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f), "%d", TagCount);
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Name
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if (ImGui::Selectable(TCHAR_TO_ANSI(*Tag.GetTagName().ToString()), Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||||
|
{
|
||||||
|
Selected = Index;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Tooltip
|
||||||
|
//------------------------
|
||||||
|
if (ImGui::IsItemHovered())
|
||||||
|
{
|
||||||
|
FCogWindowWidgets::BeginTableTooltip();
|
||||||
|
RenderTag(AbilitySystemComponent, Tag);
|
||||||
|
FCogWindowWidgets::EndTableTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
|
Index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tags::RenderTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag)
|
||||||
{
|
{
|
||||||
if (ImGui::BeginTable("Tag", 2, ImGuiTableFlags_Borders))
|
if (ImGui::BeginTable("Tag", 2, ImGuiTableFlags_Borders))
|
||||||
{
|
{
|
||||||
@@ -91,61 +205,6 @@ void FCogAbilityWindow_Tags::DrawTag(const UAbilitySystemComponent& AbilitySyste
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndTable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
void FCogAbilityWindow_Tags::DrawTagContainer(const FString& TagContainerName, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer)
|
|
||||||
{
|
|
||||||
if (ImGui::BeginTable(TCHAR_TO_ANSI(*TagContainerName), 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_BordersOuterV))
|
|
||||||
{
|
|
||||||
ImGui::TableSetupColumn("Count");
|
|
||||||
ImGui::TableSetupColumn(TCHAR_TO_ANSI(*TagContainerName));
|
|
||||||
ImGui::TableHeadersRow();
|
|
||||||
|
|
||||||
TArray<FGameplayTag> Tags;
|
|
||||||
TagContainer.GetGameplayTagArray(Tags);
|
|
||||||
|
|
||||||
static int Selected = -1;
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
for (const FGameplayTag& Tag : Tags)
|
|
||||||
{
|
|
||||||
ImGui::TableNextRow();
|
|
||||||
|
|
||||||
ImGui::PushID(index);
|
|
||||||
|
|
||||||
//------------------------
|
|
||||||
// Count
|
|
||||||
//------------------------
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
const int32 TagCount = AbilitySystemComponent.GetTagCount(Tag);
|
|
||||||
ImGui::TextColored(TagCount > 1 ? ImVec4(1.0f, 1.0f, 0.0f, 1.0f) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f), "%d", TagCount);
|
|
||||||
|
|
||||||
//------------------------
|
|
||||||
// Name
|
|
||||||
//------------------------
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*Tag.GetTagName().ToString()), Selected == index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
|
||||||
{
|
|
||||||
Selected = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------
|
|
||||||
// Tooltip
|
|
||||||
//------------------------
|
|
||||||
if (ImGui::IsItemHovered())
|
|
||||||
{
|
|
||||||
FCogWindowWidgets::BeginTableTooltip();
|
|
||||||
DrawTag(AbilitySystemComponent, Tag);
|
|
||||||
FCogWindowWidgets::EndTableTooltip();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::PopID();
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "CogWindow.h"
|
#include "CogWindow.h"
|
||||||
|
#include "CogWindowConfig.h"
|
||||||
|
#include "CogAbilityWindow_Tags.generated.h"
|
||||||
|
|
||||||
class UAbilitySystemComponent;
|
|
||||||
struct FGameplayTagContainer;
|
struct FGameplayTagContainer;
|
||||||
struct FGameplayTag;
|
struct FGameplayTag;
|
||||||
|
class UCogAbilityConfig_Tags;
|
||||||
|
class UAbilitySystemComponent;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
class COGABILITY_API FCogAbilityWindow_Tags : public FCogWindow
|
class COGABILITY_API FCogAbilityWindow_Tags : public FCogWindow
|
||||||
@@ -18,11 +21,38 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
virtual void ResetConfig();
|
||||||
|
|
||||||
virtual void RenderHelp() override;
|
virtual void RenderHelp() override;
|
||||||
|
|
||||||
virtual void RenderContent() override;
|
virtual void RenderContent() override;
|
||||||
|
|
||||||
virtual void DrawTagContainer(const FString& TagContainerName, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer);
|
virtual void RenderTagContainer(const FString& TagContainerName, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer);
|
||||||
|
|
||||||
virtual void DrawTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag);
|
virtual void RenderTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag);
|
||||||
|
|
||||||
|
virtual void RenderMenu();
|
||||||
|
|
||||||
|
TObjectPtr<UCogAbilityConfig_Tags> Config = nullptr;
|
||||||
|
|
||||||
|
ImGuiTextFilter Filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
UCLASS(Config = Cog)
|
||||||
|
class UCogAbilityConfig_Tags : public UCogWindowConfig
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool SortByName = false;
|
||||||
|
|
||||||
|
virtual void Reset() override
|
||||||
|
{
|
||||||
|
Super::Reset();
|
||||||
|
|
||||||
|
SortByName = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
- CogWindow: Add reset window position menu item or reset layout (window can get far away)
|
- CogWindow: Add reset window position menu item or reset layout (window can get far away)
|
||||||
- CogWindow: Try to remove CogWindow dependency to cogimgui. Should only depends on imgui (currently use setdpiscale of cogimgui)
|
- CogWindow: Try to remove CogWindow dependency to cogimgui. Should only depends on imgui (currently use setdpiscale of cogimgui)
|
||||||
|
- CogWindow: Overlay window should have achnoring options (top bottom left right center mid)
|
||||||
|
- CogWindow: Hide menu is not saved anymore
|
||||||
|
|
||||||
- CogEngine: More stats in the stats window
|
- CogEngine: More stats in the stats window
|
||||||
- CogEngine: Overlay mode of stats.
|
- CogEngine: Overlay mode of stats.
|
||||||
@@ -22,6 +24,4 @@
|
|||||||
- CogSample: Add more debug for area (change color on tick, duration ...)
|
- CogSample: Add more debug for area (change color on tick, duration ...)
|
||||||
|
|
||||||
- CogDebug: Check KismetExecutionMessage for warnings. As an exemple it is used by GEngine::GetWorldFromContextObject.
|
- CogDebug: Check KismetExecutionMessage for warnings. As an exemple it is used by GEngine::GetWorldFromContextObject.
|
||||||
- CogDebug: Rework Tickness and Duration params.
|
- CogDebug: Rework Thickness and Duration params.
|
||||||
|
|
||||||
- CogInput: Add gamepad stick drag to set their values
|
|
||||||
|
|||||||
Reference in New Issue
Block a user