Files
UnrealEngineUWP/Engine/Source/Developer/LauncherServices/Private/LauncherServicesModule.cpp
ben marsh b4369ae399 Unified the code used by the editor and project launcher, to fix incorrect editor executable being used for cooking when using the project launcher.
#rb none
#jira UE-76216

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: ben.marsh
#ROBOMERGE-SOURCE: CL 6989146 in //UE4/Release-4.23/... via CL 6989149
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR) (v367-6836689)

[CL 7022668 by ben marsh in Dev-VR branch]
2019-06-15 04:34:55 -04:00

116 lines
3.4 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "CoreMinimal.h"
#include "Misc/Guid.h"
#include "Modules/ModuleManager.h"
#include "ILauncherServicesModule.h"
#include "Profiles/LauncherDeviceGroup.h"
#include "Profiles/LauncherProfile.h"
#include "Profiles/LauncherProfileManager.h"
#include "Launcher/Launcher.h"
/**
* Implements the LauncherServices module.
*/
class FLauncherServicesModule
: public ILauncherServicesModule
{
public:
//~ ILauncherServicesModule interface
virtual ILauncherDeviceGroupRef CreateDeviceGroup() override
{
return MakeShareable(new FLauncherDeviceGroup());
}
virtual ILauncherDeviceGroupRef CreateDeviceGroup(const FGuid& Guid, const FString& Name) override
{
return MakeShareable(new FLauncherDeviceGroup(Guid, Name));
}
virtual ILauncherRef CreateLauncher() override
{
return MakeShareable(new FLauncher());
}
virtual ILauncherProfileRef CreateProfile(const FString& ProfileName) override
{
ILauncherProfileManagerRef ProfileManager = GetProfileManager();
return MakeShareable(new FLauncherProfile(ProfileManager, FGuid(), ProfileName));
}
virtual ILauncherProfileManagerRef GetProfileManager() override
{
if (!ProfileManagerSingleton.IsValid())
{
TSharedPtr<FLauncherProfileManager> ProfileManager = MakeShareable(new FLauncherProfileManager());
ProfileManager->Load();
ProfileManagerSingleton = ProfileManager;
ProfileManagerInitializedDelegate.Broadcast(*ProfileManager);
}
return ProfileManagerSingleton.ToSharedRef();
}
DECLARE_DERIVED_EVENT(FLauncherServicesModule, ILauncherServicesModule::FLauncherServicesSDKNotInstalled, FLauncherServicesSDKNotInstalled);
virtual FLauncherServicesSDKNotInstalled& OnLauncherServicesSDKNotInstalled() override
{
return LauncherServicesSDKNotInstalled;
}
void BroadcastLauncherServicesSDKNotInstalled(const FString& PlatformName, const FString& DocLink) override
{
return LauncherServicesSDKNotInstalled.Broadcast(PlatformName, DocLink);
}
virtual FString GetExecutableForCommandlets() const
{
FString ExecutableName;
#if WITH_EDITOR
ExecutableName = FString(FPlatformProcess::ExecutablePath());
#if PLATFORM_WINDOWS
// turn UE4editor into UE4editor-cmd
if (ExecutableName.EndsWith(".exe", ESearchCase::IgnoreCase) && !FPaths::GetBaseFilename(ExecutableName).EndsWith("-cmd", ESearchCase::IgnoreCase))
{
FString NewExeName = ExecutableName.Left(ExecutableName.Len() - 4) + "-Cmd.exe";
if (FPaths::FileExists(NewExeName))
{
ExecutableName = NewExeName;
}
}
#elif PLATFORM_MAC
// turn UE4editor into UE4editor-cmd
if (!FPaths::GetBaseFilename(ExecutableName).EndsWith("-cmd", ESearchCase::IgnoreCase))
{
FString NewExeName = ExecutableName + "-Cmd";
if (FPaths::FileExists(NewExeName))
{
ExecutableName = NewExeName;
}
}
#endif
#endif
return ExecutableName;
}
private:
/** Event to be called when the editor tried to use a platform, but it wasn't installed. */
FLauncherServicesSDKNotInstalled LauncherServicesSDKNotInstalled;
/** The launcher profile manager singleton. */
static ILauncherProfileManagerPtr ProfileManagerSingleton;
};
/* Static initialization
*****************************************************************************/
FOnLauncherProfileManagerInitialized ILauncherServicesModule::ProfileManagerInitializedDelegate;
ILauncherProfileManagerPtr FLauncherServicesModule::ProfileManagerSingleton = NULL;
IMPLEMENT_MODULE(FLauncherServicesModule, LauncherServices);