mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-22 17:19:58 -04:00
Triforce v0.7.0 "Sage Of Courage"
The 0.6 crashes after warps and area changes fixed (no write-back into memory the capture leaves out), invisible objects fixed (occlusion gate), DLSS frame generation flicker fixed, achievements, the renderer built with a play profile, faster translated game code, helper threads judged on settled scenes, memory, shader preparation, audio effects, launcher, controls and Linux fixes.
This commit is contained in:
@@ -176,7 +176,7 @@ public sealed partial class Backend
|
||||
/// <summary>The menu's own words for the values the benchmark touches (Triforce.Logic.GameOptionsSchema).</summary>
|
||||
static string BenchLabel(string key, int v, IReadOnlyList<SettingChange> all, bool after = false)
|
||||
{
|
||||
if (GameOptionsSchema.ByKey(key) is not { } row) return v.ToString();
|
||||
if (GameOptionsSchema.ByKey(key) is not { } row) return GameOptionsSchema.Part(key)?.Label(v) ?? v.ToString(); // ((Triforce, options_version 8) a merged row's part: Steady frame rate, Frame generation)
|
||||
if (key == Benchmark.KResolution)
|
||||
{
|
||||
// (its label follows the Upscaler: "Quality (67%)" with DLSS / FSR, "67%" without)
|
||||
|
||||
@@ -328,15 +328,21 @@ public sealed partial class Backend
|
||||
r.Line += l => { lock (logOut) logOut.AppendLine(l); };
|
||||
var last = DateTime.MinValue;
|
||||
var eb = req.IsUpdate ? (release != null && workKind == "update" ? "Updating to " + release.Tag : "Building your game again") : "Building your game";
|
||||
// (the lines come on two threads, the tick on a third: one at a time)
|
||||
var pushGate = new object();
|
||||
var ticking = true;
|
||||
void Push(bool force = false)
|
||||
{
|
||||
if (!force && (DateTime.UtcNow - last).TotalMilliseconds < 250) return;
|
||||
last = DateTime.UtcNow;
|
||||
var e = r.Estimate ?? est;
|
||||
var left = BuildClock.Remaining(e, r.Tracker);
|
||||
WorkScreen(eb, BuildClock.LeftText(left), 0.08 + 0.92 * Fraction(e, r.Tracker), Steps(null, (e, r.Tracker)),
|
||||
"Keep this window open; you can minimize it. You get a notice when the game is ready.", true,
|
||||
req.IsUpdate ? null : new[] { ("Your game", "done"), ("Build", "now"), ("Play", "") });
|
||||
lock (pushGate)
|
||||
{
|
||||
if (!force && (DateTime.UtcNow - last).TotalMilliseconds < 250) return;
|
||||
last = DateTime.UtcNow;
|
||||
var e = r.Estimate ?? est;
|
||||
var left = BuildClock.Remaining(e, r.Tracker);
|
||||
WorkScreen(eb, BuildClock.LeftText(left), 0.08 + 0.92 * Fraction(e, r.Tracker), Steps(null, (e, r.Tracker)),
|
||||
"Keep this window open; you can minimize it. You get a notice when the game is ready.", true,
|
||||
req.IsUpdate ? null : new[] { ("Your game", "done"), ("Build", "now"), ("Play", "") });
|
||||
}
|
||||
}
|
||||
r.Event += _ => Push();
|
||||
r.StageChanged += (_, _) => Push(true);
|
||||
@@ -344,7 +350,15 @@ public sealed partial class Backend
|
||||
Go("work");
|
||||
using var reg = token.Register(() => r.Stop());
|
||||
lastFailure = null;
|
||||
var res = lastResult = await r.RunAsync(req, token);
|
||||
// (a step can take minutes with no line: the time left counts down, or holds, every second all the same)
|
||||
var tick = new Timer(_ => { lock (pushGate) if (ticking) Push(); }, null, 1000, 1000);
|
||||
BuildResult res;
|
||||
try { res = lastResult = await r.RunAsync(req, token); }
|
||||
finally
|
||||
{
|
||||
lock (pushGate) ticking = false;
|
||||
tick.Dispose();
|
||||
}
|
||||
Push(true);
|
||||
FlushLog();
|
||||
logTimer?.Dispose(); logTimer = null;
|
||||
|
||||
@@ -23,16 +23,21 @@ public sealed partial class Backend
|
||||
if (!CanChangeGame(out var f) || GameOptionsSchema.ByKey(key) is not { } row) return;
|
||||
var now = f!.Get(key);
|
||||
var text = H(row.Help ?? "") + (row.Restart ? "<br><span style=\"color:var(--text3)\">Takes effect the next time the game starts.</span>" : "");
|
||||
if (key == Benchmark.KPreset)
|
||||
text += "<br>" + string.Join("<br>", GameOptionsSchema.PresetSummaries.Select((s, i) => i == 0 ? "" : "<b>" + H(f.ChoicesOf(key).ElementAtOrDefault(i)?.Label) + "</b> " + H(s)).Where(x => x.Length > 0));
|
||||
var choices = f.ChoicesOf(key).AsEnumerable();
|
||||
if (key == Benchmark.KUpscaler)
|
||||
{
|
||||
// (as the game's menu offers them: DLSS and DLAA with an NVIDIA card and DLSS in the build; FSR 4 on AMD cards)
|
||||
// (as the game's menu offers them: DLSS (and DLAA, its Native) with an NVIDIA card and DLSS in the build; FSR 4 on AMD cards)
|
||||
var dlss = Gpus.HasNvidia() && new Game(ctx).HasDlss(GameDir!);
|
||||
var amd = Gpus.List().Any(x => x.Vendor == GpuVendor.Amd);
|
||||
choices = choices.Where(c => c.Value == now || (c.Value is not (1 or 2) || dlss) && (c.Value is not (4 or 5) || amd));
|
||||
}
|
||||
if (key == GameOptionsSchema.FrameGenKey)
|
||||
{
|
||||
// ((Triforce, options_version 8) NVIDIA DLSS 2x to 4x, merged into the row, where DLSS frame generation can run:
|
||||
// an NVIDIA card and DLSS in the build, as the game's menu offers them (vk_menu.cpp dlssg_offered))
|
||||
var dlssg = Gpus.HasNvidia() && new Game(ctx).HasDlss(GameDir!);
|
||||
choices = choices.Where(c => c.Value == now || c.Value < 10 || dlssg);
|
||||
}
|
||||
Choice(row.Name, text, "gopt.set", choices.Select(c => (c.Value.ToString(), c.Label, (string?)null, c.Value == now)), "Choose", key);
|
||||
});
|
||||
On("gopt.set", m =>
|
||||
@@ -74,7 +79,7 @@ public sealed partial class Backend
|
||||
{
|
||||
var g = GameDir;
|
||||
if (g == null) return null;
|
||||
if (!gpusHooked) { GameOptionsSchema.UseGameGpus(() => GameDir); gpusHooked = true; } // ((Triforce) 11-19: the game's own order)
|
||||
if (!gpusHooked) { GameOptionsSchema.UseGameGpus(() => GameDir); GameOptionsSchema.UseSystemLatency(); gpusHooked = true; } // ((Triforce) 11-19: the game's own order; options_version 8: Low latency by the card's maker)
|
||||
GameOptionsFile f;
|
||||
try { f = GameOptionsFile.Load(g, MainScreen()); }
|
||||
catch (Exception e) { Log.Write("game options: " + e.Message); return null; }
|
||||
|
||||
@@ -305,11 +305,11 @@ public sealed class WinHost : IHost
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)] static extern ushort RegisterClassEx(ref WNDCLASSEX c);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)] static extern IntPtr CreateWindowEx(uint ex, string cls, string name, uint style, int x, int y, int w, int h, IntPtr parent, IntPtr menu, IntPtr inst, IntPtr p);
|
||||
[DllImport("user32")] static extern IntPtr DefWindowProc(IntPtr h, uint m, IntPtr w, IntPtr l);
|
||||
[DllImport("user32")] static extern int GetMessage(out MSG m, IntPtr h, uint a, uint b);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)] static extern IntPtr DefWindowProc(IntPtr h, uint m, IntPtr w, IntPtr l);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)] static extern int GetMessage(out MSG m, IntPtr h, uint a, uint b);
|
||||
[DllImport("user32")] static extern bool TranslateMessage(ref MSG m);
|
||||
[DllImport("user32")] static extern IntPtr DispatchMessage(ref MSG m);
|
||||
[DllImport("user32")] static extern bool PostMessage(IntPtr h, uint m, IntPtr w, IntPtr l);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)] static extern IntPtr DispatchMessage(ref MSG m);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)] static extern bool PostMessage(IntPtr h, uint m, IntPtr w, IntPtr l);
|
||||
[DllImport("user32")] static extern void PostQuitMessage(int c);
|
||||
[DllImport("user32")] static extern bool ShowWindow(IntPtr h, int c);
|
||||
[DllImport("user32")] static extern bool UpdateWindow(IntPtr h);
|
||||
@@ -318,8 +318,8 @@ public sealed class WinHost : IHost
|
||||
[DllImport("user32")] static extern bool SetForegroundWindow(IntPtr h);
|
||||
[DllImport("user32")] static extern bool GetClientRect(IntPtr h, out RECT r);
|
||||
[DllImport("user32")] static extern bool SetWindowPos(IntPtr h, IntPtr after, int x, int y, int w, int hh, uint f);
|
||||
[DllImport("user32")] static extern IntPtr LoadCursor(IntPtr i, int id);
|
||||
[DllImport("user32")] static extern IntPtr LoadIcon(IntPtr i, IntPtr id);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)] static extern IntPtr LoadCursor(IntPtr i, int id);
|
||||
[DllImport("user32", CharSet = CharSet.Unicode)] static extern IntPtr LoadIcon(IntPtr i, IntPtr id);
|
||||
[DllImport("user32")] static extern uint GetDpiForSystem();
|
||||
[DllImport("user32")] static extern bool SetProcessDpiAwarenessContext(IntPtr v);
|
||||
[DllImport("user32")] static extern bool SystemParametersInfo(uint a, uint b, ref RECT r, uint c);
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<Version>1.0.0</Version>
|
||||
<!-- ((Triforce) 11-20) the name Windows shows for the exe (pinned taskbar button, Task Manager), not its file name -->
|
||||
<AssemblyTitle>Triforce</AssemblyTitle>
|
||||
<Product>Triforce</Product>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net10.0-windows'">
|
||||
|
||||
@@ -71,9 +71,11 @@ public sealed class Benchmark : IBenchmarkRunner
|
||||
|
||||
// the options file's keys (gpu/vk/vk_menu.cpp ini_key; values gpu/vk/vk_menu.h, upscaler_rows.h, fps_cap.h)
|
||||
public const string KCap = "frame_rate_cap", KVsync = "vsync", KSteady = "steady_frame_rate", KUpscaler = "dlss",
|
||||
KResolution = "resolution", KPreset = "quality_preset", KFrameGen = "frame_generation";
|
||||
KResolution = "resolution", KFrameGen = "frame_generation";
|
||||
// frame_rate_cap: 0 60, 1 90, 2 120, 3 144, 4 165, 5 240, 6 the monitor's. dlss (the Upscaler row): 0 the game's, 1 DLSS,
|
||||
// 3 FSR 3.1, 4 FSR 4. resolution: 3 = 67 % (Quality), 5 = 58 % (Balanced), 4 = 50 % (Performance). quality_preset 0 Custom.
|
||||
// 3 FSR 3.1, 4 FSR 4. resolution: 3 = 67 % (Quality), 5 = 58 % (Balanced), 4 = 50 % (Performance). ((Triforce, options_version 8)
|
||||
// steady_frame_rate and frame_generation are the saved values of the merged Frame pacing and Frame generation rows; the
|
||||
// Quality preset is gone: the game drops its line)
|
||||
static readonly (int value, int fps)[] Caps = { (0, 60), (2, 120), (3, 144), (5, 240) };
|
||||
public const int UpGame = 0, UpDlss = 1, UpFsr3 = 3, ResQuality = 3, ResBalanced = 5, CapUncapped = 5;
|
||||
public const int SteadyRefreshSteps = 2; // (fps_cap.h: 0 Off, 1 Any rate, 2 Refresh steps)
|
||||
@@ -172,7 +174,7 @@ public sealed class Benchmark : IBenchmarkRunner
|
||||
try
|
||||
{
|
||||
var keys = new Dictionary<string, int> { [KCap] = CapUncapped, [KVsync] = 0, [KSteady] = 0, [KFrameGen] = 0 };
|
||||
if (upscaler is { } u) { keys[KUpscaler] = u.upscaler; keys[KResolution] = ResQuality; keys[KPreset] = 0; }
|
||||
if (upscaler is { } u) { keys[KUpscaler] = u.upscaler; keys[KResolution] = ResQuality; }
|
||||
BenchIni.Set(ini, keys);
|
||||
var si = new ProcessStartInfo(exe) { UseShellExecute = false, WorkingDirectory = game, RedirectStandardError = true, RedirectStandardOutput = true };
|
||||
foreach (var a in new[] { Path.Combine(game, "image.bin"), "--romfs", Path.Combine(game, "romfs"), "--user", userCopy }) si.ArgumentList.Add(a);
|
||||
@@ -297,8 +299,6 @@ public sealed class Benchmark : IBenchmarkRunner
|
||||
recs.Add(new SettingChange(KSteady, "Steady frame rate", Now(KSteady, 0), uneven ? SteadyRefreshSteps : Now(KSteady, 0)));
|
||||
// frame generation: never turned on by this (DESIGN 12: only below 60 with DLSS-G / FSR 4 FG, not measured yet)
|
||||
recs.Add(new SettingChange(KFrameGen, "Frame generation", Now(KFrameGen, 0), Now(KFrameGen, 0)));
|
||||
if (recs.Any(r => r.Changes && (r.Key == KUpscaler || r.Key == KResolution)))
|
||||
recs.Add(new SettingChange(KPreset, "Quality preset", Now(KPreset, 0), 0));
|
||||
return recs;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ public static class BuildProtocol
|
||||
}
|
||||
|
||||
/// <summary>The build's state as its lines come (old Shell.cs Line/Ended; the Tk builder's parser): the stage it is in, that
|
||||
/// stage's progress, when each stage began, the plan, the time left the compile said, the folder @@done named, the last
|
||||
/// stage's progress (and how it moved), when each stage began, the plan, the time left the compile said, the folder @@done named, the last
|
||||
/// @@error. Fed line by line by BuildRunner, or by a test from a transcript.</summary>
|
||||
public sealed class BuildTracker
|
||||
{
|
||||
@@ -149,10 +149,20 @@ public sealed class BuildTracker
|
||||
Stage = s.Id;
|
||||
StageStarted = t;
|
||||
StageProgress = 0;
|
||||
lock (Gate) { recent.Clear(); recent.Add((t, 0)); }
|
||||
if (s.Id != "compile") EtaSeconds = null;
|
||||
StageChanged?.Invoke(was, s.Id);
|
||||
break;
|
||||
case BuildEvent.Progress p: StageProgress = p.Fraction; break;
|
||||
case BuildEvent.Progress p:
|
||||
StageProgress = p.Fraction;
|
||||
lock (Gate)
|
||||
{
|
||||
if (recent.Count == 0) recent.Add((StageStarted, 0));
|
||||
if (p.Fraction < recent[^1].Progress) { recent.Clear(); recent.Add((now(), p.Fraction)); } // (it went back: start over)
|
||||
else if (p.Fraction > recent[^1].Progress) recent.Add((now(), p.Fraction));
|
||||
if (recent.Count > KeepSamples) recent.RemoveRange(0, recent.Count - KeepSamples / 2);
|
||||
}
|
||||
break;
|
||||
case BuildEvent.Plan p: Plan = (p.Changed, p.Total); break;
|
||||
case BuildEvent.FileBuilt f when f.How is "new" or "again": FilesBuilt++; break;
|
||||
case BuildEvent.Eta x: EtaSeconds = x.Seconds; break;
|
||||
@@ -177,4 +187,15 @@ public sealed class BuildTracker
|
||||
|
||||
public TimeSpan Elapsed => now() - Started;
|
||||
public TimeSpan InStage => Stage == null ? TimeSpan.Zero : now() - StageStarted;
|
||||
public DateTime Now => now();
|
||||
|
||||
/// <summary>This stage's progress as it moved: (when, how far), from (the stage's start, 0), a sample each time it went up (the
|
||||
/// last 2000), for BuildClock's rate over the last minutes.</summary>
|
||||
public IReadOnlyList<(DateTime At, double Progress)> Recent { get { lock (Gate) return recent.ToArray(); } }
|
||||
|
||||
const int KeepSamples = 2000;
|
||||
readonly List<(DateTime At, double Progress)> recent = new();
|
||||
/// <summary>The time left last shown and when (BuildClock.Remaining's smoothing), under Gate: the App asks from more than one thread.</summary>
|
||||
internal (double Seconds, DateTime At)? Shown;
|
||||
internal readonly object Gate = new();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// nx2/make_game.py as a child process (old Setup.cs Runner, Shell.cs Run/Line/Ended; hookshot_builder.py start_make/on_exit):
|
||||
// <python> -I <tools>\nx2\make_game.py <args> cwd <tools>, stdout+stderr UTF-8, below-normal priority (Windows)
|
||||
// <python> -I <tools>\nx2\make_game.py <args> cwd <tools>, stdout+stderr UTF-8, normal priority (below normal on
|
||||
// Windows only with HOOKSHOT_LOW_PRIORITY=1)
|
||||
// env: PYTHONIOENCODING=utf-8, HOOKSHOT_BUILDER_EXE (written into the game folder's builder= line), HOOKSHOT_NGX_SDK when
|
||||
// DLSS is on, EMSDK / RX_CPM / WGPU_NATIVE / HOOKSHOT_MINGW for tool folders that exist (Windows); Linux: DLSS on drops
|
||||
// HOOKSHOT_VK_PREBUILT (the Vulkan back end is compiled with NGX), DLSS off drops HOOKSHOT_NGX_SDK
|
||||
@@ -195,7 +196,12 @@ public sealed class BuildRunner
|
||||
var si = StartInfo(ctx, tools, args, ctx.NgxSdkFolder, dlss);
|
||||
using var p = ctx.Platform.StartTree(si);
|
||||
process = p;
|
||||
try { if (ctx.IsWindows) p.PriorityClass = ProcessPriorityClass.BelowNormal; } catch (Exception) { }
|
||||
// (Triforce, 11-22, the performance audit's OS-57, after Source A's) The build tools run at normal priority;
|
||||
// below normal, as every build was before, only with HOOKSHOT_LOW_PRIORITY=1. Source A's reason, a report it
|
||||
// did not measure: below normal, Windows kept the steps that are one process (the read, the lift) on a hybrid
|
||||
// Intel CPU's efficiency cores while the performance cores idled.
|
||||
if (Environment.GetEnvironmentVariable("HOOKSHOT_LOW_PRIORITY") == "1")
|
||||
try { if (ctx.IsWindows) p.PriorityClass = ProcessPriorityClass.BelowNormal; } catch (Exception) { }
|
||||
try { p.StandardInput.Close(); } catch (Exception) { }
|
||||
p.ErrorDataReceived += (_, e) => { if (e.Data != null) Take(e.Data); };
|
||||
p.BeginErrorReadLine();
|
||||
|
||||
@@ -115,6 +115,10 @@ public static class BuildEstimator
|
||||
{
|
||||
GpuVendor.Nvidia => (TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(20)),
|
||||
GpuVendor.Amd => (TimeSpan.FromMinutes(30), TimeSpan.FromMinutes(120)),
|
||||
// ((Triforce, 11-22) Intel's Arc cards: an A750's preparation took 4.3 h on v0.6.0 (#bug-tracker "Intel Arc A750 current
|
||||
// state", 12 threads), an A770's 11 h; with the compute warm cut to the listed programs (RX_VK_WARM_COMPUTES) a
|
||||
// re-preparation is over an hour shorter. The 10 to 40 minutes before had the time left show minutes for hours)
|
||||
GpuVendor.Intel => (TimeSpan.FromMinutes(60), TimeSpan.FromMinutes(240)),
|
||||
_ => (TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(40)),
|
||||
};
|
||||
|
||||
@@ -136,6 +140,13 @@ public static class BuildEstimator
|
||||
{
|
||||
if (!shaders) continue;
|
||||
if (stages != null && stages.Seconds.TryGetValue("shaders", out var ss) && ss > 0) { list.Add(Exact(st.Id, ss)); continue; }
|
||||
// ((Triforce, 11-22) an update with no update of its own on record: the shader step this PC measured in its
|
||||
// last build of any kind, before the stated range (an update after a full build prepares the same shaders)
|
||||
if (history.Stages.LastOrDefault(r => r.Seconds.TryGetValue("shaders", out var any) && any > 0) is { } anyRec)
|
||||
{
|
||||
list.Add(Exact(st.Id, anyRec.Seconds["shaders"]));
|
||||
continue;
|
||||
}
|
||||
var (sl, sh) = ShaderRange(gpu);
|
||||
list.Add(new StageEstimate(st.Id, sl, sh, false));
|
||||
continue;
|
||||
@@ -171,9 +182,34 @@ public static class BuildClock
|
||||
return Unit(low) == Unit(high) ? M(low) + " to " + M(high) + " " + Unit(high) : M(low) + " " + Unit(low) + " to " + M(high) + " " + Unit(high);
|
||||
}
|
||||
|
||||
/// <summary>The time left: the stages after this one by the estimate, and this one by @@eta (compile), else by its progress so
|
||||
/// far (from 5 %), else its estimate less what it has run. Never below zero; "Almost done" is the App's words under a minute.</summary>
|
||||
/// <summary>The time left as shown: Estimated, smoothed. Each call counts the shown time down by the time since the last one and
|
||||
/// moves it toward the new estimate: down within seconds (FallSeconds), up slowly (RiseSeconds) and never faster than half a
|
||||
/// second a second, so one odd moment never makes it jump. The first call of a build shows the estimate itself. Never below
|
||||
/// zero; "Almost done" is the App's words under a minute.</summary>
|
||||
public static TimeSpan Remaining(BuildEstimate estimate, BuildTracker tracker)
|
||||
{
|
||||
var raw = Estimated(estimate, tracker).TotalSeconds;
|
||||
lock (tracker.Gate)
|
||||
{
|
||||
var now = tracker.Now;
|
||||
var shown = raw;
|
||||
if (tracker.Shown is { } was)
|
||||
{
|
||||
var dt = Math.Max(0, (now - was.At).TotalSeconds);
|
||||
var counted = Math.Max(0, was.Seconds - dt);
|
||||
shown = raw < counted ? counted + (raw - counted) * (1 - Math.Exp(-dt / FallSeconds))
|
||||
: Math.Min(counted + (raw - counted) * (1 - Math.Exp(-dt / RiseSeconds)), was.Seconds + MaxRise * dt);
|
||||
}
|
||||
tracker.Shown = (shown, now);
|
||||
return TimeSpan.FromSeconds(Math.Max(0, shown));
|
||||
}
|
||||
}
|
||||
|
||||
const double FallSeconds = 15, RiseSeconds = 30, MaxRise = 0.5;
|
||||
|
||||
/// <summary>The time left now, unsmoothed: the stages after this one by the estimate, and this one by @@eta (compile), else by
|
||||
/// StageLeft. Never below zero.</summary>
|
||||
public static TimeSpan Estimated(BuildEstimate estimate, BuildTracker tracker)
|
||||
{
|
||||
var at = tracker.Stage is { } s ? BuildStages.IndexOf(s) : -1;
|
||||
var left = TimeSpan.Zero;
|
||||
@@ -181,15 +217,63 @@ public static class BuildClock
|
||||
if (BuildStages.IndexOf(st.Stage) > at) left += st.Mid;
|
||||
if (at >= 0 && estimate.Of(tracker.Stage!) is { } cur)
|
||||
{
|
||||
TimeSpan here;
|
||||
if (tracker.Stage == "compile" && tracker.EtaSeconds is { } eta) here = TimeSpan.FromSeconds(eta);
|
||||
else if (tracker.StageProgress >= 0.05) here = tracker.InStage * ((1 - tracker.StageProgress) / tracker.StageProgress);
|
||||
else here = cur.Mid - tracker.InStage;
|
||||
var here = tracker.Stage == "compile" && tracker.EtaSeconds is { } eta ? TimeSpan.FromSeconds(eta)
|
||||
: StageLeft(cur.Mid, tracker.Recent, tracker.StageStarted, tracker.Now);
|
||||
left += here < TimeSpan.Zero ? TimeSpan.Zero : here;
|
||||
}
|
||||
return left;
|
||||
}
|
||||
|
||||
/// <summary>A stage's time left by its progress. The work per step is uneven (the shader step: on AMD and Intel cards the first
|
||||
/// part, the compute pipelines, can be most of its time, an Arc A750 spent 5175 s of 5858 s on them; one slow shader holds it
|
||||
/// for minutes), so the rate since the stage began says hours where there is an hour. Instead:
|
||||
/// the rate of the last WindowSeconds of progress, each wait between two steps counted as at most 4 times the usual one (and
|
||||
/// at least half a minute), so one slow item is one step late, not a new pace;
|
||||
/// blended with the estimate's own pace (what it leaves of the stage, at least a tenth of it, and past it a quarter of the
|
||||
/// time over too), trusting the measured rate more as the stage goes (all of it from TrustFrom of the way);
|
||||
/// reckoned at the last step: between steps it counts down for one usual wait, then holds, and after a long stall (2
|
||||
/// minutes, or 4 waits) rises by a quarter of the time.
|
||||
/// No progress yet: the estimate less the time run (the same floor).</summary>
|
||||
public static TimeSpan StageLeft(TimeSpan expected, IReadOnlyList<(DateTime At, double Progress)> samples, DateTime began, DateTime now)
|
||||
{
|
||||
var e = expected.TotalSeconds;
|
||||
static double Prior(double e, double run) => Math.Max(e - run, 0.1 * e + 0.25 * Math.Max(0, run - e));
|
||||
if (samples.Count < 2 || samples[^1].Progress <= 0) return TimeSpan.FromSeconds(Prior(e, Math.Max(0, (now - began).TotalSeconds)));
|
||||
var (last, p) = samples[^1];
|
||||
if (p >= 1) return TimeSpan.Zero;
|
||||
var run = Math.Max(0, (last - began).TotalSeconds);
|
||||
var rateHere = (1 - p) / Math.Max(1, Prior(e, run));
|
||||
var recent = RecentRate(samples);
|
||||
var w = recent == null ? 0 : Math.Clamp(p / TrustFrom, 0, 1);
|
||||
var rate = w * (recent?.Rate ?? 0) + (1 - w) * rateHere;
|
||||
var atStep = (1 - p) / rate;
|
||||
var wait = recent?.Wait ?? 0;
|
||||
var stall = Math.Max(0, (now - last).TotalSeconds);
|
||||
var left = atStep - Math.Min(stall, wait) + 0.25 * Math.Max(0, stall - Math.Max(120, 4 * wait));
|
||||
return TimeSpan.FromSeconds(Math.Max(0, left));
|
||||
}
|
||||
|
||||
const double WindowSeconds = 180, TrustFrom = 0.3;
|
||||
|
||||
/// <summary>Progress a second over the last WindowSeconds (each wait capped), and the usual wait between steps (the median of
|
||||
/// the last 64); null with no step yet.</summary>
|
||||
static (double Rate, double Wait)? RecentRate(IReadOnlyList<(DateTime At, double Progress)> s)
|
||||
{
|
||||
if (s.Count < 2) return null;
|
||||
var waits = new List<double>();
|
||||
for (var i = s.Count - 1; i >= 1 && waits.Count < 64; i--) waits.Add((s[i].At - s[i - 1].At).TotalSeconds);
|
||||
waits.Sort();
|
||||
var usual = waits[waits.Count / 2];
|
||||
var cap = Math.Max(30, 4 * usual);
|
||||
double span = 0, moved = 0;
|
||||
for (var i = s.Count - 1; i >= 1 && span < WindowSeconds; i--)
|
||||
{
|
||||
span += Math.Min(cap, (s[i].At - s[i - 1].At).TotalSeconds);
|
||||
moved += s[i].Progress - s[i - 1].Progress;
|
||||
}
|
||||
return span <= 0 || moved <= 0 ? null : (moved / span, usual);
|
||||
}
|
||||
|
||||
/// <summary>"About 31 minutes left"; "Almost done" under a minute (DESIGN 6 Build).</summary>
|
||||
public static string LeftText(TimeSpan left) =>
|
||||
left.TotalSeconds < 60 ? "Almost done" : left.TotalMinutes < 90 ? "About " + (int)Math.Round(left.TotalMinutes) + " minutes left" : "About " + (int)left.TotalHours + " h " + left.Minutes + " min left";
|
||||
|
||||
@@ -148,6 +148,9 @@ public sealed class Game
|
||||
if (DropPrefixes.Any(p => key.StartsWith(p, StringComparison.Ordinal)) || DropNames.Contains(key)) si.Environment.Remove(key);
|
||||
si.RedirectStandardOutput = si.RedirectStandardError = true;
|
||||
si.RedirectStandardInput = true;
|
||||
// ((Triforce, 11-21) the game's log into triforce_log.txt all the same: with stderr a pipe the game kept it there,
|
||||
// and the pipe's lines are dropped below, so a session started with Play wrote no log (host/hos_main.c HOS_LOG_FILE)
|
||||
si.Environment["HOS_LOG_FILE"] = "1";
|
||||
}
|
||||
si.Environment["HOOKSHOT_NO_UPDATE_CHECK"] = "1";
|
||||
var p = ctx.IsWindows ? Process.Start(si) : ctx.Platform.StartTree(si);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// The game's in-game Options (gpu/vk/vk_menu.cpp, the Row table) as plain data for the launcher: one GameOptionRow per row the
|
||||
// game keeps in triforce_options.ini, with its tab, section, name, key, range, default, help and the labels its value shows.
|
||||
// GameOptionsSchema.All lists them; GameOptionsFile reads and writes the file the way the game does.
|
||||
// game shows with a value, with its tab, section, name, key, range, default, help and the labels its value shows.
|
||||
// GameOptionsSchema.All lists them; GameOptionsFile reads and writes the file the way the game does. ((Triforce, options_version
|
||||
// 8) A merged row (HDR, Frame generation, Frame pacing, Low latency: gpu/vk/merged_rows.h) has no line of its own: it is a view
|
||||
// of two saved values, its Parts, each kept under its own key as before.)
|
||||
namespace Triforce.Logic;
|
||||
|
||||
/// <summary>The Options screen's tabs, as the game's header shows them. (The game's Debug tab is not ported: its rows'
|
||||
@@ -15,8 +17,8 @@ public enum GameOptionKind { Choice, Slider }
|
||||
public sealed record GameOptionChoice(int Value, string Label);
|
||||
|
||||
/// <summary>The values of the other rows, for the labels that depend on them (the Render resolution's sizes follow the
|
||||
/// Upscaler, the Output resolution and the Handheld profile; the Anti-aliasing row shows the upscaler's own while one
|
||||
/// draws; the Microphone shows the saved device's name). GameOptionsFile is one.</summary>
|
||||
/// Upscaler and the Output resolution; the Anti-aliasing row shows the upscaler's own while one draws; the Microphone shows
|
||||
/// the saved device's name). GameOptionsFile is one.</summary>
|
||||
public interface IGameOptionValues
|
||||
{
|
||||
/// <summary>A row's value as the game reads it (its default when the file has no line).</summary>
|
||||
@@ -25,37 +27,59 @@ public interface IGameOptionValues
|
||||
string? Raw(string key);
|
||||
}
|
||||
|
||||
/// <summary>A row of the game's Options menu that has a value in triforce_options.ini.</summary>
|
||||
/// <summary>((Triforce, options_version 8) A saved value that a merged row stands for (vk_menu.cpp's TAB_HIDDEN rows): its key
|
||||
/// in triforce_options.ini, its range and default (vk_menu.h Options), and its own value's label (the hidden row's tx_*).</summary>
|
||||
public sealed record GameOptionPart(string Key, int Lo, int Hi, int Default, Func<int, string> Label)
|
||||
{
|
||||
/// <summary>A value as the game reads it from the file: inside Lo..Hi.</summary>
|
||||
public int AsRead(int value) => Math.Clamp(value, Lo, Hi);
|
||||
}
|
||||
|
||||
/// <summary>A merged row's rules (merged_rows.h): its value from its parts' (Of), and its parts' from a new value of it and
|
||||
/// their values now (Split).</summary>
|
||||
public sealed record GameOptionMerge(Func<int[], int> Of, Func<int, int[], int[]> Split);
|
||||
|
||||
/// <summary>A row of the game's Options menu that has a value in triforce_options.ini (its own line, or its Parts' lines).</summary>
|
||||
public sealed record GameOptionRow
|
||||
{
|
||||
/// <summary>The tab it is on. The Motion page's rows and the Controls page's Button prompts are on Controls, in
|
||||
/// the sections "Motion" and "Controls" (the rows that open those pages).</summary>
|
||||
public required GameOptionTab Tab { get; init; }
|
||||
/// <summary>The heading above it on its tab (the menu's section rows), null where the tab has none (Audio).</summary>
|
||||
/// <summary>The heading above it on its tab (the menu's MENU_HEADING rows), null where the tab has none.</summary>
|
||||
public required string? Section { get; init; }
|
||||
/// <summary>The row's name, exactly as the menu shows it.</summary>
|
||||
public required string Name { get; init; }
|
||||
/// <summary>Its key in triforce_options.ini (vk_menu.cpp ini_key).</summary>
|
||||
/// <summary>Its key in triforce_options.ini (vk_menu.cpp ini_key). A merged row has no line: its key here starts with '@'
|
||||
/// and is the launcher's alone (its values are its Parts' keys).</summary>
|
||||
public required string Key { get; init; }
|
||||
public required int Lo { get; init; }
|
||||
public required int Hi { get; init; }
|
||||
public required int Step { get; init; }
|
||||
/// <summary>The game's default (vk_menu.h Options): the value when the file has no line for it.</summary>
|
||||
public required int Default { get; init; }
|
||||
readonly int dflt;
|
||||
/// <summary>The game's default (vk_menu.h Options): the value when the file has no line for it. A merged row's: the view
|
||||
/// of its parts' defaults (Low latency's follows the card's maker).</summary>
|
||||
public int Default { get => Merge != null ? Merge.Of(Parts!.Select(p => p.Default).ToArray()) : dflt; init => dflt = value; }
|
||||
public required GameOptionKind Kind { get; init; }
|
||||
/// <summary>The help under the list while the row is selected, exactly the menu's.</summary>
|
||||
public required string Help { get; init; }
|
||||
/// <summary>Read once at the game's start: a change applies after a restart (the menu tags it "After restart").</summary>
|
||||
public required bool Restart { get; init; }
|
||||
/// <summary>A change here leaves the Quality preset alone; any other row changed by hand turns it back to Custom.</summary>
|
||||
/// <summary>The table's preset_exempt flag. (Triforce, options_version 8) The Quality preset is gone and nothing reads it;
|
||||
/// the rows keep their shape, so the flag is kept as the table has it.</summary>
|
||||
public required bool PresetExempt { get; init; }
|
||||
/// <summary>A merged row's saved values, in merged_rows.h's order (null for a row with a line of its own).</summary>
|
||||
public IReadOnlyList<GameOptionPart>? Parts { get; init; }
|
||||
/// <summary>A merged row's rules (null for a row with a line of its own).</summary>
|
||||
public GameOptionMerge? Merge { get; init; }
|
||||
/// <summary>A merged row: a view of its Parts, no line of its own.</summary>
|
||||
public bool IsMerged => Merge != null;
|
||||
|
||||
internal Func<int, IGameOptionValues?, string> Format { get; init; } = (v, _) => v.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
internal Func<IReadOnlyList<GameOptionChoice>>? ChoiceList { get; init; }
|
||||
|
||||
/// <summary>The values a Choice row offers, in the menu's order, with their labels as the menu shows them where nothing
|
||||
/// is known of this PC (fps cap 6 "Monitor's rate", GPU device from GameOptionsSchema.GpuNames). Empty for a Slider.
|
||||
/// GameOptionsFile.ChoicesOf has the ones that follow the file's other rows (the Render resolution).</summary>
|
||||
/// GameOptionsFile.ChoicesOf has the ones that follow the file's other rows (the Upscaler, the Render resolution).</summary>
|
||||
public IReadOnlyList<GameOptionChoice> Choices => ChoiceList?.Invoke() ?? Array.Empty<GameOptionChoice>();
|
||||
|
||||
/// <summary>The label of a value, as the menu shows it with the other rows at their defaults.</summary>
|
||||
|
||||
@@ -81,14 +81,17 @@ public sealed class GameOptionsFile : IGameOptionValues
|
||||
return (int)Math.Clamp(v, int.MinValue, int.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>Each row's value as the game reads the file at its start (menu_init): the last line's, in the row's range;
|
||||
/// then the rules for a file of an older options_version (the defaults that changed: such a file wrote the old one
|
||||
/// whether chosen or not), the old dynamic_resolution key, the Microphone without a device's name.</summary>
|
||||
/// <summary>Each saved value as the game reads the file at its start (menu_init), by its key (every row's with a line of its
|
||||
/// own, and the merged rows' parts): the last line's, in its range; then the rules for a file of an older options_version
|
||||
/// (the defaults that changed: such a file wrote the old one whether chosen or not; version 8's moves of the rows that
|
||||
/// went), the old dynamic_resolution key, the Microphone without a device's name.</summary>
|
||||
Dictionary<string, int> Effective(Dictionary<string, string> lines, bool exists)
|
||||
{
|
||||
var v = new Dictionary<string, int>(StringComparer.Ordinal);
|
||||
foreach (var r in GameOptionsSchema.All)
|
||||
foreach (var r in GameOptionsSchema.All.Where(r => !r.IsMerged))
|
||||
v[r.Key] = exists && lines.TryGetValue(r.Key, out var s) ? r.AsRead(Atoi(s)) : r.Default;
|
||||
foreach (var p in GameOptionsSchema.Parts.Values)
|
||||
v[p.Key] = exists && lines.TryGetValue(p.Key, out var s) ? p.AsRead(Atoi(s)) : p.Default;
|
||||
if (!exists) return v;
|
||||
foreach (var (key, value) in Migrated(lines)) if (v.ContainsKey(key)) v[key] = value;
|
||||
if (!lines.ContainsKey(GameOptionsSchema.ResolutionKey) && lines.TryGetValue("dynamic_resolution", out var dyn))
|
||||
@@ -108,6 +111,20 @@ public sealed class GameOptionsFile : IGameOptionValues
|
||||
{
|
||||
if (!lines.TryGetValue(key, out var s) || Atoi(s) != value) list.Add((key, value));
|
||||
}
|
||||
// ((Triforce, options_version 8) merged_rows.h migrate: the handheld profile is the Output resolution's 1536x864, the
|
||||
// shared stick dead zone each stick's own where it had none of its own. The other rows that went move nothing; their
|
||||
// lines stay until the game's next save drops them. A 436f9ac-based build's 7 has none of these lines: nothing moves)
|
||||
if (version < 8)
|
||||
{
|
||||
if (lines.TryGetValue("handheld_profile", out var hh) && Atoi(hh) != 0) Force(GameOptionsSchema.OutputResKey, GameOptionsSchema.HandheldOutput);
|
||||
var old = lines.TryGetValue("stick_dead_zone", out var sz) ? Atoi(sz) : 0;
|
||||
var shared = old is > 0 and < 6 ? GameOptionsSchema.SharedZone[old] : -1;
|
||||
foreach (var key in new[] { "left_stick_dead_zone", "right_stick_dead_zone" })
|
||||
{
|
||||
var own = lines.TryGetValue(key, out var s) ? GameOptionsSchema.Get(key).AsRead(Atoi(s)) : -1;
|
||||
if (own < 0 && shared != own) list.Add((key, shared));
|
||||
}
|
||||
}
|
||||
if (!hasVersion) Force("game_speed", 1);
|
||||
if (version < 4) Force("descriptor_reuse", 1);
|
||||
if (version < 5)
|
||||
@@ -142,12 +159,21 @@ public sealed class GameOptionsFile : IGameOptionValues
|
||||
|
||||
// ---- the values ----
|
||||
|
||||
/// <summary>A row's value: the launcher's change, else what the game reads from the file (its default without a line).
|
||||
/// KeyNotFoundException for a key that is no row (Raw has those).</summary>
|
||||
/// <summary>A saved value by its key (a row's own line or a merged row's part): the launcher's change, else what the game
|
||||
/// reads from the file (its default without a line).</summary>
|
||||
int Value(string key) => set.TryGetValue(key, out var v) ? v : read[key];
|
||||
|
||||
/// <summary>A row's value as the game's menu shows it: the launcher's change, else what the game reads from the file (its
|
||||
/// default without a line). A merged row's: the view of its parts (merged_rows.h); the Render resolution's: NativeStep while
|
||||
/// the Upscaler is an engine's native AA (its saved value is then left for the engine's other steps). A merged row's part
|
||||
/// by its own key: its saved value. KeyNotFoundException for any other key (Raw has those).</summary>
|
||||
public int Get(string key)
|
||||
{
|
||||
GameOptionsSchema.Get(key);
|
||||
return set.TryGetValue(key, out var v) ? v : read[key];
|
||||
if (GameOptionsSchema.Part(key) != null) return Value(key);
|
||||
var row = GameOptionsSchema.Get(key);
|
||||
if (row.Merge != null) return row.Merge.Of(row.Parts!.Select(p => Value(p.Key)).ToArray());
|
||||
if (key == GameOptionsSchema.ResolutionKey && GameOptionsSchema.FullScale(Value(GameOptionsSchema.UpscalerKey))) return GameOptionsSchema.NativeStep;
|
||||
return Value(key);
|
||||
}
|
||||
|
||||
/// <summary>A line's value as the file has it (the last line with that key, trimmed), null without one. Any key.</summary>
|
||||
@@ -157,20 +183,22 @@ public sealed class GameOptionsFile : IGameOptionValues
|
||||
/// sizes, the Anti-aliasing while an upscaler draws, the Microphone's device).</summary>
|
||||
public string Label(string key) => GameOptionsSchema.Get(key).Label(Get(key), this);
|
||||
|
||||
/// <summary>The values a row offers with the other rows as they are here: the Render resolution's steps for the Upscaler
|
||||
/// chosen (none with DLAA or a native AA), the Microphone's saved device, the row's own Choices otherwise. The value it has
|
||||
/// now is always in the list (a hand-edited one where it would sit).</summary>
|
||||
/// <summary>The values a row offers with the other rows as they are here: the Upscaler's engines (the one chosen by its
|
||||
/// saved value: an engine's native AA is its engine here), the Render resolution's steps for the Upscaler chosen (Native
|
||||
/// (100%), NativeStep, among DLSS's and FSR's), the Microphone's saved device, the row's own Choices otherwise. The value it
|
||||
/// has now is always in the list (a hand-edited one where it would sit).</summary>
|
||||
public IReadOnlyList<GameOptionChoice> ChoicesOf(string key)
|
||||
{
|
||||
var row = GameOptionsSchema.Get(key);
|
||||
if (row.Kind == GameOptionKind.Slider) return Array.Empty<GameOptionChoice>();
|
||||
var now = Get(key);
|
||||
var values = key switch
|
||||
{
|
||||
GameOptionsSchema.ResolutionKey => GameOptionsSchema.ResolutionSteps(Get(GameOptionsSchema.UpscalerKey)).ToList(),
|
||||
GameOptionsSchema.ResolutionKey => GameOptionsSchema.ResolutionSteps(Value(GameOptionsSchema.UpscalerKey)).ToList(),
|
||||
GameOptionsSchema.UpscalerKey => GameOptionsSchema.UpscalerOrder.Select(e => e == GameOptionsSchema.Engine(now) ? now : e).ToList(),
|
||||
GameOptionsSchema.MicKey => Raw(GameOptionsSchema.MicDeviceKey) is { Length: > 0 } ? new List<int> { 0, 1, 2 } : new List<int> { 0, 1 },
|
||||
_ => row.Choices.Select(c => c.Value).ToList(),
|
||||
};
|
||||
var now = Get(key);
|
||||
if (!values.Contains(now)) values.Add(now);
|
||||
if (key == GameOptionsSchema.GpuKey)
|
||||
{
|
||||
@@ -182,57 +210,93 @@ public sealed class GameOptionsFile : IGameOptionValues
|
||||
return values.Select(v => new GameOptionChoice(v, row.Label(v, this))).ToList();
|
||||
}
|
||||
|
||||
/// <summary>The rows the launcher changed since the file was read, with their new values (Save writes these).</summary>
|
||||
/// <summary>The saved values the launcher changed since the file was read, by their keys in the file (a merged row's are
|
||||
/// its parts'), with their new values (Save writes these).</summary>
|
||||
public IReadOnlyDictionary<string, int> Changes => set;
|
||||
|
||||
/// <summary>The file's lines that are no row here, in order, as (key, value): the KeptKeys and pad_/key_ lines, and
|
||||
/// <summary>The file's lines that are no value here, in order, as (key, value): the KeptKeys and pad_/key_ lines, and
|
||||
/// any key nobody knows (kept as it is). Lines without a key (blank, a comment) are kept too but not listed.</summary>
|
||||
public IReadOnlyList<(string Key, string Value)> OtherLines =>
|
||||
lines.Select(l => (Key: KeyOf(l), Line: l)).Where(x => x.Key != null && GameOptionsSchema.ByKey(x.Key) == null)
|
||||
lines.Select(l => (Key: KeyOf(l), Line: l)).Where(x => x.Key != null && !GameOptionsSchema.IsValueKey(x.Key))
|
||||
.Select(x => (x.Key!, x.Line[(x.Key!.Length + 1)..])).ToList();
|
||||
|
||||
/// <summary>OtherLines' keys that neither the schema nor KeptKeys knows.</summary>
|
||||
public IReadOnlyList<string> UnknownKeys => OtherLines.Select(o => o.Key).Where(k => !GameOptionsSchema.IsKept(k)).Distinct().ToList();
|
||||
|
||||
/// <summary>Sets a row as the game's menu would (set_row): the value inside its range and on its steps (GameOptionRow.Clamp);
|
||||
/// the Quality preset sets its rows (PresetValues, the Render resolution then on the Upscaler's nearest step); another
|
||||
/// Upscaler moves the Render resolution to its nearest step; a row that is not PresetExempt, changed, turns the preset
|
||||
/// back to Custom. Returns the value set. Nothing is written until Save.</summary>
|
||||
/// <summary>Sets a row as the game's menu would (set_row): the value inside its range and on its steps (GameOptionRow.Clamp).
|
||||
/// A merged row sets its parts (merged_rows.h *_set: one of a pair chosen, the other Off). The Upscaler takes an engine as
|
||||
/// upscaler_rows.h step_engine does: the Render resolution's Native (100%) goes with it (the game's own at 100% becomes the
|
||||
/// engine's native AA and back), the Render resolution then on the engine's nearest step; an engine's native AA value
|
||||
/// (DLAA 2, FSR 4's 5, FSR 3.1's 6) is set as it is. The Render resolution's NativeStep makes the Upscaler its engine's
|
||||
/// native AA (the game's own: 100%); another step with a native AA makes it the engine again (step_resolution). A merged
|
||||
/// row's part by its own key: in its range. Returns the row's value afterwards. Nothing is written until Save.
|
||||
/// (options_version 8: no Quality preset turns back to Custom.)</summary>
|
||||
public int Set(string key, int value)
|
||||
{
|
||||
var row = GameOptionsSchema.Get(key);
|
||||
var v = row.Clamp(value);
|
||||
if (key == GameOptionsSchema.PresetKey)
|
||||
if (GameOptionsSchema.Part(key) is { } part)
|
||||
{
|
||||
Put(key, v);
|
||||
foreach (var (k, pv) in GameOptionsSchema.PresetValues(v)) Put(k, pv);
|
||||
if (v > 0) Put(GameOptionsSchema.ResolutionKey, GameOptionsSchema.SnapResolution(Get(GameOptionsSchema.UpscalerKey), Get(GameOptionsSchema.ResolutionKey)));
|
||||
return v;
|
||||
Put(key, part.AsRead(value));
|
||||
return Value(key);
|
||||
}
|
||||
var changed = Get(key) != v;
|
||||
Put(key, v);
|
||||
if (key == GameOptionsSchema.UpscalerKey)
|
||||
Put(GameOptionsSchema.ResolutionKey, GameOptionsSchema.SnapResolution(v, Get(GameOptionsSchema.ResolutionKey)));
|
||||
if (changed && !row.PresetExempt) Put(GameOptionsSchema.PresetKey, 0);
|
||||
return v;
|
||||
var row = GameOptionsSchema.Get(key);
|
||||
if (row.Merge != null)
|
||||
{
|
||||
var parts = row.Parts!;
|
||||
var split = row.Merge.Split(row.Clamp(value), parts.Select(p => Value(p.Key)).ToArray());
|
||||
for (var i = 0; i < parts.Count; i++) Put(parts[i].Key, parts[i].AsRead(split[i]));
|
||||
return Get(key);
|
||||
}
|
||||
const string Up = GameOptionsSchema.UpscalerKey, Res = GameOptionsSchema.ResolutionKey;
|
||||
if (key == Up)
|
||||
{
|
||||
var v = row.Clamp(value);
|
||||
var e = GameOptionsSchema.Engine(v);
|
||||
if (!GameOptionsSchema.FullScale(v) && e != GameOptionsSchema.Engine(Value(Up)) && GameOptionsSchema.NativeSize(Value(Up), Value(Res)))
|
||||
{
|
||||
if (e == 0) Put(Res, 1); // (the game's own at 100%)
|
||||
else v = GameOptionsSchema.NativeOf(e);
|
||||
}
|
||||
else if (!GameOptionsSchema.FullScale(v) && e == GameOptionsSchema.Engine(Value(Up))) v = Value(Up); // (its engine already: as it is)
|
||||
Put(Up, v);
|
||||
Put(Res, GameOptionsSchema.SnapResolution(v, Value(Res)));
|
||||
return Get(key);
|
||||
}
|
||||
if (key == Res)
|
||||
{
|
||||
var up = Value(Up);
|
||||
if (value == GameOptionsSchema.NativeStep)
|
||||
{
|
||||
if (GameOptionsSchema.Engine(up) == 0) Put(Res, 1);
|
||||
else Put(Up, GameOptionsSchema.NativeOf(GameOptionsSchema.Engine(up)));
|
||||
return Get(key);
|
||||
}
|
||||
if (GameOptionsSchema.FullScale(up)) Put(Up, GameOptionsSchema.Engine(up));
|
||||
Put(Res, row.Clamp(value));
|
||||
return Get(key);
|
||||
}
|
||||
Put(key, row.Clamp(value));
|
||||
return Get(key);
|
||||
}
|
||||
|
||||
void Put(string key, int v)
|
||||
{
|
||||
if (read[key] == v) set.Remove(key); // (what the game reads from the file already: nothing to write)
|
||||
// (what the game reads from the file already: nothing to write. ((Triforce) 11-22) But for the GPU device row's card chosen
|
||||
// again while the file has no name for it, or another one (a number saved before 11-20, in Windows' order): its number and
|
||||
// name are written, as the game finds the card by the name first; nothing was written before and the number decided)
|
||||
if (read[key] == v && !(key == GameOptionsSchema.GpuKey && GpuNameDiffers(v))) set.Remove(key);
|
||||
else set[key] = v;
|
||||
}
|
||||
|
||||
/// <summary>The benchmark's recommendations (key to value): the Quality preset first when it is one of them, then each
|
||||
/// other row with Set's rules (so a row the preset set to the same value leaves it as it is; one that differs, and is not
|
||||
/// PresetExempt, makes it Custom, as in the game). KeyNotFoundException, and nothing set, for a key that is no row.
|
||||
/// Returns the rows' values afterwards, for the keys given. Nothing is written until Save.</summary>
|
||||
bool GpuNameDiffers(int v) =>
|
||||
GameOptionsSchema.GpuNameOf(v) is { } name && (Raw(GameOptionsSchema.GpuNameKey) ?? "").Trim() != name;
|
||||
|
||||
/// <summary>The benchmark's recommendations (key to value), each with Set's rules, in the order given. KeyNotFoundException,
|
||||
/// and nothing set, for a key that is no row (nor a merged row's part). Returns the values afterwards, for the keys given.
|
||||
/// Nothing is written until Save.</summary>
|
||||
public IReadOnlyDictionary<string, int> Apply(IReadOnlyDictionary<string, int> values)
|
||||
{
|
||||
foreach (var k in values.Keys) GameOptionsSchema.Get(k);
|
||||
if (values.TryGetValue(GameOptionsSchema.PresetKey, out var p)) Set(GameOptionsSchema.PresetKey, p);
|
||||
foreach (var (k, v) in values)
|
||||
if (k != GameOptionsSchema.PresetKey) Set(k, v);
|
||||
foreach (var k in values.Keys) if (GameOptionsSchema.Part(k) == null) GameOptionsSchema.Get(k);
|
||||
foreach (var (k, v) in values) Set(k, v);
|
||||
return values.Keys.ToDictionary(k => k, Get, StringComparer.Ordinal);
|
||||
}
|
||||
public IReadOnlyDictionary<string, int> Apply(Dictionary<string, int> values) => Apply((IReadOnlyDictionary<string, int>)values);
|
||||
@@ -243,7 +307,7 @@ public sealed class GameOptionsFile : IGameOptionValues
|
||||
/// get its value, every other line stays exactly as the file has it (so a line changed outside since Load is kept, as
|
||||
/// the game's merge keeps it), a changed row the file has no line for is added before options_version. A file of an
|
||||
/// older options_version is brought up to the current one as the game would read it (the values its rules give are
|
||||
/// written, options_version=7), so the game does not read the launcher's values by the old rules. The whole file is
|
||||
/// written, options_version=8), so the game does not read the launcher's values by the old rules. The whole file is
|
||||
/// written beside it as .new and then put in its place: a reader never meets half a file, and a failure leaves the old
|
||||
/// one (IOException). Nothing to write: nothing written. The caller refuses while the game runs (Game.IsRunning).
|
||||
/// Afterwards this object holds the file as written.</summary>
|
||||
@@ -283,7 +347,7 @@ public sealed class GameOptionsFile : IGameOptionValues
|
||||
else outLines.Add(l);
|
||||
}
|
||||
var missing = write.Keys.Where(k => !done.Contains(k) && k != GameOptionsSchema.VersionKey)
|
||||
.OrderBy(k => GameOptionsSchema.ByKey(k) is { } r ? IndexOf(r) : int.MaxValue).Select(k => k + "=" + write[k]).ToList();
|
||||
.OrderBy(k => GameOptionsSchema.RowOfLine(k) is { } r ? IndexOf(r) : int.MaxValue).Select(k => k + "=" + write[k]).ToList();
|
||||
var at = outLines.FindIndex(l => KeyOf(l) == GameOptionsSchema.VersionKey);
|
||||
if (at < 0) at = outLines.Count;
|
||||
outLines.InsertRange(at, missing);
|
||||
|
||||
@@ -1,31 +1,36 @@
|
||||
// The game's Options menu as data: gpu/vk/vk_menu.cpp's Row table (rows[]), the tx_* functions that label its values, the
|
||||
// keys ini_key gives them, the defaults of vk_menu.h's Options, and the Quality preset (apply_preset, hn_preset). Every row
|
||||
// the game keeps in triforce_options.ini is here except the ones KeptKeys names (the Debug tab, the Layout preset); the Game
|
||||
// language is language.txt's, not this file's (Languages.cs). Labels are the menu's own words: players compare them.
|
||||
// Where the menu's label depends on this PC (the display's refresh, a gyroscope, what the driver runs) the label here is the
|
||||
// one the menu shows when it knows nothing of it. When vk_menu.cpp's table changes, change this one: the test
|
||||
// "game options: schema matches vk_menu.cpp" reads the table and says what differs.
|
||||
// keys ini_key gives them, the defaults of vk_menu.h's Options, and (options_version 8) the merged rows of merged_rows.h. Every
|
||||
// row the game keeps in triforce_options.ini is here except the ones KeptKeys names (the Debug tab, the Layout preset, the
|
||||
// lines options_version 8 dropped); the Game language is language.txt's, not this file's (Languages.cs). Labels are the menu's
|
||||
// own words: players compare them. Where the menu's label depends on this PC (the display's refresh, a gyroscope, what the
|
||||
// driver runs) the label here is the one the menu shows when it knows nothing of it. When vk_menu.cpp's table changes, change
|
||||
// this one: the test "game options: schema matches vk_menu.cpp" reads the table and says what differs.
|
||||
using System.Globalization;
|
||||
|
||||
namespace Triforce.Logic;
|
||||
|
||||
/// <summary>Whose low-latency library the Low latency row stands for (merged_rows.h Vendor): NVIDIA Reflex, AMD Anti-Lag 2,
|
||||
/// or neither (the game hides the row there).</summary>
|
||||
public enum LatencyVendor { None, Nvidia, Amd }
|
||||
|
||||
public static class GameOptionsSchema
|
||||
{
|
||||
/// <summary>The file the game reads at its start and writes at every change in its menu, in the game folder.</summary>
|
||||
public const string FileName = "triforce_options.ini";
|
||||
/// <summary>The options_version the game writes (vk_menu.cpp save): the file's format, which menu_init's rules read.</summary>
|
||||
public const int CurrentVersion = 7;
|
||||
/// <summary>The options_version the game writes (vk_menu.cpp save, merged_rows.h kVersion): the file's format, which
|
||||
/// menu_init's rules read.</summary>
|
||||
public const int CurrentVersion = 8;
|
||||
|
||||
public const string OutputResKey = "output_res";
|
||||
public const string ResolutionKey = "resolution";
|
||||
public const string UpscalerKey = "dlss";
|
||||
public const string PresetKey = "quality_preset";
|
||||
public const string RumbleKey = "rumble_strength";
|
||||
public const string GpuKey = "gpu_device";
|
||||
public const string MicKey = "microphone";
|
||||
public const string HandheldKey = "handheld_profile";
|
||||
public const string VersionKey = "options_version";
|
||||
public const string MicDeviceKey = "microphone_device";
|
||||
/// <summary>The merged rows' keys (the launcher's alone: no line has them, their Parts' keys are the file's).</summary>
|
||||
public const string HdrKey = "@hdr", FrameGenKey = "@frame_generation", PacingKey = "@frame_pacing", LatencyKey = "@low_latency";
|
||||
|
||||
/// <summary>The names of the graphics cards, in the order the game counts them (its GPU device row's 1 is the first),
|
||||
/// for the GPU device row's labels. The launcher sets it (UseSystemGpus: Gpus.List()). The game lists the cards
|
||||
@@ -61,18 +66,42 @@ public static class GameOptionsSchema
|
||||
};
|
||||
public const string GpuListFile = "triforce_gpus.txt";
|
||||
|
||||
/// <summary>((Triforce, options_version 8) Whose library the Low latency row is, as the game decides it by the card it runs
|
||||
/// on (vk_menu.cpp latency_vendor: Reflex on an NVIDIA card, Anti-Lag 2 on an AMD one). Null: NVIDIA's, the row's widest
|
||||
/// (Off, On, On + Boost). The launcher sets it (UseSystemLatency).</summary>
|
||||
public static Func<LatencyVendor>? LatencyVendorOf { get; set; }
|
||||
/// <summary>LatencyVendorOf from the card that most likely runs the game (Gpus.Main(): an NVIDIA or AMD one before an
|
||||
/// integrated Intel one).</summary>
|
||||
public static void UseSystemLatency() => LatencyVendorOf = () => Gpus.Main()?.Vendor switch
|
||||
{
|
||||
GpuVendor.Nvidia => LatencyVendor.Nvidia, GpuVendor.Amd => LatencyVendor.Amd, _ => LatencyVendor.None,
|
||||
};
|
||||
static LatencyVendor LatencyNow()
|
||||
{
|
||||
try { return LatencyVendorOf?.Invoke() ?? LatencyVendor.Nvidia; } catch (Exception) { return LatencyVendor.Nvidia; }
|
||||
}
|
||||
/// <summary>merged_rows.h latency_hi: the Low latency row's last value for this vendor (2 Reflex's On + Boost, 1 Anti-Lag 2's On).</summary>
|
||||
public static int LatencyHi(LatencyVendor v) => v == LatencyVendor.Nvidia ? 2 : v == LatencyVendor.Amd ? 1 : 0;
|
||||
|
||||
// ---- the keys ----
|
||||
|
||||
/// <summary>vk_menu.cpp ini_key: a few rows keep the keys they were first saved with; every other row's key is its
|
||||
/// name lower-cased, its spaces as '_', cut to 31 characters.</summary>
|
||||
/// <summary>vk_menu.cpp ini_key: a few rows keep the keys they were first saved with (the rows renamed since, options_version
|
||||
/// 8's groups among them); every other row's key is its name lower-cased, its spaces as '_', cut to 31 characters.</summary>
|
||||
public static string IniKey(string name) => name switch
|
||||
{
|
||||
"Output resolution" => OutputResKey,
|
||||
"Render resolution" => ResolutionKey,
|
||||
"Game frame rate cap" => "frame_rate_cap",
|
||||
"Window scaling filter" => "upscaling",
|
||||
"Frame rate cap" => "frame_rate_cap",
|
||||
"Upscaler" => UpscalerKey,
|
||||
"Start next frame early" => "tail_early",
|
||||
"Aspect ratio" => "ultrawide", "HUD position" => "ultrawide_hud", "Menu sides" => "ultrawide_menus",
|
||||
"Paper white" => "hdr_paper_white", "Peak brightness" => "hdr_peak_brightness", "UI brightness" => "renodx_ui_brightness",
|
||||
"Tonemapper" => "renodx_tonemapper", "Gamma correction" => "renodx_gamma_correction", "Color space" => "renodx_color_space",
|
||||
"Exposure" => "renodx_exposure", "Middle gray" => "renodx_midgray", "Match tone slope" => "renodx_match_tone_slope",
|
||||
"Tone slope" => "renodx_tone_slope", "Hue clip" => "renodx_hue_clip", "Highlight saturation" => "renodx_highlight_saturation",
|
||||
"Blowout" => "renodx_blowout", "Flare" => "renodx_flare", "Hue correction" => "renodx_hue_correction",
|
||||
"Color grading" => "renodx_color_grading", "Highlights" => "renodx_highlights", "Shadows" => "renodx_shadows",
|
||||
"Contrast" => "renodx_contrast", "Saturation" => "renodx_saturation", "Bloom" => "renodx_bloom",
|
||||
_ => Cut(new string(name.Select(c => c == ' ' ? '_' : c is >= 'A' and <= 'Z' ? (char)(c + 32) : c).ToArray()), 31),
|
||||
};
|
||||
static string Cut(string s, int n) => s.Length > n ? s[..n] : s;
|
||||
@@ -86,7 +115,9 @@ public static class GameOptionsSchema
|
||||
|
||||
static string TxOnoff(int v, IGameOptionValues? o) => v != 0 ? "On" : "Off";
|
||||
static string TxMenuShortcut(int v, IGameOptionValues? o) => v != 0 ? "F1 only" : "Insert or F1";
|
||||
static string TxHdr(int v, IGameOptionValues? o) => v == 1 ? "Expanded" : v == 2 ? "Native" : "Off";
|
||||
static string TxHdr(int v) => v == 1 ? "Expanded" : v == 2 ? "Native" : "Off";
|
||||
/// <summary>tx_hdr_mode: the HDR row, opts.hdr with RenoDX HDR as its fourth value.</summary>
|
||||
static string TxHdrMode(int v, IGameOptionValues? o) => v == HdrRenodx ? "Native + RenoDX" : TxHdr(Math.Clamp(v, 0, 2));
|
||||
static string TxNits(int v, IGameOptionValues? o) => v.ToString(CultureInfo.InvariantCulture) + " nits";
|
||||
/// <summary>tx_fps_cap. 6, Monitor's rate, shows the display's rate in the game ("Monitor's rate (144)") once it knows it.</summary>
|
||||
static string TxFpsCap(int v, IGameOptionValues? o)
|
||||
@@ -95,22 +126,22 @@ public static class GameOptionsSchema
|
||||
if (v >= 6) return "Monitor's rate";
|
||||
return new[] { "60 (the console's)", "90", "120", "144", "165", "240" }[v];
|
||||
}
|
||||
static string TxSteadyFps(int v, IGameOptionValues? o) => v == 1 ? "Any rate" : v == 2 ? "Refresh steps" : "Off";
|
||||
static string TxSteadyFps(int v) => v == 1 ? "Any rate" : v == 2 ? "Refresh steps" : "Off";
|
||||
/// <summary>tx_pacing: Frame pacing and Steady frame rate in one row.</summary>
|
||||
static string TxPacing(int v, IGameOptionValues? o) => Pick(new[] { "Off", "Even", "Steady, any rate", "Steady, refresh steps" }, v);
|
||||
/// <summary>tx_gyro without a controller's answer (the game adds "(gyro found)" and the like).</summary>
|
||||
static string TxGyro(int v, IGameOptionValues? o) => v != 0 ? "On" : "Off";
|
||||
static string TxMousecam(int v, IGameOptionValues? o) => v != 0 ? "Native" : "As the stick";
|
||||
static string TxSens(int v, IGameOptionValues? o) =>
|
||||
(v < 0 ? "-" : "") + (Math.Abs(v) / 100).ToString(CultureInfo.InvariantCulture) + "." + (Math.Abs(v) % 100).ToString("00", CultureInfo.InvariantCulture);
|
||||
static readonly string[] Upscales = { "Off", "Catmull-Rom", "Lanczos", "AMD FSR 1" };
|
||||
/// <summary>tx_filter as tx_upscale: the game shows "Not needed (window = output)" while its window is the output's size.</summary>
|
||||
static string TxFilter(int v, IGameOptionValues? o) => OrFirst(Upscales, v);
|
||||
/// <summary>tx_reflex as on an NVIDIA card with Reflex (elsewhere the game shows Off, and On with DLSS frame generation).</summary>
|
||||
static string TxReflex(int v, IGameOptionValues? o) => Pick(new[] { "Off", "On", "On + Boost" }, v);
|
||||
/// <summary>tx_antilag as on an AMD card with Anti-Lag 2 (elsewhere the game shows Off).</summary>
|
||||
static string TxAntilag(int v, IGameOptionValues? o) => v != 0 ? "On" : "Off";
|
||||
static readonly string[] Upscalers = { "Game", "NVIDIA DLSS", "NVIDIA DLAA", "AMD FSR 3.1", "AMD FSR 4", "AMD FSR 4 Native AA", "AMD FSR 3.1 Native AA" };
|
||||
/// <summary>tx_upscaler by the value chosen (the game shows what runs: the game's own where the choice cannot).</summary>
|
||||
static string TxUpscaler(int v, IGameOptionValues? o) => Pick(Upscalers, v);
|
||||
static readonly string[] LatencyNames = { "Off", "On", "On + Boost" };
|
||||
/// <summary>tx_latency: the Low latency row by the card's maker (with DLSS frame generation the game shows Reflex's Off as
|
||||
/// On: Streamline's Reflex is always on).</summary>
|
||||
static string TxLatency(int v, IGameOptionValues? o) => LatencyNames[Math.Clamp(v, 0, LatencyHi(LatencyNow()))];
|
||||
static readonly string[] Engines = { "Game", "NVIDIA DLSS", "NVIDIA DLSS", "AMD FSR 3.1", "AMD FSR 4", "AMD FSR 4", "AMD FSR 3.1" };
|
||||
/// <summary>tx_upscaler: the engine alone (options_version 8: DLAA and the native AAs are the Render resolution's Native
|
||||
/// (100%)); the game names FSR 4 by the version AMD's library runs once it has asked ("AMD FSR 4.1").</summary>
|
||||
static string TxUpscaler(int v, IGameOptionValues? o) => Engines[Engine(v)];
|
||||
/// <summary>tx_dlss_model without RX_VK_DLSS_PRESET.</summary>
|
||||
static string TxDlssModel(int v, IGameOptionValues? o) => Pick(new[] { "Transformer (K)", "Transformer 2 (M)", "Transformer 2 (L)", "NVIDIA default" }, v);
|
||||
static string TxAniso(int v, IGameOptionValues? o) => OrFirst(new[] { "Game", "2x", "4x", "8x", "16x" }, v);
|
||||
@@ -134,19 +165,20 @@ public static class GameOptionsSchema
|
||||
static string TxMenuSounds(int v, IGameOptionValues? o) => v != 0 ? Pct(v) : "Off";
|
||||
static string TxSprint(int v, IGameOptionValues? o) => v == 1 ? "Left stick click" : v == 2 ? "B" : "Off";
|
||||
static string TxSprintMode(int v, IGameOptionValues? o) => v != 0 ? "Hold" : "Toggle";
|
||||
static string TxStickDeadZone(int v, IGameOptionValues? o) => OrFirst(new[] { "Default (24%)", "5%", "10%", "15%", "20%", "30%" }, v);
|
||||
static string TxOwnDeadZone(int v, IGameOptionValues? o) => v < 0 ? "As Stick dead zone" : Pct(v);
|
||||
/// <summary>tx_own_dead_zone: -1 is XInput's own (~24%), the Default (options_version 8: the shared Stick dead zone is gone).</summary>
|
||||
static string TxOwnDeadZone(int v, IGameOptionValues? o) => v < 0 ? "Default (24%)" : Pct(v);
|
||||
static string TxWalkKey(int v, IGameOptionValues? o) => OrFirst(new[] { "Off", "Caps Lock", "Shift", "Ctrl", "Tab" }, v);
|
||||
static string TxAudioOutput(int v, IGameOptionValues? o) => OrFirst(new[] { "Auto", "Stereo", "5.1" }, v);
|
||||
static string TxDeadzone(int v, IGameOptionValues? o) => Pick(new[] { "Low", "Standard", "High" }, v);
|
||||
static string TxRobust(int v, IGameOptionValues? o) => OrFirst(new[] { "Auto", "Off", "On" }, v);
|
||||
static string TxMesh(int v, IGameOptionValues? o) => v == 1 ? "Compute fallback" : "Auto";
|
||||
static string TxPerf(int v, IGameOptionValues? o) => v == 1 ? "On" : v >= 2 ? "Full" : "Off";
|
||||
static string TxDlssg(int v, IGameOptionValues? o) => v == 1 ? "2x" : v == 2 ? "3x" : v == 3 ? "4x" : "Off";
|
||||
/// <summary>tx_framegen where AMD's library can make the frames (elsewhere the game shows a saved AMD FSR 4 as 2x).</summary>
|
||||
static string TxFramegen(int v, IGameOptionValues? o) => Pick(new[] { "Off", "Auto", "2x", "3x", "4x", "5x", "6x", "7x", "8x", "AMD FSR 4" }, v);
|
||||
static readonly string[] Presets = { "Custom", "Minimum (6GB)", "Low (8GB)", "Balanced (12GB)", "High (16GB)", "Ultra (20GB+)" };
|
||||
static string TxPreset(int v, IGameOptionValues? o) => Pick(Presets, v);
|
||||
static string TxDlssg(int v) => v == 1 ? "2x" : v == 2 ? "3x" : v == 3 ? "4x" : "Off";
|
||||
/// <summary>tx_framegen where AMD's library can make the frames, before it has said its version (the game then shows
|
||||
/// "AMD FSR (4.0.2)" and the like; elsewhere a saved 9 as 2x).</summary>
|
||||
static string TxFramegen(int v) => Pick(new[] { "Off", "Auto", "2x", "3x", "4x", "5x", "6x", "7x", "8x", "AMD FSR" }, v);
|
||||
/// <summary>tx_framegen_row: the renderer's own and AMD's (opts.framegen), then NVIDIA DLSS 2x to 4x (opts.dlssg).</summary>
|
||||
static string TxFramegenRow(int v, IGameOptionValues? o) =>
|
||||
v >= FgDlss ? new[] { "NVIDIA DLSS 2x", "NVIDIA DLSS 3x", "NVIDIA DLSS 4x" }[Math.Clamp(v - FgDlss, 0, 2)] : TxFramegen(v);
|
||||
/// <summary>tx_gpu: 0 "Auto", then "<n>: <name>" counted from 0 (GpuNames), "<n>: Device <n>" without a name.</summary>
|
||||
static string TxGpu(int v, IGameOptionValues? o)
|
||||
{
|
||||
@@ -183,30 +215,45 @@ public static class GameOptionsSchema
|
||||
|
||||
// ---- the Output resolution and the Render resolution ----
|
||||
|
||||
/// <summary>The Output resolution's sizes by their saved value (kOutputs); 6 came after the others so that saved values
|
||||
/// keep their sizes.</summary>
|
||||
public static readonly IReadOnlyList<(int W, int H)> Outputs = new[] { (2048, 1152), (2560, 1440), (3840, 2160), (1920, 1080), (5120, 1440), (5120, 2880), (5120, 2160) };
|
||||
/// <summary>The Output resolution's sizes by their saved value (kOutputs); 6 and 7 came after the others so that saved
|
||||
/// values keep their sizes. (options_version 8) 7 is 1536x864, the game's handheld profile, once a row of its own.</summary>
|
||||
public static readonly IReadOnlyList<(int W, int H)> Outputs = new[] { (2048, 1152), (2560, 1440), (3840, 2160), (1920, 1080), (5120, 1440), (5120, 2880), (5120, 2160), (1536, 864) };
|
||||
/// <summary>The Output resolution's handheld profile (merged_rows.h kHandheldOutput).</summary>
|
||||
public const int HandheldOutput = 7;
|
||||
/// <summary>The order the menu shows them in, smallest to largest (kOutputOrder).</summary>
|
||||
public static readonly IReadOnlyList<int> OutputOrder = new[] { 3, 0, 1, 2, 4, 6, 5 };
|
||||
public static readonly IReadOnlyList<int> OutputOrder = new[] { 7, 3, 0, 1, 2, 4, 6, 5 };
|
||||
static int OutputChoice(int v) => v >= 0 && v < Outputs.Count ? v : 0;
|
||||
static string TxOutputRes(int v, IGameOptionValues? o)
|
||||
{
|
||||
var (w, h) = Outputs[OutputChoice(v)];
|
||||
v = OutputChoice(v);
|
||||
if (v == HandheldOutput) return "1536x864 (handheld)";
|
||||
var (w, h) = Outputs[v];
|
||||
return w + "x" + h;
|
||||
}
|
||||
|
||||
// (upscaler_rows.h)
|
||||
const int Game = 0, Dlss = 1, Dlaa = 2, Fsr3 = 3, Fsr4 = 4, Fsr4Aa = 5, Fsr3Aa = 6;
|
||||
/// <summary>The Upscaler row's order in the menu: each engine's native anti-aliasing after it (kOrder).</summary>
|
||||
public static readonly IReadOnlyList<int> UpscalerOrder = new[] { Game, Dlss, Dlaa, Fsr3, Fsr3Aa, Fsr4, Fsr4Aa };
|
||||
/// <summary>The engines in the order the Upscaler row shows them (kEngines): an engine's native anti-aliasing (DLAA, FSR's
|
||||
/// Native AA) is the Render resolution's Native (100%) from options_version 8, its saved value as before.</summary>
|
||||
public static readonly IReadOnlyList<int> UpscalerOrder = new[] { Game, Dlss, Fsr3, Fsr4 };
|
||||
/// <summary>upscaler_rows.h engine: DLAA is DLSS's, FSR 4's and FSR 3.1's native AA their own.</summary>
|
||||
public static int Engine(int up) => up == Dlaa ? Dlss : up == Fsr4Aa ? Fsr4 : up == Fsr3Aa ? Fsr3 : up is >= Game and <= Fsr3Aa ? up : Game;
|
||||
/// <summary>upscaler_rows.h native_of: an engine's native anti-aliasing (the game's own has none: itself).</summary>
|
||||
public static int NativeOf(int engine) => engine == Dlss ? Dlaa : engine == Fsr4 ? Fsr4Aa : engine == Fsr3 ? Fsr3Aa : engine;
|
||||
/// <summary>The Render resolution row's Native (100%) with DLSS or FSR (upscaler_rows.h kNativeStep): its value here while
|
||||
/// the Upscaler is an engine's native AA (GameOptionsFile.Get). Chosen, the Upscaler becomes that native AA and the
|
||||
/// saved resolution stays as it is.</summary>
|
||||
public const int NativeStep = -1;
|
||||
static readonly int[] Percents = { 0, 100, 75, 67, 50, 58, 33 };
|
||||
static int Percent(int v) => v > 0 && v < Percents.Length ? Percents[v] : 0;
|
||||
static bool FullScale(int up) => up == Dlaa || up == Fsr4Aa || up == Fsr3Aa;
|
||||
public static bool FullScale(int up) => up == Dlaa || up == Fsr4Aa || up == Fsr3Aa;
|
||||
static bool ScalesByMode(int up) => up == Dlss || up == Fsr3 || up == Fsr4;
|
||||
static readonly int[] GameSteps = { 0, 1, 2, 3, 4 }, DlssSteps = { 0, 3, 5, 4, 6 };
|
||||
/// <summary>The Render resolution values the menu steps through with this Upscaler (none with DLAA or a native AA:
|
||||
/// the 3D is drawn at full size).</summary>
|
||||
public static IReadOnlyList<int> ResolutionSteps(int upscaler) => FullScale(upscaler) ? Array.Empty<int>() : ScalesByMode(upscaler) ? DlssSteps : GameSteps;
|
||||
/// <summary>upscaler_rows.h native_size: the 3D at the output's full size (an engine's native AA, or the game's own at 100%).</summary>
|
||||
public static bool NativeSize(int up, int resolution) => FullScale(up) || (up == Game && Percent(resolution) == 100);
|
||||
static readonly int[] GameSteps = { 0, 1, 2, 3, 4 }, DlssSteps = { 0, 3, 5, 4, 6 }, TemporalSteps = { 0, NativeStep, 3, 5, 4, 6 };
|
||||
/// <summary>The Render resolution values the menu steps through with this Upscaler: the game's own its shares; DLSS and
|
||||
/// FSR (and their native AAs) Auto, Native (100%) and their modes (upscaler_rows.h kTemporalSteps).</summary>
|
||||
public static IReadOnlyList<int> ResolutionSteps(int upscaler) => ScalesByMode(Engine(upscaler)) ? TemporalSteps : GameSteps;
|
||||
/// <summary>upscaler_rows.h snap: v as one of the upscaler's steps, the nearest in size (the larger on a tie); Auto stays,
|
||||
/// and with a full-size upscaler v is kept for the next.</summary>
|
||||
public static int SnapResolution(int upscaler, int v)
|
||||
@@ -225,17 +272,15 @@ public static class GameOptionsSchema
|
||||
}
|
||||
static string ModeName(int v) => Percent(v) switch { 67 => "Quality", 58 => "Balanced", 50 => "Performance", 33 => "Ultra Performance", _ => "" };
|
||||
/// <summary>tx_resolution: by the Upscaler chosen, and the size the game draws the 3D at for a fixed share of the
|
||||
/// Output resolution (the handheld profile's 1536x864), a twelfth of it as the game takes it.</summary>
|
||||
/// Output resolution (the handheld profile's 1536x864 among them), a twelfth of it as the game takes it.</summary>
|
||||
static string TxResolution(int v, IGameOptionValues? o)
|
||||
{
|
||||
var up = V(o, UpscalerKey, 0);
|
||||
if (up == Dlaa) return "Native (DLAA)";
|
||||
if (up == Fsr4Aa) return "Native (FSR 4)";
|
||||
if (up == Fsr3Aa) return "Native (FSR 3.1)";
|
||||
if (FullScale(up) || v == NativeStep) return "Native (100%)";
|
||||
var p = Percent(v);
|
||||
if (p == 0) return "Auto (dynamic)";
|
||||
if (ScalesByMode(up) && ModeName(v).Length > 0) return ModeName(v) + " (" + p + "%)";
|
||||
var (ow, oh) = V(o, HandheldKey, 0) != 0 ? (1536, 864) : Outputs[OutputChoice(V(o, OutputResKey, 0))];
|
||||
var (ow, oh) = Outputs[OutputChoice(V(o, OutputResKey, 0))];
|
||||
var k = Math.Min(Math.Max((int)(p / 100.0f * 12.0f + 0.5f), 1), 12);
|
||||
return p + "% (" + (ow * k + 11) / 12 + "x" + oh * k / 12 + ")";
|
||||
}
|
||||
@@ -249,6 +294,38 @@ public static class GameOptionsSchema
|
||||
return OrFirst(AaNames, v);
|
||||
}
|
||||
|
||||
// ---- the merged rows (merged_rows.h) ----
|
||||
|
||||
const int HdrRenodx = 3, FgDlss = 10;
|
||||
/// <summary>The saved values the merged rows stand for (vk_menu.cpp's TAB_HIDDEN rows), by key: each keeps its line.</summary>
|
||||
public static readonly IReadOnlyDictionary<string, GameOptionPart> Parts = new GameOptionPart[]
|
||||
{
|
||||
new("hdr", 0, 2, 0, TxHdr), new("renodx_hdr", 0, 1, 0, v => v != 0 ? "On" : "Off"),
|
||||
new("frame_generation", 0, 9, 0, TxFramegen), new("dlss_frame_generation", 0, 3, 0, TxDlssg),
|
||||
new("frame_pacing", 0, 1, 1, v => v != 0 ? "On" : "Off"), new("steady_frame_rate", 0, 2, 0, TxSteadyFps),
|
||||
new("nvidia_reflex", 0, 2, 2, v => Pick(LatencyNames, v)), new("amd_anti-lag_2", 0, 1, 0, v => v != 0 ? "On" : "Off"),
|
||||
}.ToDictionary(p => p.Key, StringComparer.Ordinal);
|
||||
/// <summary>A saved value a merged row stands for, by its key; null for any other key.</summary>
|
||||
public static GameOptionPart? Part(string key) => Parts.GetValueOrDefault(key);
|
||||
|
||||
static (string[] Parts, GameOptionMerge Merge) MergeHdr => (new[] { "hdr", "renodx_hdr" }, new GameOptionMerge(
|
||||
p => p[0] == 2 && p[1] != 0 ? HdrRenodx : Math.Clamp(p[0], 0, 2),
|
||||
(row, _) => new[] { row >= HdrRenodx ? 2 : Math.Max(row, 0), row >= HdrRenodx ? 1 : 0 }));
|
||||
static (string[] Parts, GameOptionMerge Merge) MergeFramegen => (new[] { "frame_generation", "dlss_frame_generation" }, new GameOptionMerge(
|
||||
p => p[1] is >= 1 and <= 3 ? FgDlss + p[1] - 1 : p[0],
|
||||
(row, _) => row >= FgDlss ? new[] { 0, Math.Min(row - FgDlss + 1, 3) } : new[] { Math.Max(row, 0), 0 }));
|
||||
static (string[] Parts, GameOptionMerge Merge) MergePacing => (new[] { "frame_pacing", "steady_frame_rate" }, new GameOptionMerge(
|
||||
p => p[1] == 1 ? 2 : p[1] == 2 ? 3 : p[0] != 0 ? 1 : 0,
|
||||
(row, _) => new[] { row != 0 ? 1 : 0, row == 2 ? 1 : row == 3 ? 2 : 0 }));
|
||||
static (string[] Parts, GameOptionMerge Merge) MergeLatency => (new[] { "nvidia_reflex", "amd_anti-lag_2" }, new GameOptionMerge(
|
||||
p => LatencyNow() switch { LatencyVendor.Nvidia => Math.Clamp(p[0], 0, 2), LatencyVendor.Amd => p[1] != 0 ? 1 : 0, _ => 0 },
|
||||
(row, now) => LatencyNow() switch
|
||||
{
|
||||
LatencyVendor.Nvidia => new[] { Math.Clamp(row, 0, 2), now[1] },
|
||||
LatencyVendor.Amd => new[] { now[0], row > 0 ? 1 : 0 },
|
||||
_ => now.ToArray(),
|
||||
}));
|
||||
|
||||
// ---- the rows ----
|
||||
|
||||
static GameOptionRow Row(GameOptionTab tab, string? section, string name, int lo, int hi, int step, int dflt, GameOptionKind kind,
|
||||
@@ -282,184 +359,182 @@ public static class GameOptionsSchema
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Every row, in the menu's order (Display, Graphics, System, Audio, Controls as the table has them; the
|
||||
/// Motion page's rows and Button prompts after the Controls tab's own).</summary>
|
||||
/// <summary>A merged row (merged_rows.h): a Choice row with no line of its own, a view of its parts. Low latency's choices
|
||||
/// follow the card's maker (LatencyVendorOf).</summary>
|
||||
static GameOptionRow Merged(GameOptionTab tab, string section, string name, int lo, int hi, int step,
|
||||
(string[] Parts, GameOptionMerge Merge) merge, Func<int, IGameOptionValues?, string> format, bool restart, bool exempt, string help)
|
||||
{
|
||||
var key = name switch { "HDR" => HdrKey, "Frame generation" => FrameGenKey, "Frame pacing" => PacingKey, _ => LatencyKey };
|
||||
Func<IReadOnlyList<GameOptionChoice>> list = key == LatencyKey
|
||||
? () => Enumerable.Range(0, LatencyHi(LatencyNow()) + 1).Select(v => new GameOptionChoice(v, format(v, null))).ToList()
|
||||
: () => Enumerable.Range(lo, hi - lo + 1).Select(v => new GameOptionChoice(v, format(v, null))).ToList();
|
||||
return new GameOptionRow
|
||||
{
|
||||
Tab = tab, Section = section, Name = name, Key = key, Lo = lo, Hi = hi, Step = step, Kind = GameOptionKind.Choice,
|
||||
Format = format, ChoiceList = list, Restart = restart, PresetExempt = exempt, Help = help,
|
||||
Parts = merge.Parts.Select(k => Parts[k]).ToList(), Merge = merge.Merge,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Every row, in the menu's order (as vk_menu.cpp's table has them: Display, Graphics, System's Game, Audio,
|
||||
/// System's Online, Controls; the Motion page's rows and Button prompts after the Controls tab's own).</summary>
|
||||
public static readonly IReadOnlyList<GameOptionRow> All = new[]
|
||||
{
|
||||
Row(GameOptionTab.Display, "Screen", "Fullscreen", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Fills the whole screen with the game, without the window's border. The same as F10 or Alt+Enter."),
|
||||
Row(GameOptionTab.Display, "Screen", "Output resolution", 0, 6, 1, 0, GameOptionKind.Choice, TxOutputRes, true, false,
|
||||
"The game's whole frame, HUD included, before it is scaled to the window. Docked only. Applies after a restart."),
|
||||
"The game fills the whole screen, without the window's border. F10 and Alt+Enter do the same."),
|
||||
Row(GameOptionTab.Display, "Screen", "Output resolution", 0, 7, 1, 0, GameOptionKind.Choice, TxOutputRes, true, false,
|
||||
"The size of the game's whole frame, HUD included, before it is scaled to the window. Applies after a restart."),
|
||||
Row(GameOptionTab.Display, "Screen", "GPU device", 0, 8, 1, 0, GameOptionKind.Choice, TxGpu, true, true,
|
||||
"Which graphics card the game runs on. Applies after a restart."),
|
||||
Row(GameOptionTab.Display, "Widescreen", "Ultrawide", 0, 3, 1, 0, GameOptionKind.Choice, TxUltrawide, true, false,
|
||||
"The camera's shape: the game's own 16:9, or a fixed 16:10, 21:9 or 32:9 for a screen or a window of that shape. A screen of another shape shows the picture between black bars. Applies after a restart."),
|
||||
Row(GameOptionTab.Display, "Widescreen", "Ultrawide HUD", 0, 1, 1, 0, GameOptionKind.Choice, TxWideHud, true, true,
|
||||
"With Ultrawide: where the hearts, the item slot and the map sit on a screen wider than 16:9. Middle: in the middle 16:9, as on a normal screen. Screen edges: out in the screen's corners. Applies after a restart."),
|
||||
Row(GameOptionTab.Display, "Widescreen", "Ultrawide menus", 0, 2, 1, 1, GameOptionKind.Choice, TxWideMenus, false, false,
|
||||
"With Ultrawide: the pause, item and map menus, and what shows beside them. Loading screens and pre-rendered movies, which draw no world either, get the same sides; a fade always covers the whole screen. Changes at once."),
|
||||
Row(GameOptionTab.Display, "Frame rate", "Game frame rate cap", -3, 6, 1, 0, GameOptionKind.Choice, TxFpsCap, true, true,
|
||||
"Limits frames rendered by the game. Generated frames are additional. Takes a restart. 30, 40 and 45 are for a PC or handheld that holds one of them steadily where 60 swings; the game keeps its speed. Past 60 is experimental: the game keeps real time, but some cutscenes and bosses can misbehave (Gohma, the intro's narration). 60 is the safe choice. Monitor's rate is the refresh rate of the screen the game starts on, from 30 to 240."),
|
||||
Row(GameOptionTab.Display, "Frame rate", "Steady frame rate", 0, 2, 1, 0, GameOptionKind.Choice, TxSteadyFps, true, true,
|
||||
"Paces the game to a frame rate this PC holds where you are, under the Game frame rate cap, and shows each frame a period after the last, so that frames come evenly instead of each as soon as it is ready. It goes down quickly where frames run late and back up slowly where there is room; loads and single hitches do not move it. Gives up some frame rate for steadiness. Any rate suits a screen with variable refresh (G-SYNC, FreeSync) or VSync off; Refresh steps keeps to whole divisions of the refresh rate (at 240 Hz: 120, 80, 60 ...) for VSync without variable refresh. Takes a restart."),
|
||||
Row(GameOptionTab.Display, "Frame rate", "Reflex frame limit", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"With DLSS frame generation: NVIDIA Reflex holds the Game frame rate cap where each frame starts, in place of the game's own wait, so a frame waits once and the controls are read later. The game's own wait is back whenever no frame is being generated. Where RivaTuner Statistics Server is the game's limiter it holds the frames instead. Changes at once."),
|
||||
Row(GameOptionTab.Display, "Frame rate", "VSync", 0, 1, 1, 1, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Whether a finished frame waits for the screen's next refresh. Off shows it at once: a little less delay, and the picture can tear. Neither changes the frame rate, which the Game frame rate cap limits. Changes at once."),
|
||||
Row(GameOptionTab.Display, "Frame rate", "FPS counter", 0, 2, 1, 0, GameOptionKind.Choice, TxPerf, false, true,
|
||||
"On: frames per second in the top right corner. Full: a performance overlay in its place, with the GPU's and the CPU's load, temperatures and memory, the frame rate and its 1% and 0.1% lows, the frame times and their graph, the waits per frame and the picture's settings."),
|
||||
Row(GameOptionTab.Display, "High dynamic range", "HDR", 0, 2, 1, 0, GameOptionKind.Choice, TxHdr, false, true,
|
||||
"HDR10 out on an HDR display (Windows: Use HDR on in the display settings). Expanded: the game's SDR picture, its white at the paper white and its highlights up to the peak. Native: the game's own HDR, told the display's peak and paper white."),
|
||||
Row(GameOptionTab.Display, "High dynamic range", "HDR paper white", 80, 400, 10, 200, GameOptionKind.Slider, TxNits, false, true,
|
||||
"How bright the picture's white is with HDR on. Around 200 for a normal room; higher in a bright one."),
|
||||
Row(GameOptionTab.Display, "High dynamic range", "HDR peak brightness", 400, 10000, 100, 1000, GameOptionKind.Slider, TxNits, false, true,
|
||||
"The brightest highlights with HDR on: set it to your display's peak brightness."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX HDR", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, true, true,
|
||||
"With HDR set to Native: RenoDX's tone mapping, eye adaptation and color grading in place of the game's own, and its rows below. Off: the game's own HDR. Applies after a restart. RenoDX is by Carlos Lopez (clshortfuse), under the MIT license."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX tonemapper", 0, 2, 1, 1, GameOptionKind.Choice, TxRdxTonemap, false, true,
|
||||
"With HDR Native: how the scene's light is brought to the display. Vanilla: the game's own curve. PsychoV35: RenoDX's, which keeps hue and saturation into the highlights, up to the peak brightness. RenoDRT: RenoDX's, which carries the game's SDR look up to the peak by brightness. RenoDX is by Carlos Lopez (clshortfuse), under the MIT license."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX gamma correction", 0, 2, 1, 0, GameOptionKind.Choice, TxRdxGamma, false, true,
|
||||
"Shows the picture as a 2.2 or BT.1886 (2.4) display would, as the game was made to be seen: darker shadows. Off keeps the sRGB curve. With every tonemapper. PsychoV35 and RenoDRT still end at the peak brightness; Vanilla's highlights are the game's own, which 2.2 dims a little and 2.4 brightens a little."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX midgray", 0, 2, 1, 1, GameOptionKind.Choice, TxRdxMidgray, false, true,
|
||||
"With PsychoV35: what the scene's middle grey is held to. Render: as rendered. Vanilla: where the game's own curve puts it. Eye adaptation: it follows what is on screen over a few seconds, weighted towards the middle of the view, as eyes adjust."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX match tone slope", 0, 1, 1, 1, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"With PsychoV35: gives the mid tones the contrast of the game's own curve. Off: PsychoV35's own, softer."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX tone slope", 0, 100, 1, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"With PsychoV35: the steepness of the tone curve through middle grey. 50 leaves it unchanged."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX hue clip", 0, 100, 5, 50, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"With PsychoV35: how much bright colors turn as they do where the game's SDR picture clips: fire towards yellow and white. 0% keeps their hue."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX UI brightness", 80, 400, 10, 200, GameOptionKind.Slider, TxNits, false, true,
|
||||
"How bright the menus' and the HUD's white is with RenoDX's tonemapper. The scene's follows HDR paper white."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX color space", 0, 2, 1, 1, GameOptionKind.Choice, TxRdxSpace, false, true,
|
||||
"The colors the picture is taken to be in before HDR10's. Vanilla: the game's own matrix. BT.709: as the SDR picture. DCI-P3: more saturated."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX exposure", 0, 200, 5, 100, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"The scene's brightness before RenoDX's tone mapping. 100% is the game's."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX highlights", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"RenoDX's color grading: the bright parts of the scene. 50 is neutral."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX shadows", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"RenoDX's color grading: the dark parts of the scene. 50 is neutral."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX contrast", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"RenoDX's color grading: the scene's contrast. 50 is neutral."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX saturation", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"RenoDX's color grading: the scene's saturation. 50 is neutral."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX highlight saturation", 0, 100, 1, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"With RenoDRT: the strength of the colors of the brightest parts. 50 leaves it unchanged."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX blowout", 0, 100, 1, 0, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"With RenoDRT: turns the brightest parts towards white. 0 keeps their color."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX flare", 0, 100, 1, 0, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"With RenoDRT: lifts the darkest parts as a little stray light would. 0 keeps black black."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX hue correction", 0, 100, 5, 100, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"With RenoDRT: how much bright colors keep the hue they have before the tonemapper. 0% lets them shift as the curve takes them."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX color grading", 0, 100, 5, 100, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"With RenoDRT: how much of the game's own color grading the HDR picture keeps. 0% is the scene without it."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "RenoDX bloom", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"How strong the glow around bright things is. 50 is the game's."),
|
||||
Row(GameOptionTab.Graphics, "Quality", "Quality preset", 0, 5, 1, 0, GameOptionKind.Choice, TxPreset, false, false,
|
||||
"Sets the scaling rows and memory limits for a GPU with that much memory. The Upscaler and Frame generation stay yours."),
|
||||
Row(GameOptionTab.Graphics, "Quality", "Render resolution", 0, 6, 1, 0, GameOptionKind.Choice, TxResolution, true, false,
|
||||
"The share of the output the 3D is drawn at; the Upscaler fills in the rest. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Quality", "Texture detail", 0, 3, 1, 0, GameOptionKind.Choice, TxTexDetail, true, false,
|
||||
"How large the game's textures are kept in video memory. Automatic suits the graphics card; a Quality preset sets it for its card's size. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Quality", "Texture filtering", 0, 4, 1, 0, GameOptionKind.Choice, TxAniso, false, false,
|
||||
"Anisotropic filtering: keeps ground, paths and walls sharp where they slope away from the camera. Game's is what the game asks for; 16x is the sharpest, at a small cost."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling and edges", "Upscaler", 0, 6, 1, 0, GameOptionKind.Choice, TxUpscaler, false, false,
|
||||
"What scales the 3D up to the Output resolution."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling and edges", "DLSS model", 0, 3, 1, 0, GameOptionKind.Choice, TxDlssModel, false, true,
|
||||
Row(GameOptionTab.Display, "Ultrawide", "Aspect ratio", 0, 3, 1, 0, GameOptionKind.Choice, TxUltrawide, true, false,
|
||||
"The shape of the picture: the game's own 16:9, or 16:10, 21:9 or 32:9 for a screen of that shape. A screen of another shape shows it between black bars. Applies after a restart."),
|
||||
Row(GameOptionTab.Display, "Ultrawide", "HUD position", 0, 1, 1, 0, GameOptionKind.Choice, TxWideHud, true, true,
|
||||
"Where the hearts, the item buttons and the map sit. Middle: in the middle 16:9, as on a normal screen. Screen edges: in the screen's corners. Applies after a restart."),
|
||||
Row(GameOptionTab.Display, "Ultrawide", "Menu sides", 0, 2, 1, 1, GameOptionKind.Choice, TxWideMenus, false, false,
|
||||
"What is beside the pause, item and map menus, loading screens and movies, which are 16:9. Changes at once."),
|
||||
Merged(GameOptionTab.Display, "HDR", "HDR", 0, 3, 1, MergeHdr, TxHdrMode, true, true,
|
||||
"HDR10 on an HDR display (Windows: Use HDR on in the display settings). Native + RenoDX applies after a restart."),
|
||||
Row(GameOptionTab.Display, "HDR", "Paper white", 80, 400, 10, 200, GameOptionKind.Slider, TxNits, false, true,
|
||||
"How bright white is: around 200 nits for a normal room, higher for a bright one."),
|
||||
Row(GameOptionTab.Display, "HDR", "Peak brightness", 400, 10000, 100, 1000, GameOptionKind.Slider, TxNits, false, true,
|
||||
"The brightest highlights: set it to your display's peak brightness."),
|
||||
Row(GameOptionTab.Display, "HDR", "UI brightness", 80, 400, 10, 200, GameOptionKind.Slider, TxNits, false, true,
|
||||
"How bright the HUD's and the menus' white is with RenoDX. The scene's white is Paper white."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Tonemapper", 0, 2, 1, 1, GameOptionKind.Choice, TxRdxTonemap, false, true,
|
||||
"How the scene's light is brought to the display. Vanilla: the game's own curve. PsychoV35: keeps hue and saturation into the highlights. RenoDRT: carries the game's SDR look up to the peak brightness."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Gamma correction", 0, 2, 1, 0, GameOptionKind.Choice, TxRdxGamma, false, true,
|
||||
"Shows the picture as a 2.2 or BT.1886 (2.4) display would, as the game was made to be seen: darker shadows. Off keeps the sRGB curve."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Color space", 0, 2, 1, 1, GameOptionKind.Choice, TxRdxSpace, false, true,
|
||||
"The colors the picture is taken to be in. Vanilla: the game's own. BT.709: as the SDR picture. DCI-P3: more saturated."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Exposure", 0, 200, 5, 100, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"The scene's brightness before tone mapping. 100% is the game's."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Middle gray", 0, 2, 1, 1, GameOptionKind.Choice, TxRdxMidgray, false, true,
|
||||
"What the scene's middle gray is held to. Render: as rendered. Vanilla: where the game's curve puts it. Eye adaptation: it follows what is on screen over a few seconds."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Match tone slope", 0, 1, 1, 1, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"PsychoV35: the mid tones get the contrast of the game's own curve. Off: PsychoV35's own, softer."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Tone slope", 0, 100, 1, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"PsychoV35: how steep the tone curve is through middle gray. 50 leaves it unchanged."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Hue clip", 0, 100, 5, 50, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"PsychoV35: how much bright colors turn as they do where the SDR picture clips, fire towards yellow and white. 0% keeps their hue."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Highlight saturation", 0, 100, 1, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"RenoDRT: how strong the colors of the brightest parts are. 50 leaves them unchanged."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Blowout", 0, 100, 1, 0, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"RenoDRT: turns the brightest parts towards white. 0 keeps their color."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Flare", 0, 100, 1, 0, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"RenoDRT: lifts the darkest parts as a little stray light would. 0 keeps black black."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Hue correction", 0, 100, 5, 100, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"RenoDRT: how much bright colors keep the hue they had before tone mapping."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Color grading", 0, 100, 5, 100, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"RenoDRT: how much of the game's own color grading is kept. 0% is the scene without it."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Highlights", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"The bright parts of the scene. 50 is neutral."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Shadows", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"The dark parts of the scene. 50 is neutral."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Contrast", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"The scene's contrast. 50 is neutral."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Saturation", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"The scene's color. 50 is neutral."),
|
||||
Row(GameOptionTab.Display, "RenoDX", "Bloom", 0, 100, 5, 50, GameOptionKind.Slider, TxRdxGrade, false, true,
|
||||
"The glow around bright things. 50 is the game's. RenoDX is by Carlos Lopez (clshortfuse), under the MIT license."),
|
||||
Row(GameOptionTab.Display, "Overlay", "FPS counter", 0, 2, 1, 0, GameOptionKind.Choice, TxPerf, false, true,
|
||||
"Frames per second in the top right corner. Full: a performance panel in its place: the GPU's and the CPU's load, temperatures and memory, the frame rate and its lows, the frame times and their graph, the waits per frame and the picture's settings."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling", "Upscaler", 0, 6, 1, 0, GameOptionKind.Choice, TxUpscaler, false, false,
|
||||
"What draws the 3D up to the Output resolution."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling", "DLSS model", 0, 3, 1, 0, GameOptionKind.Choice, TxDlssModel, false, true,
|
||||
"Which of NVIDIA's DLSS networks draws the picture."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling and edges", "Upscale before bloom", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, true, true,
|
||||
"With NVIDIA DLSS, DLAA or AMD FSR as the Upscaler: On, it works on the scene before the game's glow and tone mapping, so both are made from the sharpened scene. Off: on the finished picture, as before. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling and edges", "Anti-aliasing", 0, 3, 1, 0, GameOptionKind.Choice, TxAa, false, true,
|
||||
"How the 3D's edges are smoothed before it is scaled up: by the game's own SMAA, not at all, by FXAA, or by SMAA at its Ultra preset. Changes at once."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling and edges", "Sharpness", 0, 100, 10, 0, GameOptionKind.Slider, TxPercent, false, false,
|
||||
"Sharpens the picture as it goes to the window, with any filter. Too much shows halos around edges."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling and edges", "Window scaling filter", 0, 3, 1, 0, GameOptionKind.Choice, TxFilter, false, false,
|
||||
"How the finished picture is scaled to the window, when its size differs from the Output resolution."),
|
||||
Row(GameOptionTab.Graphics, "Smoothness", "Frame generation", 0, 9, 1, 0, GameOptionKind.Choice, TxFramegen, false, true,
|
||||
"Makes frames between the game's own, for smoother motion, at a little input delay. Fast motion or camera cuts can show artifacts."),
|
||||
Row(GameOptionTab.Graphics, "Smoothness", "DLSS frame generation", 0, 3, 1, 0, GameOptionKind.Choice, TxDlssg, true, true,
|
||||
"NVIDIA RTX 40 and 50 cards: frames made between the game's own by NVIDIA DLSS, from the scene's depth and motion, with NVIDIA Reflex. The Frame generation row above is not used with it. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Smoothness", "Frame pacing", 0, 1, 1, 1, GameOptionKind.Choice, TxOnoff, false, false,
|
||||
"When each frame is shown."),
|
||||
Row(GameOptionTab.Graphics, "Latency", "NVIDIA Reflex", 0, 2, 1, 2, GameOptionKind.Choice, TxReflex, false, false,
|
||||
"NVIDIA GPUs: each frame starts as late as it can, for less input delay. With DLSS frame generation it runs through NVIDIA Streamline; not used with the other frame generation."),
|
||||
Row(GameOptionTab.Graphics, "Latency", "AMD Anti-Lag 2", 0, 1, 1, 0, GameOptionKind.Choice, TxAntilag, false, false,
|
||||
"AMD GPUs: each frame starts as late as it can, for less input delay. Not used with frame generation."),
|
||||
Row(GameOptionTab.Graphics, "Advanced", "Handheld profile", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, true, false,
|
||||
"Runs the game as if the console were undocked. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Advanced", "Robust buffers", 0, 2, 1, 1, GameOptionKind.Choice, TxRobust, true, false,
|
||||
"Bounds-checked buffer reads: a read past a buffer's end is dropped instead of stopping the GPU. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling", "Render resolution", 0, 6, 1, 0, GameOptionKind.Choice, TxResolution, true, false,
|
||||
"The size the 3D is drawn at; the upscaler fills in the rest. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling", "Upscale before bloom", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, true, true,
|
||||
"On: the upscaler works on the scene before the game's glow and tone mapping, which are then made at full size. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Upscaling", "Sharpness", 0, 100, 10, 0, GameOptionKind.Slider, TxPercent, false, false,
|
||||
"With DLSS, DLAA or AMD FSR as the Upscaler, the 3D before the HUD (FSR's own sharpening; AMD's RCAS for DLSS); with the game's own upscaler, the picture at the window. 0 is off. Too much shows halos around edges."),
|
||||
Row(GameOptionTab.Graphics, "Anti-aliasing", "Anti-aliasing", 0, 3, 1, 0, GameOptionKind.Choice, TxAa, false, true,
|
||||
"How the 3D's edges are smoothed: the game's own SMAA, none, FXAA, or SMAA at its Ultra preset. Changes at once."),
|
||||
Merged(GameOptionTab.Graphics, "Frame generation", "Frame generation", 0, 12, 1, MergeFramegen, TxFramegenRow, true, true,
|
||||
"Makes frames between the game's own, for smoother motion, at a little input delay. Fast motion and camera cuts can show artifacts. NVIDIA DLSS applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Frame rate & latency", "Frame rate cap", -3, 6, 1, 0, GameOptionKind.Choice, TxFpsCap, true, true,
|
||||
"The most frames the game renders a second; made frames come on top. 60 is the safe choice: past it some cutscenes and bosses can misbehave. 30, 40 and 45 are for a PC that holds one of them where 60 swings. Monitor's rate: the refresh rate of the screen the game starts on. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Frame rate & latency", "VSync", 0, 1, 1, 1, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Whether a finished frame waits for the screen's next refresh. Off: a little less delay, and the picture can tear. Changes at once."),
|
||||
Merged(GameOptionTab.Graphics, "Frame rate & latency", "Frame pacing", 0, 3, 1, MergePacing, TxPacing, true, false,
|
||||
"When each frame is shown. Steady paces the game to a rate this PC holds where you are: steadier, at some frame rate."),
|
||||
Merged(GameOptionTab.Graphics, "Frame rate & latency", "Low latency", 0, 2, 1, MergeLatency, TxLatency, false, false,
|
||||
"Each frame starts as late as it can, for less input delay: NVIDIA Reflex on NVIDIA cards, AMD Anti-Lag 2 on AMD ones."),
|
||||
Row(GameOptionTab.Graphics, "Textures", "Texture filtering", 0, 4, 1, 0, GameOptionKind.Choice, TxAniso, false, false,
|
||||
"Keeps ground, paths and walls sharp where they slope away from the camera. Game: what the game asks for; 16x is the sharpest, at a small cost."),
|
||||
Row(GameOptionTab.Graphics, "Textures", "Texture detail", 0, 3, 1, 0, GameOptionKind.Choice, TxTexDetail, true, false,
|
||||
"How large the game's textures are kept in video memory. Automatic suits the graphics card. Applies after a restart."),
|
||||
Row(GameOptionTab.Graphics, "Advanced", "Mesh shaders", 0, 1, 1, 0, GameOptionKind.Choice, TxMesh, true, false,
|
||||
"How the game's mesh-shader draws run. Try Compute fallback on an AMD card that shows glowing walls or loses the GPU. Applies after a restart."),
|
||||
Row(GameOptionTab.System, "Game", "Game speed", 0, 1, 1, 1, GameOptionKind.Choice, TxSpeed, false, false,
|
||||
"How the game keeps time when it runs below 60 fps."),
|
||||
Row(GameOptionTab.System, "Game", "Text speed", 0, 3, 1, 0, GameOptionKind.Choice, TxTextSpeed, false, false,
|
||||
"How fast the letters of dialogue and other messages appear."),
|
||||
Row(GameOptionTab.System, "Game", "Discord status", 0, 1, 1, 1, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Shows \"Playing Triforce\" and the time played in your Discord status, while Discord runs on this PC."),
|
||||
Row(GameOptionTab.Audio, null, "Master volume", 0, 100, 5, 100, GameOptionKind.Slider, TxVolume, false, true,
|
||||
"How loud the game is, in percent of its own volume. The game's sounds and music keep their balance."),
|
||||
Row(GameOptionTab.Audio, null, "Menu sounds", 0, 100, 5, 80, GameOptionKind.Slider, TxMenuSounds, false, true,
|
||||
"How loud these options' own sounds are: the game's interface sounds, played from your game files as you move through the tabs and rows. Off is silent. The Master volume is over them too."),
|
||||
Row(GameOptionTab.Audio, null, "Audio output", 0, 2, 1, 0, GameOptionKind.Choice, TxAudioOutput, true, true,
|
||||
Row(GameOptionTab.System, "Game", "Game speed", 0, 1, 1, 1, GameOptionKind.Choice, TxSpeed, false, false,
|
||||
"How the game keeps time when it runs below 60 fps."),
|
||||
Row(GameOptionTab.Audio, "Sound", "Master volume", 0, 100, 5, 100, GameOptionKind.Slider, TxVolume, false, true,
|
||||
"How loud the game is, in percent of its own volume."),
|
||||
Row(GameOptionTab.Audio, "Sound", "Menu sounds", 0, 100, 5, 80, GameOptionKind.Slider, TxMenuSounds, false, true,
|
||||
"How loud these options' own sounds are, the game's interface sounds from your game files."),
|
||||
Row(GameOptionTab.Audio, "Sound", "Audio output", 0, 2, 1, 0, GameOptionKind.Choice, TxAudioOutput, true, true,
|
||||
"The speakers the game mixes its sound for. Applies after a restart."),
|
||||
Row(GameOptionTab.Audio, null, "Microphone", 0, 18, 1, 1, GameOptionKind.Choice, TxMic, false, true,
|
||||
Row(GameOptionTab.Audio, "Microphone", "Microphone", 0, 18, 1, 1, GameOptionKind.Choice, TxMic, false, true,
|
||||
"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming)."),
|
||||
Row(GameOptionTab.Controls, "Camera", "Camera speed", 25, 300, 5, 100, GameOptionKind.Slider, TxSens, true, true,
|
||||
"How fast the right stick turns the camera: times the game's own speed, at any Camera sensitivity of the game's Options. The mouse keeps its own sensitivity. Applies after a restart."),
|
||||
Row(GameOptionTab.Controls, "Camera", "Invert camera X", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Inverts horizontal look (left/right) on the right analog stick."),
|
||||
Row(GameOptionTab.Controls, "Camera", "Invert camera Y", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Inverts vertical look (up/down) on the right analog stick."),
|
||||
Row(GameOptionTab.Controls, "Camera", "Mouse camera", 0, 1, 1, 0, GameOptionKind.Choice, TxMousecam, false, true,
|
||||
"How the captured mouse turns the camera."),
|
||||
Row(GameOptionTab.Controls, "Camera", "Mouse sensitivity", 10, 500, 10, 100, GameOptionKind.Slider, TxSens, false, true,
|
||||
"How far the camera turns for a mouse movement, with either Mouse camera: at 1.00 native look turns 0.1 degree a count. The - and = keys change it in game too."),
|
||||
Row(GameOptionTab.Controls, "Camera", "Invert mouse vertical", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Swaps up and down for the mouse."),
|
||||
Row(GameOptionTab.Controls, "Sticks", "Stick dead zone", 0, 5, 1, 0, GameOptionKind.Choice, TxStickDeadZone, false, true,
|
||||
"How far a stick moves before the game sees it, on each axis. Lower for a precise stick, higher for one that drifts. The game's own dead zone still follows."),
|
||||
Row(GameOptionTab.Controls, "Sticks", "Left stick dead zone", -1, 50, 1, -1, GameOptionKind.Slider, TxOwnDeadZone, false, true,
|
||||
"The left stick's own dead zone, in percent of its travel on each axis, in place of Stick dead zone: a worn stick can have a larger one than the other. 0% cuts nothing; the game's own dead zone still follows."),
|
||||
Row(GameOptionTab.Controls, "Sticks", "Right stick dead zone", -1, 50, 1, -1, GameOptionKind.Slider, TxOwnDeadZone, false, true,
|
||||
"The right stick's own dead zone, in percent of its travel on each axis, in place of Stick dead zone: a worn stick can have a larger one than the other. 0% cuts nothing; the game's own dead zone still follows."),
|
||||
Row(GameOptionTab.Controls, "Movement", "Sprint button", 0, 2, 1, 0, GameOptionKind.Choice, TxSprint, false, true,
|
||||
"Link sprints from a button press, without rolling first. Left stick click: the game has no other use for it. B: sprints only while Link moves, and puts the weapon away as usual otherwise (with the game's Swap Jump Controls B is the jump: use the stick's click)."),
|
||||
Row(GameOptionTab.Controls, "Movement", "Sprint mode", 0, 1, 1, 0, GameOptionKind.Choice, TxSprintMode, false, true,
|
||||
"Toggle: a press starts the sprint and the next press, or stopping, ends it. Hold: Link sprints while the button is held."),
|
||||
Row(GameOptionTab.Controls, "Movement", "Walk key", 0, 4, 1, 0, GameOptionKind.Choice, TxWalkKey, false, true,
|
||||
"A key that makes Link walk on the keyboard: held with the movement keys, they push the left stick only as far as Walk scale. While it is chosen the key presses nothing else."),
|
||||
Row(GameOptionTab.Controls, "Movement", "Walk scale", 20, 90, 1, 51, GameOptionKind.Slider, TxSens, false, true,
|
||||
"How far the movement keys push the left stick while the Walk key is held: 1.00 would be all the way, lower walks slower. A controller's stick and the camera's keys are not changed."),
|
||||
Row(GameOptionTab.Controls, "Vibration", "Rumble strength", 0, 300, 25, 100, GameOptionKind.Slider, TxRumble, false, true,
|
||||
"How strongly the controller rumbles, in percent of the game's rumble. Off turns it off. Over 100% a rumble that would pass the motors' full strength stops there."),
|
||||
Row(GameOptionTab.Controls, "Vibration", "Vibration curve", 20, 150, 5, 100, GameOptionKind.Slider, TxSens, false, true,
|
||||
"Shapes the rumble of a controller's two motors. 1.00 is the game's. Lower lifts the many weak rumbles so they can be felt and hardly changes the strong ones; higher quiets them. A Switch controller's HD rumble is not changed by it."),
|
||||
Row(GameOptionTab.Controls, "Vibration", "Trigger vibration", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Xbox One and Series controllers: the motors in the triggers rumble too, with the lighter of the two motors. Controllers without them rumble as before."),
|
||||
Row(GameOptionTab.Controls, "Other", "Controller in background", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, false,
|
||||
Row(GameOptionTab.System, "Online", "Discord status", 0, 1, 1, 1, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Shows \"Playing Triforce\" and the time played in your Discord status, while Discord runs on this PC."),
|
||||
Row(GameOptionTab.Controls, "Controller", "Controller in background", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, false,
|
||||
"Whether the controller plays the game while another window has the focus."),
|
||||
Row(GameOptionTab.Controls, "Other", "Menu shortcut", 0, 1, 1, 0, GameOptionKind.Choice, TxMenuShortcut, false, true,
|
||||
Row(GameOptionTab.Controls, "Controller", "Left stick dead zone", -1, 50, 1, -1, GameOptionKind.Slider, TxOwnDeadZone, false, true,
|
||||
"How far the left stick moves before the game sees it, in percent of its travel on each axis: lower for a precise stick, higher for one that drifts. The game's own dead zone still follows."),
|
||||
Row(GameOptionTab.Controls, "Controller", "Right stick dead zone", -1, 50, 1, -1, GameOptionKind.Slider, TxOwnDeadZone, false, true,
|
||||
"How far the right stick moves before the game sees it, in percent of its travel on each axis: lower for a precise stick, higher for one that drifts. The game's own dead zone still follows."),
|
||||
Row(GameOptionTab.Controls, "Controller", "Camera speed", 25, 300, 5, 100, GameOptionKind.Slider, TxSens, true, true,
|
||||
"How fast the right stick turns the camera, times the game's own speed. Applies after a restart."),
|
||||
Row(GameOptionTab.Controls, "Controller", "Invert camera X", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Swaps left and right for the right stick's camera."),
|
||||
Row(GameOptionTab.Controls, "Controller", "Invert camera Y", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Swaps up and down for the right stick's camera."),
|
||||
Row(GameOptionTab.Controls, "Mouse & keyboard", "Mouse camera", 0, 1, 1, 0, GameOptionKind.Choice, TxMousecam, false, true,
|
||||
"How the captured mouse turns the camera."),
|
||||
Row(GameOptionTab.Controls, "Mouse & keyboard", "Mouse sensitivity", 10, 500, 10, 100, GameOptionKind.Slider, TxSens, false, true,
|
||||
"How far the camera turns for a mouse movement. The - and = keys change it in game too."),
|
||||
Row(GameOptionTab.Controls, "Mouse & keyboard", "Invert mouse vertical", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Swaps up and down for the mouse."),
|
||||
Row(GameOptionTab.Controls, "Mouse & keyboard", "Walk key", 0, 4, 1, 0, GameOptionKind.Choice, TxWalkKey, false, true,
|
||||
"A key that makes Link walk: held with the movement keys, they push the stick only as far as Walk scale. While it is chosen the key presses nothing else."),
|
||||
Row(GameOptionTab.Controls, "Mouse & keyboard", "Walk scale", 20, 90, 1, 51, GameOptionKind.Slider, TxSens, false, true,
|
||||
"How far the movement keys push the stick while the Walk key is held: 1.00 would be all the way."),
|
||||
Row(GameOptionTab.Controls, "Mouse & keyboard", "Menu shortcut", 0, 1, 1, 0, GameOptionKind.Choice, TxMenuShortcut, false, true,
|
||||
"Which keys open and close these options from anywhere. F1 always does; F1 only leaves Insert free for an overlay."),
|
||||
Row(GameOptionTab.Controls, "Rumble", "Rumble strength", 0, 300, 25, 100, GameOptionKind.Slider, TxRumble, false, true,
|
||||
"How strongly the controller rumbles, in percent of the game's rumble. Off turns it off."),
|
||||
Row(GameOptionTab.Controls, "Rumble", "Vibration curve", 20, 150, 5, 100, GameOptionKind.Slider, TxSens, false, true,
|
||||
"Shapes the rumble: 1.00 is the game's. Lower makes the many weak rumbles easier to feel; higher quiets them. A Switch controller's HD rumble is not changed."),
|
||||
Row(GameOptionTab.Controls, "Rumble", "Trigger vibration", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Xbox One and Series controllers: the motors in the triggers rumble too."),
|
||||
Row(GameOptionTab.Controls, "Gameplay", "Sprint button", 0, 2, 1, 0, GameOptionKind.Choice, TxSprint, false, true,
|
||||
"Link sprints from a button press, without rolling first. Left stick click: the game has no other use for it. B: sprints while Link moves (with the game's Swap Jump Controls B is the jump: use the stick's click)."),
|
||||
Row(GameOptionTab.Controls, "Gameplay", "Sprint mode", 0, 1, 1, 0, GameOptionKind.Choice, TxSprintMode, false, true,
|
||||
"Toggle: a press starts the sprint, the next press or stopping ends it. Hold: Link sprints while the button is held."),
|
||||
Row(GameOptionTab.Controls, "Motion", "Motion controls", 0, 1, 1, 1, GameOptionKind.Choice, TxGyro, false, true,
|
||||
"Aims and looks with the controller's gyroscope where the game uses motion, as on the Switch. Works with Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. Shown beside it: whether the connected pad has one."),
|
||||
"Aims and looks with the controller's gyroscope where the game uses motion, as on the Switch: Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4."),
|
||||
Row(GameOptionTab.Controls, "Motion", "Motion sensitivity X", 10, 600, 10, 100, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"How far the aim moves left and right for a given turn of the controller. 100% is the console's own."),
|
||||
"How far the aim moves left and right for a turn of the controller. 100% is the console's."),
|
||||
Row(GameOptionTab.Controls, "Motion", "Motion sensitivity Y", 10, 300, 10, 100, GameOptionKind.Slider, TxPercent, false, true,
|
||||
"How far the aim moves up and down for a given tilt of the controller. 100% is the console's own."),
|
||||
"How far the aim moves up and down for a tilt of the controller. 100% is the console's."),
|
||||
Row(GameOptionTab.Controls, "Motion", "Invert motion X", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Turns the motion aim's left and right around."),
|
||||
"Swaps the motion aim's left and right."),
|
||||
Row(GameOptionTab.Controls, "Motion", "Invert motion Y", 0, 1, 1, 0, GameOptionKind.Choice, TxOnoff, false, true,
|
||||
"Turns the motion aim's up and down around."),
|
||||
"Swaps the motion aim's up and down."),
|
||||
Row(GameOptionTab.Controls, "Motion", "Motion deadzone", 0, 2, 1, 1, GameOptionKind.Choice, TxDeadzone, false, true,
|
||||
"How slow a turn counts as none, the console's three settings: Standard is its own. High steadies a pad that jitters when held still; Low keeps the smallest movements."),
|
||||
"How slow a turn counts as none, the console's three settings: Standard is its own. High steadies a pad that jitters; Low keeps the smallest movements."),
|
||||
Row(GameOptionTab.Controls, "Controls", "Button prompts", 0, 6, 1, 0, GameOptionKind.Choice, TxPrompts, true, true,
|
||||
"The button icons the game shows, in its texts and menus: those of this controller, or the keyboard's and the mouse's, for the buttons or keys your controls put each action on."),
|
||||
"The button icons the game shows in its texts and menus: those of this controller, or the keyboard's and the mouse's."),
|
||||
};
|
||||
|
||||
static readonly Dictionary<string, GameOptionRow> byKey = All.ToDictionary(r => r.Key, StringComparer.Ordinal);
|
||||
static readonly Dictionary<string, GameOptionRow> byName = All.ToDictionary(r => r.Name, StringComparer.Ordinal);
|
||||
|
||||
/// <summary>The row of a triforce_options.ini key (exact, as the game compares them), null for any other key.</summary>
|
||||
/// <summary>The row of a key (a triforce_options.ini key, exact as the game compares them, or a merged row's own '@' key),
|
||||
/// null for any other key. A merged row's parts' keys are no row's: Part has them.</summary>
|
||||
public static GameOptionRow? ByKey(string key) => byKey.GetValueOrDefault(key);
|
||||
/// <summary>The row of a key; KeyNotFoundException for a key no row has.</summary>
|
||||
public static GameOptionRow Get(string key) => ByKey(key) ?? throw new KeyNotFoundException("no Options row has the key " + key);
|
||||
@@ -467,8 +542,14 @@ public static class GameOptionsSchema
|
||||
public static GameOptionRow? ByName(string name) => byName.GetValueOrDefault(name);
|
||||
/// <summary>A tab's rows, in order.</summary>
|
||||
public static IReadOnlyList<GameOptionRow> RowsOf(GameOptionTab tab) => All.Where(r => r.Tab == tab).ToList();
|
||||
/// <summary>A tab's sections that have rows here, in order (Audio has none: its rows' Section is null).</summary>
|
||||
/// <summary>A tab's sections that have rows here, in order.</summary>
|
||||
public static IReadOnlyList<string> Sections(GameOptionTab tab) => RowsOf(tab).Select(r => r.Section).OfType<string>().Distinct().ToList();
|
||||
/// <summary>A key the launcher reads and writes as a value of its own line: a row's (not a merged row's), or a merged
|
||||
/// row's part.</summary>
|
||||
public static bool IsValueKey(string key) => ByKey(key) is { IsMerged: false } || Parts.ContainsKey(key);
|
||||
/// <summary>The row a file key belongs to: its own row, or the merged row a part is of (null for any other key).</summary>
|
||||
public static GameOptionRow? RowOfLine(string key) =>
|
||||
ByKey(key) is { IsMerged: false } r ? r : All.FirstOrDefault(m => m.Parts?.Any(p => p.Key == key) == true);
|
||||
|
||||
// ---- the keys of the file that are not rows here ----
|
||||
|
||||
@@ -476,7 +557,7 @@ public static class GameOptionsSchema
|
||||
/// Besides these: every pad_* and key_* line (KeptPrefixes).</summary>
|
||||
public static readonly IReadOnlyDictionary<string, string> KeptKeys = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
[VersionKey] = "the file's format: the rules the game reads an older file by (GameOptionsFile.Save writes 7 when it brings an older file up to date)",
|
||||
[VersionKey] = "the file's format: the rules the game reads an older file by (GameOptionsFile.Save writes 8 when it brings an older file up to date)",
|
||||
[MicDeviceKey] = "the Microphone row's device, by its name: the game's to choose from the devices it lists",
|
||||
[GpuNameKey] = "the GPU device row's card by its name (11-20): Save writes it with the row; the game finds the card by it first",
|
||||
["layout_preset"] = "the Controls page's Layout preset: choosing one in the game rebinds the pad_ lines, which a changed value alone would not do",
|
||||
@@ -488,6 +569,12 @@ public static class GameOptionsSchema
|
||||
["replay_helper_threads"] = "the Debug tab's Developer rows (not ported)",
|
||||
["tail_early"] = "the Debug tab's Start next frame early (not ported)",
|
||||
["opaque_textures_as_bc1"] = "the Debug tab's Developer rows (not ported)",
|
||||
["robust_buffers"] = "the Debug tab's Developer rows from options_version 8, the Graphics tab's before (not ported)",
|
||||
["quality_preset"] = "a row gone in options_version 8 (merged_rows.h kDropped: its memory limits are the card's own): the game reads nothing from it and drops the line at its next save",
|
||||
["upscaling"] = "the Window scaling filter, gone in options_version 8 (the sizes choose the filter: upscaler_rows.h auto_filter): dropped at the game's next save",
|
||||
["reflex_frame_limit"] = "a row gone in options_version 8 (off, its old default): dropped at the game's next save",
|
||||
["handheld_profile"] = "a row gone in options_version 8: a file before 8 with it on gets the Output resolution's 1536x864 (handheld) once (GameOptionsFile), then the game drops the line",
|
||||
["stick_dead_zone"] = "a row gone in options_version 8: a file before 8 gets its share in each stick's own dead zone that had none (GameOptionsFile), then the game drops the line",
|
||||
["menu_size"] = "the old Menu size row, gone from the menu (the game's menus have one size): the game keeps the line and reads nothing from it",
|
||||
["dynamic_resolution"] = "the Render resolution's old key: read once by the game where the file has no resolution line",
|
||||
["debug_tab"] = "an old line (Alt+G's Debug tab): the game drops it at its next save",
|
||||
@@ -496,43 +583,10 @@ public static class GameOptionsSchema
|
||||
};
|
||||
/// <summary>The binding lines of the Controls page's grid: pad_<button>=<input> and key_<button>=<key>,<key>.</summary>
|
||||
public static readonly IReadOnlyList<string> KeptPrefixes = new[] { "pad_", "key_" };
|
||||
/// <summary>A key that is not a row here but is known (KeptKeys, KeptPrefixes): kept in the file as it is.</summary>
|
||||
/// <summary>A key that is not a value here but is known (KeptKeys, KeptPrefixes): kept in the file as it is.</summary>
|
||||
public static bool IsKept(string key) => KeptKeys.ContainsKey(key) || KeptPrefixes.Any(p => key.StartsWith(p, StringComparison.Ordinal));
|
||||
|
||||
// ---- the Quality preset ----
|
||||
|
||||
/// <summary>What each Quality preset sets (vk_menu.cpp apply_preset), in the menu's own words (hn_preset).</summary>
|
||||
public static readonly IReadOnlyList<string> PresetSummaries = new[]
|
||||
{
|
||||
"Each row as you set it. Changing most rows yourself comes back to Custom.",
|
||||
"Resolution 50% (with DLSS its nearest mode), Lanczos, Sharpness 30%, Handheld profile.",
|
||||
"Resolution 75% (with DLSS its nearest mode), Lanczos, Sharpness 30%, Handheld profile.",
|
||||
"Resolution 100% (with DLSS its nearest mode), Catmull-Rom, Sharpness 30%.",
|
||||
"Resolution 100% (with DLSS its nearest mode), Lanczos, Sharpness 40%.",
|
||||
"Resolution 100% (with DLSS its nearest mode), Lanczos, Sharpness 50%.",
|
||||
};
|
||||
|
||||
/// <summary>The rows a Quality preset sets and their values (apply_preset): the Render resolution (then moved to the
|
||||
/// Upscaler's nearest step: GameOptionsFile.Set does that), the Window scaling filter, Sharpness, Frame pacing, Game speed,
|
||||
/// the Handheld profile and the Texture detail. Custom (0) sets nothing. The Upscaler and Frame generation stay the
|
||||
/// player's. (The game also sets its memory budgets from the preset; they are not kept in the file.)</summary>
|
||||
public static IReadOnlyDictionary<string, int> PresetValues(int preset)
|
||||
{
|
||||
var (res, filter, sharp, handheld) = preset switch
|
||||
{
|
||||
1 => (4, 2, 30, 1),
|
||||
2 => (2, 2, 30, 1),
|
||||
3 => (1, 1, 30, 0),
|
||||
4 => (1, 2, 40, 0),
|
||||
5 => (1, 2, 50, 0),
|
||||
_ => (-1, 0, 0, 0),
|
||||
};
|
||||
if (res < 0) return new Dictionary<string, int>();
|
||||
int[] detail = { 0, 3, 2, 1, 1, 1 };
|
||||
return new Dictionary<string, int>(StringComparer.Ordinal)
|
||||
{
|
||||
[ResolutionKey] = res, ["upscaling"] = filter, ["sharpness"] = sharp, ["frame_pacing"] = 1, ["game_speed"] = 1,
|
||||
[HandheldKey] = handheld, ["texture_detail"] = detail[preset],
|
||||
};
|
||||
}
|
||||
/// <summary>merged_rows.h kSharedZone: the old shared Stick dead zone's shares in percent, by its saved value (-1 XInput's
|
||||
/// own, each stick's Default), for a file before options_version 8.</summary>
|
||||
public static readonly IReadOnlyList<int> SharedZone = new[] { -1, 5, 10, 15, 20, 30 };
|
||||
}
|
||||
|
||||
@@ -85,26 +85,90 @@ public sealed class Uninstaller
|
||||
readonly TriforceContext ctx;
|
||||
public Uninstaller(TriforceContext ctx) { this.ctx = ctx; }
|
||||
|
||||
// ((Triforce, 11-21, ticket "Downloads folder got deleted while uninstalling the Triforce launcher") The uninstall took its
|
||||
// folder away whole (rmdir /s), and that folder was the install folder or, for a Setup never installed, the folder it ran
|
||||
// from: a TriforceSetup.exe run from Downloads took the player's whole Downloads folder with it. Now only the launcher's own
|
||||
// entries go (OwnFiles, and OwnFolders where the folder is the launcher's alone: Dedicated), then the folder itself only
|
||||
// if nothing else is left in it (rmdir without /s), and a Setup that is not the installed one removes nothing of its folder.
|
||||
|
||||
/// <summary>The launcher's own files in its folder (del patterns): its exe, the copies an update or a handover leaves
|
||||
/// (TriforceSetup.old.exe, TriforceSetup.exe.partial), and its log.</summary>
|
||||
public static readonly string[] OwnFiles = { "TriforceSetup*.exe", "TriforceSetup*.exe.*", "setup.log", "setup.log.*" };
|
||||
/// <summary>The folders it makes there (TriforceContext ToolsFolder, DownloadsFolder, NgxSdkFolder); save-backups stays (saves).</summary>
|
||||
public static readonly string[] OwnFolders = { "tools", "downloads", "ngx-sdk" };
|
||||
|
||||
/// <summary>Is dir a folder of the launcher's alone, where its folders' names (downloads, tools) can only be its own? The
|
||||
/// default install folder, or one named Triforce that is not a drive's root, the account's folder or one above it, nor one
|
||||
/// of the account's known folders. Elsewhere (a player who installed into Downloads, D:\Games or their own folder) its
|
||||
/// folders' names may be the player's: only its files go there.</summary>
|
||||
public static bool Dedicated(string dir, string defaultDir, IEnumerable<string> known)
|
||||
{
|
||||
try
|
||||
{
|
||||
var full = Path.GetFullPath(dir).TrimEnd('\\', '/');
|
||||
if (TriforceContext.SamePath(full, defaultDir)) return true;
|
||||
if (Path.GetPathRoot(full) is { } root && TriforceContext.SamePath(full, root)) return false;
|
||||
foreach (var k in known)
|
||||
if (!string.IsNullOrEmpty(k) && (TriforceContext.SamePath(full, k) || TriforceContext.Inside(full, k))) return false;
|
||||
return string.Equals(Path.GetFileName(full), "Triforce", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
catch (Exception) { return false; }
|
||||
}
|
||||
|
||||
/// <summary>The account's folders an install folder must never be (nor hold): its own, Desktop, Documents, Downloads and the
|
||||
/// other known ones, AppData's roots, Program Files.</summary>
|
||||
public static IEnumerable<string> KnownFolders()
|
||||
{
|
||||
var profile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
foreach (var f in new[] { Environment.SpecialFolder.UserProfile, Environment.SpecialFolder.DesktopDirectory, Environment.SpecialFolder.MyDocuments,
|
||||
Environment.SpecialFolder.MyMusic, Environment.SpecialFolder.MyPictures, Environment.SpecialFolder.MyVideos,
|
||||
Environment.SpecialFolder.ApplicationData, Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolder.ProgramFiles,
|
||||
Environment.SpecialFolder.ProgramFilesX86, Environment.SpecialFolder.Windows })
|
||||
yield return Environment.GetFolderPath(f);
|
||||
if (!string.IsNullOrEmpty(profile))
|
||||
{
|
||||
yield return Path.Combine(profile, "Downloads");
|
||||
yield return Path.Combine(profile, "OneDrive");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The short-lived cmd's line that removes the launcher from dir once this process is gone: its files, its folders
|
||||
/// where dir is Dedicated, then dir itself only when empty.</summary>
|
||||
public static string RemoveCommand(string dir, bool dedicated)
|
||||
{
|
||||
var d = Path.GetFullPath(dir).TrimEnd('\\', '/');
|
||||
var line = "/c timeout /t 2 /nobreak >nul";
|
||||
foreach (var f in OwnFiles) line += " & del /f /q \"" + Path.Combine(d, f) + "\" 2>nul";
|
||||
if (dedicated)
|
||||
foreach (var f in OwnFolders) line += " & rmdir /s /q \"" + Path.Combine(d, f) + "\" 2>nul";
|
||||
return line + " & rmdir \"" + d + "\" 2>nul";
|
||||
}
|
||||
|
||||
public UninstallPlan Describe()
|
||||
{
|
||||
var dir = ctx.InstalledDir;
|
||||
var removes = new List<string>
|
||||
{
|
||||
"Triforce and its tools (" + ctx.Home + ")",
|
||||
dir != null ? "Triforce and its tools (" + dir + ")" : "Triforce's settings and Apps-list entry",
|
||||
"the shortcuts",
|
||||
"the build's work folder and compile cache (" + ctx.WorkFolder + ", made again by a build)",
|
||||
"the launcher's settings",
|
||||
};
|
||||
if (!ctx.IsWindows) removes[0] = "the launcher's updates and NVIDIA's SDK (" + ctx.Platform.DefaultInstallDir + ")";
|
||||
var keeps = new List<string> { "your game folders" + (ctx.Settings.GameFolder is { } g ? " (" + g + ")" : ""), "your saves" };
|
||||
if (ctx.IsWindows && dir == null) keeps.Add("this Setup file and everything beside it (" + ctx.SelfDir + "): delete the file yourself");
|
||||
else if (ctx.IsWindows && dir != null && !Dedicated(dir, ctx.Platform.DefaultInstallDir, KnownFolders()))
|
||||
keeps.Add("everything in " + dir + " that is not Triforce's own files");
|
||||
return new UninstallPlan(removes, keeps);
|
||||
}
|
||||
|
||||
/// <summary>Does it. The launcher's own folder goes once this process is gone (Windows: a short-lived cmd waits 2 s, then
|
||||
/// rmdir; Linux: removed now, a running binary can be unlinked).</summary>
|
||||
/// <summary>Does it. The launcher's own files go once this process is gone (Windows: a short-lived cmd waits 2 s, then
|
||||
/// removes them: RemoveCommand; Linux: removed now, a running binary can be unlinked).</summary>
|
||||
public void Run()
|
||||
{
|
||||
var dir = ctx.InstalledDir ?? ctx.Home;
|
||||
ctx.Log.Write("uninstall: " + dir);
|
||||
// (the installed launcher's folder only: never the folder a Setup that is not installed runs from, Downloads)
|
||||
var dir = ctx.IsWindows ? ctx.InstalledDir : ctx.Home;
|
||||
ctx.Log.Write("uninstall: " + (dir ?? "(not installed: nothing removed from " + ctx.SelfDir + ")"));
|
||||
ctx.Platform.RemoveShortcuts();
|
||||
// (the build's work folder and compile cache, nx2/make_game.py --work: several GB, made again by a build)
|
||||
var work = ctx.WorkFolder;
|
||||
@@ -114,9 +178,13 @@ public sealed class Uninstaller
|
||||
if (ctx.IsWindows)
|
||||
{
|
||||
// (this exe is running from the folder: a short-lived cmd removes it once we are gone)
|
||||
if (File.Exists(Path.Combine(dir, BuildInfo.SetupAsset)) && ctx.Allowed(dir))
|
||||
Process.Start(new ProcessStartInfo("cmd.exe", "/c timeout /t 2 /nobreak >nul & rmdir /s /q \"" + dir + "\"")
|
||||
if (dir != null && File.Exists(Path.Combine(dir, BuildInfo.SetupAsset)) && ctx.Allowed(dir))
|
||||
{
|
||||
var dedicated = Dedicated(dir, ctx.Platform.DefaultInstallDir, ctx.TestRoot != null ? Array.Empty<string>() : KnownFolders());
|
||||
ctx.Log.Write("uninstall: " + (dedicated ? "its files and folders" : "its files alone (the folder is not Triforce's alone)"));
|
||||
Process.Start(new ProcessStartInfo("cmd.exe", RemoveCommand(dir, dedicated))
|
||||
{ CreateNoWindow = true, UseShellExecute = false, WorkingDirectory = Path.GetTempPath() })?.Dispose();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -229,12 +229,24 @@ public sealed class Tools
|
||||
}
|
||||
|
||||
/// <summary>Whether the tools in folder hold base b whole (progress: 0..1 while it reads the files). Remembers a match in base.have.</summary>
|
||||
/// <summary>((Triforce, 11-21, ticket "Every tools update re-downloads the whole base, even when it didn't change") A file of the
|
||||
/// base that the tools rewrite as they run: the bundled Python's bytecode caches (__pycache__\*.pyc), which Python writes
|
||||
/// again whenever its sources are newer or the cache's interpreter differs. Their sizes and hashes in base.list were those of
|
||||
/// the packed folder, so after one build 352 of the 417 differed and every update fetched the whole base (~95% of the tools)
|
||||
/// again. Not compared: one that is stale or missing is made again by Python itself.</summary>
|
||||
public static bool Regenerated(string path)
|
||||
{
|
||||
var p = path.Replace('\\', '/');
|
||||
return p.EndsWith(".pyc", StringComparison.OrdinalIgnoreCase) || p.Contains("/__pycache__/", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static bool HasBase(Base b, string folder, Action<double>? progress)
|
||||
{
|
||||
foreach (var d in b.Dirs)
|
||||
if (!Directory.Exists(Path.Combine(folder, d))) return false;
|
||||
foreach (var f in b.Files) // (every file there, at its size: quick, and enough once base.have says the rest was read)
|
||||
{
|
||||
if (Regenerated(f.Path)) continue;
|
||||
var fi = new FileInfo(Path.Combine(folder, f.Path));
|
||||
if (!fi.Exists || fi.Length != f.Size) return false;
|
||||
}
|
||||
@@ -244,6 +256,7 @@ public sealed class Tools
|
||||
long total = Math.Max(1, b.Files.Sum(f => f.Size)), done = 0;
|
||||
foreach (var f in b.Files)
|
||||
{
|
||||
if (Regenerated(f.Path)) { done += f.Size; continue; }
|
||||
string got;
|
||||
using (var s = File.OpenRead(Path.Combine(folder, f.Path))) got = Convert.ToHexStringLower(SHA256.HashData(s));
|
||||
if (got != f.Sha) return false;
|
||||
|
||||
@@ -58,6 +58,8 @@ static partial class Tests
|
||||
Check(none.Text.Contains(" to "), "a range in words: " + none.Text);
|
||||
var amd = BuildEstimator.Estimate(BuildHistory.Load(root), false, 16, GpuVendor.Amd);
|
||||
Equal(TimeSpan.FromMinutes(120), amd.Of("shaders")!.High, "AMD's shader step up to 2 hours");
|
||||
var intel = BuildEstimator.Estimate(BuildHistory.Load(root), false, 12, GpuVendor.Intel);
|
||||
Equal(TimeSpan.FromMinutes(240), intel.Of("shaders")!.High, "Intel's shader step up to 4 hours (an A750: 4.3 h on v0.6.0)");
|
||||
File.WriteAllText(Path.Combine(root, "build_times.json"), new JsonObject
|
||||
{
|
||||
["format"] = 1,
|
||||
@@ -74,6 +76,8 @@ static partial class Tests
|
||||
var est2 = BuildEstimator.Estimate(BuildHistory.Load(root), false, 8, GpuVendor.Nvidia);
|
||||
Equal(TimeSpan.FromSeconds(1500), est2.Of("compile")!.Low, "the stage record wins");
|
||||
Equal(TimeSpan.FromSeconds(600), est2.Of("shaders")!.High, "the shader step measured too");
|
||||
var upd = BuildEstimator.Estimate(BuildHistory.Load(root), true, 8, GpuVendor.Intel);
|
||||
Equal(TimeSpan.FromSeconds(600), upd.Of("shaders")!.High, "an update with no update on record: the build's measured shader step, not the stated range");
|
||||
Equal("About 40 minutes", est2.Text, "one time in words");
|
||||
var tr = new BuildTracker();
|
||||
tr.Feed("@@stage compile Compiling");
|
||||
@@ -85,6 +89,112 @@ static partial class Tests
|
||||
Equal("1 h 5 min", BuildClock.Span(TimeSpan.FromMinutes(65)), "span");
|
||||
}
|
||||
|
||||
static BuildEstimate OneStage(string stage, double low, double high, bool measured) =>
|
||||
new(new[] { new StageEstimate(stage, TimeSpan.FromSeconds(low), TimeSpan.FromSeconds(high), measured) }, measured);
|
||||
|
||||
/// <summary>A stage run second by second on a fake clock: progress(t) said as the game says it (each time the tenth of a percent
|
||||
/// moves), the shown time left asked each second as the App's tick does. The shown seconds at each second.</summary>
|
||||
static double[] RunStage(BuildEstimate est, string stage, Func<double, double> progress, int seconds)
|
||||
{
|
||||
var t0 = new DateTime(2026, 11, 22, 10, 0, 0, DateTimeKind.Utc);
|
||||
var now = t0;
|
||||
var tr = new BuildTracker(() => now);
|
||||
tr.Feed("@@stage " + stage + " x");
|
||||
var shown = new double[seconds + 1];
|
||||
var said = 0.0;
|
||||
for (var t = 0; t <= seconds; t++)
|
||||
{
|
||||
now = t0.AddSeconds(t);
|
||||
var p = Math.Floor(Math.Clamp(progress(t), 0, 1) * 1000) / 1000;
|
||||
if (p > said) { said = p; tr.Feed("@@progress " + p.ToString("0.000", System.Globalization.CultureInfo.InvariantCulture)); }
|
||||
shown[t] = BuildClock.Remaining(est, tr).TotalSeconds;
|
||||
}
|
||||
return shown;
|
||||
}
|
||||
|
||||
static void EtaSlowStart()
|
||||
{
|
||||
// (an Intel-like shader step of an hour: the compute pipelines, the first 14 %, take 52 minutes; the rest 8. The rate since
|
||||
// the stage began said 4 hours and more there)
|
||||
static double P(double t) => t < 3120 ? 0.14 * t / 3120 : 0.14 + 0.86 * (t - 3120) / 480;
|
||||
foreach (var (est, what) in new[] { (OneStage("shaders", 600, 2400, false), "the stated range"), (OneStage("shaders", 3600, 3600, true), "this PC's last time") })
|
||||
{
|
||||
var shown = RunStage(est, "shaders", P, 3600);
|
||||
for (var t = 300; t <= 3600; t++)
|
||||
{
|
||||
Check(shown[t] < 90 * 60, what + ": no hours after the first minutes (" + BuildClock.LeftText(TimeSpan.FromSeconds(shown[t])) + " at " + t + " s)");
|
||||
Check(shown[t] <= shown[t - 1] + 1, what + ": never up by more than a second a second (" + shown[t - 1] + " to " + shown[t] + " at " + t + " s)");
|
||||
}
|
||||
Check(shown[3540] < 180, what + ": near the end it says so: " + shown[3540]);
|
||||
}
|
||||
// (this PC's own time knows the hour: it is told within a quarter of an hour all the way)
|
||||
var measured = RunStage(OneStage("shaders", 3600, 3600, true), "shaders", P, 3600);
|
||||
for (var t = 0; t <= 3600; t += 60) Check(Math.Abs(measured[t] - (3600 - t)) < 15 * 60, "measured: " + measured[t] + " at " + t + " s");
|
||||
}
|
||||
|
||||
static void EtaStall()
|
||||
{
|
||||
// (a 20 minute stage, steady, that sits 10 minutes on one item at 400 s)
|
||||
static double P(double t) => t < 400 ? t / 1200 : t < 1000 ? 400.0 / 1200 : (t - 600) / 1200;
|
||||
var shown = RunStage(OneStage("shaders", 1200, 1200, true), "shaders", P, 1800);
|
||||
var before = shown[400];
|
||||
var most = shown.Skip(400).Take(900).Max();
|
||||
Check(most - before <= 4 * 60, "the stall and the steps after it add at most 4 minutes: " + before + " to " + most);
|
||||
Check(shown.Skip(400).Take(600).Min() >= before - 120, "it holds while nothing moves: " + shown.Skip(400).Take(600).Min());
|
||||
Check(Math.Abs(shown[1500] - 300) < 120, "back on time once it moves again: " + shown[1500]);
|
||||
Check(shown[1790] < 60, "done at the end: " + shown[1790]);
|
||||
}
|
||||
|
||||
static void EtaSteady()
|
||||
{
|
||||
var shown = RunStage(OneStage("shaders", 1200, 1200, true), "shaders", t => t / 1200, 1200);
|
||||
for (var t = 60; t + 60 <= 1200; t += 60)
|
||||
{
|
||||
var fell = shown[t] - shown[t + 60];
|
||||
Check(fell is > 45 and < 75, "a minute a minute (" + fell + " s at " + t + " s)");
|
||||
Check(Math.Abs(shown[t] - (1200 - t)) < 60, "on time: " + shown[t] + " at " + t + " s");
|
||||
}
|
||||
// (slower than the stated range said: the measured rate takes over and it is told right by the middle)
|
||||
var slow = RunStage(OneStage("shaders", 600, 2400, false), "shaders", t => t / 2400.0, 2400);
|
||||
for (var t = 1200; t <= 2340; t += 60) Check(Math.Abs(slow[t] - (2400 - t)) < 0.2 * (2400 - t) + 60, "slow but steady: " + slow[t] + " at " + t + " s");
|
||||
for (var t = 1; t <= 2400; t++) Check(slow[t] <= slow[t - 1] + 0.5, "never up by more than half a second a second at " + t + " s");
|
||||
}
|
||||
|
||||
static void EtaOtherStages()
|
||||
{
|
||||
var est = new BuildEstimate(new[]
|
||||
{
|
||||
new StageEstimate("read", TimeSpan.FromSeconds(90), TimeSpan.FromSeconds(90), true), new StageEstimate("lift", TimeSpan.FromSeconds(130), TimeSpan.FromSeconds(130), true),
|
||||
new StageEstimate("compile", TimeSpan.FromSeconds(1500), TimeSpan.FromSeconds(1500), true), new StageEstimate("finish", TimeSpan.FromSeconds(70), TimeSpan.FromSeconds(70), true),
|
||||
new StageEstimate("shaders", TimeSpan.FromSeconds(600), TimeSpan.FromSeconds(600), true),
|
||||
}, true);
|
||||
var t0 = new DateTime(2026, 11, 22, 10, 0, 0, DateTimeKind.Utc);
|
||||
var now = t0;
|
||||
var tr = new BuildTracker(() => now);
|
||||
Equal(TimeSpan.FromSeconds(2390), BuildClock.Estimated(est, tr), "before the first stage: every stage");
|
||||
tr.Feed("@@stage lift Translating");
|
||||
now = t0.AddSeconds(30);
|
||||
Equal(TimeSpan.FromSeconds(100 + 1500 + 70 + 600), BuildClock.Estimated(est, tr), "no progress: its estimate less its time");
|
||||
Equal(TimeSpan.FromSeconds(100 + 1500 + 70 + 600), BuildClock.Remaining(est, tr), "shown as it is");
|
||||
now = t0.AddSeconds(40);
|
||||
Equal(TimeSpan.FromSeconds(90 + 1500 + 70 + 600), BuildClock.Remaining(est, tr), "and counted down");
|
||||
now = t0.AddSeconds(400);
|
||||
Equal(TimeSpan.FromSeconds(13 + 0.25 * 270 + 1500 + 70 + 600), BuildClock.Estimated(est, tr), "past its estimate: a tenth of it and a quarter of the time over");
|
||||
// (steady progress: by its rate)
|
||||
var lift = new BuildTracker(() => now);
|
||||
now = t0;
|
||||
lift.Feed("@@stage lift Translating");
|
||||
for (var t = 1; t <= 65; t++) { now = t0.AddSeconds(t); lift.Feed("@@progress " + (t / 130.0).ToString("0.000", System.Globalization.CultureInfo.InvariantCulture)); }
|
||||
Check(Math.Abs(BuildClock.Estimated(est, lift).TotalSeconds - (65 + 1500 + 70 + 600)) < 3, "half way at its pace: " + BuildClock.Estimated(est, lift));
|
||||
// (the compile by its @@eta, as before; the eta goes with the stage)
|
||||
lift.Feed("@@stage compile Compiling");
|
||||
lift.Feed("@@eta 300");
|
||||
Equal(TimeSpan.FromSeconds(300 + 70 + 600), BuildClock.Estimated(est, lift), "the compile's eta");
|
||||
lift.Feed("@@stage finish Putting");
|
||||
Equal(TimeSpan.FromSeconds(70 + 600), BuildClock.Estimated(est, lift), "the eta ends with the compile");
|
||||
Equal(1, lift.Recent.Count, "a new stage starts its samples over");
|
||||
}
|
||||
|
||||
/// <summary>A test root with fake tools: tools\nx2\make_game.py, and this program as tools\python\python.exe.</summary>
|
||||
static TriforceContext FakeTools(string root)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,10 @@ static partial class Tests
|
||||
yield return ("tools: update from the fake server with progress", ToolsUpdate);
|
||||
yield return Sync("build: @@ protocol from a recorded transcript", Protocol);
|
||||
yield return Sync("build: estimates from history and without", Estimates);
|
||||
yield return Sync("build: time left, slow first part of the shaders then fast", EtaSlowStart);
|
||||
yield return Sync("build: time left, one item stalls for 10 minutes", EtaStall);
|
||||
yield return Sync("build: time left, a steady stage counts down", EtaSteady);
|
||||
yield return Sync("build: time left, other stages and the compile eta", EtaOtherStages);
|
||||
yield return ("build: runner with a fake make_game (done, args, log, times)", RunnerDone);
|
||||
yield return ("build: runner stop kills the tree", RunnerStop);
|
||||
yield return ("build: runner failure and test-root refusal", RunnerFail);
|
||||
@@ -382,6 +386,60 @@ static partial class Tests
|
||||
Check(!Directory.Exists(Path.Combine(root, "build")), "work folder gone");
|
||||
Equal(null, Ctx(root, self).Platform.Settings.GetUninstall("InstallLocation"), "uninstall entry gone");
|
||||
Equal(null, Ctx(root, self).Settings.GameFolder, "settings gone");
|
||||
UninstallKeepsOthers();
|
||||
}
|
||||
|
||||
// (11-21, ticket "Downloads folder got deleted while uninstalling the Triforce launcher": the whole folder went, rmdir /s,
|
||||
// and for a Setup run from Downloads, never installed, that folder was Downloads)
|
||||
static void UninstallKeepsOthers()
|
||||
{
|
||||
var def = @"C:\Users\Ann\AppData\Local\Programs\Triforce";
|
||||
var known = new[] { @"C:\Users\Ann", @"C:\Users\Ann\Downloads", @"C:\Users\Ann\Desktop", @"C:\Users\Ann\AppData\Local" };
|
||||
Check(Uninstaller.Dedicated(def, def, known), "the default install folder is the launcher's");
|
||||
Check(Uninstaller.Dedicated(@"D:\Triforce", def, known), "a folder named Triforce is");
|
||||
Check(!Uninstaller.Dedicated(@"C:\Users\Ann\Downloads", def, known), "Downloads is not");
|
||||
Check(!Uninstaller.Dedicated(@"C:\Users\Ann", def, known), "the account's folder is not");
|
||||
Check(!Uninstaller.Dedicated(@"C:\Users", def, known), "a folder above it is not");
|
||||
Check(!Uninstaller.Dedicated(@"D:\", def, known), "a drive's root is not");
|
||||
Check(!Uninstaller.Dedicated(@"D:\Games", def, known), "a folder of the player's own is not");
|
||||
var c = Uninstaller.RemoveCommand(@"C:\Users\Ann\Downloads", false);
|
||||
Check(!c.Contains("rmdir /s"), "outside a folder of its own, no folder is removed whole: " + c);
|
||||
Check(c.Contains(@"del /f /q ""C:\Users\Ann\Downloads\TriforceSetup*.exe"""), "its exe goes");
|
||||
Check(c.EndsWith(@"rmdir ""C:\Users\Ann\Downloads"" 2>nul"), "the folder itself only when empty (no /s)");
|
||||
var c2 = Uninstaller.RemoveCommand(def, true);
|
||||
Check(c2.Contains(@"rmdir /s /q """ + def + @"\tools""") && c2.Contains(@"rmdir /s /q """ + def + @"\downloads"""), "its own folders go in its own folder");
|
||||
Check(!c2.Contains(@"rmdir /s /q """ + def + @""""), "but never the folder whole");
|
||||
|
||||
// (a Setup that is not installed, run from Downloads beside the player's files: nothing of that folder goes)
|
||||
var root = NewRoot("uninstall-downloads");
|
||||
var downloads = Path.Combine(root, "Downloads");
|
||||
var self = Path.Combine(downloads, BuildInfo.SetupAsset);
|
||||
Directory.CreateDirectory(downloads);
|
||||
File.WriteAllText(self, "launcher bytes");
|
||||
File.WriteAllText(Path.Combine(downloads, "photo.jpg"), "the player's");
|
||||
var ctx = Ctx(root, self);
|
||||
Equal(null, ctx.InstalledDir, "not installed");
|
||||
var plan = new Uninstaller(ctx).Describe();
|
||||
Check(plan.Keeps.Any(k => k.Contains(downloads)), "the plan says the Setup's folder stays");
|
||||
new Uninstaller(ctx).Run();
|
||||
Thread.Sleep(3500);
|
||||
Check(File.Exists(Path.Combine(downloads, "photo.jpg")) && File.Exists(self), "the Setup's folder is left as it was");
|
||||
|
||||
// (installed: its files and folders go, the player's file put beside them stays, and so the folder)
|
||||
var root2 = NewRoot("uninstall-installed");
|
||||
var self2 = Path.Combine(root2, "Downloads", BuildInfo.SetupAsset);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(self2)!);
|
||||
File.WriteAllText(self2, "launcher bytes");
|
||||
var ctx2 = Ctx(root2, self2);
|
||||
var exe = new Installer(ctx2).Run(new Installer(ctx2).DefaultDir, desktop: false, startMenu: false);
|
||||
var idir = Path.GetDirectoryName(exe)!;
|
||||
Directory.CreateDirectory(Path.Combine(idir, "tools", "x"));
|
||||
File.WriteAllText(Path.Combine(idir, "notes.txt"), "the player's");
|
||||
new Uninstaller(ctx2).Run();
|
||||
Thread.Sleep(3500);
|
||||
Check(!File.Exists(exe) && !Directory.Exists(Path.Combine(idir, "tools")), "installed: its exe and tools gone");
|
||||
Check(File.Exists(Path.Combine(idir, "notes.txt")), "and a file of the player's there stays");
|
||||
Check(File.Exists(self2), "the downloaded Setup it was installed from stays");
|
||||
}
|
||||
|
||||
// ---- report, languages ----
|
||||
|
||||
@@ -17,7 +17,7 @@ static partial class Tests
|
||||
yield return Sync("game options: keys, labels, choices, no Hookshot", GameOptionsLabels);
|
||||
yield return Sync("game options: the real triforce_options.ini (read only)", GameOptionsRealFile);
|
||||
yield return Sync("game options: round trip, merge, atomic write (a copy)", GameOptionsWrite);
|
||||
yield return Sync("game options: Set's rules, Quality preset, Apply", GameOptionsSetRules);
|
||||
yield return Sync("game options: Set's rules, merged rows, Upscaler, Apply", GameOptionsSetRules);
|
||||
yield return Sync("game options: an older options_version, a new file", GameOptionsOldVersion);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,10 @@ static partial class Tests
|
||||
sb.Append(c);
|
||||
}
|
||||
body = sb.ToString();
|
||||
// (the in-game UI merge, 11-20: section titles written as MENU_HEADING(tab, "title"), vk_menu.cpp's macro for a heading
|
||||
// row: expanded here as the compiler does, so the sections are read again)
|
||||
body = Regex.Replace(body, @"MENU_HEADING\((TAB_[A-Z]+),\s*(""(?:[^""\\]|\\.)*"")\)",
|
||||
"{$1, $2, nullptr, 0, 0, 0, nullptr, nullptr, nullptr, false, true, -1, true}");
|
||||
var rows = new List<MenuRow>();
|
||||
foreach (Match m in Regex.Matches(body, @"\{(TAB_[A-Z]+),"))
|
||||
{
|
||||
@@ -117,8 +121,8 @@ static partial class Tests
|
||||
Check(table.Count > 100, "the table read: " + table.Count + " entries");
|
||||
var symbols = new Dictionary<string, int>
|
||||
{
|
||||
["kLastOutput"] = 6, ["ur::kValues - 1"] = 6, ["ur::kUpscalers - 1"] = 6, ["ur::kModels - 1"] = 3, ["aa_rows::kValues - 1"] = 3,
|
||||
["2 + kMaxMics"] = 18, ["HOS_PROMPT_N"] = 6,
|
||||
["kLastOutput"] = 7, ["ur::kValues - 1"] = 6, ["ur::kUpscalers - 1"] = 6, ["ur::kModels - 1"] = 3, ["aa_rows::kValues - 1"] = 3,
|
||||
["2 + kMaxMics"] = 18, ["HOS_PROMPT_N"] = 6, ["mr7::FG_DLSS_LAST"] = 12, ["framegen_rows::kRowMax"] = 9,
|
||||
};
|
||||
int Num(string s, string what) => int.TryParse(s, out var v) ? v : symbols.TryGetValue(s, out v) ? v : throw new TestFailed(what + ": a symbol the test does not know, " + s);
|
||||
var tabs = new Dictionary<string, GameOptionTab>
|
||||
@@ -127,13 +131,31 @@ static partial class Tests
|
||||
["TAB_CONTROLS"] = GameOptionTab.Controls, ["TAB_SYSTEM"] = GameOptionTab.System, ["TAB_MOTION"] = GameOptionTab.Controls,
|
||||
["TAB_PAGE"] = GameOptionTab.Controls,
|
||||
};
|
||||
// ((Triforce, options_version 8) the saved values the merged rows stand for: the TAB_HIDDEN rows, each a part here, with
|
||||
// the hidden row's range and vk_menu.h's default; and the merged rows' own (&merged.*): their default the view of their
|
||||
// parts' defaults, by the schema's own rules)
|
||||
var hidden = table.Where(r => r.Tab == "TAB_HIDDEN" && r.Value != "nullptr").ToList();
|
||||
var partDefaults = new Dictionary<string, int>(StringComparer.Ordinal);
|
||||
foreach (var r in hidden)
|
||||
{
|
||||
var key = GameOptionsSchema.IniKey(r.Name);
|
||||
var part = GameOptionsSchema.Part(key);
|
||||
Check(part != null, "the hidden row \"" + r.Name + "\" is a merged row's part, key " + key);
|
||||
Equal(Num(r.Lo, r.Name), part!.Lo, r.Name + " (hidden): lo");
|
||||
Equal(Num(r.Hi, r.Name), part.Hi, r.Name + " (hidden): hi");
|
||||
Equal(defaults[r.Value["&opts.".Length..]], part.Default, r.Name + " (hidden): default");
|
||||
Equal(1, GameOptionsSchema.All.Count(m => m.Parts?.Any(p => p.Key == key) == true), r.Name + " (hidden): the part of one merged row");
|
||||
partDefaults[key] = part.Default;
|
||||
}
|
||||
Equal(string.Join(",", hidden.Select(r => GameOptionsSchema.IniKey(r.Name)).OrderBy(k => k, StringComparer.Ordinal)),
|
||||
string.Join(",", GameOptionsSchema.Parts.Keys.OrderBy(k => k, StringComparer.Ordinal)), "the parts are the hidden rows");
|
||||
var left = new[] { "&opts.language", "&opts.pad_layout" }; // (Game language: language.txt's; Layout preset: KeptKeys)
|
||||
var sections = new Dictionary<string, string>();
|
||||
var names = new List<string>();
|
||||
foreach (var r in table)
|
||||
{
|
||||
if (r.Heading) { sections[r.Tab] = r.Name; continue; }
|
||||
if (r.Value == "nullptr" || r.Tab == "TAB_DEBUG" || left.Contains(r.Value)) continue;
|
||||
if (r.Value == "nullptr" || r.Tab == "TAB_DEBUG" || r.Tab == "TAB_HIDDEN" || left.Contains(r.Value)) continue;
|
||||
var row = GameOptionsSchema.ByName(r.Name);
|
||||
Check(row != null, "the menu's row \"" + r.Name + "\" is in the schema");
|
||||
names.Add(r.Name);
|
||||
@@ -146,9 +168,24 @@ static partial class Tests
|
||||
Equal(r.Help, row.Help, r.Name + ": help");
|
||||
Equal(r.Restart, row.Restart, r.Name + ": restart");
|
||||
Equal(r.Exempt, row.PresetExempt, r.Name + ": preset exempt");
|
||||
Equal(defaults[r.Value["&opts.".Length..]], row.Default, r.Name + ": default");
|
||||
if (r.Value.StartsWith("&merged.", StringComparison.Ordinal))
|
||||
{
|
||||
Check(row.IsMerged, r.Name + ": a merged row");
|
||||
Equal(row.Merge!.Of(row.Parts!.Select(p => partDefaults[p.Key]).ToArray()), row.Default, r.Name + ": default (its parts')");
|
||||
}
|
||||
else
|
||||
{
|
||||
Check(!row.IsMerged && GameOptionsSchema.IniKey(r.Name) == row.Key, r.Name + ": its own line, key " + row.Key);
|
||||
Equal(defaults[r.Value["&opts.".Length..]], row.Default, r.Name + ": default");
|
||||
}
|
||||
}
|
||||
Equal(string.Join("|", names), string.Join("|", GameOptionsSchema.All.Select(r => r.Name)), "the rows, in the menu's order");
|
||||
// (the lines the game's save drops, merged_rows.h kDropped: kept keys, read once to move them)
|
||||
var mr = File.ReadAllText(Path.Combine(dir!, "merged_rows.h"));
|
||||
Check(mr.Contains("kVersion = " + GameOptionsSchema.CurrentVersion + ";"), "merged_rows.h's kVersion is CurrentVersion");
|
||||
var dropped = Regex.Match(mr, @"kDropped\[\]\s*=\s*\{([^}]*)\}").Groups[1].Value;
|
||||
foreach (Match d in Regex.Matches(dropped, "\"([^\"]+)\""))
|
||||
Check(GameOptionsSchema.KeptKeys.ContainsKey(d.Groups[1].Value) && GameOptionsSchema.ByKey(d.Groups[1].Value) == null, d.Groups[1].Value + ": dropped by the game, a kept key here");
|
||||
// (the Debug tab's keys, and the Layout preset's, are the KeptKeys: each with its reason)
|
||||
foreach (var r in table.Where(r => r.Value != "nullptr" && !r.Heading && (r.Tab == "TAB_DEBUG" || r.Value == "&opts.pad_layout")))
|
||||
Check(GameOptionsSchema.KeptKeys.ContainsKey(GameOptionsSchema.IniKey(r.Name)), r.Name + "'s key " + GameOptionsSchema.IniKey(r.Name) + " is a kept key");
|
||||
@@ -162,9 +199,18 @@ static partial class Tests
|
||||
Equal(all.Count, all.Select(r => r.Key).Distinct().Count(), "keys are unique");
|
||||
Check(all.All(r => r.Key.Length <= 31 && !r.Key.Contains(' ')), "keys as ini_key makes them");
|
||||
Equal("frame_rate_cap", GameOptionsSchema.Get("frame_rate_cap").Key, "renamed row keeps its key");
|
||||
Equal("Game frame rate cap", GameOptionsSchema.Get("frame_rate_cap").Name, "by key");
|
||||
Equal("amd_anti-lag_2", GameOptionsSchema.ByName("AMD Anti-Lag 2")!.Key, "AMD Anti-Lag 2's key");
|
||||
Equal("upscaling", GameOptionsSchema.ByName("Window scaling filter")!.Key, "Window scaling filter's key");
|
||||
Equal("Frame rate cap", GameOptionsSchema.Get("frame_rate_cap").Name, "by key");
|
||||
// ((Triforce, options_version 8) the rows renamed into their groups keep their keys; a merged row has none of its own)
|
||||
Equal("ultrawide", GameOptionsSchema.ByName("Aspect ratio")!.Key, "Aspect ratio's key");
|
||||
Equal("hdr_paper_white", GameOptionsSchema.ByName("Paper white")!.Key, "Paper white's key");
|
||||
Equal("renodx_bloom", GameOptionsSchema.ByName("Bloom")!.Key, "Bloom's key");
|
||||
Equal(GameOptionsSchema.LatencyKey, GameOptionsSchema.ByName("Low latency")!.Key, "Low latency: a merged row");
|
||||
Equal("nvidia_reflex,amd_anti-lag_2", string.Join(",", GameOptionsSchema.ByName("Low latency")!.Parts!.Select(p => p.Key)), "its parts' keys");
|
||||
Equal(null, GameOptionsSchema.ByKey("amd_anti-lag_2"), "a part is no row");
|
||||
Check(GameOptionsSchema.Part("amd_anti-lag_2") != null && GameOptionsSchema.IsValueKey("amd_anti-lag_2"), "but a value");
|
||||
Check(!GameOptionsSchema.IsValueKey(GameOptionsSchema.HdrKey), "a merged row's own key is no line's");
|
||||
foreach (var gone in new[] { "Quality preset", "Window scaling filter", "Reflex frame limit", "Handheld profile", "Stick dead zone", "Robust buffers" })
|
||||
Equal(null, GameOptionsSchema.ByName(gone), gone + ": no row (options_version 8)");
|
||||
Equal("tail_early", GameOptionsSchema.IniKey("Start next frame early"), "Start next frame early's key");
|
||||
Equal("export_save_for_a_bug_report", GameOptionsSchema.IniKey("Export save for a bug report"), "a long name: 28 letters");
|
||||
Equal("abcdefghijklmnopqrstuvwxyzabcde", GameOptionsSchema.IniKey("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH"), "cut at 31");
|
||||
@@ -186,25 +232,39 @@ static partial class Tests
|
||||
}
|
||||
else Equal(0, r.Choices.Count, r.Name + ": a slider has no choice list");
|
||||
}
|
||||
Equal(1, all.Count(r => r.Tab == GameOptionTab.Graphics && r.Key == GameOptionsSchema.PresetKey), "the preset row");
|
||||
Equal("Screen,Widescreen,Frame rate,High dynamic range,RenoDX", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Display)), "Display's sections");
|
||||
Equal("Quality,Upscaling and edges,Smoothness,Latency,Advanced", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Graphics)), "Graphics' sections");
|
||||
Equal("Camera,Sticks,Movement,Vibration,Other,Motion,Controls", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Controls)), "Controls' sections");
|
||||
Equal(0, GameOptionsSchema.Sections(GameOptionTab.Audio).Count, "Audio has none");
|
||||
Equal("Screen,Ultrawide,HDR,RenoDX,Overlay", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Display)), "Display's sections");
|
||||
Equal("Upscaling,Anti-aliasing,Frame generation,Frame rate & latency,Textures,Advanced", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Graphics)), "Graphics' sections");
|
||||
Equal("Controller,Mouse & keyboard,Rumble,Gameplay,Motion,Controls", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Controls)), "Controls' sections");
|
||||
Equal("Sound,Microphone", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.Audio)), "Audio's sections");
|
||||
Equal("Game,Online", string.Join(",", GameOptionsSchema.Sections(GameOptionTab.System)), "System's sections (with rows)");
|
||||
|
||||
string L(string key, int v) => GameOptionsSchema.Get(key).Label(v);
|
||||
string Cs(string key) => string.Join("|", GameOptionsSchema.Get(key).Choices.Select(c => c.Value + "=" + c.Label));
|
||||
Equal("-3=30|-2=40|-1=45|0=60 (the console's)|1=90|2=120|3=144|4=165|5=240|6=Monitor's rate", Cs("frame_rate_cap"), "fps cap");
|
||||
Equal("3=1920x1080|0=2048x1152|1=2560x1440|2=3840x2160|4=5120x1440|6=5120x2160|5=5120x2880", Cs("output_res"), "output sizes, smallest first");
|
||||
Equal("0=Game|1=NVIDIA DLSS|2=NVIDIA DLAA|3=AMD FSR 3.1|6=AMD FSR 3.1 Native AA|4=AMD FSR 4|5=AMD FSR 4 Native AA", Cs("dlss"), "upscalers in the menu's order");
|
||||
Equal("7=1536x864 (handheld)|3=1920x1080|0=2048x1152|1=2560x1440|2=3840x2160|4=5120x1440|6=5120x2160|5=5120x2880", Cs("output_res"), "output sizes, smallest first");
|
||||
Equal("0=Game|1=NVIDIA DLSS|3=AMD FSR 3.1|4=AMD FSR 4", Cs("dlss"), "upscalers: the engines, in the menu's order");
|
||||
Equal("0=Auto (dynamic)|1=100% (2048x1152)|2=75% (1536x864)|3=67% (1366x768)|4=50% (1024x576)", Cs("resolution"), "render resolution, the game's own");
|
||||
Equal("0=Custom|1=Minimum (6GB)|2=Low (8GB)|3=Balanced (12GB)|4=High (16GB)|5=Ultra (20GB+)", Cs("quality_preset"), "presets");
|
||||
Equal("0=Off|1=Default", Cs("microphone"), "microphone without devices");
|
||||
Equal("0=Game SMAA|1=Off|2=FXAA|3=SMAA Ultra", Cs("anti-aliasing"), "anti-aliasing");
|
||||
Equal("0=Off|1=Auto|2=2x|3=3x|4=4x|5=5x|6=6x|7=7x|8=8x|9=AMD FSR 4", Cs("frame_generation"), "frame generation");
|
||||
Equal("0=Off|1=Auto|2=2x|3=3x|4=4x|5=5x|6=6x|7=7x|8=8x|9=AMD FSR|10=NVIDIA DLSS 2x|11=NVIDIA DLSS 3x|12=NVIDIA DLSS 4x", Cs(GameOptionsSchema.FrameGenKey), "frame generation, DLSS's merged in");
|
||||
Equal("0=Off|1=Expanded|2=Native|3=Native + RenoDX", Cs(GameOptionsSchema.HdrKey), "HDR, RenoDX merged in");
|
||||
Equal("0=Off|1=Even|2=Steady, any rate|3=Steady, refresh steps", Cs(GameOptionsSchema.PacingKey), "frame pacing, steady merged in");
|
||||
Equal("0=Auto|1=Switch|2=Xbox|3=PlayStation 4|4=PlayStation 5|5=Steam Deck|6=Keyboard & mouse", Cs("button_prompts"), "prompts");
|
||||
Equal("0=Auto|1=Off|2=On", Cs("robust_buffers"), "robust");
|
||||
Equal("0=Insert or F1|1=F1 only", Cs("menu_shortcut"), "menu shortcut");
|
||||
// (Low latency by the card's maker: NVIDIA's Reflex where it is not known)
|
||||
var vendorBefore = GameOptionsSchema.LatencyVendorOf;
|
||||
try
|
||||
{
|
||||
GameOptionsSchema.LatencyVendorOf = null;
|
||||
Equal("0=Off|1=On|2=On + Boost", Cs(GameOptionsSchema.LatencyKey), "low latency, not known: Reflex's");
|
||||
Equal(2, GameOptionsSchema.Get(GameOptionsSchema.LatencyKey).Default, "Reflex's default On + Boost");
|
||||
GameOptionsSchema.LatencyVendorOf = () => LatencyVendor.Amd;
|
||||
Equal("0=Off|1=On", Cs(GameOptionsSchema.LatencyKey), "AMD: Anti-Lag 2's");
|
||||
Equal(0, GameOptionsSchema.Get(GameOptionsSchema.LatencyKey).Default, "Anti-Lag 2's default Off");
|
||||
GameOptionsSchema.LatencyVendorOf = () => LatencyVendor.None;
|
||||
Equal("0=Off", Cs(GameOptionsSchema.LatencyKey), "neither");
|
||||
}
|
||||
finally { GameOptionsSchema.LatencyVendorOf = vendorBefore; }
|
||||
Equal("1.25", L("mouse_sensitivity", 125), "sensitivity");
|
||||
Equal("0.51", L("walk_scale", 51), "walk scale");
|
||||
Equal("10000 nits", L("hdr_peak_brightness", 10000), "nits");
|
||||
@@ -212,12 +272,15 @@ static partial class Tests
|
||||
Equal("85%", L("master_volume", 85), "volume");
|
||||
Equal("Off", L("menu_sounds", 0), "menu sounds 0");
|
||||
Equal("Off", L("rumble_strength", 0), "rumble 0");
|
||||
Equal("As Stick dead zone", L("left_stick_dead_zone", -1), "own dead zone");
|
||||
Equal("Default (24%)", L("left_stick_dead_zone", -1), "own dead zone's default");
|
||||
Equal("0%", L("right_stick_dead_zone", 0), "own dead zone 0");
|
||||
Equal("50", L("renodx_bloom", 50), "grade");
|
||||
Equal("Default (24%)", L("stick_dead_zone", 0), "stick dead zone");
|
||||
Equal("Off", L("upscaling", 7), "past the row: its first");
|
||||
Equal("Normal", L("text_speed", 7), "past the row: its first");
|
||||
Equal("16:9", L("ultrawide", 0), "ultrawide");
|
||||
Equal("1536x864 (handheld)", L("output_res", 7), "the handheld profile is an Output resolution");
|
||||
Equal("NVIDIA DLSS", L("dlss", 2), "DLAA reads as its engine");
|
||||
Equal("AMD FSR 3.1", L("dlss", 6), "FSR 3.1's native AA too");
|
||||
Equal("Native (100%)", L("resolution", GameOptionsSchema.NativeStep), "the Render resolution's Native");
|
||||
|
||||
// (the GPU device row: the names the launcher gives it)
|
||||
var before = GameOptionsSchema.GpuNames;
|
||||
@@ -259,11 +322,34 @@ static partial class Tests
|
||||
text = File.ReadAllText(Path.Combine(nf, GameOptionsSchema.FileName));
|
||||
Check(text.Contains("gpu_device=0") && text.Contains("gpu_device_name=\r\n") || text.Contains("gpu_device_name=\n"),
|
||||
"Auto: the name emptied: " + text.Replace("\n", " | "));
|
||||
// ((Triforce) 11-22) a number saved before 11-20 has no name: the row's card chosen again (the same value) writes it,
|
||||
// where nothing was written and the number alone decided; chosen again with its name there: nothing to write
|
||||
GameOptionsSchema.GpuNames = () => new[] { "AMD Radeon(TM) Graphics", "AMD Radeon RX 6600" };
|
||||
var old = NewRoot("gpuold");
|
||||
File.WriteAllText(Path.Combine(old, GameOptionsSchema.FileName), "gpu_device=2\r\noptions_version=8\r\n");
|
||||
opt = GameOptionsFile.Load(old);
|
||||
opt.Set(GameOptionsSchema.GpuKey, 2);
|
||||
Check(opt.Changes.ContainsKey(GameOptionsSchema.GpuKey), "the same card again without its name: a change");
|
||||
opt.Save();
|
||||
text = File.ReadAllText(Path.Combine(old, GameOptionsSchema.FileName));
|
||||
Check(text.Contains("gpu_device=2\r\n") && text.Contains("gpu_device_name=AMD Radeon RX 6600\r\n"),
|
||||
"the name written beside the old number: " + text.Replace("\r\n", " | "));
|
||||
opt = GameOptionsFile.Load(old);
|
||||
opt.Set(GameOptionsSchema.GpuKey, 2);
|
||||
Equal(0, opt.Changes.Count, "the same card again with its name: nothing to write");
|
||||
File.WriteAllText(Path.Combine(old, GameOptionsSchema.FileName), "gpu_device=2\r\ngpu_device_name=AMD Radeon(TM) Graphics\r\noptions_version=8\r\n");
|
||||
opt = GameOptionsFile.Load(old);
|
||||
opt.Set(GameOptionsSchema.GpuKey, 2);
|
||||
opt.Save();
|
||||
text = File.ReadAllText(Path.Combine(old, GameOptionsSchema.FileName));
|
||||
Check(text.Contains("gpu_device_name=AMD Radeon RX 6600\r\n") && !text.Contains("Radeon(TM)"),
|
||||
"another card's name beside the number: the row's card's: " + text.Replace("\r\n", " | "));
|
||||
File.WriteAllText(Path.Combine(old, GameOptionsSchema.FileName), "gpu_device=0\r\noptions_version=8\r\n");
|
||||
opt = GameOptionsFile.Load(old);
|
||||
opt.Set(GameOptionsSchema.GpuKey, 0);
|
||||
Equal(0, opt.Changes.Count, "Auto again: nothing to write");
|
||||
}
|
||||
finally { GameOptionsSchema.GpuNames = before; }
|
||||
|
||||
Equal(6, GameOptionsSchema.PresetSummaries.Count, "a summary for each preset");
|
||||
Equal(0, GameOptionsSchema.PresetValues(0).Count, "Custom sets nothing");
|
||||
}
|
||||
|
||||
// ---- the real file ----
|
||||
@@ -290,8 +376,15 @@ static partial class Tests
|
||||
if (r.Kind == GameOptionKind.Choice)
|
||||
Check(f.ChoicesOf(r.Key).Any(c => c.Value == v && c.Label == label), r.Name + ": " + v + " = \"" + label + "\" is one of its choices");
|
||||
else
|
||||
Check(Regex.IsMatch(label, @"^(-?\d+( nits|%)?|\d\.\d\d|Off|Muted|As Stick dead zone)$"), r.Name + ": a slider's label \"" + label + "\"");
|
||||
Check(f.Raw(r.Key) == null || v == r.AsRead(GameOptionsFile.Atoi(f.Raw(r.Key)!)), r.Name + ": the file's value as the game reads it");
|
||||
Check(Regex.IsMatch(label, @"^(-?\d+( nits|%)?|\d\.\d\d|Off|Muted|Default \(24%\))$"), r.Name + ": a slider's label \"" + label + "\"");
|
||||
Check(r.IsMerged || v == GameOptionsSchema.NativeStep || f.Raw(r.Key) == null || v == r.AsRead(GameOptionsFile.Atoi(f.Raw(r.Key)!)),
|
||||
r.Name + ": the file's value as the game reads it");
|
||||
}
|
||||
// (the merged rows' parts: each its line's value, in its range; the game writes every one)
|
||||
foreach (var p in GameOptionsSchema.Parts.Values)
|
||||
{
|
||||
Check(f.Raw(p.Key) != null, p.Key + ": the game wrote its line");
|
||||
Equal(p.AsRead(GameOptionsFile.Atoi(f.Raw(p.Key)!)), f.Get(p.Key), p.Key + ": as the game reads it");
|
||||
}
|
||||
info.Refresh();
|
||||
Equal(len, info.Length, "the real file is not written");
|
||||
@@ -357,31 +450,52 @@ static partial class Tests
|
||||
Equal("DCI-P3", Lb("renodx_color_space"), "colour space");
|
||||
Equal("Eye adaptation", Lb("renodx_midgray"), "midgray");
|
||||
Equal("Transformer 2 (M)", Lb("dlss_model"), "dlss model");
|
||||
Equal("Lanczos", Lb("upscaling"), "filter");
|
||||
Equal("50%", Lb("sharpness"), "sharpness");
|
||||
Equal("Off", Lb("robust_buffers"), "robust 1");
|
||||
Equal("Default", Lb("microphone"), "microphone");
|
||||
Equal("Full", Lb("texture_detail"), "texture detail");
|
||||
Equal("Off", Lb("nvidia_reflex"), "reflex 0");
|
||||
Equal("Off", Lb(GameOptionsSchema.LatencyKey), "low latency: reflex 0");
|
||||
Equal("Even", Lb(GameOptionsSchema.PacingKey), "frame pacing on, no steady");
|
||||
Equal("Off", Lb(GameOptionsSchema.HdrKey), "hdr 0");
|
||||
Equal("Off", Lb(GameOptionsSchema.FrameGenKey), "no frame generation");
|
||||
Equal("Per frame", GameOptionsSchema.Get("game_speed").Label(0), "game speed 0");
|
||||
Equal("Real time", Lb("game_speed"), "game speed: its default without a line");
|
||||
Equal("80%", Lb("menu_sounds"), "menu sounds' default");
|
||||
Equal("Middle", Lb("ultrawide_hud"), "wide HUD");
|
||||
Equal("Centred, blurred sides", Lb("ultrawide_menus"), "wide menus");
|
||||
Equal("layout_preset,debug_tools,replay_helper_threads,tail_early,options_version,menu_size,pad_a,key_a,key_cam_right",
|
||||
Equal("Default (24%)", Lb("left_stick_dead_zone"), "a stick's own dead zone: its default");
|
||||
// (a v0.5.1 file, options_version 7: the rows that went are other lines, kept for the game to drop)
|
||||
Equal("quality_preset,upscaling,robust_buffers,layout_preset,debug_tools,replay_helper_threads,tail_early,options_version,menu_size,pad_a,key_a,key_cam_right",
|
||||
string.Join(",", fx.OtherLines.Select(o => o.Key)), "other lines in the file's order");
|
||||
Equal("", string.Join(",", fx.UnknownKeys), "each one known");
|
||||
Equal("69,0", fx.OtherLines.Single(o => o.Key == "key_a").Value, "a binding's value as it is");
|
||||
// ((Triforce, options_version 8) the Upscaler's engines and the Render resolution's Native (upscaler_rows.h step_engine):
|
||||
// the game's own at 100% is the 3D at full size, so DLSS from it is DLSS's native AA, DLAA)
|
||||
fx.Set("dlss", 1);
|
||||
Equal("Quality (67%)", fx.Label("resolution"), "with DLSS: its mode (100% moved to Quality)");
|
||||
Equal(2, fx.Get("dlss"), "DLSS from the game's own at 100%: DLAA");
|
||||
Equal("NVIDIA DLSS", fx.Label("dlss"), "shown as its engine");
|
||||
Equal("Native (100%)", fx.Label("resolution"), "at Native");
|
||||
Equal(GameOptionsSchema.NativeStep, fx.Get("resolution"), "the row's Native step");
|
||||
Equal("DLSS's own", fx.Label("anti-aliasing"), "aa with DLSS");
|
||||
Equal("0,3,5,4,6", string.Join(",", fx.ChoicesOf("resolution").Select(c => c.Value)), "DLSS's steps");
|
||||
fx.Set("dlss", 2);
|
||||
Equal("Native (DLAA)", fx.Label("resolution"), "DLAA");
|
||||
Equal("0,-1,3,5,4,6", string.Join(",", fx.ChoicesOf("resolution").Select(c => c.Value)), "DLSS's steps, Native among them");
|
||||
Equal("0,2,3,4", string.Join(",", fx.ChoicesOf("dlss").Select(c => c.Value)), "the engines, DLSS by its saved value");
|
||||
fx.Set("resolution", 3);
|
||||
Equal(1, fx.Get("dlss"), "a mode: DLSS again");
|
||||
Equal("Quality (67%)", fx.Label("resolution"), "DLSS's Quality");
|
||||
fx.Set("resolution", GameOptionsSchema.NativeStep);
|
||||
Equal(2, fx.Get("dlss"), "Native: DLAA");
|
||||
Equal(3, fx.Changes["resolution"], "the saved resolution left as it was, for the other steps");
|
||||
fx.Set("dlss", 3);
|
||||
Equal(6, fx.Get("dlss"), "FSR 3.1 from DLAA: FSR 3.1's native AA");
|
||||
Equal("FSR's own", fx.Label("anti-aliasing"), "aa with FSR");
|
||||
fx.Set("dlss", 0);
|
||||
fx.Set("handheld_profile", 1);
|
||||
Equal("67% (1024x576)", fx.Label("resolution"), "handheld profile's size (100% went to DLSS's Quality, which stays with the game's own)");
|
||||
Equal(0, fx.Get("dlss"), "the game's own from a native AA");
|
||||
Equal("100% (2560x1440)", fx.Label("resolution"), "at 100%");
|
||||
fx.Set("output_res", GameOptionsSchema.HandheldOutput);
|
||||
Equal("100% (1536x864)", fx.Label("resolution"), "the handheld profile's size");
|
||||
fx.Set("resolution", 4);
|
||||
fx.Set("dlss", 4);
|
||||
Equal(4, fx.Get("dlss"), "FSR 4 from 50%: the engine");
|
||||
Equal("Performance (50%)", fx.Label("resolution"), "its mode");
|
||||
|
||||
// (the merge: a line changed outside since Load stays; the launcher's own change goes in; an unknown line stays in place)
|
||||
var m = NewGameFolder("game-options-merge", OptionsFixture);
|
||||
@@ -396,7 +510,8 @@ static partial class Tests
|
||||
Check(merged.Contains("\r\nhdr=2\r\nzz_tool_line=5\r\n"), "the outside change and its new line kept in place");
|
||||
Check(merged.StartsWith("fullscreen=1\r\n"), "the launcher's change in its line");
|
||||
Check(merged.Contains("\r\nsharpness=70\r\n"), "a row changed on both sides: the launcher's (the later writer)");
|
||||
Equal(outside.Replace("fullscreen=0", "fullscreen=1").Replace("sharpness=20", "sharpness=70"), merged, "every other line as the file had it");
|
||||
Equal(outside.Replace("fullscreen=0", "fullscreen=1").Replace("sharpness=20", "sharpness=70").Replace("options_version=7", "options_version=8"), merged,
|
||||
"every other line as the file had it (the version 7 file brought up to 8: nothing of it moves)");
|
||||
Equal("zz_tool_line", a.UnknownKeys.Single(), "an unknown key, kept");
|
||||
Equal(2, a.Get("hdr"), "this object holds the file as written");
|
||||
|
||||
@@ -407,7 +522,7 @@ static partial class Tests
|
||||
df.Set("sharpness", 30);
|
||||
df.Set("vsync", 0);
|
||||
df.Save();
|
||||
Equal("sharpness=30\nsharpness=30\n#note\nvsync=0\noptions_version=7\nmenu_size=1\n", File.ReadAllText(Path.Combine(d, GameOptionsSchema.FileName)), "LF kept, line added, comment kept");
|
||||
Equal("sharpness=30\nsharpness=30\n#note\nvsync=0\noptions_version=8\nmenu_size=1\n", File.ReadAllText(Path.Combine(d, GameOptionsSchema.FileName)), "LF kept, line added, comment kept, brought up to 8");
|
||||
|
||||
// (a device's name in UTF-8: its bytes as they were, its label as text)
|
||||
var mic = "microphone_device=Mikrofon (Ä USB)";
|
||||
@@ -445,53 +560,82 @@ static partial class Tests
|
||||
Equal(130, f.Set("mouse_sensitivity", 125), "onto the steps: the nearest, the larger on a tie");
|
||||
Equal(50, f.Set("rumble_strength", 60), "rumble on 25s");
|
||||
Equal(0, f.Set("output_res", 9), "an output past the list: the first");
|
||||
Equal(7, f.Set("output_res", 7), "the handheld profile's output");
|
||||
Equal(-1, f.Set("left_stick_dead_zone", -7), "a range below 0");
|
||||
Equal(-3, f.Set("frame_rate_cap", -3), "the cap's 30");
|
||||
|
||||
// (the preset sets its rows; a row not exempt changed by hand makes it Custom, an exempt one does not)
|
||||
f.Set("quality_preset", 4);
|
||||
foreach (var (k, v) in new Dictionary<string, int> { ["resolution"] = 1, ["upscaling"] = 2, ["sharpness"] = 40, ["frame_pacing"] = 1, ["game_speed"] = 1, ["handheld_profile"] = 0, ["texture_detail"] = 1 })
|
||||
Equal(v, f.Get(k), "High sets " + k);
|
||||
Equal("High (16GB)", f.Label("quality_preset"), "the preset's label");
|
||||
f.Set("fullscreen", 1);
|
||||
Equal(4, f.Get("quality_preset"), "an exempt row leaves the preset");
|
||||
f.Set("sharpness", 40);
|
||||
Equal(4, f.Get("quality_preset"), "the same value is no change");
|
||||
f.Set("sharpness", 60);
|
||||
Equal(0, f.Get("quality_preset"), "a scaling row by hand: Custom");
|
||||
// (with DLSS the preset's resolution is its nearest mode)
|
||||
f.Set("dlss", 1);
|
||||
f.Set("quality_preset", 2);
|
||||
Equal(3, f.Get("resolution"), "Low's 75% with DLSS: Quality (67%)");
|
||||
Equal(2, f.Get("texture_detail"), "Low: Reduced textures");
|
||||
f.Set("quality_preset", 1);
|
||||
Equal(4, f.Get("resolution"), "Minimum's 50% is DLSS's Performance");
|
||||
Equal(3, f.Get("texture_detail"), "Minimum: Low textures");
|
||||
Equal(1, f.Get("handheld_profile"), "Minimum: handheld profile");
|
||||
// (another Upscaler moves the resolution onto its steps)
|
||||
f.Set("dlss", 0);
|
||||
f.Set("resolution", 2);
|
||||
f.Set("dlss", 3);
|
||||
Equal(3, f.Get("resolution"), "75% with FSR 3.1: 67%");
|
||||
Equal(0, f.Get("quality_preset"), "the Upscaler is not exempt");
|
||||
// ((Triforce, options_version 8) a merged row sets its parts (merged_rows.h *_set): one of a pair chosen, the other Off)
|
||||
string Parts(string key) => string.Join(",", GameOptionsSchema.Get(key).Parts!.Select(p => p.Key + "=" + f.Get(p.Key)));
|
||||
f.Set(GameOptionsSchema.FrameGenKey, 11);
|
||||
Equal("frame_generation=0,dlss_frame_generation=2", Parts(GameOptionsSchema.FrameGenKey), "NVIDIA DLSS 3x");
|
||||
f.Set(GameOptionsSchema.FrameGenKey, 4);
|
||||
Equal("frame_generation=4,dlss_frame_generation=0", Parts(GameOptionsSchema.FrameGenKey), "4x, DLSS's off");
|
||||
Equal(12, f.Set(GameOptionsSchema.FrameGenKey, 40), "past the end: DLSS 4x");
|
||||
f.Set(GameOptionsSchema.HdrKey, 3);
|
||||
Equal("hdr=2,renodx_hdr=1", Parts(GameOptionsSchema.HdrKey), "Native + RenoDX");
|
||||
f.Set(GameOptionsSchema.HdrKey, 1);
|
||||
Equal("hdr=1,renodx_hdr=0", Parts(GameOptionsSchema.HdrKey), "Expanded, RenoDX off");
|
||||
f.Set(GameOptionsSchema.PacingKey, 3);
|
||||
Equal("frame_pacing=1,steady_frame_rate=2", Parts(GameOptionsSchema.PacingKey), "Steady, refresh steps: pacing on");
|
||||
f.Set(GameOptionsSchema.PacingKey, 0);
|
||||
Equal("frame_pacing=0,steady_frame_rate=0", Parts(GameOptionsSchema.PacingKey), "Off");
|
||||
var vendorBefore = GameOptionsSchema.LatencyVendorOf;
|
||||
try
|
||||
{
|
||||
GameOptionsSchema.LatencyVendorOf = () => LatencyVendor.Nvidia;
|
||||
f.Set(GameOptionsSchema.LatencyKey, 1);
|
||||
Equal("nvidia_reflex=1,amd_anti-lag_2=0", Parts(GameOptionsSchema.LatencyKey), "NVIDIA: Reflex On");
|
||||
GameOptionsSchema.LatencyVendorOf = () => LatencyVendor.Amd;
|
||||
Equal(0, f.Get(GameOptionsSchema.LatencyKey), "AMD: Anti-Lag 2's Off (Reflex's line is NVIDIA's)");
|
||||
Equal(1, f.Set(GameOptionsSchema.LatencyKey, 2), "AMD: On, its last");
|
||||
Equal("nvidia_reflex=1,amd_anti-lag_2=1", Parts(GameOptionsSchema.LatencyKey), "Anti-Lag 2 on, Reflex as it was");
|
||||
GameOptionsSchema.LatencyVendorOf = () => LatencyVendor.None;
|
||||
f.Set(GameOptionsSchema.LatencyKey, 1);
|
||||
Equal("nvidia_reflex=1,amd_anti-lag_2=1", Parts(GameOptionsSchema.LatencyKey), "neither: nothing changes");
|
||||
}
|
||||
finally { GameOptionsSchema.LatencyVendorOf = vendorBefore; }
|
||||
Equal(2, f.Set("steady_frame_rate", 5), "a part by its own key: in its range");
|
||||
Equal(3, f.Get(GameOptionsSchema.PacingKey), "and the row shows it");
|
||||
// (a pair the old launcher could save both of: the row as the game shows it)
|
||||
var both = GameOptionsFile.Load(NewGameFolder("game-options-both", "frame_generation=3\ndlss_frame_generation=1\nhdr=1\nrenodx_hdr=1\nframe_pacing=0\nsteady_frame_rate=1\noptions_version=8\n"));
|
||||
Equal("NVIDIA DLSS 2x", both.Label(GameOptionsSchema.FrameGenKey), "DLSS's frame generation over the renderer's");
|
||||
Equal("Expanded", both.Label(GameOptionsSchema.HdrKey), "RenoDX only with Native");
|
||||
Equal("Steady, any rate", both.Label(GameOptionsSchema.PacingKey), "steady over pacing off");
|
||||
|
||||
// (Apply: the preset first, then the rest by the same rules)
|
||||
// (the Upscaler: an engine; the Render resolution's Native goes with it, upscaler_rows.h step_engine)
|
||||
var u = GameOptionsFile.Load(NewGameFolder("game-options-up", OptionsFixture)); // (dlss=0, resolution=1: 100%)
|
||||
u.Set("dlss", 3);
|
||||
Equal(6, u.Get("dlss"), "FSR 3.1 from 100%: its native AA");
|
||||
u.Set("resolution", 4);
|
||||
Equal(3, u.Get("dlss"), "a mode: FSR 3.1");
|
||||
u.Set("dlss", 1);
|
||||
Equal(1, u.Get("dlss"), "DLSS from 50%: DLSS");
|
||||
Equal(4, u.Get("resolution"), "50% is DLSS's Performance");
|
||||
u.Set("dlss", 0);
|
||||
u.Set("resolution", 2);
|
||||
u.Set("dlss", 3);
|
||||
Equal(3, u.Get("resolution"), "75% with FSR 3.1: 67%");
|
||||
u.Set("dlss", 0);
|
||||
u.Set("resolution", GameOptionsSchema.NativeStep);
|
||||
Equal(1, u.Get("resolution"), "the game's own at Native: 100%");
|
||||
Equal(2, u.Set("dlss", 2), "DLAA by its saved value: as it is");
|
||||
|
||||
// (Apply: each with Set's rules)
|
||||
var b = GameOptionsFile.Load(NewGameFolder("game-options-apply", OptionsFixture));
|
||||
var got = b.Apply(new Dictionary<string, int> { ["frame_generation"] = 2, ["quality_preset"] = 3, ["sharpness"] = 30 });
|
||||
Equal(3, got["quality_preset"], "a preset row at the preset's own value keeps the preset");
|
||||
Equal(2, got["frame_generation"], "frame generation set");
|
||||
Equal(1, b.Get("upscaling"), "Balanced: Catmull-Rom");
|
||||
var c = b.Apply(new Dictionary<string, int> { ["quality_preset"] = 5, ["sharpness"] = 80 });
|
||||
Equal(0, c["quality_preset"], "a preset row changed after it: Custom, as in the game");
|
||||
Equal(80, c["sharpness"], "and its value");
|
||||
var got = b.Apply(new Dictionary<string, int> { [GameOptionsSchema.FrameGenKey] = 2, ["steady_frame_rate"] = 2, ["sharpness"] = 30 });
|
||||
Equal(2, got[GameOptionsSchema.FrameGenKey], "frame generation set");
|
||||
Equal(2, got["steady_frame_rate"], "a part by its key");
|
||||
Equal(30, got["sharpness"], "sharpness");
|
||||
var changes = b.Changes.Count;
|
||||
Throws<KeyNotFoundException>(() => b.Apply(new Dictionary<string, int> { ["vsync"] = 0, ["descriptor_reuse"] = 0 }), "a key that is no row");
|
||||
Throws<KeyNotFoundException>(() => b.Apply(new Dictionary<string, int> { ["quality_preset"] = 3 }), "the Quality preset is gone");
|
||||
Equal(changes, b.Changes.Count, "nothing set then");
|
||||
Equal(1, b.Get("vsync"), "vsync untouched");
|
||||
b.Save();
|
||||
var back = GameOptionsFile.Load(Path.GetDirectoryName(b.Path)!);
|
||||
Equal(80, back.Get("sharpness"), "saved");
|
||||
Equal(30, back.Get("sharpness"), "saved");
|
||||
Equal(2, back.Get("frame_generation"), "saved");
|
||||
Equal("Steady, refresh steps", back.Label(GameOptionsSchema.PacingKey), "saved");
|
||||
Equal(0, back.Changes.Count, "a fresh read has no changes");
|
||||
}
|
||||
|
||||
@@ -507,15 +651,37 @@ static partial class Tests
|
||||
Equal(0, GameOptionsFile.Load(g).Get("ultrawide"), "without the screen: 16:9, as the game where it cannot ask");
|
||||
f.Set("sharpness", 30);
|
||||
f.Save();
|
||||
Equal("frame_pacing=1\r\nultrawide=2\r\nnvidia_reflex=0\r\nsharpness=30\r\noptions_version=7\r\npad_a=0\r\n",
|
||||
File.ReadAllText(Path.Combine(g, GameOptionsSchema.FileName)).Replace("tail_early=1\r\n", ""), "brought up to 7 as the game would read it");
|
||||
Check(File.ReadAllText(Path.Combine(g, GameOptionsSchema.FileName)).Contains("tail_early=1\r\noptions_version=7"), "the Debug tab's tail_early too, before the version");
|
||||
Equal("frame_pacing=1\r\nultrawide=2\r\nnvidia_reflex=0\r\nsharpness=30\r\noptions_version=8\r\npad_a=0\r\n",
|
||||
File.ReadAllText(Path.Combine(g, GameOptionsSchema.FileName)).Replace("tail_early=1\r\n", ""), "brought up to 8 as the game would read it");
|
||||
Check(File.ReadAllText(Path.Combine(g, GameOptionsSchema.FileName)).Contains("tail_early=1\r\noptions_version=8"), "the Debug tab's tail_early too, before the version");
|
||||
var again = GameOptionsFile.Load(g);
|
||||
Equal(7, again.Version, "now 7");
|
||||
again.Set("frame_pacing", 0);
|
||||
Equal(8, again.Version, "now 8");
|
||||
again.Set(GameOptionsSchema.PacingKey, 0);
|
||||
again.Save();
|
||||
Equal(0, GameOptionsFile.Load(g).Get("frame_pacing"), "and from 7 on the choice is read as it is");
|
||||
|
||||
// ((Triforce, options_version 8) a v0.5.1 file (7, the old rows' lines in it): the handheld profile becomes the Output
|
||||
// resolution's 1536x864, the shared stick dead zone each stick's own that had none (merged_rows.h migrate)
|
||||
var h = NewGameFolder("game-options-v7", "output_res=1\nhandheld_profile=1\nstick_dead_zone=3\nright_stick_dead_zone=12\nquality_preset=4\nupscaling=2\noptions_version=7\n");
|
||||
var hf = GameOptionsFile.Load(h);
|
||||
Equal(7, hf.Get("output_res"), "the handheld profile: the handheld output");
|
||||
Equal("1536x864 (handheld)", hf.Label("output_res"), "its label");
|
||||
Equal(15, hf.Get("left_stick_dead_zone"), "the shared 15% into the left stick's own");
|
||||
Equal(12, hf.Get("right_stick_dead_zone"), "the right stick's own kept");
|
||||
Equal("", string.Join(",", hf.UnknownKeys), "the old rows' lines: known");
|
||||
hf.Set("vsync", 0);
|
||||
hf.Save();
|
||||
Equal("output_res=7\nhandheld_profile=1\nstick_dead_zone=3\nright_stick_dead_zone=12\nquality_preset=4\nupscaling=2\nvsync=0\nleft_stick_dead_zone=15\noptions_version=8\n",
|
||||
File.ReadAllText(Path.Combine(h, GameOptionsSchema.FileName)), "brought up to 8: the moved values written, the old lines left for the game to drop");
|
||||
var h8 = GameOptionsFile.Load(h);
|
||||
h8.Set("output_res", 1);
|
||||
h8.Save();
|
||||
Equal(1, GameOptionsFile.Load(h).Get("output_res"), "from 8 on the old handheld_profile line moves nothing");
|
||||
// (a 436f9ac-based build's 7: none of those lines, nothing moves)
|
||||
var n7 = GameOptionsFile.Load(NewGameFolder("game-options-n7", "output_res=3\nleft_stick_dead_zone=-1\noptions_version=7\n"));
|
||||
Equal(3, n7.Get("output_res"), "no handheld line: the output as it is");
|
||||
Equal(-1, n7.Get("left_stick_dead_zone"), "no shared line: the default");
|
||||
|
||||
// (no options_version line: Game speed real time; no resolution line but the old dynamic_resolution)
|
||||
var o = NewGameFolder("game-options-v0", "game_speed=0\ndynamic_resolution=0\n");
|
||||
var of = GameOptionsFile.Load(o);
|
||||
@@ -523,20 +689,23 @@ static partial class Tests
|
||||
Equal(1, of.Get("resolution"), "dynamic_resolution 0: 100%");
|
||||
Equal(2, of.Get("nvidia_reflex"), "Reflex On + Boost before 5");
|
||||
|
||||
// (no file: the defaults; a Save makes it with the changed rows and the version)
|
||||
// (no file: the defaults; a Save makes it with the changed values, in the menu's order, and the version)
|
||||
var n = Path.Combine(NewRoot("game-options-new"), "game");
|
||||
Directory.CreateDirectory(n);
|
||||
var nf = GameOptionsFile.Load(n);
|
||||
Check(!nf.Exists, "no file");
|
||||
Equal(1, nf.Get("vsync"), "default");
|
||||
Equal("Off", nf.Label("fullscreen"), "default label");
|
||||
Equal("Even", nf.Label(GameOptionsSchema.PacingKey), "frame pacing's default");
|
||||
nf.Save();
|
||||
Check(!File.Exists(nf.Path), "nothing to write: no file made");
|
||||
nf.Set("vsync", 0);
|
||||
nf.Set("master_volume", 83);
|
||||
nf.Set("vsync", 0);
|
||||
nf.Set(GameOptionsSchema.PacingKey, 3);
|
||||
nf.Save();
|
||||
var nl = OperatingSystem.IsWindows() ? "\r\n" : "\n";
|
||||
Equal("vsync=0" + nl + "master_volume=85" + nl + "options_version=7" + nl, File.ReadAllText(nf.Path), "a new file: the rows in the menu's order, then the version");
|
||||
Equal("vsync=0" + nl + "steady_frame_rate=2" + nl + "master_volume=85" + nl + "options_version=8" + nl, File.ReadAllText(nf.Path),
|
||||
"a new file: the values in the menu's order (a merged row's parts at its place; frame_pacing at its default not written), then the version");
|
||||
Check(nf.Exists, "now there");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,6 +276,24 @@ static partial class Tests
|
||||
Equal("library", File.ReadAllText(Path.Combine(tools.Folder, "python", "lib.txt")), "the base moved over");
|
||||
File.WriteAllText(Path.Combine(tools.Folder, "python", "lib.txt"), "changed!");
|
||||
Check(!Tools.HasBase(b, tools.Folder, null), "a changed base file (other size) is not the base");
|
||||
|
||||
// (11-21, ticket "Every tools update re-downloads the whole base": Python rewrites its bytecode caches as it runs, and
|
||||
// their sizes in base.list made every update fetch the base again)
|
||||
var root2 = NewRoot("parts-pyc");
|
||||
var t2 = new Tools(Ctx(root2));
|
||||
var list2 = BaseList(("python/python.exe", "py"), ("python/Lib/__pycache__/os.cpython-314.pyc", "packed bytes"));
|
||||
var b2 = Tools.ParseBaseList(list2)!;
|
||||
Directory.CreateDirectory(Path.Combine(t2.Folder, "python", "Lib", "__pycache__"));
|
||||
File.WriteAllText(Path.Combine(t2.Folder, "python", "python.exe"), "py");
|
||||
File.WriteAllText(Path.Combine(t2.Folder, "python", "Lib", "__pycache__", "os.cpython-314.pyc"), "rewritten by python, longer");
|
||||
Check(Tools.HasBase(b2, t2.Folder, null), "a bytecode cache Python rewrote is still the base");
|
||||
File.Delete(Path.Combine(t2.Folder, "python", "Lib", "__pycache__", "os.cpython-314.pyc"));
|
||||
File.Delete(Path.Combine(t2.Folder, Tools.BaseHave));
|
||||
Check(Tools.HasBase(b2, t2.Folder, null), "and one missing (Python makes it again)");
|
||||
File.WriteAllText(Path.Combine(t2.Folder, "python", "python.exe"), "other");
|
||||
File.Delete(Path.Combine(t2.Folder, Tools.BaseHave));
|
||||
Check(!Tools.HasBase(b2, t2.Folder, null), "a real base file changed still is not");
|
||||
Check(Tools.Regenerated(@"python\Lib\x\__pycache__\a.pyc") && !Tools.Regenerated("python/Lib/os.py"), "what counts as rewritten");
|
||||
}
|
||||
|
||||
static async Task ToolsUpdate()
|
||||
|
||||
Reference in New Issue
Block a user