diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugDraw.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugDraw.cpp index 8efa586..7541629 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugDraw.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugDraw.cpp @@ -2,9 +2,7 @@ #include "CogDebugDrawHelper.h" #include "CogDebugDrawImGui.h" -#include "CogDebugHelper.h" #include "CogDebugLog.h" -#include "CogDebugModule.h" #include "CogDebugReplicator.h" #include "CogDebugSettings.h" #include "CogDebugShape.h" @@ -20,7 +18,7 @@ #if ENABLE_COG //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::String2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FString& Text, const FVector2D& Location, const FColor& Color, bool Persistent) +void FCogDebugDraw::String2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FString& Text, const FVector2D& Location, const FColor& Color, const bool Persistent) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { @@ -37,7 +35,7 @@ void FCogDebugDraw::String2D(const FLogCategoryBase& LogCategory, const UObject* } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Segment2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& SegmentStart, const FVector2D& SegmentEnd, const FColor& Color, bool Persistent) +void FCogDebugDraw::Segment2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& SegmentStart, const FVector2D& SegmentEnd, const FColor& Color, const bool Persistent) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { @@ -54,7 +52,7 @@ void FCogDebugDraw::Segment2D(const FLogCategoryBase& LogCategory, const UObject } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Circle2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Location, float Radius, const FColor& Color, bool Persistent) +void FCogDebugDraw::Circle2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Location, const float Radius, const FColor& Color, const bool Persistent) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { @@ -73,7 +71,7 @@ void FCogDebugDraw::Circle2D(const FLogCategoryBase& LogCategory, const UObject* //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Rect2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Min, const FVector2D& Max, const FColor& Color, bool Persistent) +void FCogDebugDraw::Rect2D(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector2D& Min, const FVector2D& Max, const FColor& Color, const bool Persistent) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { @@ -98,7 +96,7 @@ void FCogDebugDraw::String(const FLogCategoryBase& LogCategory, const UObject* W return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -126,7 +124,7 @@ void FCogDebugDraw::Point(const FLogCategoryBase& LogCategory, const UObject* Wo return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -153,7 +151,7 @@ void FCogDebugDraw::Segment(const FLogCategoryBase& LogCategory, const UObject* return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -183,7 +181,7 @@ void FCogDebugDraw::Bone(const FLogCategoryBase& LogCategory, const UObject* Wor return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -222,7 +220,7 @@ void FCogDebugDraw::Arrow(const FLogCategoryBase& LogCategory, const UObject* Wo return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -246,20 +244,20 @@ void FCogDebugDraw::Arrow(const FLogCategoryBase& LogCategory, const UObject* Wo } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Axis(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& AxisLoc, const FRotator& AxisRot, float Scale, const bool Persistent, const uint8 DepthPriority) +void FCogDebugDraw::Axis(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& AxisLoc, const FRotator& AxisRot, const float Scale, const bool Persistent, const uint8 DepthPriority) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; } - FRotationMatrix R(AxisRot); + const FRotationMatrix R(AxisRot); UE_VLOG_ARROW(WorldContextObject, LogCategory, Verbose, AxisLoc, AxisLoc + R.GetScaledAxis(EAxis::X) * Scale, FColor::Red, TEXT_EMPTY); UE_VLOG_ARROW(WorldContextObject, LogCategory, Verbose, AxisLoc, AxisLoc + R.GetScaledAxis(EAxis::Y) * Scale, FColor::Green, TEXT_EMPTY); UE_VLOG_ARROW(WorldContextObject, LogCategory, Verbose, AxisLoc, AxisLoc + R.GetScaledAxis(EAxis::Z) * Scale, FColor::Blue, TEXT_EMPTY); @@ -285,7 +283,7 @@ void FCogDebugDraw::Circle(const FLogCategoryBase& LogCategory, const UObject* W return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -312,14 +310,14 @@ void FCogDebugDraw::Circle(const FLogCategoryBase& LogCategory, const UObject* W } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::CircleArc(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FColor& Color, const bool Persistent, const uint8 DepthPriority) +void FCogDebugDraw::CircleArc(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, const float InnerRadius, const float OuterRadius, const float Angle, const FColor& Color, const bool Persistent, const uint8 DepthPriority) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -353,7 +351,7 @@ void FCogDebugDraw::FlatCapsule(const FLogCategoryBase& LogCategory, const UObje return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -379,14 +377,14 @@ void FCogDebugDraw::FlatCapsule(const FLogCategoryBase& LogCategory, const UObje } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Sphere(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Location, float Radius, const FColor& Color, const bool Persistent, const uint8 DepthPriority) +void FCogDebugDraw::Sphere(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FVector& Location, const float Radius, const FColor& Color, const bool Persistent, const uint8 DepthPriority) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -417,7 +415,7 @@ void FCogDebugDraw::Box(const FLogCategoryBase& LogCategory, const UObject* Worl return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -448,7 +446,7 @@ void FCogDebugDraw::SolidBox(const FLogCategoryBase& LogCategory, const UObject* return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -476,14 +474,14 @@ void FCogDebugDraw::SolidBox(const FLogCategoryBase& LogCategory, const UObject* } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Frustrum(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, const float Angle, const float AspectRatio, const float NearPlane, const float FarPlane, const FColor& Color, const bool Persistent, const uint8 DepthPriority) +void FCogDebugDraw::Frustum(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, const float Angle, const float AspectRatio, const float NearPlane, const float FarPlane, const FColor& Color, const bool Persistent, const uint8 DepthPriority) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -515,7 +513,7 @@ void FCogDebugDraw::Capsule(const FLogCategoryBase& LogCategory, const UObject* return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -540,29 +538,29 @@ void FCogDebugDraw::Capsule(const FLogCategoryBase& LogCategory, const UObject* } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Points(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const TArray& Points, float Radius, const FColor& StartColor, const FColor& EndColor, const bool Persistent, const uint8 DepthPriority) +void FCogDebugDraw::Points(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const TArray& Points, const float Radius, const FColor& StartColor, const FColor& EndColor, const bool Persistent, const uint8 DepthPriority) { if (FCogDebugLog::IsLogCategoryActive(LogCategory)) { - int32 index = 0; + int32 Index = 0; for (const FVector& Point : Points) { - const FLinearColor Color = FLinearColor::LerpUsingHSV(FLinearColor(StartColor), FLinearColor(EndColor), Points.Num() <= 1 ? 0.0f : index / (float)(Points.Num() - 1)); + const FLinearColor Color = FLinearColor::LerpUsingHSV(FLinearColor(StartColor), FLinearColor(EndColor), Points.Num() <= 1 ? 0.0f : Index / (float)(Points.Num() - 1)); Sphere(LogCategory, WorldContextObject, Point, Radius, Color.ToFColor(true), Persistent, DepthPriority); - index++; + Index++; } } } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Path(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const TArray& Points, float PointSize, const FColor& StartColor, const FColor& EndColor, const bool Persistent, const uint8 DepthPriority) +void FCogDebugDraw::Path(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const TArray& Points, const float PointSize, const FColor& StartColor, const FColor& EndColor, const bool Persistent, const uint8 DepthPriority) { if (FCogDebugLog::IsLogCategoryActive(LogCategory) == false) { return; } - UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); + const UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); if (World == nullptr) { return; @@ -594,7 +592,7 @@ void FCogDebugDraw::Path(const FLogCategoryBase& LogCategory, const UObject* Wor } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugDraw::Skeleton(const FLogCategoryBase& LogCategory, const USkeletalMeshComponent* Skeleton, const FColor& Color, bool DrawSecondaryBones, uint8 DepthPriority) +void FCogDebugDraw::Skeleton(const FLogCategoryBase& LogCategory, const USkeletalMeshComponent* Skeleton, const FColor& Color, const bool DrawSecondaryBones, const uint8 DepthPriority) { if (Skeleton == nullptr) { @@ -614,7 +612,7 @@ void FCogDebugDraw::Skeleton(const FLogCategoryBase& LogCategory, const USkeleta { if (DrawSecondaryBones == false) { - FName BoneName = ReferenceSkeleton.GetBoneName(BoneIndex); + const FName BoneName = ReferenceSkeleton.GetBoneName(BoneIndex); if (FCogDebugSettings::IsSecondarySkeletonBone(BoneName)) { continue; diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp index 6af03c8..0c94fdf 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawBlueprint.cpp @@ -4,7 +4,7 @@ #include "CogDebugLogCategory.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawString(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector Location, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawString(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FString& Text, const FVector Location, const FLinearColor Color, const bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -15,7 +15,7 @@ void UCogDebugDrawBlueprint::DebugDrawString(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawPoint(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Size, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawPoint(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Location, const float Size, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -26,7 +26,7 @@ void UCogDebugDrawBlueprint::DebugDrawPoint(const UObject* WorldContextObject, F } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawSegment(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawSegment(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -37,7 +37,7 @@ void UCogDebugDrawBlueprint::DebugDrawSegment(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawArrow(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawArrow(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector SegmentStart, const FVector SegmentEnd, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -48,7 +48,7 @@ void UCogDebugDrawBlueprint::DebugDrawArrow(const UObject* WorldContextObject, F } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawAxis(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, const FRotator Rotation, float Scale, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawAxis(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Location, const FRotator Rotation, const float Scale, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -59,7 +59,7 @@ void UCogDebugDrawBlueprint::DebugDrawAxis(const UObject* WorldContextObject, FC } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawSphere(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Location, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawSphere(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Location, const float Radius, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -70,7 +70,7 @@ void UCogDebugDrawBlueprint::DebugDrawSphere(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawBox(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -81,7 +81,7 @@ void UCogDebugDrawBlueprint::DebugDrawBox(const UObject* WorldContextObject, FCo } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawSolidBox(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawSolidBox(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Center, const FVector Extent, const FQuat Rotation, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -92,7 +92,7 @@ void UCogDebugDrawBlueprint::DebugDrawSolidBox(const UObject* WorldContextObject } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawCapsule(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector Center, const float HalfHeight, const float Radius, const FQuat Rotation, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawCapsule(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector Center, const float HalfHeight, const float Radius, const FQuat Rotation, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -103,7 +103,7 @@ void UCogDebugDrawBlueprint::DebugDrawCapsule(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawCircle(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float Radius, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawCircle(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FMatrix& Matrix, const float Radius, const FLinearColor Color, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -114,7 +114,7 @@ void UCogDebugDrawBlueprint::DebugDrawCircle(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawCircleArc(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FMatrix& Matrix, float InnerRadius, float OuterRadius, float Angle, const FLinearColor Color, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawCircleArc(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FMatrix& Matrix, const float InnerRadius, const float OuterRadius, const float Angle, const FLinearColor Color, const bool Persistent, uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -125,7 +125,7 @@ void UCogDebugDrawBlueprint::DebugDrawCircleArc(const UObject* WorldContextObjec } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawPoints(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float Radius, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawPoints(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const TArray& Points, const float Radius, const FLinearColor StartColor, const FLinearColor EndColor, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -136,7 +136,7 @@ void UCogDebugDrawBlueprint::DebugDrawPoints(const UObject* WorldContextObject, } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawPath(const UObject* WorldContextObject, FCogLogCategory LogCategory, const TArray& Points, float PointSize, const FLinearColor StartColor, const FLinearColor EndColor, bool Persistent, uint8 DepthPriority) +void UCogDebugDrawBlueprint::DebugDrawPath(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const TArray& Points, const float PointSize, const FLinearColor StartColor, const FLinearColor EndColor, const bool Persistent, const uint8 DepthPriority) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -147,7 +147,7 @@ void UCogDebugDrawBlueprint::DebugDrawPath(const UObject* WorldContextObject, FC } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawString2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FString& Text, const FVector2D Location, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawString2D(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FString& Text, const FVector2D Location, const FLinearColor Color, const bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -158,7 +158,7 @@ void UCogDebugDrawBlueprint::DebugDrawString2D(const UObject* WorldContextObject } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawSegment2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D SegmentStart, const FVector2D SegmentEnd, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawSegment2D(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector2D SegmentStart, const FVector2D SegmentEnd, const FLinearColor Color, const bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -169,7 +169,7 @@ void UCogDebugDrawBlueprint::DebugDrawSegment2D(const UObject* WorldContextObjec } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawCircle2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Location, float Radius, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawCircle2D(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector2D Location, const float Radius, const FLinearColor Color, const bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) @@ -180,7 +180,7 @@ void UCogDebugDrawBlueprint::DebugDrawCircle2D(const UObject* WorldContextObject } //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugDrawBlueprint::DebugDrawRect2D(const UObject* WorldContextObject, FCogLogCategory LogCategory, const FVector2D Min, const FVector2D Max, const FLinearColor Color, bool Persistent) +void UCogDebugDrawBlueprint::DebugDrawRect2D(const UObject* WorldContextObject, const FCogLogCategory LogCategory, const FVector2D Min, const FVector2D Max, const FLinearColor Color, const bool Persistent) { #if ENABLE_COG if (const FLogCategoryBase* LogCategoryPtr = LogCategory.GetLogCategory()) diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp index f670e81..44a9c90 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugDrawHelper.cpp @@ -8,13 +8,13 @@ namespace { //---------------------------------------------------------------------------------------------------------------------- - ULineBatchComponent* GetDebugLineBatcher(const UWorld* InWorld, bool bPersistentLines, float LifeTime, bool bDepthIsForeground) + ULineBatchComponent* GetDebugLineBatcher(const UWorld* InWorld, const bool bPersistentLines, const float LifeTime, const bool bDepthIsForeground) { return (InWorld ? (bDepthIsForeground ? InWorld->ForegroundLineBatcher : ((bPersistentLines || (LifeTime > 0.f)) ? InWorld->PersistentLineBatcher : InWorld->LineBatcher)) : nullptr); } //---------------------------------------------------------------------------------------------------------------------- - static float GetLineLifeTime(ULineBatchComponent* LineBatcher, float LifeTime, bool bPersistent) + static float GetLineLifeTime(const ULineBatchComponent* LineBatcher, const float LifeTime, const bool bPersistent) { return bPersistent ? -1.0f : ((LifeTime > 0.f) ? LifeTime : LineBatcher->DefaultLifeTime); } @@ -136,8 +136,8 @@ void FCogDebugDrawHelper::DrawFlatCapsule( const uint8 DepthPriority, const float Thickness) { - FVector2D Forward = (End - Start).GetSafeNormal(); - FVector2D Right = FVector2D(-Forward.Y, Forward.X); + const FVector2D Forward = (End - Start).GetSafeNormal(); + const FVector2D Right = FVector2D(-Forward.Y, Forward.X); ::DrawDebugLine(InWorld, FVector(Start - Right * Radius, Z), FVector(End - Right * Radius, Z), Color, bPersistentLines, LifeTime, DepthPriority, Thickness); ::DrawDebugLine(InWorld, FVector(Start + Right * Radius, Z), FVector(End + Right * Radius, Z), Color, bPersistentLines, LifeTime, DepthPriority, Thickness); @@ -162,8 +162,8 @@ void FCogDebugDrawHelper::DrawRaycastSingle( { if (DrawType != EDrawDebugTrace::None) { - bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent; - float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f; + const bool DrawPersistent = DrawType == EDrawDebugTrace::Persistent; + const float DrawTime = (DrawType == EDrawDebugTrace::ForDuration) ? DrawDuration : 0.f; if (bHit && Hit.bBlockingHit) { @@ -390,9 +390,9 @@ void FCogDebugDrawHelper::DrawFrustum( const uint8 DepthPriority, const float Thickness) { - FVector Direction(1, 0, 0); - FVector LeftVector(0, 1, 0); - FVector UpVector(0, 0, 1); + const FVector Direction(1, 0, 0); + const FVector LeftVector(0, 1, 0); + const FVector UpVector(0, 0, 1); FVector Verts[8]; diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugHelper.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugHelper.cpp index a2c9f49..29213bc 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugHelper.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugHelper.cpp @@ -9,7 +9,7 @@ FColor FCogDebugHelper::GetAutoColor(FName Name, const FColor& UserColor) } else { - uint32 Hash = GetTypeHash(Name.ToString()); + const uint32 Hash = GetTypeHash(Name.ToString()); FMath::RandInit(Hash); const uint8 Hue = (uint8)(FMath::FRand() * 255); @@ -41,7 +41,7 @@ const char* FCogDebugHelper::VerbosityToString(ELogVerbosity::Type Verbosity) //-------------------------------------------------------------------------------------------------------------------------- FString FCogDebugHelper::ShortenEnumName(FString EnumNameString) { - int32 ScopeIndex = EnumNameString.Find(TEXT("::"), ESearchCase::CaseSensitive); + const int32 ScopeIndex = EnumNameString.Find(TEXT("::"), ESearchCase::CaseSensitive); if (ScopeIndex != INDEX_NONE) { return EnumNameString.Mid(ScopeIndex + 2); diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugLog.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugLog.cpp index bb92bea..2845d9e 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugLog.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugLog.cpp @@ -34,7 +34,7 @@ FString FCogDebugLogCategoryInfo::GetDisplayName() const //-------------------------------------------------------------------------------------------------------------------------- // FCogDebugLogCategoryManager //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugLog::AddLogCategory(FLogCategoryBase& LogCategory, const FString& DisplayName, const FString& Description, bool bVisible) +void FCogDebugLog::AddLogCategory(FLogCategoryBase& LogCategory, const FString& DisplayName, const FString& Description, const bool bVisible) { LogCategories.Add(LogCategory.GetCategoryName(), FCogDebugLogCategoryInfo @@ -48,7 +48,7 @@ void FCogDebugLog::AddLogCategory(FLogCategoryBase& LogCategory, const FString& } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogDebugLog::IsVerbosityActive(ELogVerbosity::Type Verbosity) +bool FCogDebugLog::IsVerbosityActive(const ELogVerbosity::Type Verbosity) { return Verbosity >= ELogVerbosity::Verbose; } @@ -60,9 +60,9 @@ bool FCogDebugLog::IsLogCategoryActive(const FLogCategoryBase& LogCategory) } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogDebugLog::IsLogCategoryActive(FName CategoryName) +bool FCogDebugLog::IsLogCategoryActive(const FName CategoryName) { - if (FLogCategoryBase* LogCategory = FindLogCategory(CategoryName)) + if (const FLogCategoryBase* LogCategory = FindLogCategory(CategoryName)) { return IsVerbosityActive(LogCategory->GetVerbosity()); } @@ -71,13 +71,13 @@ bool FCogDebugLog::IsLogCategoryActive(FName CategoryName) } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugLog::SetLogCategoryActive(FLogCategoryBase& LogCategory, bool Value) +void FCogDebugLog::SetLogCategoryActive(FLogCategoryBase& LogCategory, const bool Value) { LogCategory.SetVerbosity(Value ? ELogVerbosity::Verbose : ELogVerbosity::Warning); } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugLog::OnServerVerbosityChanged(FName CategoryName, ELogVerbosity::Type Verbosity) +void FCogDebugLog::OnServerVerbosityChanged(const FName CategoryName, const ELogVerbosity::Type Verbosity) { if (FCogDebugLogCategoryInfo* LogCategoryInfo = FindLogCategoryInfo(CategoryName)) { @@ -86,9 +86,9 @@ void FCogDebugLog::OnServerVerbosityChanged(FName CategoryName, ELogVerbosity::T } //-------------------------------------------------------------------------------------------------------------------------- -ELogVerbosity::Type FCogDebugLog::GetServerVerbosity(FName CategoryName) +ELogVerbosity::Type FCogDebugLog::GetServerVerbosity(const FName CategoryName) { - if (FCogDebugLogCategoryInfo* LogCategoryInfo = FindLogCategoryInfo(CategoryName)) + if (const FCogDebugLogCategoryInfo* LogCategoryInfo = FindLogCategoryInfo(CategoryName)) { return LogCategoryInfo->ServerVerbosity; } @@ -97,7 +97,7 @@ ELogVerbosity::Type FCogDebugLog::GetServerVerbosity(FName CategoryName) } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugLog::SetServerVerbosity(UWorld& World, FName CategoryName, ELogVerbosity::Type Verbosity) +void FCogDebugLog::SetServerVerbosity(UWorld& World, const FName CategoryName, ELogVerbosity::Type Verbosity) { if (ACogDebugReplicator* Replicator = ACogDebugReplicator::GetLocalReplicator(World)) { @@ -106,27 +106,27 @@ void FCogDebugLog::SetServerVerbosity(UWorld& World, FName CategoryName, ELogVer } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugLog::SetServerVerbosityActive(UWorld& World, FName CategoryName, bool Value) +void FCogDebugLog::SetServerVerbosityActive(UWorld& World, const FName CategoryName, const bool Value) { SetServerVerbosity(World, CategoryName, Value ? ELogVerbosity::Verbose : ELogVerbosity::Warning); } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogDebugLog::IsServerVerbosityActive(FName CategoryName) +bool FCogDebugLog::IsServerVerbosityActive(const FName CategoryName) { return IsVerbosityActive(GetServerVerbosity(CategoryName)); } //-------------------------------------------------------------------------------------------------------------------------- -FCogDebugLogCategoryInfo* FCogDebugLog::FindLogCategoryInfo(FName CategoryName) +FCogDebugLogCategoryInfo* FCogDebugLog::FindLogCategoryInfo(const FName CategoryName) { return LogCategories.Find(CategoryName); } //-------------------------------------------------------------------------------------------------------------------------- -FLogCategoryBase* FCogDebugLog::FindLogCategory(FName CategoryName) +FLogCategoryBase* FCogDebugLog::FindLogCategory(const FName CategoryName) { - if (FCogDebugLogCategoryInfo* LogCategoryInfo = FindLogCategoryInfo(CategoryName)) + if (const FCogDebugLogCategoryInfo* LogCategoryInfo = FindLogCategoryInfo(CategoryName)) { return LogCategoryInfo->LogCategory; } @@ -139,9 +139,9 @@ FLogCategoryBase* FCogDebugLog::FindLogCategory(FName CategoryName) } //-------------------------------------------------------------------------------------------------------------------------- -void FCogDebugLog::DeactivateAllLogCateories(UWorld& World) +void FCogDebugLog::DeactivateAllLogCategories(UWorld& World) { - FString ToggleStr = TEXT("Log LogCogNone Only"); + const FString ToggleStr = TEXT("Log LogCogNone Only"); GEngine->Exec(&World, *ToggleStr); if (APlayerController* PlayerController = World.GetFirstPlayerController()) diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugLogBlueprint.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugLogBlueprint.cpp index 9adb45a..6288ded 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugLogBlueprint.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugLogBlueprint.cpp @@ -5,7 +5,7 @@ #include "CogDebugLogCategory.h" //-------------------------------------------------------------------------------------------------------------------------- -void UCogDebugLogBlueprint::Log(const UObject* WorldContextObject, FCogLogCategory LogCategory, ECogLogVerbosity Verbosity, const FString& Text) +void UCogDebugLogBlueprint::Log(const UObject* WorldContextObject, const FCogLogCategory LogCategory, ECogLogVerbosity Verbosity, const FString& Text) { #if ENABLE_COG @@ -30,7 +30,7 @@ void UCogDebugLogBlueprint::Log(const UObject* WorldContextObject, FCogLogCatego } //-------------------------------------------------------------------------------------------------------------------------- -bool UCogDebugLogBlueprint::IsLogActive(const UObject* WorldContextObject, FCogLogCategory LogCategory) +bool UCogDebugLogBlueprint::IsLogActive(const UObject* WorldContextObject, const FCogLogCategory LogCategory) { #if ENABLE_COG diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugLogCategory.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugLogCategory.cpp index 2e5fd51..935990d 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugLogCategory.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugLogCategory.cpp @@ -18,7 +18,7 @@ FLogCategoryBase* FCogLogCategory::GetLogCategory() const if (LogCategory == nullptr) { - if (FCogDebugLogCategoryInfo* CategoryInfo = FCogDebugLog::GetLogCategories().Find(Name)) + if (const FCogDebugLogCategoryInfo* CategoryInfo = FCogDebugLog::GetLogCategories().Find(Name)) { LogCategory = CategoryInfo->LogCategory; } diff --git a/Plugins/Cog/Source/CogDebug/Private/CogDebugReplicator.cpp b/Plugins/Cog/Source/CogDebug/Private/CogDebugReplicator.cpp index c297813..c17c893 100644 --- a/Plugins/Cog/Source/CogDebug/Private/CogDebugReplicator.cpp +++ b/Plugins/Cog/Source/CogDebug/Private/CogDebugReplicator.cpp @@ -71,14 +71,14 @@ void ACogDebugReplicator::BeginPlay() { Super::BeginPlay(); - UWorld* World = GetWorld(); + const UWorld* World = GetWorld(); check(World); const ENetMode NetMode = World->GetNetMode(); bHasAuthority = NetMode != NM_Client; OwnerPlayerController = Cast(GetOwner()); - if (OwnerPlayerController->IsLocalController()) + if (OwnerPlayerController != nullptr && OwnerPlayerController->IsLocalController()) { Server_RequestAllCategoriesVerbosity(); Server_SetSelection(FCogDebugSettings::GetSelection()); @@ -122,10 +122,10 @@ void ACogDebugReplicator::Server_SetCategoryVerbosity_Implementation(FName LogCa { #if !UE_BUILD_SHIPPING - ENetMode NetMode = GetWorld()->GetNetMode(); + const ENetMode NetMode = GetWorld()->GetNetMode(); if (NetMode == NM_DedicatedServer || NetMode == NM_ListenServer) { - if (FCogDebugLogCategoryInfo* LogCategoryInfo = FCogDebugLog::FindLogCategoryInfo(LogCategoryName)) + if (const FCogDebugLogCategoryInfo* LogCategoryInfo = FCogDebugLog::FindLogCategoryInfo(LogCategoryName)) { LogCategoryInfo->LogCategory->SetVerbosity((ELogVerbosity::Type)Verbosity); @@ -175,13 +175,13 @@ void ACogDebugReplicator::Server_RequestAllCategoriesVerbosity_Implementation() { #if !UE_BUILD_SHIPPING - ENetMode NetMode = GetWorld()->GetNetMode(); + const ENetMode NetMode = GetWorld()->GetNetMode(); if (NetMode == NM_DedicatedServer || NetMode == NM_ListenServer) { TArray CategoriesData; for (auto& Entry : FCogDebugLog::GetLogCategories()) { - FCogDebugLogCategoryInfo& CategoryInfo = Entry.Value; + const FCogDebugLogCategoryInfo& CategoryInfo = Entry.Value; if (CategoryInfo.LogCategory != nullptr) { CategoriesData.Add( @@ -227,7 +227,7 @@ public: virtual bool IsStateEqual(INetDeltaBaseState* OtherState) override { - FCogReplicatorNetState* Other = static_cast(OtherState); + const FCogReplicatorNetState* Other = static_cast(OtherState); return (ShapesRepCounter == Other->ShapesRepCounter); } @@ -252,7 +252,7 @@ bool FCogReplicatorNetPack::NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms return false; } - FCogReplicatorNetState* OldState = static_cast(DeltaParms.OldState); + const FCogReplicatorNetState* OldState = static_cast(DeltaParms.OldState); FCogReplicatorNetState* NewState = new FCogReplicatorNetState(); check(DeltaParms.NewState); *DeltaParms.NewState = TSharedPtr(NewState); diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugDraw.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugDraw.h index 42193f4..351ca87 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugDraw.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugDraw.h @@ -48,7 +48,7 @@ struct COGDEBUG_API FCogDebugDraw static void Path(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const TArray& Points, float PointSize, const FColor& StartColor, const FColor& EndColor, const bool Persistent, const uint8 DepthPriority = 0U); - static void Frustrum(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, const float Angle, const float AspectRatio, const float NearPlane, const float FarPlane, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U); + static void Frustum(const FLogCategoryBase& LogCategory, const UObject* WorldContextObject, const FMatrix& Matrix, const float Angle, const float AspectRatio, const float NearPlane, const float FarPlane, const FColor& Color, const bool Persistent, const uint8 DepthPriority = 0U); static void Skeleton(const FLogCategoryBase& LogCategory, const USkeletalMeshComponent* Skeleton, const FColor& Color, bool DrawSecondaryBones = false, const uint8 DepthPriority = 1); diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugLog.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugLog.h index 97d2ac6..c668699 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugLog.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugLog.h @@ -36,23 +36,23 @@ struct COGDEBUG_API FCogDebugLog static void SetLogCategoryActive(FLogCategoryBase& LogCategory, bool Value); - static FLogCategoryBase* FindLogCategory(FName LogCategory); + static FLogCategoryBase* FindLogCategory(FName CategoryName); - static FCogDebugLogCategoryInfo* FindLogCategoryInfo(FName LogCategory); + static FCogDebugLogCategoryInfo* FindLogCategoryInfo(FName CategoryName); static TMap& GetLogCategories() { return LogCategories; } - static void SetServerVerbosityActive(UWorld& World, FName LogCategory, bool Value); + static void SetServerVerbosityActive(UWorld& World, FName CategoryName, bool Value); - static bool IsServerVerbosityActive(FName LogCategory); + static bool IsServerVerbosityActive(FName CategoryName); - static ELogVerbosity::Type GetServerVerbosity(FName LogCategory); + static ELogVerbosity::Type GetServerVerbosity(FName CategoryName); - static void SetServerVerbosity(UWorld& World, FName LogCategory, ELogVerbosity::Type Verbosity); + static void SetServerVerbosity(UWorld& World, FName CategoryName, ELogVerbosity::Type Verbosity); - static void OnServerVerbosityChanged(FName LogCategory, ELogVerbosity::Type Verbosity); + static void OnServerVerbosityChanged(FName CategoryName, ELogVerbosity::Type Verbosity); - static void DeactivateAllLogCateories(UWorld& World); + static void DeactivateAllLogCategories(UWorld& World); private: diff --git a/Plugins/Cog/Source/CogDebug/Public/CogDebugLogBlueprint.h b/Plugins/Cog/Source/CogDebug/Public/CogDebugLogBlueprint.h index b37d57f..0f1a422 100644 --- a/Plugins/Cog/Source/CogDebug/Public/CogDebugLogBlueprint.h +++ b/Plugins/Cog/Source/CogDebug/Public/CogDebugLogBlueprint.h @@ -30,6 +30,6 @@ public: static void Log(const UObject* WorldContextObject, FCogLogCategory LogCategory, ECogLogVerbosity Verbosity = ECogLogVerbosity::Verbose, const FString& Text = FString("")); UFUNCTION(BlueprintPure, meta = (DevelopmentOnly, WorldContext = "WorldContextObject")) - static bool IsLogActive(const UObject* WorldContextObject, FCogLogCategory LogCategory); + static bool IsLogActive(const UObject* WorldContextObject, const FCogLogCategory LogCategory); }; \ No newline at end of file diff --git a/Plugins/Cog/Source/CogDebugEditor/Private/CogDebugLogCategoryDetails.cpp b/Plugins/Cog/Source/CogDebugEditor/Private/CogDebugLogCategoryDetails.cpp index fd0ef1e..d9330a4 100644 --- a/Plugins/Cog/Source/CogDebugEditor/Private/CogDebugLogCategoryDetails.cpp +++ b/Plugins/Cog/Source/CogDebugEditor/Private/CogDebugLogCategoryDetails.cpp @@ -4,13 +4,8 @@ #include "CogDebugLog.h" #include "DetailWidgetRow.h" #include "Editor.h" -#include "IPropertyUtilities.h" -#include "Misc/TextFilter.h" #include "PropertyHandle.h" #include "SCogDebugLogCategoryWidget.h" -#include "SlateOptMacros.h" -#include "Widgets/Input/SSearchBox.h" -#include "Widgets/Layout/SSeparator.h" #define LOCTEXT_NAMESPACE "AttributeDetailsCustomization" diff --git a/Plugins/Cog/Source/CogDebugEditor/Private/SCogDebugLogCategoryGraphPin.cpp b/Plugins/Cog/Source/CogDebugEditor/Private/SCogDebugLogCategoryGraphPin.cpp index 58065e8..51bb836 100644 --- a/Plugins/Cog/Source/CogDebugEditor/Private/SCogDebugLogCategoryGraphPin.cpp +++ b/Plugins/Cog/Source/CogDebugEditor/Private/SCogDebugLogCategoryGraphPin.cpp @@ -3,7 +3,6 @@ #include "CogDebugLogCategory.h" #include "ScopedTransaction.h" #include "SCogDebugLogCategoryWidget.h" -#include "UObject/CoreRedirects.h" #include "UObject/UObjectIterator.h" #include "Widgets/SBoxPanel.h" diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineReplicator.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineReplicator.cpp index fc84325..59b95e0 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineReplicator.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineReplicator.cpp @@ -30,9 +30,9 @@ ACogEngineReplicator* ACogEngineReplicator::Spawn(APlayerController* Controller) } //-------------------------------------------------------------------------------------------------------------------------- -ACogEngineReplicator* ACogEngineReplicator::GetLocalReplicator(UWorld& World) +ACogEngineReplicator* ACogEngineReplicator::GetLocalReplicator(const UWorld& World) { - for (TActorIterator It(&World, ACogEngineReplicator::StaticClass()); It; ++It) + for (TActorIterator It(&World, StaticClass()); It; ++It) { ACogEngineReplicator* Replicator = *It; return Replicator; @@ -42,9 +42,9 @@ ACogEngineReplicator* ACogEngineReplicator::GetLocalReplicator(UWorld& World) } //-------------------------------------------------------------------------------------------------------------------------- -void ACogEngineReplicator::GetRemoteReplicators(UWorld& World, TArray& Replicators) +void ACogEngineReplicator::GetRemoteReplicators(const UWorld& World, TArray& Replicators) { - for (TActorIterator It(&World, ACogEngineReplicator::StaticClass()); It; ++It) + for (TActorIterator It(&World, StaticClass()); It; ++It) { ACogEngineReplicator* Replicator = Cast(*It); Replicators.Add(Replicator); @@ -73,7 +73,7 @@ void ACogEngineReplicator::BeginPlay() Super::BeginPlay(); - UWorld* World = GetWorld(); + const UWorld* World = GetWorld(); check(World); const ENetMode NetMode = World->GetNetMode(); bHasAuthority = NetMode != NM_Client; @@ -114,7 +114,7 @@ void ACogEngineReplicator::Server_Spawn_Implementation(const FCogEngineSpawnEntr else { FTransform Transform(FTransform::Identity); - if (APawn* Pawn = GetPlayerController()->GetPawn()) + if (const APawn* Pawn = GetPlayerController()->GetPawn()) { Transform = Pawn->GetTransform(); Transform.SetLocation(Transform.GetLocation() + Transform.GetUnitAxis(EAxis::X) * 200.0f); @@ -165,11 +165,11 @@ void ACogEngineReplicator::Server_SetTimeDilation_Implementation(float Value) } //-------------------------------------------------------------------------------------------------------------------------- -void ACogEngineReplicator::OnRep_TimeDilation() +void ACogEngineReplicator::OnRep_TimeDilation() const { #if !UE_BUILD_SHIPPING - UWorld* World = GetWorld(); + const UWorld* World = GetWorld(); if (World == nullptr) return; diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp index 822006c..c1360b9 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Collisions.cpp @@ -4,7 +4,6 @@ #include "CogDebugSettings.h" #include "CogEngineDataAsset.h" #include "CogImguiHelper.h" -#include "CogWindowHelper.h" #include "Components/BoxComponent.h" #include "Components/CapsuleComponent.h" #include "Components/PrimitiveComponent.h" diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp index 91216a3..b194c7b 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_CommandBindings.cpp @@ -20,7 +20,7 @@ void FCogEngineWindow_CommandBindings::RenderContent() { Super::RenderContent(); - APlayerController* PlayerController = GetLocalPlayerController(); + const APlayerController* PlayerController = GetLocalPlayerController(); if (PlayerController == nullptr) { return; diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp index a079176..88a9c83 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Inspector.cpp @@ -90,7 +90,7 @@ void FCogEngineWindow_Inspector::RenderContent() return; } - FCogEngineInspectorApplyFunction ApplyFunction = FindObjectApplyFunction(InspectedObject.Get()); + const FCogEngineInspectorApplyFunction ApplyFunction = FindObjectApplyFunction(InspectedObject.Get()); ImGui::BeginChild("Inspector", ImVec2(-1, ApplyFunction != nullptr ? -ImGui::GetFrameHeightWithSpacing() : -1), false); @@ -135,7 +135,7 @@ void FCogEngineWindow_Inspector::RenderMenu() int32 NewHistoryIndex = INDEX_NONE; //----------------------------------- - // Backward / Foward + // Backward / Forward //----------------------------------- { if (ImGui::ArrowButton("##Backward", ImGuiDir_Left)) @@ -147,7 +147,7 @@ void FCogEngineWindow_Inspector::RenderMenu() ImGui::SetTooltip("Backward"); } - if (ImGui::ArrowButton("##Foward", ImGuiDir_Right)) + if (ImGui::ArrowButton("##Forward", ImGuiDir_Right)) { NewHistoryIndex = FMath::Min(History.Num(), HistoryIndex + 1); } @@ -161,7 +161,7 @@ void FCogEngineWindow_Inspector::RenderMenu() // Current Inspected Object //----------------------------------- const auto InspectedObjectName = StringCast(*GetNameSafe(InspectedObject.Get())); - ImVec2 Pos = ImGui::GetCursorScreenPos(); + const ImVec2 Pos = ImGui::GetCursorScreenPos(); { ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); ImGui::SameLine(); @@ -906,7 +906,7 @@ bool FCogEngineWindow_Inspector::RenderClass(const FClassProperty* ClassProperty //-------------------------------------------------------------------------------------------------------------------------- bool FCogEngineWindow_Inspector::RenderInterface(const FInterfaceProperty* InterfaceProperty) { - UClass* Class = InterfaceProperty->InterfaceClass; + const UClass* Class = InterfaceProperty->InterfaceClass; if (Class == nullptr) { ImGui::BeginDisabled(); @@ -927,7 +927,7 @@ bool FCogEngineWindow_Inspector::RenderInterface(const FInterfaceProperty* Inter bool FCogEngineWindow_Inspector::RenderArray(const FArrayProperty* ArrayProperty, uint8* PointerToValue, bool ShowChildren) { FScriptArrayHelper Helper(ArrayProperty, PointerToValue); - int32 Num = Helper.Num(); + const int32 Num = Helper.Num(); ImGui::BeginDisabled(); ImGui::Text("%s [%d]", TCHAR_TO_ANSI(*ArrayProperty->Inner->GetClass()->GetName()), Num); @@ -963,8 +963,8 @@ bool FCogEngineWindow_Inspector::HasPropertyAnyChildren(const FProperty* Propert } else if (const FArrayProperty* ArrayProperty = CastField(Property)) { - FScriptArrayHelper Helper(ArrayProperty, PointerToValue); - int32 Num = Helper.Num(); + const FScriptArrayHelper Helper(ArrayProperty, PointerToValue); + const int32 Num = Helper.Num(); if (Num == 0) { return false; @@ -978,7 +978,7 @@ bool FCogEngineWindow_Inspector::HasPropertyAnyChildren(const FProperty* Propert } else if (const FObjectProperty* ObjectProperty = CastField(Property)) { - UObject* ReferencedObject = ObjectProperty->GetObjectPropertyValue(PointerToValue); + const UObject* ReferencedObject = ObjectProperty->GetObjectPropertyValue(PointerToValue); if (ReferencedObject == nullptr) { return false; diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp index 62e8ff4..ab4a7b2 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_LogCategories.cpp @@ -34,7 +34,7 @@ void FCogEngineWindow_LogCategories::ResetConfig() { Super::ResetConfig(); - FCogDebugLog::DeactivateAllLogCateories(*GetWorld()); + FCogDebugLog::DeactivateAllLogCategories(*GetWorld()); } //-------------------------------------------------------------------------------------------------------------------------- @@ -56,7 +56,7 @@ void FCogEngineWindow_LogCategories::RenderContent() { if (ImGui::MenuItem("Deactivate All")) { - FCogDebugLog::DeactivateAllLogCateories(*World); + FCogDebugLog::DeactivateAllLogCategories(*World); } if (ImGui::IsItemHovered(ImGuiHoveredFlags_Stationary)) { @@ -103,6 +103,12 @@ void FCogEngineWindow_LogCategories::RenderContent() ImGui::EndMenuBar(); } + if (FCogDebugLog::GetLogCategories().Num() == 0) + { + ImGui::Text("No log categories have been added."); + return; + } + const bool IsClient = World->GetNetMode() == NM_Client; ImGuiStyle& Style = ImGui::GetStyle(); @@ -110,7 +116,7 @@ void FCogEngineWindow_LogCategories::RenderContent() int Index = 0; for (const auto& Entry : FCogDebugLog::GetLogCategories()) { - FName CategoryName = Entry.Key; + const FName CategoryName = Entry.Key; const FCogDebugLogCategoryInfo& CategoryInfo = Entry.Value; if (CategoryInfo.bVisible == false) { @@ -128,7 +134,7 @@ void FCogEngineWindow_LogCategories::RenderContent() const bool IsControlDown = ImGui::GetIO().KeyCtrl; if (IsClient) { - ELogVerbosity::Type Verbosity = FCogDebugLog::GetServerVerbosity(CategoryName); + const ELogVerbosity::Type Verbosity = FCogDebugLog::GetServerVerbosity(CategoryName); bool IsActive = FCogDebugLog::IsVerbosityActive(Verbosity); if (Verbosity == ELogVerbosity::VeryVerbose) @@ -169,7 +175,7 @@ void FCogEngineWindow_LogCategories::RenderContent() } { - ELogVerbosity::Type Verbosity = Category->GetVerbosity(); + const ELogVerbosity::Type Verbosity = Category->GetVerbosity(); bool IsActive = FCogDebugLog::IsVerbosityActive(Verbosity); if (Verbosity == ELogVerbosity::VeryVerbose) @@ -214,14 +220,14 @@ void FCogEngineWindow_LogCategories::RenderContent() { if (IsClient) { - ELogVerbosity::Type CurrentVerbosity = FCogDebugLog::GetServerVerbosity(CategoryName); + const ELogVerbosity::Type CurrentVerbosity = FCogDebugLog::GetServerVerbosity(CategoryName); FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("##Server", FCogDebugHelper::VerbosityToString(CurrentVerbosity))) { for (int32 i = (int32)ELogVerbosity::Error; i <= (int32)ELogVerbosity::VeryVerbose; ++i) { - bool IsSelected = i == (int32)CurrentVerbosity; - ELogVerbosity::Type Verbosity = (ELogVerbosity::Type)i; + const bool IsSelected = i == (int32)CurrentVerbosity; + const ELogVerbosity::Type Verbosity = (ELogVerbosity::Type)i; if (ImGui::Selectable(FCogDebugHelper::VerbosityToString(Verbosity), IsSelected)) { @@ -244,14 +250,14 @@ void FCogEngineWindow_LogCategories::RenderContent() } { - ELogVerbosity::Type CurrentVerbosity = Category->GetVerbosity(); + const ELogVerbosity::Type CurrentVerbosity = Category->GetVerbosity(); FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("##Local", FCogDebugHelper::VerbosityToString(CurrentVerbosity))) { for (int32 i = (int32)ELogVerbosity::Error; i <= (int32)ELogVerbosity::VeryVerbose; ++i) { - bool IsSelected = i == (int32)CurrentVerbosity; - ELogVerbosity::Type Verbosity = (ELogVerbosity::Type)i; + const bool IsSelected = i == (int32)CurrentVerbosity; + const ELogVerbosity::Type Verbosity = (ELogVerbosity::Type)i; if (ImGui::Selectable(FCogDebugHelper::VerbosityToString(Verbosity), IsSelected)) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp index 941ee4d..d9d4059 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Metrics.cpp @@ -1,7 +1,6 @@ #include "CogEngineWindow_Metrics.h" #include "CogDebugMetric.h" -#include "CogImguiHelper.h" #include "CogWindowWidgets.h" #include "imgui.h" #include "Engine/World.h" @@ -63,9 +62,7 @@ void FCogEngineWindow_Metrics::RenderContent() { if (ImGui::BeginMenu("Options")) { - bool bSettingModified = false; - - FCogWindowWidgets::PushStyleCompact(); + FCogWindowWidgets::PushStyleCompact(); ImGui::DragFloat("Auto Restart Delay", &FCogDebugMetric::RestartDelaySetting, 0.1f, 0.0f, FLT_MAX, "%0.1f"); FCogWindowWidgets::PopStyleCompact(); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp index cca2271..c4df778 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_OutputLog.cpp @@ -5,8 +5,6 @@ #include "Engine/Engine.h" #include "Misc/StringBuilder.h" -//-------------------------------------------------------------------------------------------------------------------------- -// UCogEngineWindow_OutputLog //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_OutputLog::Initialize() { @@ -67,7 +65,7 @@ void FCogEngineWindow_OutputLog::AddLog(const TCHAR* Message, ELogVerbosity::Typ } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInfo& LineInfo, bool IsTableShown) +void FCogEngineWindow_OutputLog::DrawRow(const char* BufferStart, const FLineInfo& LineInfo, bool IsTableShown) const { ImU32 Color; switch (LineInfo.Verbosity) @@ -175,8 +173,8 @@ void FCogEngineWindow_OutputLog::RenderContent() { for (int32 i = (int32)ELogVerbosity::Error; i <= (int32)ELogVerbosity::VeryVerbose; ++i) { - bool IsSelected = i == Config->VerbosityFilter; - ELogVerbosity::Type Verbosity = (ELogVerbosity::Type)i; + const bool IsSelected = i == Config->VerbosityFilter; + const ELogVerbosity::Type Verbosity = (ELogVerbosity::Type)i; if (ImGui::Selectable(FCogDebugHelper::VerbosityToString(Verbosity), IsSelected)) { @@ -316,7 +314,7 @@ FCogLogOutputDevice::~FCogLogOutputDevice() } //-------------------------------------------------------------------------------------------------------------------------- -void FCogLogOutputDevice::Serialize(const TCHAR* Message, ELogVerbosity::Type Verbosity, const class FName& Category) +void FCogLogOutputDevice::Serialize(const TCHAR* Message, const ELogVerbosity::Type Verbosity, const FName& Category) { if (OutputLog != nullptr) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp index 2db6f41..15ae3c1 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Plots.cpp @@ -1,12 +1,10 @@ #include "CogEngineWindow_Plots.h" #include "CogDebugPlot.h" -#include "CogImguiHelper.h" #include "CogWindowWidgets.h" #include "Engine/World.h" #include "imgui.h" #include "implot_internal.h" -#include "Kismet/GameplayStatics.h" //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Plots::Initialize() @@ -169,7 +167,7 @@ void FCogEngineWindow_Plots::RenderPlotsList(TArray& Visibl } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Plots::RenderPlots(const TArray& VisiblePlots) +void FCogEngineWindow_Plots::RenderPlots(const TArray& VisiblePlots) const { if (ImGui::BeginChild("Graph", ImVec2(0, -1))) { @@ -186,14 +184,14 @@ void FCogEngineWindow_Plots::RenderPlots(const TArray& Visi ImPlotAxisFlags HasPlotOnAxisY2 = false; ImPlotAxisFlags HasPlotOnAxisY3 = false; - for (FCogDebugPlotEntry* PlotPtr : VisiblePlots) + for (const FCogDebugPlotEntry* PlotPtr : VisiblePlots) { HasPlotOnAxisY1 |= PlotPtr->CurrentYAxis == ImAxis_Y1 && PlotPtr->CurrentRow == PlotIndex; HasPlotOnAxisY2 |= PlotPtr->CurrentYAxis == ImAxis_Y2 && PlotPtr->CurrentRow == PlotIndex; HasPlotOnAxisY3 |= PlotPtr->CurrentYAxis == ImAxis_Y3 && PlotPtr->CurrentRow == PlotIndex; } - ImPlot::SetupAxis(ImAxis_X1, NULL, ImPlotAxisFlags_NoTickLabels | ImPlotAxisFlags_NoGridLines); + ImPlot::SetupAxis(ImAxis_X1, nullptr, ImPlotAxisFlags_NoTickLabels | ImPlotAxisFlags_NoGridLines); ImPlot::SetupAxis(ImAxis_Y1, HasPlotOnAxisY1 ? "" : "[drop here]", (HasPlotOnAxisY1 ? ImPlotAxisFlags_None : (ImPlotAxisFlags_NoTickLabels | ImPlotAxisFlags_NoGridLines)) | ImPlotAxisFlags_AutoFit); ImPlot::SetupAxis(ImAxis_Y2, HasPlotOnAxisY2 ? "" : "[drop here]", (HasPlotOnAxisY2 ? ImPlotAxisFlags_None : (ImPlotAxisFlags_NoTickLabels | ImPlotAxisFlags_NoGridLines)) | ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_Opposite); ImPlot::SetupAxis(ImAxis_Y3, HasPlotOnAxisY3 ? "" : "[drop here]", (HasPlotOnAxisY3 ? ImPlotAxisFlags_None : (ImPlotAxisFlags_NoTickLabels | ImPlotAxisFlags_NoGridLines)) | ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_Opposite); @@ -259,7 +257,7 @@ void FCogEngineWindow_Plots::RenderPlots(const TArray& Visi && Mouse.y < PlotMax.y && ImGui::GetDragDropPayload() == nullptr) { - ImVec2 Drag = ImGui::GetMouseDragDelta(0); + const ImVec2 Drag = ImGui::GetMouseDragDelta(0); if (FMath::Abs(Drag.x) > 10) { FCogDebugPlot::Pause = true; @@ -354,7 +352,7 @@ void FCogEngineWindow_Plots::RenderPlots(const TArray& Visi } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Plots::RenderTimeMarker() +void FCogEngineWindow_Plots::RenderTimeMarker() const { const ImVec2 PlotMin = ImPlot::GetPlotPos(); const ImVec2 PlotSize = ImPlot::GetPlotSize(); @@ -410,7 +408,7 @@ void FCogEngineWindow_Plots::RenderValues(FCogDebugPlotEntry& Entry, const char* } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Plots::RenderEvents(FCogDebugPlotEntry& Entry, const char* Label, const ImVec2& PlotMin, const ImVec2& PlotMax) +void FCogEngineWindow_Plots::RenderEvents(FCogDebugPlotEntry& Entry, const char* Label, const ImVec2& PlotMin, const ImVec2& PlotMax) const { const ImVec2 Mouse = ImGui::GetMousePos(); ImDrawList* PlotDrawList = ImPlot::GetPlotDrawList(); @@ -444,7 +442,7 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugPlotEntry& Entry, const char* const bool IsInstant = Event.StartTime == Event.EndTime; if (IsInstant) { - const float Radius = 10.0f; + constexpr float Radius = 10.0f; PlotDrawList->AddNgon(PosMid, 10, Event.BorderColor, 4); PlotDrawList->AddNgonFilled(PosMid, 10, Event.FillColor, 4); PlotDrawList->AddText(ImVec2(PosMid.x + 15, PosMid.y - 6), IM_COL32(255, 255, 255, 255), TCHAR_TO_ANSI(*Event.DisplayName)); @@ -461,7 +459,7 @@ void FCogEngineWindow_Plots::RenderEvents(FCogDebugPlotEntry& Entry, const char* const ImVec2 Min = ImVec2(PosBot.x, PosBot.y); const ImVec2 Max = ImVec2(PosEnd.x, PosTop.y); - ImDrawFlags Flags = Event.EndTime == 0.0f ? ImDrawFlags_RoundCornersLeft : ImDrawFlags_RoundCornersAll; + const ImDrawFlags Flags = Event.EndTime == 0.0f ? ImDrawFlags_RoundCornersLeft : ImDrawFlags_RoundCornersAll; PlotDrawList->AddRect(Min, Max, Event.BorderColor, 6.0f, Flags); PlotDrawList->AddRectFilled(Min, Max, Event.FillColor, 6.0f, Flags); PlotDrawList->PushClipRect(ImMax(Min, PlotMin), ImMin(Max, PlotMax)); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp index 961d508..18beba8 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Scalability.cpp @@ -1,15 +1,12 @@ #include "CogEngineWindow_Scalability.h" #include "imgui.h" -#include "CogImguiHelper.h" #include "CogWindowWidgets.h" #include "Engine/Engine.h" #include "Scalability.h" - #define SCALABILITY_NUM_LEVELS 5 - //-------------------------------------------------------------------------------------------------------------------------- void FCogEngineWindow_Scalability::RenderHelp() { @@ -24,7 +21,7 @@ void FCogEngineWindow_Scalability::RenderContent() Super::RenderContent(); Scalability::FQualityLevels Levels = Scalability::GetQualityLevels(); - FString CurrentQualityName = Scalability::GetQualityLevelText(Levels.GetMinQualityLevel(), SCALABILITY_NUM_LEVELS).ToString(); + const FString CurrentQualityName = Scalability::GetQualityLevelText(Levels.GetMinQualityLevel(), SCALABILITY_NUM_LEVELS).ToString(); FCogWindowWidgets::SetNextItemToShortWidth(); if (ImGui::BeginCombo("Scalability", TCHAR_TO_ANSI(*CurrentQualityName))) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp index 61f8874..289387c 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Selection.cpp @@ -1,11 +1,9 @@ #include "CogEngineWindow_Selection.h" -#include "CogDebugDraw.h" #include "CogDebugSettings.h" #include "CogEngineReplicator.h" #include "CogImguiHelper.h" #include "CogImguiInputHelper.h" -#include "CogImguiModule.h" #include "CogWindowManager.h" #include "CogWindowWidgets.h" #include "Components/PrimitiveComponent.h" diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp index c5d7854..2418b7b 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Skeleton.cpp @@ -2,7 +2,6 @@ #include "CogDebugSettings.h" #include "CogWindowWidgets.h" -#include "Components/LineBatchComponent.h" #include "Components/SkeletalMeshComponent.h" #include "DrawDebugHelpers.h" #include "Engine/SkeletalMesh.h" diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Slate.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Slate.cpp index 1d5837a..ab63d64 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Slate.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Slate.cpp @@ -31,7 +31,7 @@ void FCogEngineWindow_Slate::RenderContent() ImGui::SetNextItemWidth(-1); if (ImGui::BeginCombo("##User", TCHAR_TO_ANSI(*FString::Printf(TEXT("%d"), SelectedUserIndex)))) { - SlateApp.ForEachUser([this](FSlateUser& User) + SlateApp.ForEachUser([this](const FSlateUser& User) { if (ImGui::Selectable(TCHAR_TO_ANSI(*FString::Printf(TEXT("%d"), SelectedUserIndex)), false)) { @@ -41,7 +41,7 @@ void FCogEngineWindow_Slate::RenderContent() ImGui::EndCombo(); } - if (TSharedPtr User = SlateApp.GetUser(SelectedUserIndex)) + if (const TSharedPtr User = SlateApp.GetUser(SelectedUserIndex)) { RenderUser(*User.Get()); } @@ -54,7 +54,7 @@ void FCogEngineWindow_Slate::RenderUser(FSlateUser& User) if (ImGui::BeginTable("SlateUser", 2, ImGuiTableFlags_Borders)) { - const ImVec4 LabelColor(1.0f, 1.0f, 1.0f, 0.5f); + constexpr ImVec4 LabelColor(1.0f, 1.0f, 1.0f, 0.5f); ImGui::TableSetupColumn("Property"); ImGui::TableSetupColumn("Value"); @@ -68,7 +68,7 @@ void FCogEngineWindow_Slate::RenderUser(FSlateUser& User) ImGui::TextColored(LabelColor, "Focused Widget"); ImGui::TableNextColumn(); FString FocusedWidgetText = "None"; - if (TSharedPtr FocusedWidget = User.GetFocusedWidget()) + if (const TSharedPtr FocusedWidget = User.GetFocusedWidget()) { FocusedWidgetText = FocusedWidget->ToString(); } @@ -81,12 +81,12 @@ void FCogEngineWindow_Slate::RenderUser(FSlateUser& User) ImGui::TableNextColumn(); ImGui::TextColored(LabelColor, "Cursor Captor"); ImGui::TableNextColumn(); - FString CursorCaptoreWidgetText = "None"; - if (TSharedPtr CursorCaptoreWidget = User.GetCursorCaptor()) + FString CursorCaptorWidgetText = "None"; + if (const TSharedPtr CursorCaptorWidget = User.GetCursorCaptor()) { - CursorCaptoreWidgetText = CursorCaptoreWidget->ToString(); + CursorCaptorWidgetText = CursorCaptorWidget->ToString(); } - ImGui::Text("%s", TCHAR_TO_ANSI(*CursorCaptoreWidgetText)); + ImGui::Text("%s", TCHAR_TO_ANSI(*CursorCaptorWidgetText)); //------------------------ // Cursor Position diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp index d6a57d4..d318013 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Spawns.cpp @@ -3,7 +3,6 @@ #include "CogEngineDataAsset.h" #include "CogEngineReplicator.h" #include "CogImguiHelper.h" -#include "CogWindowHelper.h" #include "CogWindowWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -31,27 +30,40 @@ void FCogEngineWindow_Spawns::RenderContent() if (Asset == nullptr) { + ImGui::TextDisabled("Invalid Asset"); + return; + } + + ACogEngineReplicator* Replicator = ACogEngineReplicator::GetLocalReplicator(*GetWorld()); + if (Replicator == nullptr) + { + ImGui::TextDisabled("Invalid Replicator"); + return; + } + + if (Asset->SpawnGroups.Num() == 0) + { + ImGui::TextDisabled("No spawn group have been defined"); return; } for (const FCogEngineSpawnGroup& SpawnGroup : Asset->SpawnGroups) { - RenderSpawnGroup(SpawnGroup); + RenderSpawnGroup(*Replicator, SpawnGroup); } } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Spawns::RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup) +void FCogEngineWindow_Spawns::RenderSpawnGroup(ACogEngineReplicator& Replicator, const FCogEngineSpawnGroup& SpawnGroup) { - int32 GroupIndex = 0; - - ImGui::PushStyleColor(ImGuiCol_Header, IM_COL32(66, 66, 66, 79)); + ImGui::PushStyleColor(ImGuiCol_Header, IM_COL32(66, 66, 66, 79)); ImGui::PushStyleColor(ImGuiCol_HeaderHovered, IM_COL32(62, 62, 62, 204)); ImGui::PushStyleColor(ImGuiCol_HeaderActive, IM_COL32(86, 86, 86, 255)); if (ImGui::CollapsingHeader(TCHAR_TO_ANSI(*SpawnGroup.Name), ImGuiTreeNodeFlags_DefaultOpen)) { - ImGui::PushID(GroupIndex); + int32 GroupIndex = 0; + ImGui::PushID(GroupIndex); const bool PushColor = (SpawnGroup.Color != FColor::Transparent); if (PushColor) @@ -64,7 +76,7 @@ void FCogEngineWindow_Spawns::RenderSpawnGroup(const FCogEngineSpawnGroup& Spawn for (const FCogEngineSpawnEntry& SpawnEntry : SpawnGroup.Spawns) { - if (RenderSpawnAsset(SpawnEntry, SelectedAssetIndex == GroupIndex)) + if (RenderSpawnAsset(Replicator, SpawnEntry, SelectedAssetIndex == GroupIndex)) { SelectedAssetIndex = AssetIndex; } @@ -85,7 +97,7 @@ void FCogEngineWindow_Spawns::RenderSpawnGroup(const FCogEngineSpawnGroup& Spawn } //-------------------------------------------------------------------------------------------------------------------------- -bool FCogEngineWindow_Spawns::RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected) +bool FCogEngineWindow_Spawns::RenderSpawnAsset(ACogEngineReplicator& Replicator, const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected) { bool IsPressed = false; @@ -104,10 +116,8 @@ bool FCogEngineWindow_Spawns::RenderSpawnAsset(const FCogEngineSpawnEntry& Spawn if (ImGui::Button(TCHAR_TO_ANSI(*EntryName), ImVec2(-1, 0))) { - if (ACogEngineReplicator* Replicator = ACogEngineReplicator::GetLocalReplicator(*GetWorld())) - { - Replicator->Server_Spawn(SpawnEntry); - } + IsPressed = true; + Replicator.Server_Spawn(SpawnEntry); } ImGui::PopStyleVar(1); diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp index 45ee789..0b62bad 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_Stats.cpp @@ -7,7 +7,6 @@ #include "GameFramework/Controller.h" #include "GameFramework/PlayerController.h" #include "GameFramework/PlayerState.h" -#include "Net/NetPing.h" ImVec4 StatRedColor(1.0f, 0.4f, 0.3f, 1.0f); ImVec4 StatOrangeColor(1.0f, 0.7f, 0.4f, 1.0f); @@ -49,7 +48,7 @@ void FCogEngineWindow_Stats::RenderContent() ImGui::TextColored(GetPingColor(Ping), "%0.0fms", Ping); } - if (UNetConnection* Connection = PlayerController->GetNetConnection()) + if (const UNetConnection* Connection = PlayerController->GetNetConnection()) { const float OutPacketLost = Connection->GetOutLossPercentage().GetAvgLossPercentage() * 100.0f; ImGui::Text("Packet Loss Out "); @@ -65,12 +64,12 @@ void FCogEngineWindow_Stats::RenderContent() } //-------------------------------------------------------------------------------------------------------------------------- -float FCogEngineWindow_Stats::GetMainMenuWidgetWidth(int32 WidgetIndex, float MaxWidth) +float FCogEngineWindow_Stats::GetMainMenuWidgetWidth(const int32 SubWidgetIndex, float MaxWidth) { const APlayerController* PlayerController = GetLocalPlayerController(); const UNetConnection* Connection = PlayerController != nullptr ? PlayerController->GetNetConnection() : nullptr; - switch (WidgetIndex) + switch (SubWidgetIndex) { case 0: return FCogWindowWidgets::GetFontWidth() * 8; case 1: return Connection != nullptr ? FCogWindowWidgets::GetFontWidth() * 7 : 0.0f; @@ -81,9 +80,9 @@ float FCogEngineWindow_Stats::GetMainMenuWidgetWidth(int32 WidgetIndex, float Ma } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Stats::RenderMainMenuWidget(int32 WidgetIndex, float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidget(const int32 SubWidgetIndex, const float Width) { - switch (WidgetIndex) + switch (SubWidgetIndex) { case 0: RenderMainMenuWidgetFramerate(Width); break; case 1: RenderMainMenuWidgetPing(Width); break; @@ -92,10 +91,10 @@ void FCogEngineWindow_Stats::RenderMainMenuWidget(int32 WidgetIndex, float Width } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Stats::RenderMainMenuWidgetFramerate(float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidgetFramerate(const float Width) { extern ENGINE_API float GAverageFPS; - int32 Fps = (int32)GAverageFPS; + const int32 Fps = (int32)GAverageFPS; ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.5f)); @@ -129,7 +128,7 @@ void FCogEngineWindow_Stats::RenderMainMenuWidgetFramerate(float Width) } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Stats::RenderMainMenuWidgetPing(float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidgetPing(const float Width) { const APlayerController* PlayerController = GetLocalPlayerController(); const APlayerState* PlayerState = PlayerController != nullptr ? PlayerController->GetPlayerState() : nullptr; @@ -164,7 +163,7 @@ void FCogEngineWindow_Stats::RenderMainMenuWidgetPing(float Width) ImGui::Text("Ping"); ImGui::SameLine(); - FNamedNetDriver* SelectedNetDriver = &WorldContext.ActiveNetDrivers[0]; + const FNamedNetDriver* SelectedNetDriver = &WorldContext.ActiveNetDrivers[0]; FPacketSimulationSettings Settings = SelectedNetDriver->NetDriver->PacketSimulationSettings; TArray Values{ 0, 50, 100, 200, 500, 1000 }; if (FCogWindowWidgets::MultiChoiceButtonsInt(Values, Settings.PktIncomingLagMin, ImVec2(4.5f * FCogWindowWidgets::GetFontWidth(), 0))) @@ -178,10 +177,10 @@ void FCogEngineWindow_Stats::RenderMainMenuWidgetPing(float Width) } //-------------------------------------------------------------------------------------------------------------------------- -void FCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss(float Width) +void FCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss(const float Width) { const APlayerController* PlayerController = GetLocalPlayerController(); - UNetConnection* Connection = PlayerController != nullptr ? PlayerController->GetNetConnection() : nullptr; + const UNetConnection* Connection = PlayerController != nullptr ? PlayerController->GetNetConnection() : nullptr; if (Connection == nullptr) { return; @@ -216,7 +215,7 @@ void FCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss(float Width) ImGui::Text("Packet Loss"); ImGui::SameLine(); - FNamedNetDriver* SelectedNetDriver = &WorldContext.ActiveNetDrivers[0]; + const FNamedNetDriver* SelectedNetDriver = &WorldContext.ActiveNetDrivers[0]; FPacketSimulationSettings Settings = SelectedNetDriver->NetDriver->PacketSimulationSettings; TArray Values{ 0, 5, 10, 20, 30, 40, 50 }; @@ -232,7 +231,7 @@ void FCogEngineWindow_Stats::RenderMainMenuWidgetPacketLoss(float Width) } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogEngineWindow_Stats::GetFpsColor(float Value, float Good /*= 50.0f*/, float Medium /*= 30.0f*/) +ImVec4 FCogEngineWindow_Stats::GetFpsColor(const float Value, const float Good /*= 50.0f*/, const float Medium /*= 30.0f*/) { if (Value > Good) { @@ -248,7 +247,7 @@ ImVec4 FCogEngineWindow_Stats::GetFpsColor(float Value, float Good /*= 50.0f*/, } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogEngineWindow_Stats::GetPingColor(float Value, float Good /*= 100.0f*/, float Medium /*= 200.0f*/) +ImVec4 FCogEngineWindow_Stats::GetPingColor(const float Value, const float Good /*= 100.0f*/, const float Medium /*= 200.0f*/) { if (Value > Medium) { @@ -264,7 +263,7 @@ ImVec4 FCogEngineWindow_Stats::GetPingColor(float Value, float Good /*= 100.0f*/ } //-------------------------------------------------------------------------------------------------------------------------- -ImVec4 FCogEngineWindow_Stats::GetPacketLossColor(float Value, float Good /*= 10.0f*/, float Medium /*= 20.0f*/) +ImVec4 FCogEngineWindow_Stats::GetPacketLossColor(const float Value, const float Good /*= 10.0f*/, const float Medium /*= 20.0f*/) { if (Value > Medium) { diff --git a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp index 6dbfcda..6f36ffd 100644 --- a/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp +++ b/Plugins/Cog/Source/CogEngine/Private/CogEngineWindow_TimeScale.cpp @@ -34,19 +34,13 @@ void FCogEngineWindow_TimeScale::RenderContent() { Super::RenderContent(); - UWorld* World = GetWorld(); - if (World == nullptr) - { - return; - } - - ACogEngineReplicator* Replicator = ACogEngineReplicator::GetLocalReplicator(*World); + ACogEngineReplicator* Replicator = ACogEngineReplicator::GetLocalReplicator(*GetWorld()); if (Replicator == nullptr) { + ImGui::TextDisabled("Invalid Replicator"); return; } - float Value = Replicator->GetTimeDilation(); if (FCogWindowWidgets::MultiChoiceButtonsFloat(TimingScales, Value, ImVec2(3.5f * FCogWindowWidgets::GetFontWidth(), 0))) { diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineReplicator.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineReplicator.h index b667246..45ef082 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineReplicator.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineReplicator.h @@ -22,9 +22,9 @@ public: static ACogEngineReplicator* Spawn(APlayerController* Controller); - static ACogEngineReplicator* GetLocalReplicator(UWorld& World); + static ACogEngineReplicator* GetLocalReplicator(const UWorld& World); - static void GetRemoteReplicators(UWorld& World, TArray& Replicators); + static void GetRemoteReplicators(const UWorld& World, TArray& Replicators); virtual void BeginPlay() override; @@ -53,7 +53,7 @@ protected: void Server_SetTimeDilation(float Value); UFUNCTION() - void OnRep_TimeDilation(); + void OnRep_TimeDilation() const; TObjectPtr OwnerPlayerController; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h index 9ff419d..c104c75 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_OutputLog.h @@ -56,7 +56,7 @@ private: FName Category; }; - void DrawRow(const char* BufferStart, const FLineInfo& Info, bool IsTableShown); + void DrawRow(const char* BufferStart, const FLineInfo& Info, bool IsTableShown) const; ImGuiTextBuffer TextBuffer; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h index e8512d8..8bbfc1b 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Plots.h @@ -25,20 +25,20 @@ protected: virtual void RenderTick(float DeltaTime) override; virtual void RenderContent() override; - - void RenderPlotsList(TArray& VisiblePlots); - void RenderPlots(const TArray& VisiblePlots); + static void RenderPlotsList(TArray& VisiblePlots); + + void RenderPlots(const TArray& VisiblePlots) const; void RenderMenu(); - void RenderTimeMarker(); + void RenderTimeMarker() const; - void RenderValues(FCogDebugPlotEntry& Entry, const char* Label); + static void RenderValues(FCogDebugPlotEntry& Entry, const char* Label); - void RenderEvents(FCogDebugPlotEntry& Entry, const char* Label, const ImVec2& PlotMin, const ImVec2& PlotMax); + void RenderEvents(FCogDebugPlotEntry& Entry, const char* Label, const ImVec2& PlotMin, const ImVec2& PlotMax) const; - void RenderEventTooltip(const FCogDebugPlotEvent* HoveredEvent, FCogDebugPlotEntry& Entry); + static void RenderEventTooltip(const FCogDebugPlotEvent* HoveredEvent, FCogDebugPlotEntry& Entry); TObjectPtr Config = nullptr; diff --git a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Spawns.h b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Spawns.h index 6fdb159..221e9c9 100644 --- a/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Spawns.h +++ b/Plugins/Cog/Source/CogEngine/Public/CogEngineWindow_Spawns.h @@ -1,6 +1,7 @@ #pragma once #include "CoreMinimal.h" +#include "CogEngineReplicator.h" #include "CogWindow.h" class UCogEngineDataAsset; @@ -21,9 +22,9 @@ protected: virtual void RenderContent() override; - virtual void RenderSpawnGroup(const FCogEngineSpawnGroup& SpawnGroup); + virtual void RenderSpawnGroup(ACogEngineReplicator& Replicator, const FCogEngineSpawnGroup& SpawnGroup); - virtual bool RenderSpawnAsset(const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected); + virtual bool RenderSpawnAsset(ACogEngineReplicator& Replicator, const FCogEngineSpawnEntry& SpawnEntry, bool IsLastSelected); private: diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImGuiInputProcessor.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImGuiInputProcessor.cpp index 8dc0fe7..74e5192 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImGuiInputProcessor.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImGuiInputProcessor.cpp @@ -4,7 +4,6 @@ #include "CogImguiInputHelper.h" #include "CogImguiWidget.h" #include "CogImguiContext.h" -#include "GameFramework/PlayerInput.h" #include "imgui.h" #include "Framework/Application/SlateApplication.h" diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImguiContext.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImguiContext.cpp index c9bfff9..df97961 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImguiContext.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImguiContext.cpp @@ -3,7 +3,6 @@ #include "Application/ThrottleManager.h" #include "CogImguiHelper.h" #include "CogImguiInputHelper.h" -#include "CogImGuiInputProcessor.h" #include "CogImguiWidget.h" #include "Engine/Console.h" #include "Engine/Engine.h" diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp index 5338968..4525057 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImguiInputHelper.cpp @@ -2,11 +2,9 @@ #include "CogImGuiInputProcessor.h" #include "CogImguiKeyInfo.h" -#include "CogImguiModule.h" #include "Engine/World.h" #include "Framework/Application/SlateApplication.h" #include "Framework/Commands/UICommandInfo.h" -#include "GameFramework/GameUserSettings.h" #include "GameFramework/InputSettings.h" #include "GameFramework/PlayerController.h" #include "GameFramework/PlayerInput.h" diff --git a/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp b/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp index 6d1f499..ea1cb80 100644 --- a/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp +++ b/Plugins/Cog/Source/CogImgui/Private/CogImguiWidget.cpp @@ -2,8 +2,6 @@ #include "CogImguiContext.h" #include "CogImguiInputHelper.h" -#include "CogImguiModule.h" -#include "CogImguiWidget.h" #include "Engine/GameViewportClient.h" #include "imgui.h" #include "SlateOptMacros.h" @@ -39,12 +37,12 @@ void SCogImguiWidget::Tick(const FGeometry& AllottedGeometry, const double InCur //-------------------------------------------------------------------------------------------------------------------------- int32 SCogImguiWidget::OnPaint( - const FPaintArgs& Args, - const FGeometry& AllottedGeometry, + const FPaintArgs& Args, + const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, - FSlateWindowElementList& OutDrawElements, - int32 LayerId, - const FWidgetStyle& WidgetStyle, + FSlateWindowElementList& OutDrawElements, + int32 LayerId, + const FWidgetStyle& WidgetStyle, bool bParentEnabled) const { @@ -124,17 +122,17 @@ FReply SCogImguiWidget::OnKeyChar(const FGeometry& MyGeometry, const FCharacterE //-------------------------------------------------------------------------------------------------------------------------- FReply SCogImguiWidget::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) { - return HandleKeyEvent(MyGeometry, KeyEvent); + return HandleKeyEvent(MyGeometry, KeyEvent, true); } //-------------------------------------------------------------------------------------------------------------------------- FReply SCogImguiWidget::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) { - return HandleKeyEvent(MyGeometry, KeyEvent); + return HandleKeyEvent(MyGeometry, KeyEvent, false); } //-------------------------------------------------------------------------------------------------------------------------- -FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) +FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent, bool Down) { if (Context->GetEnableInput() == false) { @@ -154,8 +152,9 @@ FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEv { return FReply::Unhandled(); } + ImGuiIO& IO = ImGui::GetIO(); - IO.AddKeyEvent(FCogImguiInputHelper::ToImKey(KeyEvent.GetKey()), false); + IO.AddKeyEvent(FCogImguiInputHelper::ToImKey(KeyEvent.GetKey()), Down); IO.AddKeyEvent(ImGuiMod_Ctrl, KeyEvent.IsControlDown()); IO.AddKeyEvent(ImGuiMod_Shift, KeyEvent.IsShiftDown()); IO.AddKeyEvent(ImGuiMod_Alt, KeyEvent.IsAltDown()); @@ -179,7 +178,7 @@ FReply SCogImguiWidget::OnAnalogValueChanged(const FGeometry& MyGeometry, const // return FReply::Unhandled(); //} - return FReply::Unhandled(); + return FReply::Unhandled(); } return FReply::Handled(); diff --git a/Plugins/Cog/Source/CogImgui/Public/CogImguiWidget.h b/Plugins/Cog/Source/CogImgui/Public/CogImguiWidget.h index 7d345d0..01c9763 100644 --- a/Plugins/Cog/Source/CogImgui/Public/CogImguiWidget.h +++ b/Plugins/Cog/Source/CogImgui/Public/CogImguiWidget.h @@ -19,7 +19,7 @@ class COGIMGUI_API SCogImguiWidget : public SLeafWidget public: SLATE_BEGIN_ARGS(SCogImguiWidget) {} - SLATE_ARGUMENT(FCogImguiContext*, Context) + SLATE_ARGUMENT(FCogImguiContext*, Context) SLATE_END_ARGS() void Construct(const FArguments& InArgs); @@ -53,7 +53,7 @@ public: protected: - FReply HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent); + FReply HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent, bool Down); void RefreshVisibility(); diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp index 33fb22a..1b95635 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindow.cpp @@ -1,6 +1,5 @@ #include "CogWindow.h" -#include "CogDebugDraw.h" #include "CogDebugSettings.h" #include "CogWindow_Settings.h" #include "CogWindowManager.h" @@ -160,9 +159,9 @@ void FCogWindow::SetSelection(AActor* NewSelection) } //-------------------------------------------------------------------------------------------------------------------------- -APawn* FCogWindow::GetLocalPlayerPawn() +APawn* FCogWindow::GetLocalPlayerPawn() const { - APlayerController* LocalPlayerController = GetLocalPlayerController(); + const APlayerController* LocalPlayerController = GetLocalPlayerController(); if (LocalPlayerController == nullptr) { @@ -175,9 +174,9 @@ APawn* FCogWindow::GetLocalPlayerPawn() } //-------------------------------------------------------------------------------------------------------------------------- -APlayerController* FCogWindow::GetLocalPlayerController() +APlayerController* FCogWindow::GetLocalPlayerController() const { - ULocalPlayer* LocalPlayer = GetLocalPlayer(); + const ULocalPlayer* LocalPlayer = GetLocalPlayer(); if (LocalPlayer == nullptr) { return nullptr; @@ -187,7 +186,7 @@ APlayerController* FCogWindow::GetLocalPlayerController() } //-------------------------------------------------------------------------------------------------------------------------- -ULocalPlayer* FCogWindow::GetLocalPlayer() +ULocalPlayer* FCogWindow::GetLocalPlayer() const { const UWorld* World = GetWorld(); if (World == nullptr) @@ -199,13 +198,13 @@ ULocalPlayer* FCogWindow::GetLocalPlayer() } //-------------------------------------------------------------------------------------------------------------------------- -UCogWindowConfig* FCogWindow::GetConfig(const TSubclassOf ConfigClass) +UCogWindowConfig* FCogWindow::GetConfig(const TSubclassOf ConfigClass) const { return GetOwner()->GetConfig(ConfigClass); } //-------------------------------------------------------------------------------------------------------------------------- -const UObject* FCogWindow::GetAsset(const TSubclassOf AssetClass) +const UObject* FCogWindow::GetAsset(const TSubclassOf AssetClass) const { return GetOwner()->GetAsset(AssetClass); } diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp index ed66664..5e271d1 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindowManager.cpp @@ -46,11 +46,11 @@ void UCogWindowManager::InitializeInternal() ImGuiSettingsHandler IniHandler; IniHandler.TypeName = "Cog"; IniHandler.TypeHash = ImHashStr("Cog"); - IniHandler.ClearAllFn = UCogWindowManager::SettingsHandler_ClearAll; - IniHandler.ReadOpenFn = UCogWindowManager::SettingsHandler_ReadOpen; - IniHandler.ReadLineFn = UCogWindowManager::SettingsHandler_ReadLine; - IniHandler.ApplyAllFn = UCogWindowManager::SettingsHandler_ApplyAll; - IniHandler.WriteAllFn = UCogWindowManager::SettingsHandler_WriteAll; + IniHandler.ClearAllFn = SettingsHandler_ClearAll; + IniHandler.ReadOpenFn = SettingsHandler_ReadOpen; + IniHandler.ReadLineFn = SettingsHandler_ReadLine; + IniHandler.ApplyAllFn = SettingsHandler_ApplyAll; + IniHandler.WriteAllFn = SettingsHandler_WriteAll; IniHandler.UserData = this; ImGui::AddSettingsHandler(&IniHandler); @@ -142,7 +142,7 @@ void UCogWindowManager::Tick(float DeltaTime) if (LayoutToLoad != -1) { - FString Filename = FCogImguiHelper::GetIniFilePath(FString::Printf(TEXT("ImGui_Layout_%d"), LayoutToLoad)); + const FString Filename = FCogImguiHelper::GetIniFilePath(FString::Printf(TEXT("ImGui_Layout_%d"), LayoutToLoad)); ImGui::LoadIniSettingsFromDisk(TCHAR_TO_ANSI(*Filename)); LayoutToLoad = -1; } @@ -166,7 +166,7 @@ void UCogWindowManager::Render(float DeltaTime) ImGui::DockSpaceOverViewport(0, ImGuiDockNodeFlags_PassthruCentralNode | ImGuiDockNodeFlags_NoDockingInCentralNode | ImGuiDockNodeFlags_AutoHideTabBar); ImGui::PopStyleColor(1); - bool bCompactSaved = SettingsWindow->GetSettingsConfig()->bCompactMode; + const bool bCompactSaved = SettingsWindow->GetSettingsConfig()->bCompactMode; if (bCompactSaved) { FCogWindowWidgets::PushStyleCompact(); @@ -204,7 +204,7 @@ void UCogWindowManager::Render(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::AddWindow(FCogWindow* Window, const FString& Name, bool AddToMainMenu /*= true*/) +void UCogWindowManager::AddWindow(FCogWindow* Window, const FString& Name, const bool AddToMainMenu /*= true*/) { Window->SetFullName(Name); Window->SetOwner(this); @@ -227,7 +227,7 @@ void UCogWindowManager::AddWindow(FCogWindow* Window, const FString& Name, bool } //-------------------------------------------------------------------------------------------------------------------------- -FCogWindow* UCogWindowManager::FindWindowByID(ImGuiID ID) +FCogWindow* UCogWindowManager::FindWindowByID(const ImGuiID ID) { for (FCogWindow* Window : Windows) { @@ -240,7 +240,7 @@ FCogWindow* UCogWindowManager::FindWindowByID(ImGuiID ID) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SetHideAllWindows(bool Value) +void UCogWindowManager::SetHideAllWindows(const bool Value) { HideAllWindowsCounter = FMath::Max(HideAllWindowsCounter + (Value ? +1 : -1), 0); bHideAllWindows = HideAllWindowsCounter > 0; @@ -249,7 +249,7 @@ void UCogWindowManager::SetHideAllWindows(bool Value) //-------------------------------------------------------------------------------------------------------------------------- void UCogWindowManager::ResetLayout() { - for (FCogWindow* Window : Windows) + for (const FCogWindow* Window : Windows) { ImGui::SetWindowPos(TCHAR_TO_ANSI(*Window->GetName()), ImVec2(10, 10), ImGuiCond_Always); } @@ -267,7 +267,7 @@ void UCogWindowManager::CloseAllWindows() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::LoadLayout(int32 LayoutIndex) +void UCogWindowManager::LoadLayout(const int32 LayoutIndex) { for (FCogWindow* Window : Windows) { @@ -278,9 +278,9 @@ void UCogWindowManager::LoadLayout(int32 LayoutIndex) } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::SaveLayout(int32 LayoutIndex) +void UCogWindowManager::SaveLayout(const int32 LayoutIndex) { - FString Filename = *FCogImguiHelper::GetIniFilePath(FString::Printf(TEXT("imgui_layout_%d"), LayoutIndex)); + const FString Filename = *FCogImguiHelper::GetIniFilePath(FString::Printf(TEXT("imgui_layout_%d"), LayoutIndex)); ImGui::SaveIniSettingsToDisk(TCHAR_TO_ANSI(*Filename)); } @@ -290,7 +290,7 @@ void UCogWindowManager::SortMainMenu() MainMenu.SubMenus.Empty(); TArray SortedWindows = Windows; - SortedWindows.Sort([](FCogWindow& Lhs, FCogWindow& Rhs) { return Lhs.GetFullName() < Rhs.GetFullName(); }); + SortedWindows.Sort([](const FCogWindow& Lhs, const FCogWindow& Rhs) { return Lhs.GetFullName() < Rhs.GetFullName(); }); for (FCogWindow* Window : SortedWindows) { @@ -307,12 +307,12 @@ UCogWindowManager::FMenu* UCogWindowManager::AddMenu(const FString& Name) TArray Path; Name.ParseIntoArray(Path, TEXT(".")); - UCogWindowManager::FMenu* CurrentMenu = &MainMenu; + FMenu* CurrentMenu = &MainMenu; for (int i = 0; i < Path.Num(); ++i) { FString MenuName = Path[i]; - int SubMenuIndex = CurrentMenu->SubMenus.IndexOfByPredicate([&](const UCogWindowManager::FMenu& Menu) { return Menu.Name == MenuName; }); + int SubMenuIndex = CurrentMenu->SubMenus.IndexOfByPredicate([&](const FMenu& Menu) { return Menu.Name == MenuName; }); if (SubMenuIndex != -1) { CurrentMenu = &CurrentMenu->SubMenus[SubMenuIndex]; @@ -334,7 +334,7 @@ void UCogWindowManager::RenderMainMenu() if (ImGui::BeginMainMenuBar()) { - for (UCogWindowManager::FMenu& Menu : MainMenu.SubMenus) + for (FMenu& Menu : MainMenu.SubMenus) { RenderOptionMenu(Menu); } @@ -383,7 +383,7 @@ void UCogWindowManager::RenderMainMenu() if (ImGui::IsItemActive() && ImGui::IsItemHovered() == false) { - int iNext = i + (ImGui::GetMouseDragDelta(0).y < 0.f ? -1 : 1); + const int iNext = i + (ImGui::GetMouseDragDelta(0).y < 0.f ? -1 : 1); if (iNext >= 0 && iNext < Widgets.Num()) { Widgets[i] = Widgets[iNext]; @@ -480,7 +480,7 @@ void UCogWindowManager::RenderMainMenu() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::RenderOptionMenu(UCogWindowManager::FMenu& Menu) +void UCogWindowManager::RenderOptionMenu(FMenu& Menu) { if (Menu.Window != nullptr) { @@ -490,7 +490,7 @@ void UCogWindowManager::RenderOptionMenu(UCogWindowManager::FMenu& Menu) { if (ImGui::BeginMenu(TCHAR_TO_ANSI(*Menu.Name))) { - for (UCogWindowManager::FMenu& SubMenu : Menu.SubMenus) + for (FMenu& SubMenu : Menu.SubMenus) { RenderOptionMenu(SubMenu); } @@ -613,7 +613,7 @@ void UCogWindowManager::SettingsHandler_WriteAll(ImGuiContext* Context, ImGuiSet const UCogWindowManager* Manager = (UCogWindowManager*)Handler->UserData; Buffer->appendf("[%s][Windows]\n", Handler->TypeName); - for (FCogWindow* Window : Manager->Windows) + for (const FCogWindow* Window : Manager->Windows) { if (Window->GetIsVisible()) { @@ -623,7 +623,7 @@ void UCogWindowManager::SettingsHandler_WriteAll(ImGuiContext* Context, ImGuiSet Buffer->append("\n"); Buffer->appendf("[%s][Widgets]\n", Handler->TypeName); - for (FCogWindow* Window : Manager->Widgets) + for (const FCogWindow* Window : Manager->Widgets) { Buffer->appendf("0x%08X %d\n", Window->GetID(), Window->GetIsWidgetVisible()); } @@ -725,7 +725,7 @@ UCogWindowConfig* UCogWindowManager::GetConfig(const TSubclassOf AssetClass) +const UObject* UCogWindowManager::GetAsset(const TSubclassOf AssetClass) const { const UClass* Class = AssetClass.Get(); diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp index 02f3d4e..7d72bf3 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindowWidgets.cpp @@ -6,7 +6,6 @@ #include "imgui.h" #include "imgui_internal.h" #include "InputCoreTypes.h" -#include "Kismet/KismetMathLibrary.h" #include "GameFramework/PlayerInput.h" //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Layouts.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Layouts.cpp index e803104..e1bbdc6 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Layouts.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Layouts.cpp @@ -43,8 +43,8 @@ void FCogWindow_Layouts::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- void FCogWindow_Layouts::RenderLoadLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex) { - FString Command = FString::Printf(TEXT("%s %d"), *UCogWindowManager::LoadLayoutCommand, LayoutIndex); - FString Shortcut = FCogImguiInputHelper::CommandToString(PlayerInput, Command); + const FString Command = FString::Printf(TEXT("%s %d"), *UCogWindowManager::LoadLayoutCommand, LayoutIndex); + const FString Shortcut = FCogImguiInputHelper::CommandToString(PlayerInput, Command); if (ImGui::MenuItem(TCHAR_TO_ANSI(*FString::Printf(TEXT("Load Layout %d"), LayoutIndex)), TCHAR_TO_ANSI(*Shortcut))) { GetOwner()->LoadLayout(LayoutIndex); @@ -54,8 +54,8 @@ void FCogWindow_Layouts::RenderLoadLayoutMenuItem(const UPlayerInput* PlayerInpu //-------------------------------------------------------------------------------------------------------------------------- void FCogWindow_Layouts::RenderSaveLayoutMenuItem(const UPlayerInput* PlayerInput, int LayoutIndex) { - FString Command = FString::Printf(TEXT("%s %d"), *UCogWindowManager::SaveLayoutCommand, LayoutIndex); - FString Shortcut = FCogImguiInputHelper::CommandToString(PlayerInput, Command); + const FString Command = FString::Printf(TEXT("%s %d"), *UCogWindowManager::SaveLayoutCommand, LayoutIndex); + const FString Shortcut = FCogImguiInputHelper::CommandToString(PlayerInput, Command); if (ImGui::MenuItem(TCHAR_TO_ANSI(*FString::Printf(TEXT("Save Layout %d"), LayoutIndex)), TCHAR_TO_ANSI(*Shortcut))) { GetOwner()->SaveLayout(LayoutIndex); diff --git a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp index 868c7a9..bda2800 100644 --- a/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp +++ b/Plugins/Cog/Source/CogWindow/Private/CogWindow_Settings.cpp @@ -2,8 +2,6 @@ #include "CogImguiHelper.h" #include "CogImguiInputHelper.h" -#include "CogImguiModule.h" -#include "CogImguiWidget.h" #include "CogWindowManager.h" #include "CogWindowWidgets.h" #include "imgui.h" @@ -157,7 +155,7 @@ void FCogWindow_Settings::RenderTick(float DeltaTime) } //-------------------------------------------------------------------------------------------------------------------------- -void FCogWindow_Settings::SetDPIScale(float Value) +void FCogWindow_Settings::SetDPIScale(float Value) const { Config->DPIScale = Value; GetOwner()->GetContext().SetDPIScale(Config->DPIScale); diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h b/Plugins/Cog/Source/CogWindow/Public/CogWindow.h index ac51da8..de1086a 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindow.h @@ -78,12 +78,12 @@ public: template T* GetConfig() { return Cast(GetConfig(T::StaticClass())); } - UCogWindowConfig* GetConfig(const TSubclassOf ConfigClass); + UCogWindowConfig* GetConfig(const TSubclassOf ConfigClass) const; template const T* GetAsset() { return Cast(GetAsset(T::StaticClass())); } - const UObject* GetAsset(const TSubclassOf AssetClass); + const UObject* GetAsset(const TSubclassOf AssetClass) const; protected: @@ -105,11 +105,11 @@ protected: virtual void OnSelectionChanged(AActor* OldSelection, AActor* NewSelection) {} - APawn* GetLocalPlayerPawn(); + APawn* GetLocalPlayerPawn() const; - APlayerController* GetLocalPlayerController(); + APlayerController* GetLocalPlayerController() const; - ULocalPlayer* GetLocalPlayer(); + ULocalPlayer* GetLocalPlayer() const; protected: diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowHelper.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowHelper.h index 3e14f7e..7b76f6a 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowHelper.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindowHelper.h @@ -21,7 +21,7 @@ public: //---------------------------------------------------------------------------------------------------------------------- static const UObject* GetFirstAssetByClass(const TSubclassOf AssetClass) { - IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked(TEXT("AssetRegistry")).Get(); + const IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked(TEXT("AssetRegistry")).Get(); TArray Assets; AssetRegistry.GetAssetsByClass(AssetClass->GetClassPathName(), Assets, true); @@ -30,7 +30,7 @@ public: return nullptr; } - UObject* Asset = Assets[0].GetAsset(); + const UObject* Asset = Assets[0].GetAsset(); return Asset; } }; diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h b/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h index 67c8748..87d8774 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindowManager.h @@ -66,7 +66,7 @@ public: template T* GetConfig(); - const UObject* GetAsset(const TSubclassOf AssetClass); + const UObject* GetAsset(const TSubclassOf AssetClass) const; template T* GetAsset(); diff --git a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h index b7f661d..2e93c84 100644 --- a/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h +++ b/Plugins/Cog/Source/CogWindow/Public/CogWindow_Settings.h @@ -20,7 +20,7 @@ public: const UCogWindowConfig_Settings* GetSettingsConfig() const { return Config; } - void SetDPIScale(float Value); + void SetDPIScale(float Value) const; protected: diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp index 3d5824f..f4f4688 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_BehaviorTree.cpp @@ -127,7 +127,7 @@ void FCogAIWindow_BehaviorTree::RenderContent() if (Config == nullptr) { - ImGui::TextDisabled("No Config"); + ImGui::TextDisabled("Invalid Config"); return; } @@ -148,35 +148,35 @@ void FCogAIWindow_BehaviorTree::RenderContent() AActor* Selection = GetSelection(); if (Selection == nullptr) { - ImGui::TextDisabled("No Selection"); + ImGui::TextDisabled("Invalid Selection"); return; } APawn* Pawn = Cast(Selection); if (Pawn == nullptr) { - ImGui::TextDisabled("Not a pawn"); + ImGui::TextDisabled("Selection is not a pawn"); return; } AAIController* AIController = Cast(Pawn->Controller); if (AIController == nullptr) { - ImGui::TextDisabled("No AIController"); + ImGui::TextDisabled("Selection has no AIController"); return; } UBehaviorTreeComponent* BehaviorTreeComponent = Cast(AIController->GetBrainComponent()); if (BehaviorTreeComponent == nullptr) { - ImGui::TextDisabled("No BrainComponent"); + ImGui::TextDisabled("Selection has no BrainComponent"); return; } UBehaviorTree* CurrentTree = BehaviorTreeComponent->GetCurrentTree(); if (CurrentTree == nullptr) { - ImGui::TextDisabled("No Current Tree"); + ImGui::TextDisabled("Selection has no current BehaviorTree"); return; } diff --git a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp index 5d64f05..428dba7 100644 --- a/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp +++ b/Plugins/CogAI/Source/CogAI/Private/CogAIWindow_Blackboard.cpp @@ -54,42 +54,42 @@ void FCogAIWindow_Blackboard::RenderContent() AActor* Selection = GetSelection(); if (Selection == nullptr) { - ImGui::TextDisabled("No Selection"); + ImGui::TextDisabled("Invalid Selection"); return; } APawn* Pawn = Cast(Selection); if (Pawn == nullptr) { - ImGui::TextDisabled("Not a pawn"); + ImGui::TextDisabled("Selection is not a pawn"); return; } AAIController* AIController = Cast(Pawn->Controller); if (AIController == nullptr) { - ImGui::TextDisabled("No AIController"); + ImGui::TextDisabled("Selection has no AIController"); return; } UBrainComponent* BehaviorTree = AIController->GetBrainComponent(); if (BehaviorTree == nullptr) { - ImGui::TextDisabled("No BrainComponent"); + ImGui::TextDisabled("Selection has no BrainComponent"); return; } UBlackboardComponent* Blackboard = BehaviorTree->GetBlackboardComponent(); if (Blackboard == nullptr) { - ImGui::TextDisabled("No BlackboardComponent"); + ImGui::TextDisabled("Selection has no BlackboardComponent"); return; } UBlackboardData* BlackboardAsset = Blackboard->GetBlackboardAsset(); if (BlackboardAsset == nullptr) { - ImGui::TextDisabled("No BlackboardAsset"); + ImGui::TextDisabled("Selection has no BlackboardAsset"); return; } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityConfig_Alignment.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityConfig_Alignment.cpp index 1613d9d..e92f99a 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityConfig_Alignment.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityConfig_Alignment.cpp @@ -2,7 +2,6 @@ #include "AbilitySystemComponent.h" #include "CogAbilityDataAsset.h" -#include "CogImguiHelper.h" #include "GameplayEffect.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -27,6 +26,11 @@ FVector4f UCogAbilityConfig_Alignment::GetAttributeColor(const UAbilitySystemCom //-------------------------------------------------------------------------------------------------------------------------- FVector4f UCogAbilityConfig_Alignment::GetEffectColor(const UCogAbilityDataAsset* Asset, const UGameplayEffect& Effect) const { + if (Asset == nullptr) + { + return NeutralColor; + } + const FGameplayTagContainer& Tags = Effect.InheritableGameplayEffectTags.CombinedTags; if (Tags.HasTag(Asset->NegativeEffectTag)) diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp index 4d6e349..1bd5663 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityHelper.cpp @@ -1,8 +1,5 @@ #include "CogAbilityHelper.h" -#include "CogAbilityDataAsset.h" -#include "CogImguiHelper.h" -#include "GameplayEffect.h" #include "GameplayTagContainer.h" #include "imgui.h" diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp index d1db8ee..cc7ac06 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityReplicator.cpp @@ -236,12 +236,17 @@ void ACogAbilityReplicator::Server_ResetAllTweaks_Implementation() //-------------------------------------------------------------------------------------------------------------------------- void ACogAbilityReplicator::OnAnyActorSpawned(AActor* Actor) { + if (AbilityAsset == nullptr) + { + return; + } + if (AbilityAsset->ActorRootClass != nullptr && Actor->GetClass()->IsChildOf(AbilityAsset->ActorRootClass) == false) { return; } - int32 TweakCategoryIndex = FindTweakCategoryFromActor(Actor); + const int32 TweakCategoryIndex = FindTweakCategoryFromActor(Actor); if (TweakCategoryIndex == INDEX_NONE) { return; diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp index 5cc4bb8..31088ce 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Abilities.cpp @@ -6,10 +6,8 @@ #include "CogAbilityHelper.h" #include "CogAbilityReplicator.h" #include "CogImguiHelper.h" -#include "CogWindowHelper.h" #include "CogWindowWidgets.h" #include "imgui.h" -#include "imgui_internal.h" //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Abilities::Initialize() @@ -103,12 +101,14 @@ void FCogAbilityWindow_Abilities::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; } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp index 5a5d486..4675ce7 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Attributes.cpp @@ -6,11 +6,8 @@ #include "CogAbilityDataAsset.h" #include "CogAbilityHelper.h" #include "CogImguiHelper.h" -#include "CogWindowHelper.h" #include "CogWindowWidgets.h" #include "AttributeSet.h" -#include "EngineUtils.h" -#include "GameFramework/Character.h" //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Attributes::Initialize() @@ -52,6 +49,7 @@ void FCogAbilityWindow_Attributes::RenderContent() UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); if (AbilitySystemComponent == nullptr) { + ImGui::TextDisabled("Selection has no ability system component"); return; } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp index edf6cf1..9012cc9 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp @@ -1,13 +1,10 @@ #include "CogAbilityWindow_Cheats.h" -#include "AbilitySystemGlobals.h" #include "CogAbilityConfig_Alignment.h" #include "CogAbilityDataAsset.h" #include "CogAbilityReplicator.h" #include "CogCommonAllegianceActorInterface.h" -#include "CogDebugDraw.h" #include "CogImguiHelper.h" -#include "CogWindowHelper.h" #include "CogWindowWidgets.h" #include "EngineUtils.h" #include "GameFramework/Character.h" @@ -129,20 +126,20 @@ void FCogAbilityWindow_Cheats::RenderContent() if (Config == nullptr) { - ImGui::Text("Invalid Config"); + ImGui::TextDisabled("Invalid Config"); return; } AActor* SelectedActor = GetSelection(); if (SelectedActor == nullptr) { - ImGui::Text("Invalid Selection"); + ImGui::TextDisabled("Invalid Selection"); return; } if (Asset == nullptr) { - ImGui::Text("Invalid Asset"); + ImGui::TextDisabled("Invalid Asset"); return; } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp index 88b6a02..fb30a44 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Effects.cpp @@ -7,10 +7,7 @@ #include "CogAbilityDataAsset.h" #include "CogAbilityHelper.h" #include "CogImguiHelper.h" -#include "CogWindowHelper.h" #include "CogWindowWidgets.h" -#include "EngineUtils.h" -#include "GameFramework/Character.h" //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::Initialize() @@ -87,9 +84,10 @@ void FCogAbilityWindow_Effects::RenderContent() //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderEffectsTable() { - 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; } @@ -113,7 +111,7 @@ void FCogAbilityWindow_Effects::RenderEffectsTable() static int SelectedIndex = -1; int Index = 0; - FGameplayEffectQuery Query; + const FGameplayEffectQuery Query; TArray Effects = AbilitySystemComponent->GetActiveEffects(Query); if (Config->SortByName || Config->SortByAlignment) @@ -138,7 +136,7 @@ void FCogAbilityWindow_Effects::RenderEffectsTable() } bool AlignmentOrder = false; - if (Config->SortByAlignment) + if (Config->SortByAlignment && Asset != nullptr) { const FGameplayTagContainer& Tags1 = Effect1->InheritableGameplayEffectTags.CombinedTags; const FGameplayTagContainer& Tags2 = Effect2->InheritableGameplayEffectTags.CombinedTags; @@ -267,7 +265,7 @@ void FCogAbilityWindow_Effects::RenderEffectInfo(const UAbilitySystemComponent& { if (ImGui::BeginTable("Effect", 2, ImGuiTableFlags_Borders)) { - const ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); + constexpr ImVec4 TextColor(1.0f, 1.0f, 1.0f, 0.5f); ImGui::TableSetupColumn("Property"); ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch); @@ -407,7 +405,7 @@ void FCogAbilityWindow_Effects::RenderRemainingTime(const UAbilitySystemComponen if (Duration >= 0) { - 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)); @@ -473,13 +471,13 @@ void FCogAbilityWindow_Effects::CloseEffect(const FActiveGameplayEffectHandle& H //-------------------------------------------------------------------------------------------------------------------------- void FCogAbilityWindow_Effects::RenderOpenEffects() { - AActor* Selection = GetSelection(); + const AActor* Selection = GetSelection(); if (Selection == nullptr) { return; } - UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true); + const UAbilitySystemComponent* AbilitySystemComponent = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(Selection, true); if (AbilitySystemComponent == nullptr) { return; @@ -487,7 +485,7 @@ void FCogAbilityWindow_Effects::RenderOpenEffects() for (int i = OpenedEffects.Num() - 1; i >= 0; --i) { - 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_Pools.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp index f2add4f..0374bdd 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Pools.cpp @@ -4,7 +4,6 @@ #include "AbilitySystemGlobals.h" #include "CogAbilityDataAsset.h" #include "CogImguiHelper.h" -#include "CogWindowHelper.h" #include "CogWindowWidgets.h" #include "imgui_internal.h" @@ -33,12 +32,20 @@ void FCogAbilityWindow_Pools::RenderContent() if (Asset == nullptr) { + ImGui::TextDisabled("Invalid Asset"); return; } - UAbilitySystemComponent* AbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); + const UAbilitySystemComponent* AbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(GetSelection(), true); if (AbilitySystem == nullptr) { + ImGui::TextDisabled("No ability system found on selection"); + return; + } + + if (Asset->Pools.Num() == 0) + { + ImGui::TextDisabled("No pool have been defined"); return; } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp index 9a71000..9729ae5 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tags.cpp @@ -35,9 +35,10 @@ void FCogAbilityWindow_Tags::RenderContent() RenderMenu(); - 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; } diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp index 99ca87c..cfbac80 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Tweaks.cpp @@ -1,10 +1,8 @@ #include "CogAbilityWindow_Tweaks.h" -#include "AbilitySystemComponent.h" #include "CogAbilityDataAsset.h" #include "CogAbilityReplicator.h" #include "CogImguiHelper.h" -#include "CogWindowHelper.h" #include "CogWindowWidgets.h" //-------------------------------------------------------------------------------------------------------------------------- @@ -35,12 +33,14 @@ void FCogAbilityWindow_Tweaks::RenderContent() if (Asset == nullptr) { + ImGui::TextDisabled("Invalid Asset"); return; } ACogAbilityReplicator* Replicator = ACogAbilityReplicator::GetLocalReplicator(*GetWorld()); if (Replicator == nullptr) { + ImGui::TextDisabled("Invalid Replicator"); return; } @@ -54,7 +54,7 @@ void FCogAbilityWindow_Tweaks::RenderContent() ImGui::EndMenuBar(); } - int32 CurrentTweakProfileIndex = Replicator->GetTweakProfileIndex(); + const int32 CurrentTweakProfileIndex = Replicator->GetTweakProfileIndex(); FName CurrentProfileName = FName("None"); if (Asset->TweakProfiles.IsValidIndex(CurrentTweakProfileIndex)) { @@ -64,7 +64,7 @@ void FCogAbilityWindow_Tweaks::RenderContent() if (ImGui::BeginCombo("Profile", TCHAR_TO_ANSI(*CurrentProfileName.ToString()))) { { - bool IsSelected = CurrentTweakProfileIndex == INDEX_NONE; + const bool IsSelected = CurrentTweakProfileIndex == INDEX_NONE; if (ImGui::Selectable("None", IsSelected)) { Replicator->SetTweakProfile(INDEX_NONE); @@ -74,7 +74,7 @@ void FCogAbilityWindow_Tweaks::RenderContent() for (int32 TweakProfileIndex = 0; TweakProfileIndex < Asset->TweakProfiles.Num(); ++TweakProfileIndex) { const FCogAbilityTweakProfile& TweakProfile = Asset->TweakProfiles[TweakProfileIndex]; - bool IsSelected = TweakProfileIndex == CurrentTweakProfileIndex; + const bool IsSelected = TweakProfileIndex == CurrentTweakProfileIndex; if (ImGui::Selectable(TCHAR_TO_ANSI(*TweakProfile.Name.ToString()), IsSelected)) { diff --git a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h index 57037c5..9f5de61 100644 --- a/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h +++ b/Plugins/CogAbility/Source/CogAbility/Public/CogAbilityWindow_Effects.h @@ -2,7 +2,6 @@ #include "CoreMinimal.h" #include "ActiveGameplayEffectHandle.h" -#include "GameplayTagContainer.h" #include "CogWindow.h" #include "CogWindowConfig.h" #include "imgui.h" diff --git a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp index 69e8f49..ee8cf2d 100644 --- a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp +++ b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Actions.cpp @@ -47,21 +47,27 @@ void FCogInputWindow_Actions::RenderContent() if (Asset == nullptr) { - ImGui::Text("No Actions Asset"); + ImGui::TextDisabled("Invalid Asset"); return; } ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); if (LocalPlayer == nullptr) { - ImGui::Text("No Local Player"); + ImGui::TextDisabled("No Local Player"); return; } UEnhancedInputLocalPlayerSubsystem* EnhancedInputSubsystem = ULocalPlayer::GetSubsystem(LocalPlayer); if (EnhancedInputSubsystem == nullptr) { - ImGui::Text("No Enhanced Input Subsystem"); + ImGui::TextDisabled("No Enhanced Input Subsystem"); + return; + } + + if(EnhancedInputSubsystem->GetPlayerInput() == nullptr) + { + ImGui::TextDisabled("No Player Input"); return; } @@ -233,4 +239,4 @@ void FCogInputWindow_Actions::DrawAxis(const char* Format, const char* ActionNam ImGui::SetNextItemWidth(-1); FCogWindowWidgets::SliderWithReset("##Inject", InjectValue, -1.0f, 1.0f, 0.0f, "%0.2f"); ImGui::PopID(); -} \ No newline at end of file +} diff --git a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp index 57e2152..3182f98 100644 --- a/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp +++ b/Plugins/CogInput/Source/CogInput/Private/CogInputWindow_Gamepad.cpp @@ -2,7 +2,6 @@ #include "CogImguiHelper.h" #include "CogInputDataAsset.h" -#include "CogWindowHelper.h" #include "CogWindowWidgets.h" #include "Engine/LocalPlayer.h" #include "Engine/World.h" @@ -190,13 +189,13 @@ void FCogInputWindow_Gamepad::RenderStick(const FKey& Key2D, const FKey& KeyBool ImGui::SetCursorScreenPos(ButtonPosition); if (ImGui::InvisibleButton("", ButtonSize)) { - if (ActionInfo2D->bIsMouseDraggingStick == false) + if (ActionInfo2D != nullptr && ActionInfo2D->bIsMouseDraggingStick == false) { OnButtonClicked(ActionInfoBool); } } - if (ActionInfo2D->Action != nullptr) + if (ActionInfo2D != nullptr && ActionInfo2D->Action != nullptr) { if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { @@ -268,36 +267,30 @@ void FCogInputWindow_Gamepad::RenderContent() { Super::RenderContent(); - if (GetWorld() == nullptr) - { - ImGui::Text("No World"); - return; - } - - ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); + const ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); if (LocalPlayer == nullptr) { - ImGui::Text("No Local Player"); + ImGui::TextDisabled("No Local Player"); return; } - UEnhancedInputLocalPlayerSubsystem* EnhancedInputSubsystem = ULocalPlayer::GetSubsystem(LocalPlayer); + const UEnhancedInputLocalPlayerSubsystem* EnhancedInputSubsystem = ULocalPlayer::GetSubsystem(LocalPlayer); if (EnhancedInputSubsystem == nullptr) { - ImGui::Text("No Enhanced Input Subsystem"); + ImGui::TextDisabled("No Enhanced Input Subsystem"); return; } Input = EnhancedInputSubsystem->GetPlayerInput(); if (Input == nullptr) { - ImGui::Text("No Player Input"); + ImGui::TextDisabled("No Player Input"); return; } if (Asset == nullptr) { - ImGui::Text("No Input Asset"); + ImGui::TextDisabled("Invalid Asset"); } else { @@ -345,22 +338,22 @@ void FCogInputWindow_Gamepad::RenderContent() } - const float AspectRatio = 0.55f; - const float StickAmplitude = 0.04f; - const float StickRadius = 0.08f; - const float StickBaseRadius = 0.1f; - const float GamepadRound = 0.15f; - const float HandleWidth = 0.26f; - const ImVec2 DPadButtonSize(0.08f, 0.08f); - const float DpadButtonDistance = 0.075f; - const float DpadButtonRounding = 0.1f; - const ImVec2 SpecialButtonSize(0.08f, 0.04f); - const float SpecialButtonRound = 0.05f; - const float SpecialButtonDistance = 0.15f; - const float TriggerRound = 0.02f; - const ImVec2 TriggerButtonSize(0.08f, 0.05f); - const float BumperRound = 0.02f; - const ImVec2 BumperButtonSize(0.2f, 0.04f); + constexpr float AspectRatio = 0.55f; + constexpr float StickAmplitude = 0.04f; + constexpr float StickRadius = 0.08f; + constexpr float StickBaseRadius = 0.1f; + constexpr float GamepadRound = 0.15f; + constexpr float HandleWidth = 0.26f; + constexpr ImVec2 DPadButtonSize(0.08f, 0.08f); + constexpr float DpadButtonDistance = 0.075f; + constexpr float DpadButtonRounding = 0.1f; + constexpr ImVec2 SpecialButtonSize(0.08f, 0.04f); + constexpr float SpecialButtonRound = 0.05f; + constexpr float SpecialButtonDistance = 0.15f; + constexpr float TriggerRound = 0.02f; + constexpr ImVec2 TriggerButtonSize(0.08f, 0.05f); + constexpr float BumperRound = 0.02f; + constexpr ImVec2 BumperButtonSize(0.2f, 0.04f); const ImVec2 ContentMin = ImGui::GetCursorScreenPos(); const ImVec2 ContentSize = ImGui::GetContentRegionAvail(); @@ -382,8 +375,8 @@ void FCogInputWindow_Gamepad::RenderContent() DrawList->PushClipRect(ContentMin, ContentMax, true); - const ImVec2 LS_Pos(0.35f, 0.7f); - const ImVec2 RS_Pos(0.65f, 0.7f); + constexpr ImVec2 LS_Pos(0.35f, 0.7f); + constexpr ImVec2 RS_Pos(0.65f, 0.7f); //------------------------------ // Triggers @@ -426,7 +419,7 @@ void FCogInputWindow_Gamepad::RenderContent() //------------------------------ // DPad Buttons //------------------------------ - const ImVec2 DPad_Pos(0.15f, 0.44f); + constexpr ImVec2 DPad_Pos(0.15f, 0.44f); RenderButton(EKeys::Gamepad_DPad_Up, DPad_Pos + ImVec2(0.0f, -DpadButtonDistance / AspectRatio), DPadButtonSize, ImVec2(0.5f, 0.5f), DpadButtonRounding); RenderButton(EKeys::Gamepad_DPad_Down, DPad_Pos + ImVec2(0.0f, DpadButtonDistance / AspectRatio), DPadButtonSize, ImVec2(0.5f, 0.5f), DpadButtonRounding); RenderButton(EKeys::Gamepad_DPad_Left, DPad_Pos + ImVec2(-DpadButtonDistance, 0.0f), DPadButtonSize, ImVec2(0.5f, 0.5f), DpadButtonRounding); @@ -435,7 +428,7 @@ void FCogInputWindow_Gamepad::RenderContent() //------------------------------ // Face Buttons //------------------------------ - const ImVec2 Face_Pos(1.0f - 0.15f, 0.44f); + constexpr ImVec2 Face_Pos(1.0f - 0.15f, 0.44f); RenderButton(EKeys::Gamepad_FaceButton_Top, Face_Pos + ImVec2(0.0f, -DpadButtonDistance / AspectRatio), DPadButtonSize, ImVec2(0.5f, 0.5f), DpadButtonRounding); RenderButton(EKeys::Gamepad_FaceButton_Bottom, Face_Pos + ImVec2(0.0f, DpadButtonDistance / AspectRatio), DPadButtonSize, ImVec2(0.5f, 0.5f), DpadButtonRounding); RenderButton(EKeys::Gamepad_FaceButton_Left, Face_Pos + ImVec2(-DpadButtonDistance, 0.0f), DPadButtonSize, ImVec2(0.5f, 0.5f), DpadButtonRounding); @@ -460,7 +453,7 @@ void FCogInputWindow_Gamepad::RenderTick(float DeltaSeconds) return; } - ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); + const ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); if (LocalPlayer == nullptr) { return; @@ -473,7 +466,7 @@ void FCogInputWindow_Gamepad::RenderTick(float DeltaSeconds) } bool IsTimeToRepeat = false; - float WorldTime = GetWorld()->GetTimeSeconds(); + const float WorldTime = GetWorld()->GetTimeSeconds(); if (RepeatTime < WorldTime) { RepeatTime = WorldTime + Config->RepeatPeriod; diff --git a/Source/CogSample/CogSampleGameState.h b/Source/CogSample/CogSampleGameState.h index 4547ddf..ba071e1 100644 --- a/Source/CogSample/CogSampleGameState.h +++ b/Source/CogSample/CogSampleGameState.h @@ -23,12 +23,6 @@ class ACogSampleGameState : public AGameStateBase private: - //--------------------------------------------------------------------------------- - // To make sure it doesn't get garbage collected. - //--------------------------------------------------------------------------------- - UPROPERTY() - TObjectPtr CogWindowManagerRef = nullptr; - //--------------------------------------------------------------------------------- // The game state has an AbilitySystemComponent to serve as the default instigator // for effects that are not applied by characters. @@ -36,6 +30,12 @@ private: UPROPERTY() UCogSampleAbilitySystemComponent* AbilitySystemComponent = nullptr; + //--------------------------------------------------------------------------------- + // To make sure it doesn't get garbage collected. + //--------------------------------------------------------------------------------- + UPROPERTY() + TObjectPtr CogWindowManagerRef = nullptr; + #if ENABLE_COG void InitializeCog();