34 lines
754 B
GDScript
34 lines
754 B
GDScript
extends Control
|
|
|
|
@onready var tabs: Array[GameMenuTab] = [$%Tab1, $%Tab2, $%Tab3]
|
|
@onready var pages: Array[GameMenuPage] = [$%Page1, $%Page2, $%Page3]
|
|
var current_index = 0
|
|
|
|
func _ready() -> void:
|
|
for tab: GameMenuTab in tabs:
|
|
tab.on_tab_selected.connect(on_tab_pressed)
|
|
|
|
on_tab_pressed(0, true)
|
|
|
|
func on_tab_pressed(index: int, disable_animation: bool = false) -> void:
|
|
for page in pages:
|
|
page.hide_page()
|
|
|
|
for tab in tabs:
|
|
if tab.index == index:
|
|
if disable_animation:
|
|
tab.select_without_animation()
|
|
else:
|
|
tab.select()
|
|
else:
|
|
if disable_animation:
|
|
tab.deselect_without_animation()
|
|
else:
|
|
tab.deselect()
|
|
|
|
pages[index].show_page()
|
|
current_index = index
|
|
|
|
func open() -> void:
|
|
pages[current_index].show_page()
|