diff options
Diffstat (limited to 'client/gui/overlays/debug/debug.gd')
-rw-r--r-- | client/gui/overlays/debug/debug.gd | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/client/gui/overlays/debug/debug.gd b/client/gui/overlays/debug/debug.gd new file mode 100644 index 00000000..3a37a1b7 --- /dev/null +++ b/client/gui/overlays/debug/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", "main", 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")) |