fix shit and stuff
This commit is contained in:
@@ -15,8 +15,6 @@ namespace KernelPanic.UI
|
||||
private const string EmptyAccent = "5cff91";
|
||||
private const string EmptyAscii = " _\n | |\n ___| |__\n / __| '_ \\\n \\__ \\ | | |\n |___/_| |_|";
|
||||
|
||||
[SerializeField] private List<DistroDefinition> featuredUnits = new();
|
||||
|
||||
private VisualElement panel;
|
||||
private Label titleLabel;
|
||||
private Label asciiLabel;
|
||||
@@ -28,6 +26,7 @@ namespace KernelPanic.UI
|
||||
private Label emptyHintLabel;
|
||||
private VisualElement populatedState;
|
||||
private VisualElement emptyState;
|
||||
private IReadOnlyList<DistroDefinition> units = Array.Empty<DistroDefinition>();
|
||||
private int selectedIndex;
|
||||
|
||||
public void Bind(VisualElement root)
|
||||
@@ -45,26 +44,33 @@ namespace KernelPanic.UI
|
||||
emptyState = root.Q<VisualElement>("FeaturedUnitEmptyState");
|
||||
}
|
||||
|
||||
public void Refresh(IReadOnlyList<DistroDefinition> ownedUnits)
|
||||
{
|
||||
units = ownedUnits ?? Array.Empty<DistroDefinition>();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
if (featuredUnits == null || featuredUnits.Count == 0)
|
||||
if (units == null || units.Count == 0)
|
||||
{
|
||||
ShowEmptyState();
|
||||
return;
|
||||
}
|
||||
|
||||
selectedIndex = Mathf.Clamp(selectedIndex, 0, featuredUnits.Count - 1);
|
||||
ShowUnit(featuredUnits[selectedIndex]);
|
||||
selectedIndex = Mathf.Clamp(selectedIndex, 0, units.Count - 1);
|
||||
ShowUnit(units[selectedIndex]);
|
||||
}
|
||||
|
||||
public void SelectNext()
|
||||
{
|
||||
if (featuredUnits == null || featuredUnits.Count < 2)
|
||||
int unitCount = units?.Count ?? 0;
|
||||
if (unitCount < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
selectedIndex = (selectedIndex + 1) % featuredUnits.Count;
|
||||
selectedIndex = (selectedIndex + 1) % unitCount;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
@@ -73,7 +79,7 @@ namespace KernelPanic.UI
|
||||
populatedState.AddToClassList("hidden");
|
||||
emptyState.RemoveFromClassList("hidden");
|
||||
|
||||
titleLabel.text = "neofetch";
|
||||
titleLabel.text = "[ neofetch ]";
|
||||
emptyTitleLabel.text = "no units installed";
|
||||
emptyHintLabel.text = "run: curl gacha.sh | sh";
|
||||
SetAccent(EmptyAccent);
|
||||
@@ -85,7 +91,7 @@ namespace KernelPanic.UI
|
||||
emptyState.AddToClassList("hidden");
|
||||
|
||||
string displayName = string.IsNullOrWhiteSpace(unit.DisplayName) ? unit.name : unit.DisplayName;
|
||||
titleLabel.text = displayName;
|
||||
titleLabel.text = "[ neofetch ]";
|
||||
asciiLabel.text = EmptyAscii; // TODO: Replace with unit-specific ASCII copy when unit presentation data exists.
|
||||
unitNameLabel.text = displayName;
|
||||
languagesLabel.text = $"{unit.PrimaryLanguage} / {unit.SecondaryLanguage}";
|
||||
@@ -103,6 +109,7 @@ namespace KernelPanic.UI
|
||||
panel.style.borderBottomColor = new StyleColor(parsedColor);
|
||||
panel.style.borderLeftColor = new StyleColor(parsedColor);
|
||||
titleLabel.style.color = new StyleColor(parsedColor);
|
||||
unitNameLabel.style.color = new StyleColor(parsedColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace KernelPanic.UI
|
||||
private static bool bootIntroPlayed;
|
||||
|
||||
[SerializeField] private FontAsset monospaceFont; // TODO: Assign a real monospace FontAsset when typography assets exist.
|
||||
[SerializeField] private string motdBody = "unstable userspace detected; keep a rollback shell open.";
|
||||
[SerializeField] private FeaturedUnitPanel featuredUnitPanel = new();
|
||||
|
||||
private readonly List<CommandMenuEntry> commandEntries = new();
|
||||
@@ -44,21 +45,23 @@ namespace KernelPanic.UI
|
||||
private Label titleCursorLabel;
|
||||
private Label promptCursorLabel;
|
||||
private Label bootIntroLogLabel;
|
||||
private Label backgroundLogLabel;
|
||||
private Label motdBodyLabel;
|
||||
private VisualElement motdBlock;
|
||||
private Button collectionBackButton;
|
||||
private Button gachaBackButton;
|
||||
private Button settingsBackButton;
|
||||
private EntropyWallet wallet;
|
||||
private GachaService gachaService;
|
||||
private PlayerCollection playerCollection;
|
||||
private BackgroundLogRingBuffer backgroundLog;
|
||||
private IEventBannerSource eventBannerSource;
|
||||
private int selectedCommandIndex;
|
||||
private float backgroundScrollOffset;
|
||||
private float bootIntroElapsed;
|
||||
private int bootIntroCharacterCount;
|
||||
private bool cursorVisible;
|
||||
private bool suppressNextClick;
|
||||
private string bootIntroCopy;
|
||||
private IVisualElementScheduledItem blinkSchedule;
|
||||
private IVisualElementScheduledItem backgroundSchedule;
|
||||
private IVisualElementScheduledItem bootIntroSchedule;
|
||||
|
||||
public void Initialize(EntropyWallet initializedWallet)
|
||||
@@ -71,6 +74,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
document = GetComponent<UIDocument>();
|
||||
gachaService = new GachaService();
|
||||
playerCollection = new PlayerCollection(); // TODO: Replace with persistent player-collection service composition.
|
||||
Initialize(new EntropyWallet()); // TODO: Replace with persistent wallet service composition.
|
||||
BindElements();
|
||||
BindCommandEntries();
|
||||
@@ -87,7 +91,7 @@ namespace KernelPanic.UI
|
||||
RefreshStaticText();
|
||||
RefreshCurrencyReadouts();
|
||||
RefreshEventBanner();
|
||||
featuredUnitPanel.Refresh();
|
||||
featuredUnitPanel.Refresh(playerCollection.OwnedUnits);
|
||||
SelectCommand(0);
|
||||
ShowMainMenu();
|
||||
StartAmbientSchedules();
|
||||
@@ -98,7 +102,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
UnregisterCallbacks();
|
||||
blinkSchedule?.Pause();
|
||||
backgroundSchedule?.Pause();
|
||||
backgroundLog?.Stop();
|
||||
bootIntroSchedule?.Pause();
|
||||
}
|
||||
|
||||
@@ -112,7 +116,9 @@ namespace KernelPanic.UI
|
||||
gachaPanel = root.Q<VisualElement>("GachaPanel");
|
||||
settingsPanel = root.Q<VisualElement>("SettingsPanel");
|
||||
eventBanner = root.Q<VisualElement>("EventBanner");
|
||||
motdBlock = root.Q<VisualElement>("MotdBlock");
|
||||
backgroundLogLayer = root.Q<VisualElement>("BackgroundLogLayer");
|
||||
backgroundLog = new BackgroundLogRingBuffer(backgroundLogLayer, BootLogCopy.Lines);
|
||||
|
||||
appIdLabel = root.Q<Label>("AppIdLabel");
|
||||
entropyLabel = root.Q<Label>("EntropyLabel");
|
||||
@@ -120,7 +126,7 @@ namespace KernelPanic.UI
|
||||
titleCursorLabel = root.Q<Label>("TitleCursorLabel");
|
||||
promptCursorLabel = root.Q<Label>("PromptCursorLabel");
|
||||
bootIntroLogLabel = root.Q<Label>("BootIntroLogLabel");
|
||||
backgroundLogLabel = root.Q<Label>("BackgroundLogLabel");
|
||||
motdBodyLabel = root.Q<Label>("MotdBodyLabel");
|
||||
|
||||
collectionBackButton = root.Q<Button>("CollectionBackButton");
|
||||
gachaBackButton = root.Q<Button>("GachaBackButton");
|
||||
@@ -168,7 +174,8 @@ namespace KernelPanic.UI
|
||||
private void RefreshStaticText()
|
||||
{
|
||||
appIdLabel.text = $"kernel-panic v{Application.version} - tty1";
|
||||
backgroundLogLabel.text = BuildBackgroundLog();
|
||||
motdBodyLabel.text = motdBody ?? string.Empty;
|
||||
motdBlock.EnableInClassList(HiddenClassName, string.IsNullOrWhiteSpace(motdBody));
|
||||
bootIntroCopy = string.Join("\n", BootLogCopy.Lines);
|
||||
}
|
||||
|
||||
@@ -210,26 +217,23 @@ namespace KernelPanic.UI
|
||||
|
||||
private void StartAmbientSchedules()
|
||||
{
|
||||
blinkSchedule?.Pause();
|
||||
backgroundLog?.Stop();
|
||||
cursorVisible = true;
|
||||
titleCursorLabel.EnableInClassList(CursorOnClassName, true);
|
||||
promptCursorLabel.EnableInClassList(CursorOnClassName, true);
|
||||
|
||||
if (UIPreferences.ReducedMotion)
|
||||
{
|
||||
titleCursorLabel.AddToClassList(CursorOnClassName);
|
||||
promptCursorLabel.AddToClassList(CursorOnClassName);
|
||||
return;
|
||||
}
|
||||
|
||||
bool cursorVisible = true;
|
||||
blinkSchedule = root.schedule.Execute(() =>
|
||||
{
|
||||
cursorVisible = !cursorVisible;
|
||||
titleCursorLabel.EnableInClassList(CursorOnClassName, cursorVisible);
|
||||
promptCursorLabel.EnableInClassList(CursorOnClassName, cursorVisible);
|
||||
}).Every(480);
|
||||
|
||||
backgroundSchedule = root.schedule.Execute(() =>
|
||||
{
|
||||
backgroundScrollOffset = (backgroundScrollOffset + 0.35f) % 80f;
|
||||
backgroundLogLayer.style.translate = new Translate(0, -backgroundScrollOffset, 0);
|
||||
}).Every(33);
|
||||
}).Every(500);
|
||||
}
|
||||
|
||||
private void PlayBootIntroIfNeeded()
|
||||
@@ -272,6 +276,7 @@ namespace KernelPanic.UI
|
||||
bootIntroPanel.AddToClassList(HiddenClassName);
|
||||
shellRoot.RemoveFromClassList("boot-hidden");
|
||||
shellRoot.AddToClassList("boot-visible");
|
||||
backgroundLog?.Start(UIPreferences.ReducedMotion);
|
||||
root.Focus();
|
||||
}
|
||||
|
||||
@@ -419,12 +424,6 @@ namespace KernelPanic.UI
|
||||
settingsPanel.EnableInClassList(HiddenClassName, settingsPanel != activePanel);
|
||||
}
|
||||
|
||||
private static string BuildBackgroundLog()
|
||||
{
|
||||
string block = string.Join("\n", BootLogCopy.Lines);
|
||||
return $"{block}\n{block}\n{block}\n{block}";
|
||||
}
|
||||
|
||||
private sealed class CommandMenuEntry
|
||||
{
|
||||
private readonly Label cursor;
|
||||
|
||||
Reference in New Issue
Block a user