From 0eaaa562be767e7402563a8825f55687862e6315 Mon Sep 17 00:00:00 2001 From: Kevin Poretti Date: Wed, 30 Mar 2022 22:32:14 -0400 Subject: [PATCH] Setup SwordNGun editor module --- SwordNGun/Source/SwordNGun/SwordNGun.Build.cs | 2 +- SwordNGun/Source/SwordNGunEditor.Target.cs | 2 +- .../SwordNGunEditor/ISNGModuleInterface.cpp | 23 ++++++++++++++++++ .../SwordNGunEditor/ISNGModuleInterface.h | 23 ++++++++++++++++++ .../Private/States/SNGStateMachineFactory.cpp | Bin .../States/SNGStateMachineTypeActions.cpp | Bin .../Public/States/SNGStateMachineFactory.h | Bin .../States/SNGStateMachineTypeActions.h | Bin .../SwordNGunEditor/SwordNGunEditor.Build.cs | 23 ++++++++++++++++++ .../SwordNGunEditor/SwordNGunEditor.cpp | 18 ++++++++++++++ .../Source/SwordNGunEditor/SwordNGunEditor.h | 22 +++++++++++++++++ SwordNGun/SwordNGun.uproject | 8 ++++++ 12 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 SwordNGun/Source/SwordNGunEditor/ISNGModuleInterface.cpp create mode 100644 SwordNGun/Source/SwordNGunEditor/ISNGModuleInterface.h rename SwordNGun/Source/{SwordNGun => SwordNGunEditor}/Private/States/SNGStateMachineFactory.cpp (100%) rename SwordNGun/Source/{SwordNGun => SwordNGunEditor}/Private/States/SNGStateMachineTypeActions.cpp (100%) rename SwordNGun/Source/{SwordNGun => SwordNGunEditor}/Public/States/SNGStateMachineFactory.h (100%) rename SwordNGun/Source/{SwordNGun => SwordNGunEditor}/Public/States/SNGStateMachineTypeActions.h (100%) create mode 100644 SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.Build.cs create mode 100644 SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.cpp create mode 100644 SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.h diff --git a/SwordNGun/Source/SwordNGun/SwordNGun.Build.cs b/SwordNGun/Source/SwordNGun/SwordNGun.Build.cs index 49e6fd9..220eac4 100644 --- a/SwordNGun/Source/SwordNGun/SwordNGun.Build.cs +++ b/SwordNGun/Source/SwordNGun/SwordNGun.Build.cs @@ -8,7 +8,7 @@ public class SwordNGun : ModuleRules { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; - PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "PhysicsCore", "UnrealEd", "AssetTools" }); + PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "PhysicsCore"}); PrivateDependencyModuleNames.AddRange(new string[] { }); diff --git a/SwordNGun/Source/SwordNGunEditor.Target.cs b/SwordNGun/Source/SwordNGunEditor.Target.cs index 64040be..8372108 100644 --- a/SwordNGun/Source/SwordNGunEditor.Target.cs +++ b/SwordNGun/Source/SwordNGunEditor.Target.cs @@ -9,6 +9,6 @@ public class SwordNGunEditorTarget : TargetRules { Type = TargetType.Editor; DefaultBuildSettings = BuildSettingsVersion.V2; - ExtraModuleNames.AddRange( new string[] { "SwordNGun" } ); + ExtraModuleNames.AddRange( new string[] { "SwordNGunEditor" } ); } } diff --git a/SwordNGun/Source/SwordNGunEditor/ISNGModuleInterface.cpp b/SwordNGun/Source/SwordNGunEditor/ISNGModuleInterface.cpp new file mode 100644 index 0000000..cb9f1a5 --- /dev/null +++ b/SwordNGun/Source/SwordNGunEditor/ISNGModuleInterface.cpp @@ -0,0 +1,23 @@ +// Project Sword & Gun Copyright © 2021 Kevin Poretti + +#include "ISNGModuleInterface.h" + +void ISNGModuleInterface::StartupModule() +{ + if(IsRunningCommandlet()) + { + AddModuleListeners(); + for (int32 i = 0; i < ModuleListeners.Num(); i++) + { + ModuleListeners[i]->OnStartupModule(); + } + } +} + +void ISNGModuleInterface::ShutdownModule() +{ + for (int32 i = 0; i < ModuleListeners.Num(); i++) + { + ModuleListeners[i]->OnShutdownModule(); + } +} diff --git a/SwordNGun/Source/SwordNGunEditor/ISNGModuleInterface.h b/SwordNGun/Source/SwordNGunEditor/ISNGModuleInterface.h new file mode 100644 index 0000000..c5a67ee --- /dev/null +++ b/SwordNGun/Source/SwordNGunEditor/ISNGModuleInterface.h @@ -0,0 +1,23 @@ +// Project Sword & Gun Copyright © 2021 Kevin Poretti + +#pragma once + +#include "Modules/ModuleManager.h" + +class ISNGModuleListenerInterface +{ +public: + virtual void OnStartupModule() {}; + virtual void OnShutdownModule() {}; +}; + +class ISNGModuleInterface : public IModuleInterface +{ +public: + virtual void StartupModule() override; + virtual void ShutdownModule() override; + virtual void AddModuleListeners() {}; + +protected: + TArray> ModuleListeners; +}; diff --git a/SwordNGun/Source/SwordNGun/Private/States/SNGStateMachineFactory.cpp b/SwordNGun/Source/SwordNGunEditor/Private/States/SNGStateMachineFactory.cpp similarity index 100% rename from SwordNGun/Source/SwordNGun/Private/States/SNGStateMachineFactory.cpp rename to SwordNGun/Source/SwordNGunEditor/Private/States/SNGStateMachineFactory.cpp diff --git a/SwordNGun/Source/SwordNGun/Private/States/SNGStateMachineTypeActions.cpp b/SwordNGun/Source/SwordNGunEditor/Private/States/SNGStateMachineTypeActions.cpp similarity index 100% rename from SwordNGun/Source/SwordNGun/Private/States/SNGStateMachineTypeActions.cpp rename to SwordNGun/Source/SwordNGunEditor/Private/States/SNGStateMachineTypeActions.cpp diff --git a/SwordNGun/Source/SwordNGun/Public/States/SNGStateMachineFactory.h b/SwordNGun/Source/SwordNGunEditor/Public/States/SNGStateMachineFactory.h similarity index 100% rename from SwordNGun/Source/SwordNGun/Public/States/SNGStateMachineFactory.h rename to SwordNGun/Source/SwordNGunEditor/Public/States/SNGStateMachineFactory.h diff --git a/SwordNGun/Source/SwordNGun/Public/States/SNGStateMachineTypeActions.h b/SwordNGun/Source/SwordNGunEditor/Public/States/SNGStateMachineTypeActions.h similarity index 100% rename from SwordNGun/Source/SwordNGun/Public/States/SNGStateMachineTypeActions.h rename to SwordNGun/Source/SwordNGunEditor/Public/States/SNGStateMachineTypeActions.h diff --git a/SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.Build.cs b/SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.Build.cs new file mode 100644 index 0000000..dca7808 --- /dev/null +++ b/SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.Build.cs @@ -0,0 +1,23 @@ +// Project Sword & Gun Copyright © 2021 Kevin Poretti + +using UnrealBuildTool; + +public class SwordNGunEditor : ModuleRules +{ + public SwordNGunEditor(ReadOnlyTargetRules Target) : base(Target) + { + PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; + + PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "PhysicsCore", "UnrealEd", "AssetTools", "SwordNGun" }); + + PrivateDependencyModuleNames.AddRange(new string[] { }); + + // Uncomment if you are using Slate UI + // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); + + // Uncomment if you are using online features + // PrivateDependencyModuleNames.Add("OnlineSubsystem"); + + // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true + } +} \ No newline at end of file diff --git a/SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.cpp b/SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.cpp new file mode 100644 index 0000000..b2093bc --- /dev/null +++ b/SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.cpp @@ -0,0 +1,18 @@ +#include "SwordNGunEditor.h" + +IMPLEMENT_GAME_MODULE(FSwordNGunEditor, SwordNGunEditor) + +void FSwordNGunEditor::StartupModule() +{ + ISNGModuleInterface::StartupModule(); +} + +void FSwordNGunEditor::ShutdownModule() +{ + ISNGModuleInterface::ShutdownModule(); +} + +void FSwordNGunEditor::AddModuleListeners() +{ + // add tools later +} diff --git a/SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.h b/SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.h new file mode 100644 index 0000000..162d1f1 --- /dev/null +++ b/SwordNGun/Source/SwordNGunEditor/SwordNGunEditor.h @@ -0,0 +1,22 @@ +#pragma once +#include "ISNGModuleInterface.h" + +class FSwordNGunEditor : public ISNGModuleInterface +{ +public: + /** IModuleInterface implementation */ + virtual void StartupModule() override; + virtual void ShutdownModule() override; + + virtual void AddModuleListeners() override; + + static FSwordNGunEditor& Get() + { + return FModuleManager::LoadModuleChecked("SwordNGunEditor"); + } + + static bool IsAvailable() + { + return FModuleManager::Get().IsModuleLoaded("SwordNGunEditor"); + } +}; diff --git a/SwordNGun/SwordNGun.uproject b/SwordNGun/SwordNGun.uproject index d5f4967..5dd3f95 100644 --- a/SwordNGun/SwordNGun.uproject +++ b/SwordNGun/SwordNGun.uproject @@ -13,6 +13,14 @@ "CoreUObject", "UnrealEd" ] + }, + { + "Name": "SwordNGunEditor", + "Type": "Editor", + "LoadingPhase": "PostEngineInit", + "AdditionalDependencies": [ + "Engine" + ] } ], "Plugins": [