pause menu

This commit is contained in:
vengefulcartographer 2023-08-20 14:59:32 -06:00
parent 332e9e0066
commit 0f2f954930
12 changed files with 212 additions and 6 deletions

View File

@ -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")

View File

@ -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

View File

@ -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",

BIN
godot/UI/Exit.png (Stored with Git LFS) Normal file

Binary file not shown.

34
godot/UI/Exit.png.import Normal file
View File

@ -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

BIN
godot/UI/Pause.png (Stored with Git LFS) Normal file

Binary file not shown.

34
godot/UI/Pause.png.import Normal file
View File

@ -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

19
godot/UI/PauseMenu.gd Normal file
View File

@ -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()

68
godot/UI/PauseMenu.tscn Normal file
View File

@ -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"]

BIN
godot/UI/Play.png (Stored with Git LFS) Normal file

Binary file not shown.

34
godot/UI/Play.png.import Normal file
View File

@ -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

View File

@ -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"]