2024-09-12 02:04:24 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
@onready var tabs = [
|
|
|
|
$HBoxContainer/BuildingTab, $HBoxContainer/BuildingTab2, $HBoxContainer/BuildingTab3
|
|
|
|
]
|
|
|
|
|
2024-09-12 02:40:54 +00:00
|
|
|
@onready var building_data = Data.data.buildings
|
|
|
|
@onready var buildings = building_data.keys()
|
|
|
|
|
2024-09-12 02:04:24 +00:00
|
|
|
|
|
|
|
@onready var v_box_container: HBoxContainer = $Buildings/VBoxContainer
|
|
|
|
|
|
|
|
@onready var icons = [
|
|
|
|
$Buildings/VBoxContainer/BuildingIcon,
|
|
|
|
$Buildings/VBoxContainer/BuildingIcon2,
|
|
|
|
$Buildings/VBoxContainer/BuildingIcon3,
|
|
|
|
$Buildings/VBoxContainer/BuildingIcon4
|
|
|
|
]
|
|
|
|
|
|
|
|
@onready var spacers = [
|
|
|
|
$Buildings/VBoxContainer/Spacer,
|
|
|
|
$Buildings/VBoxContainer/Spacer2,
|
|
|
|
$Buildings/VBoxContainer/Spacer3
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
swap_to_tab(0)
|
|
|
|
|
|
|
|
|
|
|
|
func swap_to_tab(index):
|
|
|
|
for i in range(0, tabs.size()):
|
|
|
|
if i == index:
|
|
|
|
tabs[i].select()
|
|
|
|
else:
|
|
|
|
tabs[i].unselect()
|
|
|
|
|
2024-09-15 03:21:43 +00:00
|
|
|
var filtered_buildings = buildings.filter(func(building): return building_data[building].type == tabs[index].key and (not building_data[building].has("disabled") or not building_data[building].disabled))
|
2024-09-12 02:04:24 +00:00
|
|
|
|
|
|
|
for i in range(0, icons.size()):
|
2024-09-12 02:40:54 +00:00
|
|
|
if i < filtered_buildings.size():
|
2024-09-12 02:04:24 +00:00
|
|
|
icons[i].visible = true
|
2024-09-14 00:09:38 +00:00
|
|
|
icons[i].key = filtered_buildings[i]
|
2024-09-12 02:40:54 +00:00
|
|
|
icons[i].texture_rect.texture = Data.data.images[filtered_buildings[i]]
|
2024-09-12 02:04:24 +00:00
|
|
|
|
|
|
|
if i > 0:
|
|
|
|
spacers[i - 1].visible = true
|
|
|
|
else:
|
|
|
|
icons[i].visible = false
|
|
|
|
|
|
|
|
if i > 0:
|
|
|
|
spacers[i - 1].visible = false
|
|
|
|
|
|
|
|
|
|
|
|
func _on_building_tab_clicked() -> void:
|
|
|
|
swap_to_tab(0)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_building_tab_2_clicked() -> void:
|
|
|
|
swap_to_tab(1)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_building_tab_3_clicked() -> void:
|
|
|
|
swap_to_tab(2)
|