Files
Super-Mario-Bros.-Remastere…/Scripts/UI/TitleScreenOptions.gd
KirbyKidJ cc640c5ac1 Title Screen QOL Theming
This was supposed to be a quick quality of life addition for the Title Screen that applied the save and theme to the menu, but then I discovered a new bug I had to bypass with the character palette when doing it. So I ended up doing a bit more related to the Title Screen as a result.

I also *had* a function which checks for the number of valid folders within the Pck to see how many worlds there are, but I think it might've been a bit slow so I replaced it with constant values.

- Save for the currently loaded campaign gets applied on startup
- Backing out of World 9 and over keeps you on said worlds at the title screen
- Added Skyland and Volcano to SMB1 themes since it shares most of its themes with Lost Levels
- Fixed Title Screen Stars for the Volcano Theme
2025-09-20 22:21:22 -07:00

57 lines
1.3 KiB
GDScript

class_name TitleScreenOptions
extends VBoxContainer
@export var active := false
@export var can_exit := true
var selected_index := 0
@export var options: Array[Label] = []
@onready var title_screen_parent := owner
signal option_1_selected
signal option_2_selected
signal option_3_selected
signal closed
func _process(_delta: float) -> void:
if active:
handle_inputs()
func open() -> void:
Global.world_num = clamp(Global.world_num, 1, Level.get_world_count())
title_screen_parent.active_options = self
show()
await get_tree().physics_frame
active = true
func close() -> void:
active = false
hide()
func handle_inputs() -> void:
if Input.is_action_just_pressed("ui_down"):
selected_index += 1
if Settings.file.audio.extra_sfx == 1:
AudioManager.play_global_sfx("menu_move")
if Input.is_action_just_pressed("ui_up"):
selected_index -= 1
if Settings.file.audio.extra_sfx == 1:
AudioManager.play_global_sfx("menu_move")
var amount := []
for i in options:
if i.visible:
amount.append(i)
selected_index = clamp(selected_index, 0, amount.size() - 1)
if Input.is_action_just_pressed("ui_accept"):
option_selected()
elif can_exit and Input.is_action_just_pressed("ui_back"):
close()
closed.emit()
func option_selected() -> void:
active = false
emit_signal("option_" + str(selected_index + 1) + "_selected")