You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Note that for Windows to work, the AutomationTool.exe needs to be marked as a Desktop app, so when running on Linux, this command is needed one time: sed -i 's/WindowsDesktop/NETCore/' AutomationTool.runtimeconfig.json - Removed some platform-specific checks for the platform building it, and #if WINDOWS type checks (not all gone, but getting better) #rb jonathan.adamczewski #preflight 6195a7de841fa7e69d5964d4 [FYI] graeme.thornton #ROBOMERGE-AUTHOR: josh.adams #ROBOMERGE-SOURCE: CL 18237766 via CL 18242422 via CL 18242492 via CL 18242564 via CL 18244551 via CL 18244617 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469) [CL 18244669 by josh adams in ue5-release-engine-test branch]
138 lines
3.1 KiB
C#
138 lines
3.1 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Text.RegularExpressions;
|
|
using System.Drawing;
|
|
using EpicGames.Core;
|
|
|
|
namespace Turnkey
|
|
{
|
|
class HybridIOProvider : ConsoleIOProvider
|
|
{
|
|
static HybridIOProvider()
|
|
{
|
|
}
|
|
|
|
private string ShowMacDialog(string Prompt, string Default)
|
|
{
|
|
string Params = string.Format("-e 'display dialog \"{0}\" with title \"Turnkey Input\" default answer \"{1}\"'", Prompt.Replace("\n", "\\n").Replace("\t", "\\t"), Default);
|
|
string OSAOutput = UnrealBuildTool.Utils.RunLocalProcessAndReturnStdOut("osascript", Params);
|
|
|
|
// blank string means user canceled, which goes to stderr
|
|
if (OSAOutput == "")
|
|
{
|
|
return null;
|
|
}
|
|
|
|
// regex the result
|
|
Match Match = Regex.Match(OSAOutput, "text returned:(.*)$");
|
|
if (!Match.Success)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
// return the text in the dialog box
|
|
return Match.Groups[1].Value;
|
|
}
|
|
|
|
private string ShowDialog(string Prompt, string Default, bool bIsList)
|
|
{
|
|
string Result = "";
|
|
|
|
if (RuntimePlatform.IsWindows)
|
|
{
|
|
System.Threading.Thread t = new System.Threading.Thread(x =>
|
|
{
|
|
Result = UnrealWindowsForms.TurnkeyDialog.ShowDialogAndReturnResult(Prompt, Default);
|
|
});
|
|
|
|
t.SetApartmentState(System.Threading.ApartmentState.STA);
|
|
t.Start();
|
|
t.Join();
|
|
}
|
|
else if (RuntimePlatform.IsMac)
|
|
{
|
|
Result = ShowMacDialog(Prompt, Default);
|
|
}
|
|
else
|
|
{
|
|
throw new NotImplementedException("Linux dialog not implemented");
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(Result) && bIsList)
|
|
{
|
|
return "0";
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
public override void PauseForUser(string Message, bool bAppendNewLine)
|
|
{
|
|
ShowDialog(Message, "", false);
|
|
}
|
|
|
|
public override string ReadInput(string Prompt, string Default, bool bAppendNewLine)
|
|
{
|
|
return ShowDialog(Prompt, Default, false);
|
|
}
|
|
|
|
public override int ReadInputInt(string Prompt, List<string> Options, bool bIsCancellable, int DefaultValue, bool bAppendNewLine)
|
|
{
|
|
StringBuilder FullPromptBuilder = new StringBuilder();
|
|
|
|
// start with given prompt
|
|
FullPromptBuilder.Append(Prompt);
|
|
if (bAppendNewLine)
|
|
{
|
|
FullPromptBuilder.AppendLine("");
|
|
}
|
|
|
|
// now add the options given
|
|
int Index = 1;
|
|
foreach (string Option in Options)
|
|
{
|
|
if (Option.StartsWith(";"))
|
|
{
|
|
FullPromptBuilder.AppendLine(" {0}", Option.Substring(1));
|
|
}
|
|
else
|
|
{
|
|
FullPromptBuilder.AppendLine(" ({0}) {1}", Index++, Option);
|
|
}
|
|
}
|
|
|
|
string FullPrompt = FullPromptBuilder.ToString();
|
|
|
|
// go until good choice
|
|
while (true)
|
|
{
|
|
string ChoiceString = ShowDialog(FullPrompt, DefaultValue >= 0 ? DefaultValue.ToString() : null, true);
|
|
|
|
if (ChoiceString == null)
|
|
{
|
|
return bIsCancellable ? 0 : -1;
|
|
}
|
|
|
|
int Choice;
|
|
if (Int32.TryParse(ChoiceString, out Choice) == false || Choice < 0 || Choice >= Options.Count + (bIsCancellable ? 1 : 0))
|
|
{
|
|
if (Choice < 0 && bIsCancellable)
|
|
{
|
|
return 0;
|
|
}
|
|
TurnkeyUtils.Log("Invalid choice");
|
|
}
|
|
else
|
|
{
|
|
return Choice;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|