From eb963614b9e69ea264fe0e5818206d54bf2006a7 Mon Sep 17 00:00:00 2001 From: Arnaud Jamin Date: Tue, 10 Oct 2023 23:53:34 -0400 Subject: [PATCH] simplify integration --- Plugins/CogAbility/CogAbility.uplugin | 2 +- .../Source/CogAbility/CogAbility.Build.cs | 2 +- .../Private/CogAbilityWindow_Cheats.cpp | 10 +-- .../CogCommon.uplugin} | 4 +- .../Resources/Icon128.png | Bin .../Source/CogCommon/CogCommon.Build.cs} | 4 +- .../CogCommon/Private/CogCommonModule.cpp} | 10 +-- .../Source/CogCommon/Public/CogCommon.h} | 33 ++++++---- .../CogCommonAllegianceActorInterface.h} | 10 +-- .../CogCommonDebugFilteredActorInterface.h | 15 +++++ .../Source/CogCommon/Public/CogCommonModule.h | 17 +++++ .../Public/CogCommonPossessorInterface.h} | 6 +- Plugins/CogDebug/CogDebug.uplugin | 2 +- .../Source/CogDebug/CogDebug.Build.cs | 2 +- .../Source/CogDebug/Private/CogDebugDraw.cpp | 7 +- .../CogDebug/Private/CogDebugLogBlueprint.cpp | 2 +- .../Private/CogDebugPlotBlueprint.cpp | 2 +- .../CogDebug/Private/CogDebugSettings.cpp | 4 +- .../Source/CogDebug/Public/CogDebugDefines.h | 7 -- .../Source/CogDebug/Public/CogDebugDraw.h | 2 +- .../CogDebug/Public/CogDebugDrawHelper.h | 1 - .../Source/CogDebug/Public/CogDebugLog.h | 1 - .../Source/CogDebug/Public/CogDebugMetric.h | 2 +- .../Source/CogDebug/Public/CogDebugPlot.h | 2 +- .../Source/CogDebug/Public/CogDebugSettings.h | 1 - Plugins/CogEngine/CogEngine.uplugin | 4 ++ .../Source/CogEngine/CogEngine.Build.cs | 2 +- .../CogEngine/Private/CogEngineReplicator.cpp | 8 +-- .../Public/CogInterfaceDebugFilteredActor.h | 15 ----- .../CogInterface/Public/CogInterfaceModule.h | 17 ----- .../CogWindow/Private/CogWindowManager.cpp | 20 ++++-- .../CogWindow/Public/CogWindowManager.h | 15 +++-- Source/CogSample/CogSample.Build.cs | 6 +- Source/CogSample/CogSampleCharacter.cpp | 34 +++++----- Source/CogSample/CogSampleCharacter.h | 12 ++-- .../CogSampleCharacterMovementComponent.cpp | 20 +++--- .../CogSampleCharacterMovementComponent.h | 4 +- Source/CogSample/CogSampleDefines.h | 17 ++--- .../CogSampleFunctionLibrary_Gameplay.cpp | 4 +- Source/CogSample/CogSampleGameState.cpp | 62 ++++++------------ Source/CogSample/CogSampleGameState.h | 8 +-- Source/CogSample/CogSampleLogCategories.cpp | 8 +-- .../CogSample/CogSamplePlayerController.cpp | 15 ++--- Source/CogSample/CogSamplePlayerController.h | 4 +- .../CogSample/CogSampleTargetAcquisition.cpp | 24 +++---- 45 files changed, 217 insertions(+), 230 deletions(-) rename Plugins/{CogInterface/CogInterface.uplugin => CogCommon/CogCommon.uplugin} (87%) rename Plugins/{CogInterface => CogCommon}/Resources/Icon128.png (100%) rename Plugins/{CogInterface/Source/CogInterface/CogInterface.Build.cs => CogCommon/Source/CogCommon/CogCommon.Build.cs} (83%) rename Plugins/{CogInterface/Source/CogInterface/Private/CogInterfaceModule.cpp => CogCommon/Source/CogCommon/Private/CogCommonModule.cpp} (57%) rename Plugins/{CogDebug/Source/CogDebug/Public/CogDebugLogMacros.h => CogCommon/Source/CogCommon/Public/CogCommon.h} (92%) rename Plugins/{CogInterface/Source/CogInterface/Public/CogInterfaceAllegianceActor.h => CogCommon/Source/CogCommon/Public/CogCommonAllegianceActorInterface.h} (66%) create mode 100644 Plugins/CogCommon/Source/CogCommon/Public/CogCommonDebugFilteredActorInterface.h create mode 100644 Plugins/CogCommon/Source/CogCommon/Public/CogCommonModule.h rename Plugins/{CogInterface/Source/CogInterface/Public/CogInterfacePossessor.h => CogCommon/Source/CogCommon/Public/CogCommonPossessorInterface.h} (77%) delete mode 100644 Plugins/CogDebug/Source/CogDebug/Public/CogDebugDefines.h delete mode 100644 Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceDebugFilteredActor.h delete mode 100644 Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceModule.h diff --git a/Plugins/CogAbility/CogAbility.uplugin b/Plugins/CogAbility/CogAbility.uplugin index a1b7e00..6348991 100644 --- a/Plugins/CogAbility/CogAbility.uplugin +++ b/Plugins/CogAbility/CogAbility.uplugin @@ -27,7 +27,7 @@ "Enabled": true }, { - "Name": "CogInterface", + "Name": "CogCommon", "Enabled": true }, { diff --git a/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs b/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs index 65bb171..8bab94c 100644 --- a/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs +++ b/Plugins/CogAbility/Source/CogAbility/CogAbility.Build.cs @@ -23,7 +23,7 @@ public class CogAbility : ModuleRules { "Core", "CogImgui", - "CogInterface", + "CogCommon", "CogDebug", "CogWindow", "GameplayAbilities", diff --git a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp index e68eb2e..369908d 100644 --- a/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp +++ b/Plugins/CogAbility/Source/CogAbility/Private/CogAbilityWindow_Cheats.cpp @@ -3,7 +3,7 @@ #include "AbilitySystemGlobals.h" #include "CogAbilityDataAsset_Cheats.h" #include "CogAbilityReplicator.h" -#include "CogInterfaceAllegianceActor.h" +#include "CogCommonAllegianceActorInterface.h" #include "CogDebugDraw.h" #include "CogImguiHelper.h" #include "EngineUtils.h" @@ -252,15 +252,15 @@ void UCogAbilityWindow_Cheats::RequestCheat(AActor* ControlledActor, AActor* Sel { if (AActor* OtherActor = *It) { - ECogInterfacesAllegiance Allegiance = ECogInterfacesAllegiance::Enemy; + ECogCommonAllegiance Allegiance = ECogCommonAllegiance::Enemy; - if (ICogInterfacesAllegianceActor* AllegianceInterface = Cast(OtherActor)) + if (ICogCommonAllegianceActorInterface* AllegianceInterface = Cast(OtherActor)) { AllegianceInterface->GetAllegianceWithOtherActor(ControlledActor); } - if ((IsShiftDown && (Allegiance == ECogInterfacesAllegiance::Enemy)) - || (IsAltDown && (Allegiance == ECogInterfacesAllegiance::Friendly))) + if ((IsShiftDown && (Allegiance == ECogCommonAllegiance::Enemy)) + || (IsAltDown && (Allegiance == ECogCommonAllegiance::Friendly))) { Actors.Add(OtherActor); } diff --git a/Plugins/CogInterface/CogInterface.uplugin b/Plugins/CogCommon/CogCommon.uplugin similarity index 87% rename from Plugins/CogInterface/CogInterface.uplugin rename to Plugins/CogCommon/CogCommon.uplugin index c690e32..f353731 100644 --- a/Plugins/CogInterface/CogInterface.uplugin +++ b/Plugins/CogCommon/CogCommon.uplugin @@ -2,7 +2,7 @@ "FileVersion": 1, "Version": 1, "VersionName": "1.0", - "FriendlyName": "CogInterface", + "FriendlyName": "CogCommon", "Description": "", "Category": "Other", "CreatedBy": "Arnaud Jamin", @@ -16,7 +16,7 @@ "Installed": false, "Modules": [ { - "Name": "CogInterface", + "Name": "CogCommon", "Type": "Runtime", "LoadingPhase": "Default" } diff --git a/Plugins/CogInterface/Resources/Icon128.png b/Plugins/CogCommon/Resources/Icon128.png similarity index 100% rename from Plugins/CogInterface/Resources/Icon128.png rename to Plugins/CogCommon/Resources/Icon128.png diff --git a/Plugins/CogInterface/Source/CogInterface/CogInterface.Build.cs b/Plugins/CogCommon/Source/CogCommon/CogCommon.Build.cs similarity index 83% rename from Plugins/CogInterface/Source/CogInterface/CogInterface.Build.cs rename to Plugins/CogCommon/Source/CogCommon/CogCommon.Build.cs index 361a77c..6ef362c 100644 --- a/Plugins/CogInterface/Source/CogInterface/CogInterface.Build.cs +++ b/Plugins/CogCommon/Source/CogCommon/CogCommon.Build.cs @@ -1,8 +1,8 @@ using UnrealBuildTool; -public class CogInterface : ModuleRules +public class CogCommon : ModuleRules { - public CogInterface(ReadOnlyTargetRules Target) : base(Target) + public CogCommon(ReadOnlyTargetRules Target) : base(Target) { PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; diff --git a/Plugins/CogInterface/Source/CogInterface/Private/CogInterfaceModule.cpp b/Plugins/CogCommon/Source/CogCommon/Private/CogCommonModule.cpp similarity index 57% rename from Plugins/CogInterface/Source/CogInterface/Private/CogInterfaceModule.cpp rename to Plugins/CogCommon/Source/CogCommon/Private/CogCommonModule.cpp index 238cffe..dc85505 100644 --- a/Plugins/CogInterface/Source/CogInterface/Private/CogInterfaceModule.cpp +++ b/Plugins/CogCommon/Source/CogCommon/Private/CogCommonModule.cpp @@ -1,17 +1,17 @@ -#include "CogInterfaceModule.h" +#include "CogCommonModule.h" -#define LOCTEXT_NAMESPACE "FCogInterfacesModule" +#define LOCTEXT_NAMESPACE "FCogCommonModule" //-------------------------------------------------------------------------------------------------------------------------- -void FCogInterfaceModule::StartupModule() +void FCogCommonModule::StartupModule() { } //-------------------------------------------------------------------------------------------------------------------------- -void FCogInterfaceModule::ShutdownModule() +void FCogCommonModule::ShutdownModule() { } #undef LOCTEXT_NAMESPACE -IMPLEMENT_MODULE(FCogInterfaceModule, CogInterface) \ No newline at end of file +IMPLEMENT_MODULE(FCogCommonModule, CogCommon) \ No newline at end of file diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogMacros.h b/Plugins/CogCommon/Source/CogCommon/Public/CogCommon.h similarity index 92% rename from Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogMacros.h rename to Plugins/CogCommon/Source/CogCommon/Public/CogCommon.h index b2e37d6..3c2e407 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLogMacros.h +++ b/Plugins/CogCommon/Source/CogCommon/Public/CogCommon.h @@ -1,19 +1,18 @@ -#pragma once +#pragma once #include "CoreMinimal.h" -#include "CogDebugDefines.h" -#include "CogDebugSettings.h" #include "Templates/IsArrayOrRefOfType.h" -#if !ENABLE_COG +#ifndef ENABLE_COG +#define ENABLE_COG !UE_BUILD_SHIPPING +#endif -#define COG_LOG_ACTIVE_FOR_OBJECT(Object) (0) -#define COG_LOG(LogCategory, Verbosity, Format, ...) (0) -#define COG_LOG_FUNC(LogCategory, Verbosity, Format, ...) (0) -#define COG_LOG_OBJECT(LogCategory, Verbosity, Actor, Format, ...) (0) -#define COG_LOG_OBJECT_NO_CONTEXT(LogCategory, Verbosity, Actor, Format, ...) (0) +#if ENABLE_COG -#else //!ENABLE_COG +#include "CogDebugSettings.h" + +#define IF_COG(expr) { expr; } +#define COG_LOG_CATEGORY FLogCategoryBase //-------------------------------------------------------------------------------------------------------------------------- #define COG_LOG_ACTIVE_FOR_OBJECT(Object) (FCogDebugSettings::IsDebugActiveForObject(Object)) @@ -49,5 +48,17 @@ COG_LOG(LogCategory, Verbosity, TEXT("%s - %s"), *GetNameSafe(Object), *FString::Printf(Format, ##__VA_ARGS__)); \ } \ +#else //ENABLE_COG + +#define IF_COG(expr) (0) +#define COG_LOG_CATEGORY FNoLoggingCategory +#define COG_LOG_ABILITY(...) (0) + +#define COG_LOG_ACTIVE_FOR_OBJECT(Object) (0) +#define COG_LOG(LogCategory, Verbosity, Format, ...) (0) +#define COG_LOG_FUNC(LogCategory, Verbosity, Format, ...) (0) +#define COG_LOG_OBJECT(LogCategory, Verbosity, Actor, Format, ...) (0) +#define COG_LOG_OBJECT_NO_CONTEXT(LogCategory, Verbosity, Actor, Format, ...) (0) + +#endif //ENABLE_COG -#endif //!ENABLE_COG diff --git a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceAllegianceActor.h b/Plugins/CogCommon/Source/CogCommon/Public/CogCommonAllegianceActorInterface.h similarity index 66% rename from Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceAllegianceActor.h rename to Plugins/CogCommon/Source/CogCommon/Public/CogCommonAllegianceActorInterface.h index 657a89c..e07ae94 100644 --- a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceAllegianceActor.h +++ b/Plugins/CogCommon/Source/CogCommon/Public/CogCommonAllegianceActorInterface.h @@ -1,11 +1,11 @@ #pragma once #include "CoreMinimal.h" -#include "CogInterfaceAllegianceActor.generated.h" +#include "CogCommonAllegianceActorInterface.generated.h" //-------------------------------------------------------------------------------------------------------------------------- UENUM(BlueprintType) -enum class ECogInterfacesAllegiance : uint8 +enum class ECogCommonAllegiance : uint8 { Friendly, Enemy, @@ -14,17 +14,17 @@ enum class ECogInterfacesAllegiance : uint8 //-------------------------------------------------------------------------------------------------------------------------- UINTERFACE(MinimalAPI, Blueprintable) -class UCogInterfacesAllegianceActor : public UInterface +class UCogCommonAllegianceActorInterface : public UInterface { GENERATED_BODY() }; //-------------------------------------------------------------------------------------------------------------------------- -class ICogInterfacesAllegianceActor +class ICogCommonAllegianceActorInterface { GENERATED_BODY() public: - virtual ECogInterfacesAllegiance GetAllegianceWithOtherActor(const AActor* OtherActor) const = 0; + virtual ECogCommonAllegiance GetAllegianceWithOtherActor(const AActor* OtherActor) const = 0; }; \ No newline at end of file diff --git a/Plugins/CogCommon/Source/CogCommon/Public/CogCommonDebugFilteredActorInterface.h b/Plugins/CogCommon/Source/CogCommon/Public/CogCommonDebugFilteredActorInterface.h new file mode 100644 index 0000000..5d81a1c --- /dev/null +++ b/Plugins/CogCommon/Source/CogCommon/Public/CogCommonDebugFilteredActorInterface.h @@ -0,0 +1,15 @@ +#pragma once + +#include "CoreMinimal.h" +#include "CogCommonDebugFilteredActorInterface.generated.h" + +UINTERFACE(MinimalAPI, Blueprintable) +class UCogCommonDebugFilteredActorInterface : public UInterface +{ + GENERATED_BODY() +}; + +class ICogCommonDebugFilteredActorInterface +{ + GENERATED_BODY() +}; diff --git a/Plugins/CogCommon/Source/CogCommon/Public/CogCommonModule.h b/Plugins/CogCommon/Source/CogCommon/Public/CogCommonModule.h new file mode 100644 index 0000000..b6b66d8 --- /dev/null +++ b/Plugins/CogCommon/Source/CogCommon/Public/CogCommonModule.h @@ -0,0 +1,17 @@ +#pragma once + +#include "CoreMinimal.h" +#include "Modules/ModuleManager.h" + +class COGCOMMON_API FCogCommonModule : public IModuleInterface +{ +public: + + static inline FCogCommonModule& Get() { return FModuleManager::LoadModuleChecked("CogCommon"); } + + virtual void StartupModule() override; + + virtual void ShutdownModule() override; + +private: +}; diff --git a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfacePossessor.h b/Plugins/CogCommon/Source/CogCommon/Public/CogCommonPossessorInterface.h similarity index 77% rename from Plugins/CogInterface/Source/CogInterface/Public/CogInterfacePossessor.h rename to Plugins/CogCommon/Source/CogCommon/Public/CogCommonPossessorInterface.h index 4103837..6371092 100644 --- a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfacePossessor.h +++ b/Plugins/CogCommon/Source/CogCommon/Public/CogCommonPossessorInterface.h @@ -1,17 +1,17 @@ #pragma once #include "CoreMinimal.h" -#include "CogInterfacePossessor.generated.h" +#include "CogCommonPossessorInterface.generated.h" //-------------------------------------------------------------------------------------------------------------------------- UINTERFACE(MinimalAPI, Blueprintable) -class UCogInterfacePossessor : public UInterface +class UCogCommonPossessorInterface : public UInterface { GENERATED_BODY() }; //-------------------------------------------------------------------------------------------------------------------------- -class ICogInterfacePossessor +class ICogCommonPossessorInterface { GENERATED_BODY() diff --git a/Plugins/CogDebug/CogDebug.uplugin b/Plugins/CogDebug/CogDebug.uplugin index 3953e44..9c5b79d 100644 --- a/Plugins/CogDebug/CogDebug.uplugin +++ b/Plugins/CogDebug/CogDebug.uplugin @@ -32,7 +32,7 @@ "Enabled": true }, { - "Name": "CogInterface", + "Name": "CogCommon", "Enabled": true } ] diff --git a/Plugins/CogDebug/Source/CogDebug/CogDebug.Build.cs b/Plugins/CogDebug/Source/CogDebug/CogDebug.Build.cs index 12d9968..5317901 100644 --- a/Plugins/CogDebug/Source/CogDebug/CogDebug.Build.cs +++ b/Plugins/CogDebug/Source/CogDebug/CogDebug.Build.cs @@ -23,7 +23,7 @@ public class CogDebug : ModuleRules { "Core", "CogImgui", - "CogInterface", + "CogCommon", } ); diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDraw.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDraw.cpp index 2900daa..8eaf861 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDraw.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugDraw.cpp @@ -1,13 +1,14 @@ #include "CogDebugDraw.h" #include "CogDebugDrawHelper.h" -#include "CogDebugShape.h" -#include "CogDebugHelper.h" #include "CogDebugDrawImGui.h" -#include "CogImguiHelper.h" +#include "CogDebugHelper.h" #include "CogDebugLog.h" #include "CogDebugModule.h" #include "CogDebugReplicator.h" +#include "CogDebugSettings.h" +#include "CogDebugShape.h" +#include "CogImguiHelper.h" #include "Engine/SkeletalMesh.h" #include "VisualLogger/VisualLogger.h" diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogBlueprint.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogBlueprint.cpp index 5c30c93..a01fd1d 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogBlueprint.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugLogBlueprint.cpp @@ -1,7 +1,7 @@ #include "CogDebugLogBlueprint.h" +#include "CogCommon.h" #include "CogDebugLog.h" -#include "CogDebugLogMacros.h" //-------------------------------------------------------------------------------------------------------------------------- void UCogDebugLogBlueprint::Log(const UObject* WorldContextObject, FCogLogCategory LogCategory, ECogLogVerbosity Verbosity, const FString& Text) diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugPlotBlueprint.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugPlotBlueprint.cpp index 03ab033..2b61343 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugPlotBlueprint.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugPlotBlueprint.cpp @@ -1,6 +1,6 @@ #include "CogDebugPlotBlueprint.h" -#include "CogDebugDefines.h" +#include "CogCommon.h" #include "CogDebugPlot.h" //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugSettings.cpp b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugSettings.cpp index 07ac063..14eed99 100644 --- a/Plugins/CogDebug/Source/CogDebug/Private/CogDebugSettings.cpp +++ b/Plugins/CogDebug/Source/CogDebug/Private/CogDebugSettings.cpp @@ -1,6 +1,6 @@ #include "CogDebugSettings.h" -#include "CogInterfaceDebugFilteredActor.h" +#include "CogCommonDebugFilteredActorInterface.h" //-------------------------------------------------------------------------------------------------------------------------- TWeakObjectPtr FCogDebugSettings::Selection; @@ -92,7 +92,7 @@ bool FCogDebugSettings::IsDebugActiveForObject(const UObject* WorldContextObject return true; } - if (Cast(Outer)) + if (Cast(Outer)) { return false; } diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDefines.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDefines.h deleted file mode 100644 index f55d65d..0000000 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDefines.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" - -#ifndef ENABLE_COG -#define ENABLE_COG (ENABLE_DRAW_DEBUG && !NO_LOGGING) -#endif diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDraw.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDraw.h index 10f756c..42193f4 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDraw.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDraw.h @@ -1,7 +1,7 @@ #pragma once #include "CoreMinimal.h" -#include "CogDebugLogMacros.h" +#include "CogCommon.h" class USkeletalMeshComponent; struct FCogDebugShape; diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDrawHelper.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDrawHelper.h index 6065647..0479b95 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDrawHelper.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugDrawHelper.h @@ -1,7 +1,6 @@ #pragma once #include "CoreMinimal.h" -#include "CogDebugDefines.h" namespace EDrawDebugTrace { enum Type; } diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLog.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLog.h index eb7a858..b3f95b2 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLog.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugLog.h @@ -1,7 +1,6 @@ #pragma once #include "CoreMinimal.h" -#include "CogDebugDefines.h" #include "Logging/LogVerbosity.h" //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugMetric.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugMetric.h index c79e5b3..32a6a97 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugMetric.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugMetric.h @@ -1,7 +1,7 @@ #pragma once #include "CoreMinimal.h" -#include "CogDebugDefines.h" +#include "CogCommon.h" #ifdef ENABLE_COG diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugPlot.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugPlot.h index f22a073..71cfe80 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugPlot.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugPlot.h @@ -1,7 +1,7 @@ #pragma once #include "CoreMinimal.h" -#include "CogDebugDefines.h" +#include "CogCommon.h" #include "imgui.h" #include "implot.h" diff --git a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugSettings.h b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugSettings.h index e0fb732..46f33ad 100644 --- a/Plugins/CogDebug/Source/CogDebug/Public/CogDebugSettings.h +++ b/Plugins/CogDebug/Source/CogDebug/Public/CogDebugSettings.h @@ -1,7 +1,6 @@ #pragma once #include "CoreMinimal.h" -#include "CogDebugLogMacros.h" struct COGDEBUG_API FCogDebugSettings { diff --git a/Plugins/CogEngine/CogEngine.uplugin b/Plugins/CogEngine/CogEngine.uplugin index 27439a7..8455af2 100644 --- a/Plugins/CogEngine/CogEngine.uplugin +++ b/Plugins/CogEngine/CogEngine.uplugin @@ -26,6 +26,10 @@ "Name": "CogImgui", "Enabled": true }, + { + "Name": "CogCommon", + "Enabled": true + }, { "Name": "CogDebug", "Enabled": true diff --git a/Plugins/CogEngine/Source/CogEngine/CogEngine.Build.cs b/Plugins/CogEngine/Source/CogEngine/CogEngine.Build.cs index 4af7de5..4a66a02 100644 --- a/Plugins/CogEngine/Source/CogEngine/CogEngine.Build.cs +++ b/Plugins/CogEngine/Source/CogEngine/CogEngine.Build.cs @@ -22,7 +22,7 @@ public class CogEngine : ModuleRules new string[] { "Core", - "CogInterface", + "CogCommon", "CogImgui", "CogDebug", "CogWindow", diff --git a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineReplicator.cpp b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineReplicator.cpp index 3a4107f..546c585 100644 --- a/Plugins/CogEngine/Source/CogEngine/Private/CogEngineReplicator.cpp +++ b/Plugins/CogEngine/Source/CogEngine/Private/CogEngineReplicator.cpp @@ -1,7 +1,7 @@ #include "CogEngineReplicator.h" -#include "CogDebugLogMacros.h" -#include "CogInterfacePossessor.h" +#include "CogCommon.h" +#include "CogCommonPossessorInterface.h" #include "GameFramework/PlayerController.h" #include "GameFramework/WorldSettings.h" #include "EngineUtils.h" @@ -159,7 +159,7 @@ void ACogEngineReplicator::Server_Possess_Implementation(APawn* Pawn) { #if !UE_BUILD_SHIPPING - if (ICogInterfacePossessor* Possessor = Cast(OwnerPlayerController)) + if (ICogCommonPossessorInterface* Possessor = Cast(OwnerPlayerController)) { Possessor->SetPossession(Pawn); } @@ -172,7 +172,7 @@ void ACogEngineReplicator::Server_ResetPossession_Implementation() { #if !UE_BUILD_SHIPPING - if (ICogInterfacePossessor* Possessor = Cast(OwnerPlayerController)) + if (ICogCommonPossessorInterface* Possessor = Cast(OwnerPlayerController)) { Possessor->ResetPossession(); } diff --git a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceDebugFilteredActor.h b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceDebugFilteredActor.h deleted file mode 100644 index 8970e50..0000000 --- a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceDebugFilteredActor.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "CogInterfaceDebugFilteredActor.generated.h" - -UINTERFACE(MinimalAPI, Blueprintable) -class UCogInterfacesDebugFilteredActor : public UInterface -{ - GENERATED_BODY() -}; - -class ICogInterfacesDebugFilteredActor -{ - GENERATED_BODY() -}; diff --git a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceModule.h b/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceModule.h deleted file mode 100644 index f93b9f7..0000000 --- a/Plugins/CogInterface/Source/CogInterface/Public/CogInterfaceModule.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "Modules/ModuleManager.h" - -class COGINTERFACE_API FCogInterfaceModule : public IModuleInterface -{ -public: - - static inline FCogInterfaceModule& Get() { return FModuleManager::LoadModuleChecked("CogInterface"); } - - virtual void StartupModule() override; - - virtual void ShutdownModule() override; - -private: -}; diff --git a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp index 8e39371..6c68188 100644 --- a/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp +++ b/Plugins/CogWindow/Source/CogWindow/Private/CogWindowManager.cpp @@ -1,9 +1,10 @@ #include "CogWindowManager.h" +#include "CogDebugDrawImGui.h" #include "CogImguiModule.h" #include "CogImguiWidget.h" -#include "CogWindowWidgets.h" #include "CogWindow_Spacing.h" +#include "CogWindowWidgets.h" #include "Engine/Engine.h" #include "imgui_internal.h" @@ -13,10 +14,9 @@ UCogWindowManager::UCogWindowManager() } //-------------------------------------------------------------------------------------------------------------------------- -void UCogWindowManager::Initialize(UWorld* InWorld, TSharedPtr InImGuiWidget) +void UCogWindowManager::InitializeInternal() { - World = InWorld; - ImGuiWidget = InImGuiWidget; + ImGuiWidget = FCogImguiModule::Get().CreateImGuiViewport(GEngine->GameViewport, [this](float DeltaTime) { Render(DeltaTime); }); ImGuiSettingsHandler IniHandler; IniHandler.TypeName = "Cog"; @@ -50,6 +50,16 @@ void UCogWindowManager::Shutdown() //-------------------------------------------------------------------------------------------------------------------------- void UCogWindowManager::Tick(float DeltaTime) { + if (GEngine->GameViewport == nullptr) + { + return; + } + + if (ImGuiWidget.IsValid() == false) + { + InitializeInternal(); + } + if (LayoutToLoad != -1) { FString Filename = FCogImguiHelper::GetIniFilePath(FString::Printf(TEXT("ImGui_Layout_%d"), LayoutToLoad)); @@ -112,6 +122,8 @@ void UCogWindowManager::Render(float DeltaTime) } TickDPI(); + + FCogDebugDrawImGui::Draw(); } //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h index 71fa965..fc59cda 100644 --- a/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h +++ b/Plugins/CogWindow/Source/CogWindow/Public/CogWindowManager.h @@ -19,8 +19,6 @@ class COGWINDOW_API UCogWindowManager : public UObject public: UCogWindowManager(); - void Initialize(UWorld* World, TSharedPtr InImGuiWidget); - void Shutdown(); void SortMainMenu(); @@ -61,7 +59,7 @@ public: bool GetShowHelp() const { return bShowHelp; } -private: +protected: struct FMenu { @@ -70,6 +68,8 @@ private: TArray SubMenus; }; + void InitializeInternal(); + void RefreshDPIScale(); void DrawMainMenu(); @@ -79,9 +79,13 @@ private: void DrawMenu(FMenu& Menu); static void SettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*); + static void SettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*); + static void* SettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name); + static void SettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line); + static void SettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf); void TickDPI(); @@ -109,10 +113,13 @@ private: TSharedPtr ImGuiWidget; - TWeakObjectPtr World; FMenu MainMenu; + int32 LayoutToLoad = -1; + int32 HideAllWindowsCounter = 0; + bool bHideAllWindows = false; + bool bRefreshDPIScale; }; diff --git a/Source/CogSample/CogSample.Build.cs b/Source/CogSample/CogSample.Build.cs index 3c0691b..d99cabe 100644 --- a/Source/CogSample/CogSample.Build.cs +++ b/Source/CogSample/CogSample.Build.cs @@ -8,8 +8,8 @@ public class CogSample : ModuleRules PublicDependencyModuleNames.AddRange(new string[] { - "CogDebug", - "Core", + "CogCommon", + "Core", "CoreUObject", "Engine", "EnhancedInput", @@ -25,8 +25,8 @@ public class CogSample : ModuleRules { PublicDependencyModuleNames.AddRange(new string[] { + "CogDebug", "CogImgui", - "CogInterface", "CogWindow", "CogEngine", "CogInput", diff --git a/Source/CogSample/CogSampleCharacter.cpp b/Source/CogSample/CogSampleCharacter.cpp index 9a5376a..ecf8c26 100644 --- a/Source/CogSample/CogSampleCharacter.cpp +++ b/Source/CogSample/CogSampleCharacter.cpp @@ -1,8 +1,7 @@ #include "CogSampleCharacter.h" #include "Camera/CameraComponent.h" -#include "CogDebugLogMacros.h" -#include "CogDebugMetric.h" +#include "CogCommon.h" #include "CogSampleAttributeSet_Health.h" #include "CogSampleAttributeSet_Misc.h" #include "CogSampleCharacterMovementComponent.h" @@ -24,10 +23,11 @@ #include "Net/Core/PushModel/PushModel.h" #include "Net/UnrealNetwork.h" -#if USE_COG +#if ENABLE_COG #include "CogDebugDraw.h" +#include "CogDebugMetric.h" #include "CogDebugPlot.h" -#endif //USE_COG +#endif //ENABLE_COG //-------------------------------------------------------------------------------------------------------------------------- ACogSampleCharacter::ACogSampleCharacter(const FObjectInitializer& ObjectInitializer) @@ -476,18 +476,18 @@ void ACogSampleCharacter::Look(const FInputActionValue& Value) } //-------------------------------------------------------------------------------------------------------------------------- -ECogInterfacesAllegiance ACogSampleCharacter::GetAllegianceWithOtherActor(const AActor* OtherActor) const +ECogCommonAllegiance ACogSampleCharacter::GetAllegianceWithOtherActor(const AActor* OtherActor) const { ECogSampleAllegiance Allegiance = UCogSampleFunctionLibrary_Team::GetActorsAllegiance(this, OtherActor); switch (Allegiance) { - case ECogSampleAllegiance::Enemy: return ECogInterfacesAllegiance::Enemy; - case ECogSampleAllegiance::Friendly: return ECogInterfacesAllegiance::Friendly; - case ECogSampleAllegiance::Neutral: return ECogInterfacesAllegiance::Neutral; + case ECogSampleAllegiance::Enemy: return ECogCommonAllegiance::Enemy; + case ECogSampleAllegiance::Friendly: return ECogCommonAllegiance::Friendly; + case ECogSampleAllegiance::Neutral: return ECogCommonAllegiance::Neutral; } - return ECogInterfacesAllegiance::Neutral; + return ECogCommonAllegiance::Neutral; } //-------------------------------------------------------------------------------------------------------------------------- @@ -495,9 +495,9 @@ void ACogSampleCharacter::HandleDamageReceived(const FCogSampleDamageEventParams { OnDamageReceived.Broadcast(Params); -#if USE_COG +#if ENABLE_COG FCogDebugMetric::AddMetric(this, "Damage Received", Params.MitigatedDamage, Params.UnmitigatedDamage, false); -#endif //USE_COG +#endif //ENABLE_COG } //-------------------------------------------------------------------------------------------------------------------------- @@ -505,9 +505,9 @@ void ACogSampleCharacter::HandleDamageDealt(const FCogSampleDamageEventParams& P { OnDamageDealt.Broadcast(Params); -#if USE_COG +#if ENABLE_COG FCogDebugMetric::AddMetric(this, "Damage Dealt", Params.MitigatedDamage, Params.UnmitigatedDamage, false); -#endif //USE_COG +#endif //ENABLE_COG } //-------------------------------------------------------------------------------------------------------------------------- @@ -553,21 +553,21 @@ void ACogSampleCharacter::OnRevived(AActor* InInstigator, AActor* InCauser, cons // ---------------------------------------------------------------------------------------------------------------- void ACogSampleCharacter::OnGameplayEffectAdded(UAbilitySystemComponent* AbilitySystemComponent, const FGameplayEffectSpec& GameplayEffectSpec, FActiveGameplayEffectHandle Handle) { -#if USE_COG +#if ENABLE_COG FCogDebugPlot::PlotEvent(this, "Effects", GameplayEffectSpec.Def->GetFName(), GameplayEffectSpec.GetDuration() == 0.0f) .AddParam("Name", AbilitySystemComponent->CleanupName(GetNameSafe(GameplayEffectSpec.Def))) .AddParam("Effect Instigator", GetNameSafe(GameplayEffectSpec.GetEffectContext().GetInstigator())) .AddParam("Effect Level", GameplayEffectSpec.GetLevel()) .AddParam("Effect Duration", GameplayEffectSpec.GetDuration()); -#endif //USE_COG +#endif //ENABLE_COG } // ---------------------------------------------------------------------------------------------------------------- void ACogSampleCharacter::OnGameplayEffectRemoved(const FActiveGameplayEffect& RemovedGameplayEffect) { -#if USE_COG +#if ENABLE_COG FCogDebugPlot::PlotEventStop(this, "Effects", RemovedGameplayEffect.Spec.Def->GetFName()); -#endif //USE_COG +#endif //ENABLE_COG } // ---------------------------------------------------------------------------------------------------------------- diff --git a/Source/CogSample/CogSampleCharacter.h b/Source/CogSample/CogSampleCharacter.h index a23497b..169cdf3 100644 --- a/Source/CogSample/CogSampleCharacter.h +++ b/Source/CogSample/CogSampleCharacter.h @@ -4,10 +4,10 @@ #include "AbilitySystemInterface.h" #include "ActiveGameplayEffectHandle.h" #include "AttributeSet.h" -#include "CogSampleDefines.h" -#include "CogInterfaceAllegianceActor.h" -#include "CogInterfaceDebugFilteredActor.h" +#include "CogCommonAllegianceActorInterface.h" +#include "CogCommonDebugFilteredActorInterface.h" #include "CogSampleDamageEvent.h" +#include "CogSampleDefines.h" #include "CogSampleTargetableInterface.h" #include "CogSampleTeamInterface.h" #include "GameFramework/Character.h" @@ -65,8 +65,8 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCogSampleCharacterEventDelegate, AC UCLASS(config=Game) class ACogSampleCharacter : public ACharacter , public IAbilitySystemInterface - , public ICogInterfacesDebugFilteredActor - , public ICogInterfacesAllegianceActor + , public ICogCommonDebugFilteredActorInterface + , public ICogCommonAllegianceActorInterface , public ICogSampleTeamInterface , public ICogSampleTargetableInterface { @@ -108,7 +108,7 @@ public: // ICogInterfacesAllegianceActor overrides //---------------------------------------------------------------------------------------------------------------------- - ECogInterfacesAllegiance GetAllegianceWithOtherActor(const AActor* OtherActor) const override; + ECogCommonAllegiance GetAllegianceWithOtherActor(const AActor* OtherActor) const override; //---------------------------------------------------------------------------------------------------------------------- // ICogSampleTargetInterface overrides diff --git a/Source/CogSample/CogSampleCharacterMovementComponent.cpp b/Source/CogSample/CogSampleCharacterMovementComponent.cpp index ba6580d..116faac 100644 --- a/Source/CogSample/CogSampleCharacterMovementComponent.cpp +++ b/Source/CogSample/CogSampleCharacterMovementComponent.cpp @@ -9,10 +9,10 @@ #include "Components/CapsuleComponent.h" #include "GameFramework/Character.h" -#if USE_COG +#if ENABLE_COG #include "CogDebugDraw.h" #include "CogDebugPlot.h" -#endif //USE_COG +#endif //ENABLE_COG //-------------------------------------------------------------------------------------------------------------------------- // UCogSampleCharacterMovementComponent::FCogSampleSavedMove @@ -209,17 +209,17 @@ void UCogSampleCharacterMovementComponent::BeginPlay() { Super::BeginPlay(); -#if USE_COG +#if ENABLE_COG const ACharacter* Character = GetCharacterOwner(); const UCapsuleComponent* CapsuleComponent = Character->GetCapsuleComponent(); DebugLastBottomLocation = Character->GetActorLocation() - FVector::UpVector * CapsuleComponent->GetScaledCapsuleHalfHeight(); -#endif //USE_COG +#endif //ENABLE_COG } //-------------------------------------------------------------------------------------------------------------------------- void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { -#if USE_COG +#if ENABLE_COG const ACharacter* Character = GetCharacterOwner(); const UCapsuleComponent* CapsuleComponent = Character->GetCapsuleComponent(); @@ -232,11 +232,11 @@ void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum E FCogDebugPlot::PlotValue(GetPawnOwner(), "Move Input Local Y", FVector::DotProduct(GetPawnOwner()->GetActorForwardVector(), GetPendingInputVector())); } -#endif //USE_COG +#endif //ENABLE_COG Super::TickComponent(DeltaTime, TickType, ThisTickFunction); -#if USE_COG +#if ENABLE_COG const FVector DebugLocation = Character->GetActorLocation(); const FVector DebugBottomLocation = DebugLocation - FVector::UpVector * CapsuleComponent->GetScaledCapsuleHalfHeight(); @@ -294,7 +294,7 @@ void UCogSampleCharacterMovementComponent::TickComponent(float DeltaTime, enum E DebugLastVelocity = Velocity; DebugIsPositionCorrected = false; -#endif //USE_COG +#endif //ENABLE_COG } @@ -303,9 +303,9 @@ bool UCogSampleCharacterMovementComponent::ClientUpdatePositionAfterServerUpdate { bool Result = Super::ClientUpdatePositionAfterServerUpdate(); -#if USE_COG +#if ENABLE_COG DebugIsPositionCorrected = true; -#endif //USE_COG +#endif //ENABLE_COG return Result; } diff --git a/Source/CogSample/CogSampleCharacterMovementComponent.h b/Source/CogSample/CogSampleCharacterMovementComponent.h index 6af1c86..3d097a3 100644 --- a/Source/CogSample/CogSampleCharacterMovementComponent.h +++ b/Source/CogSample/CogSampleCharacterMovementComponent.h @@ -47,7 +47,7 @@ private: bool bWasAvoidanceEnabled = false; -#if USE_COG +#if ENABLE_COG FVector DebugLastBottomLocation = FVector::ZeroVector; @@ -55,7 +55,7 @@ private: bool DebugIsPositionCorrected = false; -#endif //USE_COG +#endif //ENABLE_COG //---------------------------------------------------------------------------------------------------------------------- diff --git a/Source/CogSample/CogSampleDefines.h b/Source/CogSample/CogSampleDefines.h index 8e5fe99..b0c560a 100644 --- a/Source/CogSample/CogSampleDefines.h +++ b/Source/CogSample/CogSampleDefines.h @@ -1,19 +1,12 @@ #pragma once #include "CoreMinimal.h" +#include "CogCommon.h" -#ifndef USE_COG -#define USE_COG (ENABLE_DRAW_DEBUG && !NO_LOGGING) -#endif +#if ENABLE_COG -#if USE_COG - -#include "CogDebugLogMacros.h" #include "CogDebugSettings.h" -#define IF_COG(expr) { expr; } -#define COG_LOG_CATEGORY FLogCategoryBase - #define COG_LOG_ABILITY(Verbosity, Ability, Format, ...) \ if (Ability != nullptr) \ { \ @@ -28,10 +21,8 @@ } \ } \ -#else //USE_COG +#else //ENABLE_COG -#define IF_COG(expr) (0) -#define COG_LOG_CATEGORY FNoLoggingCategory #define COG_LOG_ABILITY(...) (0) -#endif //USE_COG +#endif //ENABLE_COG diff --git a/Source/CogSample/CogSampleFunctionLibrary_Gameplay.cpp b/Source/CogSample/CogSampleFunctionLibrary_Gameplay.cpp index 573d08d..e8225f4 100644 --- a/Source/CogSample/CogSampleFunctionLibrary_Gameplay.cpp +++ b/Source/CogSample/CogSampleFunctionLibrary_Gameplay.cpp @@ -14,10 +14,10 @@ #include "Particles/ParticleSystemComponent.h" #include "ScalableFloat.h" -#if USE_COG +#if ENABLE_COG #include "CogDebugDraw.h" #include "CogDebugLog.h" -#endif //USE_COG +#endif //ENABLE_COG //-------------------------------------------------------------------------------------------------------------------------- void UCogSampleFunctionLibrary_Gameplay::AdjustAttributeForMaxChange(UAbilitySystemComponent* AbilityComponent, FGameplayAttributeData& AffectedAttribute, float OldValue, float NewMaxValue, const FGameplayAttribute& AffectedAttributeProperty) diff --git a/Source/CogSample/CogSampleGameState.cpp b/Source/CogSample/CogSampleGameState.cpp index 62cf888..6b3ecdf 100644 --- a/Source/CogSample/CogSampleGameState.cpp +++ b/Source/CogSample/CogSampleGameState.cpp @@ -2,14 +2,14 @@ #include "AssetRegistry/AssetRegistryModule.h" #include "AssetRegistry/IAssetRegistry.h" -#include "CogSampleDefines.h" +#include "CogCommon.h" #include "CogSampleFunctionLibrary_Tag.h" #include "GameFramework/Character.h" #include "GameFramework/GameMode.h" #include "GameFramework/GameState.h" #include "Modules/ModuleManager.h" -#if USE_COG +#if ENABLE_COG #include "CogAbilityDataAsset_Abilities.h" #include "CogAbilityDataAsset_Cheats.h" #include "CogAbilityDataAsset_Pools.h" @@ -22,7 +22,6 @@ #include "CogAbilityWindow_Pools.h" #include "CogAbilityWindow_Tags.h" #include "CogAbilityWindow_Tweaks.h" -#include "CogDebugDefines.h" #include "CogDebugDrawImGui.h" #include "CogDebugPlot.h" #include "CogEngineDataAsset_Collisions.h" @@ -47,7 +46,7 @@ #include "CogInputWindow_Actions.h" #include "CogInputWindow_Gamepad.h" #include "CogWindowManager.h" -#endif //USE_COG +#endif //ENABLE_COG //-------------------------------------------------------------------------------------------------------------------------- @@ -82,6 +81,10 @@ ACogSampleGameState::ACogSampleGameState(const FObjectInitializer & ObjectInitia void ACogSampleGameState::BeginPlay() { Super::BeginPlay(); + +#if ENABLE_COG + InitializeCog(); +#endif //ENABLE_COG } //-------------------------------------------------------------------------------------------------------------------------- @@ -89,12 +92,12 @@ void ACogSampleGameState::EndPlay(const EEndPlayReason::Type EndPlayReason) { Super::EndPlay(EndPlayReason); -#if USE_COG +#if ENABLE_COG if (CogWindowManager != nullptr) { CogWindowManager->Shutdown(); } -#endif //USE_COG +#endif //ENABLE_COG } //-------------------------------------------------------------------------------------------------------------------------- @@ -102,48 +105,28 @@ void ACogSampleGameState::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); -#if USE_COG - TickCog(DeltaSeconds); -#endif //USE_COG -} - -#if USE_COG - -//-------------------------------------------------------------------------------------------------------------------------- -void ACogSampleGameState::TickCog(float DeltaSeconds) -{ - //--------------------------------------- - // Wait for the viewport to be set - //--------------------------------------- - if (GEngine->GameViewport != nullptr) - { - if (CogWindowManager == nullptr) - { - InitializeCog(); - } - else - { - CogWindowManager->Tick(DeltaSeconds); - } - } +#if ENABLE_COG extern ENGINE_API float GAverageFPS; extern ENGINE_API float GAverageMS; FCogDebugPlot::PlotValue(this, "Frame Rate", GAverageFPS); FCogDebugPlot::PlotValue(this, "Frame Time", GAverageMS); + + CogWindowManager->Tick(DeltaSeconds); + +#endif //ENABLE_COG } +#if ENABLE_COG + //-------------------------------------------------------------------------------------------------------------------------- void ACogSampleGameState::InitializeCog() { - RegisterCommand(TEXT("Cog.ToggleInput"), TEXT(""), FConsoleCommandWithArgsDelegate::CreateUObject(this, &ACogSampleGameState::CogToggleInput)); - - TSharedPtr Widget = FCogImguiModule::Get().CreateImGuiViewport(GEngine->GameViewport, [this](float DeltaTime) { RenderCog(DeltaTime); }); FCogImguiModule::Get().SetToggleInputKey(FCogImGuiKeyInfo(EKeys::Insert)); + RegisterCommand(TEXT("Cog.ToggleInput"), TEXT(""), FConsoleCommandWithArgsDelegate::CreateUObject(this, &ACogSampleGameState::CogToggleInput)); CogWindowManager = NewObject(this); CogWindowManagerRef = CogWindowManager; - CogWindowManager->Initialize(GetWorld(), Widget); //--------------------------------------- // Engine @@ -174,7 +157,7 @@ void ACogSampleGameState::InitializeCog() CogWindowManager->CreateWindow("Engine.Skeleton"); - UCogEngineWindow_Spawns* SpawnWindow =CogWindowManager->CreateWindow("Engine.Spawns"); + UCogEngineWindow_Spawns* SpawnWindow = CogWindowManager->CreateWindow("Engine.Spawns"); SpawnWindow->SetSpawnsAsset(GetFirstAssetByClass()); UCogEngineWindow_Stats* StatsWindow = CogWindowManager->CreateWindow("Engine.Stats"); @@ -220,13 +203,6 @@ void ACogSampleGameState::InitializeCog() CogWindowManager->AddMainMenuWidget(StatsWindow); } -//-------------------------------------------------------------------------------------------------------------------------- -void ACogSampleGameState::RenderCog(float DeltaTime) -{ - CogWindowManager->Render(DeltaTime); - FCogDebugDrawImGui::Draw(); -} - //-------------------------------------------------------------------------------------------------------------------------- void ACogSampleGameState::RegisterCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsDelegate& Command) { @@ -244,4 +220,4 @@ void ACogSampleGameState::CogToggleInput(const TArray& Args) } -#endif //USE_COG +#endif //ENABLE_COG diff --git a/Source/CogSample/CogSampleGameState.h b/Source/CogSample/CogSampleGameState.h index 5c95d2d..c6adefd 100644 --- a/Source/CogSample/CogSampleGameState.h +++ b/Source/CogSample/CogSampleGameState.h @@ -25,19 +25,15 @@ private: UPROPERTY() TObjectPtr CogWindowManagerRef = nullptr; -#if USE_COG +#if ENABLE_COG void InitializeCog(); - void TickCog(float DeltaTime); - - void RenderCog(float DeltaTime); - void RegisterCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsDelegate& Command); void CogToggleInput(const TArray& Args); TObjectPtr CogWindowManager = nullptr; -#endif //USE_COG +#endif //ENABLE_COG }; diff --git a/Source/CogSample/CogSampleLogCategories.cpp b/Source/CogSample/CogSampleLogCategories.cpp index 7469795..c9be6ca 100644 --- a/Source/CogSample/CogSampleLogCategories.cpp +++ b/Source/CogSample/CogSampleLogCategories.cpp @@ -3,9 +3,9 @@ #include "AbilitySystemLog.h" #include "CogSampleDefines.h" -#if USE_COG +#if ENABLE_COG #include "CogDebugLog.h" -#endif //USE_COG +#endif //ENABLE_COG DEFINE_LOG_CATEGORY(LogCogAlways); @@ -24,7 +24,7 @@ namespace CogSampleLog { void RegiterAllLogCategories() { -#if USE_COG +#if ENABLE_COG FCogDebugLog::AddLogCategory(LogCogAlways, "Always", false); FCogDebugLog::AddLogCategory(LogCogAbility, "Ability"); @@ -39,7 +39,7 @@ namespace CogSampleLog FCogDebugLog::AddLogCategory(LogCogSkeleton, "Skeleton"); FCogDebugLog::AddLogCategory(LogCogTargetAcquisition, "Target Acquisition"); FCogDebugLog::AddLogCategory(LogGameplayEffects, "Gameplay Effects"); -#endif //USE_COG +#endif //ENABLE_COG } } diff --git a/Source/CogSample/CogSamplePlayerController.cpp b/Source/CogSample/CogSamplePlayerController.cpp index 3386d0e..68b365e 100644 --- a/Source/CogSample/CogSamplePlayerController.cpp +++ b/Source/CogSample/CogSamplePlayerController.cpp @@ -1,19 +1,18 @@ #include "CogSamplePlayerController.h" -#include "CogDebugLogMacros.h" +#include "CogCommon.h" #include "CogSampleDefines.h" #include "CogSampleCharacter.h" #include "CogSampleLogCategories.h" #include "CogSampleTargetAcquisition.h" #include "Net/UnrealNetwork.h" -#if USE_COG +#if ENABLE_COG #include "CogAbilityReplicator.h" -#include "CogDebugDefines.h" #include "CogDebugDraw.h" #include "CogDebugReplicator.h" #include "CogEngineReplicator.h" -#endif //USE_COG +#endif //ENABLE_COG //-------------------------------------------------------------------------------------------------------------------------- ACogSamplePlayerController::ACogSamplePlayerController() @@ -25,11 +24,11 @@ void ACogSamplePlayerController::BeginPlay() { Super::BeginPlay(); -#if USE_COG +#if ENABLE_COG ACogDebugReplicator::Spawn(this); ACogAbilityReplicator::Spawn(this); ACogEngineReplicator::Spawn(this); -#endif //USE_COG +#endif //ENABLE_COG } //-------------------------------------------------------------------------------------------------------------------------- @@ -169,12 +168,12 @@ void ACogSamplePlayerController::TickTargeting(float DeltaSeconds) SetTarget(Result.Target); } -#if USE_COG +#if ENABLE_COG if (Target != nullptr && PossessedCharacter != nullptr) { FCogDebugDraw::Segment(LogCogTargetAcquisition, PossessedCharacter.Get(), PossessedCharacter->GetActorLocation(), Target->GetActorLocation(), FColor::White, false); } -#endif //USE_COG +#endif //ENABLE_COG } //-------------------------------------------------------------------------------------------------------------------------- diff --git a/Source/CogSample/CogSamplePlayerController.h b/Source/CogSample/CogSamplePlayerController.h index 5e35600..2e086ca 100644 --- a/Source/CogSample/CogSamplePlayerController.h +++ b/Source/CogSample/CogSamplePlayerController.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" #include "AbilitySystemInterface.h" -#include "CogInterfacePossessor.h" +#include "CogCommonPossessorInterface.h" #include "GameFramework/PlayerController.h" #include "CogSamplePlayerController.generated.h" @@ -18,7 +18,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FCogSampleControlledCharacterChan UCLASS(config=Game) class ACogSamplePlayerController : public APlayerController - , public ICogInterfacePossessor + , public ICogCommonPossessorInterface { GENERATED_BODY() diff --git a/Source/CogSample/CogSampleTargetAcquisition.cpp b/Source/CogSample/CogSampleTargetAcquisition.cpp index 4473837..0b5dba7 100644 --- a/Source/CogSample/CogSampleTargetAcquisition.cpp +++ b/Source/CogSample/CogSampleTargetAcquisition.cpp @@ -9,10 +9,10 @@ #include "Components/CapsuleComponent.h" #include "GameFramework/PlayerController.h" -#if USE_COG +#if ENABLE_COG #include "CogDebugDraw.h" #include "CogDebugLog.h" -#endif //USE_COG +#endif //ENABLE_COG //-------------------------------------------------------------------------------------------------------------------------- // FCogSampleTargetTargetAcquisitionParams @@ -125,13 +125,13 @@ void UCogSampleTargetAcquisition::FindBestTarget( //---------------------------------------------------------------------------------------------------------------------- // Draw the ScreenSearchDirection if valid //---------------------------------------------------------------------------------------------------------------------- -#if USE_COG +#if ENABLE_COG const FVector2D SearchDirectionNormalized = (TargetSwitchSearchDirection.IsNearlyZero() == false) ? TargetSwitchSearchDirection.GetSafeNormal() : FVector2D::ZeroVector; if (SearchDirectionNormalized.IsNearlyZero() == false) { FCogDebugDraw::Segment2D(LogCogTargetAcquisition, Controller, FVector2D::ZeroVector, FVector2D(SearchDirectionNormalized.X, -SearchDirectionNormalized.Y), FColor(255, 255, 0, 255), bIsDebugPersistent); } -#endif //USE_COG +#endif //ENABLE_COG static const FName TraceTag(TEXT("FindLockTarget_GatherTargets")); FCollisionQueryParams QueryParams(TraceTag, SCENE_QUERY_STAT_ONLY(CogSampleTargetAcquisition), false); @@ -285,7 +285,7 @@ void UCogSampleTargetAcquisition::FindBestTargetInCandidates( // Draw screen limits //---------------------------------------------------------------------------------------------------------------------- -#if USE_COG +#if ENABLE_COG FCogDebugDraw::Circle2D(LogCogTargetAcquisition, Controller, ScreenCrosshairPosition, 5.0f, FColor(255, 255, 255, 255), bIsDebugPersistent); @@ -312,7 +312,7 @@ void UCogSampleTargetAcquisition::FindBestTargetInCandidates( bIsDebugPersistent); } } -#endif //USE_COG +#endif //ENABLE_COG const FRotator YawRotation = GetReferentialRotation(Character, YawReferential); const FVector YawDirection = YawRotation.Vector(); @@ -545,7 +545,7 @@ bool UCogSampleTargetAcquisition::EvaluateCandidate( //-------------------------------------------------------------------------------------------------------------- // Draw the score of each candidate //-------------------------------------------------------------------------------------------------------------- -#if USE_COG +#if ENABLE_COG if (FCogDebugLog::IsLogCategoryActive(LogCogTargetAcquisition)) { @@ -597,7 +597,7 @@ bool UCogSampleTargetAcquisition::EvaluateCandidate( FCogDebugDraw::String(LogCogTargetAcquisition, EvalParams.Controller, Text, CandidateTargetLocation, FColor::White, EvalParams.IsDebugPersistent); } -#endif //USE_COG +#endif //ENABLE_COG return true; } @@ -669,13 +669,13 @@ bool UCogSampleTargetAcquisition::ComputeCandidateScreenLocation( bFoundValidCandidate = true; } -#if USE_COG +#if ENABLE_COG const FColor CapsuleColor = (ScreenCenterToCapsuleDistance > 0.0f) ? FColor(255, 255, 255, 100) : FColor(0, 255, 0, 200); FCogDebugDraw::Segment2D(LogCogTargetAcquisition, CandidateActor, CapsuleBot2D + FVector2D(CapsuleRadius2D, 0), CapsuleTop2D + FVector2D(CapsuleRadius2D, 0), CapsuleColor, Params.IsDebugPersistent); FCogDebugDraw::Segment2D(LogCogTargetAcquisition, CandidateActor, CapsuleBot2D - FVector2D(CapsuleRadius2D, 0), CapsuleTop2D - FVector2D(CapsuleRadius2D, 0), CapsuleColor, Params.IsDebugPersistent); FCogDebugDraw::Circle2D(LogCogTargetAcquisition, CandidateActor, CapsuleTop2D, CapsuleRadius2D, CapsuleColor, Params.IsDebugPersistent); FCogDebugDraw::Circle2D(LogCogTargetAcquisition, CandidateActor, CapsuleBot2D, CapsuleRadius2D, CapsuleColor, Params.IsDebugPersistent); -#endif //USE_COG +#endif //ENABLE_COG } } else @@ -688,12 +688,12 @@ bool UCogSampleTargetAcquisition::ComputeCandidateScreenLocation( } } -#if USE_COG +#if ENABLE_COG if (bFoundValidCandidate) { FCogDebugDraw::Circle2D(LogCogTargetAcquisition, CandidateActor, CandidateClosestScreenLocation, 2.0f, FColor(0, 255, 0, 255), Params.IsDebugPersistent); } -#endif //USE_COG +#endif //ENABLE_COG return bFoundValidCandidate; }