Revamp UI a whole lot

This commit is contained in:
2026-11-18 19:42:44 +01:00
parent 260abc2c98
commit fdde7f9d80
57 changed files with 2667 additions and 935 deletions
+199 -114
View File
@@ -359,6 +359,142 @@ public class CombatLayoutTests
_root.style.height = size.y;
}
[UnityTest]
public IEnumerator CombatUsesProcessRowsCommandTokensAndNarrowPaneSwitching()
{
Resize(new Vector2(1280, 720));
Call(_view, "RefreshEnemies");
Call(_view, "RefreshCommandPrompt");
for (int frame = 0; frame < 4; frame++) yield return null;
var prompt = _root.Q("CombatCommandPrompt");
Assert.That(prompt, Is.Not.Null);
Assert.That(prompt.Q<Label>(className: "syntax-prompt").text, Does.StartWith("player@gentoo"));
Assert.That(prompt.Q<Label>(className: "syntax-command").text, Is.EqualTo("exec"));
Assert.That(prompt.Q<Label>(className: "syntax-argument").text, Does.Contain("--target pid"));
var header = _root.Q("ProcessTableHeader");
CollectionAssert.AreEqual(new[] { "PID", "STATE", "PROCESS", "UPTIME", "SHIELD", "NEXT", "RESULT" },
header.Query<Label>(className: "process-column").ToList().Select(label => label.text).ToArray());
var stateColumn = header.Q<Label>(className: "process-col-state");
var processColumn = header.Q<Label>(className: "process-col-name");
Assert.That(processColumn.worldBound.xMin - stateColumn.worldBound.xMin, Is.GreaterThanOrEqualTo(125));
Assert.That(processColumn.worldBound.width, Is.InRange(230, 250));
var processes = _root.Query<Button>(className: "enemy-card").ToList();
Assert.That(processes.Count, Is.EqualTo(2));
Assert.That(processes.Select(row => row.Q<Label>(className: "process-pid").text).Distinct().Count(), Is.EqualTo(2));
foreach (var process in processes)
{
Assert.That(process.Q<Label>(className: "process-state").text, Is.Not.Empty);
Assert.That(process.Q<Label>(className: "enemy-name").text, Is.Not.Empty);
Assert.That(process.Q(className: "process-col-uptime"), Is.Not.Null);
Assert.That(process.Q("ProcessIntent"), Is.Not.Null);
Assert.That(process.Q<Label>("ProcessResult"), Is.Not.Null);
Assert.That(process.Q<Label>(className: "process-behavior"), Is.Null,
"Lifecycle and intent columns replace the old expanding explanation line.");
}
Resize(new Vector2(390, 844));
for (int frame = 0; frame < 5; frame++) yield return null;
Assert.That(_root.ClassListContains("narrow"), Is.True);
var hand = _root.Q<Button>("CombatPane_hand");
using (var submit = NavigationSubmitEvent.GetPooled())
{
submit.target = hand;
hand.SendEvent(submit);
}
Assert.That(_root.ClassListContains("combat-pane-hand"), Is.True);
Assert.That(hand.ClassListContains("selected"), Is.True);
Assert.That(_root.Q<Button>("CombatPane_processes").ClassListContains("selected"), Is.False);
LogAssert.NoUnexpectedReceived();
}
[UnityTest]
public IEnumerator RestartingZombieCannotWrapLivingTargetsOutOfTheProcessList()
{
var database = AssetDatabase.LoadAssetAtPath<CardDatabase>("Assets/Data/Cards/CardDatabase.asset");
var enemies = (List<EnemyInstance>)_combat.Enemies;
enemies.Clear();
var zombie = new EnemyInstance(EnemyArchetypeCatalog.Get("zombie_process"), 7);
zombie.MarkPendingRevive();
enemies.Add(zombie);
enemies.Add(new EnemyInstance(EnemyArchetypeCatalog.Get("cron_job"), 8));
var fetch = new CardInstance(database.FindById("lang_js_fetch"));
_combat.HandController.Add(fetch);
Assert.That(_combat.PlayCard(fetch), Is.False, "The first play should enter enemy targeting.");
Assert.That(_combat.PendingTargetCard, Is.SameAs(fetch));
Call(_view, "RefreshEnemies");
Resize(new Vector2(1280, 720));
for (int frame = 0; frame < 6; frame++) yield return null;
var rows = _root.Query<Button>(className: "enemy-card").ToList();
Assert.That(rows.Count, Is.EqualTo(2));
var zombieRow = rows.Single(row => row.Q<Label>(className: "enemy-name").text.Contains("Zombie"));
var cronRow = rows.Single(row => row.Q<Label>(className: "enemy-name").text.Contains("Cron"));
Assert.That(zombieRow.parent.resolvedStyle.flexWrap, Is.EqualTo(Wrap.NoWrap));
Assert.That(cronRow.worldBound.xMin, Is.EqualTo(zombieRow.worldBound.xMin).Within(1),
"A taller restarting process must not wrap the next target into an off-screen column.");
Assert.That(cronRow.worldBound.yMin, Is.GreaterThanOrEqualTo(zombieRow.worldBound.yMax - 1));
Assert.That(cronRow.enabledInHierarchy, Is.True);
Assert.That(cronRow.worldBound.width, Is.GreaterThan(100));
using (var submit = NavigationSubmitEvent.GetPooled())
{
submit.target = cronRow;
cronRow.SendEvent(submit);
}
Assert.That(_combat.PendingTargetCard, Is.Null);
Assert.That(_combat.HandController.Cards.Contains(fetch), Is.False,
"The living process below a restarting Zombie must remain selectable.");
LogAssert.NoUnexpectedReceived();
}
[UnityTest]
public IEnumerator DefaultCombatViewCollapsesSecondaryTelemetryUntilRequested()
{
Resize(new Vector2(1280, 720));
Call(_view, "RefreshTracks");
Call(_view, "RefreshHand");
for (int frame = 0; frame < 6; frame++) yield return null;
var scheduler = _root.Q(className: "scheduler");
Assert.That(scheduler.ClassListContains("scheduler-idle"), Is.True);
foreach (var zone in scheduler.Query(className: "track-zone").ToList())
Assert.That(zone.resolvedStyle.display, Is.EqualTo(DisplayStyle.None));
var journal = _root.Q<Foldout>(className: "combat-journal");
Assert.That(journal.value, Is.False, "The full log should be opt-in; its title still reports the latest event.");
for (int i = 0; i < 12; i++)
Call(_view, "AppendCombatLog", $"layout event {i}", "journal-operation");
for (int frame = 0; frame < 3; frame++) yield return null;
var handPanel = _root.Q(className: "hand-panel");
var handViewport = _root.Q<ScrollView>(className: "hand-scroll").contentViewport;
Assert.That(handViewport.worldBound.height, Is.GreaterThanOrEqualTo(210),
"The collapsed journal should leave enough vertical room to inspect a standard card.");
float collapsedHandTop = handPanel.worldBound.yMin;
journal.value = true;
for (int frame = 0; frame < 4; frame++) yield return null;
Assert.That(handPanel.worldBound.yMin, Is.LessThan(collapsedHandTop - 40),
"Opening the journal should lift the hand instead of permanently reserving log space.");
journal.value = false;
for (int frame = 0; frame < 4; frame++) yield return null;
Assert.That(handPanel.worldBound.yMin, Is.EqualTo(collapsedHandTop).Within(2),
"Closing the journal should return the hand to its lower resting position.");
var face = _root.Query<Button>(className: "hand-card").First();
Assert.That(face.Query<Label>(className: "software-line-number").ToList()
.All(label => label.resolvedStyle.display == DisplayStyle.None), Is.True);
var preview = face.Q<Label>(className: "software-live-preview");
Assert.That(preview, Is.Not.Null);
Assert.That(preview.resolvedStyle.display, Is.EqualTo(DisplayStyle.None));
face.Focus();
yield return null;
Assert.That(preview.resolvedStyle.display, Is.EqualTo(DisplayStyle.Flex),
"Calculated detail should appear for the card the player is actively inspecting.");
LogAssert.NoUnexpectedReceived();
}
[UnityTest]
public IEnumerator TutorialSpotlightKeepsTargetAndControlsReachableAtEveryViewport()
{
@@ -578,6 +714,22 @@ public class CombatLayoutTests
}
var footer = repository.Q(className: "repository-footer");
Assert.That(footer.worldBound.yMax, Is.LessThanOrEqualTo(_root.worldBound.yMax + 1), context);
var timeshiftToggle = repository.Q<Button>("RepositoryRulesToggle_mint_timeshift");
Assert.That(timeshiftToggle, Is.Not.Null, context);
var timeshiftCard = timeshiftToggle.parent.Q(className: "repository-card-preview");
var timeshiftDetails = timeshiftCard.Query<Label>(className: "software-conditions").ToList();
Assert.That(timeshiftDetails.Count, Is.GreaterThan(0), context);
Assert.That(timeshiftDetails.All(label => label.resolvedStyle.display == DisplayStyle.None), Is.True, context);
using (var submit = NavigationSubmitEvent.GetPooled())
{
submit.target = timeshiftToggle;
timeshiftToggle.SendEvent(submit);
}
for (int frame = 0; frame < 2; frame++) yield return null;
Assert.That(timeshiftCard.ClassListContains("repository-card-expanded"), Is.True, context);
Assert.That(timeshiftDetails.All(label => label.resolvedStyle.display == DisplayStyle.Flex), Is.True, context);
Assert.That(timeshiftToggle.text, Does.Contain("hide full rules"), context);
LogAssert.NoUnexpectedReceived();
}
}
@@ -905,87 +1057,44 @@ public class CombatLayoutTests
}
[UnityTest]
public IEnumerator PlanningActionsAndResultsDialogFitEveryViewport()
public IEnumerator JournalOwnsOptionalActionDetailsWithoutCombatPopups()
{
var view = typeof(CombatSceneController).GetField("_turnResolution", Private).GetValue(_view);
foreach (var size in Viewports)
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
{
UIPreferences.TextSize = textSize;
Resize(size);
Call(_view, "RefreshTurnPanel");
for (int frame = 0; frame < 4; frame++) yield return null;
foreach (string name in new[] { "SaveCombatButton", "OpenTurnResolution" })
{
var control = _root.Q<Button>(name);
Assert.That(control.worldBound.height, Is.GreaterThan(20), name);
AssertContainedHorizontally(control, _root, name);
Assert.That(control.worldBound.yMin, Is.GreaterThanOrEqualTo(_root.worldBound.yMin - 1), name);
Assert.That(control.worldBound.yMax, Is.LessThanOrEqualTo(_root.worldBound.yMax + 1), name);
}
view.GetType().GetMethod("Open").Invoke(view, new object[] { _root });
for (int frame = 0; frame < 4; frame++) yield return null;
var popup = _root.Q("TurnResolutionPopup");
var dialog = popup.Q("TurnResolutionDialog");
AssertContainedHorizontally(dialog, _root, $"{size}/{textSize}");
Assert.That(dialog.worldBound.yMin, Is.GreaterThanOrEqualTo(_root.worldBound.yMin - 1));
Assert.That(dialog.worldBound.yMax, Is.LessThanOrEqualTo(_root.worldBound.yMax + 1));
Assert.That(popup.Q<ScrollView>().contentViewport.worldBound.height, Is.GreaterThan(80));
var close = popup.Q<Button>("CloseTurnResolution");
using (var endTurn = KeyDownEvent.GetPooled('e', KeyCode.E, EventModifiers.None))
{ endTurn.target = close; close.SendEvent(endTurn); }
Assert.That(_combat.CurrentPhase, Is.EqualTo(TurnPhase.Execute));
using (var escape = KeyDownEvent.GetPooled('\0', KeyCode.Escape, EventModifiers.None))
{ escape.target = close; close.SendEvent(escape); }
Assert.That(_root.Q("TurnResolutionPopup"), Is.Null);
Assert.That(_root.Q("ResolutionActions"), Is.Null, "Results must not occupy the battlefield after closing.");
Assert.That(_root.focusController.focusedElement, Is.SameAs(_root.Q<Button>("OpenTurnResolution")));
}
}
Resize(new Vector2(1280, 720));
Assert.That(_root.Q<Button>("OpenExecutionPreview"), Is.Null);
Assert.That(_root.Q<Button>("OpenTurnResolution"), Is.Null);
Assert.That(_root.Q("ExecutionPreviewPopup"), Is.Null);
Assert.That(_root.Q("TurnResolutionPopup"), Is.Null);
[UnityTest]
public IEnumerator ExecutionPreviewWrapsAndDoesNotDisplaceDispatchControls()
{
var preview = _root.Q<Button>("OpenExecutionPreview");
var view = typeof(CombatSceneController).GetField("_executionPreview", Private).GetValue(_view);
view.GetType().GetMethod("Refresh").Invoke(view, new object[] { _combat });
foreach (var size in Viewports)
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
{
UIPreferences.TextSize = textSize;
Resize(size);
Call(_view, "RefreshTurnPanel");
for (int frame = 0; frame < 3; frame++) yield return null;
var before = _root.Q<ScrollView>(className: "combat-workspace").worldBound;
using (var submit = NavigationSubmitEvent.GetPooled()) { submit.target = preview; preview.SendEvent(submit); }
for (int frame = 0; frame < 5; frame++) yield return null;
var popup = _root.Q("ExecutionPreviewPopup");
Assert.That(popup, Is.Not.Null, "Preview must always open as a dialog.");
var scroll = popup.Q<ScrollView>();
Assert.That(popup.Query(className: "execution-step").ToList().Count, Is.EqualTo(6));
var workspace = _root.Q<ScrollView>(className: "combat-workspace");
Assert.That(workspace.worldBound, Is.EqualTo(before), "Opening the preview must not shift the battlefield.");
var visiblePreview = popup.Q("ExecutionPreviewDialog");
var availableArea = _root;
Assert.That(visiblePreview.worldBound.yMin, Is.GreaterThanOrEqualTo(availableArea.worldBound.yMin - 1));
Assert.That(visiblePreview.worldBound.yMax, Is.LessThanOrEqualTo(availableArea.worldBound.yMax + 1));
foreach (var label in scroll.Query<Label>(className: "terminal-body").ToList())
AssertContainedHorizontally(label, scroll.contentViewport, $"{size}/{textSize}");
Assert.That(_root.Q<Button>(className: "primary-action").worldBound.yMax,
Is.LessThanOrEqualTo(_root.worldBound.yMax + 1));
if (popup != null)
{
var close = popup.Q<Button>("CloseExecutionPreview");
using (var endTurn = KeyDownEvent.GetPooled('e', KeyCode.E, EventModifiers.None))
{ endTurn.target = close; close.SendEvent(endTurn); }
Assert.That(_combat.CurrentPhase, Is.EqualTo(TurnPhase.Execute), "Preview must consume combat shortcuts.");
using (var escape = KeyDownEvent.GetPooled('\0', KeyCode.Escape, EventModifiers.None))
{ escape.target = close; close.SendEvent(escape); }
Assert.That(_root.Q("ExecutionPreviewPopup"), Is.Null);
Assert.That(_root.Q("ExecutionPreviewSteps"), Is.Null);
Assert.That(_root.focusController.focusedElement, Is.SameAs(preview));
}
}
var trace = (CombatExecutionTrace)typeof(CombatSceneController)
.GetField("_executionTrace", Private).GetValue(_view);
Assert.That(trace, Is.Not.Null);
var action = new ExecutionAction();
typeof(ExecutionAction).GetProperty("Stage").SetValue(action, "FIFO");
typeof(ExecutionAction).GetProperty("Label").SetValue(action, "print()");
typeof(ExecutionAction).GetProperty("Complete").SetValue(action, true);
typeof(ExecutionAction).GetProperty("UptimeDamage").SetValue(action, 12L);
action.Details.Add("print() resolved / queue / FIFO");
action.DamageBreakdowns.Add("Zombie Process / base 12 - Shield 0 = 12 Uptime");
var actions = (List<ExecutionAction>)typeof(CombatExecutionTrace)
.GetField("_actions", Private).GetValue(trace);
actions.Add(action);
Call(_view, "RefreshJournalActionResults");
var journal = _root.Q<Foldout>(className: "combat-journal");
journal.value = true;
for (int frame = 0; frame < 5; frame++) yield return null;
var result = _root.Q<Foldout>(className: "journal-action-result");
Assert.That(result, Is.Not.Null);
Assert.That(result.text, Does.Contain("[FIFO] print() · done · 12 damage"));
Assert.That(result.value, Is.False, "Detailed calculations should remain opt-in.");
result.value = true;
for (int frame = 0; frame < 2; frame++) yield return null;
var damage = result.Q<Label>(className: "journal-action-damage");
Assert.That(damage, Is.Not.Null);
Assert.That(damage.resolvedStyle.display, Is.EqualTo(DisplayStyle.Flex));
Assert.That(damage.text, Does.Contain("base 12"));
Assert.That(_root.Q<Button>("SaveCombatButton"), Is.Not.Null);
LogAssert.NoUnexpectedReceived();
}
[UnityTest]
@@ -1239,7 +1348,7 @@ public class CombatLayoutTests
}
[UnityTest]
public IEnumerator MintPackageStatusAndNotificationsStayInsideCompactRows()
public IEnumerator PackagesDoNotReserveHostSpaceAndActivationFeedbackStaysTransient()
{
var packages = AssetDatabase.LoadAssetAtPath<PackageDatabase>("Assets/Data/Packages/PackageDatabase.asset");
var mint = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Mint.asset");
@@ -1248,39 +1357,29 @@ public class CombatLayoutTests
.Select(id => new PackageInstance(packages.FindById(id), 5)).ToArray(), 17, 5));
var activation = _root.Q<Label>("PackageActivation");
Assert.That(activation.style.display.value, Is.EqualTo(DisplayStyle.None));
Assert.That(_root.Q("CombatPackages"), Is.Null);
Assert.That(_root.Q("PackageReadiness"), Is.Null);
foreach (var size in Viewports)
foreach (var textSize in new[] { UITextSize.Standard, UITextSize.Large })
{
UIPreferences.TextSize = textSize;
Resize(size);
Call(_view, "RefreshPackageReadiness");
Call(_view, "RefreshPlayer");
for (int frame = 0; frame < 5; frame++) yield return null;
string context = $"{size}/{textSize}";
var strip = _root.Q("PackageReadiness");
Assert.That(_root.Q(className: "player-panel").Contains(strip), Is.True, "Packages belong with the host.");
foreach (var chip in strip.Query(className: "package-readiness-chip").ToList())
{
AssertContainedHorizontally(chip, strip, context);
Assert.That(chip.worldBound.height, Is.LessThan(70), context);
foreach (var label in chip.Query<Label>().ToList())
{
AssertContainedHorizontally(label, chip, context);
Assert.That(label.worldBound.yMin, Is.GreaterThanOrEqualTo(chip.worldBound.yMin), context);
Assert.That(label.worldBound.yMax, Is.LessThanOrEqualTo(chip.worldBound.yMax), context);
}
Assert.That(chip.tooltip, Does.Contain(chip.Q<Label>(className: "package-readiness-state").text));
}
Assert.That(_root.Q("CombatPackages"), Is.Null, context);
Assert.That(_root.Q("PackageReadiness"), Is.Null, context);
Call(_view, "HandlePackageActivated", new PackageActivation("pkg_mint_timeshift", "Timeshift", "Full recovery notification with enough detail to overflow a narrow screen if it wraps"));
Call(_view, "HandlePackageActivated", new PackageActivation("pkg_mint_cinnamon", "Cinnamon", "JavaScript damage increased for this round"));
for (int frame = 0; frame < 3; frame++) yield return null;
AssertContainedHorizontally(activation, strip.parent, context);
AssertContainedHorizontally(activation, _root.Q(className: "player-panel"), context);
Assert.That(activation.worldBound.height, Is.LessThan(30), context);
Assert.That(activation.tooltip, Is.EqualTo(activation.text));
}
}
[UnityTest]
public IEnumerator LivePreviewsAndPackageReadinessWrapAndRetainKeyboardFocus()
public IEnumerator LivePreviewsRemainReadableWithoutPersistentPackageRows()
{
var packages = AssetDatabase.LoadAssetAtPath<PackageDatabase>("Assets/Data/Packages/PackageDatabase.asset");
var config = new RunConfig(_gentoo, Language.Haskell, Language.C, _gentoo.ExclusiveCards.Take(4).ToArray(),
@@ -1295,27 +1394,13 @@ public class CombatLayoutTests
UIPreferences.TextSize = textSize;
UIPreferences.Density = density;
Resize(size);
Call(_view, "RefreshPackageReadiness");
Call(_view, "RefreshHand");
for (int frame = 0; frame < 6; frame++) yield return null;
string context = $"{size}, {textSize}, {density}";
var strip = _root.Q("PackageReadiness");
var chips = strip.Query(className: "package-readiness-chip").ToList();
Assert.That(chips.Count, Is.EqualTo(3), context);
foreach (var chip in chips)
{
AssertContainedHorizontally(chip, strip, context);
Assert.That(chip.worldBound.height, Is.GreaterThan(16), context);
Assert.That(chip.tooltip, Does.Contain("\n"), context);
foreach (var label in chip.Query<Label>().ToList())
AssertContainedHorizontally(label, chip, context);
}
var ccache = _root.Q("Readiness_pkg_gentoo_ccache");
ccache.Focus();
Call(_view, "RefreshPackageReadiness");
Assert.That(_root.focusController.focusedElement, Is.SameAs(ccache), context);
Assert.That(_root.Q("CombatPackages"), Is.Null, context);
Assert.That(_root.Q("PackageReadiness"), Is.Null, context);
Call(_view, "RefreshPlayer");
Assert.That(_root.Q("PackageReadiness"), Is.SameAs(strip), "Refreshing host stats must retain installed packages.");
Assert.That(_root.Q("CombatPackages"), Is.Null, context);
foreach (var face in _root.Query(className: "hand-card").ToList())
{
var preview = face.Q<Label>(className: "software-live-preview");