game: add menu
This commit is contained in:
@@ -12,7 +12,7 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
@onready var head = $Head
|
||||
@onready var camera = $Head/PlayerCamera
|
||||
@onready var player_debug = $Head/PlayerCamera/PlayerDebug
|
||||
@onready var overylay_fps = $Head/PlayerCamera/OverlayFPS
|
||||
@onready var overlay_fps = $Head/PlayerCamera/OverlayFPS
|
||||
@onready var player_stats = $PlayerStats
|
||||
@onready var anim_player = $AnimationPlayer
|
||||
@onready var muzzle_flash = $Head/PlayerCamera/pistol/MuzzleFlash
|
||||
@@ -41,7 +41,12 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
player_debug.visible = !player_debug.visible
|
||||
|
||||
if Input.is_action_just_pressed("overlay_fps"):
|
||||
overylay_fps.visible = true
|
||||
if !overlay_fps.visible:
|
||||
overlay_fps.visible = true
|
||||
elif !overlay_fps.advanced_output:
|
||||
overlay_fps.advanced_output = true
|
||||
else:
|
||||
overlay_fps.advanced_output = false
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not is_on_floor():
|
||||
|
13
game/main_menu.gd
Normal file
13
game/main_menu.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
extends Control
|
||||
|
||||
|
||||
func _on_play_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://world.tscn")
|
||||
|
||||
|
||||
func _on_options_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://options_menu.tscn")
|
||||
|
||||
|
||||
func _on_quit_pressed() -> void:
|
||||
get_tree().quit(0)
|
1
game/main_menu.gd.uid
Normal file
1
game/main_menu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bsx7nporxaoa6
|
36
game/main_menu.tscn
Normal file
36
game/main_menu.tscn
Normal file
@@ -0,0 +1,36 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://3pysj67x88uw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bsx7nporxaoa6" path="res://main_menu.gd" id="1_06t4h"]
|
||||
|
||||
[node name="MainMenu" 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_06t4h")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Play" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Play Game"
|
||||
|
||||
[node name="Options" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Options"
|
||||
|
||||
[node name="Quit" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Quit"
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Play" to="." method="_on_play_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Options" to="." method="_on_options_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Quit" to="." method="_on_quit_pressed"]
|
12
game/options_menu.gd
Normal file
12
game/options_menu.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends Control
|
||||
|
||||
|
||||
func _on_back_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://main_menu.tscn")
|
||||
|
||||
|
||||
func _on_check_button_toggled(toggled_on: bool) -> void:
|
||||
if toggled_on:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
else:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
1
game/options_menu.gd.uid
Normal file
1
game/options_menu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://csr3f6vfeqim8
|
34
game/options_menu.tscn
Normal file
34
game/options_menu.tscn
Normal file
@@ -0,0 +1,34 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://gu2cm1ekgftu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://csr3f6vfeqim8" path="res://options_menu.gd" id="1_lbr8e"]
|
||||
|
||||
[node name="OptionsMenu" 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_lbr8e")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Back" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Back"
|
||||
|
||||
[node name="CheckButton" type="CheckButton" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Fullscreen"
|
||||
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/Back" to="." method="_on_back_pressed"]
|
||||
[connection signal="toggled" from="MarginContainer/VBoxContainer/CheckButton" to="." method="_on_check_button_toggled"]
|
@@ -3,12 +3,20 @@ extends CanvasLayer
|
||||
@onready var text = $RichTextLabel
|
||||
@onready var timer = $Timer
|
||||
|
||||
var advanced_output: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
text.clear()
|
||||
text.add_text("FPS: %s" % Engine.get_frames_per_second())
|
||||
text.add_text("FPS: %s\n" % Engine.get_frames_per_second())
|
||||
if advanced_output:
|
||||
var res = DisplayServer.window_get_size()
|
||||
text.add_text("res: %sx%s\n" % [res.x, res.y])
|
||||
var device = RenderingServer.get_rendering_device()
|
||||
text.add_text("rendering_device: %s\n" % device.get_device_name())
|
||||
text.add_text("%s\n" % device.get_perf_report())
|
||||
|
||||
func _on_visibility_changed() -> void:
|
||||
if visible:
|
||||
|
@@ -219,12 +219,14 @@ script = ExtResource("5_2hs0m")
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -117.0
|
||||
offset_left = -1153.0
|
||||
offset_bottom = 40.0
|
||||
grow_horizontal = 0
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 0
|
||||
text = "FPS: 10.0"
|
||||
fit_content = true
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Timer" type="Timer" parent="Head/PlayerCamera/OverlayFPS"]
|
||||
wait_time = 0.5
|
||||
|
Reference in New Issue
Block a user