fix(client): build tab panel entirely in code — remove from .tscn

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 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 19:11:37 +01:00
co-authored by Claude Opus 4.6
parent 307a221527
commit 2614c3c57a
2 changed files with 27 additions and 28 deletions
+2 -17
View File
@@ -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
+25 -11
View File
@@ -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))