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
@@ -28,6 +28,10 @@ namespace KernelPanic.UI
VisualElement offers = new();
offers.AddToClassList("repository-offers");
VisualElement packageOperations = new();
packageOperations.AddToClassList("repository-package-operations");
packageOperations.Add(TerminalLayout.Heading("[ package operations ]", className: "repository-section-label"));
packageOperations.Add(TerminalLayout.BodyText("$ apt-cache search --upgradeable", className: "repository-command-heading"));
if (_runManager.RepositoryOffers.Count == 0)
{
offers.Add(EmptyState("repository clean: no offers left this visit"));
@@ -41,42 +45,53 @@ namespace KernelPanic.UI
}
body.Add(DeckAnalysisView.Build(_runManager.RunDeck));
body.Add(offers);
body.Add(RemoveCardBlock());
packageOperations.Add(offers);
packageOperations.Add(RemoveCardBlock());
body.Add(packageOperations);
repo.Add(body);
VisualElement footer = new();
footer.AddToClassList("repository-footer");
footer.AddToClassList("screen-frame-footer");
VisualElement packageControls = new();
packageControls.AddToClassList("repository-footer-group");
packageControls.AddToClassList("repository-package-controls");
packageControls.Add(TerminalLayout.BodyText("package cache", className: "repository-footer-label"));
Button reroll = new(() => _runManager.RerollRepositoryOffers(cardDatabase, languageDeckDatabase))
{
text = $"apt update {_runManager.RerollCost} bits"
text = $"$ apt update {_runManager.RerollCost} bits"
};
reroll.AddToClassList("primary-action");
reroll.AddToClassList("secondary-action");
reroll.AddToClassList("repository-footer-action");
reroll.AddToClassList("repository-reroll-action");
reroll.EnableInClassList("repo-unaffordable", _runManager.Bits < _runManager.RerollCost);
reroll.SetEnabled(_runManager.Bits >= _runManager.RerollCost);
footer.Add(reroll);
packageControls.Add(reroll);
footer.Add(packageControls);
Button leave = new(() =>
{
if (_runManager.Journey.campaign) SetRouteSelectionOpen(true);
else _combatManager.ContinueToNextWave();
}) { name = "BootNextWaveButton", text = "> boot next-wave" };
}) { name = "BootNextWaveButton", text = "$ boot --next-wave" };
leave.AddToClassList("primary-action");
leave.AddToClassList("repository-leave-action");
leave.AddToClassList("repository-primary-command");
leave.AddToClassList("repository-recommended-action");
leave.SetEnabled(!_runManager.IsSuspended);
VisualElement leaveBlock = new();
leaveBlock.AddToClassList("repository-leave-block");
leaveBlock.AddToClassList("repository-footer-group");
leaveBlock.Add(TerminalLayout.BodyText("recommended next action", className: "repository-footer-label repository-recommended-label"));
leaveBlock.Add(leave);
Label banked = new($"{_runManager.Bits} bits remaining");
banked.AddToClassList("repository-banked-hint");
banked.AddToClassList("screen-frame-hint");
leaveBlock.Add(banked);
var suspend = new Button(SaveAndExitRun) { name = "SaveAndExitRunButton", text = "save & exit" };
suspend.AddToClassList("primary-action");
var suspend = new Button(SaveAndExitRun) { name = "SaveAndExitRunButton", text = "$ shutdown --save" };
suspend.AddToClassList("secondary-action");
suspend.AddToClassList("repository-leave-action");
suspend.AddToClassList("repository-save-action");
suspend.SetEnabled(!_runManager.IsSuspended);
leaveBlock.Add(suspend);
if (!string.IsNullOrEmpty(_checkpointError))
@@ -300,7 +315,7 @@ namespace KernelPanic.UI
Button buy = new(() => _runManager.BuyOffer(offer, _combatManager.PlayerState))
{
text = offer.Sold ? "installed" : OfferActionText(offer.Kind)
text = offer.Sold ? "# installed" : "$ " + OfferActionText(offer.Kind)
};
buy.tooltip = OfferCommandText(offer);
buy.AddToClassList("repository-action");
@@ -317,6 +332,7 @@ namespace KernelPanic.UI
VisualElement card = CardFaceView(preview);
card.AddToClassList("repository-card-preview");
content.Add(card);
AddRepositoryRulesToggle(content, card, preview);
if (offer.CardDefinition != null && offer.CardDefinition.IsRunOnly)
{
@@ -335,6 +351,7 @@ namespace KernelPanic.UI
VisualElement target = CardFaceView(offer.TargetCard);
target.AddToClassList("repository-upgrade-card");
content.Add(target);
AddRepositoryRulesToggle(content, target, offer.TargetCard);
}
VisualElement delta = new();
@@ -352,6 +369,31 @@ namespace KernelPanic.UI
return content;
}
private static void AddRepositoryRulesToggle(VisualElement content, VisualElement card, CardInstance instance)
{
string rules = instance?.Definition == null ? "" : CardEffectFactory.GetRulesText(instance);
// Short manifests already scan well. Long cards keep their first authoritative
// sentence visible and put restrictions/edge cases behind an explicit reveal.
if (rules.Length < 140 || card.Q<Label>(className: "software-conditions") == null) return;
card.AddToClassList("repository-card-collapsible");
Button toggle = null;
toggle = new Button(() =>
{
bool expanded = !card.ClassListContains("repository-card-expanded");
card.EnableInClassList("repository-card-expanded", expanded);
toggle.text = expanded ? "▾ hide full rules" : "▸ show full rules";
toggle.EnableInClassList("expanded", expanded);
})
{
name = "RepositoryRulesToggle_" + instance.Definition.Id,
text = "▸ show full rules",
tooltip = "Show or hide the complete card manifest."
};
toggle.AddToClassList("repository-rules-toggle");
content.Add(toggle);
}
private VisualElement StatOfferContent(RepositoryOffer offer)
{
VisualElement content = new();