Add pause menu

This commit is contained in:
Jens Pitkänen 2024-08-18 19:06:01 +03:00
parent 5feb0513f3
commit 53ecb52f19
4 changed files with 67 additions and 6 deletions

27
interface/pause_menu.tscn Normal file
View File

@ -0,0 +1,27 @@
[gd_scene load_steps=2 format=3 uid="uid://c670g1qg5gaug"]
[ext_resource type="Script" path="res://scripts/PauseMenu.cs" id="1_p5jo3"]
[node name="PauseMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_p5jo3")
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Button" type="Button" parent="CenterContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 50
text = "Continue"
[connection signal="pressed" from="CenterContainer/Button" to="." method="Close"]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=111 format=4 uid="uid://8po7ftboqq4k"] [gd_scene load_steps=113 format=4 uid="uid://8po7ftboqq4k"]
[ext_resource type="CameraAttributesPhysical" uid="uid://cxyj2tvfksjl6" path="res://maps/hazy_env_camera_attrs.tres" id="1_r2j1d"] [ext_resource type="CameraAttributesPhysical" uid="uid://cxyj2tvfksjl6" path="res://maps/hazy_env_camera_attrs.tres" id="1_r2j1d"]
[ext_resource type="LightmapGIData" uid="uid://bp05p4yab2ukx" path="res://maps/demo.lmbake" id="2_2ehlo"] [ext_resource type="LightmapGIData" uid="uid://bp05p4yab2ukx" path="res://maps/demo.lmbake" id="2_2ehlo"]
@ -8,8 +8,10 @@
[ext_resource type="Material" uid="uid://cobb5bm4y7nk7" path="res://textures/steel.tres" id="6_gip8a"] [ext_resource type="Material" uid="uid://cobb5bm4y7nk7" path="res://textures/steel.tres" id="6_gip8a"]
[ext_resource type="Material" uid="uid://bpikku6t3gxi5" path="res://textures/white.tres" id="7_70h1h"] [ext_resource type="Material" uid="uid://bpikku6t3gxi5" path="res://textures/white.tres" id="7_70h1h"]
[ext_resource type="Material" uid="uid://dgf570wtqn17j" path="res://textures/steel_fence.tres" id="8_dovc4"] [ext_resource type="Material" uid="uid://dgf570wtqn17j" path="res://textures/steel_fence.tres" id="8_dovc4"]
[ext_resource type="PackedScene" uid="uid://b61birqrnbee3" path="res://prefabs/building_block_creator.tscn" id="9_w4r35"] [ext_resource type="Script" path="res://scripts/BuildingBlockCreator.cs" id="9_3oghc"]
[ext_resource type="PackedScene" uid="uid://wjbuh7jk50nm" path="res://prefabs/player.tscn" id="10_3xiy2"] [ext_resource type="PackedScene" uid="uid://wjbuh7jk50nm" path="res://scenes/player.tscn" id="10_3xiy2"]
[ext_resource type="PackedScene" uid="uid://c670g1qg5gaug" path="res://interface/pause_menu.tscn" id="11_lav3p"]
[ext_resource type="Material" uid="uid://bq5oqyuwekryv" path="res://textures/building_block.tres" id="11_riqpg"]
[sub_resource type="ArrayMesh" id="ArrayMesh_kaiip"] [sub_resource type="ArrayMesh" id="ArrayMesh_kaiip"]
lightmap_size_hint = Vector2i(1030, 566) lightmap_size_hint = Vector2i(1030, 566)
@ -1019,9 +1021,11 @@ shape = SubResource("ConvexPolygonShape3D_ldbum")
[node name="entity_17_brush_6_collision_shape" type="CollisionShape3D" parent="FuncGodotMap/entity_17_func_buildingblock"] [node name="entity_17_brush_6_collision_shape" type="CollisionShape3D" parent="FuncGodotMap/entity_17_func_buildingblock"]
shape = SubResource("ConvexPolygonShape3D_i1n6v") shape = SubResource("ConvexPolygonShape3D_i1n6v")
[node name="BuildingBlockCreator" parent="." node_paths=PackedStringArray("TrenchbroomMap") instance=ExtResource("9_w4r35")] [node name="BuildingBlockCreator" type="Node3D" parent="." node_paths=PackedStringArray("TrenchbroomMap")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, -7.84902) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, -7.84902)
script = ExtResource("9_3oghc")
TrenchbroomMap = NodePath("../FuncGodotMap") TrenchbroomMap = NodePath("../FuncGodotMap")
BuildingBlockMaterial = ExtResource("11_riqpg")
[node name="ReflectionProbes" type="Node3D" parent="."] [node name="ReflectionProbes" type="Node3D" parent="."]
@ -1054,3 +1058,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0415039, 58.3319, 0.0198975
size = Vector3(43.3174, 26.5295, 43.4319) size = Vector3(43.3174, 26.5295, 43.4319)
[node name="Player" parent="." instance=ExtResource("10_3xiy2")] [node name="Player" parent="." instance=ExtResource("10_3xiy2")]
[node name="PauseMenu" parent="." instance=ExtResource("11_lav3p")]

View File

@ -1,6 +1,4 @@
using System.Collections.Generic;
using Godot; using Godot;
using Godot.Collections;
namespace Gmtk24 { namespace Gmtk24 {
public partial class BuildingBlockCreator : Node3D { public partial class BuildingBlockCreator : Node3D {

30
scripts/PauseMenu.cs Normal file
View File

@ -0,0 +1,30 @@
using Godot;
namespace Gmtk24 {
public partial class PauseMenu : Control {
private Vector2 SavedMousePosition = Vector2.Zero;
public override void _Ready() {
Close();
}
public override void _Input(InputEvent @event) {
if (@event is InputEventKey keyEvent) {
if (keyEvent.Keycode == Key.Escape) {
Open();
}
}
}
public void Open() {
Visible = true;
Input.MouseMode = Input.MouseModeEnum.Visible;
SavedMousePosition = GetLocalMousePosition();
}
public void Close() {
Input.MouseMode = Input.MouseModeEnum.Captured;
Visible = false;
}
}
}