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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user