diff --git a/src/modules/building/building_option/building_option.gd b/src/modules/building/building_option/building_option.gd index 5c4e822..d6e812c 100644 --- a/src/modules/building/building_option/building_option.gd +++ b/src/modules/building/building_option/building_option.gd @@ -1,16 +1,16 @@ class_name BuildingOption extends Control -const buildings_json = preload("res://src/modules/building/building_option/buildings.tres") - signal selected(item: BuildingOptionItem) @export var selected_id: int -@onready var option_button: OptionButton = $OptionButton; + +const buildings_json = preload("res://src/modules/building/building_option/buildings.tres") + +var option_button: OptionButton; var selected_option: BuildingOptionItem = null - var options: Array[BuildingOptionItem] = [] func select(selected_id: int): @@ -20,16 +20,18 @@ func select(selected_id: int): selected_option = option selected.emit(option) -func _ready(): +func _enter_tree(): + option_button = $OptionButton; + for building_group in buildings_json.data: option_button.add_separator(building_group.group) for building in building_group.children: options.append(BuildingOptionItem.new(building)) option_button.add_item("{label} ({energy} ⚡)".format(building), building.id) - - option_button.selected = -1 - + + +func _ready(): if selected_id != null: select(selected_id)