generated from krampus/template-godot4
Pause menu
This commit is contained in:
parent
5878a2efd5
commit
2517468b73
|
@ -170,6 +170,11 @@ debug_4={
|
||||||
"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":4194335,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"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":4194335,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
pause={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"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)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
[gd_resource type="Theme" load_steps=3 format=3 uid="uid://diodjft5u2cck"]
|
[gd_resource type="Theme" load_steps=5 format=3 uid="uid://diodjft5u2cck"]
|
||||||
|
|
||||||
[ext_resource type="FontFile" uid="uid://dsa0oh7c0h4pu" path="res://assets/fonts/Racing_Sans_One/RacingSansOne-Regular.ttf" id="1_3rv2b"]
|
[ext_resource type="FontFile" uid="uid://dsa0oh7c0h4pu" path="res://assets/fonts/Racing_Sans_One/RacingSansOne-Regular.ttf" id="1_3rv2b"]
|
||||||
[ext_resource type="FontFile" uid="uid://comihs66wounx" path="res://assets/fonts/Dokdo/Dokdo-Regular.ttf" id="1_eha6a"]
|
[ext_resource type="FontFile" uid="uid://comihs66wounx" path="res://assets/fonts/Dokdo/Dokdo-Regular.ttf" id="1_eha6a"]
|
||||||
|
[ext_resource type="FontFile" uid="uid://b6gxwgomstkgu" path="res://assets/fonts/Geo/Geo-Italic.ttf" id="2_5ty6u"]
|
||||||
|
[ext_resource type="FontFile" uid="uid://s4c1kf0rk2mb" path="res://assets/fonts/Geo/Geo-Regular.ttf" id="3_cee6l"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
default_font = ExtResource("3_cee6l")
|
||||||
|
default_font_size = 18
|
||||||
ClubSelectLabel/base_type = &"Label"
|
ClubSelectLabel/base_type = &"Label"
|
||||||
ClubSelectLabel/colors/font_color = Color(1, 0.933333, 0.894118, 1)
|
ClubSelectLabel/colors/font_color = Color(1, 0.933333, 0.894118, 1)
|
||||||
ClubSelectLabel/colors/font_outline_color = Color(0, 0, 0, 1)
|
ClubSelectLabel/colors/font_outline_color = Color(0, 0, 0, 1)
|
||||||
|
@ -17,6 +21,13 @@ ClubSelectLabelDisabled/base_type = &"ClubSelectLabel"
|
||||||
ClubSelectLabelDisabled/colors/font_color = Color(0.4, 0.3848, 0.376, 1)
|
ClubSelectLabelDisabled/colors/font_color = Color(0.4, 0.3848, 0.376, 1)
|
||||||
ClubSelectLabelDisabled/colors/font_outline_color = Color(0.2, 0.2, 0.2, 1)
|
ClubSelectLabelDisabled/colors/font_outline_color = Color(0.2, 0.2, 0.2, 1)
|
||||||
ClubSelectLabelDisabled/colors/font_shadow_color = Color(0.2, 0.2, 0.2, 1)
|
ClubSelectLabelDisabled/colors/font_shadow_color = Color(0.2, 0.2, 0.2, 1)
|
||||||
|
ClubSelectLabelDisabled/font_sizes/font_size = 84
|
||||||
|
ClubSelectLabelDisabled/fonts/font = ExtResource("1_3rv2b")
|
||||||
|
PauseMenuButton/base_type = &"Button"
|
||||||
|
PauseMenuButton/colors/font_outline_color = Color(0, 0, 0, 1)
|
||||||
|
PauseMenuButton/constants/outline_size = 6
|
||||||
|
PauseMenuButton/font_sizes/font_size = 32
|
||||||
|
PauseMenuButton/fonts/font = ExtResource("2_5ty6u")
|
||||||
ShotFeedback/base_type = &"RichTextLabel"
|
ShotFeedback/base_type = &"RichTextLabel"
|
||||||
ShotFeedback/colors/font_shadow_color = Color(0, 0, 0, 1)
|
ShotFeedback/colors/font_shadow_color = Color(0, 0, 0, 1)
|
||||||
ShotFeedback/constants/shadow_offset_x = 6
|
ShotFeedback/constants/shadow_offset_x = 6
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
extends Control
|
||||||
|
## Menu shown in-game when the user presses pause.
|
||||||
|
|
||||||
|
@onready var menu_list: VBoxContainer = %MenuList
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
|
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
|
|
||||||
|
func _unhandled_key_input(event: InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("pause"):
|
||||||
|
resume()
|
||||||
|
|
||||||
|
|
||||||
|
func _unhide() -> void:
|
||||||
|
menu_list.show()
|
||||||
|
|
||||||
|
|
||||||
|
func _hide() -> void:
|
||||||
|
menu_list.hide()
|
||||||
|
|
||||||
|
|
||||||
|
func resume() -> void:
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func settings() -> void:
|
||||||
|
pass # TODO
|
||||||
|
|
||||||
|
|
||||||
|
func quit() -> void:
|
||||||
|
get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)
|
|
@ -0,0 +1,68 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://byvjsvavbg5xe"]
|
||||||
|
|
||||||
|
[ext_resource type="FontFile" uid="uid://b6gxwgomstkgu" path="res://assets/fonts/Geo/Geo-Italic.ttf" id="1_4nw1f"]
|
||||||
|
[ext_resource type="Script" path="res://src/ui/menus/pause_menu/pause_menu.gd" id="1_rd0j2"]
|
||||||
|
|
||||||
|
[node name="PauseMenu" type="Control"]
|
||||||
|
process_mode = 3
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_rd0j2")
|
||||||
|
|
||||||
|
[node name="Shade" 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, 0.156863)
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 3
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
grow_vertical = 0
|
||||||
|
theme_override_constants/margin_right = 160
|
||||||
|
theme_override_constants/margin_bottom = 160
|
||||||
|
|
||||||
|
[node name="MenuList" type="VBoxContainer" parent="MarginContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="MarginContainer/MenuList"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||||
|
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||||
|
theme_override_constants/outline_size = 8
|
||||||
|
theme_override_fonts/font = ExtResource("1_4nw1f")
|
||||||
|
theme_override_font_sizes/font_size = 72
|
||||||
|
text = "Paused"
|
||||||
|
|
||||||
|
[node name="ResumeButton" type="Button" parent="MarginContainer/MenuList"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_type_variation = &"PauseMenuButton"
|
||||||
|
text = "Resume"
|
||||||
|
|
||||||
|
[node name="SettingsButton" type="Button" parent="MarginContainer/MenuList"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_type_variation = &"PauseMenuButton"
|
||||||
|
text = "Settings"
|
||||||
|
|
||||||
|
[node name="QuitButton" type="Button" parent="MarginContainer/MenuList"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_type_variation = &"PauseMenuButton"
|
||||||
|
theme_override_colors/font_color = Color(1, 0.36, 0.36, 1)
|
||||||
|
text = "Quit"
|
||||||
|
|
||||||
|
[connection signal="pressed" from="MarginContainer/MenuList/ResumeButton" to="." method="resume"]
|
||||||
|
[connection signal="pressed" from="MarginContainer/MenuList/SettingsButton" to="." method="settings"]
|
||||||
|
[connection signal="pressed" from="MarginContainer/MenuList/QuitButton" to="." method="quit"]
|
|
@ -499,7 +499,7 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
mouse_filter = 1
|
mouse_filter = 2
|
||||||
script = ExtResource("1_x5b4c")
|
script = ExtResource("1_x5b4c")
|
||||||
|
|
||||||
[node name="WoahNiceFeedback" type="RichTextLabel" parent="."]
|
[node name="WoahNiceFeedback" type="RichTextLabel" parent="."]
|
||||||
|
|
|
@ -1,8 +1,26 @@
|
||||||
class_name WorldUI extends Control
|
class_name WorldUI extends Control
|
||||||
## Container & accessor for the world UI.
|
## Container & accessor for the world UI.
|
||||||
|
|
||||||
|
@export var pause_scene := preload("res://src/ui/menus/pause_menu/pause_menu.tscn")
|
||||||
|
|
||||||
@onready var hud_container: Control = %HUDContainer
|
@onready var hud_container: Control = %HUDContainer
|
||||||
|
|
||||||
|
|
||||||
|
func _unhandled_key_input(event: InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("pause"):
|
||||||
|
pause()
|
||||||
|
|
||||||
|
|
||||||
func add_player_hud(hud: ShotHUD) -> void:
|
func add_player_hud(hud: ShotHUD) -> void:
|
||||||
hud_container.add_child(hud)
|
hud_container.add_child(hud)
|
||||||
|
|
||||||
|
|
||||||
|
func pause() -> void:
|
||||||
|
var menu := pause_scene.instantiate()
|
||||||
|
add_child(menu)
|
||||||
|
menu.tree_exiting.connect(_unpause)
|
||||||
|
get_tree().paused = true
|
||||||
|
|
||||||
|
|
||||||
|
func _unpause() -> void:
|
||||||
|
get_tree().paused = false
|
||||||
|
|
Loading…
Reference in New Issue