diff --git a/Plugins/Cog/Source/CogCommon/Public/CogCommonConfig.h b/Plugins/Cog/Source/CogCommon/Public/CogCommonConfig.h new file mode 100644 index 0000000..d555f89 --- /dev/null +++ b/Plugins/Cog/Source/CogCommon/Public/CogCommonConfig.h @@ -0,0 +1,21 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogCommonConfig.generated.h" + +UCLASS(Config = Cog) +class COGCOMMON_API UCogCommonConfig : public UObject +{ + GENERATED_BODY() + +public: + + UCogCommonConfig() + { + Reset(); + } + + virtual void Reset() + { + } +}; diff --git a/Plugins/Cog/Source/CogCommon/Public/CogCommonLog.h b/Plugins/Cog/Source/CogCommon/Public/CogCommonLog.h new file mode 100644 index 0000000..fc55b7a --- /dev/null +++ b/Plugins/Cog/Source/CogCommon/Public/CogCommonLog.h @@ -0,0 +1,34 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogCommonLog.generated.h" + +//-------------------------------------------------------------------------------------------------------------------------- +UENUM(BlueprintType) +enum class ECogLogVerbosity : uint8 +{ + NoLogging = ELogVerbosity::NoLogging, + Fatal = ELogVerbosity::Fatal, + Error = ELogVerbosity::Error, + Warning = ELogVerbosity::Warning, + Display = ELogVerbosity::Display, + Log = ELogVerbosity::Log, + Verbose = ELogVerbosity::Verbose, + VeryVerbose = ELogVerbosity::VeryVerbose +}; + +//-------------------------------------------------------------------------------------------------------------------------- +USTRUCT(BlueprintType) +struct COGCOMMON_API FCogLogCategory +{ + GENERATED_USTRUCT_BODY() + + FCogLogCategory() {} + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + FName Name; + + FString GetName() const { return Name.ToString(); } + + mutable FLogCategoryBase* LogCategory = nullptr; +}; diff --git a/Plugins/Cog/Source/CogCommon/Public/CogCommonLogCategory.h b/Plugins/Cog/Source/CogCommon/Public/CogCommonLogCategory.h deleted file mode 100644 index 5494be6..0000000 --- a/Plugins/Cog/Source/CogCommon/Public/CogCommonLogCategory.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "CogCommonLogCategory.generated.h" - -//-------------------------------------------------------------------------------------------------------------------------- -USTRUCT(BlueprintType) -struct COGCOMMON_API FCogLogCategory -{ - GENERATED_USTRUCT_BODY() - - FCogLogCategory() {} - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Cog") - FName Name; - - FString GetName() const { return Name.ToString(); } - - mutable FLogCategoryBase* LogCategory = nullptr; -}; diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebug.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebug.cpp index 7bced1e..af48ab3 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebug.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebug.cpp @@ -3,8 +3,10 @@ #include "CogCommonDebugFilteredActorInterface.h" #include "CogDebugDrawHelper.h" #include "CogDebugReplicator.h" +#include "imgui.h" #include "Engine/World.h" #include "Engine/Engine.h" +#include "Kismet/KismetMathLibrary.h" //-------------------------------------------------------------------------------------------------------------------------- TWeakObjectPtr FCogDebug::Selection; @@ -19,7 +21,7 @@ void FCogDebug::Reset() //-------------------------------------------------------------------------------------------------------------------------- bool FCogDebug::IsDebugActiveForObject(const UObject* WorldContextObject) { - const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return true; @@ -186,21 +188,49 @@ FColor FCogDebug::ModulateDebugColor(const UWorld* World, const FColor& Color, b return Color; } - const float Time = World->GetTimeSeconds(); - const FLinearColor BaseColor(Color); - FLinearColor ComplementaryColor = BaseColor.LinearRGBToHSV(); - - ComplementaryColor.R = ComplementaryColor.R - 180.0f; - if (ComplementaryColor.R < 0.0f) + switch (Settings.RecolorMode) { - ComplementaryColor.R = 360.0f - ComplementaryColor.R; + case ECogDebugRecolorMode::None: + { + return Color; + } + + case ECogDebugRecolorMode::Color: + { + return UKismetMathLibrary::LinearColorLerp(Color, Settings.RecolorColor, Settings.RecolorIntensity).ToFColor(true); + } + + case ECogDebugRecolorMode::HueOverTime: + { + const FLinearColor BaseColor(Color); + + FLinearColor ComplementaryColor = BaseColor.LinearRGBToHSV(); + ComplementaryColor.R = ComplementaryColor.R - 180.0f; + if (ComplementaryColor.R < 0.0f) + { + ComplementaryColor.R = 360.0f - ComplementaryColor.R; + } + ComplementaryColor = ComplementaryColor.HSVToLinearRGB(); + + const FLinearColor NewColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(Settings.RecolorTimeSpeed * World->GetTimeSeconds())); + const FLinearColor BlendColor = BaseColor * (1.0f - Settings.RecolorIntensity) + NewColor * Settings.RecolorIntensity; + return BlendColor.ToFColor(true); + } + + case ECogDebugRecolorMode::HueOverFrames: + { + const FLinearColor BaseColor(Color); + const float Factor = (Settings.RecolorFrameCycle > 0) ? (GFrameCounter % Settings.RecolorFrameCycle) / (float)Settings.RecolorFrameCycle : 0.0f; + const FLinearColor NewColor(Factor * 360.0f, 1.0f, 1.0f); + const FLinearColor BlendColor = BaseColor * (1.0f - Settings.RecolorIntensity) + NewColor.HSVToLinearRGB() * Settings.RecolorIntensity; + return BlendColor.ToFColor(true); + } + + default: + { + return Color; + } } - - ComplementaryColor = ComplementaryColor.HSVToLinearRGB(); - - const FLinearColor GradientColor = FLinearColor::LerpUsingHSV(FLinearColor(Color), ComplementaryColor, FMath::Cos(Settings.GradientColorSpeed * Time)); - const FLinearColor FBlendColor = BaseColor * (1.0f - Settings.GradientColorIntensity) + GradientColor * Settings.GradientColorIntensity; - return FBlendColor.ToFColor(true); } @@ -283,7 +313,7 @@ void FCogDebug::GetDebugDrawOverlapSettings(FCogDebugDrawOverlapParams& Params) Params.DepthPriority = Settings.DepthPriority; Params.Thickness = Settings.Thickness; - GetDebugChannelColors(Params.ChannelColors); + GetDebugChannelColors(Params.ChannelColors); } //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp index cdd8bb3..755c5ac 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp @@ -1,7 +1,7 @@ #include "CogDebugDrawBlueprint.h" #include "CogDebugDraw.h" -#include "CogCommonLogCategory.h" +#include "CogCommonLog.h" #include "CogDebugLog.h" //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp index 0a5fad6..cf3be2c 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp @@ -421,10 +421,10 @@ void FCogDebugDrawHelper::DrawLineTrace( End, FCogDebug::Settings.ArrowSize, HasHits ? Settings.HitColor : Settings.NoHitColor, - false, - 0.0f, - FCogDebug::GetDebugDepthPriority(0), - FCogDebug::GetDebugThickness(0.0f)); + Settings.Persistent, + Settings.LifeTime, + Settings.DepthPriority, + Settings.Thickness); DrawHitResults(World, HitResults, Settings); } @@ -449,10 +449,10 @@ void FCogDebugDrawHelper::DrawSweep( End, FCogDebug::Settings.ArrowSize, Color, - false, - 0.0f, - FCogDebug::GetDebugDepthPriority(0), - FCogDebug::GetDebugThickness(0.0f)); + Settings.Persistent, + Settings.LifeTime, + Settings.DepthPriority, + Settings.Thickness); DrawShape(World, Shape, Start, Rotation, FVector::OneVector, Color, Settings.Persistent, Settings.LifeTime, Settings.DepthPriority, Settings.Thickness); diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugLog.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugLog.cpp index 602f6ca..6a9ae3a 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugLog.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugLog.cpp @@ -1,7 +1,6 @@ #include "CogDebugLog.h" -#include "CogCommonLogCategory.h" -#include "CogDebugModule.h" +#include "CogCommonLog.h" #include "CogDebugReplicator.h" #include "Engine/Engine.h" #include "Engine/World.h" diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugLogBlueprint.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugLogBlueprint.cpp index 95e1533..ed45fb2 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugLogBlueprint.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugLogBlueprint.cpp @@ -2,7 +2,7 @@ #include "CogCommon.h" #include "CogDebugLog.h" -#include "CogCommonLogCategory.h" +#include "CogCommonLog.h" //-------------------------------------------------------------------------------------------------------------------------- void UCogDebugLogBlueprint::Log(const UObject* WorldContextObject, const FCogLogCategory LogCategory, ECogLogVerbosity Verbosity, const FString& Text) diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugPlot.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugPlot.cpp index a287b7d..0cb8e73 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugPlot.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugPlot.cpp @@ -1,5 +1,6 @@ #include "CogDebugPlot.h" +#include "CogDebug.h" #include "CogDebugDraw.h" #include "CogDebugHelper.h" #include "CogImguiHelper.h" diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugReplicator.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugReplicator.cpp index 538840c..f0ea6a6 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugReplicator.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugReplicator.cpp @@ -1,5 +1,6 @@ #include "CogDebugReplicator.h" +#include "CogDebug.h" #include "CogDebugDraw.h" #include "CogDebugLog.h" #include "EngineUtils.h" diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugShape.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugShape.cpp index 90dafb9..a1ec759 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugShape.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugShape.cpp @@ -3,6 +3,10 @@ #include "CogCommon.h" #include "CogDebugDrawHelper.h" #include "DrawDebugHelpers.h" +#include "Engine/World.h" +#include "VisualLogger/VisualLogger.h" + +DEFINE_LOG_CATEGORY(LogCogServerVLOG); //-------------------------------------------------------------------------------------------------------------------------- FCogDebugShape FCogDebugShape::MakePoint(const FVector& Location, const float Size, const FColor& Color, const bool bPersistent, const uint8 DepthPriority) @@ -20,20 +24,25 @@ FCogDebugShape FCogDebugShape::MakePoint(const FVector& Location, const float Si } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawPoint(UWorld* World) const +void FCogDebugShape::DrawPoint(const UWorld* World) const { #if ENABLE_COG if (ShapeData.Num() == 1) { + const FVector Location = ShapeData[0]; + const float ServerThickness = FCogDebug::GetDebugServerThickness(Thickness); + DrawDebugPoint( World, - ShapeData[0], - FCogDebug::GetDebugServerThickness(Thickness), + Location, + ServerThickness, FCogDebug::ModulateServerColor(Color), FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDepthPriority(DepthPriority)); + + UE_VLOG_LOCATION(World, LogCogServerVLOG, Verbose, Location, ServerThickness, Color, TEXT("")); } #endif //ENABLE_COG @@ -56,21 +65,28 @@ FCogDebugShape FCogDebugShape::MakeSegment(const FVector& StartLocation, const F } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawSegment(UWorld* World) const +void FCogDebugShape::DrawSegment(const UWorld* World) const { #if ENABLE_COG if (ShapeData.Num() == 2) { + const FVector Start = ShapeData[0]; + const FVector End = ShapeData[1]; + const FColor ServerColor = FCogDebug::ModulateServerColor(Color); + const float ServerThickness = FCogDebug::GetDebugServerThickness(Thickness); + DrawDebugLine( World, - ShapeData[0], - ShapeData[1], - FCogDebug::ModulateServerColor(Color), + Start, + End, + ServerColor, FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDepthPriority(DepthPriority), - FCogDebug::GetDebugServerThickness(Thickness)); + ServerThickness); + + UE_VLOG_SEGMENT_THICK(World, LogCogServerVLOG, Verbose, Start, End, ServerColor, ServerThickness, TEXT("")); } #endif //ENABLE_COG @@ -94,22 +110,29 @@ FCogDebugShape FCogDebugShape::MakeArrow(const FVector& StartLocation, const FVe } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawArrow(UWorld* World) const +void FCogDebugShape::DrawArrow(const UWorld* World) const { #if ENABLE_COG if (ShapeData.Num() == 3) { + const FVector Start = ShapeData[0]; + const FVector End = ShapeData[1]; + const float Size = ShapeData[2].X; + const FColor ServerColor = FCogDebug::ModulateServerColor(Color); + DrawDebugDirectionalArrow( World, - ShapeData[0], - ShapeData[1], - ShapeData[2].X, - FCogDebug::ModulateServerColor(Color), + Start, + End, + Size, + ServerColor, FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugServerThickness(Thickness)); + + UE_VLOG_ARROW(World, LogCogServerVLOG, Verbose, Start, End, ServerColor, TEXT("")); } #endif //ENABLE_COG @@ -133,21 +156,30 @@ FCogDebugShape FCogDebugShape::MakeAxes(const FVector& Location, const FRotator& } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawAxes(UWorld* World) const +void FCogDebugShape::DrawAxes(const UWorld* World) const { #if ENABLE_COG if (ShapeData.Num() == 3) { + const FVector Location = ShapeData[0]; + const FRotator Rotation(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z); + const float Scale = ShapeData[2].X; + DrawDebugCoordinateSystem( World, - ShapeData[0], - FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z), - ShapeData[2].X, + Location, + Rotation, + Scale, FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugServerThickness(Thickness)); + + const FRotationMatrix Matrix(Rotation); + UE_VLOG_ARROW(World, LogCogServerVLOG, Verbose, Location, Location + Matrix.GetScaledAxis(EAxis::X) * Scale, FColor::Red, TEXT("")); + UE_VLOG_ARROW(World, LogCogServerVLOG, Verbose, Location, Location + Matrix.GetScaledAxis(EAxis::Y) * Scale, FColor::Green, TEXT("")); + UE_VLOG_ARROW(World, LogCogServerVLOG, Verbose, Location, Location + Matrix.GetScaledAxis(EAxis::Z) * Scale, FColor::Blue, TEXT("")); } #endif //ENABLE_COG @@ -171,22 +203,27 @@ FCogDebugShape FCogDebugShape::MakeBox(const FVector& Center, const FRotator& Ro } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawBox(UWorld* World) const +void FCogDebugShape::DrawBox(const UWorld* World) const { #if ENABLE_COG if (ShapeData.Num() == 3) { + const FVector Location = ShapeData[0]; + const FVector Extent = ShapeData[1]; + const FRotator Rotation(ShapeData[2].X, ShapeData[2].Y, ShapeData[2].Z); + const FColor ServerColor = FCogDebug::ModulateServerColor(Color); + DrawDebugBox( - World, - ShapeData[0], - ShapeData[1], - FQuat(FRotator(ShapeData[2].X, ShapeData[2].Y, ShapeData[2].Z)), - FCogDebug::ModulateServerColor(Color), + World, Location, Extent, FQuat(Rotation), + ServerColor, FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugServerThickness(Thickness)); + + const FBox Box(-Extent, Extent); + UE_VLOG_OBOX(World, LogCogServerVLOG, Verbose, Box, FRotationTranslationMatrix(Rotation, Location), ServerColor, TEXT("")); } #endif //ENABLE_COG @@ -209,21 +246,29 @@ FCogDebugShape FCogDebugShape::MakeSolidBox(const FVector& Center, const FRotato } -void FCogDebugShape::DrawSolidBox(UWorld* World) const +void FCogDebugShape::DrawSolidBox(const UWorld* World) const { #if ENABLE_COG if (ShapeData.Num() == 12) { + const FVector Location = ShapeData[0]; + const FVector Extent = ShapeData[1]; + const FRotator Rotation(ShapeData[2].X, ShapeData[2].Y, ShapeData[2].Z); + const FColor ServerColor = FCogDebug::ModulateServerColor(Color); + DrawDebugSolidBox( World, - ShapeData[0], - ShapeData[1], - FQuat(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z)), - FCogDebug::ModulateServerColor(Color), + Location, + Extent, + FQuat(Rotation), + ServerColor, FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDepthPriority(DepthPriority)); + + const FBox Box(-Extent, Extent); + UE_VLOG_OBOX(World, LogCogServerVLOG, Verbose, Box, FRotationTranslationMatrix(Rotation, Location), ServerColor, TEXT("")); } #endif //ENABLE_COG @@ -247,26 +292,33 @@ FCogDebugShape FCogDebugShape::MakeCone(const FVector& Location, const FVector& } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawCone(UWorld* World) const +void FCogDebugShape::DrawCone(const UWorld* World) const { #if ENABLE_COG if (ShapeData.Num() == 3 && ShapeData[2].X > 0) { + const FVector Location = ShapeData[0]; + const FVector Direction = ShapeData[1]; + const float Length = ShapeData[2].X; const float DefaultConeAngle = 0.25f; // ~ 15 degrees + const FColor ServerColor = FCogDebug::ModulateServerColor(Color); + DrawDebugCone( World, - ShapeData[0], - ShapeData[1], - ShapeData[2].X, + Location, + Direction, + Length, DefaultConeAngle, DefaultConeAngle, FCogDebug::GetCircleSegments(), - FCogDebug::ModulateServerColor(Color), + ServerColor, FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDepthPriority(DepthPriority), FCogDebug::GetDebugServerThickness(Thickness)); + + UE_VLOG_CONE(World, LogCogServerVLOG, Verbose, Location, Direction, Length, DefaultConeAngle, ServerColor, TEXT("")); } #endif //ENABLE_COG @@ -289,7 +341,7 @@ FCogDebugShape FCogDebugShape::MakeCylinder(const FVector& Center, const float R } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawCylinder(UWorld* World) const +void FCogDebugShape::DrawCylinder(const UWorld* World) const { #if ENABLE_COG @@ -329,23 +381,33 @@ FCogDebugShape FCogDebugShape::MakeCircle(const FVector& Center, const FRotator& } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawCicle(UWorld* World) const +void FCogDebugShape::DrawCircle(const UWorld* World) const { #if ENABLE_COG if (ShapeData.Num() == 3) { + const FVector Location = ShapeData[0]; + const FRotator Rotation (ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z); + const FRotationTranslationMatrix Matrix(Rotation, Location); + const float Radius = ShapeData[2].X; + const FColor ServerColor = FCogDebug::ModulateServerColor(Color); + const float ServerThickness = FCogDebug::GetDebugServerThickness(Thickness); + DrawDebugCircle( World, - FRotationTranslationMatrix(FRotator(ShapeData[1].X, ShapeData[1].Y, ShapeData[1].Z), ShapeData[0]), - ShapeData[2].X, + Matrix, + Radius, FCogDebug::GetCircleSegments(), - FCogDebug::ModulateServerColor(Color), + ServerColor, FCogDebug::GetDebugPersistent(bPersistent), FCogDebug::GetDebugDuration(bPersistent), FCogDebug::GetDebugDepthPriority(DepthPriority), - FCogDebug::GetDebugServerThickness(Thickness), + ServerThickness, false); + + UE_VLOG_CIRCLE_THICK(World, LogCogServerVLOG, Verbose, Location, Matrix.GetUnitAxis(EAxis::X), Radius, ServerColor, ServerThickness, TEXT("")); + } #endif //ENABLE_COG @@ -369,7 +431,7 @@ FCogDebugShape FCogDebugShape::MakeCircleArc(const FVector& Center, const FRotat } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawCicleArc(UWorld* World) const +void FCogDebugShape::DrawCircleArc(const UWorld* World) const { #if ENABLE_COG @@ -410,7 +472,7 @@ FCogDebugShape FCogDebugShape::MakeCapsule(const FVector& Center, const FQuat& R } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawCapsule(UWorld* World) const +void FCogDebugShape::DrawCapsule(const UWorld* World) const { #if ENABLE_COG @@ -451,7 +513,7 @@ FCogDebugShape FCogDebugShape::MakeFlatCapsule(const FVector2D& Start, const FVe //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawFlatCapsule(UWorld* World) const +void FCogDebugShape::DrawFlatCapsule(const UWorld* World) const { #if ENABLE_COG @@ -491,7 +553,7 @@ FCogDebugShape FCogDebugShape::MakeBone(const FVector& BoneLocation, const FVect } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawBone(UWorld* World) const +void FCogDebugShape::DrawBone(const UWorld* World) const { #if ENABLE_COG @@ -535,7 +597,7 @@ FCogDebugShape FCogDebugShape::MakePolygon(const TArray& Verts, const F } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::DrawPolygon(UWorld* World) const +void FCogDebugShape::DrawPolygon(const UWorld* World) const { #if ENABLE_COG @@ -564,7 +626,7 @@ void FCogDebugShape::DrawPolygon(UWorld* World) const //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugShape::Draw(UWorld* World) const +void FCogDebugShape::Draw(const UWorld* World) const { switch (Type) { @@ -573,8 +635,8 @@ void FCogDebugShape::Draw(UWorld* World) const case ECogDebugShape::Bone: DrawBone(World); break; case ECogDebugShape::Box: DrawBox(World); break; case ECogDebugShape::Capsule: DrawCapsule(World); break; - case ECogDebugShape::Circle: DrawCicle(World); break; - case ECogDebugShape::CircleArc: DrawCicleArc(World); break; + case ECogDebugShape::Circle: DrawCircle(World); break; + case ECogDebugShape::CircleArc: DrawCircleArc(World); break; case ECogDebugShape::Cone: DrawCone(World); break; case ECogDebugShape::Cylinder: DrawCylinder(World); break; case ECogDebugShape::FlatCapsule: DrawFlatCapsule(World); break; diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebug.h b/Plugins/Cog/Source/CogDebug/Public/CogDebug.h index dcd66e9..b6e95b2 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebug.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebug.h @@ -12,6 +12,15 @@ struct FCogDebugDrawLineTraceParams; struct FCogDebugDrawOverlapParams; struct FCogDebugDrawSweepParams; +UENUM() +enum ECogDebugRecolorMode : uint8 +{ + None, + Color, + HueOverTime, + HueOverFrames, +}; + USTRUCT() struct FCogDebugSettings { @@ -54,10 +63,19 @@ struct FCogDebugSettings float AxesScale = 1.0f; UPROPERTY(Config) - float GradientColorIntensity = 0.0f; + TEnumAsByte RecolorMode = None; UPROPERTY(Config) - float GradientColorSpeed = 2.0f; + float RecolorIntensity = 0.0f; + + UPROPERTY(Config) + FColor RecolorColor = FColor(255, 0, 0, 255); + + UPROPERTY(Config) + float RecolorTimeSpeed = 2.0f; + + UPROPERTY(Config) + int32 RecolorFrameCycle = 6; UPROPERTY(Config) float TextSize = 1.0f; diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugLogBlueprint.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugLogBlueprint.h index 27e3c27..b3215d8 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugLogBlueprint.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugLogBlueprint.h @@ -1,22 +1,10 @@ #pragma once #include "CoreMinimal.h" -#include "Kismet/KismetSystemLibrary.h" -#include "Logging/LogVerbosity.h" -#include "CogDebugLogBlueprint.generated.h" +#include "CogCommonLog.h" +#include "Kismet/BlueprintFunctionLibrary.h" -//-------------------------------------------------------------------------------------------------------------------------- -UENUM() -enum class ECogLogVerbosity : uint8 -{ - Fatal = ELogVerbosity::Fatal, - Error = ELogVerbosity::Error, - Warning = ELogVerbosity::Warning, - Display = ELogVerbosity::Display, - Log = ELogVerbosity::Log, - Verbose = ELogVerbosity::Verbose, - VeryVerbose = ELogVerbosity::VeryVerbose -}; +#include "CogDebugLogBlueprint.generated.h" //-------------------------------------------------------------------------------------------------------------------------- UCLASS(meta = (ScriptName = "CogLogBlueprint")) diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugReplicator.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugReplicator.h index 3d15b07..0076af6 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugReplicator.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugReplicator.h @@ -1,9 +1,9 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonLog.h" #include "GameFramework/Actor.h" #include "CogDebugShape.h" -#include "CogDebugLogBlueprint.h" #include "UObject/Class.h" #include "UObject/ObjectMacros.h" #include "CogDebugReplicator.generated.h" diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugRob.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugRob.h new file mode 100644 index 0000000..9e8f9e9 --- /dev/null +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugRob.h @@ -0,0 +1,50 @@ +#pragma once + +//-------------------------------------------------------------------------------------------------------------------------- +// Hack to access to private members +// https://github.com/YunHsiao/Crysknife/blob/main/SourcePatch/Runtime/Core/Public/Misc/PrivateAccessor.h +// https://bloglitb.blogspot.com/2010/07/access-to-private-members-thats-easy.html +//-------------------------------------------------------------------------------------------------------------------------- + +template +struct TRob +{ + TRob() { Output = Input; } + static TRob Obj; +}; + +template +TRob TRob::Obj; + +template +using TMemberVariableType = VariableType(OwnerType::*); + +template +using TMemberFunctionType = ReturnType(OwnerType::*)(Args...); + +template +using TConstMemberFunctionType = ReturnType(OwnerType::*)(Args...) const; + +template +using TStaticVariableType = VariableType*; + +template +using TStaticFunctionType = ReturnType(*)(Args...); + +#define INIT_PRIVATE_ACCESSOR(Name, Value) template struct TRob + +#define DEFINE_PRIVATE_ACCESSOR(Name, Value, Type, ...) \ + static Type<__VA_ARGS__> Name; \ + INIT_PRIVATE_ACCESSOR(Name, Value) + +/****************************** Syntactic Sugars ******************************/ + +#define DEFINE_PRIVATE_ACCESSOR_VARIABLE(Name, Class, VariableType, VariableName) DEFINE_PRIVATE_ACCESSOR(Name, Class::VariableName, TMemberVariableType, Class, VariableType) +#define DEFINE_PRIVATE_ACCESSOR_STATIC_VARIABLE(Name, Class, VariableType, VariableName) DEFINE_PRIVATE_ACCESSOR(Name, Class::VariableName, TStaticVariableType, VariableType) +#define DEFINE_PRIVATE_ACCESSOR_FUNCTION(Name, Class, ReturnType, FunctionName, ...) DEFINE_PRIVATE_ACCESSOR(Name, Class::FunctionName, TMemberFunctionType, Class, ReturnType, __VA_ARGS__) +#define DEFINE_PRIVATE_ACCESSOR_CONST_FUNCTION(Name, Class, ReturnType, FunctionName, ...) DEFINE_PRIVATE_ACCESSOR(Name, Class::FunctionName, TConstMemberFunctionType, Class, ReturnType, __VA_ARGS__) +#define DEFINE_PRIVATE_ACCESSOR_STATIC_FUNCTION(Name, Class, ReturnType, FunctionName, ...) DEFINE_PRIVATE_ACCESSOR(Name, Class::FunctionName, TStaticFunctionType, ReturnType, __VA_ARGS__) + +#define PRIVATE_ACCESS_OBJ(Obj, Name) (Obj.*Name) +#define PRIVATE_ACCESS_PTR(Ptr, Name) (Ptr->*Name) +#define PRIVATE_ACCESS_STATIC(Name) (*Name) diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugShape.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugShape.h index 387c8bd..bb2742d 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugShape.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugShape.h @@ -2,6 +2,8 @@ #include "CoreMinimal.h" +DECLARE_LOG_CATEGORY_EXTERN(LogCogServerVLOG, Verbose, All); + enum class ECogDebugShape : uint8 { Invalid, @@ -58,22 +60,22 @@ struct COGDEBUG_API FCogDebugShape static FCogDebugShape MakeFlatCapsule(const FVector2D& Start, const FVector2D& End, const float Radius, const float Z, const FColor& Color, const float Thickness, const bool bPersistent, const uint8 DepthPriority); static FCogDebugShape MakePolygon(const TArray& Verts, const FColor& Color, const bool bPersistent, const uint8 DepthPriority); - void DrawPoint(UWorld* World) const; - void DrawSegment(UWorld* World) const; - void DrawBone(UWorld* World) const; - void DrawArrow(UWorld* World) const; - void DrawAxes(UWorld* World) const; - void DrawBox(UWorld* World) const; - void DrawSolidBox(UWorld* World) const; - void DrawCone(UWorld* World) const; - void DrawCylinder(UWorld* World) const; - void DrawCicle(UWorld* World) const; - void DrawCicleArc(UWorld* World) const; - void DrawCapsule(UWorld* World) const; - void DrawFlatCapsule(UWorld* World) const; - void DrawPolygon(UWorld* World) const; + void DrawPoint(const UWorld* World) const; + void DrawSegment(const UWorld* World) const; + void DrawBone(const UWorld* World) const; + void DrawArrow(const UWorld* World) const; + void DrawAxes(const UWorld* World) const; + void DrawBox(const UWorld* World) const; + void DrawSolidBox(const UWorld* World) const; + void DrawCone(const UWorld* World) const; + void DrawCylinder(const UWorld* World) const; + void DrawCircle(const UWorld* World) const; + void DrawCircleArc(const UWorld* World) const; + void DrawCapsule(const UWorld* World) const; + void DrawFlatCapsule(const UWorld* World) const; + void DrawPolygon(const UWorld* World) const; - void Draw(UWorld* World) const; + void Draw(const UWorld* World) const; }; FArchive& operator<<(FArchive& Ar, FCogDebugShape& Shape); diff --git a/Plugins/Cog/Source/CogDebugEditor/Private/CogDebugLogCategoryDetails.cpp b/Plugins/Cog/Source/CogDebugEditor/Private/CogDebugLogCategoryDetails.cpp index 5f2583d..bf4e93b 100644 --- a/Plugins/Cog/Source/CogDebugEditor/Private/CogDebugLogCategoryDetails.cpp +++ b/Plugins/Cog/Source/CogDebugEditor/Private/CogDebugLogCategoryDetails.cpp @@ -1,6 +1,6 @@ #include "CogDebugLogCategoryDetails.h" -#include "CogCommonLogCategory.h" +#include "CogCommonLog.h" #include "CogDebugLog.h" #include "DetailWidgetRow.h" #include "Editor.h" diff --git a/Plugins/Cog/Source/CogDebugEditor/Private/SCogDebugLogCategoryGraphPin.cpp b/Plugins/Cog/Source/CogDebugEditor/Private/SCogDebugLogCategoryGraphPin.cpp index 3f4381f..e225686 100644 --- a/Plugins/Cog/Source/CogDebugEditor/Private/SCogDebugLogCategoryGraphPin.cpp +++ b/Plugins/Cog/Source/CogDebugEditor/Private/SCogDebugLogCategoryGraphPin.cpp @@ -1,6 +1,6 @@ #include "SCogDebugLogCategoryGraphPin.h" -#include "CogCommonLogCategory.h" +#include "CogCommonLog.h" #include "ScopedTransaction.h" #include "SCogDebugLogCategoryWidget.h" #include "UObject/UObjectIterator.h" diff --git a/Plugins/Cog/Source/CogDebugEditor/Public/CogDebugGraphPanelPinFactory.h b/Plugins/Cog/Source/CogDebugEditor/Public/CogDebugGraphPanelPinFactory.h index e8d850d..720c5fb 100644 --- a/Plugins/Cog/Source/CogDebugEditor/Public/CogDebugGraphPanelPinFactory.h +++ b/Plugins/Cog/Source/CogDebugEditor/Public/CogDebugGraphPanelPinFactory.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" #include "CogDebugGraphPanelPinFactory.h" -#include "CogCommonLogCategory.h" +#include "CogCommonLog.h" #include "EdGraphSchema_K2.h" #include "EdGraphUtilities.h" #include "SCogDebugLogCategoryGraphPin.h" diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp index 6048f4a..0bdc107 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_DebugSettings.cpp @@ -166,21 +166,7 @@ void FCogEngineWindow_DebugSettings::RenderContent() ImGui::SetTooltip("The size of debug arrows."); } - FCogWindowWidgets::SetNextItemToShortWidth(); - ImGui::DragFloat("Gradient Intensity", &Settings.GradientColorIntensity, 0.01f, 0.0f, 1.0f, "%.2f"); - if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) - { - ImGui::SetTooltip("How much the debug elements color should be changed by a gradient color over time."); - } - - FCogWindowWidgets::SetNextItemToShortWidth(); - ImGui::DragFloat("Gradient Speed", &Settings.GradientColorSpeed, 0.1f, 0.0f, 10.0f, "%.1f"); - if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) - { - ImGui::SetTooltip("The speed of the gradient color change."); - } - - FCogWindowWidgets::SetNextItemToShortWidth(); + FCogWindowWidgets::SetNextItemToShortWidth(); ImGui::DragFloat("Text Size", &Settings.TextSize, 0.1f, 0.1f, 5.0f, "%.1f"); if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) { @@ -188,6 +174,54 @@ void FCogEngineWindow_DebugSettings::RenderContent() } } + if (ImGui::CollapsingHeader("Recolor", ImGuiTreeNodeFlags_DefaultOpen)) + { + FCogWindowWidgets::SetNextItemToShortWidth(); + + ECogDebugRecolorMode Mode = Settings.RecolorMode; + if (FCogWindowWidgets::ComboboxEnum("Recolor mode", Mode)) + { + Settings.RecolorMode = Mode; + } + if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) + { + ImGui::SetTooltip("How the debug element should be recolored."); + } + + if (Settings.RecolorMode != ECogDebugRecolorMode::None) + { + FCogWindowWidgets::SetNextItemToShortWidth(); + ImGui::DragFloat("Recolor Intensity", &Settings.RecolorIntensity, 0.01f, 0.0f, 1.0f, "%.2f"); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) + { + ImGui::SetTooltip("How much the debug elements color should be changed."); + } + } + + if (Settings.RecolorMode == ECogDebugRecolorMode::Color) + { + FCogImguiHelper::ColorEdit4("Recolor Color", Settings.RecolorColor, ColorEditFlags); + } + else if (Settings.RecolorMode == HueOverTime) + { + FCogWindowWidgets::SetNextItemToShortWidth(); + ImGui::DragFloat("Recolor Speed", &Settings.RecolorTimeSpeed, 0.1f, 0.0f, 10.0f, "%.1f"); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) + { + ImGui::SetTooltip("The speed of the recolor."); + } + } + else if (Settings.RecolorMode == ECogDebugRecolorMode::HueOverFrames) + { + FCogWindowWidgets::SetNextItemToShortWidth(); + ImGui::DragInt("Recolor Cycle", &Settings.RecolorFrameCycle, 1, 2, 100); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) + { + ImGui::SetTooltip("How many frames are used to perform a full hue cycle."); + } + } + } + if (ImGui::CollapsingHeader("Gizmo")) { ImGui::SeparatorText("General"); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp index 15ae3c1..4fc8332 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp @@ -227,6 +227,11 @@ void FCogEngineWindow_Plots::RenderPlots(const TArray& Visi FCogDebugPlotEntry& Entry = *PlotPtr; + if (Entry.Values.empty()) + { + continue; + } + if (Entry.CurrentRow == PlotIndex) { //-------------------------------------------------------------------------------- diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h index 9c38ea5..9cca48b 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionTester.h @@ -1,9 +1,9 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogDebugGizmo.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "Engine/HitResult.h" #include "CogEngineCollisionTester.h" #include "CogEngineWindow_CollisionTester.generated.h" @@ -47,7 +47,7 @@ protected: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogEngineConfig_CollisionTester : public UCogWindowConfig +class UCogEngineConfig_CollisionTester : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionViewer.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionViewer.h index 3f28d30..aea5efa 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionViewer.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_CollisionViewer.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "Engine/EngineTypes.h" #include "CogEngineWindow_CollisionViewer.generated.h" @@ -37,7 +37,7 @@ protected: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogEngineConfig_CollisionViewer : public UCogWindowConfig +class UCogEngineConfig_CollisionViewer : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h index 47c705f..f56fd9d 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_DebugSettings.h @@ -1,9 +1,9 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogDebug.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogEngineWindow_DebugSettings.generated.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -32,7 +32,7 @@ private: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogEngineConfig_DebugSettings : public UCogWindowConfig +class UCogEngineConfig_DebugSettings : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Inspector.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Inspector.h index 8b05e0c..8218f42 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Inspector.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Inspector.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "imgui.h" #include "CogEngineWindow_Inspector.generated.h" @@ -110,7 +110,7 @@ protected: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogEngineConfig_Inspector : public UCogWindowConfig +class UCogEngineConfig_Inspector : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h index 4ec0a9d..6d97def 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Metrics.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogEngineWindow_Metrics.generated.h" struct FCogDebugMetricEntry; @@ -41,7 +41,7 @@ private: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogEngineConfig_Metrics : public UCogWindowConfig +class UCogEngineConfig_Metrics : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h index c104c75..3cb9f9a 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "imgui.h" #include "Misc/OutputDevice.h" #include "CogEngineWindow_OutputLog.generated.h" @@ -71,7 +71,7 @@ private: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogEngineConfig_OutputLog : public UCogWindowConfig +class UCogEngineConfig_OutputLog : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h index 8bbfc1b..377bec3 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogEngineWindow_Plots.generated.h" struct ImVec2; @@ -50,7 +50,7 @@ private: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogEngineConfig_Plots : public UCogWindowConfig +class UCogEngineConfig_Plots : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h index a094896..2235a5b 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Selection.h @@ -1,9 +1,9 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "GameFramework/Actor.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogEngineWindow_Selection.generated.h" class IConsoleObject; @@ -92,7 +92,7 @@ protected: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogEngineConfig_Selection : public UCogWindowConfig +class UCogEngineConfig_Selection : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Transform.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Transform.h index c0ad37b..2bf370b 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Transform.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Transform.h @@ -1,9 +1,9 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogDebugGizmo.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogEngineWindow_Transform.generated.h" class UCogEngineConfig_Transform; @@ -43,7 +43,7 @@ private: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogEngineConfig_Transform : public UCogWindowConfig +class UCogEngineConfig_Transform : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/Cog/Source/CogWindow/CogWindow.Build.cs b/Plugins/Cog/Source/CogWindow/CogWindow.Build.cs index df76e45..52db039 100644 --- a/Plugins/Cog/Source/CogWindow/CogWindow.Build.cs +++ b/Plugins/Cog/Source/CogWindow/CogWindow.Build.cs @@ -22,6 +22,7 @@ public class CogWindow : ModuleRules new string[] { "Core", + "CogCommon", "CogImgui", "CogDebug", } diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp index 4743a8b..e1461a5 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp @@ -1,10 +1,8 @@ #include "CogWindow.h" -#include "CogDebugDraw.h" #include "CogDebug.h" #include "CogWindow_Settings.h" #include "CogWindowManager.h" -#include "CogWindowWidgets.h" #include "Engine/World.h" #include "imgui_internal.h" #include "GameFramework/Pawn.h" @@ -180,7 +178,7 @@ ULocalPlayer* FCogWindow::GetLocalPlayer() const } //-------------------------------------------------------------------------------------------------------------------------- -UCogWindowConfig* FCogWindow::GetConfig(const TSubclassOf ConfigClass) const +UCogCommonConfig* FCogWindow::GetConfig(const TSubclassOf ConfigClass) const { return GetOwner()->GetConfig(ConfigClass); } diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp index c2452d9..c76eb1b 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp @@ -6,7 +6,6 @@ #include "CogWindow_Layouts.h" #include "CogWindow_Settings.h" #include "CogWindow_Spacing.h" -#include "CogWindowConfig.h" #include "CogWindowHelper.h" #include "CogWindowWidgets.h" #include "Engine/Engine.h" @@ -116,7 +115,7 @@ void UCogWindowManager::Shutdown() } Windows.Empty(); - for (UCogWindowConfig* Config : Configs) + for (UCogCommonConfig* Config : Configs) { Config->SaveConfig(); } @@ -741,19 +740,19 @@ void UCogWindowManager::SortCommands(UPlayerInput* PlayerInput) } //-------------------------------------------------------------------------------------------------------------------------- -UCogWindowConfig* UCogWindowManager::GetConfig(const TSubclassOf ConfigClass) +UCogCommonConfig* UCogWindowManager::GetConfig(const TSubclassOf ConfigClass) { const UClass* Class = ConfigClass.Get(); - for (UCogWindowConfig* Config : Configs) + for (UCogCommonConfig* Config : Configs) { if (Config && Config->IsA(Class)) { - return Cast(Config); + return Cast(Config); } } - UCogWindowConfig* Config = NewObject(this, Class); + UCogCommonConfig* Config = NewObject(this, Class); Configs.Add(Config); return Config; } diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp index 687a486..1fd1d4b 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp @@ -1020,3 +1020,13 @@ void FCogWindowWidgets::ActorFrame(const AActor& Actor) AddTextWithShadow(DrawList, FCogImguiHelper::ToImVec2(ScreenPosMin + FVector2D(0, -14.0f)) + Viewport->Pos, Color, TCHAR_TO_ANSI(*FCogWindowHelper::GetActorName(Actor))); } } + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogWindowWidgets::SmallButton(const char* Text, const ImVec4& Color) +{ + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.6f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(Color.x, Color.y, Color.z, Color.w * 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(Color.x, Color.y, Color.z, Color.w * 1.0f)); + ImGui::SmallButton(Text); + ImGui::PopStyleColor(3); +} \ No newline at end of file diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h b/Plugins/Cog/Source/CogWindow/Public/CogWindow.h index de1086a..fda5de3 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindow.h @@ -1,6 +1,7 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "imgui.h" #include "Templates/SubclassOf.h" #include "UObject/ReflectedTypeAccessors.h" @@ -9,7 +10,6 @@ class AActor; class APawn; class APlayerController; -class UCogWindowConfig; class UCogWindowManager; class ULocalPlayer; class UWorld; @@ -78,7 +78,7 @@ public: template T* GetConfig() { return Cast(GetConfig(T::StaticClass())); } - UCogWindowConfig* GetConfig(const TSubclassOf ConfigClass) const; + UCogCommonConfig* GetConfig(const TSubclassOf ConfigClass) const; template const T* GetAsset() { return Cast(GetAsset(T::StaticClass())); } diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowConfig.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowConfig.h deleted file mode 100644 index f5ebf54..0000000 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowConfig.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "CogWindowConfig.generated.h" - -UCLASS(Config = Cog) -class COGWINDOW_API UCogWindowConfig : public UObject -{ - GENERATED_BODY() - -public: - - UPROPERTY(Config) - bool bHideMenu = false; - - UCogWindowConfig() - { - Reset(); - } - - virtual void Reset() - { - bHideMenu = true; - } -}; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h index 2913f05..3f120d6 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h @@ -5,12 +5,12 @@ #include "imgui.h" #include "CogWindowManager.generated.h" +class UCogCommonConfig; class FCogWindow; class FCogWindow_Layouts; class FCogWindow_Settings; class IConsoleObject; class SCogImguiWidget; -class UCogWindowConfig; class UPlayerInput; class UWorld; struct ImGuiSettingsHandler; @@ -61,7 +61,7 @@ public: const FCogWindow_Settings* GetSettingsWindow() const { return SettingsWindow; } - UCogWindowConfig* GetConfig(const TSubclassOf ConfigClass); + UCogCommonConfig* GetConfig(const TSubclassOf ConfigClass); template T* GetConfig(); @@ -124,7 +124,7 @@ protected: static FString ResetLayoutCommand; UPROPERTY() - mutable TArray Configs; + mutable TArray Configs; UPROPERTY() mutable TArray Assets; @@ -172,7 +172,7 @@ T* UCogWindowManager::AddWindow(const FString& Name, bool AddToMainMenu) template T* UCogWindowManager::GetConfig() { - static_assert(TPointerIsConvertibleFromTo::Value); + static_assert(TPointerIsConvertibleFromTo::Value); return Cast(&GetConfig(T::StaticClass())); } diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h index ea232f4..e576f0e 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindowWidgets.h @@ -102,6 +102,8 @@ public: static void ActorContextMenu(AActor& Selection, const FCogWindowActorContextMenuFunction& ContextMenuFunction); static void ActorFrame(const AActor& Actor); + + static void SmallButton(const char* Text, const ImVec4& Color); }; template diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h index 80468cc..8775614 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogWindow_Settings.generated.h" class UCogEngineConfig_Settings; @@ -36,7 +36,7 @@ protected: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogWindowConfig_Settings : public UCogWindowConfig +class UCogWindowConfig_Settings : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h index e49fc80..f468b51 100644 --- a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h +++ b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_BehaviorTree.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogAIWindow_BehaviorTree.generated.h" class UBehaviorTreeComponent; @@ -37,7 +37,7 @@ private: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogAIConfig_BehaviorTree : public UCogWindowConfig +class UCogAIConfig_BehaviorTree : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h index 5e844a9..166818c 100644 --- a/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h +++ b/Plugins/CogAI/Source/CogAI/Public/CogAIWindow_Blackboard.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogAIWindow_Blackboard.generated.h" class UCogAIConfig_Blackboard; @@ -33,7 +33,7 @@ private: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogAIConfig_Blackboard : public UCogWindowConfig +class UCogAIConfig_Blackboard : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs b/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs index 8bab94c..16e7478 100644 --- a/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs +++ b/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs @@ -1,4 +1,5 @@ using UnrealBuildTool; +using UnrealBuildTool.Rules; public class CogAbility : ModuleRules { @@ -37,6 +38,7 @@ public class CogAbility : ModuleRules new string[] { "CoreUObject", + "GameplayTasks", "Engine", } ); diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp index 1bd5663..bfe67fa 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp @@ -1,5 +1,6 @@ #include "CogAbilityHelper.h" +#include "CogWindowWidgets.h" #include "GameplayTagContainer.h" #include "imgui.h" @@ -12,12 +13,47 @@ FString FCogAbilityHelper::CleanupName(FString Str) } //-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityHelper::RenderTagContainer(const FGameplayTagContainer& Container) +void FCogAbilityHelper::RenderTagContainer(const FGameplayTagContainer& Container, const bool Inline, const ImVec4& Color) { TArray GameplayTags; Container.GetGameplayTagArray(GameplayTags); - for (FGameplayTag Tag : GameplayTags) + for (const FGameplayTag& Tag : GameplayTags) { - ImGui::Text("%s", TCHAR_TO_ANSI(*Tag.ToString())); + FCogWindowWidgets::SmallButton(StringCast(*Tag.ToString()).Get(), Color); + if (Inline) + { + ImGui::SameLine(); + } + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityHelper::RenderTagContainer( + const FGameplayTagContainer& ContainerTags, + const FGameplayTagContainer& TagsToMatch, + const bool InverseMatch, + const bool OnlyShowMatches, + const bool Inline, + const ImVec4& NormalColor, + const ImVec4& MatchColor) +{ + TArray Tags; + ContainerTags.GetGameplayTagArray(Tags); + + for (const FGameplayTag& Tag : Tags) + { + bool hasTag = TagsToMatch.HasTag(Tag); + hasTag = InverseMatch ? !hasTag : hasTag; + + if (OnlyShowMatches && hasTag == false) { + continue; + } + + const ImVec4 Color = hasTag ? MatchColor : NormalColor; + FCogWindowWidgets::SmallButton(StringCast(*Tag.ToString()).Get(), Color); + if (Inline) + { + ImGui::SameLine(); + } } } \ 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 46dd13b..60c5b91 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp @@ -7,8 +7,12 @@ #include "CogAbilityReplicator.h" #include "CogImguiHelper.h" #include "CogWindowWidgets.h" +#include "CogDebugRob.h" #include "imgui.h" +DEFINE_PRIVATE_ACCESSOR_VARIABLE(GameplayAbility_ActivationBlockedTags, UGameplayAbility, FGameplayTagContainer, ActivationBlockedTags); +DEFINE_PRIVATE_ACCESSOR_VARIABLE(GameplayAbility_ActivationRequiredTags, UGameplayAbility, FGameplayTagContainer, ActivationRequiredTags); + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Abilities::Initialize() { @@ -41,9 +45,9 @@ void FCogAbilityWindow_Abilities::ResetConfig() } //-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityWindow_Abilities::RenderTick(float DetlaTime) +void FCogAbilityWindow_Abilities::RenderTick(float DeltaTime) { - Super::RenderTick(DetlaTime); + Super::RenderTick(DeltaTime); RenderOpenAbilities(); } @@ -112,13 +116,13 @@ void FCogAbilityWindow_Abilities::RenderContent() return; } - RenderAbiltiesMenu(Selection); + RenderAbilitiesMenu(Selection); RenderAbilitiesTable(*AbilitySystemComponent); } //-------------------------------------------------------------------------------------------------------------------------- -void FCogAbilityWindow_Abilities::RenderAbiltiesMenu(AActor* Selection) +void FCogAbilityWindow_Abilities::RenderAbilitiesMenu(AActor* Selection) { if (ImGui::BeginMenuBar()) { @@ -151,16 +155,11 @@ void FCogAbilityWindow_Abilities::RenderAbiltiesMenu(AActor* Selection) 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); + RenderAbilitiesMenuFilters(); 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); + RenderAbilitiesMenuColorSettings(); ImGui::Separator(); @@ -178,6 +177,83 @@ void FCogAbilityWindow_Abilities::RenderAbiltiesMenu(AActor* Selection) } } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderAbilitiesMenuFilters() +{ + ImGui::Checkbox("Sort by Name", &Config->SortByName); + ImGui::Checkbox("Show Active", &Config->ShowActive); + ImGui::Checkbox("Show Inactive", &Config->ShowInactive); + ImGui::Checkbox("Show Pressed", &Config->ShowPressed); + ImGui::Checkbox("Show Blocked", &Config->ShowBlocked); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderAbilitiesMenuColorSettings() +{ + ImGui::ColorEdit4("Active Color", (float*)&Config->ActiveAbilityColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Inactive Color", (float*)&Config->InactiveAbilityColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Blocked Color", (float*)&Config->BlockedAbilityColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Default Tag Color", (float*)&Config->DefaultTagsColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Blocked Tag Color", (float*)&Config->BlockedTagsColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Input Pressed Color", (float*)&Config->InputPressedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderAbilityActivation(FGameplayAbilitySpec& Spec) +{ + FCogWindowWidgets::PushStyleCompact(); + bool IsActive = Spec.IsActive(); + if (ImGui::Checkbox("##Activation", &IsActive)) + { + AbilityHandleToActivate = Spec.Handle; + } + FCogWindowWidgets::PopStyleCompact(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityName(UAbilitySystemComponent& AbilitySystemComponent, int& SelectedIndex, int Index, FGameplayAbilitySpec& Spec, UGameplayAbility* Ability) +{ + const ImVec4 Color = GetAbilityColor(AbilitySystemComponent, Spec); + ImGui::PushStyleColor(ImGuiCol_Text, Color); + + if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick)) + { + SelectedIndex = Index; + + if (ImGui::IsMouseDoubleClicked(0)) + { + OpenAbility(Spec.Handle); + } + } + + ImGui::PopStyleColor(1); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderAbilitiesTableAbilityBlocking(UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility* Ability) +{ + if (Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false) + { + FGameplayTagContainer OwnedGameplayTags; + AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags); + + if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags)) + { + FGameplayTagContainer AllBlockingTags; + AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags); + AllBlockingTags.AppendTags(OwnedGameplayTags); + + FCogAbilityHelper::RenderTagContainer(*ActivationBlockedTags, AllBlockingTags, false, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor)); + } + + ImGui::SameLine(); + if (const FGameplayTagContainer* ActivationRequiredTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationRequiredTags)) + { + FCogAbilityHelper::RenderTagContainer(*ActivationRequiredTags, OwnedGameplayTags, true, true, true, ImVec4(0, 0, 0, 0), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor)); + } + } +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& AbilitySystemComponent) { @@ -185,7 +261,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& TArray FitleredAbilities; - for (FGameplayAbilitySpec& Spec: Abilities) + for (FGameplayAbilitySpec& Spec : Abilities) { const UGameplayAbility* Ability = Spec.GetPrimaryInstance(); if (Ability == nullptr) @@ -193,24 +269,10 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& 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) + if (ShouldShowAbility(AbilitySystemComponent, Spec, Ability) == false) { - continue; - } - - if (Config->ShowActive == false && IsJustActive) - { - continue; - } - - if (Config->ShowInactive == false && IsJustInactive) - { - continue; - } + continue; + } const auto AbilityName = StringCast(*GetAbilityName(Ability)); if (Filter.PassFilter(AbilityName.Get()) == false) @@ -229,24 +291,8 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& }); } - if (ImGui::BeginTable("Abilities", 6, ImGuiTableFlags_SizingFixedFit - | ImGuiTableFlags_Resizable - | ImGuiTableFlags_NoBordersInBodyUntilResize - | ImGuiTableFlags_ScrollY - | ImGuiTableFlags_RowBg - | ImGuiTableFlags_BordersV - | ImGuiTableFlags_Reorderable - | ImGuiTableFlags_Hideable)) + if (RenderAbilitiesTableHeader(AbilitySystemComponent)) { - ImGui::TableSetupColumn("##Activation", 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; @@ -262,83 +308,7 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& ImGui::PushID(Index); - const ImVec4 Color = GetAbilityColor(AbilitySystemComponent, Spec); - ImGui::PushStyleColor(ImGuiCol_Text, Color); - - //------------------------ - // Activation - //------------------------ - ImGui::TableNextColumn(); - FCogWindowWidgets::PushStyleCompact(); - bool IsActive = Spec.IsActive(); - if (ImGui::Checkbox("##Activation", &IsActive)) - { - AbilityHandleToActivate = Spec.Handle; - } - FCogWindowWidgets::PopStyleCompact(); - - //------------------------ - // Name - //------------------------ - ImGui::TableNextColumn(); - - if (ImGui::Selectable(TCHAR_TO_ANSI(*GetAbilityName(Ability)), SelectedIndex == Index, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick)) - { - SelectedIndex = Index; - - if (ImGui::IsMouseDoubleClicked(0)) - { - OpenAbility(Spec.Handle); - } - } - - ImGui::PopStyleColor(1); - - //------------------------ - // Popup - //------------------------ - if (ImGui::IsItemHovered()) - { - FCogWindowWidgets::BeginTableTooltip(); - RenderAbilityInfo(AbilitySystemComponent, Spec); - FCogWindowWidgets::EndTableTooltip(); - } - - //------------------------ - // ContextMenu - //------------------------ - RenderAbilityContextMenu(AbilitySystemComponent, Spec, Index); - - //------------------------ - // Level - //------------------------ - ImGui::TableNextColumn(); - ImGui::Text("%d", Spec.Level); - - //------------------------ - // InputPressed - //------------------------ - ImGui::TableNextColumn(); - if (Spec.InputPressed > 0) - { - ImGui::Text("%d", Spec.InputPressed); - } - - //------------------------ - // Cooldown - //------------------------ - ImGui::TableNextColumn(); - RenderAbilityCooldown(AbilitySystemComponent, *Ability); - - //------------------------ - // Blocked - //------------------------ - ImGui::TableNextColumn(); - const bool IsBlocked = Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false; - if (IsBlocked) - { - ImGui::Text("Blocked"); - } + RenderAbilitiesTableRow(AbilitySystemComponent, SelectedIndex, Index, Spec, Ability); ImGui::PopID(); Index++; @@ -348,6 +318,116 @@ void FCogAbilityWindow_Abilities::RenderAbilitiesTable(UAbilitySystemComponent& } } +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogAbilityWindow_Abilities::ShouldShowAbility(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, const UGameplayAbility* Ability) +{ + const bool IsBlocked = Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false; + if (Config->ShowBlocked && IsBlocked) + { + return true; + } + + if (Config->ShowActive && Spec.IsActive()) + { + return true; + } + + if (Config->ShowInactive && Spec.IsActive() == false) + { + return true; + } + + if (Config->ShowPressed && Spec.InputPressed) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------------------------------- +bool FCogAbilityWindow_Abilities::RenderAbilitiesTableHeader(UAbilitySystemComponent& AbilitySystemComponent) +{ + if (ImGui::BeginTable("Abilities", 6, ImGuiTableFlags_SizingFixedFit + | ImGuiTableFlags_Resizable + | ImGuiTableFlags_NoBordersInBodyUntilResize + | ImGuiTableFlags_ScrollY + | ImGuiTableFlags_RowBg + | ImGuiTableFlags_BordersV + | ImGuiTableFlags_Reorderable + | ImGuiTableFlags_Hideable)) + { + ImGui::TableSetupColumn("##Activation", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupScrollFreeze(0, 1); + ImGui::TableSetupColumn("Ability"); + ImGui::TableSetupColumn("Level"); + ImGui::TableSetupColumn("Input"); + ImGui::TableSetupColumn("Cooldown"); + ImGui::TableSetupColumn("Blocking"); + ImGui::TableHeadersRow(); + + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderAbilitiesTableRow(UAbilitySystemComponent& AbilitySystemComponent, int& SelectedIndex, int Index, FGameplayAbilitySpec& Spec, UGameplayAbility* Ability) +{ + //------------------------ + // Activation + //------------------------ + ImGui::TableNextColumn(); + RenderAbilityActivation(Spec); + + //------------------------ + // Name + //------------------------ + ImGui::TableNextColumn(); + RenderAbilitiesTableAbilityName(AbilitySystemComponent, SelectedIndex, Index, Spec, Ability); + + //------------------------ + // Popup + //------------------------ + if (ImGui::IsItemHovered()) + { + FCogWindowWidgets::BeginTableTooltip(); + RenderAbilityInfo(AbilitySystemComponent, Spec); + FCogWindowWidgets::EndTableTooltip(); + } + + //------------------------ + // ContextMenu + //------------------------ + RenderAbilityContextMenu(AbilitySystemComponent, Spec, Index); + + //------------------------ + // Level + //------------------------ + ImGui::TableNextColumn(); + RenderAbilityLevel(Spec); + + //------------------------ + // InputPressed + //------------------------ + ImGui::TableNextColumn(); + RenderAbilityInputPressed(Spec); + + //------------------------ + // Cooldown + //------------------------ + ImGui::TableNextColumn(); + RenderAbilityCooldown(AbilitySystemComponent, *Ability); + + //------------------------ + // Blocking + //------------------------ + ImGui::TableNextColumn(); + RenderAbilitiesTableAbilityBlocking(AbilitySystemComponent, Ability); +} + + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Abilities::RenderAbilityCooldown(const UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility& Ability) { @@ -356,8 +436,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityCooldown(const UAbilitySystemComp return; } - FGameplayAbilitySpec* Spec = Ability.GetCurrentAbilitySpec(); - + const FGameplayAbilitySpec* Spec = Ability.GetCurrentAbilitySpec(); if (Spec == nullptr) { return; @@ -375,6 +454,21 @@ void FCogAbilityWindow_Abilities::RenderAbilityCooldown(const UAbilitySystemComp } } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderAbilityLevel(FGameplayAbilitySpec& Spec) +{ + ImGui::Text("%d", Spec.Level); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderAbilityInputPressed(FGameplayAbilitySpec& Spec) +{ + if (Spec.InputPressed) + { + FCogWindowWidgets::SmallButton("Pressed", FCogImguiHelper::ToImVec4(Config->ActiveAbilityColor)); + } +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Abilities::RenderAbilityContextMenu(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, int Index) { @@ -443,7 +537,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen if (ImGui::BeginTable("Ability", 2, ImGuiTableFlags_Borders)) { - const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); + constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); ImGui::TableSetupColumn("Property"); ImGui::TableSetupColumn("Value"); @@ -510,7 +604,7 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen ImGui::TableNextColumn(); ImGui::TextColored(TextColor, "Level"); ImGui::TableNextColumn(); - ImGui::Text("%d", Spec.Level); + RenderAbilityLevel(Spec); //------------------------ // InputID @@ -526,28 +620,65 @@ void FCogAbilityWindow_Abilities::RenderAbilityInfo(const UAbilitySystemComponen //------------------------ ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextColored(TextColor, "InputPressed"); + ImGui::TextColored(TextColor, "Input Pressed"); ImGui::TableNextColumn(); - ImGui::Text("%d", Spec.InputPressed); + RenderAbilityInputPressed(Spec); //------------------------ // AbilityTags //------------------------ ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::TextColored(TextColor, "AbilityTags"); + ImGui::TextColored(TextColor, "Ability Tags"); ImGui::TableNextColumn(); - const bool SatisfyTagRequirements = Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent); FCogAbilityHelper::RenderTagContainer(Ability->AbilityTags); - //--------------------------------------------- - // TODO: find a way to display blocking tags - //--------------------------------------------- + //------------------------ + // RequiredTags + //------------------------ + FGameplayTagContainer OwnedGameplayTags; + AbilitySystemComponent.GetOwnedGameplayTags(OwnedGameplayTags); + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Required Tags"); + ImGui::TableNextColumn(); + if (const FGameplayTagContainer* ActivationRequiredTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationRequiredTags)) + { + FCogAbilityHelper::RenderTagContainer(*ActivationRequiredTags, OwnedGameplayTags, true, false, false, FCogImguiHelper::ToImVec4(Config->DefaultTagsColor), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor)); + } + + //------------------------ + // BlockingTags + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Blocking Tags"); + ImGui::TableNextColumn(); + if (const FGameplayTagContainer* ActivationBlockedTags = &PRIVATE_ACCESS_PTR(Ability, GameplayAbility_ActivationBlockedTags)) + { + FGameplayTagContainer AllBlockingTags; + AbilitySystemComponent.GetBlockedAbilityTags(AllBlockingTags); + AllBlockingTags.AppendTags(OwnedGameplayTags); + + FCogAbilityHelper::RenderTagContainer(*ActivationBlockedTags, AllBlockingTags, false, false, false, FCogImguiHelper::ToImVec4(Config->DefaultTagsColor), FCogImguiHelper::ToImVec4(Config->BlockedTagsColor)); + } + + //------------------------ + // Additional info + //------------------------ + RenderAbilityAdditionalInfo(AbilitySystemComponent, Spec, *Ability, TextColor); ImGui::EndTable(); } } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Abilities::RenderAbilityAdditionalInfo(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, UGameplayAbility& Ability, const ImVec4& TextColor) +{ + +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Abilities::GameTick(float DeltaTime) { @@ -627,13 +758,13 @@ ImVec4 FCogAbilityWindow_Abilities::GetAbilityColor(const UAbilitySystemComponen if (Spec.IsActive()) { - return FCogImguiHelper::ToImVec4(Config->ActiveColor); + return FCogImguiHelper::ToImVec4(Config->ActiveAbilityColor); } if (Ability != nullptr && Ability->DoesAbilitySatisfyTagRequirements(AbilitySystemComponent) == false) { - return FCogImguiHelper::ToImVec4(Config->BlockedColor); + return FCogImguiHelper::ToImVec4(Config->BlockedAbilityColor); } - return FCogImguiHelper::ToImVec4(Config->InactiveColor); + return FCogImguiHelper::ToImVec4(Config->InactiveAbilityColor); } \ No newline at end of file diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp index 770fe42..38c657d 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp @@ -85,14 +85,14 @@ void FCogAbilityWindow_Effects::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderEffectsTable() { - const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); + const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); if (AbilitySystemComponent == nullptr) { ImGui::TextDisabled("Selection has no ability system component"); return; } - if (ImGui::BeginTable("Effects", 4, ImGuiTableFlags_SizingFixedFit + if (ImGui::BeginTable("Effects", 5, ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBodyUntilResize | ImGuiTableFlags_ScrollY @@ -107,6 +107,7 @@ void FCogAbilityWindow_Effects::RenderEffectsTable() ImGui::TableSetupColumn("Remaining Time"); ImGui::TableSetupColumn("Stacks"); ImGui::TableSetupColumn("Prediction"); + ImGui::TableSetupColumn("Inhibited"); ImGui::TableHeadersRow(); static int SelectedIndex = -1; @@ -258,6 +259,11 @@ void FCogAbilityWindow_Effects::RenderEffectRow(const UAbilitySystemComponent& A ImGui::TableNextColumn(); RenderPrediction(ActiveEffect, true); + //------------------------ + // Inhibited + //------------------------ + ImGui::TableNextColumn(); + RenderInhibition(ActiveEffect, true); } @@ -266,7 +272,7 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& { if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders)) { - constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); + constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); ImGui::TableSetupColumn("Property"); ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch); @@ -325,6 +331,15 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& ImGui::TableNextColumn(); RenderPrediction(ActiveEffect, false); + //------------------------ + // Inhibited + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Inhibited"); + ImGui::TableNextColumn(); + RenderInhibition(ActiveEffect, false); + //------------------------ // Dynamic Asset Tags //------------------------ @@ -406,7 +421,7 @@ void FCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponen if (Duration >= 0) { - const UWorld* World = AbilitySystemComponent.GetWorld(); + const UWorld* World = AbilitySystemComponent.GetWorld(); const float RemainingTime = StartTime + Duration - World->GetTimeSeconds(); ImGui::PushStyleColor(ImGuiCol_PlotHistogram, IM_COL32(100, 100, 100, 255)); @@ -457,6 +472,19 @@ void FCogAbilityWindow_Effects::RenderPrediction(const FActiveGameplayEffect& Ac ImGui::Text("%s", TCHAR_TO_ANSI(*PredictionString)); } +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Effects::RenderInhibition(const FActiveGameplayEffect& ActiveEffect, bool Short) +{ + if (ActiveEffect.bIsInhibited) + { + FCogWindowWidgets::SmallButton("Yes", ImVec4(1, 0, 0, 1)); + } + else + { + ImGui::Text("No"); + } +} + //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::OpenEffect(const FActiveGameplayEffectHandle& Handle) { @@ -472,13 +500,13 @@ void FCogAbilityWindow_Effects::CloseEffect(const FActiveGameplayEffectHandle& H //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderOpenEffects() { - const AActor* Selection = GetSelection(); + const AActor* Selection = GetSelection(); if (Selection == nullptr) { return; } - const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true); + const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true); if (AbilitySystemComponent == nullptr) { return; @@ -486,7 +514,7 @@ void FCogAbilityWindow_Effects::RenderOpenEffects() for (int i = OpenedEffects.Num() - 1; i >= 0; --i) { - const FActiveGameplayEffectHandle Handle = OpenedEffects[i]; + const FActiveGameplayEffectHandle Handle = OpenedEffects[i]; const FActiveGameplayEffect* ActiveEffectPtr = AbilitySystemComponent->GetActiveGameplayEffect(Handle); if (ActiveEffectPtr == nullptr) diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp index a700c09..5f41f7a 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp @@ -235,6 +235,8 @@ void FCogAbilityWindow_OwnedTags::GetTagContainer(FGameplayTagContainer& TagCont } //-------------------------------------------------------------------------------------------------------------------------- +// FCogAbilityWindow_BlockedTags +//------------------------------------------ void FCogAbilityWindow_BlockedTags::Initialize() { Super::Initialize(); diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp new file mode 100644 index 0000000..e971eb3 --- /dev/null +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tasks.cpp @@ -0,0 +1,414 @@ +#include "CogAbilityWindow_Tasks.h" + +#include "AbilitySystemGlobals.h" +#include "AbilitySystemComponent.h" +#include "CogAbilityDataAsset.h" +#include "CogAbilityHelper.h" +#include "CogAbilityReplicator.h" +#include "CogImguiHelper.h" +#include "CogWindowHelper.h" +#include "CogWindowWidgets.h" +#include "imgui.h" + +class UCogAbilityConfig_Tasks; +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::Initialize() +{ + Super::Initialize(); + + bHasMenu = true; + bNoPadding = true; + + Config = GetConfig(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::RenderHelp() +{ + ImGui::Text( + "This window displays the gameplay tasks. "); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::ResetConfig() +{ + Super::ResetConfig(); + + Config->Reset(); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::RenderTick(float DetlaTime) +{ + Super::RenderTick(DetlaTime); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::RenderContent() +{ + Super::RenderContent(); + + AActor* Selection = GetSelection(); + if (Selection == nullptr) + { + ImGui::TextDisabled("Invalid selection"); + return; + } + + UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true); + if (AbilitySystemComponent == nullptr) + { + ImGui::TextDisabled("Selection has no ability system component"); + return; + } + + RenderTaskMenu(Selection); + + RenderTasksTable(*AbilitySystemComponent); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::RenderTaskMenu(AActor* Selection) +{ + if (ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("Options")) + { + ImGui::Checkbox("Sort by Name", &Config->SortByName); + ImGui::Checkbox("Show Uninitialized", &Config->ShowUninitialized); + ImGui::Checkbox("Show Awaiting Activation", &Config->ShowAwaitingActivation); + ImGui::Checkbox("Show Active", &Config->ShowActive); + ImGui::Checkbox("Show Paused", &Config->ShowPaused); + ImGui::Checkbox("Show Finished", &Config->ShowFinished); + ImGui::Checkbox("Show Ticking", &Config->ShowTicking); + ImGui::Checkbox("Show Simulating", &Config->ShowSimulating); + + ImGui::Separator(); + + ImGui::ColorEdit4("Uninitialized Color", (float*)&Config->UninitializedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Awaiting Activation Color", (float*)&Config->AwaitingActivationColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Active Color", (float*)&Config->ActiveColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Paused Color", (float*)&Config->PausedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + ImGui::ColorEdit4("Finished Color", (float*)&Config->FinishedColor, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf); + + ImGui::Separator(); + + if (ImGui::MenuItem("Reset")) + { + ResetConfig(); + } + + ImGui::EndMenu(); + } + + FCogWindowWidgets::SearchBar(Filter); + + ImGui::EndMenuBar(); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::RenderTasksTable(UAbilitySystemComponent& AbilitySystemComponent) +{ + TArray FilteredTasks; + FilteredTasks.Reserve(16); + + const AActor* Selection = GetSelection(); + + for (FConstGameplayTaskIterator it = AbilitySystemComponent.GetKnownTaskIterator(); it; ++it) + { + const UGameplayTask* Task = Cast(*it); + if (Task == nullptr) + { + continue; + } + + const EGameplayTaskState TaskState = Task->GetState(); + + if (Config->ShowUninitialized == false && TaskState == EGameplayTaskState::Uninitialized) + { + continue; + } + + if (Config->ShowAwaitingActivation == false && TaskState == EGameplayTaskState::AwaitingActivation) + { + continue; + } + + if (Config->ShowActive == false && TaskState == EGameplayTaskState::Active) + { + continue; + } + + if (Config->ShowPaused == false && TaskState == EGameplayTaskState::Paused) + { + continue; + } + + if (Config->ShowFinished == false && TaskState == EGameplayTaskState::Finished) + { + continue; + } + + if (Config->ShowTicking == false && Task->IsTickingTask()) + { + continue; + } + + if (Config->ShowSimulating == false && Task->IsSimulating()) + { + continue; + } + + const char* TaskName = StringCast(*Task->GetName()).Get(); + bool PassFilter = Filter.PassFilter(TaskName); + + if (PassFilter == false) + { + if (const UGameplayAbility* Ability = Cast(Task->GetTaskOwner())) + { + const char* AbilityName = StringCast(*FCogAbilityHelper::CleanupName(Ability->GetName())).Get(); + PassFilter = Filter.PassFilter(AbilityName); + } + } + + if (PassFilter == false) + { + continue; + } + + FilteredTasks.Add(Task); + } + + if (Config->SortByName) + { + FilteredTasks.Sort([](const UGameplayTask& Lhs, const UGameplayTask& Rhs) + { + return Lhs.GetName().Compare(Rhs.GetName()) < 0; + }); + } + + if (ImGui::BeginTable("Tasks", 4, ImGuiTableFlags_SizingFixedFit + | ImGuiTableFlags_Resizable + | ImGuiTableFlags_NoBordersInBodyUntilResize + | ImGuiTableFlags_ScrollY + | ImGuiTableFlags_RowBg + | ImGuiTableFlags_BordersV + | ImGuiTableFlags_Reorderable + | ImGuiTableFlags_Hideable)) + { + ImGui::TableSetupScrollFreeze(0, 1); + ImGui::TableSetupColumn("State"); + ImGui::TableSetupColumn("Task"); + ImGui::TableSetupColumn("Owner"); + ImGui::TableSetupColumn("Is Ticking"); + ImGui::TableHeadersRow(); + + static int SelectedIndex = -1; + + ImGuiListClipper Clipper; + Clipper.Begin(FilteredTasks.Num()); + while (Clipper.Step()) + { + for (int32 LineIndex = Clipper.DisplayStart; LineIndex < Clipper.DisplayEnd; LineIndex++) + { + const UGameplayTask* Task = FilteredTasks[LineIndex]; + + ImGui::TableNextRow(); + ImGui::PushID(LineIndex); + + //------------------------ + // State + //------------------------ + ImGui::TableNextColumn(); + RenderTaskState(Task); + + //------------------------ + // Name + //------------------------ + ImGui::TableNextColumn(); + + const char* TaskName = StringCast(*Task->GetName()).Get(); + if (ImGui::Selectable(TaskName, SelectedIndex == LineIndex, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick)) + { + SelectedIndex = LineIndex; + } + + //------------------------ + // Popup + //------------------------ + if (ImGui::IsItemHovered()) + { + FCogWindowWidgets::BeginTableTooltip(); + RenderTaskInfo(Task); + FCogWindowWidgets::EndTableTooltip(); + } + + //------------------------ + // Owner + //------------------------ + ImGui::TableNextColumn(); + RenderTaskOwner(Task); + + //------------------------ + // IsTicking + //------------------------ + ImGui::TableNextColumn(); + ImGui::Text(Task->IsTickingTask() ? "Yes" : "No"); + + ImGui::PopID(); + } + } + Clipper.End(); + + ImGui::EndTable(); + } +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::RenderTaskInfo(const UGameplayTask* Task) +{ + if (Task == nullptr) + { + return; + } + + if (ImGui::BeginTable("Task", 2, ImGuiTableFlags_Borders)) + { + constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); + + ImGui::TableSetupColumn("Property"); + ImGui::TableSetupColumn("Value"); + + //------------------------ + // Name + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Name"); + ImGui::TableNextColumn(); + ImGui::Text(StringCast(*Task->GetName()).Get()); + + //------------------------ + // Instance Name + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Instance Name"); + ImGui::TableNextColumn(); + ImGui::Text(StringCast(*Task->GetInstanceName().ToString()).Get()); + + //------------------------ + // Owner + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Ability"); + ImGui::TableNextColumn(); + RenderTaskOwner(Task); + + //------------------------ + // State + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "State"); + ImGui::TableNextColumn(); + RenderTaskState(Task); + + //------------------------ + // Priority + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Priority"); + ImGui::TableNextColumn(); + ImGui::Text("%d", (int32)Task->GetPriority()); + + //------------------------ + // IsTicking + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Is Ticking"); + ImGui::TableNextColumn(); + ImGui::Text(Task->IsTickingTask() ? "Yes" : "No"); + + //------------------------ + // IsSimulated + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Is Simulated"); + ImGui::TableNextColumn(); + ImGui::Text(Task->IsSimulatedTask() ? "Yes" : "No"); + + //------------------------ + // IsSimulating + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Is Simulating"); + ImGui::TableNextColumn(); + ImGui::Text(Task->IsSimulating() ? "Yes" : "No"); + + //------------------------ + // Debug + //------------------------ + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::TextColored(TextColor, "Debug"); + ImGui::TableNextColumn(); + ImGui::PushTextWrapPos(FCogWindowWidgets::GetFontWidth() * 80); + ImGui::Text(StringCast(*Task->GetDebugString()).Get()); + ImGui::PopTextWrapPos(); + + ImGui::EndTable(); + } +} + + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::RenderTaskOwner(const UGameplayTask* Task) +{ + IGameplayTaskOwnerInterface* TaskOwner = Task->GetTaskOwner(); + + FString OwnerName; + if (const UGameplayAbility* Ability = Cast(TaskOwner)) + { + OwnerName = FCogAbilityHelper::CleanupName(Ability->GetName()); + } + else if (const UObject* Object = Cast(TaskOwner)) + { + OwnerName = GetNameSafe(Object); + } + + ImGui::Text(StringCast(*OwnerName).Get()); +} + +//-------------------------------------------------------------------------------------------------------------------------- +void FCogAbilityWindow_Tasks::RenderTaskState(const UGameplayTask* Task) +{ + switch (Task->GetState()) + { + case EGameplayTaskState::Uninitialized: + FCogWindowWidgets::SmallButton("Uninitialized", FCogImguiHelper::ToImVec4(Config->UninitializedColor)); + break; + + case EGameplayTaskState::AwaitingActivation: + FCogWindowWidgets::SmallButton("Awaiting Activation", FCogImguiHelper::ToImVec4(Config->AwaitingActivationColor)); + break; + + case EGameplayTaskState::Active: + FCogWindowWidgets::SmallButton("Active", FCogImguiHelper::ToImVec4(Config->ActiveColor)); + break; + + case EGameplayTaskState::Paused: + FCogWindowWidgets::SmallButton("Paused", FCogImguiHelper::ToImVec4(Config->PausedColor)); + break; + + case EGameplayTaskState::Finished: + FCogWindowWidgets::SmallButton("Finished", FCogImguiHelper::ToImVec4(Config->FinishedColor)); + break; + } +} diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig_Alignment.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig_Alignment.h index 4492b3f..9b055da 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig_Alignment.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityConfig_Alignment.h @@ -1,7 +1,7 @@ #pragma once #include "CoreMinimal.h" -#include "CogWindowConfig.h" +#include "CogCommonConfig.h" #include "CogAbilityConfig_Alignment.generated.h" class UAbilitySystemComponent; @@ -14,7 +14,7 @@ struct FModifierSpec; //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogAbilityConfig_Alignment : public UCogWindowConfig +class UCogAbilityConfig_Alignment : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityHelper.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityHelper.h index 3cb840f..f0a7fd4 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityHelper.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityHelper.h @@ -15,5 +15,15 @@ public: static FString CleanupName(FString Str); - static void RenderTagContainer(const FGameplayTagContainer& Container); + static void RenderTagContainer(const FGameplayTagContainer& Container, const bool Inline = false, const ImVec4& Color = ImVec4(0.4f, 0.4f, 0.4f, 1.0f)); + + static void RenderTagContainer( + const FGameplayTagContainer& ContainerTags, + const FGameplayTagContainer& TagsToMatch, + const bool InverseMatch = false, + const bool OnlyShowMatches = false, + const bool Inline = false, + const ImVec4& DefaultColor = ImVec4(0.4f, 0.4f, 0.4f, 1.0f), + const ImVec4& MatchColor = ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); + }; diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h index 50bdcd0..99806f3 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Abilities.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "GameplayAbilitySpecHandle.h" #include "CogAbilityWindow_Abilities.generated.h" @@ -26,18 +26,37 @@ protected: virtual void RenderHelp() override; - virtual void RenderTick(float DetlaTime) override; + virtual void RenderTick(float DeltaTime) override; virtual void RenderContent() override; virtual void GameTick(float DeltaTime) override; - virtual void RenderAbiltiesMenu(AActor* Selection); + virtual void RenderAbilitiesMenu(AActor* Selection); + + virtual void RenderAbilitiesMenuFilters(); + + virtual void RenderAbilitiesMenuColorSettings(); virtual FString GetAbilityName(const UGameplayAbility* Ability); - + virtual void RenderAbilitiesTable(UAbilitySystemComponent& AbilitySystemComponent); + virtual bool RenderAbilitiesTableHeader(UAbilitySystemComponent& AbilitySystemComponent); + + virtual void RenderAbilitiesTableRow(UAbilitySystemComponent& AbilitySystemComponent, int& SelectedIndex, int Index, + FGameplayAbilitySpec& Spec, UGameplayAbility* Ability); + + virtual void RenderAbilityActivation(FGameplayAbilitySpec& Spec); + + virtual void RenderAbilitiesTableAbilityName(UAbilitySystemComponent& AbilitySystemComponent, int& SelectedIndex, int Index, FGameplayAbilitySpec& Spec, UGameplayAbility* Ability); + + virtual void RenderAbilitiesTableAbilityBlocking(UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility* Ability); + + virtual void RenderAbilityLevel(FGameplayAbilitySpec& Spec); + + virtual void RenderAbilityInputPressed(FGameplayAbilitySpec& Spec); + virtual void RenderAbilityCooldown(const UAbilitySystemComponent& AbilitySystemComponent, UGameplayAbility& Ability); virtual void RenderAbilityContextMenu(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, int Index); @@ -46,6 +65,8 @@ protected: virtual void RenderAbilityInfo(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec); + virtual void RenderAbilityAdditionalInfo(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, UGameplayAbility& Ability, const ImVec4& TextColor); + virtual void ProcessAbilityActivation(const FGameplayAbilitySpecHandle& Handle); virtual void ActivateAbility(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec); @@ -58,6 +79,9 @@ protected: virtual ImVec4 GetAbilityColor(const UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec); + virtual bool ShouldShowAbility(UAbilitySystemComponent& AbilitySystemComponent, FGameplayAbilitySpec& Spec, + const UGameplayAbility* Ability); + FGameplayAbilitySpecHandle AbilityHandleToActivate; FGameplayAbilitySpecHandle AbilityHandleToRemove; @@ -73,7 +97,7 @@ protected: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogAbilityConfig_Abilities : public UCogWindowConfig +class UCogAbilityConfig_Abilities : public UCogCommonConfig { GENERATED_BODY() @@ -88,17 +112,29 @@ public: UPROPERTY(Config) bool ShowInactive = true; + UPROPERTY(Config) + bool ShowPressed = true; + UPROPERTY(Config) bool ShowBlocked = true; UPROPERTY(Config) - FVector4f ActiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); + FVector4f ActiveAbilityColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); UPROPERTY(Config) - FVector4f InactiveColor = FVector4f(1.0f, 1.0f, 1.0f, 1.0f); + FVector4f InactiveAbilityColor = FVector4f(1.0f, 1.0f, 1.0f, 1.0f); UPROPERTY(Config) - FVector4f BlockedColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + FVector4f BlockedAbilityColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + + UPROPERTY(Config) + FVector4f DefaultTagsColor = FVector4f(0.6f, 0.6f, 0.6f, 1.0f); + + UPROPERTY(Config) + FVector4f BlockedTagsColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + + UPROPERTY(Config) + FVector4f InputPressedColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); virtual void Reset() override { @@ -107,9 +143,13 @@ public: SortByName = false; ShowActive = true; ShowInactive = true; + ShowPressed = 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); + ActiveAbilityColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); + InactiveAbilityColor = FVector4f(1.0f, 1.0f, 1.0f, 1.0f); + BlockedAbilityColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + DefaultTagsColor = FVector4f(0.6f, 0.6f, 0.6f, 1.0f); + BlockedTagsColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + InputPressedColor = FVector4f(0.0f, 1.0f, 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 9d35a38..19fa71c 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Attributes.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogAbilityWindow_Attributes.generated.h" class UAbilitySystemComponent; @@ -42,7 +42,7 @@ private: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogAbilityConfig_Attributes : public UCogWindowConfig +class UCogAbilityConfig_Attributes : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h index 7c24f77..478ea92 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Cheats.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogAbilityWindow_Cheats.generated.h" class AActor; @@ -47,7 +47,7 @@ protected: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogAbilityConfig_Cheats : public UCogWindowConfig +class UCogAbilityConfig_Cheats : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h index 9f5de61..36237dd 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h @@ -2,8 +2,8 @@ #include "CoreMinimal.h" #include "ActiveGameplayEffectHandle.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "imgui.h" #include "CogAbilityWindow_Effects.generated.h" @@ -48,6 +48,8 @@ protected: virtual void RenderPrediction(const FActiveGameplayEffect& ActiveEffect, bool Short); + virtual void RenderInhibition(const FActiveGameplayEffect& ActiveEffect, bool Short); + virtual FString GetEffectName(const UGameplayEffect& Effect); virtual FString GetEffectNameSafe(const UGameplayEffect* Effect); @@ -71,7 +73,7 @@ protected: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogAbilityConfig_Effects : public UCogWindowConfig +class UCogAbilityConfig_Effects : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h index 784d3c3..010ecf1 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tags.h @@ -1,8 +1,8 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogAbilityWindow_Tags.generated.h" struct FGameplayTagContainer; @@ -67,7 +67,7 @@ class COGABILITY_API FCogAbilityWindow_BlockedTags : public FCogAbilityWindow_Ta //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogAbilityConfig_Tags : public UCogWindowConfig +class UCogAbilityConfig_Tags : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tasks.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tasks.h new file mode 100644 index 0000000..b0519df --- /dev/null +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Tasks.h @@ -0,0 +1,106 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogWindow.h" +#include "CogAbilityWindow_Tasks.generated.h" + +class UAbilitySystemComponent; +class UCogAbilityConfig_Tasks; +class UCogAbilityDataAsset; +class UGameplayTask; + +class COGABILITY_API FCogAbilityWindow_Tasks : public FCogWindow +{ + typedef FCogWindow Super; + +public: + + virtual void Initialize() override; + +protected: + + virtual void ResetConfig() override; + + virtual void RenderHelp() override; + + virtual void RenderTick(float DetlaTime) override; + + virtual void RenderContent() override; + + virtual void RenderTaskMenu(AActor* Selection); + + virtual void RenderTasksTable(UAbilitySystemComponent& AbilitySystemComponent); + + virtual void RenderTaskInfo(const UGameplayTask* Task); + + virtual void RenderTaskOwner(const UGameplayTask* Task); + + virtual void RenderTaskState(const UGameplayTask* Task); + + TObjectPtr Config = nullptr; + + ImGuiTextFilter Filter; +}; + +//-------------------------------------------------------------------------------------------------------------------------- +UCLASS(Config = Cog) +class UCogAbilityConfig_Tasks : public UCogCommonConfig +{ + GENERATED_BODY() + +public: + + UPROPERTY(Config) + bool SortByName = false; + + UPROPERTY(Config) + bool ShowTicking = true; + + UPROPERTY(Config) + bool ShowSimulating = true; + + UPROPERTY(Config) + bool ShowUninitialized = true; + + UPROPERTY(Config) + bool ShowAwaitingActivation = true; + + UPROPERTY(Config) + bool ShowActive = true; + + UPROPERTY(Config) + bool ShowPaused = true; + + UPROPERTY(Config) + bool ShowFinished = true; + + UPROPERTY(Config) + FVector4f UninitializedColor = FVector4f(0.0f, 0.0f, 0.0f, 1.0f); + + UPROPERTY(Config) + FVector4f AwaitingActivationColor = FVector4f(0.6f, 0.6f, 0.6f, 1.0f); + + UPROPERTY(Config) + FVector4f ActiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); + + UPROPERTY(Config) + FVector4f PausedColor = FVector4f(0.3f, 0.3f, 0.3f, 1.0f); + + UPROPERTY(Config) + FVector4f FinishedColor = FVector4f(1.0f, 0.5f, 0.5f, 1.0f); + + + virtual void Reset() override + { + Super::Reset(); + + SortByName = false; + ShowTicking = true; + ShowActive = true; + ShowPaused = true; + ShowFinished = true; + ActiveColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); + PausedColor = FVector4f(0.3f, 0.3f, 0.3f, 1.0f); + FinishedColor = FVector4f(0.0f, 1.0f, 0.5f, 1.0f); + } +}; \ No newline at end of file diff --git a/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp b/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp index 15ad279..b44f392 100644 --- a/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp +++ b/Plugins/CogAll/Source/CogAll/Private/CogAll.cpp @@ -6,6 +6,7 @@ #include "CogAbilityWindow_Effects.h" #include "CogAbilityWindow_Pools.h" #include "CogAbilityWindow_Tags.h" +#include "CogAbilityWindow_Tasks.h" #include "CogAbilityWindow_Tweaks.h" #include "CogAIWindow_BehaviorTree.h" #include "CogAIWindow_Blackboard.h" @@ -107,6 +108,8 @@ void Cog::AddAllWindows(UCogWindowManager& CogWindowManager) CogWindowManager.AddWindow("Gameplay.Owned Tags"); + CogWindowManager.AddWindow("Gameplay.Tasks"); + CogWindowManager.AddWindow("Gameplay.Tweaks"); //--------------------------------------- diff --git a/Plugins/CogInput/Source/CogInput/CogInput.Build.cs b/Plugins/CogInput/Source/CogInput/CogInput.Build.cs index 0f0a1d0..4fa3374 100644 --- a/Plugins/CogInput/Source/CogInput/CogInput.Build.cs +++ b/Plugins/CogInput/Source/CogInput/CogInput.Build.cs @@ -22,6 +22,7 @@ public class CogInput : ModuleRules new string[] { "Core", + "CogCommon", "CogImgui", "CogDebug", "CogWindow", diff --git a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h index b751de8..b85ddbd 100644 --- a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h +++ b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Actions.h @@ -1,9 +1,9 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogInjectActionInfo.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "CogInputWindow_Actions.generated.h" class UInputAction; @@ -44,7 +44,7 @@ private: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogInputConfig_Actions : public UCogWindowConfig +class UCogInputConfig_Actions : public UCogCommonConfig { GENERATED_BODY() diff --git a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h index c0a79fd..05913d6 100644 --- a/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h +++ b/Plugins/CogInput/Source/CogInput/Public/CogInputWindow_Gamepad.h @@ -1,9 +1,9 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommonConfig.h" #include "CogInjectActionInfo.h" #include "CogWindow.h" -#include "CogWindowConfig.h" #include "imgui.h" #include "InputCoreTypes.h" #include "CogInputWindow_Gamepad.generated.h" @@ -66,7 +66,7 @@ protected: //-------------------------------------------------------------------------------------------------------------------------- UCLASS(Config = Cog) -class UCogInputConfig_Gamepad : public UCogWindowConfig +class UCogInputConfig_Gamepad : public UCogCommonConfig { GENERATED_BODY()