Add NixOS and Go
This commit is contained in:
@@ -63,6 +63,13 @@ namespace KernelPanic.UI
|
||||
private PackageSlot? _packageInventoryFilter;
|
||||
|
||||
public event Action ViewChanged;
|
||||
public event Action<Language> LanguageTrainingRequested;
|
||||
|
||||
public void ShowLanguage(Language language)
|
||||
{
|
||||
_selectedLanguageIndex = _languages.ToList().FindIndex(entry => entry.Language == language);
|
||||
ShowLanguages();
|
||||
}
|
||||
|
||||
public void Bind(VisualElement root, FontAsset artFont, LanguageDeckDatabase deckDatabase, CardDatabase cardsDatabase, PlayerCollection collection, Func<DistroDefinition, int> getMergesBalance = null, Func<DistroDefinition, VersionUpgradeResult> tryUpgradeUnit = null, PackageDatabase packageDatabase = null, PackageLoadout packageLoadout = null, Action packageLoadoutChanged = null, Func<SaveData> getSaveData = null, Func<OwnedPackageInstance, PackageUpgradeResult> tryUpgradePackage = null, Func<OwnedPackageInstance, PackageScrapResult> tryScrapPackage = null)
|
||||
{
|
||||
@@ -1699,6 +1706,18 @@ namespace KernelPanic.UI
|
||||
}
|
||||
|
||||
_detail.Add(BuildSubviewCommand($"cat ~/lang/{GetLanguageId(language.Language)}/deck", "starter deck", true, () => OpenLanguageDeck(language), null));
|
||||
if (LanguageTraining.IsSupported(language.Language))
|
||||
{
|
||||
var learn = new Button(() =>
|
||||
{
|
||||
if (LanguageUnlock.IsUnlocked(language.Language, _playerCollection))
|
||||
LanguageTrainingRequested?.Invoke(language.Language);
|
||||
}) { name = "LearnLanguageButton", text = "Learn more / practice fight" };
|
||||
learn.AddToClassList("terminal-button");
|
||||
_detail.Add(learn);
|
||||
_detail.Add(TerminalLayout.BodyText("Learn the basics by playing a guided fight. You can retry or leave without changing your saved campaign."));
|
||||
}
|
||||
else _detail.Add(TerminalLayout.BodyText("Practice fight unavailable: this language's playable cards are still planned."));
|
||||
}
|
||||
|
||||
private void OpenUnitCards(DistroDefinition unit)
|
||||
@@ -1908,7 +1927,7 @@ namespace KernelPanic.UI
|
||||
return row;
|
||||
}
|
||||
|
||||
private static void AddPassiveDetails(VisualElement target, DistroDefinition unit)
|
||||
private void AddPassiveDetails(VisualElement target, DistroDefinition unit)
|
||||
{
|
||||
if (unit.Passive == null)
|
||||
{
|
||||
@@ -1918,6 +1937,17 @@ namespace KernelPanic.UI
|
||||
VisualElement passive = TerminalLayout.Section(unit.Passive.Name,
|
||||
sectionClass: "unit-info-section unit-passive-section", headingClass: "detail-section-title");
|
||||
Label passiveRules = TerminalLayout.BodyText(unit.Passive.RulesText, className: "collection-detail-description");
|
||||
if (unit.Id == "nixos")
|
||||
{
|
||||
var policy = new NixGovernorState(); policy.BeginWave(GetUnitVersion(unit));
|
||||
passiveRules.name = "NixCurrentPolicy";
|
||||
passiveRules.text = "Start each wave in schedutil. Switch once per player turn.\n"
|
||||
+ string.Join("\n", Enum.GetValues(typeof(NixGovernor)).Cast<NixGovernor>().Select(governor =>
|
||||
$"{governor.ToString().ToLowerInvariant()}: {policy.DamageFor(governor)-100:+0;-0;0}% card damage / {policy.ShieldFor(governor)-100:+0;-0;0}% card Shield"))
|
||||
+ (policy.Version >= 3 ? "\nFirst successful switch each wave is free; later switches cost 1 Cycle." : "\nSwitch cost: 1 Cycle.")
|
||||
+ "\nModifiers apply when card effects resolve."
|
||||
+ (policy.Version >= 5 ? "\nSpecialisation on switch: performance deals 5 damage, powersave grants 6 Shield, schedutil draws 1. These bonuses are unscaled." : "");
|
||||
}
|
||||
passive.Add(passiveRules);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(unit.Passive.FlavorText))
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace KernelPanic.UI
|
||||
[RequireComponent(typeof(UIDocument))]
|
||||
[RequireComponent(typeof(RunManager))]
|
||||
[RequireComponent(typeof(CombatManager))]
|
||||
public sealed class CombatSceneController : MonoBehaviour
|
||||
public sealed partial class CombatSceneController : MonoBehaviour
|
||||
{
|
||||
private const string StyleResourcePath = "CombatScene";
|
||||
private const string SharedScrollbarStyleResourcePath = "TerminalScrollbars";
|
||||
@@ -300,6 +300,10 @@ namespace KernelPanic.UI
|
||||
|
||||
private void HandleKeyDown(KeyDownEvent evt)
|
||||
{
|
||||
if (_tutorial?.IsLanguageTraining == true && evt.keyCode == KeyCode.Escape)
|
||||
{ _tutorial.ExitLanguageTraining(); evt.StopPropagation(); return; }
|
||||
if (evt.keyCode == KeyCode.Escape && _combatManager.PendingGoroutineCard != null)
|
||||
{ _combatManager.CancelGoroutineSelection(); evt.StopPropagation(); return; }
|
||||
if (_tutorial?.Guide.Active == true)
|
||||
{
|
||||
if (evt.keyCode == KeyCode.E && _tutorial.Guide.CanEndTurn) _combatManager.EndPlayerTurn();
|
||||
@@ -495,6 +499,7 @@ namespace KernelPanic.UI
|
||||
_schedulerActivity.AddToClassList("scheduler-activity");
|
||||
_schedulerActivity.text = "No operations dispatched.";
|
||||
scheduler.Add(schedulerHeader);
|
||||
BuildGoScheduler(scheduler);
|
||||
_interpreterStrip = AddTrackZone(scheduler, "queue / FIFO", "Interpreter: resolves in order during the interpret phase", "track-zone-queue");
|
||||
_lazyStackPile = AddTrackZone(scheduler, "stack / LIFO", "After FIFO: newest first. Captured multiplier scales damage and explicit Shield only.", "track-zone-stack");
|
||||
_interpreterStrip.name = "TutorialQueue";
|
||||
@@ -779,8 +784,10 @@ namespace KernelPanic.UI
|
||||
: "Endless mode";
|
||||
if (config?.IsTutorial == true)
|
||||
{
|
||||
_waveLabel.text = $"training {config.TutorialLesson}/{TutorialCampaign.LessonCount}";
|
||||
_waveLabel.tooltip = "Clear both training waves for a one-time Bandwidth and Entropy reward.";
|
||||
_waveLabel.text = config.IsLanguageTraining ? $"{config.TrainingLanguage} practice"
|
||||
: $"training {config.TutorialLesson}/{TutorialCampaign.LessonCount}";
|
||||
_waveLabel.tooltip = config.IsLanguageTraining ? "Optional practice with loan cards. Exit any time; campaign progress is unchanged."
|
||||
: "Clear all three training waves for a one-time Bandwidth and Entropy reward.";
|
||||
}
|
||||
_phaseLabel.text = PhaseText(_combatManager.CurrentPhase);
|
||||
_bitsLabel.text = _runManager.Bits.ToString();
|
||||
@@ -828,6 +835,7 @@ namespace KernelPanic.UI
|
||||
}
|
||||
|
||||
_playerPanel.Add(StatusBlock(state, true));
|
||||
RefreshGovernorPanel();
|
||||
|
||||
var compilation = _combatManager.Compilation;
|
||||
if (compilation.Active)
|
||||
@@ -880,6 +888,7 @@ namespace KernelPanic.UI
|
||||
|
||||
private void RefreshTracks()
|
||||
{
|
||||
RefreshGoScheduler();
|
||||
_queueView.Sync(_combatManager.InterpreterQueue.Cards);
|
||||
_stackView.Sync(_combatManager.LazyStack.Cards);
|
||||
_stackView.SyncMultipliers(_combatManager.LazyStack.Entries);
|
||||
@@ -903,7 +912,8 @@ namespace KernelPanic.UI
|
||||
((VisualElement)_tokenArea.userData).EnableInClassList("track-idle", _combatManager.Python.AutomationCount == 0);
|
||||
_root.Q(className: "scheduler").EnableInClassList("scheduler-idle",
|
||||
_combatManager.InterpreterQueue.Count == 0 && _combatManager.LazyStack.Count == 0
|
||||
&& _combatManager.Python.AutomationCount == 0 && _combatManager.Python.RepeatCount == 0 && _combatManager.Python.AreaCount == 0);
|
||||
&& _combatManager.Python.AutomationCount == 0 && _combatManager.Python.RepeatCount == 0 && _combatManager.Python.AreaCount == 0
|
||||
&& _combatManager.Go.Count == 0);
|
||||
((VisualElement)_interpreterStrip.userData).EnableInClassList("track-resolving", _combatManager.CurrentPhase == TurnPhase.Interpret);
|
||||
}
|
||||
|
||||
@@ -1150,9 +1160,11 @@ namespace KernelPanic.UI
|
||||
? $"[!] RECOVER {card.CorruptionRoundsRemaining} ROUNDS" : "[!] CORRUPTED") : card.IsLocked ? $"[L] UNLOCK {EnemyArchetypeCatalog.DrmUnlockCycleCost}c"
|
||||
: card.Definition.IsToken ? "TOKEN / NOT EXECUTABLE"
|
||||
: GetDisplayCardCost(card) > _combatManager.PlayerState.Cycles ? $"NEEDS {GetDisplayCardCost(card)} CYCLES"
|
||||
: _combatManager.PendingTargetCard == card ? "> SELECT TARGET" : "";
|
||||
: _combatManager.PendingGoroutineCard == card ? "> SELECT GOROUTINE"
|
||||
: _combatManager.GoPlayBlockReason(card) ?? (_combatManager.PendingTargetCard == card ? "> SELECT TARGET" : "");
|
||||
if (!string.IsNullOrEmpty(reason)) { stateLabel.text = reason; face.tooltip += "\n" + reason; }
|
||||
face.SetEnabled(!_combatManager.RunFinished && _combatManager.CurrentPhase == TurnPhase.Execute && !card.IsBroken
|
||||
&& _combatManager.GoPlayBlockReason(card) == null
|
||||
&& _combatManager.TutorialGuide?.AllowsCard(card) != false);
|
||||
_handCardElements[card] = face;
|
||||
if (added) PlayElementBeat(face, "hand-card-drawn", 180);
|
||||
@@ -1255,6 +1267,15 @@ namespace KernelPanic.UI
|
||||
|
||||
private void RefreshSurrenderCommand()
|
||||
{
|
||||
if (_tutorial?.IsLanguageTraining == true)
|
||||
{
|
||||
_surrenderConfirming = false;
|
||||
_surrenderButton.text = "[Esc] Exit training";
|
||||
_surrenderButton.SetEnabled(true);
|
||||
_surrenderConfirmLabel.AddToClassList("hidden");
|
||||
_surrenderCancelButton.AddToClassList("hidden");
|
||||
return;
|
||||
}
|
||||
bool canSurrender = _combatManager.CanSurrenderRun;
|
||||
if (!canSurrender)
|
||||
{
|
||||
@@ -1278,6 +1299,7 @@ namespace KernelPanic.UI
|
||||
|
||||
private void HandleSurrenderClicked()
|
||||
{
|
||||
if (_tutorial?.IsLanguageTraining == true) { _tutorial.ExitLanguageTraining(); return; }
|
||||
if (!_combatManager.CanSurrenderRun)
|
||||
{
|
||||
_surrenderConfirming = false;
|
||||
@@ -2012,14 +2034,23 @@ namespace KernelPanic.UI
|
||||
var preview = CardPreviewService.Build(_combatManager, card);
|
||||
if (!string.IsNullOrEmpty(preview.Summary) && !preview.Summary.StartsWith("Utility", StringComparison.Ordinal))
|
||||
{
|
||||
string timing = card.Definition.ResolutionTrack == ResolutionTrack.Native ? "now: " : "preview: ";
|
||||
var label = SoftwareCardView.Text(timing + preview.Summary + (preview.IsConditional ? " *" : ""), "software-live-preview");
|
||||
target.Q(className: "software-body")?.Add(label);
|
||||
bool python = card.Definition.Language == Language.Python;
|
||||
var label = SoftwareCardView.Text(preview.Summary, "software-live-preview");
|
||||
label.tooltip = preview.Details;
|
||||
var body = target.Q(className: "software-body");
|
||||
if (python) body?.Insert(1, label);
|
||||
else body?.Add(label);
|
||||
if (!string.IsNullOrEmpty(preview.CriticalSummary) && body != null)
|
||||
{
|
||||
var crit = SoftwareCardView.Text(preview.CriticalSummary, "software-live-crit");
|
||||
crit.tooltip = preview.Details;
|
||||
body.Insert(body.IndexOf(label) + 1, crit);
|
||||
}
|
||||
}
|
||||
// Rules are already printed on the card. Keep hover help contextual and brief.
|
||||
target.tooltip = card.IsBroken ? CardPreviewService.CorruptionDetails(card)
|
||||
: card.IsLocked ? "Unlock for 1 Cycle before playing."
|
||||
: preview.IsConditional ? "Current estimate; targets, defenses and later effects can change the result."
|
||||
: preview.IsConditional ? "Based on the current setup. Targets, defenses and later effects can change the result."
|
||||
: "";
|
||||
}
|
||||
|
||||
@@ -2425,6 +2456,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
ResolutionTrack.InterpreterQueue => _interpreterStrip,
|
||||
ResolutionTrack.LazyStack => _lazyStackPile,
|
||||
ResolutionTrack.Goroutine => _goScheduler,
|
||||
_ => FirstTargetElement(payload.Card)
|
||||
};
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
ResolutionTrack.InterpreterQueue => name + " queued / oldest first.",
|
||||
ResolutionTrack.LazyStack => name + " stacked / newest first.",
|
||||
ResolutionTrack.Goroutine => name + " deployed / first tick next round.",
|
||||
_ => name + " / executes now."
|
||||
};
|
||||
_instruction.text = "Spend any remaining Cycles, then press [E] End turn. Shield absorbs incoming damage.";
|
||||
@@ -107,7 +108,8 @@ namespace KernelPanic.UI
|
||||
public void CardResolved(string name, ResolutionTrack track)
|
||||
{
|
||||
if (!Visible || _completed) return;
|
||||
_receipt.text = name + " resolved" + (track == ResolutionTrack.Native ? " immediately." : track == ResolutionTrack.InterpreterQueue ? " from the front of the queue." : " from the top of the stack.");
|
||||
_receipt.text = track == ResolutionTrack.Goroutine ? name + " deployed; ticking starts next round."
|
||||
: name + " resolved" + (track == ResolutionTrack.Native ? " immediately." : track == ResolutionTrack.InterpreterQueue ? " from the front of the queue." : " from the top of the stack.");
|
||||
}
|
||||
|
||||
public void PhaseChanged(TurnPhase phase)
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace KernelPanic.UI
|
||||
for (int i = 0; i < distros.Count; i++)
|
||||
{
|
||||
DistroDefinition distro = distros[i];
|
||||
if (GachaService.IsBeginnerInstallMediaDistro(distro))
|
||||
if (GachaService.IsBeginnerInstallMediaDistro(distro) || distro?.Id == "nixos")
|
||||
{
|
||||
gacha.AddToBannerPool(distro);
|
||||
}
|
||||
|
||||
@@ -216,6 +216,7 @@ namespace KernelPanic.UI
|
||||
FontAsset resolvedFont = ResolveMonospaceFont();
|
||||
featuredUnitPanel.Bind(_root, resolvedFont, GetBestWaveForUnit, OpenFeaturedUnitDetail);
|
||||
collectionScreen.Bind(_root, resolvedFont, languageDeckDatabase, cardDatabase, _playerCollection, GetMergesBalance, UpgradeCollectionUnit, packageDatabase, _packageLoadout, SaveCurrentState, () => _saveData, UpgradeCollectionPackage, ScrapCollectionPackage);
|
||||
collectionScreen.LanguageTrainingRequested += StartLanguageTraining;
|
||||
gachaScreen.Bind(_root, distroDatabase, packageDatabase, resolvedFont, _gachaService, _playerCollection, _wallet, ResolvePulledDistros, ClaimStandardFiveStarSelector, HandleMetaStateChanged, OpenRootCreditExchange, StartGachaPullCutscene);
|
||||
LoadMetaState();
|
||||
_playerCollection.Changed += HandleMetaStateChanged;
|
||||
@@ -309,6 +310,14 @@ namespace KernelPanic.UI
|
||||
PlayBootIntroIfNeeded();
|
||||
RefreshDailyQuestPanel();
|
||||
_dailyQuestSchedule = _root.schedule.Execute(TickDailyQuests).Every(1000);
|
||||
if (RunContext.TryTakeLanguageReturn(out var trainingLanguage))
|
||||
{
|
||||
CompleteBootIntro();
|
||||
ShowCollectionLanguages();
|
||||
collectionScreen.ShowLanguage(trainingLanguage);
|
||||
ShowScreen(MenuScreen.Collection);
|
||||
_root.Q<Button>("LearnLanguageButton")?.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -995,7 +1004,7 @@ namespace KernelPanic.UI
|
||||
for (int i = 0; i < distros.Count; i++)
|
||||
{
|
||||
DistroDefinition distro = distros[i];
|
||||
if (GachaService.IsBeginnerInstallMediaDistro(distro))
|
||||
if (GachaService.IsBeginnerInstallMediaDistro(distro) || distro?.Id == "nixos")
|
||||
{
|
||||
_gachaService.AddToBannerPool(distro);
|
||||
}
|
||||
@@ -1113,6 +1122,24 @@ namespace KernelPanic.UI
|
||||
return true;
|
||||
}
|
||||
|
||||
private void StartLanguageTraining(Language language)
|
||||
{
|
||||
if (_runLaunchPending || PersistenceBlocked || TutorialCampaign.Required(_saveData)
|
||||
|| !LanguageUnlock.IsUnlocked(language, _playerCollection) || !LanguageTraining.IsSupported(language)) return;
|
||||
try
|
||||
{
|
||||
var host = _playerCollection.OwnedUnits.Count > 0 ? _playerCollection.OwnedUnits[0] : null;
|
||||
RunContext.SetTutorial(LanguageTraining.CreateConfig(language, host, cardDatabase));
|
||||
_runLaunchPending = true;
|
||||
SceneLoader.LoadGame(_root);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
var detail = _root.Q<ScrollView>("CollectionDetail");
|
||||
detail?.Add(TerminalLayout.BodyText("Training could not start: " + ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveCurrentState()
|
||||
{
|
||||
if (_saveLoadFailed || _loadingMetaState) return;
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace KernelPanic.UI
|
||||
{
|
||||
ResolutionTrack.InterpreterQueue => "QUEUE / FIFO",
|
||||
ResolutionTrack.LazyStack => "STACK / LIFO",
|
||||
ResolutionTrack.Goroutine => "GOROUTINE / NEXT ROUND",
|
||||
_ => "NATIVE / NOW"
|
||||
};
|
||||
|
||||
@@ -34,17 +35,62 @@ namespace KernelPanic.UI
|
||||
header.Add(Text($"{cost}c", "software-cost"));
|
||||
target.Add(header);
|
||||
target.Add(Text(string.IsNullOrWhiteSpace(definition.DisplayName) ? definition.name : definition.DisplayName, "software-name"));
|
||||
target.Add(Text(TrackName(definition.ResolutionTrack), "software-track"));
|
||||
bool python = definition.Language == Language.Python;
|
||||
string role = null;
|
||||
string displayRules = rules;
|
||||
if (python)
|
||||
{
|
||||
// Lift only known presentation prefixes out of the generated rules.
|
||||
// Amounts, upgrades, targets and conditions remain authoritative.
|
||||
foreach (string prefix in new[] { "payload", "automation", "modifier", "preparation" })
|
||||
{
|
||||
if (!rules.StartsWith(prefix + ": ", System.StringComparison.Ordinal)) continue;
|
||||
role = prefix;
|
||||
displayRules = rules.Substring(prefix.Length + 2);
|
||||
target.AddToClassList("software-python-" + role);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (role != null)
|
||||
{
|
||||
var metadata = new VisualElement();
|
||||
metadata.AddToClassList("software-python-metadata");
|
||||
metadata.Add(Text(role.ToUpperInvariant(), "software-python-role"));
|
||||
metadata.Add(Text(TrackName(definition.ResolutionTrack), "software-track"));
|
||||
target.Add(metadata);
|
||||
}
|
||||
else target.Add(Text(TrackName(definition.ResolutionTrack), "software-track"));
|
||||
|
||||
if (card.DrawRider > 0) rules += $" Draw {card.DrawRider}.";
|
||||
if (card.DrawRider > 0)
|
||||
{
|
||||
rules += $" Draw {card.DrawRider}.";
|
||||
displayRules += $" Draw {card.DrawRider}.";
|
||||
}
|
||||
target.tooltip = rules;
|
||||
if (card.IsBroken) target.tooltip += "\n\n" + CardPreviewService.CorruptionDetails(card);
|
||||
var body = new VisualElement();
|
||||
body.AddToClassList("software-body");
|
||||
// Break at a sentence boundary only. Never reinterpret effect amounts or conditions.
|
||||
int split = rules.IndexOf(". ", System.StringComparison.Ordinal);
|
||||
body.Add(Text(split < 0 ? rules : rules.Substring(0, split + 1), "software-effect"));
|
||||
if (split >= 0) body.Add(Text(rules.Substring(split + 2), "software-conditions"));
|
||||
int split = displayRules.IndexOf(". ", System.StringComparison.Ordinal);
|
||||
body.Add(Text(split < 0 ? displayRules : displayRules.Substring(0, split + 1), "software-effect"));
|
||||
if (split >= 0)
|
||||
{
|
||||
string details = displayRules.Substring(split + 2);
|
||||
if (python)
|
||||
{
|
||||
// Give each rule its own line without abbreviating or hiding restrictions.
|
||||
var sentences = details.Split(new[] { ". " }, System.StringSplitOptions.None);
|
||||
for (int i = 0; i < sentences.Length; i++)
|
||||
{
|
||||
string line = sentences[i] + (i < sentences.Length - 1 ? "." : "");
|
||||
var rule = new VisualElement();
|
||||
rule.AddToClassList("software-python-rule");
|
||||
rule.Add(Text(line, "software-conditions"));
|
||||
body.Add(rule);
|
||||
}
|
||||
}
|
||||
else body.Add(Text(details, "software-conditions"));
|
||||
}
|
||||
target.Add(body);
|
||||
|
||||
var footer = new VisualElement();
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace KernelPanic.UI
|
||||
|
||||
public static void SetDistro(VisualElement root, DistroDefinition distro)
|
||||
{
|
||||
foreach (string id in new[] { "arch", "ubuntu", "fedora", "mint", "gentoo" })
|
||||
foreach (string id in new[] { "arch", "ubuntu", "fedora", "mint", "gentoo", "nixos" })
|
||||
root.EnableInClassList("distro-" + id, distro != null && distro.Id == id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace KernelPanic.UI
|
||||
private readonly LanguageDeckDatabase _languages;
|
||||
private readonly SaveService _save;
|
||||
private readonly Action _returnToMenu;
|
||||
private readonly Language? _language;
|
||||
private TutorialSpotlight _spotlight;
|
||||
private Action _refresh;
|
||||
private int _lesson, _shopStep;
|
||||
@@ -27,12 +28,14 @@ namespace KernelPanic.UI
|
||||
public TutorialGuide Guide { get; private set; }
|
||||
public bool Reading => Guide.Reading;
|
||||
public int Lesson => _lesson;
|
||||
public bool IsLanguageTraining => _language.HasValue;
|
||||
|
||||
public TutorialFlow(VisualElement overlay, RunManager run, CombatManager combat, CardDatabase cards,
|
||||
LanguageDeckDatabase languages, SaveService save, RunConfig config, Action returnToMenu)
|
||||
{
|
||||
_overlay = overlay; _run = run; _combat = combat; _cards = cards; _languages = languages;
|
||||
_save = save; _lesson = config.TutorialLesson; _returnToMenu = returnToMenu;
|
||||
_language = config.TrainingLanguage;
|
||||
_resuming = _lesson > 1;
|
||||
SetGuide(_lesson);
|
||||
}
|
||||
@@ -42,7 +45,7 @@ namespace KernelPanic.UI
|
||||
private void SetGuide(int lesson)
|
||||
{
|
||||
_spotlight?.Dispose(); _spotlight = null;
|
||||
Guide = new TutorialGuide(lesson); _combat.TutorialGuide = Guide;
|
||||
Guide = _language.HasValue ? new TutorialGuide(_language.Value) : new TutorialGuide(lesson); _combat.TutorialGuide = Guide;
|
||||
_combat.TutorialReading = true; _renderKey = null;
|
||||
}
|
||||
public void ObserveCard(ResolutionTrack track) => Guide.CardPlayed(track);
|
||||
@@ -52,6 +55,39 @@ namespace KernelPanic.UI
|
||||
public void Review() => Redraw();
|
||||
public void AdvancePage() { if (_leaving || _resuming) return; Guide.Acknowledge(_combat); Redraw(); }
|
||||
|
||||
public void ExitLanguageTraining()
|
||||
{
|
||||
if (!_language.HasValue || _leaving) return;
|
||||
_leaving = true;
|
||||
RunContext.ReturnToLanguage(_language.Value);
|
||||
_returnToMenu();
|
||||
}
|
||||
|
||||
private void RefreshLanguageResult()
|
||||
{
|
||||
_spotlight?.Dispose(); _spotlight = null;
|
||||
string key = "language-result:" + _combat.RunLost;
|
||||
if (_renderKey == key) return;
|
||||
_renderKey = key;
|
||||
_overlay.Clear(); _overlay.AddToClassList("tutorial-overlay"); _overlay.style.display = DisplayStyle.Flex;
|
||||
var panel = TerminalLayout.Section(_combat.RunLost ? "Practice ended" : "Practice complete", "LanguageTrainingResult");
|
||||
panel.AddToClassList("tutorial-dialog");
|
||||
var scroll = new ScrollView(ScrollViewMode.Vertical);
|
||||
scroll.style.flexShrink = 1; scroll.style.minHeight = 0;
|
||||
scroll.Add(TerminalLayout.BodyText("Return to your language collection, or try the same fight again. Your campaign and collection are unchanged."));
|
||||
panel.Add(scroll);
|
||||
var retry = new Button(() =>
|
||||
{
|
||||
var config = _run.CurrentConfig;
|
||||
_overlay.RemoveFromClassList("tutorial-overlay");
|
||||
SetGuide(0); _run.StartRun(config); Redraw();
|
||||
}) { text = "Try again", name = "RetryLanguageTraining" };
|
||||
retry.AddToClassList("primary-action"); panel.Add(retry);
|
||||
var back = new Button(ExitLanguageTraining) { text = "Back to languages", name = "ReturnToLanguages" };
|
||||
back.AddToClassList("primary-action"); panel.Add(back);
|
||||
TerminalTheme.ConstrainModalFocus(panel); _overlay.Add(panel); back.Focus();
|
||||
}
|
||||
|
||||
public void ResumeSecondWave()
|
||||
{
|
||||
if (!_resuming) return;
|
||||
@@ -63,10 +99,13 @@ namespace KernelPanic.UI
|
||||
{
|
||||
if (_leaving || _resuming) return;
|
||||
UpdateState();
|
||||
if (_language.HasValue && (_combat.AwaitingWaveContinue || _combat.RunFinished))
|
||||
{ RefreshLanguageResult(); return; }
|
||||
if (Guide.Active && !_combat.RunFinished)
|
||||
{
|
||||
_overlay.RemoveFromClassList("tutorial-overlay");
|
||||
_spotlight ??= new TutorialSpotlight(_overlay, AdvancePage);
|
||||
if (_language.HasValue) _spotlight.SetExit(ExitLanguageTraining);
|
||||
_spotlight.Show(Guide, _combat);
|
||||
return;
|
||||
}
|
||||
@@ -148,6 +187,7 @@ namespace KernelPanic.UI
|
||||
|
||||
public void Continue()
|
||||
{
|
||||
if (_language.HasValue) return;
|
||||
if (_leaving || Guide.Active || !_combat.AwaitingWaveContinue || _combat.RunFinished) return;
|
||||
if (_lesson == 1 && !_run.RepositoryOffers.Any(offer => offer.Sold)) return;
|
||||
if (_run.WavesCleared < _lesson) return;
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace KernelPanic.UI
|
||||
private readonly VisualElement[] _shades = new VisualElement[4];
|
||||
private readonly Label _title, _copy, _progress;
|
||||
private readonly Button _next;
|
||||
private Button _exit;
|
||||
private readonly IVisualElementScheduledItem _placement;
|
||||
private TutorialGuide _guide;
|
||||
private VisualElement _anchor;
|
||||
@@ -50,7 +51,9 @@ namespace KernelPanic.UI
|
||||
_guide = guide; _overlay.style.display = DisplayStyle.Flex;
|
||||
_root.EnableInClassList("tutorial-card-focus", guide.Step.Anchor == "card");
|
||||
_anchor = ResolveAnchor();
|
||||
_progress.text = $"Wave {combat.RunConfig.TutorialLesson}/{TutorialCampaign.LessonCount} / step {guide.Index + 1} of {guide.Count}";
|
||||
_progress.text = combat.RunConfig.TrainingLanguage.HasValue
|
||||
? $"{KernelPanic.Data.LanguageCatalog.Get(combat.RunConfig.TrainingLanguage.Value).DisplayName} practice / step {guide.Index + 1} of {guide.Count}"
|
||||
: $"Wave {combat.RunConfig.TutorialLesson}/{TutorialCampaign.LessonCount} / step {guide.Index + 1} of {guide.Count}";
|
||||
_title.text = guide.Step.Title; _copy.text = guide.Step.Copy;
|
||||
_next.style.display = guide.Reading ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
_next.SetEnabled(combat.TutorialInputReady);
|
||||
@@ -70,6 +73,14 @@ namespace KernelPanic.UI
|
||||
Place();
|
||||
}
|
||||
|
||||
public void SetExit(Action exit)
|
||||
{
|
||||
if (_exit != null) return;
|
||||
_exit = new Button(exit) { name = "ExitLanguageTraining", text = "[Esc] Exit training" };
|
||||
_exit.AddToClassList("secondary-action");
|
||||
_panel.Add(_exit);
|
||||
}
|
||||
|
||||
private VisualElement ResolveAnchor()
|
||||
{
|
||||
if (_guide?.Step == null) return null;
|
||||
@@ -95,7 +106,9 @@ namespace KernelPanic.UI
|
||||
private void TrapFocus(NavigationMoveEvent evt)
|
||||
{
|
||||
if (_guide?.Active != true || evt.direction is not (NavigationMoveEvent.Direction.Next or NavigationMoveEvent.Direction.Previous)) return;
|
||||
_root.panel?.focusController.IgnoreEvent(evt); evt.StopImmediatePropagation(); FocusAction();
|
||||
_root.panel?.focusController.IgnoreEvent(evt); evt.StopImmediatePropagation();
|
||||
if (_exit != null && _root.panel?.focusController.focusedElement != _exit) _exit.Focus();
|
||||
else FocusAction();
|
||||
}
|
||||
|
||||
private void Place()
|
||||
|
||||
Reference in New Issue
Block a user