mirror of
https://github.com/Ed94/Cog.git
synced 2026-07-28 18:30:04 +00:00
fix scale replication and other fixes
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
#include "CogAbilityHelper.h"
|
||||
|
||||
#include "GameplayEffect.h"
|
||||
#include "CogAbilityDataAsset.h"
|
||||
#include "CogImguiHelper.h"
|
||||
#include "imgui.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
FString FCogAbilityHelper::CleanupName(FString Str)
|
||||
{
|
||||
@@ -7,3 +12,116 @@ FString FCogAbilityHelper::CleanupName(FString Str)
|
||||
Str.RemoveFromEnd(TEXT("_c"));
|
||||
return Str;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ImVec4 FCogAbilityHelper::GetAttributeColor(const UCogAbilityDataAsset* Asset, float BaseValue, float CurrentValue)
|
||||
{
|
||||
FLinearColor Color = FLinearColor::White;
|
||||
if (Asset != nullptr)
|
||||
{
|
||||
if (CurrentValue > BaseValue)
|
||||
{
|
||||
Color = Asset->PositiveEffectColor;
|
||||
}
|
||||
else if (CurrentValue < BaseValue)
|
||||
{
|
||||
Color = Asset->NegativeEffectColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
Color = Asset->NeutralEffectColor;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -281,7 +281,6 @@ void UCogAbilityWindow_Attributes::RenderContent()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayAttribute& Attribute)
|
||||
{
|
||||
@@ -295,23 +294,6 @@ void UCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone
|
||||
const float BaseValue = AbilitySystemComponent.GetNumericAttributeBase(Attribute);
|
||||
const float CurrentValue = AbilitySystemComponent.GetNumericAttribute(Attribute);
|
||||
|
||||
FLinearColor Color = FLinearColor::White;
|
||||
if (Asset != nullptr)
|
||||
{
|
||||
if (CurrentValue > BaseValue)
|
||||
{
|
||||
Color = Asset->PositiveEffectColor;
|
||||
}
|
||||
else if (CurrentValue < BaseValue)
|
||||
{
|
||||
Color = Asset->NegativeEffectColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
Color = Asset->NeutralEffectColor;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------
|
||||
// Name
|
||||
//------------------------
|
||||
@@ -337,7 +319,7 @@ void UCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextColored(TextColor, "Current Value");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Color));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, GetAttributeColor(AbilitySystemComponent, Attribute));
|
||||
ImGui::Text("%0.2f", CurrentValue);
|
||||
ImGui::PopStyleColor(1);
|
||||
|
||||
@@ -357,68 +339,6 @@ void UCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone
|
||||
{
|
||||
const FModifierSpec& ModSpec = ActiveEffect->Spec.Modifiers[i];
|
||||
const FGameplayModifierInfo& ModInfo = ActiveEffect->Spec.Def->Modifiers[i];
|
||||
const float ModValue = ModSpec.GetEvaluatedMagnitude();
|
||||
|
||||
FLinearColor ModColor = FLinearColor::White;
|
||||
if (Asset != nullptr)
|
||||
{
|
||||
ModColor = Asset->NeutralEffectColor;
|
||||
|
||||
switch (ModInfo.ModifierOp)
|
||||
{
|
||||
case EGameplayModOp::Additive:
|
||||
{
|
||||
if (ModValue > 0.0f)
|
||||
{
|
||||
ModColor = Asset->PositiveEffectColor;
|
||||
}
|
||||
else if (ModValue < 0.0f)
|
||||
{
|
||||
ModColor = Asset->NegativeEffectColor;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EGameplayModOp::Multiplicitive:
|
||||
{
|
||||
if (ModValue > 1.0f)
|
||||
{
|
||||
ModColor = Asset->PositiveEffectColor;
|
||||
}
|
||||
else if (ModValue < 1.0f)
|
||||
{
|
||||
ModColor = Asset->NegativeEffectColor;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EGameplayModOp::Division:
|
||||
{
|
||||
if (ModValue < 1.0f)
|
||||
{
|
||||
ModColor = Asset->PositiveEffectColor;
|
||||
}
|
||||
else if (ModValue > 1.0f)
|
||||
{
|
||||
ModColor = Asset->NegativeEffectColor;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EGameplayModOp::Override:
|
||||
{
|
||||
if (ModValue > BaseValue)
|
||||
{
|
||||
ModColor = Asset->PositiveEffectColor;
|
||||
}
|
||||
else if (ModValue < BaseValue)
|
||||
{
|
||||
ModColor = Asset->NegativeEffectColor;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ModInfo.Attribute == Attribute)
|
||||
{
|
||||
@@ -430,7 +350,7 @@ void UCogAbilityWindow_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(FCogImguiHelper::ToImVec4(ModColor), "%0.2f", ModSpec.GetEvaluatedMagnitude());
|
||||
ImGui::TextColored(GetEffectModifierColor(ModSpec, ModInfo, BaseValue), "%0.2f", ModSpec.GetEvaluatedMagnitude());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -438,3 +358,19 @@ void UCogAbilityWindow_Attributes::DrawAttributeInfo(const UAbilitySystemCompone
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ImVec4 UCogAbilityWindow_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 UCogAbilityWindow_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);
|
||||
}
|
||||
@@ -88,26 +88,7 @@ void UCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A
|
||||
//------------------------
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
const FGameplayTagContainer& Tags = Effect.InheritableGameplayEffectTags.CombinedTags;
|
||||
|
||||
FLinearColor Color = FLinearColor::White;
|
||||
if (Asset != nullptr)
|
||||
{
|
||||
if (Tags.HasTag(Asset->NegativeEffectTag))
|
||||
{
|
||||
Color = Asset->NegativeEffectColor;
|
||||
}
|
||||
else if (Tags.HasTag(Asset->PositiveEffectTag))
|
||||
{
|
||||
Color = Asset->PositiveEffectColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
Color = Asset->NeutralEffectColor;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, FCogImguiHelper::ToImVec4(Color));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, GetEffectColor(Effect));
|
||||
|
||||
if (ImGui::Selectable(TCHAR_TO_ANSI(*GetEffectName(Effect)), Selected == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap | ImGuiSelectableFlags_AllowDoubleClick))
|
||||
{
|
||||
@@ -263,6 +244,7 @@ void UCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent&
|
||||
{
|
||||
const FModifierSpec& ModSpec = ActiveEffect.Spec.Modifiers[i];
|
||||
const FGameplayModifierInfo& ModInfo = ActiveEffect.Spec.Def->Modifiers[i];
|
||||
const float AttributeBaseValue = AbilitySystemComponent.GetNumericAttributeBase(ModInfo.Attribute);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
@@ -272,7 +254,7 @@ void UCogAbilityWindow_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::Text("%0.2f", ModSpec.GetEvaluatedMagnitude());
|
||||
ImGui::TextColored(GetEffectModifierColor(ModSpec, ModInfo, AttributeBaseValue), "%0.2f", ModSpec.GetEvaluatedMagnitude());
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
@@ -355,3 +337,17 @@ void UCogAbilityWindow_Effects::RenderPrediction(const FActiveGameplayEffect& Ac
|
||||
|
||||
ImGui::Text("%s", TCHAR_TO_ANSI(*PredictionString));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ImVec4 UCogAbilityWindow_Effects::GetEffectColor(const UGameplayEffect& Effect) const
|
||||
{
|
||||
return FCogAbilityHelper::GetEffectColor(Asset.Get(), Effect);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
ImVec4 UCogAbilityWindow_Effects::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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "imgui.h"
|
||||
|
||||
class UCogAbilityDataAsset;
|
||||
class UGameplayEffect;
|
||||
namespace EGameplayModOp { enum Type; }
|
||||
|
||||
class COGABILITY_API FCogAbilityHelper
|
||||
{
|
||||
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);
|
||||
};
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
class UAbilitySystemComponent;
|
||||
class UCogAbilityDataAsset;
|
||||
struct FGameplayAttribute;
|
||||
struct FModifierSpec;
|
||||
struct FGameplayModifierInfo;
|
||||
|
||||
UCLASS(Config = Cog)
|
||||
class COGABILITY_API UCogAbilityWindow_Attributes : public UCogWindow
|
||||
@@ -31,6 +33,10 @@ 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:
|
||||
|
||||
UPROPERTY(Config)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "CogWindow.h"
|
||||
#include "imgui.h"
|
||||
#include "CogAbilityWindow_Effects.generated.h"
|
||||
|
||||
class UAbilitySystemComponent;
|
||||
@@ -10,6 +11,9 @@ class UCogAbilityDataAsset;
|
||||
class UGameplayEffect;
|
||||
struct FActiveGameplayEffect;
|
||||
struct FActiveGameplayEffectHandle;
|
||||
struct FGameplayModifierInfo;
|
||||
struct FModifierSpec;
|
||||
namespace EGameplayModOp { enum Type; };
|
||||
|
||||
UCLASS()
|
||||
class COGABILITY_API UCogAbilityWindow_Effects : public UCogWindow
|
||||
@@ -46,6 +50,10 @@ protected:
|
||||
|
||||
virtual FString GetEffectName(const UGameplayEffect& Effect);
|
||||
|
||||
ImVec4 GetEffectColor(const UGameplayEffect& Effect) const;
|
||||
|
||||
ImVec4 GetEffectModifierColor(const FModifierSpec& ModSpec, const FGameplayModifierInfo& ModInfo, float BaseValue) const;
|
||||
|
||||
UPROPERTY()
|
||||
TWeakObjectPtr<const UCogAbilityDataAsset> Asset = nullptr;
|
||||
};
|
||||
|
||||
@@ -82,20 +82,20 @@ void UCogWindow::Render(float DeltaTime)
|
||||
}
|
||||
}
|
||||
|
||||
if (bHasMenu)
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
if (bHasMenu)
|
||||
{
|
||||
ImGui::Checkbox("Hide Menu", &bHideMenu);
|
||||
|
||||
if (ImGui::Button("Reset"))
|
||||
{
|
||||
ResetConfig();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::Button("Reset"))
|
||||
{
|
||||
ResetConfig();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
RenderContent();
|
||||
ImGui::End();
|
||||
|
||||
@@ -24,12 +24,6 @@ void UCogWindow_Settings::PostInitProperties()
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogWindow_Settings::RenderContent()
|
||||
{
|
||||
ImGui::Checkbox("Compact Mode", &GetOwner()->bCompactMode);
|
||||
|
||||
ImGui::Checkbox("Show Windows In Main Menu", &GetOwner()->bShowWindowsInMainMenu);
|
||||
|
||||
ImGui::Checkbox("Show Window Help", &GetOwner()->bShowHelp);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::SliderFloat("DPI Scale", &GetOwner()->DPIScale, 0.5f, 2.0f, "%.1f");
|
||||
if (ImGui::IsItemDeactivatedAfterEdit())
|
||||
@@ -37,6 +31,12 @@ void UCogWindow_Settings::RenderContent()
|
||||
GetOwner()->bRefreshDPIScale = true;
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Compact Mode", &GetOwner()->bCompactMode);
|
||||
|
||||
ImGui::Checkbox("Show Windows In Main Menu", &GetOwner()->bShowWindowsInMainMenu);
|
||||
|
||||
ImGui::Checkbox("Show Window Help", &GetOwner()->bShowHelp);
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
|
||||
Reference in New Issue
Block a user