65 lines
2.1 KiB
GDScript
65 lines
2.1 KiB
GDScript
extends CanvasLayer
|
|
|
|
#UI Elements
|
|
@onready var confirmation_mask = $ConfirmationMask
|
|
@onready var masks = $Masks
|
|
@onready var pause_menu = $PauseMenu
|
|
|
|
#GameOver Scenes
|
|
@onready var its_game_over = $ITSGameOverControl
|
|
|
|
#Preloading Confirmation dialog
|
|
var confirmation_dialog = preload("res://Scenes/UI/confirmation_dialog.tscn")
|
|
|
|
#Signals for saving and loading
|
|
signal save_slot_pressed(save_slot_number: int)
|
|
signal load_slot_pressed(load_slot_number: int)
|
|
|
|
#Signal for going back to main menu
|
|
signal main_menu_pressed
|
|
|
|
#Signals for handling text settings
|
|
signal text_value_changed
|
|
signal auto_value_changed
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
|
|
#Connecting signals
|
|
pause_menu.settings.text_value_changed.connect(func(): text_value_changed.emit())
|
|
pause_menu.settings.auto_value_changed.connect(func(): auto_value_changed.emit())
|
|
|
|
#Hiding everything at start
|
|
confirmation_mask.hide()
|
|
|
|
|
|
#Brings up a Confirmation Dialog
|
|
func ask_confirmation(function_yes: Callable, function_no: Callable, choice_text: String):
|
|
|
|
var choice_dialog = confirmation_dialog.instantiate()
|
|
add_child(choice_dialog)
|
|
|
|
var choice_text_label = choice_dialog.get_node("ConfirmationDialog/MarginContainer/VBoxContainer/ConfirmationText")
|
|
var choice_yes = choice_dialog.get_node("ConfirmationDialog/MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/YesButton")
|
|
var choice_no = choice_dialog.get_node("ConfirmationDialog/MarginContainer/VBoxContainer/MarginContainer/HBoxContainer/NoButton")
|
|
|
|
#Clears the Confirmation Dialog and Remove the Mask no matter what choice is made
|
|
choice_yes.pressed.connect(func(): confirmation_mask.hide())
|
|
choice_yes.pressed.connect(func(): choice_dialog.queue_free())
|
|
choice_no.pressed.connect(func(): confirmation_mask.hide())
|
|
choice_no.pressed.connect(func(): choice_dialog.queue_free())
|
|
|
|
choice_yes.text = ("YES")
|
|
choice_no.text = ("NO")
|
|
choice_text_label.text = choice_text
|
|
|
|
#Connects Choices to their Functions
|
|
choice_yes.pressed.connect(function_yes, CONNECT_ONE_SHOT)
|
|
if function_no.is_valid():
|
|
choice_no.pressed.connect(function_no, CONNECT_ONE_SHOT)
|
|
|
|
choice_dialog.show()
|
|
confirmation_mask.show()
|
|
|