mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-06 15:48:48 +00:00
Merge remote-tracking branch 'arnaud-jamin/main'
# Conflicts: # .gitignore # Plugins/Cog/Source/CogEngine/Public/CogEngineCollisionTester.h # Plugins/Cog/Source/ThirdParty/ImGui/imgui_widgets.cpp
This commit is contained in:
@@ -26,7 +26,7 @@ public class CogAbility : ModuleRules
|
||||
"CogCommon",
|
||||
"CogDebug",
|
||||
"CogEngine",
|
||||
"CogWindow",
|
||||
"Cog",
|
||||
"GameplayAbilities",
|
||||
"GameplayTags",
|
||||
"NetCore",
|
||||
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
#include "CogAbilityCheat_Execution_ActivateAbility.h"
|
||||
|
||||
#include "CogAbilityDataAsset.h"
|
||||
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "CogAbilityConfig_Alignment.h"
|
||||
#include "CogCommon.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindow.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityCheat_Execution_ActivateAbility::Execute_Implementation(const UObject* WorldContextObject, const AActor* Instigator, const TArray<AActor*>& Targets) const
|
||||
{
|
||||
if (Ability == nullptr)
|
||||
{ return; }
|
||||
|
||||
for (AActor* Target : Targets)
|
||||
{
|
||||
UAbilitySystemComponent* AbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Target, true);
|
||||
if (AbilitySystem == nullptr)
|
||||
{
|
||||
COG_LOG_FUNC(LogCogImGui, ELogVerbosity::Warning, TEXT("Target:%s | Invalid Target AbilitySystem"), *GetNameSafe(Target));
|
||||
continue;
|
||||
}
|
||||
|
||||
FGameplayAbilitySpecHandle Handle;
|
||||
const FGameplayAbilitySpec* Spec = AbilitySystem->FindAbilitySpecFromClass(Ability);
|
||||
if (Spec != nullptr)
|
||||
{
|
||||
if (Spec->IsActive())
|
||||
{
|
||||
AbilitySystem->CancelAbilityHandle(Spec->Handle);
|
||||
if (RemoveAbilityOnEnd)
|
||||
{
|
||||
AbilitySystem->ClearAbility(Handle);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Handle = Spec->Handle;
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle = AbilitySystem->GiveAbility(FGameplayAbilitySpec(Ability, 1, INDEX_NONE, Target));
|
||||
Spec = AbilitySystem->FindAbilitySpecFromHandle(Handle, EConsiderPending::All);
|
||||
}
|
||||
|
||||
AbilitySystem->TryActivateAbility(Handle);
|
||||
|
||||
if (Spec->IsActive() == false)
|
||||
{
|
||||
if (RemoveAbilityOnEnd)
|
||||
{
|
||||
AbilitySystem->ClearAbility(Handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ECogEngineCheat_ActiveState UCogAbilityCheat_Execution_ActivateAbility::IsActiveOnTargets_Implementation(const UObject* WorldContextObject, const TArray<AActor*>& Targets) const
|
||||
{
|
||||
if (Ability == nullptr)
|
||||
{
|
||||
return ECogEngineCheat_ActiveState::Inactive;
|
||||
}
|
||||
|
||||
int32 NumActiveAbilities = 0;
|
||||
for (const AActor* Target : Targets)
|
||||
{
|
||||
const UAbilitySystemComponent* AbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Target, true);
|
||||
if (AbilitySystem == nullptr)
|
||||
{ continue; }
|
||||
|
||||
const FGameplayAbilitySpec* Spec = AbilitySystem->FindAbilitySpecFromClass(Ability);
|
||||
if (Spec == nullptr)
|
||||
{ continue; }
|
||||
|
||||
if (Spec->IsActive())
|
||||
{
|
||||
NumActiveAbilities++;
|
||||
}
|
||||
}
|
||||
|
||||
if (NumActiveAbilities == 0)
|
||||
{
|
||||
return ECogEngineCheat_ActiveState::Inactive;
|
||||
}
|
||||
|
||||
if (NumActiveAbilities == Targets.Num())
|
||||
{
|
||||
return ECogEngineCheat_ActiveState::Active;
|
||||
}
|
||||
|
||||
return ECogEngineCheat_ActiveState::Partial;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool UCogAbilityCheat_Execution_ActivateAbility::GetColor(const FCogWindow& InCallingWindow, FLinearColor& OutColor) const
|
||||
{
|
||||
if (Ability == nullptr)
|
||||
{ return false; }
|
||||
|
||||
const UGameplayAbility* GameplayAbility = Ability->GetDefaultObject<UGameplayAbility>();
|
||||
if (GameplayAbility == nullptr)
|
||||
{ return false; }
|
||||
|
||||
const UCogAbilityConfig_Alignment* Config = InCallingWindow.GetConfig<UCogAbilityConfig_Alignment>();
|
||||
const UCogAbilityDataAsset* Asset = InCallingWindow.GetAsset<UCogAbilityDataAsset>();
|
||||
|
||||
return Config->GetAbilityColor(Asset, *GameplayAbility, OutColor);
|
||||
}
|
||||
+3
-4
@@ -9,7 +9,7 @@
|
||||
#include "CogWindow.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityCheat_Execution_ApplyEffect::Execute_Implementation(const AActor* Instigator, const TArray<AActor*>& Targets) const
|
||||
void UCogAbilityCheat_Execution_ApplyEffect::Execute_Implementation(const UObject* WorldContextObject, const AActor* Instigator, const TArray<AActor*>& Targets) const
|
||||
{
|
||||
UAbilitySystemComponent* DefaultInstigatorAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Instigator, true);
|
||||
|
||||
@@ -56,7 +56,7 @@ void UCogAbilityCheat_Execution_ApplyEffect::Execute_Implementation(const AActor
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ECogEngineCheat_ActiveState UCogAbilityCheat_Execution_ApplyEffect::IsActiveOnTargets_Implementation(const TArray<AActor*>& Targets) const
|
||||
ECogEngineCheat_ActiveState UCogAbilityCheat_Execution_ApplyEffect::IsActiveOnTargets_Implementation(const UObject* WorldContextObject, const TArray<AActor*>& Targets) const
|
||||
{
|
||||
if (Effect == nullptr)
|
||||
{
|
||||
@@ -106,6 +106,5 @@ bool UCogAbilityCheat_Execution_ApplyEffect::GetColor(const FCogWindow& InCallin
|
||||
const UCogAbilityConfig_Alignment* Config = InCallingWindow.GetConfig<UCogAbilityConfig_Alignment>();
|
||||
const UCogAbilityDataAsset* Asset = InCallingWindow.GetAsset<UCogAbilityDataAsset>();
|
||||
|
||||
OutColor = Config->GetEffectColor(Asset, *GameplayEffect);
|
||||
return true;
|
||||
return Config->GetEffectColor(Asset, *GameplayEffect, OutColor);
|
||||
}
|
||||
|
||||
@@ -24,26 +24,55 @@ FVector4f UCogAbilityConfig_Alignment::GetAttributeColor(const UAbilitySystemCom
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FVector4f UCogAbilityConfig_Alignment::GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect) const
|
||||
bool UCogAbilityConfig_Alignment::GetAbilityColor(const UCogAbilityDataAsset* Asset, const UGameplayAbility& Ability, FLinearColor& OutColor) const
|
||||
{
|
||||
if (Asset == nullptr)
|
||||
{
|
||||
return NeutralColor;
|
||||
OutColor = NeutralColor;
|
||||
return false;
|
||||
}
|
||||
|
||||
const FGameplayTagContainer& Tags = Ability.GetAssetTags();
|
||||
if (Tags.HasTag(Asset->NegativeAbilityTag))
|
||||
{
|
||||
OutColor = NegativeColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Tags.HasTag(Asset->PositiveAbilityTag))
|
||||
{
|
||||
OutColor = PositiveColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
OutColor = NeutralColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool UCogAbilityConfig_Alignment::GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect, FLinearColor& OutColor) const
|
||||
{
|
||||
if (Asset == nullptr)
|
||||
{
|
||||
OutColor = NeutralColor;
|
||||
return false;
|
||||
}
|
||||
|
||||
const FGameplayTagContainer& Tags = Effect.GetAssetTags();
|
||||
|
||||
if (Tags.HasTag(Asset->NegativeEffectTag))
|
||||
{
|
||||
return NegativeColor;
|
||||
OutColor = NegativeColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Tags.HasTag(Asset->PositiveEffectTag))
|
||||
{
|
||||
return PositiveColor;
|
||||
OutColor = PositiveColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
return NeutralColor;
|
||||
OutColor = NeutralColor;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -57,62 +86,53 @@ FVector4f UCogAbilityConfig_Alignment::GetEffectModifierColor(float ModifierValu
|
||||
{
|
||||
switch (ModifierOp)
|
||||
{
|
||||
case EGameplayModOp::Additive:
|
||||
case EGameplayModOp::AddBase:
|
||||
case EGameplayModOp::AddFinal:
|
||||
{
|
||||
if (ModifierValue > 0.0f)
|
||||
{
|
||||
return PositiveColor;
|
||||
}
|
||||
{ return PositiveColor; }
|
||||
|
||||
if (ModifierValue < 0.0f)
|
||||
{
|
||||
return NegativeColor;
|
||||
}
|
||||
break;
|
||||
{ return NegativeColor; }
|
||||
|
||||
return NeutralColor;
|
||||
}
|
||||
|
||||
case EGameplayModOp::Multiplicitive:
|
||||
case EGameplayModOp::MultiplyAdditive:
|
||||
case EGameplayModOp::MultiplyCompound:
|
||||
{
|
||||
if (ModifierValue > 1.0f)
|
||||
{
|
||||
return PositiveColor;
|
||||
}
|
||||
else if (ModifierValue < 1.0f)
|
||||
{
|
||||
return NegativeColor;
|
||||
}
|
||||
break;
|
||||
{ return PositiveColor; }
|
||||
|
||||
if (ModifierValue < 1.0f)
|
||||
{ return NegativeColor; }
|
||||
|
||||
return NeutralColor;
|
||||
}
|
||||
|
||||
case EGameplayModOp::Division:
|
||||
case EGameplayModOp::DivideAdditive:
|
||||
{
|
||||
if (ModifierValue < 1.0f)
|
||||
{
|
||||
return PositiveColor;
|
||||
}
|
||||
{ return PositiveColor; }
|
||||
|
||||
if (ModifierValue > 1.0f)
|
||||
{
|
||||
return NegativeColor;
|
||||
}
|
||||
break;
|
||||
{ return NegativeColor; }
|
||||
|
||||
return NeutralColor;
|
||||
}
|
||||
|
||||
case EGameplayModOp::Override:
|
||||
{
|
||||
if (ModifierValue > BaseValue)
|
||||
{
|
||||
return PositiveColor;
|
||||
}
|
||||
{ return PositiveColor; }
|
||||
|
||||
if (ModifierValue < BaseValue)
|
||||
{
|
||||
return NegativeColor;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
{ return NegativeColor; }
|
||||
|
||||
return NeutralColor;
|
||||
return NeutralColor;
|
||||
}
|
||||
|
||||
default: return NeutralColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "CogAbilityHelper.h"
|
||||
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogWidgets.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "imgui.h"
|
||||
|
||||
@@ -19,7 +20,7 @@ void FCogAbilityHelper::RenderTagContainer(const FGameplayTagContainer& Containe
|
||||
Container.GetGameplayTagArray(GameplayTags);
|
||||
for (const FGameplayTag& Tag : GameplayTags)
|
||||
{
|
||||
FCogWindowWidgets::SmallButton(StringCast<ANSICHAR>(*Tag.ToString()).Get(), Color);
|
||||
FCogWidgets::SmallButton(StringCast<ANSICHAR>(*Tag.ToString()).Get(), Color);
|
||||
if (Inline)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
@@ -50,10 +51,23 @@ void FCogAbilityHelper::RenderTagContainer(
|
||||
}
|
||||
|
||||
const ImVec4 Color = hasTag ? MatchColor : NormalColor;
|
||||
FCogWindowWidgets::SmallButton(StringCast<ANSICHAR>(*Tag.ToString()).Get(), Color);
|
||||
FCogWidgets::SmallButton(StringCast<ANSICHAR>(*Tag.ToString()).Get(), Color);
|
||||
if (Inline)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityHelper::RenderConfigureMessage(const TWeakObjectPtr<const UCogAbilityDataAsset> InAsset)
|
||||
{
|
||||
if (InAsset == nullptr)
|
||||
{
|
||||
ImGui::Text("Create a DataAsset child of '%s' to configure. ", StringCast<ANSICHAR>(*UCogAbilityDataAsset::StaticClass()->GetName()).Get());
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("Can be configured in the '%s' DataAsset. ", StringCast<ANSICHAR>(*GetNameSafe(InAsset.Get())).Get());
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowHelper.h"
|
||||
#include "CogHelper.h"
|
||||
#include "Components/SceneComponent.h"
|
||||
#include "Engine/World.h"
|
||||
#include "EngineUtils.h"
|
||||
@@ -59,7 +59,7 @@ ACogAbilityReplicator::ACogAbilityReplicator(const FObjectInitializer& ObjectIni
|
||||
bReplicates = true;
|
||||
bOnlyRelevantToOwner = true;
|
||||
|
||||
AbilityAsset = FCogWindowHelper::GetFirstAssetByClass<UCogAbilityDataAsset>();
|
||||
AbilityAsset = FCogHelper::GetFirstAssetByClass<UCogAbilityDataAsset>();
|
||||
|
||||
#endif // !UE_BUILD_SHIPPING
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "CogAbilityHelper.h"
|
||||
#include "CogAbilityReplicator.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogWidgets.h"
|
||||
#include "CogDebugRob.h"
|
||||
#include "imgui.h"
|
||||
|
||||
@@ -19,7 +19,6 @@ void FCogAbilityWindow_Abilities::Initialize()
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = true;
|
||||
bNoPadding = true;
|
||||
|
||||
Asset = GetAsset<UCogAbilityDataAsset>();
|
||||
Config = GetConfig<UCogAbilityConfig_Abilities>();
|
||||
@@ -32,16 +31,20 @@ void FCogAbilityWindow_Abilities::RenderHelp()
|
||||
"This window displays the gameplay abilities of the selected actor. "
|
||||
"Click the ability check box to force its activation or deactivation. "
|
||||
"Right click an ability to open or close the ability separate window. "
|
||||
"Use the 'Give Ability' menu to manually give an ability from a list defined in the '%s' data asset. "
|
||||
, TCHAR_TO_ANSI(*GetNameSafe(Asset.Get())));
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Abilities::ResetConfig()
|
||||
void FCogAbilityWindow_Abilities::PreBegin(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
Super::ResetConfig();
|
||||
WindowFlags |= ImGuiWindowFlags_NoScrollbar;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
}
|
||||
|
||||
Config->Reset();
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Abilities::PostBegin()
|
||||
{
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -175,7 +178,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenu(AActor* Selection)
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SearchBar(Filter);
|
||||
FCogWidgets::SearchBar("##Filter", Filter);
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
@@ -193,24 +196,24 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesMenuFilters()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Abilities::RenderAbilitiesMenuColorSettings()
|
||||
{
|
||||
ImGui::ColorEdit4("Active Color", (float*)&Config->ActiveAbilityColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Inactive Color", (float*)&Config->InactiveAbilityColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Blocked Color", (float*)&Config->BlockedAbilityColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Default Tag Color", (float*)&Config->DefaultTagsColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Blocked Tag Color", (float*)&Config->BlockedTagsColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Input Pressed Color", (float*)&Config->InputPressedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Active Color", &Config->ActiveAbilityColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Inactive Color", &Config->InactiveAbilityColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Blocked Color", &Config->BlockedAbilityColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Default Tag Color", &Config->DefaultTagsColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Blocked Tag Color", &Config->BlockedTagsColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Input Pressed Color", &Config->InputPressedColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Abilities::RenderAbilityActivation(FGameplayAbilitySpec& Spec)
|
||||
{
|
||||
FCogWindowWidgets::PushStyleCompact();
|
||||
FCogWidgets::PushStyleCompact();
|
||||
bool IsActive = Spec.IsActive();
|
||||
if (ImGui::Checkbox("##Activation", &IsActive))
|
||||
{
|
||||
AbilityHandleToActivate = Spec.Handle;
|
||||
}
|
||||
FCogWindowWidgets::PopStyleCompact();
|
||||
FCogWidgets::PopStyleCompact();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -393,10 +396,10 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTableRow(UAbilitySystemComponen
|
||||
//------------------------
|
||||
// Popup
|
||||
//------------------------
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
if (FCogWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
RenderAbilityInfo(AbilitySystemComponent, Spec);
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
FCogWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
@@ -467,7 +470,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityInputPressed(FGameplayAbilitySpec
|
||||
{
|
||||
if (Spec.InputPressed)
|
||||
{
|
||||
FCogWindowWidgets::SmallButton("Pressed", FCogImguiHelper::ToImVec4(Config->ActiveAbilityColor));
|
||||
FCogWidgets::SmallButton("Pressed", FCogImguiHelper::ToImVec4(Config->ActiveAbilityColor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,7 +505,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityContextMenu(UAbilitySystemCompone
|
||||
AbilityHandleToRemove = Spec.Handle;
|
||||
}
|
||||
|
||||
FCogWindowWidgets::OpenObjectAssetButton(Spec.Ability, ButtonsSize);
|
||||
FCogWidgets::OpenObjectAssetButton(Spec.Ability, ButtonsSize);
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
@@ -573,13 +576,13 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Activation");
|
||||
ImGui::TableNextColumn();
|
||||
FCogWindowWidgets::PushStyleCompact();
|
||||
FCogWidgets::PushStyleCompact();
|
||||
bool IsActive = Spec.IsActive();
|
||||
if (ImGui::Checkbox("##Activation", &IsActive))
|
||||
{
|
||||
AbilityHandleToActivate = Spec.Handle;
|
||||
}
|
||||
FCogWindowWidgets::PopStyleCompact();
|
||||
FCogWidgets::PopStyleCompact();
|
||||
|
||||
//------------------------
|
||||
// Active Count
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogAbilityHelper.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogWidgets.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "CogAbilityWindow_Abilities.h"
|
||||
#include "imgui_internal.h"
|
||||
@@ -17,7 +17,6 @@ void FCogAbilityWindow_Attributes::Initialize()
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = true;
|
||||
bNoPadding = true;
|
||||
|
||||
Config = GetConfig<UCogAbilityConfig_Attributes>();
|
||||
AlignmentConfig = GetConfig<UCogAbilityConfig_Alignment>();
|
||||
@@ -36,11 +35,15 @@ void FCogAbilityWindow_Attributes::RenderHelp()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::ResetConfig()
|
||||
void FCogAbilityWindow_Attributes::PreBegin(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
Super::ResetConfig();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
}
|
||||
|
||||
Config->Reset();
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Attributes::PostBegin()
|
||||
{
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -90,16 +93,16 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
ImGui::Checkbox("Group by Category", &Config->GroupByCategory);
|
||||
ImGui::Checkbox("Show Only Modified", &Config->ShowOnlyModified);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
FCogWindowWidgets::InputText("Attribute Set Prefixes", Config->AttributeSetPrefixes);
|
||||
FCogWidgets::SetNextItemToShortWidth();
|
||||
FCogWidgets::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::ColorEdit4("Positive Color", &AlignmentConfig->PositiveColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Negative Color", &AlignmentConfig->NegativeColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Neutral Color", &AlignmentConfig->NeutralColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("AttributeSet Color", &Config->AttributeSetColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Category Color", &Config->CategoryColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Reset"))
|
||||
{
|
||||
@@ -108,7 +111,7 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SearchBar(Filter);
|
||||
FCogWidgets::SearchBar("##Filter", Filter);
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
@@ -116,7 +119,7 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
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;
|
||||
const float FirstColWidth = (static_cast<int32>(bGroupByAttributeSetValue) + static_cast<int32>(bGroupByCategoryValue)) * ImGui::GetFontSize() * 2;
|
||||
|
||||
if (ImGui::BeginTable("Attributes", 5, ImGuiTableFlags_SizingFixedFit
|
||||
| ImGuiTableFlags_Resizable
|
||||
@@ -280,7 +283,7 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
{
|
||||
Selected = Index;
|
||||
|
||||
if (ImGui::IsMouseDoubleClicked(0))
|
||||
if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||
{
|
||||
OpenAttributeDetails(Attribute);
|
||||
}
|
||||
@@ -289,10 +292,10 @@ void FCogAbilityWindow_Attributes::RenderContent()
|
||||
//------------------------
|
||||
// Popup
|
||||
//------------------------
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
if (FCogWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
RenderAttributeDetails(*AbilitySystemComponent, AttributeSetNameStr.Get(), Attribute, true);
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
FCogWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
@@ -446,7 +449,7 @@ void FCogAbilityWindow_Attributes::RenderAttributeDetails(const UAbilitySystemCo
|
||||
char Buffer[128];
|
||||
ImFormatString(Buffer, IM_ARRAYSIZE(Buffer), "Modifier %d", ModifierIndex);
|
||||
|
||||
if (FCogWindowWidgets::DarkCollapsingHeader(Buffer, ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen))
|
||||
if (FCogWidgets::DarkCollapsingHeader(Buffer, ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
if (ImGui::BeginTable("Details", 2, TableFlags))
|
||||
{
|
||||
|
||||
@@ -1,146 +1,11 @@
|
||||
#include "CogAbilityWindow_Cheats.h"
|
||||
|
||||
#include "CogAbilityConfig_Alignment.h"
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogAbilityReplicator.h"
|
||||
#include "CogCommonAllegianceActorInterface.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowConsoleCommandManager.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "EngineUtils.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Cheats::Initialize()
|
||||
{
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = true;
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Cheats::RenderHelp()
|
||||
{
|
||||
ImGui::Text(
|
||||
"This window can be used to apply cheats to the selected actor (by default). "
|
||||
"The cheats can be configured in the '%s' data asset. "
|
||||
"When clicking a cheat button, press:\n"
|
||||
" [CTRL] to apply the cheat to controlled actor\n"
|
||||
" [ALT] to apply the cheat to the allies of the selected actor\n"
|
||||
" [SHIFT] to apply the cheat to the enemies of the selected actor\n"
|
||||
, TCHAR_TO_ANSI(*GetNameSafe(Asset.Get()))
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Cheats::ResetConfig()
|
||||
{
|
||||
Super::ResetConfig();
|
||||
|
||||
Config->Reset();
|
||||
AlignmentConfig->Reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Cheats::GameTick(float DeltaTime)
|
||||
{
|
||||
Super::GameTick(DeltaTime);
|
||||
|
||||
TryReapplyCheats();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Cheats::TryReapplyCheats()
|
||||
{
|
||||
if (Config == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (bHasReappliedCheats)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config->bReapplyCheatsBetweenPlays == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int32 IsFirstLaunch = true;
|
||||
if (IsFirstLaunch && Config->bReapplyCheatsBetweenLaunches == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IsFirstLaunch = false;
|
||||
|
||||
if (Asset == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
APawn* ControlledActor = GetLocalPlayerPawn();
|
||||
if (ControlledActor == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ACogAbilityReplicator* Replicator = ACogAbilityReplicator::GetFirstReplicator(*GetWorld());
|
||||
if (Replicator == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TArray<AActor*> Targets { ControlledActor };
|
||||
|
||||
for (int32 i = Config->AppliedCheats.Num() - 1; i >= 0; i--)
|
||||
{
|
||||
const FString& AppliedCheatName = Config->AppliedCheats[i];
|
||||
|
||||
if (const FCogAbilityCheat* Cheat = Asset->PersistentEffects.FindByPredicate(
|
||||
[AppliedCheatName](const FCogAbilityCheat& Cheat) { return Cheat.Name == AppliedCheatName; }))
|
||||
{
|
||||
Replicator->Server_ApplyCheat(ControlledActor, Targets, *Cheat);
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------------------
|
||||
// This cheat doesn't exist anymore. We can remove it.
|
||||
//-----------------------------------------------------
|
||||
Config->AppliedCheats.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
bHasReappliedCheats = true;
|
||||
ImGui::TextDisabled("This window is deprecated. Please use the CogEngineWindow_Cheat instead as it provide more functionalities.");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -148,235 +13,5 @@ void FCogAbilityWindow_Cheats::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
if (Config == nullptr)
|
||||
{
|
||||
ImGui::TextDisabled("Invalid Config");
|
||||
return;
|
||||
}
|
||||
|
||||
AActor* SelectedActor = GetSelection();
|
||||
if (SelectedActor == nullptr)
|
||||
{
|
||||
ImGui::TextDisabled("Invalid Selection");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Asset == nullptr)
|
||||
{
|
||||
ImGui::TextDisabled("Invalid Asset");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("Options"))
|
||||
{
|
||||
ImGui::Checkbox("Reapply Cheats Between Plays", &Config->bReapplyCheatsBetweenPlays);
|
||||
|
||||
if (Config->bReapplyCheatsBetweenPlays == false)
|
||||
{
|
||||
ImGui::BeginDisabled();
|
||||
}
|
||||
ImGui::Checkbox("Reapply Cheats Between Launches", &Config->bReapplyCheatsBetweenLaunches);
|
||||
|
||||
if (Config->bReapplyCheatsBetweenPlays == false)
|
||||
{
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
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::Separator();
|
||||
if (ImGui::MenuItem("Reset"))
|
||||
{
|
||||
ResetConfig();
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
APawn* ControlledActor = GetLocalPlayerPawn();
|
||||
|
||||
if (ImGui::BeginTable("Cheats", 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize))
|
||||
{
|
||||
ImGui::TableSetupColumn("Toggle", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("Instant", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
|
||||
int Index = 0;
|
||||
for (const FCogAbilityCheat& CheatEffect : Asset->PersistentEffects)
|
||||
{
|
||||
ImGui::PushID(Index);
|
||||
AddCheat(ControlledActor, SelectedActor, CheatEffect, true);
|
||||
ImGui::PopID();
|
||||
Index++;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Update the config of applied cheat to reapply them on the next launch.
|
||||
// We do not updated them only when the the user input is pressed because
|
||||
// the state of the cheat is lagging when connected to a server.
|
||||
// So we check if the array should be updated all the time.
|
||||
//----------------------------------------------------------------------------
|
||||
if (SelectedActor == ControlledActor)
|
||||
{
|
||||
for (const FCogAbilityCheat& CheatEffect : Asset->PersistentEffects)
|
||||
{
|
||||
if (ACogAbilityReplicator::IsCheatActive(SelectedActor, CheatEffect))
|
||||
{
|
||||
Config->AppliedCheats.AddUnique(CheatEffect.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
Config->AppliedCheats.Remove(CheatEffect.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
for (const FCogAbilityCheat& CheatEffect : Asset->InstantEffects)
|
||||
{
|
||||
ImGui::PushID(Index);
|
||||
AddCheat(ControlledActor, SelectedActor, CheatEffect, false);
|
||||
ImGui::PopID();
|
||||
Index++;
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool FCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat, bool IsPersistent)
|
||||
{
|
||||
if (Cheat.Effect == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const UGameplayEffect* EffectCDO = Cheat.Effect->GetDefaultObject<UGameplayEffect>();
|
||||
|
||||
if (EffectCDO != nullptr)
|
||||
{
|
||||
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, IsShiftDown, IsAltDown, IsControlDown);
|
||||
bIsPressed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ImGui::Button(TCHAR_TO_ANSI(*Cheat.Name), ImVec2(-1, 0)))
|
||||
{
|
||||
RequestCheat(ControlledActor, SelectedActor, Cheat, IsShiftDown, IsAltDown, IsControlDown);
|
||||
bIsPressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
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::EndTooltip();
|
||||
}
|
||||
|
||||
if (EffectCDO != nullptr)
|
||||
{
|
||||
FCogWindowWidgets::PopBackColor();
|
||||
}
|
||||
|
||||
return bIsPressed;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Cheats::RequestCheat(AActor* ControlledActor, AActor* SelectedActor, const FCogAbilityCheat& Cheat, bool ApplyToEnemies, bool ApplyToAllies, bool ApplyToControlled)
|
||||
{
|
||||
TArray<AActor*> Actors;
|
||||
|
||||
if (ApplyToControlled)
|
||||
{
|
||||
Actors.Add(ControlledActor);
|
||||
}
|
||||
|
||||
if (ApplyToEnemies || ApplyToAllies)
|
||||
{
|
||||
for (TActorIterator<ACharacter> It(GetWorld(), ACharacter::StaticClass()); It; ++It)
|
||||
{
|
||||
if (AActor* OtherActor = *It)
|
||||
{
|
||||
ECogCommonAllegiance Allegiance = ECogCommonAllegiance::Enemy;
|
||||
|
||||
if (ICogCommonAllegianceActorInterface* AllegianceInterface = Cast<ICogCommonAllegianceActorInterface>(OtherActor))
|
||||
{
|
||||
Allegiance = AllegianceInterface->GetAllegianceWithOtherActor(ControlledActor);
|
||||
}
|
||||
|
||||
if ((ApplyToEnemies && (Allegiance == ECogCommonAllegiance::Enemy))
|
||||
|| (ApplyToAllies && (Allegiance == ECogCommonAllegiance::Friendly)))
|
||||
{
|
||||
Actors.Add(OtherActor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((ApplyToControlled || ApplyToEnemies || ApplyToAllies) == false)
|
||||
{
|
||||
Actors.Add(SelectedActor);
|
||||
}
|
||||
|
||||
if (ACogAbilityReplicator* Replicator = ACogAbilityReplicator::GetFirstReplicator(*GetWorld()))
|
||||
{
|
||||
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;
|
||||
}
|
||||
RenderHelp();
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogAbilityHelper.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogWidgets.h"
|
||||
#include "Engine/World.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -16,7 +16,6 @@ void FCogAbilityWindow_Effects::Initialize()
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = true;
|
||||
bNoPadding = true;
|
||||
|
||||
Asset = GetAsset<UCogAbilityDataAsset>();
|
||||
Config = GetConfig<UCogAbilityConfig_Effects>();
|
||||
@@ -32,15 +31,6 @@ void FCogAbilityWindow_Effects::RenderHelp()
|
||||
);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Effects::ResetConfig()
|
||||
{
|
||||
Super::ResetConfig();
|
||||
|
||||
Config->Reset();
|
||||
AlignmentConfig->Reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Effects::RenderTick(float DeltaTime)
|
||||
{
|
||||
@@ -49,6 +39,19 @@ void FCogAbilityWindow_Effects::RenderTick(float DeltaTime)
|
||||
RenderOpenEffects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Effects::PreBegin(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Effects::PostBegin()
|
||||
{
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Effects::RenderContent()
|
||||
{
|
||||
@@ -62,9 +65,9 @@ void FCogAbilityWindow_Effects::RenderContent()
|
||||
ImGui::Checkbox("Sort by Alignment", &Config->SortByAlignment);
|
||||
|
||||
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("Positive Color", &AlignmentConfig->PositiveColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Negative Color", &AlignmentConfig->NegativeColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Neutral Color", &AlignmentConfig->NeutralColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Reset"))
|
||||
@@ -74,7 +77,7 @@ void FCogAbilityWindow_Effects::RenderContent()
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SearchBar(Filter);
|
||||
FCogWidgets::SearchBar("##Filter", Filter);
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
@@ -137,7 +140,6 @@ void FCogAbilityWindow_Effects::RenderEffectsTable()
|
||||
}
|
||||
}
|
||||
|
||||
bool AlignmentOrder = false;
|
||||
if (Config->SortByAlignment && Asset != nullptr)
|
||||
{
|
||||
const FGameplayTagContainer& Tags1 = Effect1->GetAssetTags();
|
||||
@@ -201,7 +203,9 @@ void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& Ability
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectColor(Asset, Effect)));
|
||||
FLinearColor Color;
|
||||
AlignmentConfig->GetEffectColor(Asset, Effect, Color);
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Color));
|
||||
|
||||
if (ImGui::Selectable(EffectName.Get(), Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
@@ -213,10 +217,10 @@ void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& Ability
|
||||
//------------------------
|
||||
// Popup
|
||||
//------------------------
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
if (FCogWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
RenderEffectInfo(AbilitySystemComponent, ActiveEffect, Effect);
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
FCogWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
@@ -246,7 +250,7 @@ void FCogAbilityWindow_Effects::RenderEffectRow(UAbilitySystemComponent& Ability
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::OpenObjectAssetButton(EffectPtr, ButtonsSize);
|
||||
FCogWidgets::OpenObjectAssetButton(EffectPtr, ButtonsSize);
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
@@ -454,7 +458,7 @@ void FCogAbilityWindow_Effects::RenderStacks(const FActiveGameplayEffect& Active
|
||||
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 100));
|
||||
ImGui::SetNextItemWidth(-1);
|
||||
ImGui::ProgressBar(CurrentStackCount / (float)Effect.StackLimitCount, ImVec2(FCogWindowWidgets::GetFontWidth() * 15, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), CurrentStackCount, Effect.StackLimitCount)));
|
||||
ImGui::ProgressBar(CurrentStackCount / (float)Effect.StackLimitCount, ImVec2(FCogWidgets::GetFontWidth() * 15, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), CurrentStackCount, Effect.StackLimitCount)));
|
||||
ImGui::PopStyleColor(2);
|
||||
}
|
||||
}
|
||||
@@ -487,7 +491,7 @@ void FCogAbilityWindow_Effects::RenderInhibition(const FActiveGameplayEffect& Ac
|
||||
{
|
||||
if (ActiveEffect.bIsInhibited)
|
||||
{
|
||||
FCogWindowWidgets::SmallButton("Yes", ImVec4(1, 0, 0, 1));
|
||||
FCogWidgets::SmallButton("Yes", ImVec4(1, 0, 0, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogAbilityHelper.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogWidgets.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -18,11 +19,8 @@ void FCogAbilityWindow_Pools::Initialize()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Pools::RenderHelp()
|
||||
{
|
||||
ImGui::Text(
|
||||
"This window displays attributes of the selected actor as pools. "
|
||||
"The pools can be configured in the '%s' data asset."
|
||||
, TCHAR_TO_ANSI(*GetNameSafe(Asset.Get()))
|
||||
);
|
||||
ImGui::Text("This window displays attributes of the selected actor as pools. ");
|
||||
FCogAbilityHelper::RenderConfigureMessage(Asset);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -87,19 +85,19 @@ void FCogAbilityWindow_Pools::DrawPool(const UAbilitySystemComponent* AbilitySys
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// Use a different format base on max value for all pools to be nicely aligned at the center
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const char* format = nullptr;
|
||||
if (Max >= 100) { format = "%3.0f / %3.0f"; } // |200 / 200| |__1 / 200| 3 characters with 0 floating point
|
||||
else if (Max >= 10) { format = "%4.1f / %4.1f"; } // |20.0 / 20.0| |_1.1 / 20.0| 4 characters with 1 floating point
|
||||
else { format = "%3.2f / %3.2f"; } // |2.00 / 2.00| |1.11 / 2.00| 3 characters with 2 floating points
|
||||
const char* Format;
|
||||
if (Max >= 100) { Format = "%3.0f / %3.0f"; } // |200 / 200| |__1 / 200| 3 characters with 0 floating point
|
||||
else if (Max >= 10) { Format = "%4.1f / %4.1f"; } // |20.0 / 20.0| |_1.1 / 20.0| 4 characters with 1 floating point
|
||||
else { Format = "%3.2f / %3.2f"; } // |2.00 / 2.00| |1.11 / 2.00| 3 characters with 2 floating points
|
||||
|
||||
char Buffer[64];
|
||||
ImFormatString(Buffer, IM_ARRAYSIZE(Buffer), format, Value, Max);
|
||||
ImFormatString(Buffer, IM_ARRAYSIZE(Buffer), Format, Value, Max);
|
||||
|
||||
const float Ratio = Max > 0.0f ? Value / Max : 0.0f;
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, FCogImguiHelper::ToImVec4(Pool.Color));
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, FCogImguiHelper::ToImVec4(Pool.BackColor));
|
||||
FCogWindowWidgets::ProgressBarCentered(Ratio, ImVec2(-1, 0), Buffer);
|
||||
FCogWidgets::ProgressBarCentered(Ratio, ImVec2(-1, 0), Buffer);
|
||||
ImGui::PopStyleColor(2);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "CogAbilityHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogWidgets.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Tags::Initialize()
|
||||
@@ -11,15 +11,6 @@ void FCogAbilityWindow_Tags::Initialize()
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = true;
|
||||
bNoPadding = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Tags::ResetConfig()
|
||||
{
|
||||
Super::ResetConfig();
|
||||
|
||||
Config->Reset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -28,6 +19,18 @@ void FCogAbilityWindow_Tags::RenderHelp()
|
||||
ImGui::Text("This window displays gameplay tags of the selected actor. ");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Tags::PreBegin(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Tags::PostBegin()
|
||||
{
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Tags::RenderContent()
|
||||
{
|
||||
@@ -67,7 +70,7 @@ void FCogAbilityWindow_Tags::RenderMenu()
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SearchBar(Filter);
|
||||
FCogWidgets::SearchBar("##Filter", Filter);
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
@@ -134,10 +137,10 @@ void FCogAbilityWindow_Tags::RenderTagContainer(const UAbilitySystemComponent& A
|
||||
//------------------------
|
||||
// Tooltip
|
||||
//------------------------
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
if (FCogWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
RenderTag(AbilitySystemComponent, Tag);
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
FCogWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
@@ -153,7 +156,7 @@ void FCogAbilityWindow_Tags::RenderTag(const UAbilitySystemComponent& AbilitySys
|
||||
{
|
||||
if (ImGui::BeginTable("Tag", 2, ImGuiTableFlags_Borders))
|
||||
{
|
||||
const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
ImGui::TableSetupColumn("Property");
|
||||
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "CogAbilityHelper.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogWidgets.h"
|
||||
#include "imgui.h"
|
||||
|
||||
class UCogAbilityConfig_Tasks;
|
||||
@@ -14,7 +14,6 @@ void FCogAbilityWindow_Tasks::Initialize()
|
||||
Super::Initialize();
|
||||
|
||||
bHasMenu = true;
|
||||
bNoPadding = true;
|
||||
|
||||
Config = GetConfig<UCogAbilityConfig_Tasks>();
|
||||
}
|
||||
@@ -27,17 +26,15 @@ void FCogAbilityWindow_Tasks::RenderHelp()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Tasks::ResetConfig()
|
||||
void FCogAbilityWindow_Tasks::PreBegin(ImGuiWindowFlags& WindowFlags)
|
||||
{
|
||||
Super::ResetConfig();
|
||||
|
||||
Config->Reset();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Tasks::RenderTick(float DetlaTime)
|
||||
void FCogAbilityWindow_Tasks::PostBegin()
|
||||
{
|
||||
Super::RenderTick(DetlaTime);
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -82,11 +79,11 @@ void FCogAbilityWindow_Tasks::RenderTaskMenu(AActor* Selection)
|
||||
|
||||
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::ColorEdit4("Uninitialized Color", &Config->UninitializedColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Awaiting Activation Color", &Config->AwaitingActivationColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Active Color", &Config->ActiveColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Paused Color", &Config->PausedColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
ImGui::ColorEdit4("Finished Color", &Config->FinishedColor.X, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
@@ -98,7 +95,7 @@ void FCogAbilityWindow_Tasks::RenderTaskMenu(AActor* Selection)
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
FCogWindowWidgets::SearchBar(Filter);
|
||||
FCogWidgets::SearchBar("##Filter", Filter);
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
@@ -110,8 +107,6 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
|
||||
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);
|
||||
@@ -234,10 +229,10 @@ void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilityS
|
||||
//------------------------
|
||||
// Popup
|
||||
//------------------------
|
||||
if (FCogWindowWidgets::BeginItemTableTooltip())
|
||||
if (FCogWidgets::BeginItemTableTooltip())
|
||||
{
|
||||
RenderTaskInfo(Task);
|
||||
FCogWindowWidgets::EndItemTableTooltip();
|
||||
FCogWidgets::EndItemTableTooltip();
|
||||
}
|
||||
|
||||
//------------------------
|
||||
@@ -319,7 +314,7 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Priority");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%d", (int32)Task->GetPriority());
|
||||
ImGui::Text("%d", static_cast<int32>(Task->GetPriority()));
|
||||
|
||||
//------------------------
|
||||
// IsTicking
|
||||
@@ -355,7 +350,7 @@ void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task)
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Debug");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushTextWrapPos(FCogWindowWidgets::GetFontWidth() * 80);
|
||||
ImGui::PushTextWrapPos(FCogWidgets::GetFontWidth() * 80);
|
||||
ImGui::Text("%s", StringCast<ANSICHAR>(*Task->GetDebugString()).Get());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
@@ -388,23 +383,23 @@ void FCogAbilityWindow_Tasks::RenderTaskState(const UGameplayTask* Task)
|
||||
switch (Task->GetState())
|
||||
{
|
||||
case EGameplayTaskState::Uninitialized:
|
||||
FCogWindowWidgets::SmallButton("Uninitialized", FCogImguiHelper::ToImVec4(Config->UninitializedColor));
|
||||
FCogWidgets::SmallButton("Uninitialized", FCogImguiHelper::ToImVec4(Config->UninitializedColor));
|
||||
break;
|
||||
|
||||
case EGameplayTaskState::AwaitingActivation:
|
||||
FCogWindowWidgets::SmallButton("Awaiting Activation", FCogImguiHelper::ToImVec4(Config->AwaitingActivationColor));
|
||||
FCogWidgets::SmallButton("Awaiting Activation", FCogImguiHelper::ToImVec4(Config->AwaitingActivationColor));
|
||||
break;
|
||||
|
||||
case EGameplayTaskState::Active:
|
||||
FCogWindowWidgets::SmallButton("Active", FCogImguiHelper::ToImVec4(Config->ActiveColor));
|
||||
FCogWidgets::SmallButton("Active", FCogImguiHelper::ToImVec4(Config->ActiveColor));
|
||||
break;
|
||||
|
||||
case EGameplayTaskState::Paused:
|
||||
FCogWindowWidgets::SmallButton("Paused", FCogImguiHelper::ToImVec4(Config->PausedColor));
|
||||
FCogWidgets::SmallButton("Paused", FCogImguiHelper::ToImVec4(Config->PausedColor));
|
||||
break;
|
||||
|
||||
case EGameplayTaskState::Finished:
|
||||
FCogWindowWidgets::SmallButton("Finished", FCogImguiHelper::ToImVec4(Config->FinishedColor));
|
||||
FCogWidgets::SmallButton("Finished", FCogImguiHelper::ToImVec4(Config->FinishedColor));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "CogAbilityWindow_Tweaks.h"
|
||||
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogAbilityHelper.h"
|
||||
#include "CogAbilityReplicator.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "CogWindowWidgets.h"
|
||||
#include "CogWidgets.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void FCogAbilityWindow_Tweaks::Initialize()
|
||||
@@ -20,10 +21,10 @@ void FCogAbilityWindow_Tweaks::RenderHelp()
|
||||
{
|
||||
ImGui::Text(
|
||||
"This window can be used to apply tweaks to all the loaded actors. "
|
||||
"The tweaks are used to test various gameplay settings by actor category. "
|
||||
"The tweaks can be configured in the '%s' data asset. "
|
||||
, TCHAR_TO_ANSI(*GetNameSafe(Asset.Get()))
|
||||
"Tweaks are used to test various gameplay settings by actor category. "
|
||||
);
|
||||
|
||||
FCogAbilityHelper::RenderConfigureMessage(Asset);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -141,11 +142,11 @@ void FCogAbilityWindow_Tweaks::DrawTweak(ACogAbilityReplicator* Replicator, int3
|
||||
|
||||
const FCogAbilityTweakCategory& Category = Asset->TweaksCategories[TweakCategoryIndex];
|
||||
|
||||
FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Category.Color));
|
||||
FCogWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Category.Color));
|
||||
ImGui::PushItemWidth(-1);
|
||||
ImGui::SliderFloat("##Value", Value, Asset->TweakMinValue, Asset->TweakMaxValue, "%+0.0f%%", 1.0f);
|
||||
ImGui::PopItemWidth();
|
||||
FCogWindowWidgets::PopBackColor();
|
||||
FCogWidgets::PopBackColor();
|
||||
|
||||
bool bUpdateValue = ImGui::IsItemDeactivatedAfterEdit();
|
||||
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogEngineDataAsset.h"
|
||||
#include "GameplayEffect.h"
|
||||
#include "CogAbilityCheat_Execution_ActivateAbility.generated.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
UCLASS(DisplayName = "Activate Ability")
|
||||
class COGABILITY_API UCogAbilityCheat_Execution_ActivateAbility
|
||||
: public UCogEngineCheat_Execution
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual void Execute_Implementation(const UObject* WorldContextObject, const AActor* Instigator, const TArray<AActor*>& Targets) const override;
|
||||
|
||||
virtual ECogEngineCheat_ActiveState IsActiveOnTargets_Implementation(const UObject* WorldContextObject, const TArray<AActor*>& Targets) const override;
|
||||
|
||||
virtual bool GetColor(const FCogWindow& InCallingWindow, FLinearColor& OutColor) const override;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
TSubclassOf<UGameplayAbility> Ability;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
bool RemoveAbilityOnEnd = true;
|
||||
};
|
||||
@@ -13,9 +13,9 @@ class COGABILITY_API UCogAbilityCheat_Execution_ApplyEffect
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
void Execute_Implementation(const AActor* Instigator, const TArray<AActor*>& Targets) const override;
|
||||
virtual void Execute_Implementation(const UObject* WorldContextObject, const AActor* Instigator, const TArray<AActor*>& Targets) const override;
|
||||
|
||||
ECogEngineCheat_ActiveState IsActiveOnTargets_Implementation(const TArray<AActor*>& Targets) const override;
|
||||
virtual ECogEngineCheat_ActiveState IsActiveOnTargets_Implementation(const UObject* WorldContextObject, const TArray<AActor*>& Targets) const override;
|
||||
|
||||
virtual bool GetColor(const FCogWindow& InCallingWindow, FLinearColor& OutColor) const override;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogCommonConfig.h"
|
||||
#include "Abilities/GameplayAbility.h"
|
||||
#include "CogAbilityConfig_Alignment.generated.h"
|
||||
|
||||
class UAbilitySystemComponent;
|
||||
@@ -22,12 +23,13 @@ public:
|
||||
|
||||
FVector4f GetAttributeColor(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) const;
|
||||
|
||||
bool GetAbilityColor(const UCogAbilityDataAsset* Asset, const UGameplayAbility& Ability, FLinearColor& OutColor) const;
|
||||
|
||||
FVector4f GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const;
|
||||
|
||||
FVector4f GetEffectModifierColor(float ModifierValue, EGameplayModOp::Type ModifierOp, float BaseValue) const;
|
||||
|
||||
FVector4f GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect) const;
|
||||
|
||||
bool GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect, FLinearColor& OutColor) const;
|
||||
|
||||
UPROPERTY(Config)
|
||||
FVector4f PositiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f);
|
||||
|
||||
@@ -151,6 +151,12 @@ public:
|
||||
UPROPERTY(Category = "Cheats", EditAnywhere)
|
||||
FGameplayTag PositiveEffectTag;
|
||||
|
||||
UPROPERTY(Category="Cheats", EditAnywhere)
|
||||
FGameplayTag NegativeAbilityTag;
|
||||
|
||||
UPROPERTY(Category = "Cheats", EditAnywhere)
|
||||
FGameplayTag PositiveAbilityTag;
|
||||
|
||||
UPROPERTY(Category = "Cheats", EditAnywhere, meta = (TitleProperty = "Name"))
|
||||
TArray<FCogAbilityCheat> PersistentEffects;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "imgui.h"
|
||||
|
||||
|
||||
class UCogAbilityDataAsset;
|
||||
class UGameplayEffect;
|
||||
namespace EGameplayModOp { enum Type : int; }
|
||||
@@ -25,5 +24,6 @@ public:
|
||||
const bool Inline = false,
|
||||
const ImVec4& DefaultColor = ImVec4(0.4f, 0.4f, 0.4f, 1.0f),
|
||||
const ImVec4& MatchColor = ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
|
||||
static void RenderConfigureMessage(TWeakObjectPtr<const UCogAbilityDataAsset> InAsset);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "CogAbilityReplicator.h"
|
||||
#include "CogDebugPluginSubsystem.h"
|
||||
#include "CogAbilitySubsystem.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class COGABILITY_API UCogAbilitySubsystem : public UCogDebugPluginSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
virtual void OnPlayerControllerReady(APlayerController* InController) override
|
||||
{
|
||||
if (InController != nullptr)
|
||||
{
|
||||
ACogAbilityReplicator::Spawn(InController);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -22,10 +22,12 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void ResetConfig() override;
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void PreBegin(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void PostBegin() override;
|
||||
|
||||
virtual void RenderTick(float DeltaTime) override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
@@ -24,11 +24,13 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void ResetConfig() override;
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void PreBegin(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void RenderTick(float DeltaTime);
|
||||
virtual void PostBegin() override;
|
||||
|
||||
virtual void RenderTick(float DeltaTime) override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
|
||||
@@ -16,36 +16,11 @@ class COGABILITY_API FCogAbilityWindow_Cheats : public FCogWindow
|
||||
{
|
||||
typedef FCogWindow Super;
|
||||
|
||||
public:
|
||||
|
||||
virtual void Initialize() override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void GameTick(float DeltaTime);
|
||||
|
||||
virtual void ResetConfig() override;
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
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* SelectedActor, const FCogAbilityCheat& Cheat, bool ApplyToEnemies, bool ApplyToAllies, bool ApplyToControlled);
|
||||
|
||||
virtual const FCogAbilityCheat* FindCheatByName(const FString& CheatName);
|
||||
|
||||
TObjectPtr<const UCogAbilityDataAsset> Asset = nullptr;
|
||||
|
||||
TObjectPtr<UCogAbilityConfig_Cheats> Config = nullptr;
|
||||
|
||||
TObjectPtr<UCogAbilityConfig_Alignment> AlignmentConfig = nullptr;
|
||||
|
||||
bool bHasReappliedCheats = false;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -34,7 +34,9 @@ protected:
|
||||
|
||||
virtual void RenderTick(float DeltaTime) override;
|
||||
|
||||
virtual void ResetConfig() override;
|
||||
virtual void PreBegin(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void PostBegin() override;
|
||||
|
||||
virtual void RenderEffectsTable();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "CogWindow.h"
|
||||
|
||||
class UCogAbilityDataAsset;
|
||||
|
||||
@@ -23,10 +23,12 @@ protected:
|
||||
|
||||
virtual void GetTagContainer(FGameplayTagContainer& TagContainer) {}
|
||||
|
||||
virtual void ResetConfig();
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void PreBegin(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void PostBegin() override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
virtual void RenderTagContainer(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer);
|
||||
@@ -49,7 +51,7 @@ class COGABILITY_API FCogAbilityWindow_OwnedTags : public FCogAbilityWindow_Tags
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void GetTagContainer(FGameplayTagContainer& TagContainer);
|
||||
virtual void GetTagContainer(FGameplayTagContainer& TagContainer) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -62,7 +64,7 @@ class COGABILITY_API FCogAbilityWindow_BlockedTags : public FCogAbilityWindow_Ta
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void GetTagContainer(FGameplayTagContainer& TagContainer);
|
||||
virtual void GetTagContainer(FGameplayTagContainer& TagContainer) override;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -19,11 +19,11 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void ResetConfig() override;
|
||||
|
||||
virtual void RenderHelp() override;
|
||||
|
||||
virtual void RenderTick(float DetlaTime) override;
|
||||
virtual void PreBegin(ImGuiWindowFlags& WindowFlags) override;
|
||||
|
||||
virtual void PostBegin() override;
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
|
||||
@@ -25,5 +25,5 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
TObjectPtr<const UCogAbilityDataAsset> Asset = nullptr;
|
||||
TWeakObjectPtr<const UCogAbilityDataAsset> Asset;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user