From 2614c3c57a7302f009954f2a565ca12b152ea784 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sun, 22 Mar 2026 19:11:37 +0100 Subject: [PATCH] =?UTF-8?q?fix(client):=20build=20tab=20panel=20entirely?= =?UTF-8?q?=20in=20code=20=E2=80=94=20remove=20from=20.tscn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TabContainer and its VBoxContainer parent vanish during scene instantiation when loaded as a child of MainMenu in Godot 4.6. Moving the entire tab panel construction to _ready() resolves the issue — the .tscn now only defines the preview side and footer. Co-Authored-By: Claude Opus 4.6 --- client/scenes/character_creation.tscn | 19 ++------------ client/ui/character_creation.gd | 36 +++++++++++++++++++-------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/client/scenes/character_creation.tscn b/client/scenes/character_creation.tscn index fa0eac502..22743b56e 100644 --- a/client/scenes/character_creation.tscn +++ b/client/scenes/character_creation.tscn @@ -141,23 +141,8 @@ text = "► [E]" theme_override_font_sizes/font_size = 12 theme_override_colors/font_color = Color(0.784, 0.816, 0.878, 1.0) -; =========================================================================== -; Tab panel (~40% of width): 5 customisation tabs -; =========================================================================== - -[node name="TabPanel" type="VBoxContainer" parent="Layout"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_stretch_ratio = 2.0 -add_theme_constant_override("separation", 0) - -[node name="TabContainer" type="TabContainer" parent="Layout/TabPanel"] -layout_mode = 2 -size_flags_vertical = 3 -theme_override_font_sizes/font_size = 12 -theme_override_colors/font_color = Color(0.784, 0.816, 0.878, 1.0) - -; Tab shells created programmatically in character_creation.gd _ready() +; Tab panel built programmatically in character_creation.gd _ready() +; (TabContainer defined in .tscn vanishes during child instantiation in Godot 4.6) ; =========================================================================== ; Footer — full width, 48px tall, anchored to bottom diff --git a/client/ui/character_creation.gd b/client/ui/character_creation.gd index bdde8be02..87cda33ee 100644 --- a/client/ui/character_creation.gd +++ b/client/ui/character_creation.gd @@ -195,12 +195,33 @@ var _tab_grids: Array[GridContainer] = [null, null, null, null, null] # ============================================================================= func _ready() -> void: - # Resolve TabContainer — @onready path fails when scene is instantiated as child of MainMenu - _tab_container = find_child("TabContainer", true, false) as TabContainer - if _tab_container == null: - push_error("CharacterCreation: TabContainer not found in scene tree") + # Build tab panel programmatically — Godot 4.6 destroys TabContainer children + # defined in .tscn when the scene is instantiated as a child of another scene. + var layout: HBoxContainer = get_node_or_null("Layout") as HBoxContainer + if layout == null: + push_error("CharacterCreation: Layout node not found") return + var tab_panel := VBoxContainer.new() + tab_panel.name = "TabPanel" + tab_panel.size_flags_horizontal = Control.SIZE_FILL | Control.SIZE_EXPAND + tab_panel.size_flags_stretch_ratio = 2.0 + tab_panel.add_theme_constant_override("separation", 0) + layout.add_child(tab_panel) + + _tab_container = TabContainer.new() + _tab_container.name = "TabContainer" + _tab_container.size_flags_vertical = Control.SIZE_FILL | Control.SIZE_EXPAND + _tab_container.add_theme_font_size_override("font_size", 12) + _tab_container.add_theme_color_override("font_color", Color(0.784, 0.816, 0.878, 1.0)) + tab_panel.add_child(_tab_container) + + var tab_names: Array[String] = ["Body", "Head", "Hair", "Clothing", "Accessories"] + for tab_name in tab_names: + var tab := Control.new() + tab.name = tab_name + _tab_container.add_child(tab) + _descriptor = CharacterVisualDescriptor.new() _descriptor.body_type = CharacterVisualDescriptor.BodyType.AVERAGE_M _descriptor.skin_tone = 2 # light_olive — readable middle-ground default @@ -227,13 +248,6 @@ func _ready() -> void: _rotate_left_btn.text = UIStrings.get_text("character_creation.btn_rotate_left") _rotate_right_btn.text = UIStrings.get_text("character_creation.btn_rotate_right") - # Create tab shells programmatically (Godot 4.6 TabContainer requires runtime children) - var tab_names: Array[String] = ["Body", "Head", "Hair", "Clothing", "Accessories"] - for tab_name in tab_names: - var tab := Control.new() - tab.name = tab_name - _tab_container.add_child(tab) - _build_body_tab(_tab_container.get_child(0)) _build_head_tab(_tab_container.get_child(1)) _build_hair_tab(_tab_container.get_child(2))