Added pause menu

This commit is contained in:
2026-06-27 18:25:21 +03:00
parent 071c4c16e4
commit 8beea1aac7
5 changed files with 101 additions and 0 deletions
+1
View File
@@ -6,6 +6,7 @@
[ext_resource type="AudioStream" uid="uid://cfb2adf5hft7b" path="res://sound/ui/select.wav" id="4_0i6kl"]
[node name="SoundManager" type="Node" unique_id=1576371552]
process_mode = 3
script = ExtResource("1_cg0sy")
player_count_ui = 8
player_count_sfx = 32
+53
View File
@@ -0,0 +1,53 @@
class_name PauseMenu
extends Control
@onready var continue_button : Button = $%ContinueButton
@onready var main_menu_button : Button = $%MainMenuButton
func _ready() -> void:
_init_focus()
_setup_neighbors()
func _on_gui_focus_changed(_node: Control) -> void:
SoundManager.play_ui_stream(SoundManager.ui_stream_select)
func _input(event: InputEvent) -> void:
if not visible: return
if event.is_action_pressed("pause"):
_on_continue_button_pressed.call_deferred()
func _init_focus() -> void:
continue_button.grab_focus()
func _setup_neighbors() -> void:
continue_button.focus_neighbor_top = main_menu_button.get_path()
main_menu_button.focus_neighbor_bottom = continue_button.get_path()
func _on_continue_button_pressed() -> void:
SoundManager.play_ui_stream(SoundManager.ui_stream_decline)
get_tree().paused = false
hide()
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
func _on_main_menu_button_pressed() -> void:
SoundManager.play_ui_stream(SoundManager.ui_stream_accept)
get_tree().paused = false
get_tree().change_scene_to_file("res://game/menu/main_menu.tscn")
func _on_visibility_changed() -> void:
if not is_node_ready(): return
if visible:
continue_button.grab_focus()
get_viewport().gui_focus_changed.connect(_on_gui_focus_changed)
elif get_viewport().gui_focus_changed.is_connected(_on_gui_focus_changed):
get_viewport().gui_focus_changed.disconnect(_on_gui_focus_changed)
+1
View File
@@ -0,0 +1 @@
uid://b45v44jhm26oj
+40
View File
@@ -0,0 +1,40 @@
[gd_scene format=3 uid="uid://0e3xvmn36j5b"]
[ext_resource type="Theme" uid="uid://bqj884yfvhhft" path="res://game/themes/main_menu.tres" id="1_i4rg2"]
[ext_resource type="Script" uid="uid://b45v44jhm26oj" path="res://game/menu/pause_menu.gd" id="2_e1jsn"]
[node name="PauseMenu" type="Control" unique_id=1815975678]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_i4rg2")
script = ExtResource("2_e1jsn")
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=2013458760]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer" unique_id=25712220]
layout_mode = 2
size_flags_horizontal = 4
alignment = 1
[node name="ContinueButton" type="Button" parent="MarginContainer/VBoxContainer" unique_id=220798833]
unique_name_in_owner = true
layout_mode = 2
text = "CONTINUE"
[node name="MainMenuButton" type="Button" parent="MarginContainer/VBoxContainer" unique_id=349343230]
unique_name_in_owner = true
layout_mode = 2
text = "MAIN MENU"
[connection signal="pressed" from="MarginContainer/VBoxContainer/ContinueButton" to="." method="_on_continue_button_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/MainMenuButton" to="." method="_on_main_menu_button_pressed"]
+6
View File
@@ -106,6 +106,12 @@ attack={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":true,"script":null)
]
}
pause={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
]
}
[physics]