simplify integration

This commit is contained in:
Arnaud Jamin
2023-10-10 23:53:34 -04:00
parent 7094dbf1f5
commit eb963614b9
45 changed files with 217 additions and 230 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
"Enabled": true
},
{
"Name": "CogInterface",
"Name": "CogCommon",
"Enabled": true
},
{
@@ -23,7 +23,7 @@ public class CogAbility : ModuleRules
{
"Core",
"CogImgui",
"CogInterface",
"CogCommon",
"CogDebug",
"CogWindow",
"GameplayAbilities",
@@ -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<ICogInterfacesAllegianceActor>(OtherActor))
if (ICogCommonAllegianceActorInterface* AllegianceInterface = Cast<ICogCommonAllegianceActorInterface>(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);
}
@@ -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"
}

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

@@ -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;
@@ -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)
IMPLEMENT_MODULE(FCogCommonModule, CogCommon)
@@ -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
@@ -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;
};
@@ -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()
};
@@ -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<FCogCommonModule>("CogCommon"); }
virtual void StartupModule() override;
virtual void ShutdownModule() override;
private:
};
@@ -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()
+1 -1
View File
@@ -32,7 +32,7 @@
"Enabled": true
},
{
"Name": "CogInterface",
"Name": "CogCommon",
"Enabled": true
}
]
@@ -23,7 +23,7 @@ public class CogDebug : ModuleRules
{
"Core",
"CogImgui",
"CogInterface",
"CogCommon",
}
);
@@ -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"
@@ -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)
@@ -1,6 +1,6 @@
#include "CogDebugPlotBlueprint.h"
#include "CogDebugDefines.h"
#include "CogCommon.h"
#include "CogDebugPlot.h"
//--------------------------------------------------------------------------------------------------------------------------
@@ -1,6 +1,6 @@
#include "CogDebugSettings.h"
#include "CogInterfaceDebugFilteredActor.h"
#include "CogCommonDebugFilteredActorInterface.h"
//--------------------------------------------------------------------------------------------------------------------------
TWeakObjectPtr<AActor> FCogDebugSettings::Selection;
@@ -92,7 +92,7 @@ bool FCogDebugSettings::IsDebugActiveForObject(const UObject* WorldContextObject
return true;
}
if (Cast<ICogInterfacesDebugFilteredActor>(Outer))
if (Cast<ICogCommonDebugFilteredActorInterface>(Outer))
{
return false;
}
@@ -1,7 +0,0 @@
#pragma once
#include "CoreMinimal.h"
#ifndef ENABLE_COG
#define ENABLE_COG (ENABLE_DRAW_DEBUG && !NO_LOGGING)
#endif
@@ -1,7 +1,7 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugLogMacros.h"
#include "CogCommon.h"
class USkeletalMeshComponent;
struct FCogDebugShape;
@@ -1,7 +1,6 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugDefines.h"
namespace EDrawDebugTrace { enum Type; }
@@ -1,7 +1,6 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugDefines.h"
#include "Logging/LogVerbosity.h"
//--------------------------------------------------------------------------------------------------------------------------
@@ -1,7 +1,7 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugDefines.h"
#include "CogCommon.h"
#ifdef ENABLE_COG
@@ -1,7 +1,7 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugDefines.h"
#include "CogCommon.h"
#include "imgui.h"
#include "implot.h"
@@ -1,7 +1,6 @@
#pragma once
#include "CoreMinimal.h"
#include "CogDebugLogMacros.h"
struct COGDEBUG_API FCogDebugSettings
{
+4
View File
@@ -26,6 +26,10 @@
"Name": "CogImgui",
"Enabled": true
},
{
"Name": "CogCommon",
"Enabled": true
},
{
"Name": "CogDebug",
"Enabled": true
@@ -22,7 +22,7 @@ public class CogEngine : ModuleRules
new string[]
{
"Core",
"CogInterface",
"CogCommon",
"CogImgui",
"CogDebug",
"CogWindow",
@@ -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<ICogInterfacePossessor>(OwnerPlayerController))
if (ICogCommonPossessorInterface* Possessor = Cast<ICogCommonPossessorInterface>(OwnerPlayerController))
{
Possessor->SetPossession(Pawn);
}
@@ -172,7 +172,7 @@ void ACogEngineReplicator::Server_ResetPossession_Implementation()
{
#if !UE_BUILD_SHIPPING
if (ICogInterfacePossessor* Possessor = Cast<ICogInterfacePossessor>(OwnerPlayerController))
if (ICogCommonPossessorInterface* Possessor = Cast<ICogCommonPossessorInterface>(OwnerPlayerController))
{
Possessor->ResetPossession();
}
@@ -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()
};
@@ -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<FCogInterfaceModule>("CogInterface"); }
virtual void StartupModule() override;
virtual void ShutdownModule() override;
private:
};
@@ -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<SCogImguiWidget> 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();
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -19,8 +19,6 @@ class COGWINDOW_API UCogWindowManager : public UObject
public:
UCogWindowManager();
void Initialize(UWorld* World, TSharedPtr<SCogImguiWidget> 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<FMenu> 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<SCogImguiWidget> ImGuiWidget;
TWeakObjectPtr<UWorld> World;
FMenu MainMenu;
int32 LayoutToLoad = -1;
int32 HideAllWindowsCounter = 0;
bool bHideAllWindows = false;
bool bRefreshDPIScale;
};