Files
ruckus7382sfgsgdf 6f338c8f56 Triforce v0.5.0
In-game mods (GameBanana browser, search and installs, with the Mask Salesman), code-patch and cheat mods, the devs' test18 to test45 work (full performance overlay, frame pacing on, steady frame rate, save export and import, bug capture, new options rows, Setup's Mods page and Add to Steam), occlusion queries and new defaults, Auto resolution that scales, replay helper threads and robust buffers off by default, the options in sections.
2026-11-17 22:40:50 -06:00

64 lines
2.4 KiB
C#

using System.IO;
using System.Text;
using System.Windows;
namespace HookshotBuilder;
public partial class App : Application
{
// (RecompLauncher) --cli <make_game.py's options>: no window; its lines on stdout, and its result as the exit code.
// Why it stopped is one "error <text>" line on stdout (the stream a launcher reads) and again on stderr
protected override void OnStartup(StartupEventArgs e)
{
var cli = e.Args.Length > 0 && e.Args[0] == "--cli";
// ((Triforce) one builder at a time for its tools, Instance.cs: asked before any build or window)
if (Tools.Find() is { } tools && !Instance.Take(tools.Root))
{
if (cli)
{
var said = "error " + Instance.Refusal(tools.Root).Replace("\n\n", " ");
Console.Out.WriteLine(said);
Console.Error.WriteLine(said);
}
else MessageBox.Show(Instance.Refusal(tools.Root), "Hookshot Builder", MessageBoxButton.OK, MessageBoxImage.Information);
Environment.Exit(1);
return;
}
if (cli)
{
Environment.Exit(Cli(e.Args.Skip(1).ToList()));
return;
}
base.OnStartup(e);
}
static int Cli(List<string> args)
{
using var stdout = new StreamWriter(Console.OpenStandardOutput(), new UTF8Encoding(false)) { AutoFlush = true };
var tools = Tools.Find();
if (tools == null)
{
const string missing = "error The build tools were not found next to this program.";
stdout.WriteLine(missing);
Console.Error.WriteLine(missing);
return 1;
}
var done = new ManualResetEventSlim();
string? failure = null, said = null; // (said: make_game's own "error" line in --prepare mode, already passed on to stdout)
var runner = new Runner(tools, args);
runner.Line += line =>
{
if (line.StartsWith("error ")) said = line[6..];
lock (stdout) stdout.WriteLine(line);
};
runner.Finished += result => { failure = result; done.Set(); };
runner.Start();
done.Wait();
if (failure == null) return 0;
var reason = failure == "cancelled" ? failure : said ?? failure;
if (said == null) lock (stdout) stdout.WriteLine("error " + reason);
Console.Error.WriteLine("error " + reason);
return 1;
}
}