mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-29 04:18:49 -04:00
Triforce v0.8.5
A Randomizer page in the launcher, a new title screen with Mods and Save Select tabs, scaling changes applied in game, the Jabu-Jabu bars fixed, renderer frame-time work and the brightness-flash fix, and fixes from the 0.8.4 reports.
This commit is contained in:
@@ -21,6 +21,13 @@ public sealed partial class Backend
|
||||
|
||||
// the working screen
|
||||
CancellationTokenSource? workCts;
|
||||
// ((Triforce, 11-26) 1 from the click that starts a build, a rebuild or an update until it ends: each command runs on a
|
||||
// worker of its own, so a double click (or Enter held on Build the game) started two builds into one folder, and Stop
|
||||
// reached only one. Taken with TakeWork, before anything else is done)
|
||||
int workBusy;
|
||||
bool TakeWork() => Interlocked.CompareExchange(ref workBusy, 1, 0) == 0;
|
||||
void FreeWork() => Interlocked.Exchange(ref workBusy, 0);
|
||||
int playStarting;
|
||||
BuildRunner? runner;
|
||||
string? workKind; // "build" | "update"
|
||||
Func<Task>? retry;
|
||||
@@ -72,12 +79,13 @@ public sealed partial class Backend
|
||||
var d = new Dlss(ctx);
|
||||
if (d.Chosen) { d.TurnOff(); SendReveal(); break; }
|
||||
Ask("NVIDIA DLSS", "<p>" + H(d.LicenseText).Replace("\n\n", "</p><p>").Replace("\n", "<br>") + "</p>", "dlssanswer",
|
||||
new[] { ("no", "Leave it out", false), ("yes", Dlss.AcceptLabel, true) });
|
||||
new[] { ("no", "Leave it out", false), ("yes", Dlss.AcceptLabel, true) }, AskKey(ref dlssKey));
|
||||
break;
|
||||
}
|
||||
});
|
||||
On("lang", m => { if ((string?)m["id"] is { } code) { ctx.Settings.Language = code; SendReveal(); } });
|
||||
On("dlssanswer", m => { if ((string?)m["id"] == "yes") new Dlss(ctx).Accept(); SendReveal(); });
|
||||
// (only a language the game has: the code goes to the registry or builder.ini, which other programs read)
|
||||
On("lang", m => { if (Languages.Find((string?)m["id"]) is { } l) { ctx.Settings.Language = l.Code; SendReveal(); } });
|
||||
On("dlssanswer", m => { if ((string?)m["id"] == "yes" && Answered(ref dlssKey, m)) new Dlss(ctx).Accept(); SendReveal(); });
|
||||
On("screen", _ => { });
|
||||
On("open", m => OpenThing((string?)m["arg"] ?? ""));
|
||||
On("report", _ => Copy(Report.ForBuild(ctx, lastResult, runner?.Details ?? "", new Tools(ctx).InstalledVersion, lastFailure)));
|
||||
@@ -94,6 +102,7 @@ public sealed partial class Backend
|
||||
On("uninstallanswer", m =>
|
||||
{
|
||||
if ((string?)m["id"] != "yes") { host.Close(); return; }
|
||||
if (!Answered(ref uninstallKey, m)) return;
|
||||
new Uninstaller(ctx).Run();
|
||||
host.Close();
|
||||
});
|
||||
@@ -123,7 +132,7 @@ public sealed partial class Backend
|
||||
{
|
||||
var plan = new Uninstaller(ctx).Describe();
|
||||
Ask("Uninstall Triforce?", "<p><b>Removes</b> " + H(string.Join(", ", plan.Removes)) + "</p><p><b>Keeps</b> " + H(string.Join(", ", plan.Keeps)) + "</p>",
|
||||
"uninstallanswer", new[] { ("no", "Keep it", false), ("yes", "Uninstall", true) });
|
||||
"uninstallanswer", new[] { ("no", "Keep it", false), ("yes", "Uninstall", true) }, AskKey(ref uninstallKey));
|
||||
return;
|
||||
}
|
||||
var game = GameDir;
|
||||
@@ -173,6 +182,12 @@ public sealed partial class Backend
|
||||
Ask(workKind == "update" ? "Close Triforce and stop the update?" : "Close Triforce and stop the build?",
|
||||
"<p>What is done so far is kept: next time it carries on from where it stopped.</p>", "closeanswer",
|
||||
new[] { ("no", "Keep going", true), ("yes", "Stop and close", false) });
|
||||
// ((Triforce, 11-25) a randomizer seed being made, or OOTRR being downloaded: asked too. A seed stopped part way is
|
||||
// never one the game reads: it is built under a hidden name and named only when whole)
|
||||
else if (randoCts != null || randoToolBusy)
|
||||
Ask(randoCts != null ? "Close Triforce and stop the seed?" : "Close Triforce and stop the randomizer's download?",
|
||||
randoCts != null ? "<p>The seed being made is not kept. Make it again any time.</p>" : "<p>It goes on from where it stopped next time.</p>", "closeanswer",
|
||||
new[] { ("no", "Keep going", true), ("yes", "Stop and close", false) });
|
||||
else host.Close();
|
||||
}
|
||||
|
||||
@@ -180,6 +195,7 @@ public sealed partial class Backend
|
||||
{
|
||||
try { workCts?.Cancel(); } catch { }
|
||||
try { runner?.Stop(); } catch { }
|
||||
try { randoCts?.Cancel(); } catch { } // (a seed being made: OOTRR is ended, its half-made folder taken away)
|
||||
}
|
||||
|
||||
// ---------------- first run: the game handed over ----------------
|
||||
@@ -252,6 +268,13 @@ public sealed partial class Backend
|
||||
async Task BuildFirst()
|
||||
{
|
||||
if (source == null) { Go("welcome"); return; }
|
||||
if (!TakeWork()) { Go("work"); return; }
|
||||
try { await BuildFirstOne(); }
|
||||
finally { FreeWork(); }
|
||||
}
|
||||
|
||||
async Task BuildFirstOne()
|
||||
{
|
||||
var space = new GameIntake(ctx).Space(outFolder!);
|
||||
if (space.TooLittle) { Toast("Not enough room on " + H(space.Disk) + ": the build needs " + (space.NeedWhileBuilding >> 30) + " GB free.", "error"); return; }
|
||||
retry = BuildFirst;
|
||||
@@ -281,20 +304,24 @@ public sealed partial class Backend
|
||||
{
|
||||
var g = GameDir;
|
||||
if (g == null) { Go("welcome"); return; }
|
||||
if (workCts != null) { Go("work"); return; }
|
||||
if (!TakeWork()) { Go("work"); return; }
|
||||
_ = Guarded("rebuild", async () =>
|
||||
{
|
||||
retry = () => { StartRebuild(); return Task.CompletedTask; };
|
||||
workKind = "update";
|
||||
using var cts = workCts = new CancellationTokenSource();
|
||||
try
|
||||
{
|
||||
await EnsureTools(cts.Token);
|
||||
await RunBuild(BuildRequest.Update(g), cts.Token);
|
||||
retry = () => { StartRebuild(); return Task.CompletedTask; };
|
||||
workKind = "update";
|
||||
using var cts = workCts = new CancellationTokenSource();
|
||||
try
|
||||
{
|
||||
await EnsureTools(cts.Token);
|
||||
await RunBuild(BuildRequest.Update(g), cts.Token);
|
||||
}
|
||||
catch (OperationCanceledException) { WorkStopped(); }
|
||||
catch (Exception e) { WorkFailed("The build stopped", Failure.Of(e, false).Note, e); }
|
||||
finally { workCts = null; }
|
||||
}
|
||||
catch (OperationCanceledException) { WorkStopped(); }
|
||||
catch (Exception e) { WorkFailed("The build stopped", Failure.Of(e, false).Note, e); }
|
||||
finally { workCts = null; }
|
||||
finally { FreeWork(); }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -486,7 +513,13 @@ public sealed partial class Backend
|
||||
// ---------------- update ----------------
|
||||
async Task UpdateNow(string? folder)
|
||||
{
|
||||
if (workCts != null) { Go("work"); return; }
|
||||
if (!TakeWork()) { Go("work"); return; }
|
||||
try { await UpdateNowOne(folder); }
|
||||
finally { FreeWork(); }
|
||||
}
|
||||
|
||||
async Task UpdateNowOne(string? folder)
|
||||
{
|
||||
if (release == null) await CheckRelease();
|
||||
if (release == null) { Toast("Could not reach the update server. You can still play.", "error"); return; }
|
||||
var rel = release;
|
||||
@@ -570,6 +603,9 @@ public sealed partial class Backend
|
||||
: new JsonObject { ["text"] = release != null ? "Up to date · " + built?.TrimStart('v') : built?.TrimStart('v') ?? "", ["dot"] = "" };
|
||||
}
|
||||
if (running) { home["button"] = "Running"; home["off"] = true; pill = new JsonObject { ["text"] = "Playing", ["dot"] = "blue" }; }
|
||||
// ((Triforce, 11-25) a randomizer seed that is on, said where Play is, whatever else the screen says: a save of the
|
||||
// plain game does not match it)
|
||||
if (g != null && RandoSeedOn(g) is { } seed) links.Add(new JsonObject { ["html"] = "<b>◆ Randomizer seed " + H(seed) + "</b> is on", ["act"] = "go:rando" });
|
||||
home["links"] = links;
|
||||
if (release?.NewIn is { Count: > 0 } ni)
|
||||
{
|
||||
@@ -601,9 +637,18 @@ public sealed partial class Backend
|
||||
|
||||
// ---------------- Play ----------------
|
||||
void Play()
|
||||
{
|
||||
// ((Triforce, 11-26) one start at a time: two clicks on Play started two games before the first was seen running)
|
||||
if (Interlocked.CompareExchange(ref playStarting, 1, 0) != 0) return;
|
||||
try { PlayOne(); }
|
||||
finally { Interlocked.Exchange(ref playStarting, 0); }
|
||||
}
|
||||
|
||||
void PlayOne()
|
||||
{
|
||||
var g = GameDir;
|
||||
if (g == null) { Go("welcome"); return; }
|
||||
if (Volatile.Read(ref workBusy) != 0) { Go("work"); return; } // (a build or an update is writing the game folder)
|
||||
var game = new Game(ctx);
|
||||
if (game.IsRunning(g)) { Go("playing"); ShowGame(); return; }
|
||||
gameProc = game.Play(g);
|
||||
@@ -643,6 +688,19 @@ public sealed partial class Backend
|
||||
[System.Runtime.InteropServices.DllImport("user32")] static extern bool SetForegroundWindow(IntPtr h);
|
||||
[System.Runtime.InteropServices.DllImport("user32")] static extern bool ShowWindow(IntPtr h, int c);
|
||||
|
||||
// ---------------- answers ----------------
|
||||
// ((Triforce, 11-26) the questions whose yes cannot be undone (uninstall, the NVIDIA licence) carry a key of their own, made
|
||||
// when they are asked and good once: a 'yes' the page sends without the question shown (a script that got into the page)
|
||||
// does nothing. As saves.confirm does)
|
||||
string? uninstallKey, dlssKey;
|
||||
static string AskKey(ref string? slot) => slot = Convert.ToHexString(System.Security.Cryptography.RandomNumberGenerator.GetBytes(16));
|
||||
static bool Answered(ref string? slot, JsonNode m)
|
||||
{
|
||||
var want = Interlocked.Exchange(ref slot, null);
|
||||
var got = m["ctx"] is JsonValue v && v.TryGetValue<string>(out var s) ? s : null;
|
||||
return want != null && got == want;
|
||||
}
|
||||
|
||||
// ---------------- links ----------------
|
||||
void OpenThing(string what)
|
||||
{
|
||||
@@ -652,7 +710,8 @@ public sealed partial class Backend
|
||||
"changes" => release?.PageUrl ?? BuildInfo.Home,
|
||||
_ => what.StartsWith("https://", StringComparison.Ordinal) ? what : null,
|
||||
};
|
||||
if (url != null) { try { Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); } catch { } return; }
|
||||
// (through OpenLink: https only, whatever the release feed or the page says; a test run opens nothing)
|
||||
if (url != null) { OpenLink(url); return; }
|
||||
var folder = what switch
|
||||
{
|
||||
"game" => GameDir,
|
||||
|
||||
Reference in New Issue
Block a user