mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-03 14:18:46 +00:00
Merge remote-tracking branch 'arnaud-jamin/main'
# Conflicts: # Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp # Plugins/Cog/Source/CogDebug/Private/CogDebugLog.cpp # Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp # Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp # Plugins/Cog/Source/ThirdParty/ImGui/imconfig.h # Plugins/Cog/Source/ThirdParty/ImGui/imgui.cpp # Plugins/Cog/Source/ThirdParty/ImGui/imgui.h # Plugins/Cog/Source/ThirdParty/ImGui/imgui_demo.cpp # Plugins/Cog/Source/ThirdParty/ImGui/imgui_draw.cpp # Plugins/Cog/Source/ThirdParty/ImGui/imgui_internal.h # Plugins/Cog/Source/ThirdParty/ImGui/imgui_tables.cpp # Plugins/Cog/Source/ThirdParty/ImGui/imgui_widgets.cpp # Plugins/Cog/Source/ThirdParty/ImGui/imstb_textedit.h # Plugins/Cog/Source/ThirdParty/ImGui/imstb_truetype.h # Plugins/Cog/Source/ThirdParty/ImPlot/README.md # Plugins/Cog/Source/ThirdParty/ImPlot/TODO.md # Plugins/Cog/Source/ThirdParty/ImPlot/implot.cpp # Plugins/Cog/Source/ThirdParty/ImPlot/implot.h # Plugins/Cog/Source/ThirdParty/ImPlot/implot_demo.cpp # Plugins/Cog/Source/ThirdParty/ImPlot/implot_internal.h # Plugins/Cog/Source/ThirdParty/ImPlot/implot_items.cpp # Plugins/CogInput/Source/CogInput/Public/CogInputDataAsset.h
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using UnrealBuildTool;
|
||||
using UnrealBuildTool.Rules;
|
||||
|
||||
public class CogAbility : ModuleRules
|
||||
{
|
||||
@@ -26,10 +25,11 @@ public class CogAbility : ModuleRules
|
||||
"CogImgui",
|
||||
"CogCommon",
|
||||
"CogDebug",
|
||||
"CogEngine",
|
||||
"CogWindow",
|
||||
"GameplayAbilities",
|
||||
"GameplayTags",
|
||||
"NetCore",
|
||||
"NetCore",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
#include "CogAbilityCheat_Execution_ApplyEffect.h"
|
||||
|
||||
#include "CogAbilityDataAsset.h"
|
||||
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "CogAbilityConfig_Alignment.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindow.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityCheat_Execution_ApplyEffect::Execute_Implementation(const AActor* Instigator, const TArray<AActor*>& Targets) const
|
||||
{
|
||||
UAbilitySystemComponent* DefaultInstigatorAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Instigator, true);
|
||||
|
||||
for (AActor* Target : Targets)
|
||||
{
|
||||
UAbilitySystemComponent* TargetAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Target, true);
|
||||
if (TargetAbilitySystem == nullptr)
|
||||
{
|
||||
UE_LOG(LogCogImGui, Warning, TEXT("ACogAbilityReplicator::Server_ApplyCheat_Implementation | Target:%s | Invalid Target AbilitySystem"), *GetNameSafe(Target));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (TargetAbilitySystem->GetGameplayEffectCount(Effect, nullptr) > 0)
|
||||
{
|
||||
TargetAbilitySystem->RemoveActiveGameplayEffectBySourceEffect(Effect, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------------------------------------------------
|
||||
// When executing a cheat directly on the game server, there is not an obvious
|
||||
// local player to use as the instigator. Instead, we use the target ability system.
|
||||
//-----------------------------------------------------------------------------------
|
||||
UAbilitySystemComponent* InstigatorAbilitySystem = (DefaultInstigatorAbilitySystem != nullptr) ? DefaultInstigatorAbilitySystem : TargetAbilitySystem;
|
||||
|
||||
FGameplayEffectContextHandle ContextHandle = InstigatorAbilitySystem->MakeEffectContext();
|
||||
ContextHandle.AddSourceObject(InstigatorAbilitySystem);
|
||||
FGameplayEffectSpecHandle SpecHandle = InstigatorAbilitySystem->MakeOutgoingSpec(Effect, 1, ContextHandle);
|
||||
|
||||
if (const FGameplayEffectSpec* EffectSpec = SpecHandle.Data.Get())
|
||||
{
|
||||
FHitResult HitResult;
|
||||
HitResult.HitObjectHandle = FActorInstanceHandle(Target);
|
||||
HitResult.Normal = FVector::ForwardVector;
|
||||
HitResult.ImpactNormal = FVector::ForwardVector;
|
||||
HitResult.Location = Target->GetActorLocation();
|
||||
HitResult.ImpactPoint = Target->GetActorLocation();
|
||||
HitResult.PhysMaterial = nullptr;
|
||||
ContextHandle.AddHitResult(HitResult, true);
|
||||
|
||||
InstigatorAbilitySystem->ApplyGameplayEffectSpecToTarget(*EffectSpec, TargetAbilitySystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ECogEngineCheat_ActiveState UCogAbilityCheat_Execution_ApplyEffect::IsActiveOnTargets_Implementation(const TArray<AActor*>& Targets) const
|
||||
{
|
||||
if (Effect == nullptr)
|
||||
{
|
||||
return ECogEngineCheat_ActiveState::Inactive;
|
||||
}
|
||||
|
||||
int32 NumWithEffect = 0;
|
||||
for (const AActor* Target : Targets)
|
||||
{
|
||||
const UAbilitySystemComponent* AbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Target, true);
|
||||
if (AbilitySystem == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const int32 Count = AbilitySystem->GetGameplayEffectCount(Effect, nullptr);
|
||||
if (Count > 0)
|
||||
{
|
||||
NumWithEffect++;
|
||||
}
|
||||
}
|
||||
|
||||
if (NumWithEffect == 0)
|
||||
{
|
||||
return ECogEngineCheat_ActiveState::Inactive;
|
||||
}
|
||||
|
||||
if (NumWithEffect == Targets.Num())
|
||||
{
|
||||
return ECogEngineCheat_ActiveState::Active;
|
||||
}
|
||||
|
||||
return ECogEngineCheat_ActiveState::Partial;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool UCogAbilityCheat_Execution_ApplyEffect::GetColor(const FCogWindow& InCallingWindow, FLinearColor& OutColor) const
|
||||
{
|
||||
if (Effect == nullptr)
|
||||
{ return false; }
|
||||
|
||||
const UGameplayEffect* GameplayEffect = Effect->GetDefaultObject<UGameplayEffect>();
|
||||
if (GameplayEffect == nullptr)
|
||||
{ return false; }
|
||||
|
||||
const UCogAbilityConfig_Alignment* Config = InCallingWindow.GetConfig<UCogAbilityConfig_Alignment>();
|
||||
const UCogAbilityDataAsset* Asset = InCallingWindow.GetAsset<UCogAbilityDataAsset>();
|
||||
|
||||
OutColor = Config->GetEffectColor(Asset, *GameplayEffect);
|
||||
return true;
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowHelper.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "Engine/World.h"
|
||||
@@ -30,8 +31,10 @@ ACogAbilityReplicator* ACogAbilityReplicator::GetFirstReplicator(const UWorld& W
|
||||
{
|
||||
for (TActorIterator<ACogAbilityReplicator> It(&World, StaticClass()); It; ++It)
|
||||
{
|
||||
ACogAbilityReplicator* Replicator = *It;
|
||||
return Replicator;
|
||||
if (ACogAbilityReplicator* Replicator = *It)
|
||||
{
|
||||
return Replicator;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -95,17 +98,14 @@ void ACogAbilityReplicator::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void ACogAbilityReplicator::Server_ApplyCheat_Implementation(const AActor* CheatInstigator, const TArray<AActor*>& Targets, const FCogAbilityCheat& Cheat) const
|
||||
{
|
||||
UAbilitySystemComponent* InstigatorAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(CheatInstigator, true);
|
||||
if (InstigatorAbilitySystem == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
UAbilitySystemComponent* DefaultInstigatorAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(CheatInstigator, true);
|
||||
|
||||
for (AActor* Target : Targets)
|
||||
{
|
||||
UAbilitySystemComponent* TargetAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Target, true);
|
||||
if (TargetAbilitySystem == nullptr)
|
||||
{
|
||||
UE_LOG(LogCogImGui, Warning, TEXT("ACogAbilityReplicator::Server_ApplyCheat_Implementation | Target:%s | Invalid Target AbilitySystem"), *GetNameSafe(Target));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -115,6 +115,12 @@ void ACogAbilityReplicator::Server_ApplyCheat_Implementation(const AActor* Cheat
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------------------------------------------------
|
||||
// When executing a cheat directly on the game server, there is not an obvious
|
||||
// local player to use as the instigator. Instead, we use the target ability system.
|
||||
//-----------------------------------------------------------------------------------
|
||||
UAbilitySystemComponent* InstigatorAbilitySystem = (DefaultInstigatorAbilitySystem != nullptr) ? DefaultInstigatorAbilitySystem : TargetAbilitySystem;
|
||||
|
||||
FGameplayEffectContextHandle ContextHandle = InstigatorAbilitySystem->MakeEffectContext();
|
||||
ContextHandle.AddSourceObject(InstigatorAbilitySystem);
|
||||
FGameplayEffectSpecHandle SpecHandle = InstigatorAbilitySystem->MakeOutgoingSpec(Cheat.Effect, 1, ContextHandle);
|
||||
|
||||
@@ -155,15 +155,13 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenu(AActor* Selection)
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
RenderAbilitiesMenuFilters();
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Checkbox("Sort by Name", &Config->SortByName);
|
||||
|
||||
RenderAbilitiesMenuColorSettings();
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("Reset"))
|
||||
if (ImGui::MenuItem("Reset Settings"))
|
||||
{
|
||||
ResetConfig();
|
||||
}
|
||||
@@ -171,6 +169,12 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenu(AActor* Selection)
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Filters"))
|
||||
{
|
||||
RenderAbilitiesMenuFilters();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SearchBar(Filter);
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
@@ -180,11 +184,10 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenu(AActor* Selection)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Abilities::RenderAbilitiesMenuFilters()
|
||||
{
|
||||
ImGui::Checkbox("Sort by Name", &Config->SortByName);
|
||||
ImGui::Checkbox("Show Active", &Config->ShowActive);
|
||||
ImGui::Checkbox("Show Inactive", &Config->ShowInactive);
|
||||
ImGui::Checkbox("Show Pressed", &Config->ShowPressed);
|
||||
ImGui::Checkbox("Show Blocked", &Config->ShowBlocked);
|
||||
ImGui::Checkbox("Active", &Config->ShowActive);
|
||||
ImGui::Checkbox("Inactive", &Config->ShowInactive);
|
||||
ImGui::Checkbox("Pressed", &Config->ShowPressed);
|
||||
ImGui::Checkbox("Blocked", &Config->ShowBlocked);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -201,13 +204,13 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenuColorSettings()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Abilities::RenderAbilityActivation(FGameplayAbilitySpec& Spec)
|
||||
{
|
||||
FCogWindowWidgets::PushStyleCompact();
|
||||
bool IsActive = Spec.IsActive();
|
||||
if (ImGui::Checkbox("##Activation", &IsActive))
|
||||
{
|
||||
AbilityHandleToActivate = Spec.Handle;
|
||||
}
|
||||
FCogWindowWidgets::PopStyleCompact();
|
||||
FCogWindowWidgets::PushStyleCompact();
|
||||
bool IsActive = Spec.IsActive();
|
||||
if (ImGui::Checkbox("##Activation", &IsActive))
|
||||
{
|
||||
AbilityHandleToActivate = Spec.Handle;
|
||||
}
|
||||
FCogWindowWidgets::PopStyleCompact();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -216,15 +219,15 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityName(UAbilitySystem
|
||||
const ImVec4 Color = GetAbilityColor(AbilitySystemComponent, Spec);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, Color);
|
||||
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
SelectedIndex = Index;
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
SelectedIndex = Index;
|
||||
|
||||
if (ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
OpenAbility(Spec.Handle);
|
||||
}
|
||||
}
|
||||
if (ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
OpenAbilityDetails(Spec.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(1);
|
||||
}
|
||||
@@ -232,26 +235,26 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityName(UAbilitySystem
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityBlocking(UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility* Ability)
|
||||
{
|
||||
if (Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false)
|
||||
{
|
||||
FGameplayTagContainer OwnedGameplayTags;
|
||||
AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags);
|
||||
if (Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false)
|
||||
{
|
||||
FGameplayTagContainer OwnedGameplayTags;
|
||||
AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags);
|
||||
|
||||
if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags))
|
||||
{
|
||||
FGameplayTagContainer AllBlockingTags;
|
||||
AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags);
|
||||
AllBlockingTags.AppendTags(OwnedGameplayTags);
|
||||
if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags))
|
||||
{
|
||||
FGameplayTagContainer AllBlockingTags;
|
||||
AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags);
|
||||
AllBlockingTags.AppendTags(OwnedGameplayTags);
|
||||
|
||||
FCogAbilityHelper::RenderTagContainer(*ActivationBlockedTags, AllBlockingTags, false, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor));
|
||||
}
|
||||
FCogAbilityHelper::RenderTagContainer(*ActivationBlockedTags, AllBlockingTags, false, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor));
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (const FGameplayTagContainer* ActivationRequiredTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationRequiredTags))
|
||||
{
|
||||
FCogAbilityHelper::RenderTagContainer(*ActivationRequiredTags, OwnedGameplayTags, true, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor));
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (const FGameplayTagContainer* ActivationRequiredTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationRequiredTags))
|
||||
{
|
||||
FCogAbilityHelper::RenderTagContainer(*ActivationRequiredTags, OwnedGameplayTags, true, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -259,7 +262,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
|
||||
{
|
||||
TArray<FGameplayAbilitySpec>& Abilities = AbilitySystemComponent.GetActivatableAbilities();
|
||||
|
||||
TArray<FGameplayAbilitySpec> FitleredAbilities;
|
||||
TArray<FGameplayAbilitySpec> FilteredAbilities;
|
||||
|
||||
for (FGameplayAbilitySpec& Spec : Abilities)
|
||||
{
|
||||
@@ -271,8 +274,8 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
|
||||
|
||||
if (ShouldShowAbility(AbilitySystemComponent, Spec, Ability) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto AbilityName = StringCast<ANSICHAR>(*GetAbilityName(Ability));
|
||||
if (Filter.PassFilter(AbilityName.Get()) == false)
|
||||
@@ -280,12 +283,12 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
|
||||
continue;
|
||||
}
|
||||
|
||||
FitleredAbilities.Add(Spec);
|
||||
FilteredAbilities.Add(Spec);
|
||||
}
|
||||
|
||||
if (Config->SortByName)
|
||||
{
|
||||
FitleredAbilities.Sort([](const FGameplayAbilitySpec& Lhs, const FGameplayAbilitySpec& Rhs)
|
||||
FilteredAbilities.Sort([](const FGameplayAbilitySpec& Lhs, const FGameplayAbilitySpec& Rhs)
|
||||
{
|
||||
return Lhs.Ability.GetName().Compare(Rhs.Ability.GetName()) < 0;
|
||||
});
|
||||
@@ -296,7 +299,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent&
|
||||
static int SelectedIndex = -1;
|
||||
int Index = 0;
|
||||
|
||||
for (FGameplayAbilitySpec& Spec : FitleredAbilities)
|
||||
for (FGameplayAbilitySpec& Spec : FilteredAbilities)
|
||||
{
|
||||
UGameplayAbility* Ability = Spec.GetPrimaryInstance();
|
||||
if (Ability == nullptr)
|
||||
@@ -357,7 +360,7 @@ bool FCogAbilityWindow_Abilities::RenderAbilitiesTableHeader(UAbilitySystemCompo
|
||||
| ImGuiTableFlags_Reorderable
|
||||
| ImGuiTableFlags_Hideable))
|
||||
{
|
||||
ImGui::TableSetupColumn("##Activation", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("##ActivationCol", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupScrollFreeze(0, 1);
|
||||
ImGui::TableSetupColumn("Ability");
|
||||
ImGui::TableSetupColumn("Level");
|
||||
@@ -390,11 +393,10 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableRow(UAbilitySystemComponen
|
||||
//------------------------
|
||||
// Popup
|
||||
//------------------------
|
||||
if (ImGui::IsItemHovered())
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
FCogWindowWidgets::BeginTableTooltip();
|
||||
RenderAbilityInfo(AbilitySystemComponent, Spec);
|
||||
FCogWindowWidgets::EndTableTooltip();
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
@@ -475,36 +477,45 @@ void FCogAbilityWindow_Abilities::RenderAbilityContextMenu(UAbilitySystemCompone
|
||||
if (ImGui::BeginPopupContextItem())
|
||||
{
|
||||
bool bOpen = OpenedAbilities.Contains(Spec.Handle);
|
||||
if (ImGui::Checkbox("Open", &bOpen))
|
||||
if (ImGui::Checkbox("Open Details", &bOpen))
|
||||
{
|
||||
if (bOpen)
|
||||
{
|
||||
OpenAbility(Spec.Handle);
|
||||
OpenAbilityDetails(Spec.Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseAbility(Spec.Handle);
|
||||
CloseAbilityDetails(Spec.Handle);
|
||||
}
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Remove"))
|
||||
const ImVec2 ButtonsSize = ImVec2(ImGui::GetFontSize() * 10, 0);
|
||||
|
||||
if (ImGui::Button("Cancel", ButtonsSize))
|
||||
{
|
||||
AbilitySystemComponent.CancelAbilityHandle(Spec.Handle);
|
||||
}
|
||||
|
||||
if (ImGui::Button("Remove", ButtonsSize))
|
||||
{
|
||||
AbilityHandleToRemove = Spec.Handle;
|
||||
}
|
||||
|
||||
FCogWindowWidgets::OpenObjectAssetButton(Spec.Ability, ButtonsSize);
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Abilities::OpenAbility(const FGameplayAbilitySpecHandle& Handle)
|
||||
void FCogAbilityWindow_Abilities::OpenAbilityDetails(const FGameplayAbilitySpecHandle& Handle)
|
||||
{
|
||||
OpenedAbilities.AddUnique(Handle);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Abilities::CloseAbility(const FGameplayAbilitySpecHandle& Handle)
|
||||
void FCogAbilityWindow_Abilities::CloseAbilityDetails(const FGameplayAbilitySpecHandle& Handle)
|
||||
{
|
||||
OpenedAbilities.Remove(Handle);
|
||||
}
|
||||
@@ -535,9 +546,9 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
|
||||
return;
|
||||
}
|
||||
|
||||
if (ImGui::BeginTable("Ability", 2, ImGuiTableFlags_Borders))
|
||||
if (ImGui::BeginTable("Ability", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable))
|
||||
{
|
||||
constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
ImGui::TableSetupColumn("Property");
|
||||
ImGui::TableSetupColumn("Value");
|
||||
@@ -631,7 +642,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Ability Tags");
|
||||
ImGui::TableNextColumn();
|
||||
FCogAbilityHelper::RenderTagContainer(Ability->AbilityTags);
|
||||
FCogAbilityHelper::RenderTagContainer(Ability->GetAssetTags());
|
||||
|
||||
//------------------------
|
||||
// RequiredTags
|
||||
@@ -665,8 +676,8 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
|
||||
}
|
||||
|
||||
//------------------------
|
||||
// Additional info
|
||||
//------------------------
|
||||
// Additional info
|
||||
//------------------------
|
||||
RenderAbilityAdditionalInfo(AbilitySystemComponent, Spec, *Ability, TextColor);
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "CogAbilityWindow_Abilities.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::Initialize()
|
||||
@@ -41,6 +43,32 @@ void FCogAbilityWindow_Attributes::ResetConfig()
|
||||
Config->Reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::RenderTick(float DeltaTime)
|
||||
{
|
||||
Super::RenderTick(DeltaTime);
|
||||
|
||||
RenderOpenAttributes();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::FormatAttributeSetName(FString& AttributeSetName)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::RenderContent()
|
||||
{
|
||||
@@ -61,10 +89,17 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
ImGui::Checkbox("Group by Attribute Set", &Config->GroupByAttributeSet);
|
||||
ImGui::Checkbox("Group by Category", &Config->GroupByCategory);
|
||||
ImGui::Checkbox("Show Only Modified", &Config->ShowOnlyModified);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogWindowWidgets::InputText("Attribute Set Prefixes", Config->AttributeSetPrefixes);
|
||||
ImGui::SetItemTooltip("Prefixes to remove from the attribute set name. Separate multiple prefixes with the semicolon character ';'");
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::ColorEdit4("Positive Color", (float*)&AlignmentConfig->PositiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Negative Color", (float*)&AlignmentConfig->NegativeColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Neutral Color", (float*)&AlignmentConfig->NeutralColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("AttributeSet Color", (float*)&Config->AttributeSetColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Category Color", (float*)&Config->CategoryColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Reset"))
|
||||
{
|
||||
@@ -78,10 +113,12 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
bool bGroupByAttributeSetValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByAttributeSet;
|
||||
bool bGroupByCategoryValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByCategory;
|
||||
const bool bGroupByAttributeSetValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByAttributeSet;
|
||||
const bool bGroupByCategoryValue = Filter.IsActive() == false && Config->ShowOnlyModified == false && Config->GroupByCategory;
|
||||
const float bShowGroup = bGroupByAttributeSetValue | bGroupByCategoryValue;
|
||||
const float FirstColWidth = ((int32)bGroupByAttributeSetValue + (int32)bGroupByCategoryValue) * ImGui::GetFontSize() * 2;
|
||||
|
||||
if (ImGui::BeginTable("Attributes", 3, ImGuiTableFlags_SizingFixedFit
|
||||
if (ImGui::BeginTable("Attributes", 5, ImGuiTableFlags_SizingFixedFit
|
||||
| ImGuiTableFlags_Resizable
|
||||
| ImGuiTableFlags_NoBordersInBodyUntilResize
|
||||
| ImGuiTableFlags_ScrollY
|
||||
@@ -91,6 +128,8 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
| ImGuiTableFlags_Hideable))
|
||||
{
|
||||
ImGui::TableSetupScrollFreeze(0, 1);
|
||||
ImGui::TableSetupColumn("-", ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_NoHeaderLabel | ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_WidthFixed, FirstColWidth);
|
||||
ImGui::TableSetupColumn("Set", bShowGroup ? ImGuiTableColumnFlags_DefaultHide : ImGuiTableColumnFlags_None);
|
||||
ImGui::TableSetupColumn("Attribute");
|
||||
ImGui::TableSetupColumn("Base");
|
||||
ImGui::TableSetupColumn("Current");
|
||||
@@ -102,23 +141,36 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
//------------------------------------------------------------------------------------------
|
||||
// Draw all the attribute sets
|
||||
//------------------------------------------------------------------------------------------
|
||||
for (const UAttributeSet* Set : AbilitySystemComponent->GetSpawnedAttributes())
|
||||
for (const UAttributeSet* AttributeSet : AbilitySystemComponent->GetSpawnedAttributes())
|
||||
{
|
||||
if (AttributeSet == nullptr)
|
||||
{ continue; }
|
||||
|
||||
ImGui::PushID(TCHAR_TO_ANSI(*AttributeSet->GetName()));
|
||||
|
||||
FString AttributeSetName = AttributeSet->GetName();
|
||||
FormatAttributeSetName(AttributeSetName);
|
||||
const auto AttributeSetNameStr = StringCast<ANSICHAR>(*AttributeSetName);
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
// Add an tree node categories are shown
|
||||
// Add a tree node with the name of the attribute set if grouping by attribute set
|
||||
//------------------------------------------------------------------------------------------
|
||||
bool bOpenAttributeSet = true;
|
||||
if (bGroupByAttributeSetValue)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
bOpenAttributeSet = ImGui::TreeNodeEx(TCHAR_TO_ANSI(*Set->GetName()), ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Config->AttributeSetColor));
|
||||
bOpenAttributeSet = ImGui::TreeNodeEx(AttributeSetNameStr.Get(), ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanAllColumns | ImGuiTreeNodeFlags_LabelSpanAllColumns);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
}
|
||||
|
||||
if (bOpenAttributeSet)
|
||||
{
|
||||
TArray<FGameplayAttribute> AllAttributes;
|
||||
for (TFieldIterator<FProperty> It(Set->GetClass()); It; ++It)
|
||||
for (TFieldIterator<FProperty> It(AttributeSet->GetClass()); It; ++It)
|
||||
{
|
||||
FGameplayAttribute Attribute = *It;
|
||||
if (Attribute.IsValid())
|
||||
@@ -176,7 +228,9 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
bOpenCategory = ImGui::TreeNodeEx(TCHAR_TO_ANSI(*It.Key), ImGuiTreeNodeFlags_SpanFullWidth);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Config->CategoryColor));
|
||||
bOpenCategory = ImGui::TreeNodeEx(TCHAR_TO_ANSI(*It.Key), ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanAllColumns | ImGuiTreeNodeFlags_LabelSpanAllColumns);
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
if (bOpenCategory)
|
||||
@@ -201,51 +255,66 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
for (const FGameplayAttribute& Attribute : AttributesInCategory)
|
||||
{
|
||||
if (!Attribute.IsValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
{ continue; }
|
||||
|
||||
const auto AttributeName = StringCast<ANSICHAR>(*Attribute.GetName());
|
||||
const auto AttributeNameStr = StringCast<ANSICHAR>(*Attribute.GetName());
|
||||
|
||||
if (Filter.PassFilter(AttributeName.Get()) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Filter.PassFilter(AttributeNameStr.Get()) == false)
|
||||
{ continue; }
|
||||
|
||||
const float BaseValue = AbilitySystemComponent->GetNumericAttributeBase(Attribute);
|
||||
const float CurrentValue = AbilitySystemComponent->GetNumericAttribute(Attribute);
|
||||
|
||||
if (Config->ShowOnlyModified && FMath::IsNearlyEqual(CurrentValue, BaseValue))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
{ continue; }
|
||||
|
||||
ImGui::PushID(AttributeNameStr.Get());
|
||||
|
||||
ImGui::TableNextRow();
|
||||
|
||||
//------------------------
|
||||
// Selectable
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable("", Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
Selected = Index;
|
||||
|
||||
if (ImGui::IsMouseDoubleClicked(0))
|
||||
{
|
||||
OpenAttributeDetails(Attribute);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------
|
||||
// Popup
|
||||
//------------------------
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
RenderAttributeDetails(*AbilitySystemComponent, AttributeSetNameStr.Get(), Attribute, true);
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
// ContextMenu
|
||||
//------------------------
|
||||
RenderAttributeContextMenu(*AbilitySystemComponent, Attribute, Index);
|
||||
|
||||
const ImVec4 Color = FCogImguiHelper::ToImVec4(AlignmentConfig->GetAttributeColor(*AbilitySystemComponent, Attribute));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, Color);
|
||||
|
||||
//------------------------
|
||||
// Name
|
||||
// Attribute Set
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Selectable(AttributeName.Get(), Selected == Index, ImGuiSelectableFlags_SpanAllColumns))
|
||||
{
|
||||
Selected = Index;
|
||||
}
|
||||
ImGui::PopStyleColor(1);
|
||||
ImGui::Text("%s", AttributeSetNameStr.Get());
|
||||
|
||||
//------------------------
|
||||
// Popup
|
||||
// Attribute Name
|
||||
//------------------------
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
FCogWindowWidgets::BeginTableTooltip();
|
||||
DrawAttributeInfo(*AbilitySystemComponent, Attribute);
|
||||
FCogWindowWidgets::EndTableTooltip();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", AttributeNameStr.Get());
|
||||
ImGui::PopStyleColor(1);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, Color);
|
||||
|
||||
@@ -263,6 +332,8 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
|
||||
ImGui::PopStyleColor(1);
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
@@ -274,10 +345,15 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
}
|
||||
}
|
||||
|
||||
if (bOpenAttributeSet && bGroupByAttributeSetValue)
|
||||
if (bGroupByAttributeSetValue)
|
||||
{
|
||||
ImGui::TreePop();
|
||||
if (bOpenAttributeSet)
|
||||
{
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
@@ -285,17 +361,34 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute)
|
||||
void FCogAbilityWindow_Attributes::RenderAttributeDetails(const UAbilitySystemComponent& AbilitySystemComponent, const char* AttributeSetName, const FGameplayAttribute& Attribute, bool IsForTooltip)
|
||||
{
|
||||
if (ImGui::BeginTable("Attribute", 2, ImGuiTableFlags_Borders))
|
||||
ImGuiTableFlags TableFlags = IsForTooltip ? ImGuiTableFlags_Borders
|
||||
: ImGuiTableFlags_Borders | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_Resizable;
|
||||
|
||||
const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute);
|
||||
const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute);
|
||||
|
||||
if (ImGui::BeginTable("Details", 2, TableFlags))
|
||||
{
|
||||
const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
ImGui::TableSetupColumn("Property");
|
||||
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute);
|
||||
const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute);
|
||||
if (IsForTooltip == false)
|
||||
{
|
||||
ImGui::TableHeadersRow();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
// Attribute Set
|
||||
//------------------------
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Attribute Set");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", AttributeSetName);
|
||||
|
||||
//------------------------
|
||||
// Name
|
||||
@@ -326,38 +419,197 @@ void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone
|
||||
ImGui::Text("%0.2f", CurrentValue);
|
||||
ImGui::PopStyleColor(1);
|
||||
|
||||
//------------------------
|
||||
// Modifiers
|
||||
//------------------------
|
||||
FGameplayEffectQuery Query;
|
||||
for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent.GetActiveEffects(Query))
|
||||
{
|
||||
const FActiveGameplayEffect* ActiveEffect = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle);
|
||||
if (ActiveEffect == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < ActiveEffect->Spec.Modifiers.Num(); ++i)
|
||||
{
|
||||
const FModifierSpec& ModSpec = ActiveEffect->Spec.Modifiers[i];
|
||||
const FGameplayModifierInfo& ModInfo = ActiveEffect->Spec.Def->Modifiers[i];
|
||||
|
||||
if (ModInfo.Attribute == Attribute)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Effect");
|
||||
ImGui::TextColored(TextColor, "Operation");
|
||||
ImGui::TextColored(TextColor, "Magnitude");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", TCHAR_TO_ANSI(*FCogAbilityHelper::CleanupName(GetNameSafe(ActiveEffect->Spec.Def))));
|
||||
ImGui::Text("%s", TCHAR_TO_ANSI(*EGameplayModOpToString(ModInfo.ModifierOp)));
|
||||
ImGui::TextColored(FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectModifierColor(ModSpec, ModInfo, BaseValue)), "%0.2f", ModSpec.GetEvaluatedMagnitude());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
// Modifiers
|
||||
//------------------------
|
||||
int32 ModifierIndex = 1;
|
||||
|
||||
const FGameplayEffectQuery Query;
|
||||
for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent.GetActiveEffects(Query))
|
||||
{
|
||||
const FActiveGameplayEffect* ActiveEffect = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle);
|
||||
if (ActiveEffect == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < ActiveEffect->Spec.Modifiers.Num(); ++i)
|
||||
{
|
||||
const FModifierSpec& ModSpec = ActiveEffect->Spec.Modifiers[i];
|
||||
const FGameplayModifierInfo& ModInfo = ActiveEffect->Spec.Def->Modifiers[i];
|
||||
|
||||
if (ModInfo.Attribute == Attribute)
|
||||
{
|
||||
char Buffer[128];
|
||||
ImFormatString(Buffer, IM_ARRAYSIZE(Buffer), "Modifier %d", ModifierIndex);
|
||||
|
||||
if (FCogWindowWidgets::DarkCollapsingHeader(Buffer, ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
if (ImGui::BeginTable("Details", 2, TableFlags))
|
||||
{
|
||||
constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
ImGui::TableSetupColumn("Property");
|
||||
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Effect");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", TCHAR_TO_ANSI(*FCogAbilityHelper::CleanupName(GetNameSafe(ActiveEffect->Spec.Def))));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Operation");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", TCHAR_TO_ANSI(*EGameplayModOpToString(ModInfo.ModifierOp)));
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Magnitude");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectModifierColor(ModSpec, ModInfo, BaseValue)), "%0.2f", ModSpec.GetEvaluatedMagnitude());
|
||||
|
||||
if (ModInfo.SourceTags.RequireTags.IsEmpty() == false)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "SourceTags - Require");
|
||||
ImGui::TableNextColumn();
|
||||
FCogAbilityHelper::RenderTagContainer(ModInfo.SourceTags.RequireTags, false);
|
||||
}
|
||||
|
||||
if (ModInfo.SourceTags.IgnoreTags.IsEmpty() == false)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "SourceTags - Ignore");
|
||||
ImGui::TableNextColumn();
|
||||
FCogAbilityHelper::RenderTagContainer(ModInfo.SourceTags.IgnoreTags, false);
|
||||
}
|
||||
|
||||
if (ModInfo.SourceTags.TagQuery.IsEmpty() == false)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "SourceTags - Query");
|
||||
ImGui::TableNextColumn();
|
||||
const auto Str = StringCast<ANSICHAR>(*ModInfo.SourceTags.TagQuery.GetDescription());
|
||||
ImGui::Text("%s", Str.Get());
|
||||
}
|
||||
|
||||
if (ModInfo.TargetTags.RequireTags.IsEmpty() == false)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "TargetTags - Require");
|
||||
ImGui::TableNextColumn();
|
||||
FCogAbilityHelper::RenderTagContainer(ModInfo.TargetTags.RequireTags, false);
|
||||
}
|
||||
|
||||
if (ModInfo.TargetTags.IgnoreTags.IsEmpty() == false)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "TargetTags - Ignore");
|
||||
ImGui::TableNextColumn();
|
||||
FCogAbilityHelper::RenderTagContainer(ModInfo.TargetTags.IgnoreTags, false);
|
||||
}
|
||||
|
||||
if (ModInfo.TargetTags.TagQuery.IsEmpty() == false)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "TargetTags - Query");
|
||||
ImGui::TableNextColumn();
|
||||
const auto Str = StringCast<ANSICHAR>(*ModInfo.TargetTags.TagQuery.GetDescription());
|
||||
ImGui::Text("%s", Str.Get());
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
ModifierIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::RenderOpenAttributes()
|
||||
{
|
||||
const AActor* Selection = GetSelection();
|
||||
if (Selection == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true);
|
||||
if (AbilitySystemComponent == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = OpenedAttributes.Num() - 1; i >= 0; --i)
|
||||
{
|
||||
const FGameplayAttribute& Attribute = OpenedAttributes[i];
|
||||
|
||||
FString AttributeSetName = Attribute.GetAttributeSetClass()->GetFName().ToString();
|
||||
FormatAttributeSetName(AttributeSetName);
|
||||
|
||||
const FString WindowName = AttributeSetName + FString(" - ") + Attribute.GetName();
|
||||
const auto WindowNameStr = StringCast<ANSICHAR>(*WindowName);
|
||||
|
||||
bool Open = true;
|
||||
if (ImGui::Begin(WindowNameStr.Get(), &Open))
|
||||
{
|
||||
const auto AttributeSetNameStr = StringCast<ANSICHAR>(*AttributeSetName);
|
||||
RenderAttributeDetails(*AbilitySystemComponent, AttributeSetNameStr.Get(), Attribute, false);
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
if (Open == false)
|
||||
{
|
||||
OpenedAttributes.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::RenderAttributeContextMenu(UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& InAttribute, int Index)
|
||||
{
|
||||
if (ImGui::BeginPopupContextItem())
|
||||
{
|
||||
bool bOpen = OpenedAttributes.Contains(InAttribute);
|
||||
if (ImGui::Checkbox("Open Details", &bOpen))
|
||||
{
|
||||
if (bOpen)
|
||||
{
|
||||
OpenAttributeDetails(InAttribute);
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseAttributeDetails(InAttribute);
|
||||
}
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::OpenAttributeDetails(const FGameplayAttribute& InAttribute)
|
||||
{
|
||||
OpenedAttributes.AddUnique(InAttribute);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::CloseAttributeDetails(const FGameplayAttribute& InAttribute)
|
||||
{
|
||||
OpenedAttributes.Remove(InAttribute);
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "CogAbilityReplicator.h"
|
||||
#include "CogCommonAllegianceActorInterface.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowConsoleCommandManager.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "EngineUtils.h"
|
||||
#include "GameFramework/Character.h"
|
||||
@@ -21,6 +22,29 @@ void FCogAbilityWindow_Cheats::Initialize()
|
||||
Asset = GetAsset<UCogAbilityDataAsset>();
|
||||
Config = GetConfig<UCogAbilityConfig_Cheats>();
|
||||
AlignmentConfig = GetConfig<UCogAbilityConfig_Alignment>();
|
||||
|
||||
FCogWindowConsoleCommandManager::RegisterWorldConsoleCommand(
|
||||
TEXT("Cog.Cheat"),
|
||||
TEXT("Apply a cheat to the selection. Cog.Cheat <CheatName> -Allies -Enemies -Controlled"),
|
||||
GetWorld(),
|
||||
FCogWindowConsoleCommandDelegate::CreateLambda([this](const TArray<FString>& InArgs, UWorld* InWorld)
|
||||
{
|
||||
if (InArgs.Num() > 0)
|
||||
{
|
||||
if (const FCogAbilityCheat* cheat = FindCheatByName(InArgs[0]))
|
||||
{
|
||||
const bool ApplyToEnemies = InArgs.Contains("-Enemies");
|
||||
const bool ApplyToAllies = InArgs.Contains("-Allies");
|
||||
const bool ApplyToControlled = InArgs.Contains("-Controlled");
|
||||
|
||||
RequestCheat(GetLocalPlayerPawn(), GetSelection(), *cheat, ApplyToEnemies, ApplyToAllies, ApplyToControlled);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogCogImGui, Warning, TEXT("Cog.Cheat %s | Cheat not found"), *InArgs[0]);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -84,8 +108,8 @@ void FCogAbilityWindow_Cheats::TryReapplyCheats()
|
||||
return;
|
||||
}
|
||||
|
||||
APawn* LocalPawn = GetLocalPlayerPawn();
|
||||
if (LocalPawn == nullptr)
|
||||
APawn* ControlledActor = GetLocalPlayerPawn();
|
||||
if (ControlledActor == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +120,7 @@ void FCogAbilityWindow_Cheats::TryReapplyCheats()
|
||||
return;
|
||||
}
|
||||
|
||||
TArray<AActor*> Targets { LocalPawn };
|
||||
TArray<AActor*> Targets { ControlledActor };
|
||||
|
||||
for (int32 i = Config->AppliedCheats.Num() - 1; i >= 0; i--)
|
||||
{
|
||||
@@ -105,7 +129,7 @@ void FCogAbilityWindow_Cheats::TryReapplyCheats()
|
||||
if (const FCogAbilityCheat* Cheat = Asset->PersistentEffects.FindByPredicate(
|
||||
[AppliedCheatName](const FCogAbilityCheat& Cheat) { return Cheat.Name == AppliedCheatName; }))
|
||||
{
|
||||
Replicator->Server_ApplyCheat(LocalPawn, Targets, *Cheat);
|
||||
Replicator->Server_ApplyCheat(ControlledActor, Targets, *Cheat);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -247,13 +271,17 @@ bool FCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte
|
||||
FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectColor(Asset, *EffectCDO)));
|
||||
}
|
||||
|
||||
const bool IsShiftDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Shift) != 0;
|
||||
const bool IsAltDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Alt) != 0;
|
||||
const bool IsControlDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Ctrl) != 0;
|
||||
|
||||
bool bIsPressed = false;
|
||||
if (IsPersistent)
|
||||
{
|
||||
bool isEnabled = ACogAbilityReplicator::IsCheatActive(SelectedActor, Cheat);
|
||||
if (ImGui::Checkbox(TCHAR_TO_ANSI(*Cheat.Name), &isEnabled))
|
||||
{
|
||||
RequestCheat(ControlledActor, SelectedActor, Cheat);
|
||||
RequestCheat(ControlledActor, SelectedActor, Cheat, IsShiftDown, IsAltDown, IsControlDown);
|
||||
bIsPressed = true;
|
||||
}
|
||||
}
|
||||
@@ -261,22 +289,18 @@ bool FCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte
|
||||
{
|
||||
if (ImGui::Button(TCHAR_TO_ANSI(*Cheat.Name), ImVec2(-1, 0)))
|
||||
{
|
||||
RequestCheat(ControlledActor, SelectedActor, Cheat);
|
||||
RequestCheat(ControlledActor, SelectedActor, Cheat, IsShiftDown, IsAltDown, IsControlDown);
|
||||
bIsPressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
const bool IsShiftDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Shift) != 0;
|
||||
const bool IsAltDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Alt) != 0;
|
||||
const bool IsControlDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Ctrl) != 0;
|
||||
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, IsShiftDown || IsAltDown || IsControlDown ? 0.5f : 1.0f), "On Selection");
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, IsShiftDown ? 1.0f : 0.5f), "On Enemies [SHIFT]");
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, IsAltDown ? 1.0f : 0.5f), "On Allies [ALT]");
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, IsControlDown ? 1.0f : 0.5f), "On Controlled [CTRL]");
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, IsShiftDown || IsAltDown || IsControlDown ? 0.5f : 1.0f), "On Selection");
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, IsShiftDown ? 1.0f : 0.5f), "On Enemies [SHIFT]");
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, IsAltDown ? 1.0f : 0.5f), "On Allies [ALT]");
|
||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, IsControlDown ? 1.0f : 0.5f), "On Controlled [CTRL]");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
@@ -289,20 +313,16 @@ bool FCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Cheats::RequestCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat)
|
||||
void FCogAbilityWindow_Cheats::RequestCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat, bool ApplyToEnemies, bool ApplyToAllies, bool ApplyToControlled)
|
||||
{
|
||||
const bool IsShiftDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Shift) != 0;
|
||||
const bool IsAltDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Alt) != 0;
|
||||
const bool IsControlDown = (ImGui::GetCurrentContext()->IO.KeyMods & ImGuiMod_Ctrl) != 0;
|
||||
|
||||
TArray<AActor*> Actors;
|
||||
|
||||
if (IsControlDown)
|
||||
if (ApplyToControlled)
|
||||
{
|
||||
Actors.Add(ControlledActor);
|
||||
}
|
||||
|
||||
if (IsShiftDown || IsAltDown)
|
||||
if (ApplyToEnemies || ApplyToAllies)
|
||||
{
|
||||
for (TActorIterator<ACharacter> It(GetWorld(), ACharacter::StaticClass()); It; ++It)
|
||||
{
|
||||
@@ -315,8 +335,8 @@ void FCogAbilityWindow_Cheats::RequestCheat(AActor* ControlledActor, AActor* Sel
|
||||
Allegiance = AllegianceInterface->GetAllegianceWithOtherActor(ControlledActor);
|
||||
}
|
||||
|
||||
if ((IsShiftDown && (Allegiance == ECogCommonAllegiance::Enemy))
|
||||
|| (IsAltDown && (Allegiance == ECogCommonAllegiance::Friendly)))
|
||||
if ((ApplyToEnemies && (Allegiance == ECogCommonAllegiance::Enemy))
|
||||
|| (ApplyToAllies && (Allegiance == ECogCommonAllegiance::Friendly)))
|
||||
{
|
||||
Actors.Add(OtherActor);
|
||||
}
|
||||
@@ -324,7 +344,7 @@ void FCogAbilityWindow_Cheats::RequestCheat(AActor* ControlledActor, AActor* Sel
|
||||
}
|
||||
}
|
||||
|
||||
if ((IsControlDown || IsShiftDown || IsAltDown) == false)
|
||||
if ((ApplyToControlled || ApplyToEnemies || ApplyToAllies) == false)
|
||||
{
|
||||
Actors.Add(SelectedActor);
|
||||
}
|
||||
@@ -333,4 +353,30 @@ void FCogAbilityWindow_Cheats::RequestCheat(AActor* ControlledActor, AActor* Sel
|
||||
{
|
||||
Replicator->Server_ApplyCheat(ControlledActor, Actors, Cheat);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogCogImGui, Warning, TEXT("FCogAbilityWindow_Cheats::RequestCheat | Replicator not found"));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
const FCogAbilityCheat* FCogAbilityWindow_Cheats::FindCheatByName(const FString& CheatName)
|
||||
{
|
||||
for (const FCogAbilityCheat& cheat : Asset->PersistentEffects)
|
||||
{
|
||||
if (cheat.Name == CheatName)
|
||||
{
|
||||
return &cheat;
|
||||
}
|
||||
}
|
||||
|
||||
for (const FCogAbilityCheat& cheat : Asset->InstantEffects)
|
||||
{
|
||||
if (cheat.Name == CheatName)
|
||||
{
|
||||
return &cheat;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ void FCogAbilityWindow_Effects::ResetConfig()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Effects::RenderTick(float DetlaTime)
|
||||
void FCogAbilityWindow_Effects::RenderTick(float DeltaTime)
|
||||
{
|
||||
Super::RenderTick(DetlaTime);
|
||||
Super::RenderTick(DeltaTime);
|
||||
|
||||
RenderOpenEffects();
|
||||
}
|
||||
@@ -85,7 +85,7 @@ void FCogAbilityWindow_Effects::RenderContent()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Effects::RenderEffectsTable()
|
||||
{
|
||||
const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
|
||||
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
|
||||
if (AbilitySystemComponent == nullptr)
|
||||
{
|
||||
ImGui::TextDisabled("Selection has no ability system component");
|
||||
@@ -170,7 +170,7 @@ void FCogAbilityWindow_Effects::RenderEffectsTable()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected)
|
||||
void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected)
|
||||
{
|
||||
const FActiveGameplayEffect* ActiveEffectPtr = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle);
|
||||
if (ActiveEffectPtr == nullptr)
|
||||
@@ -213,11 +213,10 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A
|
||||
//------------------------
|
||||
// Popup
|
||||
//------------------------
|
||||
if (ImGui::IsItemHovered())
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
FCogWindowWidgets::BeginTableTooltip();
|
||||
RenderEffectInfo(AbilitySystemComponent, ActiveEffect, Effect);
|
||||
FCogWindowWidgets::EndTableTooltip();
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
@@ -225,8 +224,10 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A
|
||||
//------------------------
|
||||
if (ImGui::BeginPopupContextItem())
|
||||
{
|
||||
const ImVec2 ButtonsSize = ImVec2(ImGui::GetFontSize() * 10, 0);
|
||||
|
||||
bool bOpen = OpenedEffects.Contains(ActiveHandle);
|
||||
if (ImGui::Checkbox("Open", &bOpen))
|
||||
if (ImGui::Checkbox("Open Details", &bOpen))
|
||||
{
|
||||
if (bOpen)
|
||||
{
|
||||
@@ -238,6 +239,15 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A
|
||||
}
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Remove", ButtonsSize))
|
||||
{
|
||||
AbilitySystemComponent.RemoveActiveGameplayEffect(ActiveHandle);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::OpenObjectAssetButton(EffectPtr, ButtonsSize);
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
@@ -270,7 +280,7 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect)
|
||||
{
|
||||
if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders))
|
||||
if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable))
|
||||
{
|
||||
constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
|
||||
@@ -134,11 +134,10 @@ void FCogAbilityWindow_Tags::RenderTagContainer(const UAbilitySystemComponent& A
|
||||
//------------------------
|
||||
// Tooltip
|
||||
//------------------------
|
||||
if (ImGui::IsItemHovered())
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
FCogWindowWidgets::BeginTableTooltip();
|
||||
RenderTag(AbilitySystemComponent, Tag);
|
||||
FCogWindowWidgets::EndTableTooltip();
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogAbilityHelper.h"
|
||||
#include "CogAbilityReplicator.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "imgui.h"
|
||||
|
||||
@@ -160,15 +157,15 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
|
||||
continue;
|
||||
}
|
||||
|
||||
const char* TaskName = StringCast<ANSICHAR>(*Task->GetName()).Get();
|
||||
bool PassFilter = Filter.PassFilter(TaskName);
|
||||
const auto& TaskName = StringCast<ANSICHAR>(*Task->GetName());
|
||||
bool PassFilter = Filter.PassFilter(TaskName.Get());
|
||||
|
||||
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);
|
||||
const auto& AbilityName = StringCast<ANSICHAR>(*FCogAbilityHelper::CleanupName(Ability->GetName()));
|
||||
PassFilter = Filter.PassFilter(AbilityName.Get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +174,7 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
|
||||
continue;
|
||||
}
|
||||
|
||||
FilteredTasks.Add(Task);
|
||||
FilteredTasks.Add(Task);
|
||||
}
|
||||
|
||||
if (Config->SortByName)
|
||||
@@ -228,8 +225,8 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
const char* TaskName = StringCast<ANSICHAR>(*Task->GetName()).Get();
|
||||
if (ImGui::Selectable(TaskName, SelectedIndex == LineIndex, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
const auto& TaskName = StringCast<ANSICHAR>(*Task->GetName());
|
||||
if (ImGui::Selectable(TaskName.Get(), SelectedIndex == LineIndex, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
SelectedIndex = LineIndex;
|
||||
}
|
||||
@@ -237,11 +234,10 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
|
||||
//------------------------
|
||||
// Popup
|
||||
//------------------------
|
||||
if (ImGui::IsItemHovered())
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
FCogWindowWidgets::BeginTableTooltip();
|
||||
RenderTaskInfo(Task);
|
||||
FCogWindowWidgets::EndTableTooltip();
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
@@ -254,7 +250,7 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
|
||||
// IsTicking
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
|
||||
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
@@ -275,7 +271,7 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
|
||||
|
||||
if (ImGui::BeginTable("Task", 2, ImGuiTableFlags_Borders))
|
||||
{
|
||||
constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
ImGui::TableSetupColumn("Property");
|
||||
ImGui::TableSetupColumn("Value");
|
||||
@@ -287,20 +283,20 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Name");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(StringCast<ANSICHAR>(*Task->GetName()).Get());
|
||||
ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetName()).Get());
|
||||
|
||||
//------------------------
|
||||
// Instance Name
|
||||
//------------------------
|
||||
// Instance Name
|
||||
//------------------------
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Instance Name");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(StringCast<ANSICHAR>(*Task->GetInstanceName().ToString()).Get());
|
||||
ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetInstanceName().ToString()).Get());
|
||||
|
||||
//------------------------
|
||||
// Owner
|
||||
//------------------------
|
||||
// Owner
|
||||
//------------------------
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Ability");
|
||||
@@ -316,9 +312,9 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
|
||||
ImGui::TableNextColumn();
|
||||
RenderTaskState(Task);
|
||||
|
||||
//------------------------
|
||||
// Priority
|
||||
//------------------------
|
||||
//------------------------
|
||||
// Priority
|
||||
//------------------------
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Priority");
|
||||
@@ -326,17 +322,17 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
|
||||
ImGui::Text("%d", (int32)Task->GetPriority());
|
||||
|
||||
//------------------------
|
||||
// IsTicking
|
||||
//------------------------
|
||||
// IsTicking
|
||||
//------------------------
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Is Ticking");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(Task->IsTickingTask() ? "Yes" : "No");
|
||||
|
||||
//------------------------
|
||||
// IsSimulated
|
||||
//------------------------
|
||||
//------------------------
|
||||
// IsSimulated
|
||||
//------------------------
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Is Simulated");
|
||||
@@ -344,8 +340,8 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
|
||||
ImGui::Text(Task->IsSimulatedTask() ? "Yes" : "No");
|
||||
|
||||
//------------------------
|
||||
// IsSimulating
|
||||
//------------------------
|
||||
// IsSimulating
|
||||
//------------------------
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Is Simulating");
|
||||
@@ -353,15 +349,15 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
|
||||
ImGui::Text(Task->IsSimulating() ? "Yes" : "No");
|
||||
|
||||
//------------------------
|
||||
// Debug
|
||||
//------------------------
|
||||
// Debug
|
||||
//------------------------
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Debug");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushTextWrapPos(FCogWindowWidgets::GetFontWidth() * 80);
|
||||
ImGui::Text(StringCast<ANSICHAR>(*Task->GetDebugString()).Get());
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetDebugString()).Get());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
@@ -383,7 +379,7 @@ void FCogAbilityWindow_Tasks::RenderTaskOwner(const UGameplayTask* Task)
|
||||
OwnerName = GetNameSafe(Object);
|
||||
}
|
||||
|
||||
ImGui::Text(StringCast<ANSICHAR>(*OwnerName).Get());
|
||||
ImGui::Text("%s", StringCast<ANSICHAR>(*OwnerName).Get());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogEngineDataAsset.h"
|
||||
#include "GameplayEffect.h"
|
||||
#include "CogAbilityCheat_Execution_ApplyEffect.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(DisplayName = "Apply Effect")
|
||||
class COGABILITY_API UCogAbilityCheat_Execution_ApplyEffect
|
||||
: public UCogEngineCheat_Execution
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
void Execute_Implementation(const AActor* Instigator, const TArray<AActor*>& Targets) const override;
|
||||
|
||||
ECogEngineCheat_ActiveState IsActiveOnTargets_Implementation(const TArray<AActor*>& Targets) const override;
|
||||
|
||||
virtual bool GetColor(const FCogWindow& InCallingWindow, FLinearColor& OutColor) const override;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TSubclassOf<UGameplayEffect> Effect;
|
||||
};
|
||||
@@ -73,9 +73,9 @@ protected:
|
||||
|
||||
virtual void DeactivateAbility(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec);
|
||||
|
||||
virtual void OpenAbility(const FGameplayAbilitySpecHandle& Handle);
|
||||
virtual void OpenAbilityDetails(const FGameplayAbilitySpecHandle& Handle);
|
||||
|
||||
virtual void CloseAbility(const FGameplayAbilitySpecHandle& Handle);
|
||||
virtual void CloseAbilityDetails(const FGameplayAbilitySpecHandle& Handle);
|
||||
|
||||
virtual ImVec4 GetAbilityColor(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec);
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogCommonConfig.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "CogWindow.h"
|
||||
#include "CogAbilityWindow_Attributes.generated.h"
|
||||
|
||||
class UAttributeSet;
|
||||
class UAbilitySystemComponent;
|
||||
class UCogAbilityConfig_Attributes;
|
||||
class UCogAbilityConfig_Alignment;
|
||||
struct FGameplayAttribute;
|
||||
struct FModifierSpec;
|
||||
struct FGameplayModifierInfo;
|
||||
|
||||
@@ -27,9 +28,21 @@ protected:
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void RenderTick(float DeltaTime);
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute);
|
||||
virtual void RenderAttributeDetails(const UAbilitySystemComponent& AbilitySystemComponent, const char* AttributeSetName, const FGameplayAttribute& Attribute, bool IsForTooltip);
|
||||
|
||||
virtual void RenderOpenAttributes();
|
||||
|
||||
virtual void FormatAttributeSetName(FString& AttributeSetName);
|
||||
|
||||
virtual void OpenAttributeDetails(const FGameplayAttribute& InAttribute);
|
||||
|
||||
virtual void CloseAttributeDetails(const FGameplayAttribute& InAttribute);
|
||||
|
||||
virtual void RenderAttributeContextMenu(UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& InAttribute, int Index);
|
||||
|
||||
private:
|
||||
|
||||
@@ -38,6 +51,8 @@ private:
|
||||
TObjectPtr<UCogAbilityConfig_Attributes> Config = nullptr;
|
||||
|
||||
TObjectPtr<UCogAbilityConfig_Alignment> AlignmentConfig = nullptr;
|
||||
|
||||
TArray<FGameplayAttribute> OpenedAttributes;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -60,6 +75,15 @@ public:
|
||||
UPROPERTY(Config)
|
||||
bool ShowOnlyModified = false;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FString AttributeSetPrefixes;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector4f CategoryColor = FVector4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector4f AttributeSetColor = FVector4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
virtual void Reset() override
|
||||
{
|
||||
Super::Reset();
|
||||
@@ -68,5 +92,8 @@ public:
|
||||
GroupByAttributeSet = false;
|
||||
GroupByCategory = false;
|
||||
ShowOnlyModified = false;
|
||||
AttributeSetPrefixes = FString();
|
||||
CategoryColor = FVector4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
AttributeSetColor = FVector4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
}
|
||||
};
|
||||
@@ -31,10 +31,13 @@ protected:
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void TryReapplyCheats();
|
||||
APawn* GetCheatInstigator();
|
||||
|
||||
virtual bool AddCheat(AActor* ControlledActor, AActor* TargetActor, const FCogAbilityCheat& CheatEffect, bool IsPersistent);
|
||||
|
||||
virtual void RequestCheat(AActor* ControlledActor, AActor* TargetActor, const FCogAbilityCheat& CheatEffect);
|
||||
virtual void RequestCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat, bool ApplyToEnemies, bool ApplyToAllies, bool ApplyToControlled);
|
||||
|
||||
virtual const FCogAbilityCheat* FindCheatByName(const FString& CheatName);
|
||||
|
||||
TObjectPtr<const UCogAbilityDataAsset> Asset = nullptr;
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void RenderTick(float DetlaTime) override;
|
||||
virtual void RenderTick(float DeltaTime) override;
|
||||
|
||||
virtual void ResetConfig() override;
|
||||
|
||||
virtual void RenderEffectsTable();
|
||||
|
||||
virtual void RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected);
|
||||
virtual void RenderEffectRow(UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected);
|
||||
|
||||
virtual void RenderEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user