Added pause menu

This commit is contained in:
2026-01-07 02:48:07 +03:00
parent a23d8ccff7
commit cd0476d9be
7 changed files with 111 additions and 3 deletions
+36
View File
@@ -0,0 +1,36 @@
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 _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:
get_tree().paused = false
hide()
func _on_main_menu_button_pressed() -> void:
get_tree().paused = false
get_tree().change_scene_to_file("res://game/menu/main_menu.tscn")
func _on_visibility_changed() -> void:
if visible:
if continue_button != null:
continue_button.grab_focus()
+1
View File
@@ -0,0 +1 @@
uid://cvw5egmj1f62u
+51
View File
@@ -0,0 +1,51 @@
[gd_scene load_steps=3 format=3 uid="uid://dsts4y32slhnc"]
[ext_resource type="Theme" uid="uid://bh56my8b2htnr" path="res://themes/menu.tres" id="1_i4rg2"]
[ext_resource type="Script" uid="uid://cvw5egmj1f62u" path="res://game/menu/pause_menu.gd" id="2_e1jsn"]
[node name="PauseMenu" type="Control"]
process_mode = 2
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="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
[node name="MarginContainer" type="MarginContainer" parent="."]
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"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="ContinueButton" type="Button" parent="MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Continue"
[node name="MainMenuButton" type="Button" parent="MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Main menu"
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[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"]