mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-06 15:48:48 +00:00
Add gameplay tasks window. Add blocking tags in the gameplay ability window.
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Hack to access to private members
|
||||||
|
// https://github.com/YunHsiao/Crysknife/blob/main/SourcePatch/Runtime/Core/Public/Misc/PrivateAccessor.h
|
||||||
|
// https://bloglitb.blogspot.com/2010/07/access-to-private-members-thats-easy.html
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template<typename Type, Type& Output, Type Input>
|
||||||
|
struct TRob
|
||||||
|
{
|
||||||
|
TRob() { Output = Input; }
|
||||||
|
static TRob Obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Type, Type& Output, Type Input>
|
||||||
|
TRob<Type, Output, Input> TRob<Type, Output, Input>::Obj;
|
||||||
|
|
||||||
|
template<typename OwnerType, typename VariableType>
|
||||||
|
using TMemberVariableType = VariableType(OwnerType::*);
|
||||||
|
|
||||||
|
template<typename OwnerType, typename ReturnType, typename... Args>
|
||||||
|
using TMemberFunctionType = ReturnType(OwnerType::*)(Args...);
|
||||||
|
|
||||||
|
template<typename OwnerType, typename ReturnType, typename... Args>
|
||||||
|
using TConstMemberFunctionType = ReturnType(OwnerType::*)(Args...) const;
|
||||||
|
|
||||||
|
template<typename VariableType>
|
||||||
|
using TStaticVariableType = VariableType*;
|
||||||
|
|
||||||
|
template<typename ReturnType, typename... Args>
|
||||||
|
using TStaticFunctionType = ReturnType(*)(Args...);
|
||||||
|
|
||||||
|
#define INIT_PRIVATE_ACCESSOR(Name, Value) template struct TRob<decltype(Name), Name, &Value>
|
||||||
|
|
||||||
|
#define DEFINE_PRIVATE_ACCESSOR(Name, Value, Type, ...) \
|
||||||
|
static Type<__VA_ARGS__> Name; \
|
||||||
|
INIT_PRIVATE_ACCESSOR(Name, Value)
|
||||||
|
|
||||||
|
/****************************** Syntactic Sugars ******************************/
|
||||||
|
|
||||||
|
#define DEFINE_PRIVATE_ACCESSOR_VARIABLE(Name, Class, VariableType, VariableName) DEFINE_PRIVATE_ACCESSOR(Name, Class::VariableName, TMemberVariableType, Class, VariableType)
|
||||||
|
#define DEFINE_PRIVATE_ACCESSOR_STATIC_VARIABLE(Name, Class, VariableType, VariableName) DEFINE_PRIVATE_ACCESSOR(Name, Class::VariableName, TStaticVariableType, VariableType)
|
||||||
|
#define DEFINE_PRIVATE_ACCESSOR_FUNCTION(Name, Class, ReturnType, FunctionName, ...) DEFINE_PRIVATE_ACCESSOR(Name, Class::FunctionName, TMemberFunctionType, Class, ReturnType, __VA_ARGS__)
|
||||||
|
#define DEFINE_PRIVATE_ACCESSOR_CONST_FUNCTION(Name, Class, ReturnType, FunctionName, ...) DEFINE_PRIVATE_ACCESSOR(Name, Class::FunctionName, TConstMemberFunctionType, Class, ReturnType, __VA_ARGS__)
|
||||||
|
#define DEFINE_PRIVATE_ACCESSOR_STATIC_FUNCTION(Name, Class, ReturnType, FunctionName, ...) DEFINE_PRIVATE_ACCESSOR(Name, Class::FunctionName, TStaticFunctionType, ReturnType, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define PRIVATE_ACCESS_OBJ(Obj, Name) (Obj.*Name)
|
||||||
|
#define PRIVATE_ACCESS_PTR(Ptr, Name) (Ptr->*Name)
|
||||||
|
#define PRIVATE_ACCESS_STATIC(Name) (*Name)
|
||||||
@@ -1020,3 +1020,13 @@ void FCogWindowWidgets::ActorFrame(const AActor& Actor)
|
|||||||
AddTextWithShadow(DrawList, FCogImguiHelper::ToImVec2(ScreenPosMin + FVector2D(0, -14.0f)) + Viewport->Pos, Color, TCHAR_TO_ANSI(*FCogWindowHelper::GetActorName(Actor)));
|
AddTextWithShadow(DrawList, FCogImguiHelper::ToImVec2(ScreenPosMin + FVector2D(0, -14.0f)) + Viewport->Pos, Color, TCHAR_TO_ANSI(*FCogWindowHelper::GetActorName(Actor)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogWindowWidgets::SmallButton(const char* Text, const ImVec4& Color)
|
||||||
|
{
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.6f));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.8f));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(Color.x, Color.y, Color.z, Color.w * 1.0f));
|
||||||
|
ImGui::SmallButton(Text);
|
||||||
|
ImGui::PopStyleColor(3);
|
||||||
|
}
|
||||||
@@ -102,6 +102,8 @@ public:
|
|||||||
static void ActorContextMenu(AActor& Selection, const FCogWindowActorContextMenuFunction& ContextMenuFunction);
|
static void ActorContextMenu(AActor& Selection, const FCogWindowActorContextMenuFunction& ContextMenuFunction);
|
||||||
|
|
||||||
static void ActorFrame(const AActor& Actor);
|
static void ActorFrame(const AActor& Actor);
|
||||||
|
|
||||||
|
static void SmallButton(const char* Text, const ImVec4& Color);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename EnumType>
|
template<typename EnumType>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnrealBuildTool;
|
using UnrealBuildTool;
|
||||||
|
using UnrealBuildTool.Rules;
|
||||||
|
|
||||||
public class CogAbility : ModuleRules
|
public class CogAbility : ModuleRules
|
||||||
{
|
{
|
||||||
@@ -37,6 +38,7 @@ public class CogAbility : ModuleRules
|
|||||||
new string[]
|
new string[]
|
||||||
{
|
{
|
||||||
"CoreUObject",
|
"CoreUObject",
|
||||||
|
"GameplayTasks",
|
||||||
"Engine",
|
"Engine",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "CogAbilityHelper.h"
|
#include "CogAbilityHelper.h"
|
||||||
|
|
||||||
|
#include "CogWindowWidgets.h"
|
||||||
#include "GameplayTagContainer.h"
|
#include "GameplayTagContainer.h"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
@@ -12,12 +13,32 @@ FString FCogAbilityHelper::CleanupName(FString Str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogAbilityHelper::RenderTagContainer(const FGameplayTagContainer& Container)
|
void FCogAbilityHelper::RenderTagContainer(const FGameplayTagContainer& Container, const bool Inline, const ImVec4& Color)
|
||||||
{
|
{
|
||||||
TArray<FGameplayTag> GameplayTags;
|
TArray<FGameplayTag> GameplayTags;
|
||||||
Container.GetGameplayTagArray(GameplayTags);
|
Container.GetGameplayTagArray(GameplayTags);
|
||||||
for (FGameplayTag Tag : GameplayTags)
|
for (const FGameplayTag& Tag : GameplayTags)
|
||||||
{
|
{
|
||||||
ImGui::Text("%s", TCHAR_TO_ANSI(*Tag.ToString()));
|
FCogWindowWidgets::SmallButton(StringCast<ANSICHAR>(*Tag.ToString()).Get(), Color);
|
||||||
|
if (Inline)
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityHelper::RenderTagContainerHighlighted(const FGameplayTagContainer& Container, const FGameplayTagContainer& TagsToHighlight, const bool Inline, const ImVec4& NormalColor, const ImVec4& HighlightColor)
|
||||||
|
{
|
||||||
|
TArray<FGameplayTag> GameplayTags;
|
||||||
|
Container.GetGameplayTagArray(GameplayTags);
|
||||||
|
for (const FGameplayTag& Tag : GameplayTags)
|
||||||
|
{
|
||||||
|
const ImVec4 Color = TagsToHighlight.HasTag(Tag) ? HighlightColor : NormalColor;
|
||||||
|
FCogWindowWidgets::SmallButton(StringCast<ANSICHAR>(*Tag.ToString()).Get(), Color);
|
||||||
|
if (Inline)
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,11 @@
|
|||||||
#include "CogAbilityReplicator.h"
|
#include "CogAbilityReplicator.h"
|
||||||
#include "CogImguiHelper.h"
|
#include "CogImguiHelper.h"
|
||||||
#include "CogWindowWidgets.h"
|
#include "CogWindowWidgets.h"
|
||||||
|
#include "CogDebugRob.h"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
|
DEFINE_PRIVATE_ACCESSOR_VARIABLE(GameplayAbility_ActivationBlockedTags, UGameplayAbility, FGameplayTagContainer, ActivationBlockedTags);
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogAbilityWindow_Abilities::Initialize()
|
void FCogAbilityWindow_Abilities::Initialize()
|
||||||
{
|
{
|
||||||
@@ -244,7 +247,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
|
|||||||
ImGui::TableSetupColumn("Level");
|
ImGui::TableSetupColumn("Level");
|
||||||
ImGui::TableSetupColumn("Input");
|
ImGui::TableSetupColumn("Input");
|
||||||
ImGui::TableSetupColumn("Cooldown");
|
ImGui::TableSetupColumn("Cooldown");
|
||||||
ImGui::TableSetupColumn("Blocked");
|
ImGui::TableSetupColumn("Blocking");
|
||||||
ImGui::TableHeadersRow();
|
ImGui::TableHeadersRow();
|
||||||
|
|
||||||
static int SelectedIndex = -1;
|
static int SelectedIndex = -1;
|
||||||
@@ -331,13 +334,27 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
|
|||||||
RenderAbilityCooldown(AbilitySystemComponent, *Ability);
|
RenderAbilityCooldown(AbilitySystemComponent, *Ability);
|
||||||
|
|
||||||
//------------------------
|
//------------------------
|
||||||
// Blocked
|
// Blocking
|
||||||
//------------------------
|
//------------------------
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
const bool IsBlocked = Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false;
|
if (Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false)
|
||||||
if (IsBlocked)
|
|
||||||
{
|
{
|
||||||
ImGui::Text("Blocked");
|
if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags))
|
||||||
|
{
|
||||||
|
FGameplayTagContainer AllBlockingTags;
|
||||||
|
AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags);
|
||||||
|
|
||||||
|
FGameplayTagContainer OwnedGameplayTags;
|
||||||
|
AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags);
|
||||||
|
AllBlockingTags.AppendTags(OwnedGameplayTags);
|
||||||
|
|
||||||
|
FGameplayTagContainer FilteredTags = AllBlockingTags.FilterExact(*ActivationBlockedTags);
|
||||||
|
FCogAbilityHelper::RenderTagContainer(FilteredTags, true, FCogImguiHelper::ToImVec4(Config->BlockedColor));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::Text("Blocked");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
@@ -526,7 +543,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
|
|||||||
//------------------------
|
//------------------------
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextColored(TextColor, "InputPressed");
|
ImGui::TextColored(TextColor, "Input Pressed");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("%d", Spec.InputPressed);
|
ImGui::Text("%d", Spec.InputPressed);
|
||||||
|
|
||||||
@@ -535,14 +552,28 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
|
|||||||
//------------------------
|
//------------------------
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextColored(TextColor, "AbilityTags");
|
ImGui::TextColored(TextColor, "Ability Tags");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
const bool SatisfyTagRequirements = Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent);
|
|
||||||
FCogAbilityHelper::RenderTagContainer(Ability->AbilityTags);
|
FCogAbilityHelper::RenderTagContainer(Ability->AbilityTags);
|
||||||
|
|
||||||
//---------------------------------------------
|
//------------------------
|
||||||
// TODO: find a way to display blocking tags
|
// BlockingTags
|
||||||
//---------------------------------------------
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Blocking Tags");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags))
|
||||||
|
{
|
||||||
|
FGameplayTagContainer AllBlockingTags;
|
||||||
|
AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags);
|
||||||
|
|
||||||
|
FGameplayTagContainer OwnedGameplayTags;
|
||||||
|
AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags);
|
||||||
|
AllBlockingTags.AppendTags(OwnedGameplayTags);
|
||||||
|
|
||||||
|
FCogAbilityHelper::RenderTagContainerHighlighted(*ActivationBlockedTags, AllBlockingTags, false, ImVec4(0.4f, 0.4f, 0.4f, 1.0f), FCogImguiHelper::ToImVec4(Config->BlockedColor));
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,6 +235,8 @@ void FCogAbilityWindow_OwnedTags::GetTagContainer(FGameplayTagContainer& TagCont
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// FCogAbilityWindow_BlockedTags
|
||||||
|
//------------------------------------------
|
||||||
void FCogAbilityWindow_BlockedTags::Initialize()
|
void FCogAbilityWindow_BlockedTags::Initialize()
|
||||||
{
|
{
|
||||||
Super::Initialize();
|
Super::Initialize();
|
||||||
|
|||||||
@@ -0,0 +1,414 @@
|
|||||||
|
#include "CogAbilityWindow_Tasks.h"
|
||||||
|
|
||||||
|
#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"
|
||||||
|
|
||||||
|
class UCogAbilityConfig_Tasks;
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::Initialize()
|
||||||
|
{
|
||||||
|
Super::Initialize();
|
||||||
|
|
||||||
|
bHasMenu = true;
|
||||||
|
bNoPadding = true;
|
||||||
|
|
||||||
|
Config = GetConfig<UCogAbilityConfig_Tasks>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::RenderHelp()
|
||||||
|
{
|
||||||
|
ImGui::Text(
|
||||||
|
"This window displays the gameplay tasks. ");
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::ResetConfig()
|
||||||
|
{
|
||||||
|
Super::ResetConfig();
|
||||||
|
|
||||||
|
Config->Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::RenderTick(float DetlaTime)
|
||||||
|
{
|
||||||
|
Super::RenderTick(DetlaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::RenderContent()
|
||||||
|
{
|
||||||
|
Super::RenderContent();
|
||||||
|
|
||||||
|
AActor* Selection = GetSelection();
|
||||||
|
if (Selection == nullptr)
|
||||||
|
{
|
||||||
|
ImGui::TextDisabled("Invalid selection");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true);
|
||||||
|
if (AbilitySystemComponent == nullptr)
|
||||||
|
{
|
||||||
|
ImGui::TextDisabled("Selection has no ability system component");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderTaskMenu(Selection);
|
||||||
|
|
||||||
|
RenderTasksTable(*AbilitySystemComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::RenderTaskMenu(AActor* Selection)
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenuBar())
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenu("Options"))
|
||||||
|
{
|
||||||
|
ImGui::Checkbox("Sort by Name", &Config->SortByName);
|
||||||
|
ImGui::Checkbox("Show Uninitialized", &Config->ShowUninitialized);
|
||||||
|
ImGui::Checkbox("Show Awaiting Activation", &Config->ShowAwaitingActivation);
|
||||||
|
ImGui::Checkbox("Show Active", &Config->ShowActive);
|
||||||
|
ImGui::Checkbox("Show Paused", &Config->ShowPaused);
|
||||||
|
ImGui::Checkbox("Show Finished", &Config->ShowFinished);
|
||||||
|
ImGui::Checkbox("Show Ticking", &Config->ShowTicking);
|
||||||
|
ImGui::Checkbox("Show Simulating", &Config->ShowSimulating);
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
ImGui::ColorEdit4("Uninitialized Color", (float*)&Config->UninitializedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||||
|
ImGui::ColorEdit4("Awaiting Activation Color", (float*)&Config->AwaitingActivationColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||||
|
ImGui::ColorEdit4("Active Color", (float*)&Config->ActiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||||
|
ImGui::ColorEdit4("Paused Color", (float*)&Config->PausedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||||
|
ImGui::ColorEdit4("Finished Color", (float*)&Config->FinishedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("Reset"))
|
||||||
|
{
|
||||||
|
ResetConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
FCogWindowWidgets::SearchBar(Filter);
|
||||||
|
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilitySystemComponent)
|
||||||
|
{
|
||||||
|
TArray<const UGameplayTask*> FilteredTasks;
|
||||||
|
FilteredTasks.Reserve(16);
|
||||||
|
|
||||||
|
const AActor* Selection = GetSelection();
|
||||||
|
|
||||||
|
for (FConstGameplayTaskIterator it = AbilitySystemComponent.GetKnownTaskIterator(); it; ++it)
|
||||||
|
{
|
||||||
|
const UGameplayTask* Task = Cast<const UGameplayTask>(*it);
|
||||||
|
if (Task == nullptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const EGameplayTaskState TaskState = Task->GetState();
|
||||||
|
|
||||||
|
if (Config->ShowUninitialized == false && TaskState == EGameplayTaskState::Uninitialized)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config->ShowAwaitingActivation == false && TaskState == EGameplayTaskState::AwaitingActivation)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config->ShowActive == false && TaskState == EGameplayTaskState::Active)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config->ShowPaused == false && TaskState == EGameplayTaskState::Paused)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config->ShowFinished == false && TaskState == EGameplayTaskState::Finished)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config->ShowTicking == false && Task->IsTickingTask())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config->ShowSimulating == false && Task->IsSimulating())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* TaskName = StringCast<ANSICHAR>(*Task->GetName()).Get();
|
||||||
|
bool PassFilter = Filter.PassFilter(TaskName);
|
||||||
|
|
||||||
|
if (PassFilter == false)
|
||||||
|
{
|
||||||
|
if (const UGameplayAbility* Ability = Cast<UGameplayAbility>(Task->GetTaskOwner()))
|
||||||
|
{
|
||||||
|
const char* AbilityName = StringCast<ANSICHAR>(*FCogAbilityHelper::CleanupName(Ability->GetName())).Get();
|
||||||
|
PassFilter = Filter.PassFilter(AbilityName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PassFilter == false)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FilteredTasks.Add(Task);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config->SortByName)
|
||||||
|
{
|
||||||
|
FilteredTasks.Sort([](const UGameplayTask& Lhs, const UGameplayTask& Rhs)
|
||||||
|
{
|
||||||
|
return Lhs.GetName().Compare(Rhs.GetName()) < 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginTable("Tasks", 4, ImGuiTableFlags_SizingFixedFit
|
||||||
|
| ImGuiTableFlags_Resizable
|
||||||
|
| ImGuiTableFlags_NoBordersInBodyUntilResize
|
||||||
|
| ImGuiTableFlags_ScrollY
|
||||||
|
| ImGuiTableFlags_RowBg
|
||||||
|
| ImGuiTableFlags_BordersV
|
||||||
|
| ImGuiTableFlags_Reorderable
|
||||||
|
| ImGuiTableFlags_Hideable))
|
||||||
|
{
|
||||||
|
ImGui::TableSetupScrollFreeze(0, 1);
|
||||||
|
ImGui::TableSetupColumn("State");
|
||||||
|
ImGui::TableSetupColumn("Task");
|
||||||
|
ImGui::TableSetupColumn("Owner");
|
||||||
|
ImGui::TableSetupColumn("Is Ticking");
|
||||||
|
ImGui::TableHeadersRow();
|
||||||
|
|
||||||
|
static int SelectedIndex = -1;
|
||||||
|
|
||||||
|
ImGuiListClipper Clipper;
|
||||||
|
Clipper.Begin(FilteredTasks.Num());
|
||||||
|
while (Clipper.Step())
|
||||||
|
{
|
||||||
|
for (int32 LineIndex = Clipper.DisplayStart; LineIndex < Clipper.DisplayEnd; LineIndex++)
|
||||||
|
{
|
||||||
|
const UGameplayTask* Task = FilteredTasks[LineIndex];
|
||||||
|
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::PushID(LineIndex);
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// State
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
RenderTaskState(Task);
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Name
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
|
const char* TaskName = StringCast<ANSICHAR>(*Task->GetName()).Get();
|
||||||
|
if (ImGui::Selectable(TaskName, SelectedIndex == LineIndex, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||||
|
{
|
||||||
|
SelectedIndex = LineIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Popup
|
||||||
|
//------------------------
|
||||||
|
if (ImGui::IsItemHovered())
|
||||||
|
{
|
||||||
|
FCogWindowWidgets::BeginTableTooltip();
|
||||||
|
RenderTaskInfo(Task);
|
||||||
|
FCogWindowWidgets::EndTableTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Owner
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
RenderTaskOwner(Task);
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// IsTicking
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
|
||||||
|
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Clipper.End();
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
|
||||||
|
{
|
||||||
|
if (Task == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginTable("Task", 2, ImGuiTableFlags_Borders))
|
||||||
|
{
|
||||||
|
constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||||
|
|
||||||
|
ImGui::TableSetupColumn("Property");
|
||||||
|
ImGui::TableSetupColumn("Value");
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Name
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Name");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text(StringCast<ANSICHAR>(*Task->GetName()).Get());
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Instance Name
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Instance Name");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text(StringCast<ANSICHAR>(*Task->GetInstanceName().ToString()).Get());
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Owner
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Ability");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
RenderTaskOwner(Task);
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// State
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "State");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
RenderTaskState(Task);
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Priority
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Priority");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%d", (int32)Task->GetPriority());
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// IsTicking
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Is Ticking");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// IsSimulated
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Is Simulated");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text(Task->IsSimulatedTask() ? "Yes" : "No");
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// IsSimulating
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Is Simulating");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text(Task->IsSimulating() ? "Yes" : "No");
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Debug
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextColored(TextColor, "Debug");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::PushTextWrapPos(FCogWindowWidgets::GetFontWidth() * 80);
|
||||||
|
ImGui::Text(StringCast<ANSICHAR>(*Task->GetDebugString()).Get());
|
||||||
|
ImGui::PopTextWrapPos();
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::RenderTaskOwner(const UGameplayTask* Task)
|
||||||
|
{
|
||||||
|
IGameplayTaskOwnerInterface* TaskOwner = Task->GetTaskOwner();
|
||||||
|
|
||||||
|
FString OwnerName;
|
||||||
|
if (const UGameplayAbility* Ability = Cast<UGameplayAbility>(TaskOwner))
|
||||||
|
{
|
||||||
|
OwnerName = FCogAbilityHelper::CleanupName(Ability->GetName());
|
||||||
|
}
|
||||||
|
else if (const UObject* Object = Cast<UObject>(TaskOwner))
|
||||||
|
{
|
||||||
|
OwnerName = GetNameSafe(Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Text(StringCast<ANSICHAR>(*OwnerName).Get());
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
void FCogAbilityWindow_Tasks::RenderTaskState(const UGameplayTask* Task)
|
||||||
|
{
|
||||||
|
switch (Task->GetState())
|
||||||
|
{
|
||||||
|
case EGameplayTaskState::Uninitialized:
|
||||||
|
FCogWindowWidgets::SmallButton("Uninitialized", FCogImguiHelper::ToImVec4(Config->UninitializedColor));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EGameplayTaskState::AwaitingActivation:
|
||||||
|
FCogWindowWidgets::SmallButton("Awaiting Activation", FCogImguiHelper::ToImVec4(Config->AwaitingActivationColor));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EGameplayTaskState::Active:
|
||||||
|
FCogWindowWidgets::SmallButton("Active", FCogImguiHelper::ToImVec4(Config->ActiveColor));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EGameplayTaskState::Paused:
|
||||||
|
FCogWindowWidgets::SmallButton("Paused", FCogImguiHelper::ToImVec4(Config->PausedColor));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EGameplayTaskState::Finished:
|
||||||
|
FCogWindowWidgets::SmallButton("Finished", FCogImguiHelper::ToImVec4(Config->FinishedColor));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,5 +15,8 @@ public:
|
|||||||
|
|
||||||
static FString CleanupName(FString Str);
|
static FString CleanupName(FString Str);
|
||||||
|
|
||||||
static void RenderTagContainer(const FGameplayTagContainer& Container);
|
static void RenderTagContainer(const FGameplayTagContainer& Container, const bool Inline = false, const ImVec4& Color = ImVec4(0.4f, 0.4f, 0.4f, 1.0f));
|
||||||
|
|
||||||
|
static void RenderTagContainerHighlighted(const FGameplayTagContainer& Container, const FGameplayTagContainer& TagsToHighlight, const bool Inline = false, const ImVec4& NormalColor = ImVec4(0.4f, 0.4f, 0.4f, 1.0f), const ImVec4& HighlightColor = ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "CogWindow.h"
|
||||||
|
#include "CogWindowConfig.h"
|
||||||
|
#include "CogAbilityWindow_Tasks.generated.h"
|
||||||
|
|
||||||
|
class UAbilitySystemComponent;
|
||||||
|
class UCogAbilityConfig_Tasks;
|
||||||
|
class UCogAbilityDataAsset;
|
||||||
|
class UGameplayTask;
|
||||||
|
|
||||||
|
class COGABILITY_API FCogAbilityWindow_Tasks : public FCogWindow
|
||||||
|
{
|
||||||
|
typedef FCogWindow Super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void Initialize() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void ResetConfig() override;
|
||||||
|
|
||||||
|
virtual void RenderHelp() override;
|
||||||
|
|
||||||
|
virtual void RenderTick(float DetlaTime) override;
|
||||||
|
|
||||||
|
virtual void RenderContent() override;
|
||||||
|
|
||||||
|
virtual void RenderTaskMenu(AActor* Selection);
|
||||||
|
|
||||||
|
virtual void RenderTasksTable(UAbilitySystemComponent& AbilitySystemComponent);
|
||||||
|
|
||||||
|
virtual void RenderTaskInfo(const UGameplayTask* Task);
|
||||||
|
|
||||||
|
virtual void RenderTaskOwner(const UGameplayTask* Task);
|
||||||
|
|
||||||
|
virtual void RenderTaskState(const UGameplayTask* Task);
|
||||||
|
|
||||||
|
TObjectPtr<UCogAbilityConfig_Tasks> Config = nullptr;
|
||||||
|
|
||||||
|
ImGuiTextFilter Filter;
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
|
UCLASS(Config = Cog)
|
||||||
|
class UCogAbilityConfig_Tasks : public UCogWindowConfig
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool SortByName = false;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool ShowTicking = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool ShowSimulating = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool ShowUninitialized = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool ShowAwaitingActivation = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool ShowActive = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool ShowPaused = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool ShowFinished = true;
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FVector4f UninitializedColor = FVector4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FVector4f AwaitingActivationColor = FVector4f(0.6f, 0.6f, 0.6f, 1.0f);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FVector4f ActiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FVector4f PausedColor = FVector4f(0.3f, 0.3f, 0.3f, 1.0f);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
FVector4f FinishedColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f);
|
||||||
|
|
||||||
|
|
||||||
|
virtual void Reset() override
|
||||||
|
{
|
||||||
|
Super::Reset();
|
||||||
|
|
||||||
|
SortByName = false;
|
||||||
|
ShowTicking = true;
|
||||||
|
ShowActive = true;
|
||||||
|
ShowPaused = true;
|
||||||
|
ShowFinished = true;
|
||||||
|
ActiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f);
|
||||||
|
PausedColor = FVector4f(0.3f, 0.3f, 0.3f, 1.0f);
|
||||||
|
FinishedColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "CogAbilityWindow_Effects.h"
|
#include "CogAbilityWindow_Effects.h"
|
||||||
#include "CogAbilityWindow_Pools.h"
|
#include "CogAbilityWindow_Pools.h"
|
||||||
#include "CogAbilityWindow_Tags.h"
|
#include "CogAbilityWindow_Tags.h"
|
||||||
|
#include "CogAbilityWindow_Tasks.h"
|
||||||
#include "CogAbilityWindow_Tweaks.h"
|
#include "CogAbilityWindow_Tweaks.h"
|
||||||
#include "CogAIWindow_BehaviorTree.h"
|
#include "CogAIWindow_BehaviorTree.h"
|
||||||
#include "CogAIWindow_Blackboard.h"
|
#include "CogAIWindow_Blackboard.h"
|
||||||
@@ -107,6 +108,8 @@ void Cog::AddAllWindows(UCogWindowManager& CogWindowManager)
|
|||||||
|
|
||||||
CogWindowManager.AddWindow<FCogAbilityWindow_OwnedTags>("Gameplay.Owned Tags");
|
CogWindowManager.AddWindow<FCogAbilityWindow_OwnedTags>("Gameplay.Owned Tags");
|
||||||
|
|
||||||
|
CogWindowManager.AddWindow<FCogAbilityWindow_Tasks>("Gameplay.Tasks");
|
||||||
|
|
||||||
CogWindowManager.AddWindow<FCogAbilityWindow_Tweaks>("Gameplay.Tweaks");
|
CogWindowManager.AddWindow<FCogAbilityWindow_Tweaks>("Gameplay.Tweaks");
|
||||||
|
|
||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user