using Godot; namespace Theriapolis.GodotHost.Scenes; /// /// Character creation wizard shell. Mirrors src/app.jsx per /// GODOT_PORTING_GUIDE.md §4: header + stepper + page (step + aside) + /// nav bar. Owns the resource and dispatches /// each step's content into the StepHost. /// /// The codex Theme is applied at this root in and /// cascades through every descendant — steps, Aside, popover layer. /// public partial class Wizard : Control { [Signal] public delegate void BackToTitleEventHandler(); /// Forwarded from StepReview.CharacterConfirmed so /// the wizard's owner (TitleScreen / Main) can hand off to the /// WorldGenProgressScreen without reaching into the step tree. [Signal] public delegate void CharacterConfirmedEventHandler(UI.CharacterDraft draft); private static readonly string[] StepKeys = { "clade", "species", "class", "subclass", "background", "stats", "skills", "review" }; private static readonly string[] StepNames = { "Clade", "Species", "Calling", "Subclass", "History", "Abilities", "Skills", "Sign" }; public UI.CharacterDraft Character { get; private set; } = null!; private UI.Widgets.CodexStepper _stepper = null!; private Control _stepHost = null!; private Label _folioLabel = null!; private Label _validation = null!; private Label _navProgress = null!; private Button _backBtn = null!; private Button _nextBtn = null!; // Scroll preservation: snapshot scroll position when the draft changes // (which fires before the active step's Refresh tears down + rebuilds // child nodes), then restore on the next _Process frame so the user // doesn't get punted to the top of the page when selecting a card. private ScrollContainer? _scroll; private int _savedScroll = -1; private bool _scrollPending; private int _step; private Steps.IStep? _activeStep; private static readonly System.Type?[] StepTypes = { typeof(Steps.StepClade), // 0 Clade typeof(Steps.StepSpecies), // 1 Species typeof(Steps.StepClass), // 2 Calling typeof(Steps.StepSubclass), // 3 Subclass typeof(Steps.StepBackground), // 4 History typeof(Steps.StepStats), // 5 Abilities typeof(Steps.StepSkills), // 6 Skills typeof(Steps.StepReview), // 7 Sign }; public override void _Ready() { Theme = UI.CodexTheme.Build(); // The wizard root is a Control, which paints nothing — without a // backing Panel the viewport's default grey clear color shows // through. Insert a Panel sized to the full rect so the theme's // parchment Bg fills the canvas, then move it behind the existing // children so it doesn't intercept mouse events. var bg = new Panel { AnchorRight = 1, AnchorBottom = 1, MouseFilter = MouseFilterEnum.Ignore, }; AddChild(bg); MoveChild(bg, 0); Character = new UI.CharacterDraft(); _stepper = GetNode("%Stepper"); _stepHost = GetNode("%StepHost"); _folioLabel = GetNode