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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user