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++;
		}
	}
}
Example #2
0
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
TSharedRef<SWidget> STaskListRow::GenerateWidgetForColumn(const FName& ColumnName)
{
	if (ColumnName == "Duration")
	{
		return SNew(SBox)
			.Padding(FMargin(4.0, 0.0))
			.VAlign(VAlign_Center)
			[
				SNew(STextBlock)
				.Text(this, &STaskListRow::HandleDurationText)
			];
	}
	else if (ColumnName == "Icon")
	{
		return SNew(SOverlay)

			+ SOverlay::Slot()
			.HAlign(HAlign_Center)
			.VAlign(VAlign_Center)
			[
				SNew(SThrobber)
				.Animate(SThrobber::VerticalAndOpacity)
			.NumPieces(1)
			.Visibility(this, &STaskListRow::HandleThrobberVisibility)
			]

		+ SOverlay::Slot()
			.HAlign(HAlign_Center)
			.VAlign(VAlign_Center)
			[
				SNew(SImage)
				.ColorAndOpacity(this, &STaskListRow::HandleIconColorAndOpacity)
			.Image(this, &STaskListRow::HandleIconImage)
			];
	}
	else if (ColumnName == "Status")
	{
		return SNew(SBox)
			.Padding(FMargin(4.0, 0.0))
			.VAlign(VAlign_Center)
			[
				SNew(STextBlock)
				.Text(this, &STaskListRow::HandleStatusText)
			];
	}
	else if (ColumnName == "Task")
	{
		ILauncherTaskPtr TaskPtr = Task.Pin();

		if (TaskPtr.IsValid())
		{
			return SNew(SBox)
				.Padding(FMargin(4.0, 0.0))
				.VAlign(VAlign_Center)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TaskPtr->GetDesc()))
				];
		}
	}

	return SNullWidget::NullWidget;
}