feat: singleplayer level selector
This commit is contained in:
@@ -6,6 +6,7 @@ var resume_btn: Button
|
||||
var respawn_btn: Button
|
||||
var loadouts_btn: Button
|
||||
var settings_btn: Button
|
||||
var return_btn: Button
|
||||
var exit_btn: Button
|
||||
|
||||
# Loadout UI
|
||||
@@ -48,6 +49,7 @@ var rebind_label: Label
|
||||
var waiting_for_input_action: String = ""
|
||||
|
||||
var quit_dialog: ConfirmationDialog
|
||||
var return_dialog: ConfirmationDialog
|
||||
|
||||
func _ready() -> void:
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
@@ -70,6 +72,10 @@ func _input(event: InputEvent) -> void:
|
||||
return
|
||||
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
# Don't open the pause menu if we are already in the main menu
|
||||
if get_tree().current_scene and get_tree().current_scene.name == "MainMenu":
|
||||
return
|
||||
|
||||
if visible:
|
||||
_resume()
|
||||
else:
|
||||
@@ -129,6 +135,11 @@ func _build_ui() -> void:
|
||||
settings_btn.custom_minimum_size = Vector2(200, 50)
|
||||
main_vbox.add_child(settings_btn)
|
||||
|
||||
return_btn = Button.new()
|
||||
return_btn.text = "Main Menu"
|
||||
return_btn.custom_minimum_size = Vector2(200, 50)
|
||||
main_vbox.add_child(return_btn)
|
||||
|
||||
exit_btn = Button.new()
|
||||
exit_btn.text = "Exit Game"
|
||||
exit_btn.custom_minimum_size = Vector2(200, 50)
|
||||
@@ -571,6 +582,12 @@ func _build_ui() -> void:
|
||||
quit_dialog.title = "Quit Game"
|
||||
quit_dialog.dialog_text = "Are you sure you want to close the game?"
|
||||
add_child(quit_dialog)
|
||||
|
||||
# ── Return Dialog ──
|
||||
return_dialog = ConfirmationDialog.new()
|
||||
return_dialog.title = "Main Menu"
|
||||
return_dialog.dialog_text = "Are you sure you want to return to the main menu?"
|
||||
add_child(return_dialog)
|
||||
|
||||
func _build_vol_control(parent: Node, label_name: String) -> Array:
|
||||
var hbox = HBoxContainer.new()
|
||||
@@ -619,11 +636,20 @@ func _connect_signals() -> void:
|
||||
respawn_btn.pressed.connect(_respawn)
|
||||
loadouts_btn.pressed.connect(_show_loadouts)
|
||||
settings_btn.pressed.connect(_show_settings)
|
||||
return_btn.pressed.connect(_show_return_dialog)
|
||||
exit_btn.pressed.connect(_show_exit_dialog)
|
||||
back_to_main_btn.pressed.connect(_show_main_menu)
|
||||
settings_back_btn.pressed.connect(_show_main_menu)
|
||||
save_loadout_btn.pressed.connect(_save_current_loadout)
|
||||
quit_dialog.confirmed.connect(_quit_game)
|
||||
return_dialog.confirmed.connect(_return_to_main_menu)
|
||||
|
||||
func _show_return_dialog() -> void:
|
||||
return_dialog.popup_centered()
|
||||
|
||||
func _return_to_main_menu() -> void:
|
||||
_resume() # Reset pause state and cursor mode
|
||||
get_tree().change_scene_to_file("res://ui/main_menu/main_menu.tscn")
|
||||
|
||||
func _show_main_menu() -> void:
|
||||
main_vbox.visible = true
|
||||
|
||||
Reference in New Issue
Block a user