Implement overall improvements for code stability, fallbacks and keyboard interactions

This commit is contained in:
2026-11-29 03:05:21 +01:00
parent fdde7f9d80
commit 7efc63d130
10 changed files with 1343 additions and 235 deletions
@@ -11,63 +11,16 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="4222a6b8-add3-4f43-9c42-fd6bb5a76169" name="Changes" comment=""> <list default="true" id="4222a6b8-add3-4f43-9c42-fd6bb5a76169" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/Assets/Resources/TerminalProgram.uss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.linuxdistrosbuttheyarebreedable/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.linuxdistrosbuttheyarebreedable/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.linuxdistrosbuttheyarebreedable/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.linuxdistrosbuttheyarebreedable/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Distros/Arch.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Distros/Arch.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Distros/Fedora.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Distros/Fedora.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Distros/Gentoo.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Distros/Gentoo.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Distros/Mint.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Distros/Mint.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Distros/NixOS.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Distros/NixOS.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Distros/Ubuntu.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Distros/Ubuntu.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Passives/AptUpdate.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Passives/AptUpdate.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Passives/BleedingEdge.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Passives/BleedingEdge.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Passives/EmergeWorld.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Passives/EmergeWorld.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Passives/IUseArchBtw.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Passives/IUseArchBtw.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Passives/ItJustWorks.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Passives/ItJustWorks.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Data/Passives/NixRebuildSwitch.asset" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Data/Passives/NixRebuildSwitch.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Resources/CombatScene.uss" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Resources/CombatScene.uss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Resources/KernelTheme.uss" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Resources/KernelTheme.uss" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Resources/KernelTheme.uss" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Resources/KernelTheme.uss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Meta/DailyQuests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Meta/DailyQuests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Meta/GachaBannerState.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Meta/GachaBannerState.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Meta/GachaService.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Meta/GachaService.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Meta/SaveService.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Meta/SaveService.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Run/PlayerSmokeRunner.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Run/PlayerSmokeRunner.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Run/RunCheckpoint.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Run/RunCheckpoint.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Run/RunManager.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Run/RunManager.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/CollectionScreenController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/CollectionScreenController.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/CollectionScreenController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/CollectionScreenController.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/CombatSceneController.Repository.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/CombatSceneController.Repository.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/CombatSceneController.RunReport.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/CombatSceneController.RunReport.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/CombatSceneController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/CombatSceneController.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/DailyQuestView.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/DailyQuestView.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/EnemyProcessPresentation.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/EnemyProcessPresentation.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/FeaturedUnitPanel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/FeaturedUnitPanel.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/GachaScreenController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/GachaScreenController.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/GachaScreenController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/GachaScreenController.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/GamblingSceneController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/GamblingSceneController.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/MainMenuController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/MainMenuController.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/MainMenuController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/MainMenuController.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/RunHistoryView.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/RunHistoryView.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/SoftwareCardView.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/SoftwareCardView.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/TerminalCommandLine.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/TerminalCommandLine.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/TerminalCommandLine.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/TerminalCommandLine.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/TerminalTheme.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/TerminalTheme.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Scripts/UI/TerminalTheme.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/UI/TerminalTheme.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/CampaignTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/CampaignTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/CollectionLayoutTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/CollectionLayoutTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/CombatLayoutTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/CombatLayoutTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/DailyQuestLayoutTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/DailyQuestLayoutTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/DailyQuestTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/DailyQuestTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/GentooProgressionTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/GentooProgressionTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/MenuPersistenceTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/MenuPersistenceTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/ReadabilityTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/ReadabilityTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/RewardSettlementTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/RewardSettlementTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/RunCheckpointTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/RunCheckpointTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/TerminalUiTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/TerminalUiTests.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/Tests/EditMode/TerminalUiTests.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Tests/EditMode/TerminalUiTests.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/UI/CollectionScreen.uxml" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/CollectionScreen.uxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/UI/GachaScreen.uxml" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/GachaScreen.uxml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/UI/GachaScreen.uxml" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/GachaScreen.uxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/UI/MainMenu.uss" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/MainMenu.uss" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Assets/UI/MainMenu.uss" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/MainMenu.uss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/UI/MainMenu.uxml" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/MainMenu.uxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/UI/SettingsScreen.uxml" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/UI/SettingsScreen.uxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ProjectSettings/ProjectSettings.asset" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/ProjectSettings.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gacha.md" beforeDir="false" afterPath="$PROJECT_DIR$/gacha.md" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -156,23 +109,23 @@
<component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" /> <component name="MetaFilesCheckinStateConfiguration" checkMetaFiles="true" />
<component name="NextEditCompletionFeaturesState"> <component name="NextEditCompletionFeaturesState">
<decayedCancelled> <decayedCancelled>
<entry key="MS100" value="1.0281050911525915" /> <entry key="MS100" value="1.9712182452860625" />
<entry key="MS500" value="1.9091333183029269" /> <entry key="MS500" value="5.822764859594057" />
<entry key="S2" value="3.907789773255605" /> <entry key="S2" value="15.046478452449968" />
<entry key="S5" value="4.978157918280824" /> <entry key="S5" value="24.345668146579168" />
<entry key="S10" value="5.450929638631167" /> <entry key="S10" value="30.00130040674188" />
<entry key="S30" value="6.334523831693124" /> <entry key="S30" value="35.01210592558611" />
<entry key="S60" value="11.197997428963966" /> <entry key="S60" value="36.46122494024133" />
<entry key="M2" value="22.92901828720625" /> <entry key="M2" value="37.2190799579126" />
<entry key="M5" value="40.30262844065668" /> <entry key="M5" value="37.91102812563582" />
<entry key="M10" value="49.91722862227464" /> <entry key="M10" value="41.687977406431635" />
<entry key="M15" value="57.0655051705789" /> <entry key="M15" value="48.573562875554835" />
<entry key="M30" value="91.5778543659882" /> <entry key="M30" value="77.33835931421636" />
<entry key="H1" value="169.18340420366195" /> <entry key="H1" value="149.5860671947868" />
<entry key="H2" value="333.70981096594625" /> <entry key="H2" value="309.4841189051316" />
<entry key="H4" value="696.8201747193692" /> <entry key="H4" value="661.9273952080404" />
<entry key="D1" value="2649.628529369424" /> <entry key="D1" value="2688.288261000338" />
<entry key="W1" value="10410.068849369638" /> <entry key="W1" value="10509.356962113123" />
</decayedCancelled> </decayedCancelled>
<decayedSelected> <decayedSelected>
<entry key="MS100" value="0.0" /> <entry key="MS100" value="0.0" />
@@ -185,32 +138,32 @@
<entry key="M2" value="0.0" /> <entry key="M2" value="0.0" />
<entry key="M5" value="0.0" /> <entry key="M5" value="0.0" />
<entry key="M10" value="0.0" /> <entry key="M10" value="0.0" />
<entry key="M15" value="4.3608703934388624E-219" /> <entry key="M15" value="3.1690297256451893E-221" />
<entry key="M30" value="6.60369078896691E-110" /> <entry key="M30" value="5.629415393982376E-111" />
<entry key="H1" value="2.5722906830124825E-55" /> <entry key="H1" value="7.510318032317844E-56" />
<entry key="H2" value="5.344581858408169E-28" /> <entry key="H2" value="2.887904815105072E-28" />
<entry key="H4" value="3.16029030937339E-14" /> <entry key="H4" value="2.3230660090090885E-14" />
<entry key="D1" value="0.01672542473131539" /> <entry key="D1" value="0.01588911043968005" />
<entry key="W1" value="1.8266548211379283" /> <entry key="W1" value="1.8133180192649019" />
</decayedSelected> </decayedSelected>
<decayedShown> <decayedShown>
<entry key="MS100" value="0.9803363193775019" /> <entry key="MS100" value="1.8878593701189004" />
<entry key="MS500" value="1.8947037965986282" /> <entry key="MS500" value="5.7738716812126" />
<entry key="S2" value="3.898635615503382" /> <entry key="S2" value="15.01413541595141" />
<entry key="S5" value="4.973065790434869" /> <entry key="S5" value="24.324340039093556" />
<entry key="S10" value="5.448056870810499" /> <entry key="S10" value="29.988056435637723" />
<entry key="S30" value="6.333361927661099" /> <entry key="S30" value="35.006925885081166" />
<entry key="S60" value="11.196606503301721" /> <entry key="S60" value="36.45852401144687" />
<entry key="M2" value="22.927073846159956" /> <entry key="M2" value="37.21770046060742" />
<entry key="M5" value="40.30098877846524" /> <entry key="M5" value="37.91044783514904" />
<entry key="M10" value="49.9161593138596" /> <entry key="M10" value="41.68753181844637" />
<entry key="M15" value="57.06470179922028" /> <entry key="M15" value="48.57308984840963" />
<entry key="M30" value="91.57730551620396" /> <entry key="M30" value="77.33782671625778" />
<entry key="H1" value="169.18297832589522" /> <entry key="H1" value="149.58553611191067" />
<entry key="H2" value="333.70945203686483" /> <entry key="H2" value="309.4836479164664" />
<entry key="H4" value="696.819858135537" /> <entry key="H4" value="661.9269984225874" />
<entry key="D1" value="2649.6450824914027" /> <entry key="D1" value="2688.3039546875575" />
<entry key="W1" value="10411.89538062694" /> <entry key="W1" value="10511.170152816387" />
</decayedShown> </decayedShown>
</component> </component>
<component name="ProblemsViewState"> <component name="ProblemsViewState">
@@ -600,7 +553,6 @@
<component name="UnityUnitTestConfiguration" currentTestLauncher="Both" /> <component name="UnityUnitTestConfiguration" currentTestLauncher="Both" />
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" /> <option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
<MESSAGE value="Implement cutscene for gambling and make it dopamine-inducing" />
<MESSAGE value="changed most TODOs to TODONEs" /> <MESSAGE value="changed most TODOs to TODONEs" />
<MESSAGE value="Implement Java and Rust cards alongside some smaller changes" /> <MESSAGE value="Implement Java and Rust cards alongside some smaller changes" />
<MESSAGE value="make small changes to design. Implement crits." /> <MESSAGE value="make small changes to design. Implement crits." />
@@ -625,7 +577,8 @@
<MESSAGE value="add C++, Typescript and more stuff" /> <MESSAGE value="add C++, Typescript and more stuff" />
<MESSAGE value="add more tests" /> <MESSAGE value="add more tests" />
<MESSAGE value="Refactor alot of stuff" /> <MESSAGE value="Refactor alot of stuff" />
<option name="LAST_COMMIT_MESSAGE" value="Refactor alot of stuff" /> <MESSAGE value="Revamp UI a whole lot" />
<option name="LAST_COMMIT_MESSAGE" value="Revamp UI a whole lot" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
+27 -6
View File
@@ -204,15 +204,25 @@
.kernel-ui .version-upgrade-panel { border-width: 0; background-color: transparent; } .kernel-ui .version-upgrade-panel { border-width: 0; background-color: transparent; }
.kernel-ui .collection-detail .kv-value { white-space: normal; overflow: visible; text-overflow: clip; } .kernel-ui .collection-detail .kv-value { white-space: normal; overflow: visible; text-overflow: clip; }
.kernel-ui .flavor-text { color: var(--kp-muted); font-size: var(--type-meta); margin-top: 16px; white-space: normal; } .kernel-ui .flavor-text { color: var(--kp-muted); font-size: var(--type-meta); margin-top: 16px; white-space: normal; }
.kernel-ui .gacha-banner-list { width: 230px; min-width: 180px; border-width: 0 1px 0 0; background-color: transparent; margin-right: 18px; } .kernel-ui .gacha-banner-list { width: 220px; min-width: 190px; border-width: 0 1px 0 0; background-color: transparent; margin-right: 18px; }
.kernel-ui .gacha-banner-detail-scroll { border-width: 0; background-color: transparent; } .kernel-ui .gacha-banner-detail-scroll { border-width: 0; background-color: transparent; }
.kernel-ui .gacha-banner-detail { padding: 0 10px; } .kernel-ui .gacha-banner-detail { padding: 0 6px 18px 12px; }
.kernel-ui .gacha-detail-title { color: var(--kp-text); font-size: 26px; } .kernel-ui .gacha-detail-title { color: var(--kp-text); font-size: 26px; }
.kernel-ui .gacha-hero { border-width: 0 0 1px 0; height: 180px; background-color: transparent; } .kernel-ui .gacha-hero { border-width: 0 0 1px 0; height: 146px; padding: 4px 0 8px; background-color: transparent; }
.kernel-ui .gacha-art-card { border-width: 0; background-color: transparent; } .kernel-ui .gacha-art-card { border-width: 0; background-color: transparent; }
.kernel-ui .gacha-art-button { padding: 0; border-width: 0 0 1px; border-bottom-color: transparent; background-color: transparent; }
.kernel-ui .gacha-art-button:hover,
.kernel-ui .gacha-art-button:focus { border-bottom-color: var(--kp-cyan); background-color: var(--kp-hover); }
.kernel-ui .gacha-art-cue { width: 100%; min-height: 22px; align-items: center; justify-content: center; }
.kernel-ui .gacha-art-inspect { color: var(--kp-cyan); font-size: var(--type-meta); }
.kernel-ui .gacha-actions { flex-wrap: wrap; } .kernel-ui .gacha-actions { flex-wrap: wrap; }
.kernel-ui .terminal-button, .kernel-ui .terminal-button { height: auto; min-height: 38px; margin-top: 10px; border-width: 1px; border-color: var(--kp-border); color: var(--kp-amber); background-color: var(--kp-panel); font-size: var(--type-body); padding: 8px 12px; }
.kernel-ui .gacha-action-button { height: auto; min-height: 38px; margin-top: 10px; border-width: 1px; border-color: var(--kp-border); color: var(--kp-amber); background-color: var(--kp-panel); font-size: var(--type-body); padding: 8px 12px; } .kernel-ui .gacha-action-button { height: auto; min-height: 48px; margin-top: 0; border-width: 1px; border-color: var(--kp-border); color: var(--kp-amber); background-color: var(--kp-panel); font-size: var(--type-body); padding: 8px 12px; }
.kernel-ui .gacha-action-button.gacha-action-primary { border-color: var(--kp-amber); color: var(--kp-amber); background-color: var(--kp-hover); }
.kernel-ui .gacha-action-button.gacha-action-secondary { border-color: var(--kp-border-strong); color: var(--kp-cyan); background-color: transparent; }
.kernel-ui .gacha-action-button.gacha-action-primary:disabled,
.kernel-ui .gacha-action-button.gacha-action-secondary:disabled { border-color: var(--kp-border); color: var(--kp-muted); background-color: var(--kp-panel); }
.kernel-ui .gacha-history-button { min-height: 36px; margin: 0; }
.kernel-ui .terminal-button:hover { color: var(--kp-bg); background-color: var(--kp-amber); } .kernel-ui .terminal-button:hover { color: var(--kp-bg); background-color: var(--kp-amber); }
.kernel-ui .run-setup-hint { margin-bottom: 10px; } .kernel-ui .run-setup-hint { margin-bottom: 10px; }
.kernel-ui .run-readout { border-width: 0; background-color: transparent; } .kernel-ui .run-readout { border-width: 0; background-color: transparent; }
@@ -345,6 +355,7 @@
.kernel-ui .gacha-banner-row .command-text { width: 100%; font-size: var(--type-body); } .kernel-ui .gacha-banner-row .command-text { width: 100%; font-size: var(--type-body); }
.kernel-ui .gacha-banner-row .command-description { width: auto; align-self: stretch; min-width: 0; margin: var(--space-1) 0 0; font-size: var(--type-meta); -unity-text-align: middle-left; } .kernel-ui .gacha-banner-row .command-description { width: auto; align-self: stretch; min-width: 0; margin: var(--space-1) 0 0; font-size: var(--type-meta); -unity-text-align: middle-left; }
.kernel-ui .gacha-banner-row.selected { border-left-color: var(--kp-amber); background-color: var(--kp-hover); } .kernel-ui .gacha-banner-row.selected { border-left-color: var(--kp-amber); background-color: var(--kp-hover); }
.kernel-ui .gacha-banner-row.selected .command-text { color: var(--kp-amber); }
.kernel-ui .gacha-rules { font-size: var(--type-body); white-space: normal; } .kernel-ui .gacha-rules { font-size: var(--type-body); white-space: normal; }
.kernel-ui .gacha-banner-list { flex-shrink: 0; } .kernel-ui .gacha-banner-list { flex-shrink: 0; }
.kernel-ui .gacha-action-button { min-width: 0; width: auto; flex-grow: 1; flex-basis: 180px; margin-right: var(--space-2); } .kernel-ui .gacha-action-button { min-width: 0; width: auto; flex-grow: 1; flex-basis: 180px; margin-right: var(--space-2); }
@@ -365,7 +376,7 @@
.kernel-ui .starter-description { color: var(--kp-muted); font-size: var(--type-body); } .kernel-ui .starter-description { color: var(--kp-muted); font-size: var(--type-body); }
.kernel-ui .exchange-step-row, .kernel-ui .exchange-step-row,
.kernel-ui .exchange-confirm-row { flex-wrap: wrap; } .kernel-ui .exchange-confirm-row { flex-wrap: wrap; }
.kernel-ui .exchange-step-button { width: 80px; margin: 4px; -unity-text-align: middle-center; } .kernel-ui .terminal-button.exchange-step-button { width: 80px; margin: 4px; -unity-text-align: middle-center; }
.kernel-ui .exchange-confirm-button { width: auto; flex-grow: 1; min-width: 170px; margin: 4px; } .kernel-ui .exchange-confirm-button { width: auto; flex-grow: 1; min-width: 170px; margin: 4px; }
.kernel-ui .root-credit-dialog { height: auto; } .kernel-ui .root-credit-dialog { height: auto; }
.kernel-ui .modal-close-button { color: var(--kp-amber); } .kernel-ui .modal-close-button { color: var(--kp-amber); }
@@ -798,6 +809,16 @@
.kernel-ui.narrow .featured-populated { flex-wrap: wrap; } .kernel-ui.narrow .featured-populated { flex-wrap: wrap; }
.kernel-ui.narrow .featured-populated .unit-readout { width: 100%; } .kernel-ui.narrow .featured-populated .unit-readout { width: 100%; }
.kernel-ui.narrow .gacha-banner-list { width: 100%; min-width: 0; flex-direction: row; flex-wrap: wrap; border-width: 0 0 1px; margin: 0 0 12px; } .kernel-ui.narrow .gacha-banner-list { width: 100%; min-width: 0; flex-direction: row; flex-wrap: wrap; border-width: 0 0 1px; margin: 0 0 12px; }
.kernel-ui.narrow .gacha-branch-command { display: none; }
.kernel-ui.narrow .gacha-toolbar { flex-wrap: wrap; align-items: flex-start; }
.kernel-ui.narrow .gacha-toolbar-context { display: none; }
.kernel-ui.narrow .gacha-history-button { width: 100%; min-width: 0; }
.kernel-ui.narrow .gacha-banner-detail { padding: 0 0 18px; }
.kernel-ui.narrow .gacha-active-header { align-items: flex-start; flex-wrap: wrap; }
.kernel-ui.narrow .gacha-active-status { margin: var(--space-2) 0 0; }
.kernel-ui.narrow .gacha-hero { display: none; }
.kernel-ui.narrow .gacha-progress-metric { flex-basis: 140px; min-width: 130px; }
.kernel-ui.narrow .gacha-action-button { width: 100%; flex-basis: auto; margin-right: 0; }
.kernel-ui.narrow .gacha-banner-detail .kv-key { width: 130px; min-width: 130px; } .kernel-ui.narrow .gacha-banner-detail .kv-key { width: 130px; min-width: 130px; }
.kernel-ui.narrow .gacha-banner-detail .kv-row { flex-wrap: wrap; } .kernel-ui.narrow .gacha-banner-detail .kv-row { flex-wrap: wrap; }
.kernel-ui.narrow .main-layout { flex-direction: column; } .kernel-ui.narrow .main-layout { flex-direction: column; }
@@ -50,6 +50,7 @@ namespace KernelPanic.UI
private UnitDetailTab _unitDetailTab = UnitDetailTab.Overview; private UnitDetailTab _unitDetailTab = UnitDetailTab.Overview;
private PackageSlot? _packagePickerSlot; private PackageSlot? _packagePickerSlot;
private bool _unitDetailReturnsToOverview = true; private bool _unitDetailReturnsToOverview = true;
private bool _unitDetailReadOnly;
private DistroDefinition _equipWindowUnit; private DistroDefinition _equipWindowUnit;
private PackageSlot _equipWindowSlot; private PackageSlot _equipWindowSlot;
private int _selectedUnitIndex; private int _selectedUnitIndex;
@@ -111,6 +112,7 @@ namespace KernelPanic.UI
{ {
ClosePackageEquipWindow(); ClosePackageEquipWindow();
_mode = CollectionMode.Units; _mode = CollectionMode.Units;
_unitDetailReadOnly = false;
CurrentTitle = "$ ls ~/collection"; CurrentTitle = "$ ls ~/collection";
CurrentHint = "[esc] back [left/right] tabs [tab] focus [up/down] select [enter] select"; CurrentHint = "[esc] back [left/right] tabs [tab] focus [up/down] select [enter] select";
RenderUnits(); RenderUnits();
@@ -238,6 +240,7 @@ namespace KernelPanic.UI
if (_mode == CollectionMode.UnitDetail && _units.Count > 0) if (_mode == CollectionMode.UnitDetail && _units.Count > 0)
{ {
if (_unitDetailReadOnly) return;
DistroDefinition unit = _units[_selectedUnitIndex]; DistroDefinition unit = _units[_selectedUnitIndex];
switch (_unitDetailTab) switch (_unitDetailTab)
{ {
@@ -257,7 +260,7 @@ namespace KernelPanic.UI
public void SwitchUnitDetailTabRelative(int delta) public void SwitchUnitDetailTabRelative(int delta)
{ {
if (_mode != CollectionMode.UnitDetail || _units.Count == 0) if (_mode != CollectionMode.UnitDetail || _units.Count == 0 || _unitDetailReadOnly)
{ {
return; return;
} }
@@ -270,10 +273,10 @@ namespace KernelPanic.UI
ViewChanged?.Invoke(); ViewChanged?.Invoke();
} }
public void ShowUnitDetail(DistroDefinition unit, bool returnToOverview) public void ShowUnitDetail(DistroDefinition unit, bool returnToOverview, bool readOnly = false)
{ {
SelectUnitById(unit?.Id); SelectUnitById(unit?.Id);
OpenUnitDetail(unit, true, returnToOverview); OpenUnitDetail(unit, true, returnToOverview, readOnly);
} }
private void RenderUnits() private void RenderUnits()
@@ -621,7 +624,7 @@ namespace KernelPanic.UI
string upgradeMarker = CanUpgradeUnit(unit) ? " *" : string.Empty; string upgradeMarker = CanUpgradeUnit(unit) ? " *" : string.Empty;
string listing = LsText($"{"drwxr-xr-x",-12}{"player",-8}{$"{GetDistroStars(unit)}★",-6}{$"{version}/{GachaTuning.MaxVersion}",-6}{languages,-20}{unit.Id}/{upgradeMarker}"); string listing = LsText($"{"drwxr-xr-x",-12}{"player",-8}{$"{GetDistroStars(unit)}★",-6}{$"{version}/{GachaTuning.MaxVersion}",-6}{languages,-20}{unit.Id}/{upgradeMarker}");
Button row = new(); Button row = new() { name = $"CollectionUnit_{unit.Id}" };
row.AddToClassList("collection-row"); row.AddToClassList("collection-row");
row.AddToClassList("unit-overview-row"); row.AddToClassList("unit-overview-row");
row.AddToClassList(RarityPresentation.ForStars(GetDistroStars(unit)).ClassName); row.AddToClassList(RarityPresentation.ForStars(GetDistroStars(unit)).ClassName);
@@ -796,14 +799,14 @@ namespace KernelPanic.UI
_rows[selectedIndex].Focus(); _rows[selectedIndex].Focus();
} }
private void OpenUnitDetail(DistroDefinition unit, bool notify, bool returnToOverview = true) private void OpenUnitDetail(DistroDefinition unit, bool notify, bool returnToOverview = true, bool readOnly = false)
{ {
if (unit == null) if (unit == null)
{ {
return; return;
} }
if (_mode != CollectionMode.UnitDetail) if (_mode != CollectionMode.UnitDetail || readOnly)
{ {
_unitDetailTab = UnitDetailTab.Overview; _unitDetailTab = UnitDetailTab.Overview;
_packagePickerSlot = null; _packagePickerSlot = null;
@@ -811,6 +814,7 @@ namespace KernelPanic.UI
} }
_unitDetailReturnsToOverview = returnToOverview; _unitDetailReturnsToOverview = returnToOverview;
_unitDetailReadOnly = readOnly;
_mode = CollectionMode.UnitDetail; _mode = CollectionMode.UnitDetail;
CurrentTitle = $"$ cat /etc/distros/{unit.Id}.conf"; CurrentTitle = $"$ cat /etc/distros/{unit.Id}.conf";
CurrentHint = GetUnitDetailHint(); CurrentHint = GetUnitDetailHint();
@@ -834,12 +838,12 @@ namespace KernelPanic.UI
CurrentTitle = $"$ cat /etc/distros/{unit.Id}.conf"; CurrentTitle = $"$ cat /etc/distros/{unit.Id}.conf";
CurrentHint = GetUnitDetailHint(); CurrentHint = GetUnitDetailHint();
string identity = unit.Id + ":" + GetUnitVersion(unit); string identity = unit.Id + ":" + GetUnitVersion(unit) + (_unitDetailReadOnly ? ":preview" : ":owned");
if (_headerIdentity != identity) if (_headerIdentity != identity)
{ {
_contextHeader.Clear(); _contextHeader.Clear();
_contextHeader.Add(BuildUnitDetailHeader(unit)); _contextHeader.Add(BuildUnitDetailHeader(unit));
_contextHeader.Add(BuildUnitDetailTabs(unit)); if (!_unitDetailReadOnly) _contextHeader.Add(BuildUnitDetailTabs(unit));
_headerIdentity = identity; _headerIdentity = identity;
} }
_contextHeader.RemoveFromClassList("hidden"); _contextHeader.RemoveFromClassList("hidden");
@@ -2135,6 +2139,7 @@ namespace KernelPanic.UI
private string GetUnitDetailHint() private string GetUnitDetailHint()
{ {
if (_unitDetailReadOnly) return "[esc] back";
string action = _unitDetailTab switch string action = _unitDetailTab switch
{ {
UnitDetailTab.Upgrade => "[enter] upgrade", UnitDetailTab.Upgrade => "[enter] upgrade",
+319 -110
View File
@@ -52,6 +52,7 @@ namespace KernelPanic.UI
private Action _onChanged; private Action _onChanged;
private Action _requestRootCreditExchange; private Action _requestRootCreditExchange;
private Action<string, int, int> _requestPullCutscene; private Action<string, int, int> _requestPullCutscene;
private Action<DistroDefinition> _openDistroDetail;
private int _selectedBannerIndex; private int _selectedBannerIndex;
private int _pendingPullCount; private int _pendingPullCount;
private int _pendingMissingTokens; private int _pendingMissingTokens;
@@ -64,7 +65,7 @@ namespace KernelPanic.UI
private readonly List<string> _resultRewardLines = new(); private readonly List<string> _resultRewardLines = new();
private readonly List<int> _resultRewardStars = new(); private readonly List<int> _resultRewardStars = new();
public void Bind(VisualElement root, DistroDatabase database, PackageDatabase packageDatabase, FontAsset artFont, GachaService service, PlayerCollection collection, EntropyWallet entropyWallet, Func<IReadOnlyList<DistroDefinition>, PullResolutionResult> pullResolver, Func<DistroDefinition, PackageDefinition, string> claimSelectorChoice, Action changedCallback, Action rootCreditExchangeCallback, Action<string, int, int> pullCutsceneCallback) public void Bind(VisualElement root, DistroDatabase database, PackageDatabase packageDatabase, FontAsset artFont, GachaService service, PlayerCollection collection, EntropyWallet entropyWallet, Func<IReadOnlyList<DistroDefinition>, PullResolutionResult> pullResolver, Func<DistroDefinition, PackageDefinition, string> claimSelectorChoice, Action changedCallback, Action rootCreditExchangeCallback, Action<string, int, int> pullCutsceneCallback, Action<DistroDefinition> distroDetailCallback = null)
{ {
_root = root; _root = root;
_distroDatabase = database; _distroDatabase = database;
@@ -78,6 +79,7 @@ namespace KernelPanic.UI
_onChanged = changedCallback; _onChanged = changedCallback;
_requestRootCreditExchange = rootCreditExchangeCallback; _requestRootCreditExchange = rootCreditExchangeCallback;
_requestPullCutscene = pullCutsceneCallback; _requestPullCutscene = pullCutsceneCallback;
_openDistroDetail = distroDetailCallback;
_bannerList = root.Q<VisualElement>("GachaBannerList"); _bannerList = root.Q<VisualElement>("GachaBannerList");
_bannerDetail = root.Q<VisualElement>("GachaBannerDetail"); _bannerDetail = root.Q<VisualElement>("GachaBannerDetail");
if (_pullHistoryButton != null) _pullHistoryButton.clicked -= OpenPullHistory; if (_pullHistoryButton != null) _pullHistoryButton.clicked -= OpenPullHistory;
@@ -89,7 +91,9 @@ namespace KernelPanic.UI
{ {
if (!_hasOpened) if (!_hasOpened)
{ {
_selectedBannerIndex = 0; bool beginnerExhausted = _gachaService.BeginnerState.exhausted ||
_gachaService.BeginnerState.totalPulls >= GachaService.BeginnerMaxPulls;
_selectedBannerIndex = beginnerExhausted ? 1 : 0;
_hasOpened = true; _hasOpened = true;
} }
@@ -117,7 +121,7 @@ namespace KernelPanic.UI
_bannerRows.Clear(); _bannerRows.Clear();
_bannerList.Clear(); _bannerList.Clear();
if (_pullHistoryButton != null) if (_pullHistoryButton != null)
_pullHistoryButton.text = $"git log --pulls\n{_gachaService.PullHistory.Count} saved"; _pullHistoryButton.text = $"git log --pulls · {_gachaService.PullHistory.Count} saved";
Label branchCommand = new("$ git branch --list"); Label branchCommand = new("$ git branch --list");
branchCommand.AddToClassList("gacha-branch-command"); branchCommand.AddToClassList("gacha-branch-command");
@@ -223,41 +227,29 @@ namespace KernelPanic.UI
private void RenderBeginnerBanner() private void RenderBeginnerBanner()
{ {
GachaBannerState state = _gachaService.BeginnerState; GachaBannerState state = _gachaService.BeginnerState;
bool closed = state.exhausted || state.totalPulls >= GachaService.BeginnerMaxPulls;
_bannerDetail.Add(BuildActiveBannerHeader(
GachaService.BeginnerBannerId,
"beginner install media",
closed ? "CLOSED" : $"OPEN · {GachaService.BeginnerMaxPulls - state.totalPulls} LEFT",
closed));
_bannerDetail.Add(BuildBannerHero("beginner install media")); _bannerDetail.Add(BuildBannerHero("beginner install media"));
_bannerDetail.Add(BuildInfoLine("Entropy", _wallet == null ? "--" : _wallet.Balance.ToString())); VisualElement counters = BuildCounterGrid();
_bannerDetail.Add(BuildInfoLine("Commits", _gachaService.PullTokens.ToString())); counters.Add(BuildProgressMetric("allocation", "allocation", $"{state.totalPulls}/{GachaService.BeginnerMaxPulls}", state.totalPulls, GachaService.BeginnerMaxPulls,
_bannerDetail.Add(BuildInfoLine("pulls", $"{state.totalPulls}/{GachaService.BeginnerMaxPulls}")); closed ? "install-media allocation complete" : "discounted pulls remaining"));
_bannerDetail.Add(BuildInfoLine("4-star pity", $"{state.pityCounter}/{GachaService.FourStarHardPity}")); counters.Add(BuildProgressMetric("four-star", "4★ guarantee", $"{state.pityCounter}/{GachaService.FourStarHardPity}", state.pityCounter, GachaService.FourStarHardPity,
_bannerDetail.Add(BuildInfoLine("cost", $"1 Commit / {GachaService.EntropyPerCommit} Entropy per pull")); "resets on a 4★+ result"));
_bannerDetail.Add(BuildInfoLine("guarantees", FormatBeginnerGuarantees())); counters.Add(BuildProgressMetric("milestones", "milestones", "20 · 40 · 50", -1, 0, FormatBeginnerGuarantees()));
_bannerDetail.Add(counters);
Label rules = new("Base result is a 3-star package cache. A 4-star package cache or starter distro can appear early, with one 4-star+ result guaranteed every 10 pulls."); _bannerDetail.Add(BuildPullPanel(
rules.AddToClassList("gacha-rules"); GachaService.BeginnerSinglePullCost,
_bannerDetail.Add(rules); _gachaService.GetBeginnerPullCost(10),
CanAttemptBeginnerPull(1),
VisualElement actions = new(); CanAttemptBeginnerPull(10),
actions.AddToClassList("gacha-actions"); "4★ base 7% · 5★ base 0.8% · fixed rewards at pulls 20, 40 and 50",
closed ? "remote: beginner allocation is complete; checkout stable to keep pulling." : null));
Button singleButton = new(() => RequestPullSelectedBanner(1))
{
text = $"git pull --single\n1x {GachaService.FormatCurrencyName(GachaCurrencyType.StandardPull)}"
};
singleButton.AddToClassList("terminal-button");
singleButton.AddToClassList("gacha-action-button");
singleButton.SetEnabled(CanAttemptBeginnerPull(1));
actions.Add(singleButton);
Button tenButton = new(() => RequestPullSelectedBanner(10))
{
text = $"git pull --ten\n{_gachaService.GetBeginnerPullCost(10)}x {GachaService.FormatCurrencyName(GachaCurrencyType.StandardPull)}"
};
tenButton.AddToClassList("terminal-button");
tenButton.AddToClassList("gacha-action-button");
tenButton.SetEnabled(CanAttemptBeginnerPull(10));
actions.Add(tenButton);
_bannerDetail.Insert(_bannerDetail.IndexOf(rules), actions);
if (_pendingPullCount > 0) if (_pendingPullCount > 0)
{ {
@@ -274,42 +266,26 @@ namespace KernelPanic.UI
private void RenderStandardBanner() private void RenderStandardBanner()
{ {
GachaBannerState state = _gachaService.StandardState; GachaBannerState state = _gachaService.StandardState;
_bannerDetail.Add(BuildActiveBannerHeader(
GachaService.StandardBannerId,
"stable branch",
"PERMANENT",
false));
_bannerDetail.Add(BuildBannerHero("stable branch")); _bannerDetail.Add(BuildBannerHero("stable branch"));
_bannerDetail.Add(BuildInfoLine("Entropy", _wallet == null ? "--" : _wallet.Balance.ToString())); VisualElement counters = BuildCounterGrid();
_bannerDetail.Add(BuildInfoLine("Commits", _gachaService.PullTokens.ToString())); counters.Add(BuildProgressMetric("total-pulls", "pull history", state.totalPulls.ToString(), -1, 0, "lifetime pulls on stable"));
_bannerDetail.Add(BuildInfoLine("pulls", state.totalPulls.ToString())); counters.Add(BuildProgressMetric("four-star", "4★ guarantee", $"{state.pityCounter}/{GachaService.FourStarHardPity}", state.pityCounter, GachaService.FourStarHardPity, "guaranteed by pull 10"));
_bannerDetail.Add(BuildInfoLine("4-star pity", $"{state.pityCounter}/{GachaService.FourStarHardPity}")); counters.Add(BuildProgressMetric("five-star", "5★ pity", $"{state.fiveStarPityCounter}/{GachaService.FiveStarHardPity}", state.fiveStarPityCounter, GachaService.FiveStarHardPity, "odds rise after 65"));
_bannerDetail.Add(BuildInfoLine("5-star pity", $"{state.fiveStarPityCounter}/{GachaService.FiveStarHardPity}")); counters.Add(BuildProgressMetric("selector", "5★ selector", $"{_gachaService.GetStandardFiveStarSelectorProgress()}/{GachaService.StandardFiveStarSelectorInterval}", _gachaService.GetStandardFiveStarSelectorProgress(), GachaService.StandardFiveStarSelectorInterval, "choose distro + package"));
_bannerDetail.Add(BuildInfoLine("5-star selector", $"{_gachaService.GetStandardFiveStarSelectorProgress()}/{GachaService.StandardFiveStarSelectorInterval}")); _bannerDetail.Add(counters);
_bannerDetail.Add(BuildInfoLine("cost", $"{GachaService.StandardSinglePullCost} Commit / {GachaService.StandardTenPullCost} for ten"));
Label rules = new("Base result is a 3-star package cache. A 4-star package cache or install-media distro is guaranteed every 10 pulls; 5-star odds ramp up starting pull 66 of the pity cycle and are guaranteed by pull 80. Every 200 pulls, choose a standard 5-star character and a standard 5-star package outright."); _bannerDetail.Add(BuildPullPanel(
rules.AddToClassList("gacha-rules"); GachaService.StandardSinglePullCost,
_bannerDetail.Add(rules); GachaService.StandardTenPullCost,
CanAttemptStandardPull(1),
VisualElement actions = new(); CanAttemptStandardPull(10),
actions.AddToClassList("gacha-actions"); "4★ base 7% · 5★ base 0.8% · soft pity +7% per pull from 66 · hard pity 80"));
Button singleButton = new(() => RequestPullSelectedBanner(1))
{
text = $"git pull --single\n{GachaService.StandardSinglePullCost}x {GachaService.FormatCurrencyName(GachaCurrencyType.StandardPull)}"
};
singleButton.AddToClassList("terminal-button");
singleButton.AddToClassList("gacha-action-button");
singleButton.SetEnabled(CanAttemptStandardPull(1));
actions.Add(singleButton);
Button tenButton = new(() => RequestPullSelectedBanner(10))
{
text = $"git pull --ten\n{GachaService.StandardTenPullCost}x {GachaService.FormatCurrencyName(GachaCurrencyType.StandardPull)}"
};
tenButton.AddToClassList("terminal-button");
tenButton.AddToClassList("gacha-action-button");
tenButton.SetEnabled(CanAttemptStandardPull(10));
actions.Add(tenButton);
_bannerDetail.Insert(_bannerDetail.IndexOf(rules), actions);
if (_pendingPullCount > 0) if (_pendingPullCount > 0)
{ {
@@ -337,39 +313,26 @@ namespace KernelPanic.UI
private void RenderLimitedBanner() private void RenderLimitedBanner()
{ {
GachaBannerState state = _gachaService.LimitedState; GachaBannerState state = _gachaService.LimitedState;
_bannerDetail.Add(BuildActiveBannerHeader(
GachaService.LimitedBannerId,
"feature branch: NixOS",
state.featuredFiveStarGuaranteed ? "NIXOS GUARANTEED" : "FEATURED · NIXOS",
false));
_bannerDetail.Add(BuildBannerHero("feature branch: NixOS")); _bannerDetail.Add(BuildBannerHero("feature branch: NixOS"));
_bannerDetail.Add(BuildInfoLine("Entropy", _wallet == null ? "--" : _wallet.Balance.ToString())); VisualElement counters = BuildCounterGrid();
_bannerDetail.Add(BuildInfoLine("Commits", _gachaService.PullTokens.ToString())); counters.Add(BuildProgressMetric("total-pulls", "pull history", state.totalPulls.ToString(), -1, 0, "lifetime pulls on feature/nixos"));
_bannerDetail.Add(BuildInfoLine("pulls", state.totalPulls.ToString())); counters.Add(BuildProgressMetric("four-star", "4★ guarantee", $"{state.pityCounter}/{GachaService.FourStarHardPity}", state.pityCounter, GachaService.FourStarHardPity, "guaranteed by pull 10"));
_bannerDetail.Add(BuildInfoLine("4-star pity", $"{state.pityCounter}/{GachaService.FourStarHardPity}")); counters.Add(BuildProgressMetric("five-star", "5★ pity", $"{state.fiveStarPityCounter}/{GachaService.FiveStarHardPity}", state.fiveStarPityCounter, GachaService.FiveStarHardPity, "odds rise after 65"));
_bannerDetail.Add(BuildInfoLine("5-star pity", $"{state.fiveStarPityCounter}/{GachaService.FiveStarHardPity}")); counters.Add(BuildProgressMetric("featured", "featured guarantee", state.featuredFiveStarGuaranteed ? "armed" : "not armed", -1, 0, state.featuredFiveStarGuaranteed ? "next distro hit is NixOS" : "lose once to arm"));
_bannerDetail.Add(BuildInfoLine("featured guarantee", state.featuredFiveStarGuaranteed ? "armed" : "not armed")); _bannerDetail.Add(counters);
_bannerDetail.Add(BuildInfoLine("cost", $"{GachaService.LimitedSinglePullCost} Commit / {GachaService.LimitedTenPullCost} for ten"));
Label rules = new("Featured 5-star distro: NixOS. A 4-star package or featured Fedora/Ubuntu is guaranteed every 10 pulls. Five-star odds ramp from pull 66 and guarantee by pull 80. A 5-star first splits between package and distro; a non-featured 5-star distro arms the next distro hit as guaranteed NixOS."); _bannerDetail.Add(BuildPullPanel(
rules.AddToClassList("gacha-rules"); GachaService.LimitedSinglePullCost,
_bannerDetail.Add(rules); GachaService.LimitedTenPullCost,
CanAttemptLimitedPull(1),
VisualElement actions = new(); CanAttemptLimitedPull(10),
actions.AddToClassList("gacha-actions"); "4★ base 7% · 5★ base 0.8% · soft pity +7% per pull from 66 · hard pity 80"));
Button singleButton = new(() => RequestPullSelectedBanner(1))
{
text = $"git pull --single\n{GachaService.LimitedSinglePullCost}x {GachaService.FormatCurrencyName(GachaCurrencyType.StandardPull)}"
};
singleButton.AddToClassList("terminal-button");
singleButton.AddToClassList("gacha-action-button");
singleButton.SetEnabled(CanAttemptLimitedPull(1));
actions.Add(singleButton);
Button tenButton = new(() => RequestPullSelectedBanner(10))
{
text = $"git pull --ten\n{GachaService.LimitedTenPullCost}x {GachaService.FormatCurrencyName(GachaCurrencyType.StandardPull)}"
};
tenButton.AddToClassList("terminal-button");
tenButton.AddToClassList("gacha-action-button");
tenButton.SetEnabled(CanAttemptLimitedPull(10));
actions.Add(tenButton);
_bannerDetail.Insert(_bannerDetail.IndexOf(rules), actions);
if (_pendingPullCount > 0) _bannerDetail.Add(BuildEntropyPrompt()); if (_pendingPullCount > 0) _bannerDetail.Add(BuildEntropyPrompt());
if (_resultBannerId == GachaService.LimitedBannerId && if (_resultBannerId == GachaService.LimitedBannerId &&
@@ -473,8 +436,26 @@ namespace KernelPanic.UI
{ {
_pullHistoryOverlay?.RemoveFromClassList("modal-open"); _pullHistoryOverlay?.RemoveFromClassList("modal-open");
_pullHistoryOverlay?.AddToClassList("hidden"); _pullHistoryOverlay?.AddToClassList("hidden");
if (_pullHistoryReturnFocus?.panel != null) _pullHistoryReturnFocus.Focus(); // The opener may have been removed or disabled while the history was open.
var selectedBanner = _selectedBannerIndex >= 0 && _selectedBannerIndex < _bannerRows.Count
? _bannerRows[_selectedBannerIndex] : null;
foreach (var candidate in new[] { _pullHistoryReturnFocus, _pullHistoryButton, selectedBanner })
{
if (!CanFocus(candidate)) continue;
candidate.Focus();
break;
}
_pullHistoryReturnFocus = null; _pullHistoryReturnFocus = null;
bool CanFocus(VisualElement element)
{
if (element == null || element.panel == null || element.panel != _root.panel ||
!element.focusable || !element.enabledInHierarchy || !element.visible) return false;
for (var parent = element; parent != null; parent = parent.parent)
if (parent.style.display == DisplayStyle.None || parent.resolvedStyle.display == DisplayStyle.None ||
parent.style.visibility == Visibility.Hidden) return false;
return true;
}
} }
private void EnsureSelectorOverlay() private void EnsureSelectorOverlay()
@@ -528,8 +509,26 @@ namespace KernelPanic.UI
_selectorOverlay?.AddToClassList("hidden"); _selectorOverlay?.AddToClassList("hidden");
_selectorChosenDistro = null; _selectorChosenDistro = null;
_selectorResultText = null; _selectorResultText = null;
if (_selectorReturnFocus?.panel != null) _selectorReturnFocus.Focus(); // Claiming or refreshing can remove the button that opened the selector.
var selectedBanner = _selectedBannerIndex >= 0 && _selectedBannerIndex < _bannerRows.Count
? _bannerRows[_selectedBannerIndex] : null;
foreach (var candidate in new[] { _selectorReturnFocus, _pullHistoryButton, selectedBanner })
{
if (!CanFocus(candidate)) continue;
candidate.Focus();
break;
}
_selectorReturnFocus = null; _selectorReturnFocus = null;
bool CanFocus(VisualElement element)
{
if (element == null || element.panel == null || element.panel != _root.panel ||
!element.focusable || !element.enabledInHierarchy || !element.visible) return false;
for (var parent = element; parent != null; parent = parent.parent)
if (parent.style.display == DisplayStyle.None || parent.resolvedStyle.display == DisplayStyle.None ||
parent.style.visibility == Visibility.Hidden) return false;
return true;
}
} }
private void RenderFiveStarSelectorDialog() private void RenderFiveStarSelectorDialog()
@@ -988,6 +987,144 @@ namespace KernelPanic.UI
_pendingMissingTokens = 0; _pendingMissingTokens = 0;
} }
private VisualElement BuildActiveBannerHeader(string bannerId, string title, string state, bool warning)
{
VisualElement header = new();
header.AddToClassList("gacha-active-header");
VisualElement copy = new();
copy.AddToClassList("gacha-active-copy");
Label command = new("$ git checkout " + GetBannerRef(bannerId)) { name = "GachaActiveCommand" };
command.AddToClassList("gacha-active-command");
copy.Add(command);
Label heading = new(title) { name = "GachaActiveTitle" };
heading.AddToClassList("gacha-active-title");
copy.Add(heading);
header.Add(copy);
Label status = new(state) { name = "GachaActiveStatus" };
status.AddToClassList("gacha-active-status");
if (warning) status.AddToClassList("warning");
header.Add(status);
return header;
}
private static VisualElement BuildCounterGrid()
{
VisualElement grid = new();
grid.AddToClassList("gacha-counter-grid");
return grid;
}
private static VisualElement BuildProgressMetric(string id, string label, string value, int progress, int maximum, string detail)
{
VisualElement metric = new() { name = "GachaMetric_" + id };
metric.AddToClassList("gacha-progress-metric");
Label metricLabel = new(label);
metricLabel.AddToClassList("gacha-progress-label");
metric.Add(metricLabel);
Label metricValue = new(value);
metricValue.AddToClassList("gacha-progress-value");
metric.Add(metricValue);
if (maximum > 0)
{
VisualElement track = new();
track.AddToClassList("gacha-progress-track");
VisualElement fill = new();
fill.AddToClassList("gacha-progress-fill");
float ratio = Mathf.Clamp01(progress / (float)maximum);
fill.style.width = Length.Percent(ratio * 100f);
track.Add(fill);
metric.Add(track);
if (progress >= maximum) metric.AddToClassList("complete");
}
if (!string.IsNullOrWhiteSpace(detail))
{
Label detailLabel = new(detail);
detailLabel.AddToClassList("gacha-progress-detail");
metric.Add(detailLabel);
}
return metric;
}
private VisualElement BuildPullPanel(int singleCost, int tenCost, bool canSingle, bool canTen, string oddsText, string unavailableMessage = null)
{
VisualElement panel = new();
panel.AddToClassList("gacha-pull-panel");
Label heading = new("[ pull commands ]");
heading.AddToClassList("gacha-pull-heading");
panel.Add(heading);
if (!string.IsNullOrWhiteSpace(unavailableMessage))
{
Label unavailable = new(unavailableMessage);
unavailable.AddToClassList("gacha-pull-unavailable");
panel.Add(unavailable);
return panel;
}
VisualElement actions = new();
actions.AddToClassList("gacha-actions");
Button singleButton = new(() => RequestPullSelectedBanner(1))
{
name = "GachaPullSingleButton",
text = "$ git pull --single\n" + FormatPullReadiness(singleCost, canSingle)
};
singleButton.AddToClassList("terminal-button");
singleButton.AddToClassList("gacha-action-button");
singleButton.AddToClassList("gacha-action-secondary");
singleButton.SetEnabled(canSingle);
actions.Add(singleButton);
Button tenButton = new(() => RequestPullSelectedBanner(10))
{
name = "GachaPullTenButton",
text = "$ git pull --ten\n" + FormatPullReadiness(tenCost, canTen)
};
tenButton.AddToClassList("terminal-button");
tenButton.AddToClassList("gacha-action-button");
tenButton.AddToClassList("gacha-action-primary");
tenButton.SetEnabled(canTen);
actions.Add(tenButton);
panel.Add(actions);
Foldout odds = new() { text = "inspect odds", value = false, name = "GachaOddsInspector" };
odds.AddToClassList("gacha-odds");
Label oddsCopy = new(oddsText);
oddsCopy.AddToClassList("gacha-odds-copy");
odds.Add(oddsCopy);
panel.Add(odds);
return panel;
}
private string FormatPullReadiness(int cost, bool canAttempt)
{
int commits = _gachaService?.PullTokens ?? 0;
int entropy = _wallet?.Balance ?? 0;
int entropyCost = cost * GachaService.EntropyPerCommit;
bool hasPaymentPath = commits >= cost || entropy >= entropyCost || (_gachaService?.RootCredits ?? 0) > 0;
if (!canAttempt && hasPaymentPath)
return "blocked · unavailable here";
if (commits >= cost)
return "ready · spend " + FormatCommitCost(cost);
if (entropy >= entropyCost)
return $"ready · confirm {entropyCost} Entropy";
if ((_gachaService?.RootCredits ?? 0) > 0)
return "exchange · Root Credit available";
return $"blocked · {Math.Max(0, entropyCost - entropy)} Entropy short";
}
private static string FormatCommitCost(int cost)
{
return cost == 1 ? "1 Commit" : $"{cost} Commits";
}
private VisualElement BuildBannerHero(string bannerTitle) private VisualElement BuildBannerHero(string bannerTitle)
{ {
VisualElement hero = new(); VisualElement hero = new();
@@ -998,14 +1135,19 @@ namespace KernelPanic.UI
IReadOnlyList<DistroDefinition> distros = _distroDatabase == null ? Array.Empty<DistroDefinition>() : _distroDatabase.AllDistros; IReadOnlyList<DistroDefinition> distros = _distroDatabase == null ? Array.Empty<DistroDefinition>() : _distroDatabase.AllDistros;
List<DistroDefinition> heroDistros = new(); List<DistroDefinition> heroDistros = new();
if (bannerTitle.IndexOf("NixOS", StringComparison.OrdinalIgnoreCase) >= 0) bool featuredSpotlight = bannerTitle.IndexOf("NixOS", StringComparison.OrdinalIgnoreCase) >= 0;
if (featuredSpotlight)
{ {
for (int i = 0; i < distros.Count; i++) for (int i = 0; i < distros.Count; i++)
if (string.Equals(distros[i]?.Id, GachaService.LimitedFeaturedFiveStarDistroId, StringComparison.OrdinalIgnoreCase)) if (string.Equals(distros[i]?.Id, GachaService.LimitedFeaturedFiveStarDistroId, StringComparison.OrdinalIgnoreCase))
heroDistros.Add(distros[i]); heroDistros.Add(distros[i]);
hero.AddToClassList("gacha-hero-single");
} }
else
{
for (int i = 0; i < distros.Count && heroDistros.Count < 3; i++) for (int i = 0; i < distros.Count && heroDistros.Count < 3; i++)
if (distros[i] != null && !heroDistros.Contains(distros[i])) heroDistros.Add(distros[i]); if (distros[i] != null && !heroDistros.Contains(distros[i])) heroDistros.Add(distros[i]);
}
for (int i = 0; i < heroDistros.Count; i++) artRow.Add(BuildDistroArtCard(heroDistros[i])); for (int i = 0; i < heroDistros.Count; i++) artRow.Add(BuildDistroArtCard(heroDistros[i]));
if (heroDistros.Count == 0) if (heroDistros.Count == 0)
@@ -1021,8 +1163,14 @@ namespace KernelPanic.UI
private VisualElement BuildDistroArtCard(DistroDefinition distro) private VisualElement BuildDistroArtCard(DistroDefinition distro)
{ {
VisualElement card = new(); Button card = new(() => _openDistroDetail?.Invoke(distro))
{
name = "GachaDistroArt_" + (distro == null ? "unknown" : distro.Id),
tooltip = distro == null ? "Distro details unavailable" : $"Open {DistroPresentation.DisplayName(distro)} details"
};
card.AddToClassList("gacha-art-card"); card.AddToClassList("gacha-art-card");
card.AddToClassList("gacha-art-button");
card.SetEnabled(distro != null && _openDistroDetail != null);
VisualElement artShell = new(); VisualElement artShell = new();
artShell.AddToClassList("gacha-art-shell"); artShell.AddToClassList("gacha-art-shell");
@@ -1043,17 +1191,74 @@ namespace KernelPanic.UI
artShell.Add(artLabel); artShell.Add(artLabel);
card.Add(artShell); card.Add(artShell);
Label name = new(distro == null ? "--" : DistroPresentation.DisplayName(distro)); Label ownership = new(FormatDistroOwnership(distro));
name.AddToClassList("gacha-art-name"); ownership.AddToClassList("gacha-art-name");
ownership.AddToClassList("gacha-art-ownership");
if (distro != null) if (distro != null)
{ {
name.style.color = new StyleColor(distro.AccentColor); ownership.style.color = new StyleColor(distro.AccentColor);
} }
card.Add(name); Label inspect = new(distro == null ? "--" : $"[enter] cat /etc/distros/{distro.Id}.conf");
inspect.AddToClassList("gacha-art-name");
inspect.AddToClassList("gacha-art-inspect");
inspect.AddToClassList("hidden");
VisualElement cue = new();
cue.AddToClassList("gacha-art-cue");
cue.Add(ownership);
cue.Add(inspect);
card.Add(cue);
bool pointerInside = false;
bool keyboardFocused = false;
void RefreshCue()
{
bool showInspect = distro != null && _openDistroDetail != null && (pointerInside || keyboardFocused);
ownership.EnableInClassList("hidden", showInspect);
inspect.EnableInClassList("hidden", !showInspect);
}
card.RegisterCallback<PointerEnterEvent>(_ =>
{
pointerInside = true;
RefreshCue();
});
card.RegisterCallback<PointerLeaveEvent>(_ =>
{
pointerInside = false;
RefreshCue();
});
card.RegisterCallback<FocusInEvent>(_ =>
{
keyboardFocused = true;
RefreshCue();
});
card.RegisterCallback<FocusOutEvent>(_ =>
{
keyboardFocused = false;
RefreshCue();
});
return card; return card;
} }
private string FormatDistroOwnership(DistroDefinition distro)
{
if (distro == null)
{
return "--";
}
string displayName = DistroPresentation.DisplayName(distro);
if (_playerCollection == null || !_playerCollection.IsOwned(distro.Id))
{
return $"{displayName} · not installed";
}
int version = Mathf.Clamp(_playerCollection.GetVersion(distro.Id), 1, GachaTuning.MaxVersion);
return $"{displayName} · installed v{version}/{GachaTuning.MaxVersion}";
}
private string FormatBeginnerGuarantees() private string FormatBeginnerGuarantees()
{ {
IReadOnlyList<string> ids = _gachaService.BeginnerState.guaranteedDistroIds; IReadOnlyList<string> ids = _gachaService.BeginnerState.guaranteedDistroIds;
@@ -1077,11 +1282,15 @@ namespace KernelPanic.UI
{ {
return bannerId switch return bannerId switch
{ {
GachaService.BeginnerBannerId => _gachaService.IsBeginnerBannerAvailable ? $"{_gachaService.BeginnerState.totalPulls}/{GachaService.BeginnerMaxPulls}" : "closed", GachaService.BeginnerBannerId => _gachaService.BeginnerState.exhausted || _gachaService.BeginnerState.totalPulls >= GachaService.BeginnerMaxPulls
GachaService.StandardBannerId => _gachaService.PendingStandardFiveStarSelectors > 0 ? "selector ready" : $"{_gachaService.GetStandardFiveStarSelectorProgress()}/{GachaService.StandardFiveStarSelectorInterval}", ? $"closed · {_gachaService.BeginnerState.totalPulls}/{GachaService.BeginnerMaxPulls}"
: $"allocation {_gachaService.BeginnerState.totalPulls}/{GachaService.BeginnerMaxPulls}",
GachaService.StandardBannerId => _gachaService.PendingStandardFiveStarSelectors > 0
? "selector ready"
: $"selector {_gachaService.GetStandardFiveStarSelectorProgress()}/{GachaService.StandardFiveStarSelectorInterval}",
GachaService.LimitedBannerId => _gachaService.LimitedState.featuredFiveStarGuaranteed GachaService.LimitedBannerId => _gachaService.LimitedState.featuredFiveStarGuaranteed
? "featured guaranteed" ? "NixOS guaranteed"
: $"{_gachaService.LimitedState.fiveStarPityCounter}/{GachaService.FiveStarHardPity}", : $"5★ pity {_gachaService.LimitedState.fiveStarPityCounter}/{GachaService.FiveStarHardPity}",
_ => "--" _ => "--"
}; };
} }
+28 -2
View File
@@ -222,7 +222,7 @@ namespace KernelPanic.UI
featuredUnitPanel.Bind(_root, resolvedFont, GetBestWaveForUnit, OpenFeaturedUnitDetail); featuredUnitPanel.Bind(_root, resolvedFont, GetBestWaveForUnit, OpenFeaturedUnitDetail);
collectionScreen.Bind(_root, resolvedFont, languageDeckDatabase, cardDatabase, _playerCollection, GetMergesBalance, UpgradeCollectionUnit, packageDatabase, _packageLoadout, SaveCurrentState, () => _saveData, UpgradeCollectionPackage, ScrapCollectionPackage); collectionScreen.Bind(_root, resolvedFont, languageDeckDatabase, cardDatabase, _playerCollection, GetMergesBalance, UpgradeCollectionUnit, packageDatabase, _packageLoadout, SaveCurrentState, () => _saveData, UpgradeCollectionPackage, ScrapCollectionPackage);
collectionScreen.LanguageTrainingRequested += StartLanguageTraining; collectionScreen.LanguageTrainingRequested += StartLanguageTraining;
gachaScreen.Bind(_root, distroDatabase, packageDatabase, resolvedFont, _gachaService, _playerCollection, _wallet, ResolvePulledDistros, ClaimStandardFiveStarSelector, HandleMetaStateChanged, OpenRootCreditExchange, StartGachaPullCutscene); gachaScreen.Bind(_root, distroDatabase, packageDatabase, resolvedFont, _gachaService, _playerCollection, _wallet, ResolvePulledDistros, ClaimStandardFiveStarSelector, HandleMetaStateChanged, OpenRootCreditExchange, StartGachaPullCutscene, OpenGachaDistroDetail);
LoadMetaState(); LoadMetaState();
_playerCollection.Changed += HandleMetaStateChanged; _playerCollection.Changed += HandleMetaStateChanged;
_gachaService.Changed += HandleMetaStateChanged; _gachaService.Changed += HandleMetaStateChanged;
@@ -1120,6 +1120,32 @@ namespace KernelPanic.UI
ShowScreen(MenuScreen.Collection); ShowScreen(MenuScreen.Collection);
} }
private void OpenGachaDistroDetail(DistroDefinition unit)
{
if (unit == null)
{
return;
}
_collectionTab = CollectionTopTab.Units;
ApplyCollectionTabButtons();
var previewUnits = new List<DistroDefinition>(_playerCollection.OwnedUnits);
bool alreadyListed = false;
for (int i = 0; i < previewUnits.Count; i++)
{
if (previewUnits[i] != null && string.Equals(previewUnits[i].Id, unit.Id, StringComparison.OrdinalIgnoreCase))
{
alreadyListed = true;
break;
}
}
if (!alreadyListed) previewUnits.Add(unit);
collectionScreen.RefreshUnits(previewUnits);
collectionScreen.ShowUnitDetail(unit, false, true);
SyncCollectionFrame();
ShowScreen(MenuScreen.Collection);
}
private void HandleStarterConfirmed(DistroDefinition picked, IReadOnlyList<DistroDefinition> remaining) private void HandleStarterConfirmed(DistroDefinition picked, IReadOnlyList<DistroDefinition> remaining)
{ {
_playerCollection.Add(picked, 1); _playerCollection.Add(picked, 1);
@@ -2860,7 +2886,7 @@ namespace KernelPanic.UI
return; return;
} }
ShowMainMenu(); NavigateBack();
} }
private void ShowCollectionUnits() private void ShowCollectionUnits()
+2 -1
View File
@@ -63,7 +63,8 @@ namespace KernelPanic.UI
if (_historyIndex > 0) _input.SetValueWithoutNotify(_history[--_historyIndex]); if (_historyIndex > 0) _input.SetValueWithoutNotify(_history[--_historyIndex]);
break; break;
case KeyCode.DownArrow: case KeyCode.DownArrow:
if (_historyIndex < _history.Count) _historyIndex++; if (_historyIndex == _history.Count) break;
_historyIndex++;
_input.SetValueWithoutNotify(_historyIndex == _history.Count ? _draft : _history[_historyIndex]); _input.SetValueWithoutNotify(_historyIndex == _history.Count ? _draft : _history[_historyIndex]);
break; break;
case KeyCode.Tab: case KeyCode.Tab:
+21 -3
View File
@@ -75,13 +75,31 @@ namespace KernelPanic.UI
region.schedule.Execute(() => region.schedule.Execute(() =>
{ {
if (focused.panel != null) return; if (focused.panel != null) return;
// A focus choice made since the rebuild takes precedence over restoration.
var current = region.focusController?.focusedElement as VisualElement;
if (current != null && current != focused) return;
bool CanRestoreTo(VisualElement element) => element != null && element.focusable && IsAvailable(element);
VisualElement replacement = string.IsNullOrEmpty(name) ? null : region.Q(name); VisualElement replacement = string.IsNullOrEmpty(name) ? null : region.Q(name);
if (!CanRestoreTo(replacement)) replacement = null;
if (replacement == null && !string.IsNullOrEmpty(text)) if (replacement == null && !string.IsNullOrEmpty(text))
replacement = region.Query<Button>().Where(button => button.text == text && button.enabledInHierarchy).First(); replacement = region.Query<Button>().Where(button => button.text == text && CanRestoreTo(button)).First();
replacement ??= region.Query<Button>().Where(button => button.enabledInHierarchy).First(); replacement ??= region.Query<Button>().Where(button => CanRestoreTo(button)).First();
if (replacement != null) replacement.Focus(); if (replacement != null) replacement.Focus();
else { region.focusable = true; region.Focus(); } else if (IsAvailable(region)) { region.focusable = true; region.Focus(); }
}); });
static bool IsAvailable(VisualElement element)
{
if (element.panel == null || !element.enabledInHierarchy || !element.visible) return false;
for (var parent = element; parent != null; parent = parent.parent)
{
// Inline changes may precede the next style/layout update.
if (parent.style.display == DisplayStyle.None || parent.resolvedStyle.display == DisplayStyle.None ||
parent.style.visibility == Visibility.Hidden) return false;
}
return true;
}
} }
public static void ConstrainModalFocus(VisualElement overlay) public static void ConstrainModalFocus(VisualElement overlay)
+668 -2
View File
@@ -45,6 +45,7 @@ public class TerminalUiTests
symbol.style.right = 0; symbol.style.right = 0;
} }
var steps = menu.Query<Button>(className: "exchange-step-button").ToList(); var steps = menu.Query<Button>(className: "exchange-step-button").ToList();
Assert.That(steps.Count, Is.EqualTo(6));
var stepRow = new VisualElement(); var stepRow = new VisualElement();
stepRow.style.flexDirection = FlexDirection.Row; stepRow.style.flexDirection = FlexDirection.Row;
stepRow.style.flexWrap = Wrap.Wrap; stepRow.style.flexWrap = Wrap.Wrap;
@@ -57,6 +58,7 @@ public class TerminalUiTests
foreach (int state in new[] { 0, 1, 2 }) foreach (int state in new[] { 0, 1, 2 })
{ {
foreach (var symbol in symbols) symbol.SetEnabled(state != 2); foreach (var symbol in symbols) symbol.SetEnabled(state != 2);
foreach (var step in steps) step.SetEnabled(state != 2);
if (state == 1) dynamicClose.Focus(); if (state == 1) dynamicClose.Focus();
yield return null; yield return null;
yield return null; yield return null;
@@ -72,7 +74,15 @@ public class TerminalUiTests
Assert.That(style.whiteSpace, Is.EqualTo(WhiteSpace.NoWrap)); Assert.That(style.whiteSpace, Is.EqualTo(WhiteSpace.NoWrap));
} }
foreach (var step in steps) foreach (var step in steps)
{
if (state == 1)
{
step.Focus();
yield return null;
Assert.That(root.focusController.focusedElement, Is.SameAs(step));
}
Assert.That(step.resolvedStyle.unityTextAlign, Is.EqualTo(TextAnchor.MiddleCenter), step.text); Assert.That(step.resolvedStyle.unityTextAlign, Is.EqualTo(TextAnchor.MiddleCenter), step.text);
}
Assert.That(command.resolvedStyle.unityTextAlign, Is.EqualTo(TextAnchor.MiddleLeft)); Assert.That(command.resolvedStyle.unityTextAlign, Is.EqualTo(TextAnchor.MiddleLeft));
} }
LogAssert.NoUnexpectedReceived(); LogAssert.NoUnexpectedReceived();
@@ -154,9 +164,22 @@ public class TerminalUiTests
target.Focus(); target.Focus();
yield return null; yield return null;
yield return null;
Assert.That(root.focusController.focusedElement, Is.SameAs(target)); Assert.That(root.focusController.focusedElement, Is.SameAs(target));
Assert.That(inner.scrollOffset.y, Is.GreaterThan(0)); Assert.That(inner.scrollOffset.y, Is.GreaterThan(0));
Assert.That(outer.scrollOffset.y, Is.GreaterThan(0)); Assert.That(outer.scrollOffset.y, Is.GreaterThan(0));
Assert.That(target.worldBound.width, Is.GreaterThan(0));
Assert.That(target.worldBound.height, Is.GreaterThan(0));
foreach (var scroll in new[] { inner, outer })
{
var viewport = scroll.contentViewport.worldBound;
var bounds = target.worldBound;
const float tolerance = 1f; // Allow subpixel layout rounding.
Assert.That(bounds.xMin, Is.GreaterThanOrEqualTo(viewport.xMin - tolerance));
Assert.That(bounds.xMax, Is.LessThanOrEqualTo(viewport.xMax + tolerance));
Assert.That(bounds.yMin, Is.GreaterThanOrEqualTo(viewport.yMin - tolerance));
Assert.That(bounds.yMax, Is.LessThanOrEqualTo(viewport.yMax + tolerance));
}
LogAssert.NoUnexpectedReceived(); LogAssert.NoUnexpectedReceived();
} }
finally { window.Close(); } finally { window.Close(); }
@@ -178,6 +201,370 @@ public class TerminalUiTests
} }
} }
[UnityTest]
public IEnumerator CollectionRefreshPreservesUnitFocusAndFallsBackWhenItDisappears()
{
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
Assert.Ignore("Focus restoration tests require an editor panel; run Unity without -nographics.");
var window = ScriptableObject.CreateInstance<TerminalFocusTestWindow>();
try
{
window.position = new Rect(0, 0, 900, 700);
window.Show();
var root = window.rootVisualElement;
root.styleSheets.Add(AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/UI/MainMenu.uss"));
Runtime.GetType("KernelPanic.UI.TerminalTheme").GetMethod("Attach").Invoke(null, new object[] { root });
root.Add(AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/CollectionScreen.uxml").CloneTree());
root.Q("CollectionPanel").RemoveFromClassList("hidden");
var outside = new Button { text = "outside collection" };
root.Add(outside);
var ubuntu = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Ubuntu.asset");
var arch = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Arch.asset");
var fedora = AssetDatabase.LoadAssetAtPath<DistroDefinition>("Assets/Data/Distros/Fedora.asset");
var owned = new PlayerCollection();
foreach (var unit in new[] { ubuntu, arch, fedora }) owned.Add(unit);
var screen = new CollectionScreenController();
screen.Bind(root, null, null, null, owned);
screen.RefreshUnits(new[] { ubuntu, arch, fedora });
yield return null;
yield return null;
var original = root.Q<Button>($"CollectionUnit_{arch.Id}");
Assert.That(original, Is.Not.Null);
original.Focus();
Assert.That(root.focusController.focusedElement, Is.SameAs(original));
// Move the focused unit to a different index and change its displayed version.
owned.Add(arch);
screen.RefreshUnits(new[] { fedora, ubuntu, arch });
yield return null;
yield return null;
var replacement = root.Q<Button>($"CollectionUnit_{arch.Id}");
Assert.That(replacement, Is.Not.SameAs(original));
Assert.That(root.focusController.focusedElement, Is.SameAs(replacement));
Assert.That(replacement.ClassListContains("selected"), Is.True);
// Both rebuilds happen before either scheduled restoration can execute.
screen.RefreshUnits(new[] { arch, ubuntu });
var intermediate = root.Q<Button>($"CollectionUnit_{arch.Id}");
screen.RefreshUnits(new[] { fedora, ubuntu, arch });
yield return null;
yield return null;
var finalRow = root.Q<Button>($"CollectionUnit_{arch.Id}");
Assert.That(finalRow, Is.Not.SameAs(intermediate));
Assert.That(intermediate.panel, Is.Null);
Assert.That(root.focusController.focusedElement, Is.SameAs(finalRow), "Consecutive refreshes restore into the final list.");
screen.RefreshUnits(new[] { fedora, ubuntu });
yield return null;
yield return null;
var fallback = root.Q<Button>($"CollectionUnit_{fedora.Id}");
Assert.That(root.focusController.focusedElement, Is.SameAs(fallback), "A removed unit falls back to the first available row.");
Assert.That(fallback.ClassListContains("selected"), Is.True);
screen.RefreshUnits(Array.Empty<DistroDefinition>());
yield return null;
yield return null;
Assert.That(root.focusController.focusedElement,
Is.SameAs(root.Q<ScrollView>("CollectionDetail").contentContainer), "An empty list retains focus in its content region.");
Assert.That(root.Q("CollectionEmptyTitle"), Is.Not.Null);
outside.Focus();
screen.RefreshUnits(new[] { ubuntu, arch });
yield return null;
yield return null;
Assert.That(root.focusController.focusedElement, Is.SameAs(outside), "Refreshing an unfocused collection must not steal focus.");
root.Q<Button>($"CollectionUnit_{arch.Id}").Focus();
screen.RefreshUnits(new[] { ubuntu, arch });
outside.Focus();
Assert.That(root.focusController.focusedElement, Is.SameAs(outside));
yield return null;
yield return null;
Assert.That(root.focusController.focusedElement, Is.SameAs(outside), "A newer focus choice wins over a pending restoration.");
LogAssert.NoUnexpectedReceived();
}
finally { window.Close(); }
}
[UnityTest]
public IEnumerator FocusRestorationSkipsUnavailableMatchesAndFallbacks()
{
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
Assert.Ignore("Focus restoration tests require an editor panel; run Unity without -nographics.");
var window = ScriptableObject.CreateInstance<TerminalFocusTestWindow>();
try
{
window.Show();
var root = window.rootVisualElement;
var region = new VisualElement();
root.Add(region);
var preserve = Runtime.GetType("KernelPanic.UI.TerminalTheme").GetMethod("PreserveFocus");
foreach (string state in new[] { "disabled", "hidden", "invisible", "unfocusable", "disabled ancestor", "hidden ancestor" })
{
region.Clear();
var original = new Button { name = "selected-item", text = "inspect" };
region.Add(original);
yield return null;
yield return null;
original.Focus();
Assert.That(root.focusController.focusedElement, Is.SameAs(original), state);
preserve.Invoke(null, new object[] { region });
region.Clear();
var unavailable = new VisualElement();
region.Add(unavailable);
var byName = new Button { name = "selected-item", text = "updated inspect" };
var byText = new Button { text = "inspect" };
var firstFallback = new Button { text = "unavailable fallback" };
foreach (var button in new[] { byName, byText, firstFallback })
{
unavailable.Add(button);
switch (state)
{
case "disabled": button.SetEnabled(false); break;
case "hidden": button.style.display = DisplayStyle.None; break;
case "invisible": button.style.visibility = Visibility.Hidden; break;
case "unfocusable": button.focusable = false; break;
}
}
if (state == "disabled ancestor") unavailable.SetEnabled(false);
if (state == "hidden ancestor") unavailable.style.display = DisplayStyle.None;
var fallback = new Button { text = "available fallback" };
region.Add(fallback);
yield return null;
yield return null;
Assert.That(root.focusController.focusedElement, Is.SameAs(fallback), state);
}
LogAssert.NoUnexpectedReceived();
}
finally { window.Close(); }
}
[UnityTest]
public IEnumerator ModalNavigationWrapsAndSkipsUnavailableControls()
{
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
Assert.Ignore("Modal navigation tests require an editor panel; run Unity without -nographics.");
var window = ScriptableObject.CreateInstance<TerminalFocusTestWindow>();
try
{
window.Show();
var root = window.rootVisualElement;
root.Add(new Button { text = "behind modal" });
var overlay = new VisualElement();
root.Add(overlay);
Runtime.GetType("KernelPanic.UI.TerminalTheme").GetMethod("ConstrainModalFocus")
.Invoke(null, new object[] { overlay });
var first = new Button { text = "first" };
overlay.Add(first);
var disabled = new Button { text = "disabled" };
disabled.SetEnabled(false);
overlay.Add(disabled);
var hidden = new Button { text = "hidden" };
hidden.style.display = DisplayStyle.None;
overlay.Add(hidden);
var hiddenParent = new VisualElement();
hiddenParent.style.display = DisplayStyle.None;
hiddenParent.Add(new Button { text = "hidden by parent" });
overlay.Add(hiddenParent);
var disabledParent = new VisualElement();
disabledParent.SetEnabled(false);
disabledParent.Add(new Button { text = "disabled by parent" });
overlay.Add(disabledParent);
overlay.Add(new Button { text = "excluded from tab order", tabIndex = -1 });
var input = new TextField();
overlay.Add(input);
var last = new Toggle("last");
overlay.Add(last);
int escapedEvents = 0;
root.RegisterCallback<NavigationMoveEvent>(_ => escapedEvents++);
yield return null;
yield return null;
void Move(NavigationMoveEvent.Direction direction, VisualElement expected)
{
var focused = root.focusController.focusedElement as VisualElement;
Assert.That(focused, Is.Not.Null);
using var evt = NavigationMoveEvent.GetPooled(direction);
evt.target = focused;
focused.SendEvent(evt);
var actual = root.focusController.focusedElement as VisualElement;
Assert.That(actual == expected || expected.Contains(actual), Is.True, direction.ToString());
Assert.That(escapedEvents, Is.Zero, "Modal navigation must not also reach the background screen.");
}
first.Focus();
Move(NavigationMoveEvent.Direction.Previous, last);
Move(NavigationMoveEvent.Direction.Next, first);
Move(NavigationMoveEvent.Direction.Next, input);
Move(NavigationMoveEvent.Direction.Next, last);
Move(NavigationMoveEvent.Direction.Previous, input);
Move(NavigationMoveEvent.Direction.Previous, first);
// Update eligibility while the modal is open, leaving a single tab stop.
input.SetEnabled(false);
last.style.display = DisplayStyle.None;
yield return null;
yield return null;
Move(NavigationMoveEvent.Direction.Next, first);
Move(NavigationMoveEvent.Direction.Previous, first);
LogAssert.NoUnexpectedReceived();
}
finally { window.Close(); }
}
[UnityTest]
public IEnumerator PullHistoryCloseRestoresOpenerOrAvailableFallback()
{
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
Assert.Ignore("Modal focus tests require an editor panel; run Unity without -nographics.");
var window = ScriptableObject.CreateInstance<TerminalFocusTestWindow>();
try
{
window.position = new Rect(0, 0, 900, 700);
window.Show();
var root = window.rootVisualElement;
root.styleSheets.Add(AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/UI/MainMenu.uss"));
Runtime.GetType("KernelPanic.UI.TerminalTheme").GetMethod("Attach").Invoke(null, new object[] { root });
root.Add(AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/GachaScreen.uxml").CloneTree());
root.Q("GachaPanel").RemoveFromClassList("hidden");
var screen = new GachaScreenController();
screen.Bind(root, null, null, null, new GachaService(), new PlayerCollection(), new EntropyWallet(),
null, null, () => { }, () => { }, null);
screen.Open();
var toolbar = root.Q<Button>("GachaPullHistoryButton");
yield return null;
yield return null;
foreach (string state in new[] { "available", "removed", "disabled", "hidden", "toolbar removed" })
{
var opener = state == "toolbar removed" ? toolbar : new Button { text = "open history" };
if (opener != toolbar) root.Add(opener);
yield return null;
opener.Focus();
Assert.That(root.focusController.focusedElement, Is.SameAs(opener), state);
screen.OpenPullHistory();
yield return null;
yield return null;
var overlay = root.Q("GachaPullHistoryOverlay");
var close = overlay.Q<Button>("ClosePullHistory");
Assert.That(root.focusController.focusedElement, Is.SameAs(close), "Opening history focuses its close control.");
if (state == "removed" || state == "toolbar removed") opener.RemoveFromHierarchy();
if (state == "disabled") opener.SetEnabled(false);
if (state == "hidden") opener.style.display = DisplayStyle.None;
if (state == "available" || state == "disabled")
{
using var submit = NavigationSubmitEvent.GetPooled();
submit.target = close;
close.SendEvent(submit);
}
else
{
using var escape = KeyDownEvent.GetPooled('\0', KeyCode.Escape, EventModifiers.None);
escape.target = close;
close.SendEvent(escape);
}
VisualElement expected = state == "available" ? opener : state == "toolbar removed"
? root.Q("GachaBannerList").Q<Button>(className: "selected") : toolbar;
Assert.That(overlay.ClassListContains("hidden"), Is.True, state);
Assert.That(overlay.ClassListContains("modal-open"), Is.False, state);
yield return null;
yield return null;
Assert.That(root.focusController.focusedElement, Is.SameAs(expected), state);
opener.RemoveFromHierarchy();
}
LogAssert.NoUnexpectedReceived();
}
finally { window.Close(); }
}
[UnityTest]
public IEnumerator FiveStarSelectorCloseRestoresOpenerOrAvailableFallback()
{
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
Assert.Ignore("Modal focus tests require an editor panel; run Unity without -nographics.");
var window = ScriptableObject.CreateInstance<TerminalFocusTestWindow>();
try
{
window.position = new Rect(0, 0, 900, 700);
window.Show();
var root = window.rootVisualElement;
root.styleSheets.Add(AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/UI/MainMenu.uss"));
Runtime.GetType("KernelPanic.UI.TerminalTheme").GetMethod("Attach").Invoke(null, new object[] { root });
root.Add(AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/GachaScreen.uxml").CloneTree());
root.Q("GachaPanel").RemoveFromClassList("hidden");
var service = new GachaService();
var save = SaveData.CreateDefault();
save.beginnerBannerState.totalPulls = GachaService.BeginnerMaxPulls;
save.standardBannerState.totalPulls = GachaService.StandardFiveStarSelectorInterval;
service.LoadProgress(save);
var screen = new GachaScreenController();
screen.Bind(root, null, null, null, service, new PlayerCollection(), new EntropyWallet(),
null, null, () => { }, () => { }, null);
screen.Open();
var toolbar = root.Q<Button>("GachaPullHistoryButton");
var detail = root.Q("GachaBannerDetail");
foreach (string state in new[] { "available", "removed", "disabled", "hidden", "hidden ancestor", "rebuilt", "toolbar unavailable" })
{
detail.style.display = StyleKeyword.Null;
screen.Refresh();
yield return null;
yield return null;
var opener = detail.Query<Button>().Where(button => button.text.StartsWith("claim 5")).First();
Assert.That(opener, Is.Not.Null, "A pending selector exposes its actual claim button.");
opener.Focus();
Assert.That(root.focusController.focusedElement, Is.SameAs(opener), state);
using (var submit = NavigationSubmitEvent.GetPooled())
{
submit.target = opener;
opener.SendEvent(submit);
}
yield return null;
yield return null;
var overlay = root.Q(className: "five-star-selector-overlay");
Assert.That(overlay, Is.Not.Null);
var close = overlay.Q<Button>(className: "modal-close-button");
Assert.That(root.focusController.focusedElement, Is.SameAs(close), state);
if (state == "removed" || state == "toolbar unavailable") opener.RemoveFromHierarchy();
if (state == "disabled") opener.SetEnabled(false);
if (state == "hidden") opener.style.display = DisplayStyle.None;
if (state == "hidden ancestor") detail.style.display = DisplayStyle.None;
if (state == "rebuilt")
{
screen.Refresh();
Assert.That(opener.panel, Is.Null, "Refreshing replaces the original claim button.");
}
if (state == "toolbar unavailable") toolbar.SetEnabled(false);
if (state == "available" || state == "disabled" || state == "rebuilt")
{
using var submit = NavigationSubmitEvent.GetPooled();
submit.target = close;
close.SendEvent(submit);
}
else
{
using var escape = KeyDownEvent.GetPooled('\0', KeyCode.Escape, EventModifiers.None);
escape.target = close;
close.SendEvent(escape);
}
VisualElement expected = state == "available" ? opener : state == "toolbar unavailable"
? root.Q("GachaBannerList").Q<Button>(className: "selected") : toolbar;
Assert.That(overlay.ClassListContains("hidden"), Is.True, state);
Assert.That(overlay.ClassListContains("modal-open"), Is.False, state);
yield return null;
yield return null;
Assert.That(root.focusController.focusedElement, Is.SameAs(expected), state);
Assert.That(service.PendingStandardFiveStarSelectors, Is.EqualTo(1), "Dismissing the selector must not consume its reward.");
}
LogAssert.NoUnexpectedReceived();
}
finally { window.Close(); }
}
[Test] [Test]
public void PullHistoryIsAToolbarModalAndNotABanner() public void PullHistoryIsAToolbarModalAndNotABanner()
{ {
@@ -197,8 +584,13 @@ public class TerminalUiTests
Assert.That(branches[2].Q<Label>(className: "command-text").text, Is.EqualTo("feature/nixos")); Assert.That(branches[2].Q<Label>(className: "command-text").text, Is.EqualTo("feature/nixos"));
Assert.That(bannerList.Q("GachaPullHistoryButton"), Is.Null); Assert.That(bannerList.Q("GachaPullHistoryButton"), Is.Null);
Assert.That(root.Q<Button>("GachaPullHistoryButton"), Is.Not.Null); Assert.That(root.Q<Button>("GachaPullHistoryButton"), Is.Not.Null);
Assert.That(root.Q("GachaBannerDetail").Query<Label>(className: "gacha-detail-title").ToList(), Is.Empty, var detail = root.Q("GachaBannerDetail");
"The selected branch already identifies the banner; the detail pane should not repeat its title."); Assert.That(detail.Q<Label>("GachaActiveCommand").text, Is.EqualTo("$ git checkout beginner"));
Assert.That(detail.Q<Label>("GachaActiveTitle").text, Is.EqualTo("beginner install media"));
Assert.That(detail.Query(className: "gacha-progress-metric").ToList().Count, Is.EqualTo(3));
Assert.That(detail.Q<Button>("GachaPullSingleButton"), Is.Not.Null);
Assert.That(detail.Q<Button>("GachaPullTenButton"), Is.Not.Null);
Assert.That(root.Q<Button>("GachaPullHistoryButton").text, Does.Contain("git log --pulls").And.Contain("0 saved"));
screen.OpenPullHistory(); screen.OpenPullHistory();
var overlay = root.Q("GachaPullHistoryOverlay"); var overlay = root.Q("GachaPullHistoryOverlay");
@@ -212,6 +604,144 @@ public class TerminalUiTests
"Opening history must not replace the selected banner."); "Opening history must not replace the selected banner.");
} }
[Test]
public void ExhaustedBeginnerBannerOpensOnStableBranch()
{
var root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/MainMenu.uxml").CloneTree();
var service = new GachaService();
var save = SaveData.CreateDefault();
save.beginnerBannerState.totalPulls = GachaService.BeginnerMaxPulls;
save.beginnerBannerState.exhausted = true;
service.LoadProgress(save);
var screen = new GachaScreenController();
screen.Bind(root, null, null, null, service, new PlayerCollection(), new EntropyWallet(),
null, null, () => { }, () => { }, null);
screen.Open();
var selected = root.Q("GachaBannerList").Q<Button>(className: "selected");
Assert.That(selected.Q<Label>(className: "command-text").text, Is.EqualTo("stable"));
Assert.That(root.Q<Label>("GachaActiveCommand").text, Is.EqualTo("$ git checkout stable"));
Assert.That(root.Q<Label>("GachaActiveTitle").text, Is.EqualTo("stable branch"));
Assert.That(root.Q<Label>("GachaBannerStatus_beginner").text, Does.StartWith("closed"));
}
[UnityTest]
public IEnumerator LimitedBannerHeroSpotlightsOnlyNixOS()
{
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
Assert.Ignore("Pointer and focus tests require an editor panel; run Unity without -nographics.");
var window = ScriptableObject.CreateInstance<TerminalFocusTestWindow>();
try
{
window.position = new Rect(0, 0, 800, 700);
window.Show();
var root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/MainMenu.uxml").CloneTree();
var database = AssetDatabase.LoadAssetAtPath<DistroDatabase>("Assets/Data/Distros/DistroDatabase.asset");
var collection = new PlayerCollection();
DistroDefinition opened = null;
var screen = new GachaScreenController();
screen.Bind(root, database, null, null, new GachaService(), collection, new EntropyWallet(),
null, null, () => { }, () => { }, null, distro => opened = distro);
screen.Open();
typeof(GachaScreenController).GetMethod("SelectBanner", Private).Invoke(screen, new object[] { 2 });
var hero = root.Q("GachaBannerDetail").Q(className: "gacha-hero");
// Mount only the detail panel; the full menu contains hidden screen slots.
window.rootVisualElement.Add(root.Q("GachaBannerDetail"));
var other = new Button { text = "other focus target" };
window.rootVisualElement.Add(other);
yield return null;
yield return null;
var cards = hero.Query(className: "gacha-art-card").ToList();
Assert.That(hero.ClassListContains("gacha-hero-single"), Is.True);
Assert.That(cards.Count, Is.EqualTo(1));
Assert.That(cards[0], Is.TypeOf<Button>());
Assert.That(cards[0].focusable, Is.True);
var ownership = cards[0].Q<Label>(className: "gacha-art-ownership");
var inspect = cards[0].Q<Label>(className: "gacha-art-inspect");
Assert.That(ownership.text, Is.EqualTo("NixOS · not installed"));
Assert.That(ownership.ClassListContains("hidden"), Is.False);
Assert.That(inspect.text, Is.EqualTo("[enter] cat /etc/distros/nixos.conf"));
Assert.That(inspect.ClassListContains("hidden"), Is.True);
using (var hover = PointerEnterEvent.GetPooled())
{
hover.target = cards[0];
cards[0].SendEvent(hover);
}
Assert.That(ownership.ClassListContains("hidden"), Is.True);
Assert.That(inspect.ClassListContains("hidden"), Is.False);
using (var leave = PointerLeaveEvent.GetPooled())
{
leave.target = cards[0];
cards[0].SendEvent(leave);
}
Assert.That(ownership.ClassListContains("hidden"), Is.False);
Assert.That(inspect.ClassListContains("hidden"), Is.True);
cards[0].Focus();
yield return null;
Assert.That(window.rootVisualElement.focusController.focusedElement, Is.SameAs(cards[0]));
Assert.That(ownership.ClassListContains("hidden"), Is.True);
Assert.That(inspect.ClassListContains("hidden"), Is.False);
using (var leave = PointerLeaveEvent.GetPooled())
{
leave.target = cards[0];
cards[0].SendEvent(leave);
}
Assert.That(inspect.ClassListContains("hidden"), Is.False, "Keyboard focus keeps the inspect cue visible after pointer exit.");
using (var submit = NavigationSubmitEvent.GetPooled())
{
submit.target = cards[0];
cards[0].SendEvent(submit);
}
Assert.That(opened?.Id, Is.EqualTo("nixos"));
other.Focus();
yield return null;
Assert.That(ownership.ClassListContains("hidden"), Is.False);
Assert.That(inspect.ClassListContains("hidden"), Is.True);
collection.Add(database.FindById("nixos"), 3);
screen.Refresh();
ownership = window.rootVisualElement.Q("GachaBannerDetail").Q<Label>(className: "gacha-art-ownership");
Assert.That(ownership.text, Is.EqualTo("NixOS · installed v3/5"));
LogAssert.NoUnexpectedReceived();
}
finally { window.Close(); }
}
[Test]
public void PullButtonsExplainReadinessAndKeepOddsCollapsed()
{
var root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/MainMenu.uxml").CloneTree();
var database = AssetDatabase.LoadAssetAtPath<DistroDatabase>("Assets/Data/Distros/DistroDatabase.asset");
var service = new GachaService();
foreach (var distro in database.AllDistros) service.AddToBannerPool(distro);
var wallet = new EntropyWallet();
wallet.SetBalance(89);
var screen = new GachaScreenController();
screen.Bind(root, database, null, null, service, new PlayerCollection(), wallet,
null, null, () => { }, () => { }, null);
screen.Open();
var single = root.Q<Button>("GachaPullSingleButton");
var odds = root.Q<Foldout>("GachaOddsInspector");
Assert.That(single.enabledSelf, Is.False);
Assert.That(single.text, Does.Contain("blocked · 11 Entropy short"));
Assert.That(odds.value, Is.False);
Assert.That(odds.Q<Label>(className: "gacha-odds-copy").text, Does.Contain("5★ base 0.8%"));
Assert.That(root.Q(className: "gacha-payment-note"), Is.Null);
wallet.SetBalance(100);
screen.Refresh();
single = root.Q<Button>("GachaPullSingleButton");
Assert.That(single.enabledSelf, Is.True);
Assert.That(single.text, Does.Contain("ready · confirm 100 Entropy"));
}
[Test] [Test]
public void UnitIdentityAndTabsSurviveAllFourDetailViews() public void UnitIdentityAndTabsSurviveAllFourDetailViews()
{ {
@@ -240,6 +770,30 @@ public class TerminalUiTests
Assert.That(root.Q("CollectionContextHeader").ClassListContains("hidden"), Is.True); Assert.That(root.Q("CollectionContextHeader").ClassListContains("hidden"), Is.True);
} }
[Test]
public void BannerDistroDetailIsAReadOnlyOverview()
{
var root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/UI/MainMenu.uxml").CloneTree();
var database = AssetDatabase.LoadAssetAtPath<DistroDatabase>("Assets/Data/Distros/DistroDatabase.asset");
var unit = database.FindById("nixos");
var owned = new PlayerCollection();
var screen = new CollectionScreenController();
screen.Bind(root, null, null, null, owned, packageLoadout: new PackageLoadout(owned, null));
screen.RefreshUnits(new[] { unit });
screen.ShowUnitDetail(unit, false, true);
Assert.That(screen.IsUnitDetail, Is.True);
Assert.That(screen.CurrentHint, Is.EqualTo("[esc] back"));
Assert.That(root.Q(className: "unit-detail-header"), Is.Not.Null);
Assert.That(root.Q(className: "unit-detail-tabs"), Is.Null);
Assert.That(root.Q(className: "unit-identity-section"), Is.Not.Null);
screen.SwitchUnitDetailTabRelative(1);
Assert.That(root.Q(className: "unit-detail-tabs"), Is.Null);
Assert.That(root.Q(className: "unit-identity-section"), Is.Not.Null);
}
[Test] [Test]
public void UnitOverviewListsEquippedPackageLoadout() public void UnitOverviewListsEquippedPackageLoadout()
{ {
@@ -484,6 +1038,118 @@ public class TerminalUiTests
Assert.That(input.value, Is.EqualTo("./start_run")); Assert.That(input.value, Is.EqualTo("./start_run"));
} }
[Test]
public void HistoryBoundariesPreserveFreshDraftsAndClampNavigation()
{
var root = new VisualElement();
var input = new TextField { name = "CommandInput" };
root.Add(input);
root.Add(new Label { name = "CommandOutput" });
var type = Runtime.GetType("KernelPanic.UI.TerminalCommandLine");
var line = Activator.CreateInstance(type, root, (Action<int>)(_ => { }), (Func<bool>)(() => true));
input.value = "fresh draft";
foreach (var key in new[] { KeyCode.DownArrow, KeyCode.DownArrow, KeyCode.UpArrow, KeyCode.UpArrow, KeyCode.DownArrow })
{
Send(type, line, key);
Assert.That(input.value, Is.EqualTo("fresh draft"), "Empty history must preserve input.");
}
foreach (var command in new[] { "./start_run", "ls ~/collection" })
{
input.value = command;
Send(type, line, KeyCode.Return);
}
input.value = "new draft";
Send(type, line, KeyCode.DownArrow);
Assert.That(input.value, Is.EqualTo("new draft"));
Send(type, line, KeyCode.UpArrow);
Assert.That(input.value, Is.EqualTo("ls ~/collection"));
for (int i = 0; i < 3; i++)
{
Send(type, line, KeyCode.UpArrow);
Assert.That(input.value, Is.EqualTo("./start_run"), "Up clamps at the oldest entry.");
}
Send(type, line, KeyCode.DownArrow);
Assert.That(input.value, Is.EqualTo("ls ~/collection"));
Send(type, line, KeyCode.DownArrow);
Assert.That(input.value, Is.EqualTo("new draft"));
input.value = "edited draft";
for (int i = 0; i < 3; i++)
{
Send(type, line, KeyCode.DownArrow);
Assert.That(input.value, Is.EqualTo("edited draft"), "Down at the newest entry must not restore a stale draft.");
}
Send(type, line, KeyCode.UpArrow);
Send(type, line, KeyCode.DownArrow);
Assert.That(input.value, Is.EqualTo("edited draft"));
}
[UnityTest]
public IEnumerator CommandKeysRouteThroughFocusedInputWithoutAlsoActivatingMenu()
{
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
Assert.Ignore("Keyboard routing tests require an editor panel; run Unity without -nographics.");
var window = ScriptableObject.CreateInstance<TerminalFocusTestWindow>();
try
{
window.Show();
var root = window.rootVisualElement;
var input = new TextField { name = "CommandInput" };
var output = new Label { name = "CommandOutput" };
root.Add(input);
root.Add(output);
int activations = 0, activated = -1, menuKeys = 0;
bool available = true;
Activator.CreateInstance(Runtime.GetType("KernelPanic.UI.TerminalCommandLine"), root,
(Action<int>)(index => { activations++; activated = index; }), (Func<bool>)(() => available));
root.RegisterCallback<KeyDownEvent>(_ => menuKeys++);
yield return null;
void Key(KeyCode key)
{
var focused = root.focusController.focusedElement as VisualElement;
Assert.That(focused == input || input.Contains(focused), Is.True, "Dispatch through the focused text editor.");
using var evt = KeyDownEvent.GetPooled('\0', key, EventModifiers.None);
evt.target = focused;
focused.SendEvent(evt);
}
foreach (var enter in new[] { KeyCode.Return, KeyCode.KeypadEnter })
{
input.Focus();
input.value = "./st";
Key(KeyCode.Tab);
Assert.That(input.value, Is.EqualTo("./start_run"));
int before = activations;
Key(enter);
Assert.That(activations, Is.EqualTo(before + 1));
Assert.That(activated, Is.Zero);
Assert.That(input.value, Is.Empty);
}
input.Focus();
input.value = "draft";
Key(KeyCode.UpArrow);
Assert.That(input.value, Is.EqualTo("./start_run"));
Key(KeyCode.DownArrow);
Assert.That(input.value, Is.EqualTo("draft"));
Key(KeyCode.Escape);
Assert.That(input.value, Is.Empty);
Assert.That(menuKeys, Is.Zero, "Handled command keys must not bubble into menu shortcuts.");
available = false;
input.Focus();
input.value = "ls ~/collection";
string previousOutput = output.text;
foreach (var enter in new[] { KeyCode.Return, KeyCode.KeypadEnter }) Key(enter);
Assert.That(activations, Is.EqualTo(2), "Unavailable commands must not activate.");
Assert.That(input.value, Is.EqualTo("ls ~/collection"));
Assert.That(output.text, Is.EqualTo(previousOutput));
LogAssert.NoUnexpectedReceived();
}
finally { window.Close(); }
}
private static void Send(Type type, object line, KeyCode key) private static void Send(Type type, object line, KeyCode key)
{ {
using var evt = KeyDownEvent.GetPooled('\0', key, EventModifiers.None); using var evt = KeyDownEvent.GetPooled('\0', key, EventModifiers.None);
+2 -1
View File
@@ -7,7 +7,8 @@
<ui:VisualElement class="screen-frame-content"> <ui:VisualElement class="screen-frame-content">
<ui:VisualElement name="GachaContent" class="gacha-content"> <ui:VisualElement name="GachaContent" class="gacha-content">
<ui:VisualElement class="gacha-toolbar"> <ui:VisualElement class="gacha-toolbar">
<ui:Button name="GachaPullHistoryButton" text="git log --pulls&#10;0 saved" class="terminal-button gacha-history-button" /> <ui:Label text="origin/kernel-panic · refs/remotes" class="gacha-toolbar-context" />
<ui:Button name="GachaPullHistoryButton" text="git log --pulls · 0 saved" class="terminal-button gacha-history-button" />
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement class="gacha-shell"> <ui:VisualElement class="gacha-shell">
<ui:VisualElement name="GachaBannerList" class="gacha-banner-list" /> <ui:VisualElement name="GachaBannerList" class="gacha-banner-list" />
+218 -10
View File
@@ -541,17 +541,25 @@ Button {
.gacha-toolbar { .gacha-toolbar {
flex-direction: row; flex-direction: row;
justify-content: flex-end; justify-content: space-between;
align-items: center;
flex-shrink: 0; flex-shrink: 0;
min-height: 38px; min-height: 38px;
margin-bottom: 8px; margin-bottom: 8px;
} }
.gacha-toolbar-context {
color: var(--kp-primary-dim);
font-size: var(--type-meta);
white-space: normal;
}
.gacha-history-button { .gacha-history-button {
width: 220px; width: auto;
min-width: 220px;
min-height: 38px; min-height: 38px;
margin: 0; margin: 0;
white-space: normal; white-space: nowrap;
} }
.gacha-shell { .gacha-shell {
@@ -600,6 +608,55 @@ Button {
padding: 16px; padding: 16px;
} }
.gacha-active-header {
flex-direction: row;
align-items: center;
justify-content: space-between;
min-width: 0;
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom-width: 1px;
border-bottom-color: var(--kp-border);
}
.gacha-active-copy {
flex-grow: 1;
flex-shrink: 1;
min-width: 0;
}
.gacha-active-command {
color: var(--kp-cyan);
font-size: var(--type-meta);
white-space: normal;
margin-bottom: 3px;
}
.gacha-active-title {
color: var(--kp-text);
font-size: var(--type-title);
-unity-font-style: bold;
white-space: normal;
}
.gacha-active-status {
flex-shrink: 0;
margin-left: 16px;
padding: 4px 8px;
color: var(--kp-success);
background-color: var(--kp-bg-deep);
border-bottom-width: 1px;
border-bottom-color: var(--kp-success);
font-size: var(--type-meta);
-unity-font-style: bold;
white-space: nowrap;
}
.gacha-active-status.warning {
color: var(--kp-muted);
border-bottom-color: var(--kp-muted);
}
.gacha-banner-detail .kv-value { .gacha-banner-detail .kv-value {
max-width: none; max-width: none;
min-width: 0; min-width: 0;
@@ -655,9 +712,9 @@ Button {
} }
.gacha-hero { .gacha-hero {
height: 230px; height: 146px;
margin-bottom: 12px; margin-bottom: 12px;
padding: 10px; padding: 6px 10px;
border-left-width: 1px; border-left-width: 1px;
border-right-width: 1px; border-right-width: 1px;
border-top-width: 1px; border-top-width: 1px;
@@ -675,6 +732,17 @@ Button {
flex-direction: row; flex-direction: row;
} }
.gacha-hero-single .gacha-hero-art-row {
justify-content: center;
}
.gacha-hero-single .gacha-art-card {
width: 320px;
max-width: 320px;
flex-grow: 0;
margin-right: 0;
}
.gacha-art-card { .gacha-art-card {
flex-grow: 1; flex-grow: 1;
min-width: 0; min-width: 0;
@@ -682,10 +750,26 @@ Button {
align-items: center; align-items: center;
} }
.gacha-art-button {
padding: 0;
border-left-width: 0;
border-right-width: 0;
border-top-width: 0;
border-bottom-width: 1px;
border-bottom-color: transparent;
background-color: transparent;
}
.gacha-art-button:hover,
.gacha-art-button:focus {
border-bottom-color: var(--kp-cyan);
background-color: var(--kp-hover);
}
.gacha-art-shell { .gacha-art-shell {
flex-grow: 1; flex-grow: 1;
min-height: 0; min-height: 0;
height: 165px; height: 104px;
width: 100%; width: 100%;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@@ -696,14 +780,14 @@ Button {
.gacha-ascii-art { .gacha-ascii-art {
width: 100%; width: 100%;
min-width: 0; min-width: 0;
height: 165px; height: 104px;
font-size: 14px; font-size: 11px;
} }
.gacha-art-card .ascii-placeholder, .gacha-art-card .ascii-placeholder,
.gacha-ascii-placeholder { .gacha-ascii-placeholder {
width: 150px; width: 104px;
height: 155px; height: 98px;
} }
.gacha-art-name { .gacha-art-name {
@@ -713,6 +797,23 @@ Button {
-unity-text-align: middle-center; -unity-text-align: middle-center;
} }
.gacha-art-cue {
width: 100%;
min-height: 22px;
align-items: center;
justify-content: center;
}
.gacha-art-ownership {
white-space: nowrap;
}
.gacha-art-inspect {
color: var(--kp-cyan);
font-size: 12px;
white-space: nowrap;
}
.gacha-hero-title { .gacha-hero-title {
color: var(--kp-muted); color: var(--kp-muted);
font-size: 14px; font-size: 14px;
@@ -720,6 +821,101 @@ Button {
-unity-text-align: middle-center; -unity-text-align: middle-center;
} }
.gacha-counter-grid {
flex-direction: row;
flex-wrap: wrap;
align-items: stretch;
margin: 0 0 10px;
}
.gacha-progress-metric {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 150px;
min-width: 135px;
margin: 0 8px 8px 0;
padding: 9px 10px;
background-color: var(--kp-bg-deep);
border-left-width: 2px;
border-left-color: var(--kp-border-strong);
}
.gacha-progress-metric.complete {
border-left-color: var(--kp-success);
}
.gacha-progress-label {
color: var(--kp-primary-dim);
font-size: var(--type-meta);
white-space: normal;
}
.gacha-progress-value {
color: var(--kp-text);
font-size: var(--type-section);
-unity-font-style: bold;
white-space: normal;
margin: 2px 0 5px;
}
.gacha-progress-track {
width: 100%;
height: 3px;
margin-bottom: 6px;
background-color: var(--kp-border);
}
.gacha-progress-fill {
height: 3px;
background-color: var(--kp-cyan);
}
.gacha-progress-metric.complete .gacha-progress-fill {
background-color: var(--kp-success);
}
.gacha-progress-detail {
color: var(--kp-muted);
font-size: var(--type-meta);
white-space: normal;
}
.gacha-pull-panel {
margin: 2px 0 10px;
padding: 10px 12px 8px;
background-color: var(--kp-panel);
border-top-width: 1px;
border-bottom-width: 1px;
border-top-color: var(--kp-border-strong);
border-bottom-color: var(--kp-border);
}
.gacha-pull-heading {
color: var(--kp-cyan);
font-size: var(--type-meta);
-unity-font-style: bold;
margin-bottom: 5px;
}
.gacha-pull-unavailable {
color: var(--kp-muted);
white-space: normal;
padding: 8px 0;
}
.gacha-odds {
margin-top: 4px;
color: var(--kp-muted);
font-size: var(--type-meta);
}
.gacha-odds-copy {
margin: 5px 0 2px 18px;
color: var(--kp-primary-dim);
font-size: var(--type-meta);
white-space: normal;
}
.gacha-rules { .gacha-rules {
color: var(--kp-muted); color: var(--kp-muted);
white-space: normal; white-space: normal;
@@ -744,6 +940,18 @@ Button {
-unity-text-align: middle-center; -unity-text-align: middle-center;
} }
.gacha-action-primary {
border-color: var(--kp-amber);
color: var(--kp-amber);
background-color: var(--kp-hover);
}
.gacha-action-secondary {
border-color: var(--kp-border-strong);
color: var(--kp-cyan);
background-color: transparent;
}
.gacha-result { .gacha-result {
color: var(--kp-amber); color: var(--kp-amber);
white-space: normal; white-space: normal;