fixed some bugs The Typening caused
This commit is contained in:
50
Scenes/Menus/PauseMenu/pause_menu.gd
Normal file
50
Scenes/Menus/PauseMenu/pause_menu.gd
Normal file
@ -0,0 +1,50 @@
|
||||
class_name PauseMenu extends Control
|
||||
|
||||
signal closed()
|
||||
|
||||
var options_menu_scene: PackedScene = preload("res://Scenes/Menus/options_menu.tscn")
|
||||
var confirmation_popup_scene: PackedScene = preload("res://Scenes/Menus/confirmation_popup.tscn")
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("Pause"):
|
||||
accept_event()
|
||||
_on_resume_pressed()
|
||||
|
||||
|
||||
func _on_resume_pressed() -> void:
|
||||
closed.emit()
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_options_pressed() -> void:
|
||||
var menu: OptionsMenu = options_menu_scene.instantiate()
|
||||
add_child(menu)
|
||||
|
||||
|
||||
func _on_quit_to_main_menu_pressed() -> void:
|
||||
var popup: ConfirmationPopup = confirmation_popup_scene.instantiate() as ConfirmationPopup
|
||||
popup.set_popup("Are you sure you want to quit and return to main menu?", "Yes", "No")
|
||||
popup.completed.connect(return_to_menu)
|
||||
add_child(popup)
|
||||
|
||||
|
||||
func return_to_menu(confirmation: bool) -> void:
|
||||
if confirmation:
|
||||
Game.scene_switch_main_menu()
|
||||
|
||||
|
||||
func _on_quit_to_desktop_pressed() -> void:
|
||||
var popup: ConfirmationPopup = confirmation_popup_scene.instantiate() as ConfirmationPopup
|
||||
popup.set_popup("Are you sure you want to quit?", "Yes", "No")
|
||||
popup.completed.connect(quit_game)
|
||||
add_child(popup)
|
||||
|
||||
|
||||
func quit_game(confirmation: bool) -> void:
|
||||
if confirmation:
|
||||
Game.quit_to_desktop()
|
||||
|
||||
|
||||
func _on_button_mouse_entered() -> void:
|
||||
$AudioStreamPlayer.play()
|
76
Scenes/Menus/PauseMenu/pause_menu.tscn
Normal file
76
Scenes/Menus/PauseMenu/pause_menu.tscn
Normal file
@ -0,0 +1,76 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://buvgdem68wtev"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://b6a0ip4p72tgx" path="res://new_theme.tres" id="1_gaupv"]
|
||||
[ext_resource type="Script" path="res://Scenes/Menus/PauseMenu/pause_menu.gd" id="2_4pn2l"]
|
||||
[ext_resource type="AudioStream" uid="uid://dknygn5eyuhxt" path="res://shot1.wav" id="3_q3xhn"]
|
||||
|
||||
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_n6ixr"]
|
||||
random_pitch = 1.1
|
||||
streams_count = 1
|
||||
stream_0/stream = ExtResource("3_q3xhn")
|
||||
stream_0/weight = 1.0
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_gaupv")
|
||||
script = ExtResource("2_4pn2l")
|
||||
|
||||
[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.278431, 0.278431, 0.278431, 0.545098)
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Resume" type="Button" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Resume"
|
||||
|
||||
[node name="Options" type="Button" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Options"
|
||||
|
||||
[node name="QuitToMainMenu" type="Button" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Quit to main menu"
|
||||
|
||||
[node name="QuitToDesktop" type="Button" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Quit to desktop"
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
stream = SubResource("AudioStreamRandomizer_n6ixr")
|
||||
bus = &"SFX"
|
||||
|
||||
[connection signal="mouse_entered" from="PanelContainer/VBoxContainer/Resume" to="." method="_on_button_mouse_entered"]
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/Resume" to="." method="_on_resume_pressed"]
|
||||
[connection signal="mouse_entered" from="PanelContainer/VBoxContainer/Options" to="." method="_on_button_mouse_entered"]
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/Options" to="." method="_on_options_pressed"]
|
||||
[connection signal="mouse_entered" from="PanelContainer/VBoxContainer/QuitToMainMenu" to="." method="_on_button_mouse_entered"]
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/QuitToMainMenu" to="." method="_on_quit_to_main_menu_pressed"]
|
||||
[connection signal="mouse_entered" from="PanelContainer/VBoxContainer/QuitToDesktop" to="." method="_on_button_mouse_entered"]
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/QuitToDesktop" to="." method="_on_quit_to_desktop_pressed"]
|
Reference in New Issue
Block a user