Files
UnrealEngineUWP/Engine/Extras/P4VUtils/Commands/CopyCLCommand.cs
Josh Adams a6c5a6ccd9 - Updated p4vutils to dotnet6, so we can use OperatingSystem nicely
- Will compile on Mac and Linux now
- Mac replaced the WinForms functionality with AppleScript
- Linux will compile be have reduced functionality
- Fixed up paths for p4v settings and dotnet location
- Added binaries and installer scripts for all 3 platforms - won't need UGS to install, will copy to user-library location (may need some adustment on Linux, will address after)
#rb will.damon
#preflight skip

[CL 20244727 by Josh Adams in ue5-main branch]
2022-05-17 12:00:08 -04:00

65 lines
1.6 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using EpicGames.Core;
using EpicGames.Perforce;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace P4VUtils.Commands
{
class CopyCLCommand : Command
{
public override string Description => "copy CL # only from pending and submitted CLs";
public override CustomToolInfo CustomTool => new CustomToolInfo("Copy CL #", "%c")
{
RefreshUI = false,
Shortcut = new string("Ctrl+Alt+C")
};
public override async Task<int> Execute(string[] Args, IReadOnlyDictionary<string, string> ConfigValues, ILogger Logger)
{
int Change;
if (Args.Length < 2)
{
Logger.LogError("Missing changelist number");
return 1;
}
else if (!int.TryParse(Args[1], out Change))
{
Logger.LogError("'{Argument}' is not a numbered changelist", Args[1]);
return 1;
}
#if IS_WINDOWS
// Jump through some hoops to make async & windows com happy and force STA on the clipboard call
var tcs = new TaskCompletionSource<int>();
var SetClipThread = new Thread(() =>
{
System.Windows.Forms.Clipboard.SetText(Change.ToString());
tcs.SetResult(0);
}
);
SetClipThread.SetApartmentState(ApartmentState.STA);
SetClipThread.Start();
SetClipThread.Join();
await tcs.Task;
#elif IS_MAC
System.Diagnostics.Process.Start("/bin/bash", $" -c \"osascript -e 'set the clipboard to \\\"{Change}\\\"'\"");
#endif
return 0;
}
}
}