mirror of
https://github.com/Ed94/Cog.git
synced 2026-06-13 00:01:37 -07:00
Mutiple fixes
Fix shipping build by reworking Cog integration (now use a subsystem) Fix crash when stopping and restarting in the editor
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include "CogSampleConfigurationSubsystem.h"
|
||||
|
||||
#include "CogCommon.h"
|
||||
|
||||
#if ENABLE_COG
|
||||
#include "CogAll.h"
|
||||
#include "CogSampleWindow_Team.h"
|
||||
#include "CogSubsystem.h"
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
bool UCogSampleConfigurationSubsystem::ShouldCreateSubsystem(UObject* Outer) const
|
||||
{
|
||||
if (Super::ShouldCreateSubsystem(Outer) == false)
|
||||
{ return false; }
|
||||
|
||||
#if ENABLE_COG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSampleConfigurationSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
Super::Initialize(Collection);
|
||||
#if ENABLE_COG
|
||||
CogSubsystem = Collection.InitializeDependency<UCogSubsystem>();
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
void UCogSampleConfigurationSubsystem::PostInitialize()
|
||||
{
|
||||
Super::PostInitialize();
|
||||
|
||||
#if ENABLE_COG
|
||||
UCogSubsystem* CogSubsystemPtr = Cast<UCogSubsystem>(CogSubsystem.Get());
|
||||
if (IsValid(CogSubsystemPtr) == false)
|
||||
{ return; }
|
||||
|
||||
// Add all the built-in windows. You can copy and paste this function code to organize the main menu differently.
|
||||
Cog::AddAllWindows(*CogSubsystemPtr);
|
||||
|
||||
// Add a custom window
|
||||
CogSubsystemPtr->AddWindow<FCogSampleWindow_Team>("Gameplay.Team");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "Subsystems/WorldSubsystem.h"
|
||||
#include "CogSampleConfigurationSubsystem.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class UCogSampleConfigurationSubsystem : public UWorldSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
virtual void PostInitialize() override;
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TWeakObjectPtr<USubsystem> CogSubsystem;
|
||||
};
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "CogSampleGameInstance.h"
|
||||
|
||||
#include "CogCommon.h"
|
||||
|
||||
#if ENABLE_COG
|
||||
#include "CogAll.h"
|
||||
#include "CogSampleWindow_Team.h"
|
||||
#include "CogSubsystem.h"
|
||||
#endif
|
||||
|
||||
|
||||
void UCogSampleGameInstance::Init()
|
||||
{
|
||||
Super::Init();
|
||||
|
||||
#if ENABLE_COG
|
||||
|
||||
// Get the cog subsystem
|
||||
if (UCogSubsystem* CogSubSystem = GetSubsystem<UCogSubsystem>())
|
||||
{
|
||||
// Add all the built-in windows. You copy paste this function code to organize the menu differently.
|
||||
Cog::AddAllWindows(*CogSubSystem);
|
||||
|
||||
// Add a custom window
|
||||
CogSubSystem->AddWindow<FCogSampleWindow_Team>("Gameplay.Team");
|
||||
|
||||
// Activate Cog
|
||||
CogSubSystem->Activate();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CogSampleGameInstance.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class UCogSampleGameInstance : public UGameInstance
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
void Init() override;
|
||||
};
|
||||
@@ -9,7 +9,6 @@
|
||||
#if ENABLE_COG
|
||||
#include "CogAll.h"
|
||||
#include "CogSampleWindow_Team.h"
|
||||
#include "CogSubsystem.h"
|
||||
#endif //ENABLE_COG
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user