Triforce v0.3.6

This commit is contained in:
ruckus7382sfgsgdf
2026-11-14 00:33:23 -06:00
parent 2f1e350320
commit a02bcb21a9
106 changed files with 7683 additions and 1422 deletions

View File

@@ -775,12 +775,17 @@
<TextBox x:Name="OutPath" Style="{StaticResource Path}"/>
<Button x:Name="BrowseD" Grid.Column="1" Style="{StaticResource Quiet}" Height="38" Margin="8,0,0,0"/>
</Grid>
<!-- (11-13) NVIDIA DLSS: off unless ticked; ticking asks for NVIDIA's license first (Shell.cs DlssTick) -->
<CheckBox x:Name="DlssTick" Style="{StaticResource Tick}" Margin="0,14,0,0"
Content="NVIDIA DLSS for RTX cards (downloads NVIDIA's DLSS files, about 60 MB)"/>
</StackPanel>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
<Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition Width="Auto"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
<TextBlock x:Name="SpaceText" Style="{StaticResource Small}" VerticalAlignment="Center" Margin="0,0,20,0"/>
<Button x:Name="BuildButton" Grid.Column="1" Style="{StaticResource Primary}" IsEnabled="False"/>
<!-- (11-13: back to the page this one was opened from, when there is a game to go back to) -->
<Button x:Name="SetupBack" Grid.Column="1" Style="{StaticResource Quiet}" Height="44" Margin="0,0,12,0" Visibility="Collapsed"/>
<Button x:Name="BuildButton" Grid.Column="2" Style="{StaticResource Primary}" IsEnabled="False"/>
</Grid>
</Grid>

View File

