CogAbility: Add blocked ability tags

This commit is contained in:
Arnaud Jamin
2023-11-04 00:20:18 -04:00
parent 429123dbd3
commit 9d3143298b
3 changed files with 104 additions and 12 deletions
@@ -11,8 +11,6 @@ void FCogAbilityWindow_Tags::Initialize()
Super::Initialize();
bHasMenu = true;
Config = GetConfig<UCogAbilityConfig_Tags>();
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -42,11 +40,10 @@ void FCogAbilityWindow_Tags::RenderContent()
return;
}
FGameplayTagContainer OwnedTags, BlockedTags;
AbilitySystemComponent->GetOwnedGameplayTags(OwnedTags);
AbilitySystemComponent->GetBlockedAbilityTags(BlockedTags);
FGameplayTagContainer Tags;
GetTagContainer(Tags);
RenderTagContainer("Owned Tags", *AbilitySystemComponent, OwnedTags);
RenderTagContainer(*AbilitySystemComponent, Tags);
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -75,9 +72,9 @@ void FCogAbilityWindow_Tags::RenderMenu()
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_Tags::RenderTagContainer(const FString& TagContainerName, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer)
void FCogAbilityWindow_Tags::RenderTagContainer(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer)
{
if (ImGui::BeginTable(TCHAR_TO_ANSI(*TagContainerName), 2, ImGuiTableFlags_SizingFixedFit
if (ImGui::BeginTable("Tags", 2, ImGuiTableFlags_SizingFixedFit
| ImGuiTableFlags_Resizable
| ImGuiTableFlags_NoBordersInBodyUntilResize
| ImGuiTableFlags_ScrollY
@@ -89,7 +86,7 @@ void FCogAbilityWindow_Tags::RenderTagContainer(const FString& TagContainerName,
{
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("Count");
ImGui::TableSetupColumn(TCHAR_TO_ANSI(*TagContainerName));
ImGui::TableSetupColumn(TCHAR_TO_ANSI(*GetName()));
ImGui::TableHeadersRow();
TArray<FGameplayTag> Tags;
@@ -207,4 +204,56 @@ void FCogAbilityWindow_Tags::RenderTag(const UAbilitySystemComponent& AbilitySys
ImGui::EndTable();
}
}
}
//--------------------------------------------------------------------------------------------------------------------------
// FCogAbilityWindow_OwnedTags
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_OwnedTags::Initialize()
{
Super::Initialize();
Config = GetConfig<UCogAbilityConfig_OwnedTags>();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_OwnedTags::RenderHelp()
{
ImGui::Text("This window displays gameplay tags of the selected actor. ");
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_OwnedTags::GetTagContainer(FGameplayTagContainer& TagContainer)
{
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
if (AbilitySystemComponent == nullptr)
{
return;
}
AbilitySystemComponent->GetOwnedGameplayTags(TagContainer);
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_BlockedTags::Initialize()
{
Super::Initialize();
Config = GetConfig<UCogAbilityConfig_BlockedAbilitiesTags>();
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_BlockedTags::RenderHelp()
{
ImGui::Text("This window displays the tags blocking abilities of the selected actor.");
}
//--------------------------------------------------------------------------------------------------------------------------
void FCogAbilityWindow_BlockedTags::GetTagContainer(FGameplayTagContainer& TagContainer)
{
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
if (AbilitySystemComponent == nullptr)
{
return;
}
AbilitySystemComponent->GetBlockedAbilityTags(TagContainer);
}
@@ -21,13 +21,15 @@ public:
protected:
virtual void GetTagContainer(FGameplayTagContainer& TagContainer) {}
virtual void ResetConfig();
virtual void RenderHelp() override;
virtual void RenderContent() override;
virtual void RenderTagContainer(const FString& TagContainerName, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer);
virtual void RenderTagContainer(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer);
virtual void RenderTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag);
@@ -38,6 +40,31 @@ protected:
ImGuiTextFilter Filter;
};
//--------------------------------------------------------------------------------------------------------------------------
class COGABILITY_API FCogAbilityWindow_OwnedTags : public FCogAbilityWindow_Tags
{
typedef FCogAbilityWindow_Tags Super;
virtual void Initialize() override;
virtual void RenderHelp() override;
virtual void GetTagContainer(FGameplayTagContainer& TagContainer);
};
//--------------------------------------------------------------------------------------------------------------------------
class COGABILITY_API FCogAbilityWindow_BlockedTags : public FCogAbilityWindow_Tags
{
typedef FCogAbilityWindow_Tags Super;
virtual void Initialize() override;
virtual void RenderHelp() override;
virtual void GetTagContainer(FGameplayTagContainer& TagContainer);
};
//--------------------------------------------------------------------------------------------------------------------------
UCLASS(Config = Cog)
class UCogAbilityConfig_Tags : public UCogWindowConfig
@@ -55,4 +82,18 @@ public:
SortByName = false;
}
};
//--------------------------------------------------------------------------------------------------------------------------
UCLASS(Config = Cog)
class UCogAbilityConfig_OwnedTags : public UCogAbilityConfig_Tags
{
GENERATED_BODY()
};
//--------------------------------------------------------------------------------------------------------------------------
UCLASS(Config = Cog)
class UCogAbilityConfig_BlockedAbilitiesTags : public UCogAbilityConfig_Tags
{
GENERATED_BODY()
};
+3 -1
View File
@@ -171,13 +171,15 @@ void ACogSampleGameState::InitializeCog()
CogWindowManager->AddWindow<FCogAbilityWindow_Attributes>("Gameplay.Attributes");
CogWindowManager->AddWindow<FCogAbilityWindow_BlockedTags>("Gameplay.Blocking Tags");
CogWindowManager->AddWindow<FCogAbilityWindow_Cheats>("Gameplay.Cheats");
CogWindowManager->AddWindow<FCogAbilityWindow_Effects>("Gameplay.Effects");
CogWindowManager->AddWindow<FCogAbilityWindow_Pools>("Gameplay.Pools");
CogWindowManager->AddWindow<FCogAbilityWindow_Tags>("Gameplay.Tags");
CogWindowManager->AddWindow<FCogAbilityWindow_OwnedTags>("Gameplay.Owned Tags");
CogWindowManager->AddWindow<FCogAbilityWindow_Tweaks>("Gameplay.Tweaks");