RynthCore as of 2026-11-12 (internal eb12118): release 2026.11.12.1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
55e15c0ac4
commit
7f1e7d5039
71 changed files with 3413 additions and 587 deletions
|
|
@ -13,7 +13,7 @@ namespace RynthCore.Engine.UI
|
|||
namespace TrackerSettingsTests
|
||||
{
|
||||
// Offline tests for the Tracker's settings file. See the csproj. TrackerSettings loads once per
|
||||
// process, so the order matters: an old-style file first, then saves.
|
||||
// process, so the order matters: an old-style file first, then saves; other files go through Parse.
|
||||
internal static class Program
|
||||
{
|
||||
private static int _fails, _asserts;
|
||||
|
|
@ -67,6 +67,83 @@ namespace TrackerSettingsTests
|
|||
Check(!TrackerSettings.TextOnly, "Text only is off at once");
|
||||
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
|
||||
Check(!doc.RootElement.GetProperty("textOnly").GetBoolean(), "Text only off is saved");
|
||||
|
||||
// 2026-11-12: full click-through and hidden stats.
|
||||
// The old file had neither: click-through off, every stat shown.
|
||||
Check(!TrackerSettings.ClickThrough, "an old file (no clickThrough) leaves click-through off");
|
||||
Check(TrackerSettings.HiddenIds.Length == 0, "an old file (no hidden) shows every stat");
|
||||
foreach (TrackerStat s in TrackerSettings.Stats)
|
||||
Check(!TrackerSettings.IsLabelHidden(s.Label), $"{s.Label} shown by default");
|
||||
|
||||
// Click-through on: saved with the rest.
|
||||
TrackerSettings.SetTextOnly(true);
|
||||
TrackerSettings.SetClickThrough(true);
|
||||
Check(TrackerSettings.ClickThrough, "click-through is on at once");
|
||||
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
|
||||
{
|
||||
Check(doc.RootElement.GetProperty("clickThrough").GetBoolean(), "click-through on is saved");
|
||||
Check(doc.RootElement.GetProperty("textOnly").GetBoolean(), "saving click-through keeps Text only");
|
||||
Check(doc.RootElement.GetProperty("bgAlpha").GetInt32() == 40, "saving click-through keeps the opacity");
|
||||
}
|
||||
|
||||
// Hiding stats: by id, the version goes up, saved in the table's order, the rest kept.
|
||||
int v0 = TrackerSettings.HiddenVersion;
|
||||
TrackerSettings.SetHidden("deaths", true);
|
||||
TrackerSettings.SetHidden("lum5m", true);
|
||||
Check(TrackerSettings.HiddenVersion > v0, "hiding a stat bumps HiddenVersion");
|
||||
Check(TrackerSettings.IsLabelHidden("Deaths") && TrackerSettings.IsLabelHidden("Lum/5m"), "hidden by their labels");
|
||||
Check(!TrackerSettings.IsLabelHidden("XP"), "XP still shown");
|
||||
int v1 = TrackerSettings.HiddenVersion;
|
||||
TrackerSettings.SetHidden("deaths", true);
|
||||
Check(TrackerSettings.HiddenVersion == v1, "hiding a hidden stat again changes nothing");
|
||||
TrackerSettings.SetHidden("nonsense", true);
|
||||
Check(TrackerSettings.HiddenVersion == v1 && !TrackerSettings.IsHidden("nonsense"), "an unknown id is not hidden");
|
||||
Check(TrackerSettings.IsLabelHidden("Some new row") == false, "a label not in the table is shown");
|
||||
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
|
||||
{
|
||||
var arr = doc.RootElement.GetProperty("hidden").EnumerateArray().Select(e => e.GetString()).ToArray();
|
||||
Check(arr.SequenceEqual(new[] { "lum5m", "deaths" }), $"hidden saved in order (got [{string.Join(",", arr)}])");
|
||||
Check(doc.RootElement.GetProperty("clickThrough").GetBoolean(), "saving hidden keeps click-through");
|
||||
}
|
||||
TrackerSettings.SetHidden("deaths", false);
|
||||
Check(!TrackerSettings.IsLabelHidden("Deaths"), "a stat shown again");
|
||||
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
|
||||
Check(doc.RootElement.GetProperty("hidden").GetArrayLength() == 1, "showing a stat is saved");
|
||||
TrackerSettings.ShowAll();
|
||||
Check(TrackerSettings.HiddenIds.Length == 0, "Show all clears the hidden set");
|
||||
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
|
||||
Check(doc.RootElement.GetProperty("hidden").GetArrayLength() == 0, "Show all is saved");
|
||||
TrackerSettings.SetClickThrough(false);
|
||||
using (var doc = JsonDocument.Parse(File.ReadAllText(file)))
|
||||
Check(!doc.RootElement.GetProperty("clickThrough").GetBoolean(), "click-through off is saved");
|
||||
|
||||
// The stat ids are unique and every TrackerSource label is in the table.
|
||||
Check(TrackerSettings.Stats.Select(s => s.Id).Distinct().Count() == TrackerSettings.Stats.Length, "stat ids unique");
|
||||
Check(TrackerSettings.Stats.Select(s => s.Label).Distinct().Count() == TrackerSettings.Stats.Length, "stat labels unique");
|
||||
foreach (string label in new[] { "Session", "XP/hr", "Lum/hr", "Lum/5m", "Pass/hr", "Rad/hr", "Kls/hr", "XP", "Lum", "Pass-up", "Rad", "Kills", "XP/kl", "Deaths" })
|
||||
Check(TrackerSettings.StatId(label) != label, $"{label} has a stat id");
|
||||
|
||||
// Parse: round trip of ToJson, old files, bad values.
|
||||
var full = TrackerSettings.Parse(TrackerSettings.ToJson(77, true, true, new[] { "kills", "session", "rad" }));
|
||||
Check(full.BgAlpha == 77 && full.TextOnly && full.ClickThrough, "Parse(ToJson) keeps opacity, Text only, click-through");
|
||||
Check(full.Hidden.SequenceEqual(new[] { "session", "rad", "kills" }), "Parse(ToJson) keeps hidden, in table order");
|
||||
var old = TrackerSettings.Parse("{\"bgAlpha\":100,\"textOnly\":true}");
|
||||
Check(old.BgAlpha == 100 && old.TextOnly && !old.ClickThrough && old.Hidden.Length == 0, "an old file parses with the new defaults");
|
||||
var empty = TrackerSettings.Parse("{}");
|
||||
Check(empty.BgAlpha == 0xCC && !empty.TextOnly && !empty.ClickThrough && empty.Hidden.Length == 0, "an empty file is all defaults");
|
||||
var bad = TrackerSettings.Parse("{\"bgAlpha\":\"x\",\"textOnly\":1,\"clickThrough\":\"yes\",\"hidden\":\"deaths\"}");
|
||||
Check(bad.BgAlpha == 0xCC && !bad.TextOnly && !bad.ClickThrough && bad.Hidden.Length == 0, "values of the wrong kind are ignored");
|
||||
var mixed = TrackerSettings.Parse("{\"bgAlpha\":999,\"clickThrough\":true,\"hidden\":[\"deaths\",5,null,\"bogus\",\"deaths\",\"xp\",{}]}");
|
||||
Check(mixed.BgAlpha == 255, "an opacity over 255 is clamped");
|
||||
Check(mixed.ClickThrough, "a good key beside bad ones is still read");
|
||||
Check(mixed.Hidden.SequenceEqual(new[] { "xp", "deaths" }), $"only known string ids kept, once (got [{string.Join(",", mixed.Hidden)}])");
|
||||
var notObject = TrackerSettings.Parse("[1,2]");
|
||||
Check(notObject.BgAlpha == 0xCC && notObject.Hidden.Length == 0, "a file that is not an object is all defaults");
|
||||
using (var doc = JsonDocument.Parse(TrackerSettings.ToJson(10, false)))
|
||||
{
|
||||
Check(!doc.RootElement.GetProperty("clickThrough").GetBoolean(), "ToJson defaults click-through off");
|
||||
Check(doc.RootElement.GetProperty("hidden").GetArrayLength() == 0, "ToJson defaults to nothing hidden");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue