diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini index 58fc9cb..5387297 100644 --- a/Config/DefaultInput.ini +++ b/Config/DefaultInput.ini @@ -70,6 +70,7 @@ bEnableLegacyInputScales=True bEnableMotionControls=True bFilterInputByPlatformUser=False bShouldFlushPressedKeysOnViewportFocusLost=True +bEnableDynamicComponentInputBinding=True bAlwaysShowTouchInterface=False bShowConsoleOnFourFingerTap=True bEnableGestureRecognizer=False diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp index b720bbb..c7ab994 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp @@ -66,16 +66,18 @@ void FCogEngineWindow_CommandBindings::RenderContent() { ImGui::PushID(Index); - if (FCogWindowWidgets::KeyBind(KeyBind)) - { - PlayerInput->SaveConfig(); - } - - ImGui::SameLine(); if (FCogWindowWidgets::DeleteArrayItemButton()) { IndexToRemove = Index; } + + ImGui::SameLine(); + + if (FCogWindowWidgets::KeyBind(KeyBind)) + { + PlayerInput->SaveConfig(); + } + ImGui::PopID(); Index++; diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp index ff38308..7ecc5bf 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp @@ -265,19 +265,19 @@ void FCogEngineWindow_Inspector::RenderMenu() ImGui::Separator(); - ImGui::Checkbox("Sort by name", &Config->bSortByName); - ImGui::Checkbox("Show background", &Config->bShowRowBackground); - ImGui::Checkbox("Show borders", &Config->bShowBorders); + ImGui::Checkbox("Sort by Name", &Config->bSortByName); + ImGui::Checkbox("Show Background", &Config->bShowRowBackground); + ImGui::Checkbox("Show Sorders", &Config->bShowBorders); #if WITH_EDITORONLY_DATA - ImGui::Checkbox("Show display name", &Config->bShowDisplayName); - ImGui::Checkbox("Show categories", &Config->bShowCategories); + ImGui::Checkbox("Show Display Name", &Config->bShowDisplayName); + ImGui::Checkbox("Show Categories", &Config->bShowCategories); ImGui::Separator(); - if (ImGui::MenuItem("Collapse all categories", nullptr, false, Config->bShowCategories)) + if (ImGui::MenuItem("Collapse All Categories", nullptr, false, Config->bShowCategories)) { bCollapseAllCategories = true; } - if (ImGui::MenuItem("Expand all categories", nullptr, false, Config->bShowCategories)) + if (ImGui::MenuItem("Expand All Categories", nullptr, false, Config->bShowCategories)) { bExpandAllCategories = true; } diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp index d3fd229..f596bd6 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp @@ -292,22 +292,24 @@ bool FCogWindowWidgets::ComboboxEnum(const char* Label, UEnum* Enum, int64 Curre bool FCogWindowWidgets::CheckBoxState(const char* Label, ECheckBoxState& State) { const char* TooltipText = nullptr; + + int32 Flags = 0; ImVec4 ButtonColor = ImGui::GetStyleColorVec4(ImGuiCol_Button); ImVec4 TextColor = ImGui::GetStyleColorVec4(ImGuiCol_Text); switch (State) { - case ECheckBoxState::Checked: + case ECheckBoxState::Unchecked: { - TooltipText = "Checked"; + TooltipText = "Unchecked"; + Flags = 0; break; } - case ECheckBoxState::Unchecked: + case ECheckBoxState::Checked: { - ButtonColor.w = 0.5f; - TextColor.w = 0.5f; - TooltipText = "Unchecked"; + TooltipText = "Checked"; + Flags = 3; break; } @@ -316,38 +318,27 @@ bool FCogWindowWidgets::CheckBoxState(const char* Label, ECheckBoxState& State) ButtonColor.w = 0.1f; TextColor.w = 0.1f; TooltipText = "Undetermined"; + Flags = 1; break; } } - ImGui::PushStyleColor(ImGuiCol_Text, TextColor); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(ButtonColor.x, ButtonColor.y, ButtonColor.z, ButtonColor.w * 0.6f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(ButtonColor.x, ButtonColor.y, ButtonColor.z, ButtonColor.w * 0.8f)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(ButtonColor.x, ButtonColor.y, ButtonColor.z, ButtonColor.w * 1.0f)); - ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(1.0f, 1.0f, 1.0f, 0.1f)); + ImGui::PushStyleColor(ImGuiCol_Text, TextColor); + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(ButtonColor.x, ButtonColor.y, ButtonColor.z, ButtonColor.w * 0.6f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(ButtonColor.x, ButtonColor.y, ButtonColor.z, ButtonColor.w * 0.8f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(ButtonColor.x, ButtonColor.y, ButtonColor.z, ButtonColor.w * 1.0f)); + ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(ButtonColor.x, ButtonColor.y, ButtonColor.z, ButtonColor.w * 1.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + const bool IsPressed = ImGui::CheckboxFlags(Label, &Flags, 3); - const bool Pressed = ImGui::Button(Label); - - if (State == ECheckBoxState::Unchecked) - { - ImVec2 Pos = ImGui::GetItemRectMin(); - ImVec2 Size = ImGui::GetItemRectSize(); - - ImGui::GetWindowDrawList()->AddLine(ImVec2(Pos.x, Pos.y + Size.y * 0.5f), ImVec2(Pos.x + Size.x, Pos.y + Size.y * 0.5f), IM_COL32(255, 255, 255, 255), 0.0f); - } - - ImGui::PopStyleVar(); - - ImGui::PopStyleColor(5); + ImGui::PopStyleColor(6); if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) { ImGui::SetTooltip(TooltipText); } - if (Pressed) + if (IsPressed) { switch (State) { @@ -357,7 +348,7 @@ bool FCogWindowWidgets::CheckBoxState(const char* Label, ECheckBoxState& State) } } - return Pressed; + return IsPressed; } //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp index ec9197c..617b05f 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp @@ -41,7 +41,7 @@ void FCogAIWindow_Blackboard::RenderContent() { if (ImGui::BeginMenu("Options")) { - ImGui::Checkbox("Sort by name", &Config->bSortByName); + ImGui::Checkbox("Sort by Name", &Config->bSortByName); ImGui::EndMenu(); } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityConfig_Alignment.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityConfig_Alignment.cpp new file mode 100644 index 0000000..1613d9d --- /dev/null +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityConfig_Alignment.cpp @@ -0,0 +1,114 @@ +#include "CogAbilityConfig_Alignment.h" + +#include "AbilitySystemComponent.h" +#include "CogAbilityDataAsset.h" +#include "CogImguiHelper.h" +#include "GameplayEffect.h" + +//-------------------------------------------------------------------------------------------------------------------------- +FVector4f UCogAbilityConfig_Alignment::GetAttributeColor(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) const +{ + const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute); + const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute); + + if (CurrentValue > BaseValue) + { + return PositiveColor; + } + + if (CurrentValue < BaseValue) + { + return NegativeColor; + } + + return NeutralColor; +} + +//-------------------------------------------------------------------------------------------------------------------------- +FVector4f UCogAbilityConfig_Alignment::GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect) const +{ + const FGameplayTagContainer& Tags = Effect.InheritableGameplayEffectTags.CombinedTags; + + if (Tags.HasTag(Asset->NegativeEffectTag)) + { + return NegativeColor; + } + + if (Tags.HasTag(Asset->PositiveEffectTag)) + { + return PositiveColor; + } + + return NeutralColor; +} + +//-------------------------------------------------------------------------------------------------------------------------- +FVector4f UCogAbilityConfig_Alignment::GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const +{ + return GetEffectModifierColor(ModSpec.GetEvaluatedMagnitude(), ModInfo.ModifierOp, BaseValue); +} + +//-------------------------------------------------------------------------------------------------------------------------- +FVector4f UCogAbilityConfig_Alignment::GetEffectModifierColor(float ModifierValue, EGameplayModOp::Type ModifierOp, float BaseValue) const +{ + switch (ModifierOp) + { + case EGameplayModOp::Additive: + { + if (ModifierValue > 0.0f) + { + return PositiveColor; + } + + if (ModifierValue < 0.0f) + { + return NegativeColor; + } + break; + } + + case EGameplayModOp::Multiplicitive: + { + if (ModifierValue > 1.0f) + { + return PositiveColor; + } + else if (ModifierValue < 1.0f) + { + return NegativeColor; + } + break; + } + + case EGameplayModOp::Division: + { + if (ModifierValue < 1.0f) + { + return PositiveColor; + } + + if (ModifierValue > 1.0f) + { + return NegativeColor; + } + break; + } + + case EGameplayModOp::Override: + { + if (ModifierValue > BaseValue) + { + return PositiveColor; + } + + if (ModifierValue < BaseValue) + { + return NegativeColor; + } + break; + } + } + + return NeutralColor; +} + diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp index 3d76ae8..4d6e349 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp @@ -1,8 +1,9 @@ #include "CogAbilityHelper.h" -#include "GameplayEffect.h" #include "CogAbilityDataAsset.h" #include "CogImguiHelper.h" +#include "GameplayEffect.h" +#include "GameplayTagContainer.h" #include "imgui.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -13,115 +14,13 @@ FString FCogAbilityHelper::CleanupName(FString Str) return Str; } - //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogAbilityHelper::GetAttributeColor(const UCogAbilityDataAsset* Asset, float BaseValue, float CurrentValue) +void FCogAbilityHelper::RenderTagContainer(const FGameplayTagContainer& Container) { - FLinearColor Color = FLinearColor::White; - if (Asset != nullptr) + TArray GameplayTags; + Container.GetGameplayTagArray(GameplayTags); + for (FGameplayTag Tag : GameplayTags) { - if (CurrentValue > BaseValue) - { - Color = Asset->PositiveEffectColor; - } - else if (CurrentValue < BaseValue) - { - Color = Asset->NegativeEffectColor; - } - else - { - Color = Asset->NeutralEffectColor; - } + ImGui::Text("%s", TCHAR_TO_ANSI(*Tag.ToString())); } - - return FCogImguiHelper::ToImVec4(Color); -} - -//-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogAbilityHelper::GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect) -{ - FLinearColor Color = FLinearColor::White; - - if (Asset != nullptr) - { - const FGameplayTagContainer& Tags = Effect.InheritableGameplayEffectTags.CombinedTags; - - if (Tags.HasTag(Asset->NegativeEffectTag)) - { - Color = Asset->NegativeEffectColor; - } - else if (Tags.HasTag(Asset->PositiveEffectTag)) - { - Color = Asset->PositiveEffectColor; - } - else - { - Color = Asset->NeutralEffectColor; - } - } - - return FCogImguiHelper::ToImVec4(Color); -} - -//-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogAbilityHelper::GetEffectModifierColor(const UCogAbilityDataAsset* Asset, float ModifierValue, EGameplayModOp::Type ModifierOp, float BaseValue) -{ - FLinearColor Color = Asset->NeutralEffectColor; - - switch (ModifierOp) - { - case EGameplayModOp::Additive: - { - if (ModifierValue > 0.0f) - { - Color = Asset->PositiveEffectColor; - } - else if (ModifierValue < 0.0f) - { - Color = Asset->NegativeEffectColor; - } - break; - } - - case EGameplayModOp::Multiplicitive: - { - if (ModifierValue > 1.0f) - { - Color = Asset->PositiveEffectColor; - } - else if (ModifierValue < 1.0f) - { - Color = Asset->NegativeEffectColor; - } - break; - } - - case EGameplayModOp::Division: - { - if (ModifierValue < 1.0f) - { - Color = Asset->PositiveEffectColor; - } - else if (ModifierValue > 1.0f) - { - Color = Asset->NegativeEffectColor; - } - break; - } - - case EGameplayModOp::Override: - { - if (ModifierValue > BaseValue) - { - Color = Asset->PositiveEffectColor; - } - else if (ModifierValue < BaseValue) - { - Color = Asset->NegativeEffectColor; - } - break; - } - } - - return FCogImguiHelper::ToImVec4(Color); } \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp index 7983d3f..4b37b28 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp @@ -19,6 +19,7 @@ void FCogAbilityWindow_Abilities::Initialize() bHasMenu = true; Asset = GetAsset(); + Config = GetConfig(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -32,6 +33,14 @@ void FCogAbilityWindow_Abilities::RenderHelp() , TCHAR_TO_ANSI(*GetNameSafe(Asset.Get()))); } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::ResetConfig() +{ + Super::ResetConfig(); + + Config->Reset(); +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Abilities::RenderTick(float DetlaTime) { @@ -112,31 +121,58 @@ void FCogAbilityWindow_Abilities::RenderAbiltiesMenu(AActor* Selection) { if (ImGui::BeginMenuBar()) { - if (ImGui::BeginMenu("Give Ability")) + if (ImGui::BeginMenu("Options")) { - if (Asset != nullptr) + if (ImGui::BeginMenu("Give Ability")) { - int Index = 0; - for (TSubclassOf AbilityClass : Asset->Abilities) + if (Asset != nullptr) { - ImGui::PushID(Index); - - if (ImGui::MenuItem(TCHAR_TO_ANSI(*GetNameSafe(AbilityClass)))) + int Index = 0; + for (TSubclassOf AbilityClass : Asset->Abilities) { - if (ACogAbilityReplicator* Replicator = ACogAbilityReplicator::GetLocalReplicator(*GetWorld())) - { - Replicator->GiveAbility(Selection, AbilityClass); - } - } + ImGui::PushID(Index); - ImGui::PopID(); - Index++; + if (ImGui::MenuItem(TCHAR_TO_ANSI(*GetNameSafe(AbilityClass)))) + { + if (ACogAbilityReplicator* Replicator = ACogAbilityReplicator::GetLocalReplicator(*GetWorld())) + { + Replicator->GiveAbility(Selection, AbilityClass); + } + } + + ImGui::PopID(); + Index++; + } } + + ImGui::EndMenu(); + } + + ImGui::Separator(); + + ImGui::Checkbox("Sort by Name", &Config->SortByName); + ImGui::Checkbox("Show Active", &Config->ShowActive); + ImGui::Checkbox("Show Inactive", &Config->ShowInactive); + ImGui::Checkbox("Show Blocked", &Config->ShowBlocked); + + ImGui::Separator(); + + ImGui::ColorEdit4("Active Color", (float*)&Config->ActiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Inactive Color", (float*)&Config->InactiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Blocked Color", (float*)&Config->BlockedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + + ImGui::Separator(); + + if (ImGui::MenuItem("Reset")) + { + ResetConfig(); } ImGui::EndMenu(); } + FCogWindowWidgets::MenuSearchBar(Filter); + ImGui::EndMenuBar(); } } @@ -146,19 +182,75 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& { TArray& Abilities = AbilitySystemComponent.GetActivatableAbilities(); - if (ImGui::BeginTable("Abilities", 5, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersH | ImGuiTableFlags_NoBordersInBody)) + TArray FitleredAbilities; + + for (FGameplayAbilitySpec& Spec: Abilities) + { + const UGameplayAbility* Ability = Spec.GetPrimaryInstance(); + if (Ability == nullptr) + { + Ability = Spec.Ability; + } + + const bool IsJustBlocked = Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false; + const bool IsJustActive = Spec.IsActive() && IsJustBlocked == false; + const bool IsJustInactive = Spec.IsActive() == false && IsJustBlocked == false; + + if (Config->ShowBlocked == false && IsJustBlocked) + { + continue; + } + + if (Config->ShowActive == false && IsJustActive) + { + continue; + } + + if (Config->ShowInactive == false && IsJustInactive) + { + continue; + } + + const char* AbilityName = TCHAR_TO_ANSI(*GetAbilityName(Ability)); + if (Filter.PassFilter(AbilityName) == false) + { + continue; + } + + FitleredAbilities.Add(Spec); + } + + if (Config->SortByName) + { + FitleredAbilities.Sort([](const FGameplayAbilitySpec& Lhs, const FGameplayAbilitySpec& Rhs) + { + return Lhs.Ability.GetName().Compare(Rhs.Ability.GetName()) < 0; + }); + } + + if (ImGui::BeginTable("Abilities", 6, ImGuiTableFlags_SizingFixedFit + | ImGuiTableFlags_Resizable + | ImGuiTableFlags_NoBordersInBodyUntilResize + | ImGuiTableFlags_ScrollY + | ImGuiTableFlags_RowBg + | ImGuiTableFlags_BordersOuter + | ImGuiTableFlags_BordersV + | ImGuiTableFlags_Reorderable + | ImGuiTableFlags_Hideable)) { ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupScrollFreeze(0, 1); ImGui::TableSetupColumn("Ability"); ImGui::TableSetupColumn("Level"); ImGui::TableSetupColumn("Input"); ImGui::TableSetupColumn("Cooldown"); + ImGui::TableSetupColumn("Blocked"); ImGui::TableHeadersRow(); static int SelectedIndex = -1; int Index = 0; - for (FGameplayAbilitySpec& Spec : Abilities) + for (FGameplayAbilitySpec& Spec : FitleredAbilities) { UGameplayAbility* Ability = Spec.GetPrimaryInstance(); if (Ability == nullptr) @@ -170,11 +262,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& ImGui::PushID(Index); - ImVec4 Color(1.0f, 1.0f, 1.0f, 1.0f); - if (Asset != nullptr) - { - Color = FCogImguiHelper::ToImVec4(Spec.ActiveCount > 0 ? Asset->AbilityActiveColor : Asset->AbilityInactiveColor); - } + const ImVec4 Color = GetAbilityColor(AbilitySystemComponent, Spec); ImGui::PushStyleColor(ImGuiCol_Text, Color); //------------------------ @@ -221,8 +309,6 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& //------------------------ RenderAbilityContextMenu(AbilitySystemComponent, Spec, Index); - ImGui::PushStyleColor(ImGuiCol_Text, Color); - //------------------------ // Level //------------------------ @@ -244,7 +330,15 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& ImGui::TableNextColumn(); RenderAbilityCooldown(AbilitySystemComponent, *Ability); - ImGui::PopStyleColor(1); + //------------------------ + // Blocked + //------------------------ + ImGui::TableNextColumn(); + const bool IsBlocked = Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false; + if (IsBlocked) + { + ImGui::Text("Blocked"); + } ImGui::PopID(); Index++; @@ -349,11 +443,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen ImGui::TableSetupColumn("Property"); ImGui::TableSetupColumn("Value"); - ImVec4 Color(1.0f, 1.0f, 1.0f, 1.0f); - if (Asset != nullptr) - { - Color = FCogImguiHelper::ToImVec4(Spec.ActiveCount > 0 ? Asset->AbilityActiveColor : Asset->AbilityInactiveColor); - } + const ImVec4 Color = GetAbilityColor(AbilitySystemComponent, Spec); //------------------------ // Name @@ -435,6 +525,20 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen ImGui::TableNextColumn(); ImGui::Text("%d", Spec.InputPressed); + //------------------------ + // AbilityTags + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "AbilityTags"); + ImGui::TableNextColumn(); + const bool SatisfyTagRequirements = Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent); + FCogAbilityHelper::RenderTagContainer(Ability->AbilityTags); + + //--------------------------------------------- + // TODO: find a way to display blocking tags + //--------------------------------------------- + ImGui::EndTable(); } } @@ -505,4 +609,26 @@ void FCogAbilityWindow_Abilities::DeactivateAbility(UAbilitySystemComponent& Abi { Spec.InputPressed = false; AbilitySystemComponent.CancelAbilityHandle(Spec.Handle); +} + +//-------------------------------------------------------------------------------------------------------------------------- +ImVec4 FCogAbilityWindow_Abilities::GetAbilityColor(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec) +{ + UGameplayAbility* Ability = Spec.GetPrimaryInstance(); + if (Ability == nullptr) + { + Ability = Spec.Ability; + } + + if (Spec.IsActive()) + { + return FCogImguiHelper::ToImVec4(Config->ActiveColor); + } + + if (Ability != nullptr && Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false) + { + return FCogImguiHelper::ToImVec4(Config->BlockedColor); + } + + return FCogImguiHelper::ToImVec4(Config->InactiveColor); } \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp index f11ba7f..68f7706 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp @@ -2,6 +2,7 @@ #include "AbilitySystemComponent.h" #include "AbilitySystemGlobals.h" +#include "CogAbilityConfig_Alignment.h" #include "CogAbilityDataAsset.h" #include "CogAbilityHelper.h" #include "CogImguiHelper.h" @@ -18,8 +19,8 @@ void FCogAbilityWindow_Attributes::Initialize() bHasMenu = true; - Asset = GetAsset(); Config = GetConfig(); + AlignmentConfig = GetConfig(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -57,10 +58,19 @@ void FCogAbilityWindow_Attributes::RenderContent() { if (ImGui::BeginMenu("Options")) { - ImGui::Checkbox("Sort by name", &Config->SortByName); - ImGui::Checkbox("Group by attribute set", &Config->GroupByAttributeSet); - ImGui::Checkbox("Group by category", &Config->GroupByCategory); + ImGui::Checkbox("Sort by Name", &Config->SortByName); + ImGui::Checkbox("Group by Attribute Set", &Config->GroupByAttributeSet); + ImGui::Checkbox("Group by Category", &Config->GroupByCategory); ImGui::Checkbox("Show Only Modified", &Config->ShowOnlyModified); + 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(); } @@ -214,24 +224,8 @@ void FCogAbilityWindow_Attributes::RenderContent() ImGui::TableNextRow(); - FLinearColor Color = FLinearColor::White; - if (Asset != nullptr) - { - if (CurrentValue > BaseValue) - { - Color = Asset->PositiveEffectColor; - } - else if (CurrentValue < BaseValue) - { - Color = Asset->NegativeEffectColor; - } - else - { - Color = Asset->NeutralEffectColor; - } - } - - ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Color)); + const ImVec4 Color = FCogImguiHelper::ToImVec4(AlignmentConfig->GetAttributeColor(*AbilitySystemComponent, Attribute)); + ImGui::PushStyleColor(ImGuiCol_Text, Color); //------------------------ // Name @@ -255,7 +249,7 @@ void FCogAbilityWindow_Attributes::RenderContent() FCogWindowWidgets::EndTableTooltip(); } - ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Color)); + ImGui::PushStyleColor(ImGuiCol_Text, Color); //------------------------ // Base Value @@ -330,7 +324,7 @@ void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone ImGui::TableNextColumn(); ImGui::TextColored(TextColor, "Current Value"); ImGui::TableNextColumn(); - ImGui::PushStyleColor(ImGuiCol_Text, GetAttributeColor(AbilitySystemComponent, Attribute)); + ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(AlignmentConfig->GetAttributeColor(AbilitySystemComponent, Attribute))); ImGui::Text("%0.2f", CurrentValue); ImGui::PopStyleColor(1); @@ -361,7 +355,7 @@ void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone 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(GetEffectModifierColor(ModSpec, ModInfo, BaseValue), "%0.2f", ModSpec.GetEvaluatedMagnitude()); + ImGui::TextColored(FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectModifierColor(ModSpec, ModInfo, BaseValue)), "%0.2f", ModSpec.GetEvaluatedMagnitude()); } } } @@ -369,19 +363,3 @@ void FCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone ImGui::EndTable(); } } - -//-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogAbilityWindow_Attributes::GetAttributeColor(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) const -{ - const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute); - const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute); - ImVec4 Color = FCogAbilityHelper::GetAttributeColor(Asset.Get(), BaseValue, CurrentValue); - return Color; -} - -//-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogAbilityWindow_Attributes::GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const -{ - const float ModValue = ModSpec.GetEvaluatedMagnitude(); - return FCogAbilityHelper::GetEffectModifierColor(Asset.Get(), ModSpec.GetEvaluatedMagnitude(), ModInfo.ModifierOp, BaseValue); -} \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp index a28eeae..edf6cf1 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp @@ -1,6 +1,7 @@ #include "CogAbilityWindow_Cheats.h" #include "AbilitySystemGlobals.h" +#include "CogAbilityConfig_Alignment.h" #include "CogAbilityDataAsset.h" #include "CogAbilityReplicator.h" #include "CogCommonAllegianceActorInterface.h" @@ -22,6 +23,7 @@ void FCogAbilityWindow_Cheats::Initialize() Asset = GetAsset(); Config = GetConfig(); + AlignmentConfig = GetConfig(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -44,6 +46,7 @@ void FCogAbilityWindow_Cheats::ResetConfig() Super::ResetConfig(); Config->Reset(); + AlignmentConfig->Reset(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -159,6 +162,18 @@ void FCogAbilityWindow_Cheats::RenderContent() { 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(); } @@ -228,26 +243,14 @@ bool FCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte return false; } + const UGameplayEffect* EffectCDO = Cheat.Effect->GetDefaultObject(); + + if (EffectCDO != nullptr) + { + FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectColor(Asset, *EffectCDO))); + } + bool bIsPressed = false; - - const FGameplayTagContainer& Tags = Cheat.Effect->GetDefaultObject()->InheritableGameplayEffectTags.CombinedTags; - - FLinearColor Color; - if (Tags.HasTag(Asset->NegativeEffectTag)) - { - Color = Asset->NegativeEffectColor; - } - else if (Tags.HasTag(Asset->PositiveEffectTag)) - { - Color = Asset->PositiveEffectColor; - } - else - { - Color = Asset->NeutralEffectColor; - } - - FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Color)); - if (IsPersistent) { bool isEnabled = ACogAbilityReplicator::IsCheatActive(SelectedActor, Cheat); @@ -280,7 +283,10 @@ bool FCogAbilityWindow_Cheats::AddCheat(AActor* ControlledActor, AActor* Selecte ImGui::EndTooltip(); } - FCogWindowWidgets::PopBackColor(); + if (EffectCDO != nullptr) + { + FCogWindowWidgets::PopBackColor(); + } return bIsPressed; } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp index 74f72d5..43ed693 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp @@ -3,6 +3,7 @@ #include "AbilitySystemComponent.h" #include "AbilitySystemGlobals.h" #include "AttributeSet.h" +#include "CogAbilityConfig_Alignment.h" #include "CogAbilityDataAsset.h" #include "CogAbilityHelper.h" #include "CogImguiHelper.h" @@ -16,9 +17,11 @@ void FCogAbilityWindow_Effects::Initialize() { Super::Initialize(); - bHasMenu = false; + bHasMenu = true; Asset = GetAsset(); + Config = GetConfig(); + AlignmentConfig = GetConfig(); } //-------------------------------------------------------------------------------------------------------------------------- @@ -30,11 +33,53 @@ void FCogAbilityWindow_Effects::RenderHelp() ); } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Effects::ResetConfig() +{ + Super::ResetConfig(); + + Config->Reset(); + AlignmentConfig->Reset(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Effects::RenderTick(float DetlaTime) +{ + Super::RenderTick(DetlaTime); + + RenderOpenEffects(); +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderContent() { Super::RenderContent(); + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("Options")) + { + ImGui::Checkbox("Sort by Name", &Config->SortByName); + 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::Separator(); + if (ImGui::MenuItem("Reset")) + { + ResetConfig(); + } + ImGui::EndMenu(); + } + + FCogWindowWidgets::MenuSearchBar(Filter); + + ImGui::EndMenuBar(); + } + RenderEffectsTable(); } @@ -47,30 +92,86 @@ void FCogAbilityWindow_Effects::RenderEffectsTable() return; } - ImGui::BeginTable("Effects", 4, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersH | ImGuiTableFlags_NoBordersInBody); - ImGui::TableSetupColumn("Effect"); - ImGui::TableSetupColumn("Remaining Time"); - ImGui::TableSetupColumn("Stacks"); - ImGui::TableSetupColumn("Prediction"); - ImGui::TableHeadersRow(); - - static int SelectedIndex = -1; - int Index = 0; - - FGameplayEffectQuery Query; - for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent->GetActiveEffects(Query)) + if (ImGui::BeginTable("Effects", 4, ImGuiTableFlags_SizingFixedFit + | ImGuiTableFlags_Resizable + | ImGuiTableFlags_NoBordersInBodyUntilResize + | ImGuiTableFlags_ScrollY + | ImGuiTableFlags_RowBg + | ImGuiTableFlags_BordersOuter + | ImGuiTableFlags_BordersV + | ImGuiTableFlags_Reorderable + | ImGuiTableFlags_Hideable)) { - RenderEffectRow(*AbilitySystemComponent, ActiveHandle, Index, SelectedIndex); - } - ImGui::EndTable(); + ImGui::TableSetupScrollFreeze(0, 1); + ImGui::TableSetupColumn("Effect"); + ImGui::TableSetupColumn("Remaining Time"); + ImGui::TableSetupColumn("Stacks"); + ImGui::TableSetupColumn("Prediction"); + ImGui::TableHeadersRow(); + + static int SelectedIndex = -1; + int Index = 0; + + FGameplayEffectQuery Query; + TArray Effects = AbilitySystemComponent->GetActiveEffects(Query); + + if (Config->SortByName || Config->SortByAlignment) + { + Effects.Sort([&](const FActiveGameplayEffectHandle& Handle1, const FActiveGameplayEffectHandle& Handle2) + { + const FActiveGameplayEffect* ActiveEffect1 = AbilitySystemComponent->GetActiveGameplayEffect(Handle1); + const FActiveGameplayEffect* ActiveEffect2 = AbilitySystemComponent->GetActiveGameplayEffect(Handle2); + const UGameplayEffect* Effect1 = ActiveEffect1 != nullptr ? ActiveEffect1->Spec.Def : nullptr; + const UGameplayEffect* Effect2 = ActiveEffect2 != nullptr ? ActiveEffect2->Spec.Def : nullptr; + + bool NameOrder = false; + if (Config->SortByName) + { + const FString EffectName1 = GetEffectNameSafe(Effect1); + const FString EffectName2 = GetEffectNameSafe(Effect2); + NameOrder = EffectName1.Compare(EffectName2) < 0; + if (Config->SortByAlignment == false) + { + return NameOrder; + } + } + + bool AlignmentOrder = false; + if (Config->SortByAlignment) + { + const FGameplayTagContainer& Tags1 = Effect1->InheritableGameplayEffectTags.CombinedTags; + const FGameplayTagContainer& Tags2 = Effect2->InheritableGameplayEffectTags.CombinedTags; + const int32 Pos1 = Tags1.HasTag(Asset->PositiveEffectTag) ? 1 : Tags1.HasTag(Asset->NegativeEffectTag) ? -1 : 0; + const int32 Pos2 = Tags2.HasTag(Asset->PositiveEffectTag) ? 1 : Tags2.HasTag(Asset->NegativeEffectTag) ? -1 : 0; + const int32 Diff = Pos2 - Pos1; + if (Diff == 0) + { + return NameOrder; + } + + return Diff < 0; + } + + return false; + }); + } + + for (const FActiveGameplayEffectHandle& ActiveHandle : Effects) + { + ImGui::PushID(Index); + RenderEffectRow(*AbilitySystemComponent, ActiveHandle, Index, SelectedIndex); + ImGui::PopID(); + Index++; + } + + ImGui::EndTable(); + } } //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected) { - ImGui::PushID(Index); - const FActiveGameplayEffect* ActiveEffectPtr = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle); if (ActiveEffectPtr == nullptr) { @@ -86,6 +187,13 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A const FActiveGameplayEffect& ActiveEffect = *ActiveEffectPtr; const UGameplayEffect& Effect = *EffectPtr; + const char* EffectName = TCHAR_TO_ANSI(*GetEffectName(Effect)); + if (Filter.PassFilter(EffectName) == false) + { + return; + } + + ImGui::TableNextRow(ImGuiTableRowFlags_None, 0.0f); //------------------------ @@ -93,9 +201,9 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A //------------------------ ImGui::TableNextColumn(); - ImGui::PushStyleColor(ImGuiCol_Text, GetEffectColor(Effect)); + ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectColor(Asset, Effect))); - if (ImGui::Selectable(TCHAR_TO_ANSI(*GetEffectName(Effect)), Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick)) + if (ImGui::Selectable(EffectName, Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick)) { Selected = Index; } @@ -117,9 +225,17 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A //------------------------ if (ImGui::BeginPopupContextItem()) { - if (ImGui::Button("Open")) + bool bOpen = OpenedEffects.Contains(ActiveHandle); + if (ImGui::Checkbox("Open", &bOpen)) { - //GetOwner()->GetPropertyGrid()->Open(EffectPtr); + if (bOpen) + { + OpenEffect(ActiveHandle); + } + else + { + CloseEffect(ActiveHandle); + } ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); @@ -143,8 +259,7 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A ImGui::TableNextColumn(); RenderPrediction(ActiveEffect, true); - ImGui::PopID(); - Index++; + } //-------------------------------------------------------------------------------------------------------------------------- @@ -218,7 +333,7 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& ImGui::TableNextColumn(); ImGui::TextColored(TextColor, "Dynamic Asset Tags"); ImGui::TableNextColumn(); - RenderTagContainer(ActiveEffect.Spec.GetDynamicAssetTags()); + FCogAbilityHelper::RenderTagContainer(ActiveEffect.Spec.GetDynamicAssetTags()); //------------------------ // All Asset Tags @@ -229,7 +344,7 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& ImGui::TableNextColumn(); FGameplayTagContainer AllAssetTagsContainer; ActiveEffect.Spec.GetAllAssetTags(AllAssetTagsContainer); - RenderTagContainer(AllAssetTagsContainer); + FCogAbilityHelper::RenderTagContainer(AllAssetTagsContainer); //------------------------ // All Granted Tags @@ -240,7 +355,7 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& ImGui::TableNextColumn(); FGameplayTagContainer AllGrantedTagsContainer; ActiveEffect.Spec.GetAllGrantedTags(AllGrantedTagsContainer); - RenderTagContainer(AllGrantedTagsContainer); + FCogAbilityHelper::RenderTagContainer(AllGrantedTagsContainer); //------------------------ // Modifiers @@ -259,24 +374,13 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& ImGui::TableNextColumn(); ImGui::Text("%s", TCHAR_TO_ANSI(*ModInfo.Attribute.GetName())); ImGui::Text("%s", TCHAR_TO_ANSI(*EGameplayModOpToString(ModInfo.ModifierOp))); - ImGui::TextColored(GetEffectModifierColor(ModSpec, ModInfo, AttributeBaseValue), "%0.2f", ModSpec.GetEvaluatedMagnitude()); + ImGui::TextColored(FCogImguiHelper::ToImVec4(AlignmentConfig->GetEffectModifierColor(ModSpec, ModInfo, AttributeBaseValue)), "%0.2f", ModSpec.GetEvaluatedMagnitude()); } ImGui::EndTable(); } } -//-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityWindow_Effects::RenderTagContainer(const FGameplayTagContainer& Container) -{ - TArray GameplayTags; - Container.GetGameplayTagArray(GameplayTags); - for (FGameplayTag Tag : GameplayTags) - { - ImGui::Text("%s", TCHAR_TO_ANSI(*Tag.ToString())); - } -} - //-------------------------------------------------------------------------------------------------------------------------- FString FCogAbilityWindow_Effects::GetEffectName(const UGameplayEffect& Effect) { @@ -284,6 +388,17 @@ FString FCogAbilityWindow_Effects::GetEffectName(const UGameplayEffect& Effect) return Str; } +//-------------------------------------------------------------------------------------------------------------------------- +FString FCogAbilityWindow_Effects::GetEffectNameSafe(const UGameplayEffect* Effect) +{ + if (Effect == nullptr) + { + return "none"; + } + + return GetEffectName(*Effect); +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect) { @@ -344,15 +459,58 @@ void FCogAbilityWindow_Effects::RenderPrediction(const FActiveGameplayEffect& Ac } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogAbilityWindow_Effects::GetEffectColor(const UGameplayEffect& Effect) const +void FCogAbilityWindow_Effects::OpenEffect(const FActiveGameplayEffectHandle& Handle) { - return FCogAbilityHelper::GetEffectColor(Asset.Get(), Effect); + OpenedEffects.AddUnique(Handle); } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogAbilityWindow_Effects::GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const +void FCogAbilityWindow_Effects::CloseEffect(const FActiveGameplayEffectHandle& Handle) { - const float ModValue = ModSpec.GetEvaluatedMagnitude(); - return FCogAbilityHelper::GetEffectModifierColor(Asset.Get(), ModSpec.GetEvaluatedMagnitude(), ModInfo.ModifierOp, BaseValue); + OpenedEffects.Remove(Handle); } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Effects::RenderOpenEffects() +{ + AActor* Selection = GetSelection(); + if (Selection == nullptr) + { + return; + } + + UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true); + if (AbilitySystemComponent == nullptr) + { + return; + } + + for (int i = OpenedEffects.Num() - 1; i >= 0; --i) + { + FActiveGameplayEffectHandle Handle = OpenedEffects[i]; + + const FActiveGameplayEffect* ActiveEffectPtr = AbilitySystemComponent->GetActiveGameplayEffect(Handle); + if (ActiveEffectPtr == nullptr) + { + return; + } + + const UGameplayEffect* Effect = ActiveEffectPtr->Spec.Def; + if (Effect == nullptr) + { + return; + } + + bool Open = true; + if (ImGui::Begin(TCHAR_TO_ANSI(*GetEffectName(*Effect)), &Open)) + { + RenderEffectInfo(*AbilitySystemComponent, *ActiveEffectPtr, *Effect); + ImGui::End(); + } + + if (Open == false) + { + OpenedEffects.RemoveAt(i); + } + } +} diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig.h deleted file mode 100644 index daccc12..0000000 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -//#include "CoreMinimal.h" -//#include "CogAbilityModule.h" -//#include "CogAbilityConfig.generated.h" -// -//USTRUCT() -//struct FCogAbilityAttributesConfig -//{ -// GENERATED_BODY() -// -//public: -// -// UPROPERTY(Config) -// bool SortByName = true; -// -// UPROPERTY(Config) -// bool GroupByAttributeSet = false; -// -// UPROPERTY(Config) -// bool GroupByCategory = false; -// -// UPROPERTY(Config) -// bool ShowOnlyModified = false; -// -// void Reset() -// { -// SortByName = true; -// GroupByAttributeSet = false; -// GroupByCategory = false; -// ShowOnlyModified = false; -// } -//}; -// -//UCLASS(Config = Cog) -//class COGABILITY_API UCogAbilityConfig : public UObject -//{ -// GENERATED_BODY() -// -//public: -// -// static inline UCogAbilityConfig* Get() { return FCogAbilityModule::Config; } -// -// UPROPERTY(Config) -// FCogAbilityAttributesConfig Attributes; -// -//}; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig_Alignment.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig_Alignment.h new file mode 100644 index 0000000..fcbb65e --- /dev/null +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig_Alignment.h @@ -0,0 +1,49 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogWindowConfig.h" +#include "CogAbilityConfig_Alignment.generated.h" + +class UAbilitySystemComponent; +class UCogAbilityDataAsset; +class UGameplayEffect; +namespace EGameplayModOp { enum Type; }; +struct FGameplayAttribute; +struct FGameplayModifierInfo; +struct FModifierSpec; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogAbilityConfig_Alignment : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + + FVector4f GetAttributeColor(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) 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; + + + UPROPERTY(Config) + FVector4f PositiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); + + UPROPERTY(Config) + FVector4f NegativeColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + + UPROPERTY(Config) + FVector4f NeutralColor = FVector4f(1.0f, 1.0f, 1.0f, 1.0f); + + virtual void Reset() override + { + Super::Reset(); + + PositiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); + NegativeColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + NeutralColor = FVector4f(1.0f, 1.0f, 1.0f, 1.0f); + } +}; \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityDataAsset.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityDataAsset.h index 737324a..56a96dc 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityDataAsset.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityDataAsset.h @@ -141,12 +141,6 @@ public: UPROPERTY(Category = "Abilities", EditAnywhere) TArray> Abilities; - UPROPERTY(Category = "Abilities", EditAnywhere) - FLinearColor AbilityActiveColor = FLinearColor(1.0f, 0.8f, 0.0f, 1.0f); - - UPROPERTY(Category = "Abilities", EditAnywhere) - FLinearColor AbilityInactiveColor = FLinearColor(1.0f, 1.0f, 1.0f, 1.0f); - //---------------------------------------------------------------------------------------------------------------------- // Cheats //---------------------------------------------------------------------------------------------------------------------- @@ -157,15 +151,6 @@ public: UPROPERTY(Category = "Cheats", EditAnywhere) FGameplayTag PositiveEffectTag; - UPROPERTY(Category = "Cheats", EditAnywhere) - FLinearColor NeutralEffectColor = FLinearColor(0.5f, 0.5f, 0.5f, 1.0f); - - UPROPERTY(Category = "Cheats", EditAnywhere) - FLinearColor NegativeEffectColor = FLinearColor(1.0f, 0.5f, 0.5f, 1.0f); - - UPROPERTY(Category = "Cheats", EditAnywhere) - FLinearColor PositiveEffectColor = FLinearColor(0.0f, 1.0f, 0.5f, 1.0f); - UPROPERTY(Category = "Cheats", EditAnywhere, meta = (TitleProperty = "Name")) TArray PersistentEffects; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityHelper.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityHelper.h index bf2f7e5..c9f59d9 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityHelper.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityHelper.h @@ -3,9 +3,11 @@ #include "CoreMinimal.h" #include "imgui.h" + class UCogAbilityDataAsset; class UGameplayEffect; namespace EGameplayModOp { enum Type; } +struct FGameplayTagContainer; class COGABILITY_API FCogAbilityHelper { @@ -13,9 +15,5 @@ public: static FString CleanupName(FString Str); - static ImVec4 GetAttributeColor(const UCogAbilityDataAsset* Asset, float BaseValue, float CurrentValue); - - static ImVec4 GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect); - - static ImVec4 GetEffectModifierColor(const UCogAbilityDataAsset* Asset, float ModifierValue, EGameplayModOp::Type ModifierOp, float BaseValue); + static void RenderTagContainer(const FGameplayTagContainer& Container); }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h index 89a0752..50bdcd0 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h @@ -2,11 +2,14 @@ #include "CoreMinimal.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "GameplayAbilitySpecHandle.h" +#include "CogAbilityWindow_Abilities.generated.h" class UAbilitySystemComponent; -class UGameplayAbility; +class UCogAbilityConfig_Abilities; class UCogAbilityDataAsset; +class UGameplayAbility; struct FGameplayAbilitySpec; class COGABILITY_API FCogAbilityWindow_Abilities : public FCogWindow @@ -18,6 +21,8 @@ public: virtual void Initialize() override; protected: + + virtual void ResetConfig() override; virtual void RenderHelp() override; @@ -51,7 +56,7 @@ protected: virtual void CloseAbility(const FGameplayAbilitySpecHandle& Handle); -private: + virtual ImVec4 GetAbilityColor(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec); FGameplayAbilitySpecHandle AbilityHandleToActivate; @@ -60,4 +65,51 @@ private: TArray OpenedAbilities; TObjectPtr Asset = nullptr; + + TObjectPtr Config = nullptr; + + ImGuiTextFilter Filter; }; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogAbilityConfig_Abilities : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + + UPROPERTY(Config) + bool SortByName = false; + + UPROPERTY(Config) + bool ShowActive = true; + + UPROPERTY(Config) + bool ShowInactive = true; + + UPROPERTY(Config) + bool ShowBlocked = true; + + UPROPERTY(Config) + FVector4f ActiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); + + UPROPERTY(Config) + FVector4f InactiveColor = FVector4f(1.0f, 1.0f, 1.0f, 1.0f); + + UPROPERTY(Config) + FVector4f BlockedColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + + virtual void Reset() override + { + Super::Reset(); + + SortByName = false; + ShowActive = true; + ShowInactive = true; + ShowBlocked = true; + ActiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); + InactiveColor = FVector4f(1.0f, 1.0f, 1.0f, 1.0f); + BlockedColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + } +}; \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h index 6d50188..9d35a38 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h @@ -6,7 +6,8 @@ #include "CogAbilityWindow_Attributes.generated.h" class UAbilitySystemComponent; -class UCogAbilityDataAsset; +class UCogAbilityConfig_Attributes; +class UCogAbilityConfig_Alignment; struct FGameplayAttribute; struct FModifierSpec; struct FGameplayModifierInfo; @@ -30,17 +31,13 @@ protected: virtual void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute); - virtual ImVec4 GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const; - - virtual ImVec4 GetAttributeColor(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute) const; - private: ImGuiTextFilter Filter; - TObjectPtr Asset = nullptr; - TObjectPtr Config = nullptr; + + TObjectPtr AlignmentConfig = nullptr; }; //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h index 88cc663..7c24f77 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h @@ -6,6 +6,8 @@ #include "CogAbilityWindow_Cheats.generated.h" class AActor; +class UCogAbilityConfig_Alignment; +class UCogAbilityConfig_Cheats; class UCogAbilityDataAsset; struct FCogAbilityCheat; @@ -38,6 +40,8 @@ protected: TObjectPtr Config = nullptr; + TObjectPtr AlignmentConfig = nullptr; + bool bHasReappliedCheats = false; }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h index 0c06385..beb6f57 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h @@ -3,16 +3,20 @@ #include "CoreMinimal.h" #include "GameplayTagContainer.h" #include "CogWindow.h" +#include "CogWindowConfig.h" #include "imgui.h" +#include "CogAbilityWindow_Effects.generated.h" class UAbilitySystemComponent; +class UCogAbilityConfig_Alignment; +class UCogAbilityConfig_Effects; class UCogAbilityDataAsset; class UGameplayEffect; +namespace EGameplayModOp { enum Type; }; struct FActiveGameplayEffect; struct FActiveGameplayEffectHandle; struct FGameplayModifierInfo; struct FModifierSpec; -namespace EGameplayModOp { enum Type; }; //-------------------------------------------------------------------------------------------------------------------------- class COGABILITY_API FCogAbilityWindow_Effects : public FCogWindow @@ -29,14 +33,16 @@ protected: virtual void RenderContent() override; + virtual void RenderTick(float DetlaTime) override; + + virtual void ResetConfig() override; + virtual void RenderEffectsTable(); virtual void RenderEffectRow(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffectHandle& ActiveHandle, int32 Index, int32& Selected); virtual void RenderEffectInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect); - virtual void RenderTagContainer(const FGameplayTagContainer& Container); - virtual void RenderRemainingTime(const UAbilitySystemComponent& AbilitySystemComponent, const FActiveGameplayEffect& ActiveEffect); virtual void RenderStacks(const FActiveGameplayEffect& ActiveEffect, const UGameplayEffect& Effect); @@ -44,10 +50,45 @@ protected: virtual void RenderPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short); virtual FString GetEffectName(const UGameplayEffect& Effect); + + virtual FString GetEffectNameSafe(const UGameplayEffect* Effect); - ImVec4 GetEffectColor(const UGameplayEffect& Effect) const; + virtual void RenderOpenEffects(); - ImVec4 GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const; + virtual void OpenEffect(const FActiveGameplayEffectHandle& Handle); + + virtual void CloseEffect(const FActiveGameplayEffectHandle& Handle); TObjectPtr Asset = nullptr; + + TObjectPtr Config = nullptr; + + TObjectPtr AlignmentConfig = nullptr; + + TArray OpenedEffects; + + ImGuiTextFilter Filter; }; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogAbilityConfig_Effects : public UCogWindowConfig +{ + GENERATED_BODY() + +public: + + UPROPERTY(Config) + bool SortByName = true; + + UPROPERTY(Config) + bool SortByAlignment = true; + + virtual void Reset() override + { + Super::Reset(); + + SortByName = true; + SortByAlignment = true; + } +}; \ No newline at end of file diff --git a/TODO.txt b/TODO.txt index 2ef9bcd..7c47771 100644 --- a/TODO.txt +++ b/TODO.txt @@ -12,6 +12,7 @@ - CogEngine: save active log categories - CogEngine: add menu on the PlotWindow wih the controls - CogEngine: Improve collision window: Add Query Type, Single or Multi, By Channel or Object Type, Object Type. +- CogEngine: Add multi selection to the selection window actor filter (Character+GameState for example). - CogSample: Add a custom window in sample (changing the character faction) - CogSample: Create more abilities