mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-21 00:59:59 -04:00
Triforce v0.6.0 "Sage Of Power"
Faster frames (the replay's memory work, held submits, helper threads, collection and capture cuts), the game letting old areas go (QueryMemoryInfo), the 0.5.2 stutter fixed, AMD RX 5000/6000 and integrated-GPU fixes, the GPU device chosen by name, the in-game menus and launcher reworked, controller, Linux and benchmark fixes.
This commit is contained in:
@@ -11,6 +11,12 @@ static partial class Tests
|
||||
(string, Func<Task>) Sync(string n, Action a) => (n, () => { a(); return Task.CompletedTask; });
|
||||
yield return Sync("settings: registry.txt round trip", SettingsTestRoot);
|
||||
yield return Sync("settings: builder.ini round trip (Linux store)", SettingsIni);
|
||||
yield return Sync("linux: the user folder follows the saves (triforce/user, then hookshot, then the game's)", LinuxUserFolder);
|
||||
yield return Sync("benchmark: an uneven run gets Steady frame rate Refresh steps, an even one keeps the player's", BenchSteady);
|
||||
yield return Sync("benchmark: a place left out is read and said", BenchSkipped);
|
||||
yield return Sync("settings: color scheme, the page's 'color' read", ColorParse);
|
||||
yield return Sync("settings: color scheme kept and read back (registry.txt, builder.ini, old files)", ColorKept);
|
||||
yield return Sync("settings: color scheme, the launcher's color (--snapshot, commands out of order)", ColorChoice);
|
||||
yield return Sync("startup: argument parsing", StartArgsParsing);
|
||||
yield return Sync("startup: lock name algorithm", LockName);
|
||||
yield return Sync("startup: installed run, old exe removed, second start defers", StartupInstalled);
|
||||
@@ -43,6 +49,8 @@ static partial class Tests
|
||||
yield return Sync("steam: add, set, remove in a fake Steam folder", SteamShortcut);
|
||||
yield return Sync("report: names out", ReportNames);
|
||||
yield return Sync("languages", LanguagesTest);
|
||||
yield return Sync("media: the game's music loop through decode, mix and WAV (smpl)", MusicLoop);
|
||||
yield return Sync("media: the WAV cache made again with the loop, an older file replaced", MusicCache);
|
||||
}
|
||||
|
||||
// ---- settings ----
|
||||
@@ -77,6 +85,48 @@ static partial class Tests
|
||||
Equal(null, Ctx(root).Settings.Language, "NoWrites writes nothing");
|
||||
}
|
||||
|
||||
static void BenchSkipped()
|
||||
{
|
||||
var root = NewRoot("benchskip");
|
||||
var f = Path.Combine(root, "results.json");
|
||||
File.WriteAllText(f, "{\"version\":1,\"stopped\":false,\"scenes\":[{\"name\":\"Hyrule Field\",\"avg\":60,\"low1\":50,\"frametimes_ms\":[16.6]}],\"skipped\":[\"Lake Hylia\"],\"settings\":{}}");
|
||||
var run = Benchmark.ReadResults(f, TimeSpan.FromSeconds(1));
|
||||
Equal(1, run.Scenes.Count, "the measured place");
|
||||
Equal("Lake Hylia", run.Skipped.Single(), "the place left out");
|
||||
Check(Benchmark.SkippedNote(run.Skipped).Contains("Lake Hylia was left out"), "the verdict's note");
|
||||
Equal("", Benchmark.SkippedNote(Array.Empty<string>()), "no note without one");
|
||||
File.WriteAllText(f, "{\"version\":1,\"stopped\":false,\"scenes\":[]}");
|
||||
Equal(0, Benchmark.ReadResults(f, TimeSpan.Zero).Skipped.Count, "an older game's results: none");
|
||||
}
|
||||
|
||||
static void BenchSteady()
|
||||
{
|
||||
var now = new Dictionary<string, int> { [Benchmark.KSteady] = 0 };
|
||||
var uneven = new[] { new PlaceResult("Hyrule Field", 45, 28), new PlaceResult("Kokiri Forest", 58, 55) };
|
||||
var r = Benchmark.Recommend(now, uneven, null, null, 60).Single(c => c.Key == Benchmark.KSteady);
|
||||
Equal(Benchmark.SteadyRefreshSteps, r.To, "lows under 80 % of the average: Refresh steps (36 fps on 60 Hz was uneven)");
|
||||
var even = new[] { new PlaceResult("Hyrule Field", 60, 58) };
|
||||
Equal(0, Benchmark.Recommend(now, even, null, null, 60).Single(c => c.Key == Benchmark.KSteady).To, "even: the player's own");
|
||||
}
|
||||
|
||||
static void LinuxUserFolder()
|
||||
{
|
||||
var root = NewRoot("linuxuser");
|
||||
var p = new LinuxPlatform(new Dictionary<string, string?> { ["TRIFORCE_TEST_ROOT"] = root });
|
||||
var game = Path.Combine(root, "game");
|
||||
var now = Path.Combine(p.DataHome, "triforce", "user");
|
||||
var old = Path.Combine(p.DataHome, "hookshot");
|
||||
Equal(now, p.UserFolder(game), "no saves anywhere: the new folder");
|
||||
Directory.CreateDirectory(Path.Combine(game, "user", "save", "1"));
|
||||
Equal(Path.Combine(game, "user"), p.UserFolder(game), "saves the game could not move out of its folder: there");
|
||||
Directory.CreateDirectory(Path.Combine(old, "save", "1"));
|
||||
Equal(old, p.UserFolder(game), "an older build's ~/.local/share/hookshot, not renamed yet: there");
|
||||
Equal(Path.Combine(old, "save", "abc"), p.SaveFolder(game, "abc"), "SaveFolder under it");
|
||||
Directory.CreateDirectory(Path.Combine(now, "save", "1"));
|
||||
Equal(now, p.UserFolder(game), "triforce/user once it has saves: first");
|
||||
Equal(Path.Combine(now, "save", "abc"), p.SaveFolder(game, "abc"), "SaveFolder under the new one");
|
||||
}
|
||||
|
||||
static void SettingsIni()
|
||||
{
|
||||
var root = NewRoot("ini");
|
||||
@@ -95,6 +145,119 @@ static partial class Tests
|
||||
Throws<ArgumentException>(() => s.Set("x", "a\nb"), "a line break is refused");
|
||||
}
|
||||
|
||||
static void ColorParse()
|
||||
{
|
||||
Equal("#e0b23e", LauncherColor.Default, "the default is Triforce gold, the page's GOLD");
|
||||
Equal("#5e9cf0", LauncherColor.Parse("#5E9CF0"), "upper case kept as lower case");
|
||||
Equal("#0a0908", LauncherColor.Parse("#0a0908"), "lower case as it is");
|
||||
foreach (var bad in new[] { null, "", "#", "#fff", "e0b23e", "#e0b23", "#e0b23e0", "#e0b23eff", "#gggggg", " #e0b23e", "#e0b23e ",
|
||||
"#e0b23e\n", "##e0b23", "rgb(224,178,62)", "gold", "#e0 23e", "#" + (char)0xFF45 + "0b23e" })
|
||||
Equal(null, LauncherColor.Parse(bad), "not a #rrggbb: [" + bad + "]");
|
||||
|
||||
string? Cmd(string json) => LauncherColor.FromCommand(System.Text.Json.Nodes.JsonNode.Parse(json));
|
||||
Equal("#5e9cf0", Cmd("""{"t":"cmd","c":"color","hex":"#5E9CF0"}"""), "the page's message");
|
||||
Equal("#e0b23e", Cmd("""{"t":"cmd","c":"color","hex":"#e0b23e"}"""), "Reset to gold");
|
||||
Equal(null, Cmd("""{"t":"cmd","c":"color"}"""), "no hex");
|
||||
Equal(null, Cmd("""{"t":"cmd","c":"color","hex":null}"""), "hex null");
|
||||
Equal(null, Cmd("""{"t":"cmd","c":"color","hex":14725694}"""), "hex a number");
|
||||
Equal(null, Cmd("""{"t":"cmd","c":"color","hex":true}"""), "hex a bool");
|
||||
Equal(null, Cmd("""{"t":"cmd","c":"color","hex":["#e0b23e"]}"""), "hex an array");
|
||||
Equal(null, Cmd("""{"t":"cmd","c":"color","hex":{"v":"#e0b23e"}}"""), "hex an object");
|
||||
Equal(null, Cmd("""{"t":"cmd","c":"color","hex":"#e0b23e; background:url(x)"}"""), "hex with more after it");
|
||||
Equal(null, Cmd("""{"t":"cmd","c":"color","hex":"blue"}"""), "a name");
|
||||
Equal(null, Cmd("""["#e0b23e"]"""), "a message that is not an object");
|
||||
Equal(null, LauncherColor.FromCommand(null), "no message");
|
||||
}
|
||||
|
||||
static void ColorKept()
|
||||
{
|
||||
// registry.txt (Windows' values in a test run): a file from before the color has no Color line and reads as gold
|
||||
var root = NewRoot("color");
|
||||
File.WriteAllLines(Path.Combine(root, "registry.txt"), new[] { @"Software\Triforce\Language=de", @"Software\Triforce\MusicVolume=55", @"Software\Triforce\Muted=1" });
|
||||
var old = Ctx(root);
|
||||
Equal(LauncherColor.Default, old.Settings.Color, "an old settings file: the default");
|
||||
Equal("de", old.Settings.Language, "and its other values as before");
|
||||
Equal(55, old.Settings.MusicVolume, "music volume as before");
|
||||
Check(old.Settings.Muted, "muted as before");
|
||||
Check(!File.ReadAllText(Path.Combine(root, "registry.txt")).Contains("Color"), "reading writes nothing");
|
||||
|
||||
old.Settings.Color = "#5E9CF0";
|
||||
Equal("#5e9cf0", Ctx(root).Settings.Color, "kept, lower case, read back by a new start");
|
||||
var lines = File.ReadAllLines(Path.Combine(root, "registry.txt"));
|
||||
Check(lines.Contains(@"Software\Triforce\Color=#5e9cf0"), "one line beside the others: " + string.Join(" / ", lines));
|
||||
Check(lines.Contains(@"Software\Triforce\Language=de") && lines.Contains(@"Software\Triforce\MusicVolume=55"), "the other values kept");
|
||||
|
||||
Throws<ArgumentException>(() => old.Settings.Color = "blue", "a bad color is refused");
|
||||
Throws<ArgumentException>(() => old.Settings.Color = "#fff", "three digits are refused");
|
||||
Equal("#5e9cf0", Ctx(root).Settings.Color, "and the kept one stays");
|
||||
|
||||
Ctx(root).Settings.Color = LauncherColor.Default;
|
||||
Equal(LauncherColor.Default, Ctx(root).Settings.Color, "Reset to gold kept");
|
||||
Equal(1, File.ReadAllLines(Path.Combine(root, "registry.txt")).Count(l => l.StartsWith(@"Software\Triforce\Color=")), "one line per name after a write");
|
||||
|
||||
// a kept value that does not read (changed by hand) is the default, not an error
|
||||
Ctx(root).Settings.Set(SettingNames.Color, "#12345");
|
||||
Equal(LauncherColor.Default, Ctx(root).Settings.Color, "an unreadable kept value: the default");
|
||||
Ctx(root).Settings.Set(SettingNames.Color, "#ABCDEF");
|
||||
Equal("#abcdef", Ctx(root).Settings.Color, "a kept upper-case value reads as lower case");
|
||||
|
||||
var snap = Ctx(root);
|
||||
snap.NoWrites = true;
|
||||
snap.Settings.Color = "#4fc3b4";
|
||||
Equal("#abcdef", Ctx(root).Settings.Color, "NoWrites writes no color");
|
||||
|
||||
Ctx(root).Platform.Settings.RemoveAll();
|
||||
Equal(LauncherColor.Default, Ctx(root).Settings.Color, "settings removed (uninstall): the default");
|
||||
|
||||
// builder.ini (Linux): its own key, the Tk builder's keys kept
|
||||
var iroot = NewRoot("color-ini");
|
||||
var file = Path.Combine(iroot, "triforce", "builder.ini");
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(file)!);
|
||||
File.WriteAllText(file, "kind=nup\nout=/home/a/Games/Triforce\nlanguage=en-US\nMusicVolume=30\n");
|
||||
var ini = new Settings(new IniSettingsStore(file), () => false);
|
||||
Equal(LauncherColor.Default, ini.Color, "an old builder.ini: the default");
|
||||
Equal(30, ini.MusicVolume, "and its volume as before");
|
||||
ini.Color = "#C77DDA";
|
||||
Equal("#c77dda", new Settings(new IniSettingsStore(file), () => false).Color, "kept in builder.ini");
|
||||
var text = File.ReadAllText(file);
|
||||
Check(text.Contains("Color=#c77dda\n") && text.Contains("kind=nup\n") && text.Contains("out=/home/a/Games/Triforce\n") && text.Contains("MusicVolume=30\n"),
|
||||
"Color= beside the Tk builder's keys: " + text);
|
||||
}
|
||||
|
||||
static void ColorChoice()
|
||||
{
|
||||
static System.Text.Json.Nodes.JsonNode Msg(string hex) => System.Text.Json.Nodes.JsonNode.Parse("{\"t\":\"cmd\",\"c\":\"color\",\"hex\":\"" + hex + "\"}")!;
|
||||
var root = NewRoot("color-choice");
|
||||
Ctx(root).Settings.Color = "#5e9cf0";
|
||||
|
||||
// --snapshot (NoWrites): the choice is not kept, but state.color (Current) is the player's, not the kept one
|
||||
var snap = Ctx(root);
|
||||
snap.NoWrites = true;
|
||||
var c = new LauncherColorChoice(snap.Settings);
|
||||
Equal("#5e9cf0", c.Current, "before the page sends one: the kept color");
|
||||
Equal("#c77dda", c.Take(Msg("#C77DDA")), "the page's color taken, lower case");
|
||||
c.Keep();
|
||||
Equal("#c77dda", c.Current, "NoWrites: the chosen color, so the Settings list does not set the page back");
|
||||
Equal("#5e9cf0", Ctx(root).Settings.Color, "and nothing written");
|
||||
Equal(null, c.Take(Msg("blue")), "a bad color is not taken");
|
||||
Equal("#c77dda", c.Current, "and the choice stays");
|
||||
|
||||
// a 'settings.list' handled before the 'color' just ahead of it has been kept: Current is already the new color
|
||||
var ctx = Ctx(root);
|
||||
c = new LauncherColorChoice(ctx.Settings);
|
||||
c.Take(Msg("#4fc3b4"));
|
||||
Equal("#4fc3b4", c.Current, "taken as it arrives, before its worker runs");
|
||||
Equal("#5e9cf0", ctx.Settings.Color, "not kept yet");
|
||||
// two colors whose workers run the wrong way round: the newest is kept
|
||||
c.Take(Msg("#e05a5a"));
|
||||
c.Keep(); c.Keep();
|
||||
Equal("#e05a5a", Ctx(root).Settings.Color, "the newest kept");
|
||||
Equal("#e05a5a", c.Current, "and sent");
|
||||
c.Take(Msg(LauncherColor.Default));
|
||||
c.Keep();
|
||||
Equal(LauncherColor.Default, Ctx(root).Settings.Color, "Reset to gold kept");
|
||||
}
|
||||
|
||||
// ---- startup ----
|
||||
|
||||
static void StartArgsParsing()
|
||||
|
||||
Reference in New Issue
Block a user