This commit is contained in:
Arnaud Jamin
2023-10-04 09:37:35 -04:00
parent 496439fe20
commit 901b92e70c
50 changed files with 861 additions and 592 deletions
@@ -9,6 +9,17 @@
ImVec4 ActiveColor(1.0f, 0.8f, 0.0f, 1.0f);
ImVec4 DeactiveColor(1.0f, 1.0f, 1.0f, 1.0f);
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Abilities::RenderHelp()
{
ImGui::Text(
"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(AbilitiesAsset.Get())));
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Abilities::PreRender(ImGuiWindowFlags& WindowFlags)
{
@@ -107,7 +118,7 @@ void UCogAbilityWindow_Abilities::RenderAbiltiesMenu(AActor* Selection)
{
if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("Add"))
if (ImGui::BeginMenu("Give Ability"))
{
if (AbilitiesAsset != nullptr)
{
@@ -9,8 +9,15 @@
#include "GameFramework/Character.h"
//--------------------------------------------------------------------------------------------------------------------------
UCogAbilityWindow_Attributes::UCogAbilityWindow_Attributes()
void UCogAbilityWindow_Attributes::RenderHelp()
{
ImGui::Text(
"This window display the gameplay attributes of the selected actor. "
"Attributes can be sorted by name, category or attribute set. "
"Attributes with the Current value greater than the Base value are displayed in green. "
"Attributes with the Current value lower than the Base value are displayed in red. "
"Use the options 'Show Only Modified' to only show the attributes that have modifiers. "
);
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -19,98 +26,6 @@ void UCogAbilityWindow_Attributes::PreRender(ImGuiWindowFlags& WindowFlags)
WindowFlags = ImGuiWindowFlags_MenuBar;
}
//--------------------------------------------------------------------------------------------------------------------------
static void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute)
{
if (ImGui::BeginTable("Attribute", 2, ImGuiTableFlags_Borders))
{
const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
ImGui::TableSetupColumn("Property");
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute);
const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute);
ImVec4 Color;
if (CurrentValue > BaseValue)
{
Color = ImVec4(0.0f, 1.0f, 0.0f, 1.0f);
}
else if (CurrentValue < BaseValue)
{
Color = ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
}
else
{
Color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
}
//------------------------
// Name
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Name");
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*Attribute.GetName()));
//------------------------
// Base Value
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Base Value");
ImGui::TableNextColumn();
ImGui::Text("%0.2f", BaseValue);
//------------------------
// Current Value
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Current Value");
ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Text, Color);
ImGui::Text("%0.2f", CurrentValue);
ImGui::PopStyleColor(1);
//------------------------
// Modifiers
//------------------------
FGameplayEffectQuery Query;
for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent.GetActiveEffects(Query))
{
const FActiveGameplayEffect* ActiveEffect = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle);
if (ActiveEffect == nullptr)
{
continue;
}
for (int32 i = 0; i < ActiveEffect->Spec.Modifiers.Num(); ++i)
{
const FModifierSpec& ModSpec = ActiveEffect->Spec.Modifiers[i];
const FGameplayModifierInfo& ModInfo = ActiveEffect->Spec.Def->Modifiers[i];
if (ModInfo.Attribute == Attribute)
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Effect");
ImGui::TextColored(TextColor, "Operation");
ImGui::TextColored(TextColor, "Magnitude");
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*FCogAbilityHelper::CleanupName(GetNameSafe(ActiveEffect->Spec.Def))));
ImGui::Text("%s", TCHAR_TO_ANSI(*EGameplayModOpToString(ModInfo.ModifierOp)));
ImGui::Text("%0.2f", ModSpec.GetEvaluatedMagnitude());
}
}
}
ImGui::EndTable();
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Attributes::RenderContent()
{
@@ -348,4 +263,97 @@ void UCogAbilityWindow_Attributes::RenderContent()
ImGui::EndTable();
}
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute)
{
if (ImGui::BeginTable("Attribute", 2, ImGuiTableFlags_Borders))
{
const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f);
ImGui::TableSetupColumn("Property");
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch);
const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute);
const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute);
ImVec4 Color;
if (CurrentValue > BaseValue)
{
Color = ImVec4(0.0f, 1.0f, 0.0f, 1.0f);
}
else if (CurrentValue < BaseValue)
{
Color = ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
}
else
{
Color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
}
//------------------------
// Name
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Name");
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*Attribute.GetName()));
//------------------------
// Base Value
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Base Value");
ImGui::TableNextColumn();
ImGui::Text("%0.2f", BaseValue);
//------------------------
// Current Value
//------------------------
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Current Value");
ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Text, Color);
ImGui::Text("%0.2f", CurrentValue);
ImGui::PopStyleColor(1);
//------------------------
// Modifiers
//------------------------
FGameplayEffectQuery Query;
for (const FActiveGameplayEffectHandle& ActiveHandle : AbilitySystemComponent.GetActiveEffects(Query))
{
const FActiveGameplayEffect* ActiveEffect = AbilitySystemComponent.GetActiveGameplayEffect(ActiveHandle);
if (ActiveEffect == nullptr)
{
continue;
}
for (int32 i = 0; i < ActiveEffect->Spec.Modifiers.Num(); ++i)
{
const FModifierSpec& ModSpec = ActiveEffect->Spec.Modifiers[i];
const FGameplayModifierInfo& ModInfo = ActiveEffect->Spec.Def->Modifiers[i];
if (ModInfo.Attribute == Attribute)
{
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::TextColored(TextColor, "Effect");
ImGui::TextColored(TextColor, "Operation");
ImGui::TextColored(TextColor, "Magnitude");
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*FCogAbilityHelper::CleanupName(GetNameSafe(ActiveEffect->Spec.Def))));
ImGui::Text("%s", TCHAR_TO_ANSI(*EGameplayModOpToString(ModInfo.ModifierOp)));
ImGui::Text("%0.2f", ModSpec.GetEvaluatedMagnitude());
}
}
}
ImGui::EndTable();
}
}
@@ -9,6 +9,20 @@
#include "imgui.h"
#include "imgui_internal.h"
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_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(CheatsAsset.Get()))
);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Cheats::RenderContent()
{
@@ -8,6 +8,15 @@
#include "EngineUtils.h"
#include "GameFramework/Character.h"
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Effects::RenderHelp()
{
ImGui::Text(
"This window displays the gameplay effects of the selected actor. "
"Mouse over an effect to see its details such as its modifiers and the gameplay tags it grants"
);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Effects::PreRender(ImGuiWindowFlags& WindowFlags)
{
@@ -300,7 +309,7 @@ void UCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponen
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255));
ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 100));
ImGui::ProgressBar(RemainingTime / Duration, ImVec2(FCogWindowWidgets::TextBaseWidth * 15, FCogWindowWidgets::TextBaseHeight * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%.2f / %.2f"), RemainingTime, Duration)));
ImGui::ProgressBar(RemainingTime / Duration, ImVec2(FCogWindowWidgets::GetFontWidth() * 15, ImGui::GetTextLineHeightWithSpacing() * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%.2f / %.2f"), RemainingTime, Duration)));
ImGui::PopStyleColor(2);
}
}
@@ -318,7 +327,7 @@ void UCogAbilityWindow_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::TextBaseWidth * 15, FCogWindowWidgets::TextBaseHeight * 0.8f), TCHAR_TO_ANSI(*FString::Printf(TEXT("%d / %d"), CurrentStackCount, Effect.StackLimitCount)));
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::PopStyleColor(2);
}
}
@@ -4,48 +4,13 @@
#include "CogImguiHelper.h"
//--------------------------------------------------------------------------------------------------------------------------
UCogAbilityWindow_Pools::UCogAbilityWindow_Pools()
void UCogAbilityWindow_Pools::RenderHelp()
{
}
//--------------------------------------------------------------------------------------------------------------------------
void DrawPool(const UAbilitySystemComponent* AbilitySystemComponent, const FCogAbilityPool& Pool)
{
if (AbilitySystemComponent->HasAttributeSetForAttribute(Pool.Max) == false)
{
return;
}
if (AbilitySystemComponent->HasAttributeSetForAttribute(Pool.Value) == false)
{
return;
}
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*Pool.Name));
const float Value = AbilitySystemComponent->GetNumericAttribute(Pool.Value);
const float Max = AbilitySystemComponent->GetNumericAttribute(Pool.Max);
//-------------------------------------------------------------------------------------------
// 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
char Buffer[64];
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);
ImGui::PopStyleColor(2);
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(PoolsAsset.Get()))
);
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -77,3 +42,44 @@ void UCogAbilityWindow_Pools::RenderContent()
ImGui::EndTable();
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Pools::DrawPool(const UAbilitySystemComponent* AbilitySystemComponent, const FCogAbilityPool& Pool)
{
if (AbilitySystemComponent->HasAttributeSetForAttribute(Pool.Max) == false)
{
return;
}
if (AbilitySystemComponent->HasAttributeSetForAttribute(Pool.Value) == false)
{
return;
}
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Text("%s", TCHAR_TO_ANSI(*Pool.Name));
const float Value = AbilitySystemComponent->GetNumericAttribute(Pool.Value);
const float Max = AbilitySystemComponent->GetNumericAttribute(Pool.Max);
//-------------------------------------------------------------------------------------------
// 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
char Buffer[64];
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);
ImGui::PopStyleColor(2);
}
@@ -5,7 +5,37 @@
#include "CogWindowWidgets.h"
//--------------------------------------------------------------------------------------------------------------------------
static void DrawTagInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag)
void UCogAbilityWindow_Tags::RenderHelp()
{
ImGui::Text("This window displays gameplay tags of the selected actor. ");
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Tags::PreRender(ImGuiWindowFlags& WindowFlags)
{
Super::PreRender(WindowFlags);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Tags::RenderContent()
{
Super::RenderContent();
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
if (AbilitySystemComponent == nullptr)
{
return;
}
FGameplayTagContainer OwnedTags, BlockedTags;
AbilitySystemComponent->GetOwnedGameplayTags(OwnedTags);
AbilitySystemComponent->GetBlockedAbilityTags(BlockedTags);
DrawTagContainer("Owned Tags", *AbilitySystemComponent, OwnedTags);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Tags::DrawTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag)
{
if (ImGui::BeginTable("Tag", 2, ImGuiTableFlags_Borders))
{
@@ -33,27 +63,6 @@ static void DrawTagInfo(const UAbilitySystemComponent& AbilitySystemComponent, c
const int32 TagCount = AbilitySystemComponent.GetTagCount(Tag);
ImGui::TextColored(TagCount > 1 ? ImVec4(1.0f, 1.0f, 0.0f, 1.0f) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f), "%d", TagCount);
//------------------------
// Abilities
//------------------------
//ImGui::TableNextRow();
//ImGui::TableNextColumn();
//ImGui::TextColored(TextColor, "Abilities");
//ImGui::TableNextColumn();
//for (FGameplayAbilitySpec AbilitySpec : AbilitySystemComponent.GetActivatableAbilities())
//{
// UGameplayAbility* Ability = AbilitySpec.GetPrimaryInstance() != nullptr ? AbilitySpec.GetPrimaryInstance() : AbilitySpec.Ability;
// if (Ability == nullptr)
// {
// continue;
// }
// if (Ability->ActivationOwnedTags GetActivationOwnedTags().HasTagExact(Tag))
// {
// ImGui::Text("%s", TCHAR_TO_ANSI(*FCogAbilityHelper::CleanupName(GetNameSafe(Ability))));
// }
//}
//------------------------
// Effects
//------------------------
@@ -83,9 +92,8 @@ static void DrawTagInfo(const UAbilitySystemComponent& AbilitySystemComponent, c
}
}
//--------------------------------------------------------------------------------------------------------------------------
static void DrawTags(const FString& Title, UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer)
void UCogAbilityWindow_Tags::DrawTagContainer(const FString& Title, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer)
{
if (ImGui::BeginTable(TCHAR_TO_ANSI(*Title), 2, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_BordersOuterV))
{
@@ -122,50 +130,19 @@ static void DrawTags(const FString& Title, UAbilitySystemComponent& AbilitySyste
}
//------------------------
// Popup
// Tooltip
//------------------------
if (ImGui::IsItemHovered())
{
FCogWindowWidgets::BeginTableTooltip();
DrawTagInfo(AbilitySystemComponent, Tag);
DrawTag(AbilitySystemComponent, Tag);
FCogWindowWidgets::EndTableTooltip();
}
ImGui::PopID();
index++;
}
ImGui::EndTable();
}
}
//--------------------------------------------------------------------------------------------------------------------------
UCogAbilityWindow_Tags::UCogAbilityWindow_Tags()
{
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Tags::PreRender(ImGuiWindowFlags& WindowFlags)
{
WindowFlags = ImGuiWindowFlags_MenuBar;
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Tags::RenderContent()
{
Super::RenderContent();
UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true);
if (AbilitySystemComponent == nullptr)
{
return;
}
FGameplayTagContainer OwnedTags, BlockedTags;
AbilitySystemComponent->GetOwnedGameplayTags(OwnedTags);
AbilitySystemComponent->GetBlockedAbilityTags(BlockedTags);
DrawTags("Owned Tags", *AbilitySystemComponent, OwnedTags);
}
@@ -3,48 +3,14 @@
#include "AbilitySystemComponent.h"
//--------------------------------------------------------------------------------------------------------------------------
UCogAbilityWindow_Tweaks::UCogAbilityWindow_Tweaks()
void UCogAbilityWindow_Tweaks::RenderHelp()
{
}
//--------------------------------------------------------------------------------------------------------------------------
void DrawTweak(ACogAbilityReplicator* Replicator, const UCogAbilityDataAsset_Tweaks* TweaksAsset, int32 TweakIndex, int32 TweakCategoryIndex)
{
if (TweaksAsset->TweaksCategories.IsValidIndex(TweakCategoryIndex) == false)
{
return;
}
float* Value = Replicator->GetTweakCurrentValuePtr(TweaksAsset, TweakIndex, TweakCategoryIndex);
if (Value == nullptr)
{
return;
}
const FCogAbilityTweakCategory& Category = TweaksAsset->TweaksCategories[TweakCategoryIndex];
FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Category.Color));
ImGui::PushItemWidth(-1);
ImGui::SliderFloat("##Value", Value, TweaksAsset->TweakMinValue, TweaksAsset->TweakMaxValue, "%+0.0f%%", 1.0f);
ImGui::PopItemWidth();
FCogWindowWidgets::PopBackColor();
bool bUpdateValue = ImGui::IsItemDeactivatedAfterEdit();
if (ImGui::BeginPopupContextItem())
{
if (ImGui::Button("Reset"))
{
*Value = 0.f;
bUpdateValue = true;
}
ImGui::EndPopup();
}
if (bUpdateValue)
{
Replicator->SetTweakValue(TweaksAsset, TweakIndex, TweakCategoryIndex, *Value);
}
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(TweaksAsset.Get()))
);
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -52,6 +18,11 @@ void UCogAbilityWindow_Tweaks::RenderContent()
{
Super::RenderContent();
if (TweaksAsset == nullptr)
{
return;
}
FCogAbilityModule& Module = FCogAbilityModule::Get();
ACogAbilityReplicator* Replicator = Module.GetLocalReplicator();
if (Replicator == nullptr)
@@ -127,7 +98,7 @@ void UCogAbilityWindow_Tweaks::RenderContent()
{
ImGui::TableNextColumn();
ImGui::PushID(TweakCategoryIndex);
DrawTweak(Replicator, TweaksAsset.Get(), TweakIndex, TweakCategoryIndex);
DrawTweak(Replicator, TweakIndex, TweakCategoryIndex);
ImGui::PopID();
}
@@ -139,3 +110,43 @@ void UCogAbilityWindow_Tweaks::RenderContent()
ImGui::EndTable();
}
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogAbilityWindow_Tweaks::DrawTweak(ACogAbilityReplicator* Replicator, int32 TweakIndex, int32 TweakCategoryIndex)
{
if (TweaksAsset->TweaksCategories.IsValidIndex(TweakCategoryIndex) == false)
{
return;
}
float* Value = Replicator->GetTweakCurrentValuePtr(TweaksAsset.Get(), TweakIndex, TweakCategoryIndex);
if (Value == nullptr)
{
return;
}
const FCogAbilityTweakCategory& Category = TweaksAsset->TweaksCategories[TweakCategoryIndex];
FCogWindowWidgets::PushBackColor(FCogImguiHelper::ToImVec4(Category.Color));
ImGui::PushItemWidth(-1);
ImGui::SliderFloat("##Value", Value, TweaksAsset->TweakMinValue, TweaksAsset->TweakMaxValue, "%+0.0f%%", 1.0f);
ImGui::PopItemWidth();
FCogWindowWidgets::PopBackColor();
bool bUpdateValue = ImGui::IsItemDeactivatedAfterEdit();
if (ImGui::BeginPopupContextItem())
{
if (ImGui::Button("Reset"))
{
*Value = 0.f;
bUpdateValue = true;
}
ImGui::EndPopup();
}
if (bUpdateValue)
{
Replicator->SetTweakValue(TweaksAsset.Get(), TweakIndex, TweakCategoryIndex, *Value);
}
}
@@ -19,6 +19,8 @@ public:
protected:
virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderTick(float DetlaTime) override;
@@ -9,12 +9,18 @@ class COGABILITY_API UCogAbilityWindow_Attributes : public UCogWindow
{
GENERATED_BODY()
public:
UCogAbilityWindow_Attributes();
protected:
virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override;
virtual void DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute);
private:
UPROPERTY(Config)
bool bSortByNameSetting = true;
@@ -15,10 +15,14 @@ class COGABILITY_API UCogAbilityWindow_Cheats : public UCogWindow
public:
virtual void RenderContent() override;
TWeakObjectPtr<UCogAbilityDataAsset_Cheats> CheatsAsset;
protected:
virtual void RenderHelp() override;
virtual void RenderContent() override;
private:
void AddCheat(AActor* InstigatorActor, AActor* TargetActor, const FCogAbilityCheat& CheatEffect, bool IsPersistent);
@@ -18,6 +18,8 @@ public:
protected:
virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override;
@@ -6,6 +6,8 @@
#include "CogAbilityWindow_Pools.generated.h"
class UCogAbilityDataAsset_Pools;
class UAbilitySystemComponent;
struct FCogAbilityPool;
UCLASS()
class COGABILITY_API UCogAbilityWindow_Pools : public UCogWindow
@@ -13,8 +15,15 @@ class COGABILITY_API UCogAbilityWindow_Pools : public UCogWindow
GENERATED_BODY()
public:
UCogAbilityWindow_Pools();
TWeakObjectPtr<UCogAbilityDataAsset_Pools> PoolsAsset;
protected:
virtual void RenderHelp() override;
virtual void RenderContent() override;
TWeakObjectPtr<UCogAbilityDataAsset_Pools> PoolsAsset;
virtual void DrawPool(const UAbilitySystemComponent* AbilitySystemComponent, const FCogAbilityPool& Pool);
};
@@ -9,9 +9,14 @@ class COGABILITY_API UCogAbilityWindow_Tags : public UCogWindow
{
GENERATED_BODY()
public:
UCogAbilityWindow_Tags();
protected:
virtual void RenderHelp() override;
virtual void PreRender(ImGuiWindowFlags& WindowFlags) override;
virtual void RenderContent() override;
virtual void DrawTagContainer(const FString& Title, const UAbilitySystemComponent& AbilitySystemComponent, FGameplayTagContainer& TagContainer);
virtual void DrawTag(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTag& Tag);
};
@@ -4,9 +4,7 @@
#include "CogWindow.h"
#include "CogAbilityWindow_Tweaks.generated.h"
class AActor;
class UCogAbilityDataAsset_Tweaks;
class ACogAbilityReplicator;
UCLASS()
class COGABILITY_API UCogAbilityWindow_Tweaks : public UCogWindow
@@ -14,10 +12,15 @@ class COGABILITY_API UCogAbilityWindow_Tweaks : public UCogWindow
GENERATED_BODY()
public:
UCogAbilityWindow_Tweaks();
TWeakObjectPtr<UCogAbilityDataAsset_Tweaks> TweaksAsset;
protected:
virtual void RenderHelp() override;
virtual void RenderContent() override;
TWeakObjectPtr<UCogAbilityDataAsset_Tweaks> TweaksAsset;
virtual void DrawTweak(ACogAbilityReplicator* Replicator, int32 TweakIndex, int32 TweakCategoryIndex);
private:
};