From f9b60dfbc75afb34319d62f13e8afbf9861bf0a7 Mon Sep 17 00:00:00 2001 From: Jakob Feldmann Date: Mon, 12 Jun 2023 14:12:23 +0200 Subject: [PATCH] feat: Quit Without Saving Menu, Timer to cancel --- project.godot | 101 ++++++++-------- src/Autoload/SaveManager.gd | 1 + .../Screens/ControlsMenu/ControlsMenu.gd | 2 + .../Screens/ControlsMenu/ControlsMenu.tscn | 109 ++++++++++++++++-- .../Screens/ControlsMenu/InputMapper.gd | 4 +- .../Screens/ControlsMenu/KeySelectMenu.gd | 19 ++- .../Screens/ControlsMenu/ReallyQuitMenu.gd | 18 +++ .../Screens/ControlsMenu/SaveAndQuitButton.gd | 16 +++ .../Screens/ControlsMenu/SaveButton.gd | 2 + .../ControlsMenu/SavedCheckBackButton.gd | 15 +++ src/UserInterface/Screens/PauseScreen.tscn | 5 +- src/Utilities/SignalManager.gd | 1 + 12 files changed, 233 insertions(+), 60 deletions(-) create mode 100644 src/UserInterface/Screens/ControlsMenu/ReallyQuitMenu.gd create mode 100644 src/UserInterface/Screens/ControlsMenu/SaveAndQuitButton.gd create mode 100644 src/UserInterface/Screens/ControlsMenu/SavedCheckBackButton.gd diff --git a/project.godot b/project.godot index bd949ae..0563096 100644 --- a/project.godot +++ b/project.godot @@ -156,55 +156,6 @@ ogg_vorbis={ [input] -up={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":87,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) - ] -} -duck={ -"deadzone": 0.5, -"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":83,"unicode":0,"echo":false,"script":null) - ] -} -move_left={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null) - ] -} -move_right={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":15,"pressure":0.0,"pressed":false,"script":null) - ] -} -jump={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777232,"unicode":0,"echo":false,"script":null) - ] -} -boost_move={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null) - ] -} -interact={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":69,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null) - ] -} -pause={ -"deadzone": 0.5, -"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null) -, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null) - ] -} ui_accept={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null) @@ -241,6 +192,58 @@ ui_end={ "deadzone": 0.5, "events": [ ] } +up={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":87,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null) + ] +} +duck={ +"deadzone": 0.5, +"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":83,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null) + ] +} +move_left={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) + ] +} +move_right={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":15,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null) + ] +} +jump={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null) + ] +} +boost_move={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null) + ] +} +interact={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":69,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null) + ] +} +pause={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null) + ] +} ui_click={ "deadzone": 0.5, "events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) diff --git a/src/Autoload/SaveManager.gd b/src/Autoload/SaveManager.gd index 35ece92..84ac539 100644 --- a/src/Autoload/SaveManager.gd +++ b/src/Autoload/SaveManager.gd @@ -17,3 +17,4 @@ func save_default() -> void: for action in InputMap.get_actions(): GlobalState.gsr.input_map[action] = InputMap.get_action_list(action) ResourceSaver.save(save_location, GlobalState.gsr) + signalManager.emit_signal("savemanager_saved") diff --git a/src/UserInterface/Screens/ControlsMenu/ControlsMenu.gd b/src/UserInterface/Screens/ControlsMenu/ControlsMenu.gd index 5355270..95baf1d 100644 --- a/src/UserInterface/Screens/ControlsMenu/ControlsMenu.gd +++ b/src/UserInterface/Screens/ControlsMenu/ControlsMenu.gd @@ -2,6 +2,7 @@ extends Control onready var _action_list = $"%ActionKeyList" onready var changes_made := false +onready var changes_saved := false func _ready(): $InputMapper.connect('profile_changed', self, 'rebuild') @@ -35,6 +36,7 @@ func _on_InputLine_change_button_pressed(action_name, line): if event == null: return changes_made = true + changes_saved = false $InputMapper.change_action_key(action_name, old_event, event) line.update_key(event) set_process_input(true) diff --git a/src/UserInterface/Screens/ControlsMenu/ControlsMenu.tscn b/src/UserInterface/Screens/ControlsMenu/ControlsMenu.tscn index e16a64b..bc9ea39 100644 --- a/src/UserInterface/Screens/ControlsMenu/ControlsMenu.tscn +++ b/src/UserInterface/Screens/ControlsMenu/ControlsMenu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=23 format=2] +[gd_scene load_steps=26 format=2] [ext_resource path="res://assets/ui/Screenshot 2023-05-23 160521.png" type="Texture" id=1] [ext_resource path="res://src/UserInterface/Screens/ControlsMenu/ProfilesMenu.gd" type="Script" id=2] @@ -15,6 +15,9 @@ [ext_resource path="res://src/UserInterface/Screens/ControlsMenu/KeySelectMenu.gd" type="Script" id=13] [ext_resource path="res://src/UserInterface/Screens/ControlsMenu/SaveButton.gd" type="Script" id=14] [ext_resource path="res://src/UserInterface/Screens/ControlsMenu/Reset.gd" type="Script" id=15] +[ext_resource path="res://src/UserInterface/Screens/ControlsMenu/SaveAndQuitButton.gd" type="Script" id=16] +[ext_resource path="res://src/UserInterface/Screens/ControlsMenu/SavedCheckBackButton.gd" type="Script" id=17] +[ext_resource path="res://src/UserInterface/Screens/ControlsMenu/ReallyQuitMenu.gd" type="Script" id=18] [sub_resource type="DynamicFont" id=1] size = 42 @@ -45,6 +48,7 @@ font_data = ExtResource( 6 ) anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 2 +input_pass_on_modal_close_click = false size_flags_horizontal = 0 size_flags_vertical = 0 theme = ExtResource( 5 ) @@ -200,8 +204,7 @@ input_pass_on_modal_close_click = false size_flags_horizontal = 0 size_flags_vertical = 0 text = "Back" -script = ExtResource( 11 ) -next_screen_path = "res://src/UserInterface/Screens/MainScreen.tscn" +script = ExtResource( 17 ) [node name="Reset" type="Button" parent="."] anchor_left = 0.5 @@ -251,12 +254,19 @@ autoplay = true bus = "Music" [node name="KeySelectMenu" type="Panel" parent="."] +pause_mode = 1 +process_priority = 1 visible = false material = SubResource( 8 ) anchor_right = 1.0 anchor_bottom = 1.0 +focus_mode = 2 +input_pass_on_modal_close_click = false script = ExtResource( 13 ) +[node name="Timer" type="Timer" parent="KeySelectMenu"] +wait_time = 5.0 + [node name="Prompt" type="Label" parent="KeySelectMenu"] anchor_left = 0.5 anchor_top = 0.5 @@ -270,16 +280,36 @@ grow_horizontal = 2 size_flags_horizontal = 0 size_flags_vertical = 0 custom_fonts/font = SubResource( 7 ) -text = "Press a key (ESC to cancel)" +text = "Press a key" +align = 1 +valign = 1 + +[node name="Prompt2" type="Label" parent="KeySelectMenu"] +anchor_left = 0.663 +anchor_top = 0.584 +anchor_right = 0.663 +anchor_bottom = 0.606 +margin_left = -202.5 +margin_top = -13.0 +margin_right = 202.5 +margin_bottom = 13.0 +rect_scale = Vector2( 0.5, 0.5 ) +size_flags_horizontal = 0 +size_flags_vertical = 0 +custom_fonts/font = SubResource( 7 ) +text = "(ESC to cancel or wait for timeout in: )" align = 1 valign = 1 [node name="ReallyQuitMenu" type="Panel" parent="."] +unique_name_in_owner = true +process_priority = 1 visible = false material = SubResource( 8 ) anchor_right = 1.0 anchor_bottom = 1.0 -script = ExtResource( 13 ) +input_pass_on_modal_close_click = false +script = ExtResource( 18 ) [node name="Prompt" type="Label" parent="ReallyQuitMenu"] anchor_left = 0.5 @@ -295,12 +325,77 @@ size_flags_horizontal = 0 size_flags_vertical = 0 custom_fonts/font = SubResource( 7 ) text = "Unsaved changes were made. - Go back anyway? Enter -> Leave, ESC -> Stay -Smile -> Save changes and leave" + Go back anyway?" align = 1 valign = 1 +[node name="SaveNQuit" type="Button" parent="ReallyQuitMenu"] +anchor_left = 0.5 +anchor_top = 0.65 +anchor_right = 0.5 +anchor_bottom = 0.65 +margin_left = -45.0 +margin_top = -12.5 +margin_right = 45.0 +margin_bottom = 12.5 +grow_horizontal = 2 +grow_vertical = 2 +rect_min_size = Vector2( 40, 20 ) +focus_neighbour_left = NodePath(".") +focus_neighbour_top = NodePath("../QuitDontSave") +focus_neighbour_right = NodePath(".") +focus_neighbour_bottom = NodePath("../ContinueEdit") +input_pass_on_modal_close_click = false +size_flags_horizontal = 0 +size_flags_vertical = 0 +text = "Save & Quit" +script = ExtResource( 16 ) +next_screen_path = "res://src/UserInterface/Screens/MainScreen.tscn" + +[node name="ContinueEdit" type="Button" parent="ReallyQuitMenu"] +anchor_left = 0.5 +anchor_top = 0.75 +anchor_right = 0.5 +anchor_bottom = 0.75 +margin_left = -50.5 +margin_top = -12.5 +margin_right = 50.5 +margin_bottom = 12.5 +focus_neighbour_left = NodePath(".") +focus_neighbour_top = NodePath("../SaveNQuit") +focus_neighbour_right = NodePath(".") +focus_neighbour_bottom = NodePath("../QuitDontSave") +input_pass_on_modal_close_click = false +text = "Continue Editing" + +[node name="QuitDontSave" type="Button" parent="ReallyQuitMenu"] +anchor_left = 0.5 +anchor_top = 0.85 +anchor_right = 0.5 +anchor_bottom = 0.85 +margin_left = -45.0 +margin_top = -12.5 +margin_right = 45.0 +margin_bottom = 12.5 +grow_horizontal = 2 +grow_vertical = 2 +rect_min_size = Vector2( 40, 20 ) +focus_neighbour_left = NodePath(".") +focus_neighbour_top = NodePath("../ContinueEdit") +focus_neighbour_right = NodePath(".") +focus_neighbour_bottom = NodePath("../SaveNQuit") +input_pass_on_modal_close_click = false +size_flags_horizontal = 0 +size_flags_vertical = 0 +text = "Quit Dont Save" +script = ExtResource( 11 ) +next_screen_path = "res://src/UserInterface/Screens/MainScreen.tscn" + [connection signal="focus_entered" from="KeymapViewer/ScrollContainer" to="KeymapViewer/ScrollContainer" method="_on_focus_entered"] [connection signal="button_up" from="Back" to="Back" method="_on_button_up"] [connection signal="button_up" from="Reset" to="Reset" method="_on_button_up"] [connection signal="button_up" from="Save" to="Save" method="_on_button_up"] +[connection signal="timeout" from="KeySelectMenu/Timer" to="KeySelectMenu" method="close_on_timeout"] +[connection signal="button_up" from="ReallyQuitMenu/SaveNQuit" to="ReallyQuitMenu/SaveNQuit" method="_on_button_up"] +[connection signal="button_up" from="ReallyQuitMenu/ContinueEdit" to="ReallyQuitMenu" method="close"] +[connection signal="button_up" from="ReallyQuitMenu/QuitDontSave" to="ReallyQuitMenu/QuitDontSave" method="_on_button_up"] diff --git a/src/UserInterface/Screens/ControlsMenu/InputMapper.gd b/src/UserInterface/Screens/ControlsMenu/InputMapper.gd index cbcb2f3..07c1b76 100644 --- a/src/UserInterface/Screens/ControlsMenu/InputMapper.gd +++ b/src/UserInterface/Screens/ControlsMenu/InputMapper.gd @@ -45,10 +45,10 @@ func initialize_profiles() -> void: for action in actions: var input_events = InputMap.get_action_list(action) for event in input_events: - if event.as_text().match("*Joy*"): + if event.as_text().match("*JoypadButton*"): controller[action] = event controller[action+"_old"] = event - else: + elif !event.as_text().match("*Joy*"): keyboard[action] = event keyboard[action+"_old"] = event change_profile(current_profile_id) diff --git a/src/UserInterface/Screens/ControlsMenu/KeySelectMenu.gd b/src/UserInterface/Screens/ControlsMenu/KeySelectMenu.gd index 4ae097d..2110b73 100644 --- a/src/UserInterface/Screens/ControlsMenu/KeySelectMenu.gd +++ b/src/UserInterface/Screens/ControlsMenu/KeySelectMenu.gd @@ -1,22 +1,39 @@ extends Panel signal key_selected(scancode) +var prev_focus func _ready(): set_process_input(false) + + +func _process(delta: float) -> void: + $Prompt2.text = ("(ESC to cancel or wait: %s" % round($Timer.time_left)) + " sec)" func _input(event): if !event.is_pressed(): return if "scancode" in event && event.scancode == 16777217: - return + event = null emit_signal("key_selected", event) close() func open(): show() + $Timer.start() + prev_focus = get_focus_owner() + self.grab_focus() set_process_input(true) func close(): hide() + self.release_focus() + prev_focus.grab_focus() set_process_input(false) + +func close_on_timeout(): + hide() + self.release_focus() + prev_focus.grab_focus() + set_process_input(false) + emit_signal("key_selected", null) diff --git a/src/UserInterface/Screens/ControlsMenu/ReallyQuitMenu.gd b/src/UserInterface/Screens/ControlsMenu/ReallyQuitMenu.gd new file mode 100644 index 0000000..6a0546f --- /dev/null +++ b/src/UserInterface/Screens/ControlsMenu/ReallyQuitMenu.gd @@ -0,0 +1,18 @@ +extends Panel + +var prev_focus + +func _ready(): + set_process_input(false) + +func open(): + show() + prev_focus = get_focus_owner() + $SaveNQuit.grab_focus() + set_process_input(true) + +func close(): + hide() + self.release_focus() + prev_focus.grab_focus() + set_process_input(false) diff --git a/src/UserInterface/Screens/ControlsMenu/SaveAndQuitButton.gd b/src/UserInterface/Screens/ControlsMenu/SaveAndQuitButton.gd new file mode 100644 index 0000000..c190b85 --- /dev/null +++ b/src/UserInterface/Screens/ControlsMenu/SaveAndQuitButton.gd @@ -0,0 +1,16 @@ +extends Button + +onready var selected_screen_base_path: String = "res://src/UserInterface/Screens" +onready var mapper := $"%InputMapper" +export(String, FILE) var next_screen_path: = "" + +func _on_button_up() -> void: + mapper.commit_to_changes() + SaveManager.save_default() + yield(SignalManager, "savemanager_saved") + get_tree().change_scene(next_screen_path) + get_tree().get_current_scene().queue_free() + get_tree().paused = false + +func _get_configuration_warning() -> String: + return "next_scene_path must be set for the button to work" if next_screen_path == "" else "" diff --git a/src/UserInterface/Screens/ControlsMenu/SaveButton.gd b/src/UserInterface/Screens/ControlsMenu/SaveButton.gd index 84bdd8a..59eb4cf 100644 --- a/src/UserInterface/Screens/ControlsMenu/SaveButton.gd +++ b/src/UserInterface/Screens/ControlsMenu/SaveButton.gd @@ -5,3 +5,5 @@ onready var mapper := $"%InputMapper" func _on_button_up() -> void: mapper.commit_to_changes() SaveManager.save_default() + get_parent().changes_saved = true + get_parent().changes_made = false diff --git a/src/UserInterface/Screens/ControlsMenu/SavedCheckBackButton.gd b/src/UserInterface/Screens/ControlsMenu/SavedCheckBackButton.gd new file mode 100644 index 0000000..de3d395 --- /dev/null +++ b/src/UserInterface/Screens/ControlsMenu/SavedCheckBackButton.gd @@ -0,0 +1,15 @@ +extends Button + +export(String, FILE) var next_screen_path: = "" +onready var selected_screen_base_path: String = "res://src/UserInterface/Screens" + +func _on_button_up() -> void: + if(!get_parent().changes_made || get_parent().changes_saved): + get_tree().change_scene(next_screen_path) + get_tree().get_current_scene().queue_free() + get_tree().paused = false + else: + $"%ReallyQuitMenu".open() + +func _get_configuration_warning() -> String: + return "next_scene_path must be set for the button to work" if next_screen_path == "" else "" diff --git a/src/UserInterface/Screens/PauseScreen.tscn b/src/UserInterface/Screens/PauseScreen.tscn index 680a1d0..78ac0d9 100644 --- a/src/UserInterface/Screens/PauseScreen.tscn +++ b/src/UserInterface/Screens/PauseScreen.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=1] +[ext_resource path="res://src/Utilities/SignalManager.tscn" type="PackedScene" id=2] [ext_resource path="res://src/UserInterface/Buttons/ChangeSceneButton.tscn" type="PackedScene" id=3] [ext_resource path="res://src/UserInterface/Buttons/RetryButton.tscn" type="PackedScene" id=4] [ext_resource path="res://src/UserInterface/Screens/PauseScreen.gd" type="Script" id=5] @@ -14,6 +15,8 @@ mouse_filter = 2 theme = ExtResource( 1 ) script = ExtResource( 5 ) +[node name="SignalManager" parent="." instance=ExtResource( 2 )] + [node name="PauseOverlay" type="ColorRect" parent="."] visible = false anchor_right = 1.0 diff --git a/src/Utilities/SignalManager.gd b/src/Utilities/SignalManager.gd index 9fd2642..5aa1d0f 100644 --- a/src/Utilities/SignalManager.gd +++ b/src/Utilities/SignalManager.gd @@ -12,6 +12,7 @@ signal level_completed() signal power_up_collected(kind) signal got_stomped() signal unlocked(key) +signal savemanager_saved() func _on_Timer_timeout() -> void: emit_signal("getback_timer_up")