Files
UnrealEngineUWP/Engine/Source/Developer/Mac/MacTargetPlatform/Private/MacTargetPlatformModule.cpp
ryan durand 471d972e62 Updating copyright for Engine Developer.
#rnx
#rb none


#ROBOMERGE-SOURCE: CL 10869240 via CL 10869516 via CL 10869902
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870584 by ryan durand in Main branch]
2019-12-26 15:32:37 -05:00

139 lines
3.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "CoreMinimal.h"
#include "GenericMacTargetPlatform.h"
#include "Modules/ModuleManager.h"
#include "ISettingsModule.h"
#include "Interfaces/ITargetPlatformModule.h"
#include "Modules/ModuleManager.h"
#include "MacTargetSettings.h"
#include "UObject/Package.h"
#include "UObject/WeakObjectPtr.h"
#define LOCTEXT_NAMESPACE "FMacTargetPlatformModule"
/**
* Holds the target platform singleton.
*/
static ITargetPlatform* Singleton = NULL;
/**
* Module for Mac as a target platform
*/
class FMacTargetPlatformModule
: public ITargetPlatformModule
{
public:
/**
* Destructor.
*/
~FMacTargetPlatformModule()
{
Singleton = NULL;
}
public:
// Begin ITargetPlatformModule interface
virtual ITargetPlatform* GetTargetPlatform() override
{
if (Singleton == NULL && TGenericMacTargetPlatform<true, false, false>::IsUsable())
{
Singleton = new TGenericMacTargetPlatform<true, false, false>();
}
return Singleton;
}
// End ITargetPlatformModule interface
public:
// Begin IModuleInterface interface
virtual void StartupModule() override
{
TargetSettings = NewObject<UMacTargetSettings>(GetTransientPackage(), "MacTargetSettings", RF_Standalone);
// We need to manually load the config properties here, as this module is loaded before the UObject system is setup to do this
GConfig->GetArray(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("TargetedRHIs"), TargetSettings->TargetedRHIs, GEngineIni);
int32 Value = 1;
GConfig->GetInt(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("MaxShaderLanguageVersion"), Value, GEngineIni);
TargetSettings->MaxShaderLanguageVersion = FMath::Max(Value, 3);
if (!GConfig->GetBool(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("UseFastIntrinsics"), TargetSettings->UseFastIntrinsics, GEngineIni))
{
TargetSettings->UseFastIntrinsics = false;
}
if (!GConfig->GetBool(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("EnableMathOptimisations"), TargetSettings->EnableMathOptimisations, GEngineIni))
{
TargetSettings->EnableMathOptimisations = true;
}
if (!GConfig->GetBool(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("ForceFloats"), TargetSettings->ForceFloats, GEngineIni))
{
TargetSettings->ForceFloats = false;
}
if (!GConfig->GetInt(TEXT("/Script/MacTargetPlatform.MacTargetSettings"), TEXT("IndirectArgumentTier"), TargetSettings->IndirectArgumentTier, GEngineIni))
{
TargetSettings->IndirectArgumentTier = 0;
}
TargetSettings->AddToRoot();
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule != nullptr)
{
SettingsModule->RegisterSettings("Project", "Platforms", "Mac",
LOCTEXT("TargetSettingsName", "Mac"),
LOCTEXT("TargetSettingsDescription", "Settings and resources for Mac platform"),
TargetSettings
);
}
}
virtual void ShutdownModule() override
{
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
if (SettingsModule != nullptr)
{
SettingsModule->UnregisterSettings("Project", "Platforms", "Mac");
}
if (!GExitPurge)
{
// If we're in exit purge, this object has already been destroyed
TargetSettings->RemoveFromRoot();
}
else
{
TargetSettings = NULL;
}
}
// End IModuleInterface interface
private:
// Holds the target settings.
UMacTargetSettings* TargetSettings;
};
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE( FMacTargetPlatformModule, MacTargetPlatform);