예제 #1
0
void FLauncherProfileManager::LoadProfiles( )
{
	TArray<FString> ProfileFileNames;

	IFileManager::Get().FindFiles(ProfileFileNames, *(GetProfileFolder() / TEXT("*.ulp")), true, false);
	
	for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It)
	{
		FString ProfileFilePath = GetProfileFolder() / *It;
		FArchive* ProfileFileReader = IFileManager::Get().CreateFileReader(*ProfileFilePath);

		if (ProfileFileReader != nullptr)
		{
			ILauncherProfilePtr LoadedProfile = LoadProfile(*ProfileFileReader);
			delete ProfileFileReader;

			if (LoadedProfile.IsValid())
			{
				AddProfile(LoadedProfile.ToSharedRef());
			}
			else
			{
				IFileManager::Get().Delete(*ProfileFilePath);
			}
		}
	}
}
void FLaunchFromProfileCommand::Run(const FString& Params)
{
	// Get the name of the profile from the command line.
	FString ProfileName;
	FParse::Value(FCommandLine::Get(), TEXT("-PROFILENAME="), ProfileName);
	if (ProfileName.IsEmpty())
	{
		UE_LOG(LogUFECommands, Warning, TEXT("Profile name was found.  Please use '-PROFILENAME=' in your command line."));
		return;
	}
	
	// Loading the launcher services module to get the needed profile.
	ILauncherServicesModule& LauncherServicesModule = FModuleManager::LoadModuleChecked<ILauncherServicesModule>(TEXT("LauncherServices"));
	ILauncherProfileManagerRef ProfileManager = LauncherServicesModule.GetProfileManager();
	ILauncherProfilePtr Profile = ProfileManager->FindProfile(ProfileName);

	// Loading the Device Proxy Manager to get the needed Device Manager.
	ITargetDeviceServicesModule& DeviceServiceModule = FModuleManager::LoadModuleChecked<ITargetDeviceServicesModule>(TEXT("TargetDeviceServices"));
	ITargetDeviceProxyManagerRef DeviceProxyManager = DeviceServiceModule.GetDeviceProxyManager();

	UE_LOG(LogUFECommands, Display, TEXT("Begin the process of launching a project using the provided profile."));
	ILauncherRef LauncherRef = LauncherServicesModule.CreateLauncher();
	ILauncherWorkerPtr LauncherWorkerPtr = LauncherRef->Launch(DeviceProxyManager, Profile.ToSharedRef());

	// This will allow us to pipe the launcher messages into the command window.
	LauncherWorkerPtr.Get()->OnOutputReceived().AddStatic(&FLaunchFromProfileCommand::MessageReceived);
	// Allows us to exit this command once the launcher worker has completed or is canceled 
	LauncherWorkerPtr.Get()->OnCompleted().AddRaw(this, &FLaunchFromProfileCommand::LaunchCompleted);
	LauncherWorkerPtr.Get()->OnCanceled().AddRaw(this, &FLaunchFromProfileCommand::LaunchCanceled);

	TArray<ILauncherTaskPtr> TaskList;
	int32 NumOfTasks = LauncherWorkerPtr->GetTasks(TaskList);	
	UE_LOG(LogUFECommands, Display, TEXT("There are '%i' tasks to be completed."), NumOfTasks);

	// Holds the current element in the TaskList array.
	int32 TaskIndex = 0;
	// Holds the name of the current tasked.
	FString TriggeredTask;

	bTestRunning = true;
	while (bTestRunning)
	{
		if (TaskIndex >= NumOfTasks) continue;
		ILauncherTaskPtr CurrentTask = TaskList[TaskIndex];

		// Log the current task, but only once per run.
		if (CurrentTask->GetStatus() == ELauncherTaskStatus::Busy)
		{
			if (CurrentTask->GetDesc() == TriggeredTask) continue;

			TriggeredTask = *CurrentTask->GetDesc();
			UE_LOG(LogUFECommands, Display, TEXT("Current Task is %s"), *TriggeredTask);
			TaskIndex++;
		}
	}
}
예제 #3
0
void FLauncherProfileManager::AddProfile( const ILauncherProfileRef& Profile )
{
	if (!SavedProfiles.Contains(Profile))
	{
		// replace the existing profile
		ILauncherProfilePtr ExistingProfile = GetProfile(Profile->GetId());

		if (ExistingProfile.IsValid())
		{
			RemoveProfile(ExistingProfile.ToSharedRef());
		}

		if (!Profile->GetDeployedDeviceGroup().IsValid())
		{
			Profile->SetDeployedDeviceGroup(AddNewDeviceGroup());
		}

		// add the new profile
		SavedProfiles.Add(Profile);
		AllProfiles.Add(Profile);

		ProfileAddedDelegate.Broadcast(Profile);
	}
}
void FLauncherProfileManager::LoadProfiles( )
{
	TArray<FString> ProfileFileNames;

	//load and move legacy profiles
	{
		IFileManager::Get().FindFilesRecursive(ProfileFileNames, *GetLegacyProfileFolder(), TEXT("*.ulp"), true, false);
		for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It)
		{
			FString ProfileFilePath = *It;
			FArchive* ProfileFileReader = IFileManager::Get().CreateFileReader(*ProfileFilePath);

			if (ProfileFileReader != nullptr)
			{
				ILauncherProfilePtr LoadedProfile = LoadProfile(*ProfileFileReader);
				delete ProfileFileReader;

				//re-save profile to new location
				if (LoadedProfile.IsValid())
				{
					SaveProfile(LoadedProfile.ToSharedRef());
				}

				//delete legacy profile.
				IFileManager::Get().Delete(*ProfileFilePath);				
			}
		}
	}

	//load and re-save legacy profiles
	{
		IFileManager::Get().FindFilesRecursive(ProfileFileNames, *FLauncherProfile::GetProfileFolder(), TEXT("*.ulp"), true, false);
		for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It)
		{
			FString ProfileFilePath = *It;
			FArchive* ProfileFileReader = IFileManager::Get().CreateFileReader(*ProfileFilePath);

			if (ProfileFileReader != nullptr)
			{
				ILauncherProfilePtr LoadedProfile = LoadProfile(*ProfileFileReader);
				delete ProfileFileReader;

				//re-save profile to the new format
				if (LoadedProfile.IsValid())
				{
					if (ProfileFilePath.Contains("NotForLicensees"))
					{
						LoadedProfile->SetNotForLicensees();
					}
					SaveJSONProfile(LoadedProfile.ToSharedRef());
				}

				//delete legacy profile.
				IFileManager::Get().Delete(*ProfileFilePath);
			}
		}
	}

	ProfileFileNames.Reset();
	IFileManager::Get().FindFilesRecursive(ProfileFileNames, *FLauncherProfile::GetProfileFolder(), TEXT("*.ulp2"), true, false);
	
	for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It)
	{
		FString ProfileFilePath = *It;
		ILauncherProfilePtr LoadedProfile = LoadJSONProfile(*ProfileFilePath);

		if (LoadedProfile.IsValid())
		{
			if (ProfileFilePath.Contains("NotForLicensees"))
			{
				LoadedProfile->SetNotForLicensees();
			}
			AddProfile(LoadedProfile.ToSharedRef());
		}
		else
		{
			IFileManager::Get().Delete(*ProfileFilePath);
		}
	}
}