From 0f2f9549305ae9101414a18b6b1b1dd9776a4644 Mon Sep 17 00:00:00 2001 From: vengefulcartographer <76922012+vengefulcartographer@users.noreply.github.com> Date: Sun, 20 Aug 2023 14:59:32 -0600 Subject: [PATCH] pause menu --- godot/Level/Island.tscn | 2 + godot/Level/World/screen_shader.tscn | 2 + godot/Player.gd | 10 ++-- godot/UI/Exit.png | 3 ++ godot/UI/Exit.png.import | 34 ++++++++++++++ godot/UI/Pause.png | 3 ++ godot/UI/Pause.png.import | 34 ++++++++++++++ godot/UI/PauseMenu.gd | 19 ++++++++ godot/UI/PauseMenu.tscn | 68 ++++++++++++++++++++++++++++ godot/UI/Play.png | 3 ++ godot/UI/Play.png.import | 34 ++++++++++++++ godot/player.tscn | 6 ++- 12 files changed, 212 insertions(+), 6 deletions(-) create mode 100644 godot/UI/Exit.png create mode 100644 godot/UI/Exit.png.import create mode 100644 godot/UI/Pause.png create mode 100644 godot/UI/Pause.png.import create mode 100644 godot/UI/PauseMenu.gd create mode 100644 godot/UI/PauseMenu.tscn create mode 100644 godot/UI/Play.png create mode 100644 godot/UI/Play.png.import diff --git a/godot/Level/Island.tscn b/godot/Level/Island.tscn index 55e4f80..4cc095c 100644 --- a/godot/Level/Island.tscn +++ b/godot/Level/Island.tscn @@ -315,11 +315,13 @@ transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 1.40507, -2.10425) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.192051, 2.60275, 0) [node name="Ambiance" type="AudioStreamPlayer" parent="."] +process_mode = 3 stream = ExtResource("22_4tylf") volume_db = 7.0 autoplay = true [node name="Music" type="AudioStreamPlayer" parent="."] +process_mode = 3 volume_db = -5.0 script = ExtResource("22_2pcqg") diff --git a/godot/Level/World/screen_shader.tscn b/godot/Level/World/screen_shader.tscn index 73b14eb..06a5960 100644 --- a/godot/Level/World/screen_shader.tscn +++ b/godot/Level/World/screen_shader.tscn @@ -11,6 +11,7 @@ shader_parameter/grid = 5 shader_parameter/anim_period = 3.0 [node name="ScreenShader" type="CanvasLayer"] +process_mode = 1 [node name="ColorRect" type="ColorRect" parent="."] material = SubResource("ShaderMaterial_yagpk") @@ -19,3 +20,4 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +mouse_filter = 2 diff --git a/godot/Player.gd b/godot/Player.gd index b6e2589..26bcd10 100644 --- a/godot/Player.gd +++ b/godot/Player.gd @@ -15,6 +15,8 @@ var holding: WeakRef = weakref(null) # Get the gravity from the project settings to be synced with RigidBody nodes. var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") +@onready var pause_menu = $PauseMenu + func _ready(): Input.mouse_mode = Input.MOUSE_MODE_CAPTURED $CameraMount.global_rotation.x = clampf($CameraMount.global_rotation.x, deg_to_rad(LOWER_CAMERA_LIMIT), deg_to_rad(UPPER_CAMERA_LIMIT)) @@ -22,8 +24,8 @@ func _ready(): func _process(_delta): # Brings your mouse out of the window if you press escape. Add pause screen function here? - if Input.is_action_pressed("ui_cancel"): - Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + if Input.is_action_just_pressed("Pause"): + $PauseMenu.pause() var obj = holding.get_ref() if obj: @@ -39,6 +41,7 @@ func _process(_delta): func _input(event): + # Handle the rotation of the camera using mouse movement. if event is InputEventMouseMotion: rotate_y(deg_to_rad(-event.relative.x * horiz_sens)) @@ -58,9 +61,6 @@ func _input(event): $grape_man/pickup.play() $grape_man.pickup() - if Input.is_action_just_pressed("Pause"): - pass - if Input.is_action_just_pressed("Soundboard"): var sound_list = (["res://Sounds/jingle.ogg", diff --git a/godot/UI/Exit.png b/godot/UI/Exit.png new file mode 100644 index 0000000..a316c4a --- /dev/null +++ b/godot/UI/Exit.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28bb1f204ab7fa63d522d17b89063dbed46ce0b368520863a4304bfb1738ebb5 +size 535 diff --git a/godot/UI/Exit.png.import b/godot/UI/Exit.png.import new file mode 100644 index 0000000..deac20d --- /dev/null +++ b/godot/UI/Exit.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://hgb2ifbdpp3" +path="res://.godot/imported/Exit.png-26c1acde1a0bd151103ef1554a8e3af5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/Exit.png" +dest_files=["res://.godot/imported/Exit.png-26c1acde1a0bd151103ef1554a8e3af5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/godot/UI/Pause.png b/godot/UI/Pause.png new file mode 100644 index 0000000..e1857c0 --- /dev/null +++ b/godot/UI/Pause.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c64c7ad999e6788a67ac9357e67ec38ae770aef448e3a20171ddb8d250bb0c0 +size 476 diff --git a/godot/UI/Pause.png.import b/godot/UI/Pause.png.import new file mode 100644 index 0000000..bedbd9a --- /dev/null +++ b/godot/UI/Pause.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dw7ewvfwyxcq" +path="res://.godot/imported/Pause.png-90c47ed988bd7d26b746eb81a6aaeedf.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/Pause.png" +dest_files=["res://.godot/imported/Pause.png-90c47ed988bd7d26b746eb81a6aaeedf.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/godot/UI/PauseMenu.gd b/godot/UI/PauseMenu.gd new file mode 100644 index 0000000..70a914d --- /dev/null +++ b/godot/UI/PauseMenu.gd @@ -0,0 +1,19 @@ +extends Control + +var is_paused = false + +@onready var resume_button = $CenterContainer/HBoxContainer/ResumeButton +@onready var quit_button = $CenterContainer/HBoxContainer/QuitButton + +func unpause(): + self.hide() + get_tree().paused = false + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + +func pause(): + self.show() + get_tree().paused = true + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + +func quit(): + get_tree().quit() diff --git a/godot/UI/PauseMenu.tscn b/godot/UI/PauseMenu.tscn new file mode 100644 index 0000000..10c40f7 --- /dev/null +++ b/godot/UI/PauseMenu.tscn @@ -0,0 +1,68 @@ +[gd_scene load_steps=4 format=3 uid="uid://cbca7q18ae42h"] + +[ext_resource type="Script" path="res://UI/PauseMenu.gd" id="1_3puj1"] +[ext_resource type="Texture2D" uid="uid://dxxd258q3uomg" path="res://UI/Play.png" id="1_c4do0"] +[ext_resource type="Texture2D" uid="uid://hgb2ifbdpp3" path="res://UI/Exit.png" id="3_djmuk"] + +[node name="PauseMenu" type="Control"] +process_mode = 3 +z_index = 3 +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_3puj1") + +[node name="Background" type="ColorRect" parent="."] +z_index = -1 +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +color = Color(0.12549, 0.458824, 0.317647, 0.356863) + +[node name="CenterContainer" type="CenterContainer" 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 = -124.0 +offset_top = -74.0 +offset_right = 124.0 +offset_bottom = 74.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer"] +layout_mode = 2 +theme_override_constants/separation = 75 +alignment = 1 + +[node name="ResumeButton" type="Button" parent="CenterContainer/HBoxContainer"] +process_mode = 3 +layout_mode = 2 +text = " " +icon = ExtResource("1_c4do0") +flat = true +icon_alignment = 1 + +[node name="QuitButton" type="Button" parent="CenterContainer/HBoxContainer"] +process_mode = 3 +layout_mode = 2 +theme_override_constants/outline_size = 1 +theme_override_constants/h_separation = 0 +theme_override_constants/icon_max_width = 0 +text = " " +icon = ExtResource("3_djmuk") +flat = true +icon_alignment = 1 + +[connection signal="pressed" from="CenterContainer/HBoxContainer/ResumeButton" to="." method="unpause"] +[connection signal="pressed" from="CenterContainer/HBoxContainer/QuitButton" to="." method="quit"] diff --git a/godot/UI/Play.png b/godot/UI/Play.png new file mode 100644 index 0000000..3656552 --- /dev/null +++ b/godot/UI/Play.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ab3dba88cd32a47e2c6cbbae638fe627e18393a6aaf2649da87e94a004c3180 +size 460 diff --git a/godot/UI/Play.png.import b/godot/UI/Play.png.import new file mode 100644 index 0000000..7c647af --- /dev/null +++ b/godot/UI/Play.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dxxd258q3uomg" +path="res://.godot/imported/Play.png-eec0d54380d32c59b84e7db5fa226d5e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://UI/Play.png" +dest_files=["res://.godot/imported/Play.png-eec0d54380d32c59b84e7db5fa226d5e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/godot/player.tscn b/godot/player.tscn index 15436bd..576fad1 100644 --- a/godot/player.tscn +++ b/godot/player.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://7utef1nnena8"] +[gd_scene load_steps=7 format=3 uid="uid://7utef1nnena8"] [ext_resource type="Script" path="res://Player.gd" id="1_7gpdp"] [ext_resource type="PackedScene" uid="uid://bgoo1lbt28na" path="res://Models/grape_man.tscn" id="2_ctyy5"] [ext_resource type="Script" path="res://Holster.gd" id="3_a68da"] +[ext_resource type="PackedScene" uid="uid://cbca7q18ae42h" path="res://UI/PauseMenu.tscn" id="4_kcqpl"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_kb4ms"] radius = 0.0669067 @@ -37,6 +38,9 @@ script = ExtResource("3_a68da") transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0.0672282, 0) shape = SubResource("SphereShape3D_6l1w6") +[node name="PauseMenu" parent="." instance=ExtResource("4_kcqpl")] +visible = false + [connection signal="anim_check_grab" from="grape_man" to="." method="_on_grape_man_anim_check_grab"] [connection signal="body_entered" from="Holster/Area3D" to="." method="_on_holster_enter"] [connection signal="body_exited" from="Holster/Area3D" to="." method="_on_holster_exit"]