Lots of little tweaks and fixes
This commit is contained in:
+15
-22
@@ -2,44 +2,37 @@ class_name PauseMain extends VBoxContainer
|
||||
|
||||
signal resumeRequested
|
||||
signal settingsRequested
|
||||
signal mainMenuRequested
|
||||
signal quitRequested
|
||||
|
||||
@export var btnResume:Button
|
||||
@export var btnSettings:Button
|
||||
@export var btnMainMenu:Button
|
||||
@export var btnQuit:Button
|
||||
@export var mainButtons:VBoxContainer
|
||||
@export var confirmQuit:VBoxContainer
|
||||
@export var btnQuitConfirm:Button
|
||||
@export var btnQuitCancel:Button
|
||||
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
btnResume.pressed.connect(resumeRequested.emit)
|
||||
btnSettings.pressed.connect(settingsRequested.emit)
|
||||
btnMainMenu.pressed.connect(mainMenuRequested.emit)
|
||||
btnQuit.pressed.connect(_showConfirm)
|
||||
btnQuitConfirm.pressed.connect(quitRequested.emit)
|
||||
btnQuitCancel.pressed.connect(cancelConfirm)
|
||||
btnMainMenu.pressed.connect(_showMainMenuConfirm)
|
||||
btnQuit.pressed.connect(_showQuitConfirm)
|
||||
UI.QUIT_DIALOG.closed.connect(_onQuitDialogClosed)
|
||||
UI.MAIN_MENU_DIALOG.closed.connect(_onMainMenuDialogClosed)
|
||||
|
||||
func _showConfirm() -> void:
|
||||
mainButtons.visible = false
|
||||
confirmQuit.visible = true
|
||||
btnQuitCancel.grab_focus()
|
||||
func _showQuitConfirm() -> void:
|
||||
UI.QUIT_DIALOG.open()
|
||||
|
||||
func cancelConfirm() -> void:
|
||||
mainButtons.visible = true
|
||||
confirmQuit.visible = false
|
||||
btnQuit.grab_focus()
|
||||
func _showMainMenuConfirm() -> void:
|
||||
UI.MAIN_MENU_DIALOG.open()
|
||||
|
||||
func isConfirming() -> bool:
|
||||
return confirmQuit.visible
|
||||
func _onQuitDialogClosed() -> void:
|
||||
if isOpen():
|
||||
btnQuit.grab_focus()
|
||||
|
||||
func _onMainMenuDialogClosed() -> void:
|
||||
if isOpen():
|
||||
btnMainMenu.grab_focus()
|
||||
|
||||
func open() -> void:
|
||||
visible = true
|
||||
if isConfirming():
|
||||
cancelConfirm()
|
||||
btnResume.grab_focus()
|
||||
|
||||
func close() -> void:
|
||||
|
||||
+1
-22
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://c7kvg0jw6w340" path="res://ui/pause/PauseMain.gd" id="1_b5xfl"]
|
||||
|
||||
[node name="PauseMain" type="VBoxContainer" node_paths=PackedStringArray("btnResume", "btnSettings", "btnMainMenu", "btnQuit", "mainButtons", "confirmQuit", "btnQuitConfirm", "btnQuitCancel")]
|
||||
[node name="PauseMain" type="VBoxContainer" node_paths=PackedStringArray("btnResume", "btnSettings", "btnMainMenu", "btnQuit")]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
@@ -16,10 +16,6 @@ btnResume = NodePath("MainButtons/Resume")
|
||||
btnSettings = NodePath("MainButtons/Settings")
|
||||
btnMainMenu = NodePath("MainButtons/MainMenu")
|
||||
btnQuit = NodePath("MainButtons/Quit")
|
||||
mainButtons = NodePath("MainButtons")
|
||||
confirmQuit = NodePath("ConfirmQuit")
|
||||
btnQuitConfirm = NodePath("ConfirmQuit/Yes")
|
||||
btnQuitCancel = NodePath("ConfirmQuit/No")
|
||||
|
||||
[node name="Title" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
@@ -44,20 +40,3 @@ text = "Main Menu"
|
||||
[node name="Quit" type="Button" parent="MainButtons"]
|
||||
layout_mode = 2
|
||||
text = "Quit Game"
|
||||
|
||||
[node name="ConfirmQuit" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
visible = false
|
||||
|
||||
[node name="Label" type="Label" parent="ConfirmQuit"]
|
||||
layout_mode = 2
|
||||
text = "Quit to desktop?"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Yes" type="Button" parent="ConfirmQuit"]
|
||||
layout_mode = 2
|
||||
text = "Yes"
|
||||
|
||||
[node name="No" type="Button" parent="ConfirmQuit"]
|
||||
layout_mode = 2
|
||||
text = "No"
|
||||
|
||||
+16
-11
@@ -1,5 +1,8 @@
|
||||
class_name PauseMenu extends Control
|
||||
|
||||
signal opened
|
||||
signal closed
|
||||
|
||||
@export var MAIN:PauseMain
|
||||
@export var settingsPanel:PauseSettings
|
||||
|
||||
@@ -7,8 +10,7 @@ func _ready() -> void:
|
||||
close()
|
||||
MAIN.resumeRequested.connect(close)
|
||||
MAIN.settingsRequested.connect(_openSettings)
|
||||
MAIN.mainMenuRequested.connect(_goToMainMenu)
|
||||
MAIN.quitRequested.connect(func(): get_tree().quit())
|
||||
UI.MAIN_MENU_DIALOG.confirmed.connect(_goToMainMenu)
|
||||
|
||||
func isOpen() -> bool:
|
||||
return visible
|
||||
@@ -17,12 +19,14 @@ func open() -> void:
|
||||
visible = true
|
||||
get_tree().paused = true
|
||||
MAIN.open()
|
||||
opened.emit()
|
||||
|
||||
func close() -> void:
|
||||
get_tree().paused = false
|
||||
visible = false
|
||||
MAIN.close()
|
||||
settingsPanel.close()
|
||||
closed.emit()
|
||||
|
||||
func _openSettings() -> void:
|
||||
MAIN.close()
|
||||
@@ -35,12 +39,13 @@ func _goToMainMenu() -> void:
|
||||
func _unhandled_input(event:InputEvent) -> void:
|
||||
if !visible:
|
||||
return
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
if MAIN.isConfirming():
|
||||
MAIN.cancelConfirm()
|
||||
elif settingsPanel.isOpen():
|
||||
settingsPanel.close()
|
||||
MAIN.open()
|
||||
else:
|
||||
close()
|
||||
get_viewport().set_input_as_handled()
|
||||
if !event.is_action_pressed("ui_cancel"):
|
||||
return
|
||||
if (UI.QUIT_DIALOG != null and UI.QUIT_DIALOG.isOpen) or (UI.MAIN_MENU_DIALOG != null and UI.MAIN_MENU_DIALOG.isOpen):
|
||||
return
|
||||
if settingsPanel.isOpen():
|
||||
settingsPanel.close()
|
||||
MAIN.open()
|
||||
else:
|
||||
close()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
Reference in New Issue
Block a user