diff options
author | metamuffin <metamuffin@disroot.org> | 2025-09-21 20:19:24 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-09-21 20:19:27 +0200 |
commit | a8dc30e49bdc1cb1befcebdcb247638ddec553ba (patch) | |
tree | 82be1aa97a9af286116d4b517f2c7a0517e68097 /client/gui/overlays | |
parent | 37cfee01938dd5a0b554e220253d5f844bbdf590 (diff) | |
download | hurrycurry-a8dc30e49bdc1cb1befcebdcb247638ddec553ba.tar hurrycurry-a8dc30e49bdc1cb1befcebdcb247638ddec553ba.tar.bz2 hurrycurry-a8dc30e49bdc1cb1befcebdcb247638ddec553ba.tar.zst |
Refactor debug overlay, add keybind
Diffstat (limited to 'client/gui/overlays')
-rw-r--r-- | client/gui/overlays/debug.gd | 39 | ||||
-rw-r--r-- | client/gui/overlays/debug.gd.uid | 1 | ||||
-rw-r--r-- | client/gui/overlays/debug.tscn | 13 | ||||
-rw-r--r-- | client/gui/overlays/overlays.tscn | 8 |
4 files changed, 60 insertions, 1 deletions
diff --git a/client/gui/overlays/debug.gd b/client/gui/overlays/debug.gd new file mode 100644 index 00000000..bb978ad8 --- /dev/null +++ b/client/gui/overlays/debug.gd @@ -0,0 +1,39 @@ +# Hurry Curry! - a game about cooking +# Copyright (C) 2025 Hurry Curry! contributors +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +extends RichTextLabel + +func _ready(): + Settings.hook_changed_init("graphics.debug_info", false, func (v): + visible = v + RenderingServer.viewport_set_measure_render_time(get_viewport().get_viewport_rid(), visible) + ) + +func _process(_delta): + if not visible: return + var t = "" + t += "Renderer: %s (%s)\n" % [RenderingServer.get_current_rendering_driver_name(), RenderingServer.get_video_adapter_name()] + t += "Timing: %.01fms CPU; %.01fms GPU\n" % [ + RenderingServer.viewport_get_measured_render_time_cpu(get_viewport().get_viewport_rid()), + RenderingServer.viewport_get_measured_render_time_gpu(get_viewport().get_viewport_rid()) + ] + t += "Resolution: %dx%d\n" % [get_tree().root.size.x, get_tree().root.size.y] + t += "FPS: %d\n" % Engine.get_frames_per_second() + t += "Node count: %d\n" % get_tree().get_node_count() + text = t + +func _input(_event): + if Input.is_action_just_pressed("toggle_debug"): + Settings.write("graphics.debug_info", not Settings.read("graphics.debug_info")) diff --git a/client/gui/overlays/debug.gd.uid b/client/gui/overlays/debug.gd.uid new file mode 100644 index 00000000..318ab745 --- /dev/null +++ b/client/gui/overlays/debug.gd.uid @@ -0,0 +1 @@ +uid://bpmdfuqjtwf5v diff --git a/client/gui/overlays/debug.tscn b/client/gui/overlays/debug.tscn new file mode 100644 index 00000000..3de36e94 --- /dev/null +++ b/client/gui/overlays/debug.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=2 format=3 uid="uid://3lytexnfrub6"] + +[ext_resource type="Script" uid="uid://bpmdfuqjtwf5v" path="res://gui/overlays/debug.gd" id="1_62otr"] + +[node name="Debug" type="RichTextLabel"] +visible = false +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +script = ExtResource("1_62otr") diff --git a/client/gui/overlays/overlays.tscn b/client/gui/overlays/overlays.tscn index 67f1082f..cf1df985 100644 --- a/client/gui/overlays/overlays.tscn +++ b/client/gui/overlays/overlays.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://cr26jennm5c0c"] +[gd_scene load_steps=9 format=3 uid="uid://cr26jennm5c0c"] [ext_resource type="Script" uid="uid://bkvtm1jlme6jf" path="res://gui/overlays/overlays.gd" id="1_dcvak"] [ext_resource type="PackedScene" uid="uid://xcxbmynn8mhi" path="res://gui/overlays/chat.tscn" id="1_n4uhr"] @@ -7,6 +7,7 @@ [ext_resource type="PackedScene" uid="uid://bc50la65ntifb" path="res://gui/overlays/lobby/lobby.tscn" id="4_jwd7s"] [ext_resource type="PackedScene" uid="uid://c7pykhpdhgs64" path="res://gui/overlays/announce_title.tscn" id="5_whygm"] [ext_resource type="PackedScene" uid="uid://b21nrnkygiyjt" path="res://gui/overlays/popup_message/popup_message.tscn" id="7_jwd7s"] +[ext_resource type="PackedScene" uid="uid://3lytexnfrub6" path="res://gui/overlays/debug.tscn" id="8_8ouu3"] [node name="Overlays" type="Control"] layout_mode = 3 @@ -39,3 +40,8 @@ grow_vertical = 2 [node name="PopupMessage" parent="." instance=ExtResource("7_jwd7s")] layout_mode = 1 + +[node name="Debug" parent="." instance=ExtResource("8_8ouu3")] +layout_mode = 1 +text = "Text of the +debug overlay" |