aboutsummaryrefslogtreecommitdiff
path: root/client/gui/overlays/debug/debug.gd
blob: 3a37a1b7b8bb9e95f9e9c7bb3f399207b3935a9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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"))