@@ -1,5 +1,5 @@
// Triforce Setup: the one file players download. It installs itself (per user, no admin), keeps itself and the Triforce tools up to
// date from the GitHub releases of ruckus7382sfgsgdf/CBeta0.2, turns the player's own game files into a game folder (nx2/make_game.py from
// date from the releases at triforceproject.com (triforce/downloads on its Forgejo), turns the player's own game files into a game folder (nx2/make_game.py from
// the tools) and starts the game. The game's own update offer (host/hos_update.c) starts it again with --update <folder>.
//
// Built for .NET Framework 4.8 (part of Windows 10 and 11): nothing to install, one small exe. setup/build.ps1 compiles it.
@@ -33,7 +33,12 @@ namespace TriforceSetup;
static class Program
{
public const string Repo = "ruckus7382sfgsgdf/CBeta0.2";
// (11-13: Triforce's own home. Releases are published in triforce/downloads on its Forgejo; the list is asked on the main
// domain, which passes /api/v1 on, so the address outlives whatever answers behind it. Forgejo's list has GitHub's
// names (tag_name, assets[].name / browser_download_url / size) and takes limit= where GitHub took per_page=.
// Up to v0.3.5 this was api.github.com/repos/ruckus7382sfgsgdf/CBeta0.2: those builds ask there and nowhere else)
public const string Home = "https://triforceproject.com";
public const string ReleaseApi = Home + "/api/v1/repos/triforce/downloads/releases?limit=1";
public const string SetupAsset = "TriforceSetup.exe";
public const string ToolsAsset = "Triforce-Tools.zip";
public const string AppName = "Triforce";
@@ -235,7 +240,7 @@ static class Install
Write(UninstallKey, "InstallLocation", dir);
Write(UninstallKey, "UninstallString", "\"" + exe + "\" --uninstall");
Write(UninstallKey, "QuietUninstallString", "\"" + exe + "\" --uninstall --quiet");
Write(UninstallKey, "URLInfoAbout", "https://github.com/" + Program.Repo);
Write(UninstallKey, "URLInfoAbout", Program.Home);
Write(UninstallKey, "NoModify", 1);
Write(UninstallKey, "NoRepair", 1);
Set("Desktop", desktop ? "1" : "0");
@@ -307,7 +312,7 @@ sealed class Release
public static async Task<Release> Latest(HttpClient http, CancellationToken token)
{
var url = Environment.GetEnvironmentVariable("TRIFORCE_RELEASE_API") is { Length: > 0 } o ? o
: "https://api.github.com/repos/" + Program.Repo + "/releases?per_page=1"; // (the newest, pre-releases too: /latest skips them)
: Program.ReleaseApi; // (the newest, pre-releases too)
using var ask = new CancellationTokenSource(TimeSpan.FromSeconds(20));
using var both = CancellationTokenSource.CreateLinkedTokenSource(token, ask.Token);
using var response = await http.GetAsync(url, both.Token);
@@ -318,7 +323,7 @@ sealed class Release
return r;
}
/// GitHub's answer, read with a real JSON parser: a list of releases (the newest first) or one release. Each asset's
/// The release list's answer (Forgejo's, GitHub's before: the same names), read with a real JSON parser: a list of releases (the newest first) or one release. Each asset's
/// object holds a nested "uploader" object, so nothing simpler than a parser reads it right (v0.1.0 found no assets)
public static Release Parse(string json)
{
@@ -453,7 +458,8 @@ sealed class Runner
public event Action<string>? Line;
public event Action<string?>? Finished;
public Runner(Tools tools, List<string> args) { this.tools = tools; this.args = args; }
readonly string? ngxSdk; // (NVIDIA DLSS chosen, its license accepted: the folder NVIDIA's SDK is fetched into and built from)
public Runner(Tools tools, List<string> args, string? ngxSdk = null) { this.tools = tools; this.args = args; this.ngxSdk = ngxSdk; }
static string Quote(string a)
{
@@ -470,7 +476,7 @@ sealed class Runner
return sb.Append('"').ToString();
}
static ProcessStartInfo Info(Tools tools, IEnumerable<string> args)
static ProcessStartInfo Info(Tools tools, IEnumerable<string> args, string? ngxSdk = null)
{
var all = new List<string> { "-I", Path.Combine(tools.Root, "nx2", "make_game.py") };
all.AddRange(args);
@@ -485,6 +491,7 @@ sealed class Runner
StandardErrorEncoding = Encoding.UTF8,
};
si.EnvironmentVariables["PYTHONIOENCODING"] = "utf-8";
if (ngxSdk != null) si.EnvironmentVariables["HOOKSHOT_NGX_SDK"] = ngxSdk; // (nx2/make_game.py --fetch-ngx-sdk, nx2/build.py)
// (written into the game folder: the game starts Setup again from here to update, host/hos_update.c)
var installed = Install.InstalledDir is { } d ? Path.Combine(d, Program.SetupAsset) : Install.Self;
si.EnvironmentVariables["HOOKSHOT_BUILDER_EXE"] = installed;
@@ -508,7 +515,7 @@ sealed class Runner
var i = args.IndexOf(name);
if (i >= 0 && i + 1 < args.Count && !Install.Allowed(args[i + 1])) { Finished?.Invoke(Install.TestOnly); return; }
}
using var p = Process.Start(Info(tools, args))!;
using var p = Process.Start(Info(tools, args, ngxSdk))!;
process = p;
p.ErrorDataReceived += (_, e) => { if (e.Data != null) Line?.Invoke(e.Data); };
p.BeginErrorReadLine();

View File

@@ -225,7 +225,27 @@ sealed partial class Shell
BrowseB.Click += (_, _) => RomfsPath.Text = FolderPicker.Pick(Window, "Choose the romfs folder", RomfsPath.Text) ?? RomfsPath.Text;
BrowseC.Click += (_, _) => ExefsPath.Text = FolderPicker.Pick(Window, "Choose the exefs folder", ExefsPath.Text) ?? ExefsPath.Text;
BrowseD.Click += (_, _) => OutPath.Text = FolderPicker.Pick(Window, "Choose where to save the game", OutPath.Text) ?? OutPath.Text;
BuildButton.Click += (_, _) => StartBuild();
// (11-13, a player's note: "If you click Build game folder there is no option to go back", and a second build of a game
// already built started at one click: 45 minutes and the same game again. Back goes home; Build asks first then)
BuildButton.Click += (_, _) =>
{
if (HasGame) Ask("You have already built a game folder. Do you want to build it again? It takes about 45 minutes.", "Build again", T(S.Back), StartBuild);
else StartBuild();
};
SetupBack = Part<Button>("SetupBack");
// (11-13) NVIDIA DLSS in the game that is built: NVIDIA's files come under NVIDIA's own license, so the tick stays only
// once that is accepted. Kept (Dlss=1): an update builds with it again
DlssTick = Part<CheckBox>("DlssTick");
DlssTick.IsChecked = DlssChosen;
DlssTick.Click += (_, _) =>
{
if (DlssTick.IsChecked != true) { Install.Set("Dlss", "0"); return; }
DlssTick.IsChecked = false;
Ask("NVIDIA DLSS is NVIDIA's, under NVIDIA's own license (github.com/NVIDIA/DLSS, LICENSE.txt). Its files are downloaded to " +
"this PC; a game folder built with them must not be shared. Do you accept NVIDIA's license?", "I accept", T(S.Back),
() => { DlssTick.IsChecked = true; Install.Set("Dlss", "1"); });
};
SetupBack.Click += (_, _) => ShowHome(homeOffline);
CancelButton.Click += (_, _) => { fetch?.Cancel(); runner?.Cancel(); };
BackButton.Click += (_, _) => ShowSetup();
OpenButton.Click += (_, _) => Process.Start(new ProcessStartInfo("explorer.exe", "\"" + finished + "\"") { UseShellExecute = true });
@@ -529,6 +549,11 @@ sealed partial class Shell
ReadValue(System.IO.Path.Combine(folder, "triforce_version.txt"), "version") ?? ReadValue(System.IO.Path.Combine(folder, "hookshot_version.txt"), "version");
static bool HasGame => Install.Get("GameFolder") is { } g && GameExe(g) != null;
Button SetupBack = null!; // (the build page's way back home)
CheckBox DlssTick = null!; // (NVIDIA DLSS, its license accepted)
static bool DlssChosen => Install.Get("Dlss") == "1";
/// Where NVIDIA's DLSS SDK is kept: beside Setup, not in the tools folder (an update replaces that one whole)
static string NgxSdk => System.IO.Path.Combine(Install.InstalledDir ?? Install.SelfDir, "ngx-sdk");
/// Play: the game starts when there is one (its settings are in its own options menu), else on to building one
void AfterHome()
@@ -544,6 +569,8 @@ sealed partial class Shell
{
if (OutPath.Text.Length == 0)
OutPath.Text = Install.Get("GameFolder") ?? System.IO.Path.Combine(Install.TestRoot ?? Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Games", "Triforce");
SetupBack.Content = T(S.Back);
SetupBack.Visibility = HasGame ? Visibility.Visible : Visibility.Collapsed; // (no game yet: nothing to go back to)
Show(SetupPage);
Banner();
Refresh();
@@ -763,8 +790,11 @@ sealed partial class Shell
SetButtons(cancel: true);
elapsed.Restart();
clock.Start();
// (NVIDIA DLSS chosen: its SDK fetched first, only what is missing, and built in; a build and an update alike)
var dlss = DlssChosen;
if (dlss && !args.Contains("--fetch-ngx-sdk")) args.AddRange(new[] { "--fetch-ngx-sdk", "--accept-nvidia-license" });
Program.Log("build: make_game.py " + string.Join(" ", args) + " (tools " + tools.Root + ")");
runner = new Runner(tools, args);
runner = new Runner(tools, args, dlss ? NgxSdk : null);
ShowClock();
runner.Line += l => Ui(() => Line(l));
runner.Finished += failure => Ui(() => Ended(failure));

View File

@@ -18,13 +18,24 @@ foreach ($need in 'python\python.exe', 'cpm', 'wgpu-native') {
if (-not (Test-Path (Join-Path $Deps 'llvm-mingw\bin\clang.exe')) -and -not $AllowNoCompiler) {
throw "no llvm-mingw in ${Deps}: players' builds would need Visual Studio. (-AllowNoCompiler packs anyway, for tests)"
}
# (v0.3.5 shipped without them: no prompts folder was made on any player's PC and the Button prompts setting did nothing)
$pins = Get-Content (Join-Path $repo 'nx2\prompt_requirements.txt') | ForEach-Object { ($_ -split '#')[0].Trim() } | Where-Object { $_ }
foreach ($pin in $pins) {
$n, $v = $pin -split '=='
$info = Join-Path $Deps ('python\Lib\site-packages\{0}-{1}.dist-info' -f ($n -replace '-', '_'), $v)
if (-not (Test-Path $info)) { throw "the tools' Python in $Deps lacks $pin (nx2\prompt_requirements.txt): players would get no button prompts" }
}
$stage = Join-Path $Out 'stage'
$tools = Join-Path $stage 'tools'
if (Test-Path $stage) { Remove-Item -Recurse -Force $stage }
New-Item -ItemType Directory -Force $tools | Out-Null
# 1. this checkout's sources (tracked files, working-tree versions)
$files = git -C $repo ls-files -- nx2 host gpu scripts third_party LICENSE
# (11-13: and assets/triforce.png. nx2/build.py makes the start-up screen's crest from it (nx2/logo_rgba.py), and a source
# tree without the picture builds a screen with the wordmark alone: every pack up to v0.3.5 left the assets folder out, so
# no player's game showed the crest while its shaders were prepared. Reported for AMD cards, where that screen stays longest)
if (-not (Test-Path (Join-Path $repo 'assets\triforce.png') -PathType Leaf)) { throw 'assets\triforce.png is missing: the tools would build a game without the crest on its start-up screen' }
$files = git -C $repo ls-files -- nx2 host gpu scripts third_party LICENSE assets/triforce.png
foreach ($f in $files) {
$src = Join-Path $repo $f
if (-not (Test-Path $src -PathType Leaf)) { continue }