updates
This commit is contained in:
parent
276d43613d
commit
4298caf5cb
552 changed files with 42990 additions and 776 deletions
266
addons/GD-Sync/UI/Profiler/GDSyncProfiler.gd
Normal file
266
addons/GD-Sync/UI/Profiler/GDSyncProfiler.gd
Normal file
|
|
@ -0,0 +1,266 @@
|
|||
@tool
|
||||
extends Control
|
||||
|
||||
#Copyright (c) 2023-present GD-Sync.
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source form, with or without modification,
|
||||
#are permitted provided that the following conditions are met:
|
||||
#
|
||||
#1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
#2. Neither the name of GD-Sync nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific
|
||||
# prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
#EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
#OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
#SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
#TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
#ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
#SUCH DAMAGE.
|
||||
|
||||
signal stats_updated(client_id : int, stats : Dictionary)
|
||||
signal custom_data_updated(data : Dictionary)
|
||||
signal message_details_updated(details : Dictionary)
|
||||
signal client_joined(client_id : int)
|
||||
signal client_left(client_id : int)
|
||||
signal ping_measured(client_id : int, ping : float, perceived_ping : float)
|
||||
signal start_monitoring_connections
|
||||
signal stop_monitoring_connections
|
||||
signal artificial_latency_changed(latency_ms : int)
|
||||
signal profiler_cleared()
|
||||
signal profiler_started()
|
||||
signal profiler_stopped()
|
||||
|
||||
@export var start_button : Button = null : set = _set_start_button
|
||||
@export var stop_button : Button = null : set = _set_stop_button
|
||||
|
||||
var auto_start : bool = false
|
||||
var artificial_latency_ms : int = 0
|
||||
|
||||
var valid_session : bool = false
|
||||
var global_stats : Dictionary = {
|
||||
"up":0,"down":0,"pkts_up":0,"pkts_down":0,
|
||||
"up_sec":0.0,"down_sec":0.0,"pkts_up_sec":0.0,"pkts_down_sec":0.0,
|
||||
"avg_msg_up":0.0,"avg_msg_down":0.0,"avg_msg_up_sec":0.0,"avg_msg_down_sec":0.0,
|
||||
"last":0.0,"hist":[],
|
||||
"total_sec": 0.0
|
||||
}
|
||||
var client_stats : Dictionary = {}
|
||||
var custom_data : Dictionary = {}
|
||||
var message_details_up : Dictionary = {}
|
||||
var message_details_down : Dictionary = {}
|
||||
var last_details_emit : float = 0.0
|
||||
const DETAILS_EMIT_INTERVAL : float = 5.0
|
||||
|
||||
func _ready() -> void:
|
||||
stop()
|
||||
clear()
|
||||
invalidate_session()
|
||||
_update_button_states()
|
||||
|
||||
func _on_auto_start_toggled(toggled_on: bool) -> void:
|
||||
auto_start = true
|
||||
|
||||
func _on_artificial_latency_changed(value : float) -> void:
|
||||
artificial_latency_ms = int(value)
|
||||
artificial_latency_changed.emit(artificial_latency_ms)
|
||||
|
||||
func _set_start_button(btn) -> void:
|
||||
start_button = btn
|
||||
_update_button_states()
|
||||
|
||||
func _set_stop_button(btn) -> void:
|
||||
stop_button = btn
|
||||
_update_button_states()
|
||||
|
||||
func _update_button_states() -> void:
|
||||
if start_button:
|
||||
start_button.disabled = is_processing() or !valid_session
|
||||
if stop_button:
|
||||
stop_button.disabled = !is_processing() or !valid_session
|
||||
|
||||
func start() -> void:
|
||||
if is_processing(): return
|
||||
set_process(true)
|
||||
profiler_started.emit()
|
||||
_update_button_states()
|
||||
|
||||
func stop() -> void:
|
||||
if not is_processing(): return
|
||||
set_process(false)
|
||||
profiler_stopped.emit()
|
||||
_update_button_states()
|
||||
|
||||
func clear() -> void:
|
||||
global_stats = {
|
||||
"up":0,"down":0,"pkts_up":0,"pkts_down":0,
|
||||
"up_sec":0.0,"down_sec":0.0,"pkts_up_sec":0.0,"pkts_down_sec":0.0,
|
||||
"avg_msg_up":0.0,"avg_msg_down":0.0,"avg_msg_up_sec":0.0,"avg_msg_down_sec":0.0,
|
||||
"last":0.0,"hist":[],
|
||||
"total_sec": 0.0
|
||||
}
|
||||
client_stats.clear()
|
||||
custom_data.clear()
|
||||
message_details_up.clear()
|
||||
message_details_down.clear()
|
||||
last_details_emit = 0.0
|
||||
profiler_cleared.emit()
|
||||
custom_data_updated.emit(custom_data)
|
||||
message_details_updated.emit({"up": {}, "down": {}})
|
||||
|
||||
func validate_session() -> void:
|
||||
valid_session = true
|
||||
_update_button_states()
|
||||
|
||||
func invalidate_session() -> void:
|
||||
valid_session = false
|
||||
_update_button_states()
|
||||
|
||||
func game_started() -> void:
|
||||
if auto_start:
|
||||
start()
|
||||
|
||||
func register_transfer_usage(client_id : int, origin : Dictionary, byte_count : int, upload : bool, details : String) -> void:
|
||||
if client_id <= 0: return
|
||||
var dir = "up" if upload else "down"
|
||||
var pkt_key = "pkts_" + dir
|
||||
global_stats[dir] += byte_count
|
||||
global_stats[pkt_key] += 1
|
||||
var c = client_stats.get(client_id, {
|
||||
"up":0,"down":0,"pkts_up":0,"pkts_down":0,
|
||||
"up_sec":0.0,"down_sec":0.0,"pkts_up_sec":0.0,"pkts_down_sec":0.0,
|
||||
"avg_msg_up":0.0,"avg_msg_down":0.0,"avg_msg_up_sec":0.0,"avg_msg_down_sec":0.0,
|
||||
"last":0.0,"hist":[],
|
||||
"total_sec": 0.0
|
||||
})
|
||||
c[dir] += byte_count
|
||||
c[pkt_key] += 1
|
||||
client_stats[client_id] = c
|
||||
|
||||
var key = "%s-%s-%s" % [origin.get("type", ""), origin.get("object", ""), origin.get("target", "")]
|
||||
if key == "--":
|
||||
return
|
||||
|
||||
var details_dict = message_details_up if upload else message_details_down
|
||||
var entry = details_dict.get(key, {
|
||||
"type": origin.get("type", ""),
|
||||
"object": origin.get("object", ""),
|
||||
"target": origin.get("target", ""),
|
||||
"count": 0,
|
||||
"total_bytes": 0,
|
||||
"avg_bytes": 0.0,
|
||||
"percent": 0.0,
|
||||
"last_details": []
|
||||
})
|
||||
entry.count += 1
|
||||
entry.total_bytes += byte_count
|
||||
entry.avg_bytes = entry.total_bytes / entry.count
|
||||
|
||||
entry.last_details.append(details)
|
||||
if entry.last_details.size() > 3:
|
||||
entry.last_details.pop_front()
|
||||
|
||||
details_dict[key] = entry
|
||||
|
||||
func register_custom_data(data : Dictionary) -> void:
|
||||
for key in data.keys():
|
||||
custom_data[key] = data[key]
|
||||
custom_data_updated.emit(custom_data)
|
||||
|
||||
func _process(_delta):
|
||||
var now = Time.get_ticks_msec() / 1000.0
|
||||
if now - global_stats.last >= 1.0:
|
||||
_update_rates(global_stats, now)
|
||||
_update_rates_all_clients(now)
|
||||
_emit_all()
|
||||
global_stats.last = now
|
||||
|
||||
if now - last_details_emit >= DETAILS_EMIT_INTERVAL:
|
||||
_update_message_percentages()
|
||||
var combined = {
|
||||
"up": message_details_up.duplicate(),
|
||||
"down": message_details_down.duplicate()
|
||||
}
|
||||
message_details_updated.emit(combined)
|
||||
last_details_emit = now
|
||||
|
||||
func _update_message_percentages() -> void:
|
||||
_update_percentages_for(message_details_up)
|
||||
_update_percentages_for(message_details_down)
|
||||
|
||||
func _update_percentages_for(dict : Dictionary) -> void:
|
||||
var total_bytes : int = 0
|
||||
for key in dict.keys():
|
||||
total_bytes += dict[key].total_bytes
|
||||
if total_bytes == 0:
|
||||
for key in dict.keys():
|
||||
dict[key].percent = 0.0
|
||||
else:
|
||||
for key in dict.keys():
|
||||
var entry = dict[key]
|
||||
entry.percent = (entry.total_bytes as float / total_bytes) * 100.0
|
||||
dict[key] = entry
|
||||
|
||||
func _update_rates(stats : Dictionary, now : float) -> void:
|
||||
var h = stats.hist
|
||||
h.append({
|
||||
"t":now,
|
||||
"up":stats.up,"down":stats.down,
|
||||
"pkts_up":stats.pkts_up,"pkts_down":stats.pkts_down
|
||||
})
|
||||
while h.size() > 0 and now - h[0].t > 5.0:
|
||||
h.pop_front()
|
||||
if h.size() < 2:
|
||||
stats.up_sec = 0.0
|
||||
stats.down_sec = 0.0
|
||||
stats.pkts_up_sec = 0.0
|
||||
stats.pkts_down_sec = 0.0
|
||||
stats.avg_msg_up = 0.0
|
||||
stats.avg_msg_down = 0.0
|
||||
stats.avg_msg_up_sec = 0.0
|
||||
stats.avg_msg_down_sec = 0.0
|
||||
stats.total_sec = 0.0
|
||||
return
|
||||
var first = h[0]
|
||||
var last = h[-1]
|
||||
var dt = last.t - first.t
|
||||
if dt <= 0.0:
|
||||
stats.up_sec = 0.0
|
||||
stats.down_sec = 0.0
|
||||
stats.pkts_up_sec = 0.0
|
||||
stats.pkts_down_sec = 0.0
|
||||
stats.avg_msg_up_sec = 0.0
|
||||
stats.avg_msg_down_sec = 0.0
|
||||
stats.total_sec = 0.0
|
||||
return
|
||||
var delta_up = last.up - first.up
|
||||
var delta_down = last.down - first.down
|
||||
var delta_pkts_up = last.pkts_up - first.pkts_up
|
||||
var delta_pkts_down = last.pkts_down - first.pkts_down
|
||||
stats.up_sec = delta_up / dt
|
||||
stats.down_sec = delta_down / dt
|
||||
stats.pkts_up_sec = delta_pkts_up / dt
|
||||
stats.pkts_down_sec = delta_pkts_down / dt
|
||||
stats.avg_msg_up_sec = delta_up / delta_pkts_up if delta_pkts_up > 0 else 0.0
|
||||
stats.avg_msg_down_sec = delta_down / delta_pkts_down if delta_pkts_down > 0 else 0.0
|
||||
var total_pkts_up = stats.pkts_up
|
||||
var total_pkts_down = stats.pkts_down
|
||||
stats.avg_msg_up = stats.up / total_pkts_up if total_pkts_up > 0 else 0.0
|
||||
stats.avg_msg_down = stats.down / total_pkts_down if total_pkts_down > 0 else 0.0
|
||||
stats.total_sec = stats.up_sec + stats.down_sec
|
||||
|
||||
func _update_rates_all_clients(now : float) -> void:
|
||||
for cid in client_stats.keys():
|
||||
_update_rates(client_stats[cid], now)
|
||||
|
||||
func _emit_all() -> void:
|
||||
stats_updated.emit(-1, global_stats)
|
||||
for cid in client_stats.keys():
|
||||
stats_updated.emit(cid, client_stats[cid])
|
||||
1
addons/GD-Sync/UI/Profiler/GDSyncProfiler.gd.uid
Normal file
1
addons/GD-Sync/UI/Profiler/GDSyncProfiler.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c00gfpya5uiw0
|
||||
810
addons/GD-Sync/UI/Profiler/GDSyncProfiler.tscn
Normal file
810
addons/GD-Sync/UI/Profiler/GDSyncProfiler.tscn
Normal file
|
|
@ -0,0 +1,810 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://c3udn6jwoy6an"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c00gfpya5uiw0" path="res://addons/GD-Sync/UI/Profiler/GDSyncProfiler.gd" id="1_ysct5"]
|
||||
[ext_resource type="Script" uid="uid://b3p26nyamgl8j" path="res://addons/GD-Sync/UI/Profiler/ProfilerLabel.gd" id="2_5m75r"]
|
||||
[ext_resource type="Script" uid="uid://8618gttywoy6" path="res://addons/GD-Sync/UI/Profiler/ProfilerGraph.gd" id="3_hrjsf"]
|
||||
[ext_resource type="Script" uid="uid://4b1i1ihfsqdf" path="res://addons/GD-Sync/UI/Profiler/ProfilerDetailsDisplay.gd" id="4_bk6j0"]
|
||||
[ext_resource type="Script" uid="uid://frgb8qcxxcoj" path="res://addons/GD-Sync/UI/Profiler/ProfilerConnectionMonitor.gd" id="4_gnjya"]
|
||||
|
||||
[node name="GDSyncProfiler" type="Control" node_paths=PackedStringArray("start_button", "stop_button")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_ysct5")
|
||||
start_button = NodePath("VBoxContainer/HBoxContainer/Start")
|
||||
stop_button = NodePath("VBoxContainer/HBoxContainer/Stop")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "GD-Sync Network Profiler"
|
||||
|
||||
[node name="VSeparator" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Start" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Start Profiler"
|
||||
|
||||
[node name="Stop" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Stop Profiler"
|
||||
|
||||
[node name="Clear" type="Button" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Clear Profiler"
|
||||
|
||||
[node name="VSeparator2" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="AutoStart" type="CheckButton" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Auto Start"
|
||||
|
||||
[node name="VSeparator3" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LatencyLabel" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Adds artificial send and receive latency to this client for debugging. Set to 0 to disable."
|
||||
text = "Artificial Latency (ms)"
|
||||
|
||||
[node name="LatencySpinBox" type="SpinBox" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Adds artificial send and receive latency to this client for debugging. Set to 0 to disable."
|
||||
max_value = 5000.0
|
||||
prefix = ""
|
||||
suffix = "ms"
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
current_tab = 1
|
||||
|
||||
[node name="General" type="TabBar" parent="VBoxContainer/TabContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
metadata/_tab_index = 0
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/TabContainer/General"]
|
||||
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="VBoxContainer/TabContainer/General/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Incoming" type="Label" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Incoming:"
|
||||
|
||||
[node name="Label1" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer" node_paths=PackedStringArray("profiler")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "The total amount of bytes that have been received from both the server and other clients."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Total Bytes Received: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
stat_key = "down"
|
||||
decimal_places = 2
|
||||
suffix = ""
|
||||
label_text = "Total Bytes Received"
|
||||
|
||||
[node name="Label2" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer" node_paths=PackedStringArray("profiler")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "The total amount of messages that have been received from both the server and other clients."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Total Messages Received: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
stat_key = "pkts_down"
|
||||
is_bytes = false
|
||||
decimal_places = 0
|
||||
suffix = ""
|
||||
label_text = "Total Messages Received"
|
||||
|
||||
[node name="Label3" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer" node_paths=PackedStringArray("profiler")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "The total amount of bytes that are being received per second from both the server and other clients."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Bytes Received Per Second: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
stat_key = "down_sec"
|
||||
decimal_places = 2
|
||||
label_text = "Bytes Received Per Second"
|
||||
|
||||
[node name="Label4" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer" node_paths=PackedStringArray("profiler")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "The total amount of messages that are being received per second from both the server and other clients."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Messages Received Per Second: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
stat_key = "pkts_down_sec"
|
||||
is_bytes = false
|
||||
decimal_places = 0
|
||||
label_text = "Messages Received Per Second"
|
||||
|
||||
[node name="Label5" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer" node_paths=PackedStringArray("profiler")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "The average size of all received messages."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Average Message Size: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
stat_key = "avg_msg_down"
|
||||
suffix = ""
|
||||
label_text = "Average Message Size"
|
||||
|
||||
[node name="VBoxContainer3" type="VBoxContainer" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Outgoing" type="Label" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer3"]
|
||||
layout_mode = 2
|
||||
text = "Outgoing:"
|
||||
|
||||
[node name="Label1" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer3" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "The total amount of bytes that have been sent to both the server and other clients."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Total Bytes Sent: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
stat_key = "up"
|
||||
decimal_places = 2
|
||||
suffix = ""
|
||||
label_text = "Total Bytes Sent"
|
||||
|
||||
[node name="Label2" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer3" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "The total amount of messages that have been sent to both the server and other clients."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Total Messages Sent: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
stat_key = "pkts_up"
|
||||
is_bytes = false
|
||||
decimal_places = 0
|
||||
suffix = ""
|
||||
label_text = "Total Messages Sent"
|
||||
|
||||
[node name="Label3" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer3" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "The total amount of bytes that are being sent per second to both the server and other clients."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Bytes Sent Per Second: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
decimal_places = 2
|
||||
label_text = "Bytes Sent Per Second"
|
||||
|
||||
[node name="Label4" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer3" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "The total amount of messages that are being sent per second to both the server and other clients."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Messages Sent Per Second: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
stat_key = "pkts_up_sec"
|
||||
is_bytes = false
|
||||
decimal_places = 0
|
||||
label_text = "Messages Sent Per Second"
|
||||
|
||||
[node name="Label5" type="RichTextLabel" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer3" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "The average size of all sent messages."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Average Message Size: ...[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../../../..")
|
||||
stat_key = "avg_msg_up"
|
||||
suffix = ""
|
||||
label_text = "Average Message Size"
|
||||
|
||||
[node name="VSeparator2" type="VSeparator" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Graph" type="Control" parent="VBoxContainer/TabContainer/General/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/VBoxContainer2" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("3_hrjsf")
|
||||
profiler = NodePath("../../../../../../../../..")
|
||||
series = Array[Dictionary]([{
|
||||
"color": Color(0.290196, 0.870588, 0.501961, 1),
|
||||
"key": "down_sec",
|
||||
"label": "Incoming"
|
||||
}, {
|
||||
"color": Color(0.376471, 0.647059, 0.980392, 1),
|
||||
"key": "up_sec",
|
||||
"label": "Outgoing"
|
||||
}, {
|
||||
"color": Color(0.574867, 0.498099, 0.980392, 1),
|
||||
"key": "total_sec",
|
||||
"label": "Total"
|
||||
}])
|
||||
|
||||
[node name="Connections" type="TabBar" parent="VBoxContainer/TabContainer"]
|
||||
layout_mode = 2
|
||||
metadata/_tab_index = 1
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/TabContainer/Connections"]
|
||||
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="VBoxContainer/TabContainer/Connections/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer" node_paths=PackedStringArray("profiler", "button_template", "latency_graph_template", "jitter_graph_template")]
|
||||
layout_mode = 2
|
||||
script = ExtResource("4_gnjya")
|
||||
profiler = NodePath("../../../../../..")
|
||||
button_template = NodePath("HBoxContainer/HBoxContainer/VBoxContainer/ButtonTemplate")
|
||||
latency_graph_template = NodePath("HBoxContainer/VBoxContainer2/LatencyGraph")
|
||||
jitter_graph_template = NodePath("HBoxContainer/VBoxContainer3/JitterGraph")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MonitorButton" type="CheckButton" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Start monitoring the connections between clients. This will measure the ping and jitter and slightly increase transfer usage will enabled."
|
||||
text = "Monitor Connections"
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ButtonTemplate" type="Button" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
tooltip_text = "Press to show the latency and jitter to this client."
|
||||
text = "Client: 123"
|
||||
|
||||
[node name="VSeparator2" type="VSeparator" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="LatencyGraph" type="Control" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/VBoxContainer2" node_paths=PackedStringArray("profiler")]
|
||||
custom_minimum_size = Vector2(0, 200)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
tooltip_text = "Latency is the raw network round-trip time in milliseconds: the time for a message to go to the other client and return.
|
||||
|
||||
Perceived latency is the same trip, plus extra delay from frame timing and message handling, representing what the player actually experiences."
|
||||
script = ExtResource("3_hrjsf")
|
||||
profiler = NodePath("../../..")
|
||||
series = Array[Dictionary]([{
|
||||
"color": Color(0.376471, 0.647059, 0.980392, 1),
|
||||
"key": "latency",
|
||||
"label": "Latency"
|
||||
}, {
|
||||
"color": Color(0.6431373, 1, 0.76932174, 1),
|
||||
"key": "perceived_latency",
|
||||
"label": "Perceived Latency"
|
||||
}])
|
||||
display_mode = 1
|
||||
|
||||
[node name="VBoxContainer3" type="VBoxContainer" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="JitterGraph" type="Control" parent="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/VBoxContainer3" node_paths=PackedStringArray("profiler")]
|
||||
custom_minimum_size = Vector2(0, 200)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
tooltip_text = "The jitter between this and the selected client. Jitter is the difference between latency between now and last second.
|
||||
|
||||
High jitter indicates an unstable connection. Little to no jitter indicates a stable connection."
|
||||
script = ExtResource("3_hrjsf")
|
||||
profiler = NodePath("../../..")
|
||||
series = Array[Dictionary]([{
|
||||
"color": Color(0.952941, 0.545098, 0.658824, 1),
|
||||
"key": "jitter",
|
||||
"label": "Jitter"
|
||||
}])
|
||||
display_mode = 1
|
||||
|
||||
[node name="Session" type="TabBar" parent="VBoxContainer/TabContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
metadata/_tab_index = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/TabContainer/Session"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/Session/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Session Information"
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Label1" type="RichTextLabel" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2/VBoxContainer" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "The Client ID that is assigned to this session."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Client ID: N/A[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../..")
|
||||
stat_key = "client_id"
|
||||
is_bytes = false
|
||||
suffix = ""
|
||||
label_text = "Client ID"
|
||||
use_custom_data = true
|
||||
|
||||
[node name="Label2" type="RichTextLabel" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2/VBoxContainer" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "If the client in this session is the host of the current lobby or not."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Is Host: N/A[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../..")
|
||||
stat_key = "is_host"
|
||||
is_bytes = false
|
||||
suffix = ""
|
||||
label_text = "Is Host"
|
||||
use_custom_data = true
|
||||
|
||||
[node name="Label3" type="RichTextLabel" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2/VBoxContainer" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "If the client in this session is the host of the current lobby or not."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Host ID: N/A[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../..")
|
||||
stat_key = "host"
|
||||
is_bytes = false
|
||||
suffix = ""
|
||||
label_text = "Host ID"
|
||||
use_custom_data = true
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Label3" type="RichTextLabel" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2/VBoxContainer2" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "The name of the lobby the client of this session is currently in."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Lobby Name: N/A[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../..")
|
||||
stat_key = "lobby_name"
|
||||
is_bytes = false
|
||||
suffix = ""
|
||||
label_text = "Lobby Name"
|
||||
use_custom_data = true
|
||||
|
||||
[node name="Label4" type="RichTextLabel" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer2/VBoxContainer2" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "The password of the lobby the client of this session is currently in."
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]Lobby Password: N/A[/color]"
|
||||
fit_content = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../../..")
|
||||
stat_key = "lobby_password"
|
||||
is_bytes = false
|
||||
suffix = ""
|
||||
label_text = "Lobby Password"
|
||||
use_custom_data = true
|
||||
|
||||
[node name="VSeparator" type="VSeparator" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Player Data"
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label1" type="RichTextLabel" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
focus_mode = 2
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]{}[/color]"
|
||||
selection_enabled = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../..")
|
||||
stat_key = "player_data"
|
||||
is_bytes = false
|
||||
suffix = ""
|
||||
label_text = "Player Data"
|
||||
show_label_text = false
|
||||
use_custom_data = true
|
||||
missing_text = "{}"
|
||||
|
||||
[node name="VSeparator2" type="VSeparator" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer3" type="VBoxContainer" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer3"]
|
||||
layout_mode = 2
|
||||
text = "Lobby Data"
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer3"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label1" type="RichTextLabel" parent="VBoxContainer/TabContainer/Session/ScrollContainer/HBoxContainer/VBoxContainer3" node_paths=PackedStringArray("profiler")]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
focus_mode = 2
|
||||
bbcode_enabled = true
|
||||
text = "[color=#ffffff]{}[/color]"
|
||||
selection_enabled = true
|
||||
script = ExtResource("2_5m75r")
|
||||
profiler = NodePath("../../../../../../..")
|
||||
stat_key = "lobby_data"
|
||||
is_bytes = false
|
||||
suffix = ""
|
||||
label_text = "Player Data"
|
||||
show_label_text = false
|
||||
use_custom_data = true
|
||||
missing_text = "{}"
|
||||
|
||||
[node name="Incoming Details" type="TabBar" parent="VBoxContainer/TabContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
metadata/_tab_index = 3
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/TabContainer/Incoming Details"]
|
||||
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="VBoxContainer/TabContainer/Incoming Details/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Incoming Usage Details"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Button" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Type"
|
||||
|
||||
[node name="Label2" type="Button" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Object"
|
||||
|
||||
[node name="Label3" type="Button" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Target"
|
||||
|
||||
[node name="Label4" type="Button" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Count"
|
||||
|
||||
[node name="Label5" type="Button" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Total Bytes (descending)"
|
||||
|
||||
[node name="Label6" type="Button" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Percent"
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2" node_paths=PackedStringArray("type_sort_button", "object_sort_button", "target_sort_button", "count_sort_button", "usage_sort_button", "percent_sort_button", "profiler", "label_template")]
|
||||
layout_mode = 2
|
||||
script = ExtResource("4_bk6j0")
|
||||
type_sort_button = NodePath("../HBoxContainer/Label")
|
||||
object_sort_button = NodePath("../HBoxContainer/Label2")
|
||||
target_sort_button = NodePath("../HBoxContainer/Label3")
|
||||
count_sort_button = NodePath("../HBoxContainer/Label4")
|
||||
usage_sort_button = NodePath("../HBoxContainer/Label5")
|
||||
percent_sort_button = NodePath("../HBoxContainer/Label6")
|
||||
listen_key = "down"
|
||||
profiler = NodePath("../../../../../../../..")
|
||||
label_template = NodePath("PanelContainer")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer"]
|
||||
visible = false
|
||||
self_modulate = Color(0.734375, 0.734375, 0.734375, 1)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Data" type="HBoxContainer" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Type" type="RichTextLabel" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "Sync Var"
|
||||
fit_content = true
|
||||
|
||||
[node name="Object" type="RichTextLabel" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "Node123"
|
||||
fit_content = true
|
||||
|
||||
[node name="Target" type="RichTextLabel" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "Property Name"
|
||||
fit_content = true
|
||||
|
||||
[node name="Count" type="RichTextLabel" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "0"
|
||||
fit_content = true
|
||||
|
||||
[node name="Usage" type="RichTextLabel" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "0B"
|
||||
fit_content = true
|
||||
|
||||
[node name="Percentage" type="RichTextLabel" parent="VBoxContainer/TabContainer/Incoming Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "0%"
|
||||
fit_content = true
|
||||
|
||||
[node name="Outgoing Details" type="TabBar" parent="VBoxContainer/TabContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
metadata/_tab_index = 4
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/TabContainer/Outgoing Details"]
|
||||
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="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
text = "Incoming Usage Details"
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Button" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Type"
|
||||
|
||||
[node name="Label2" type="Button" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Object"
|
||||
|
||||
[node name="Label3" type="Button" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Target"
|
||||
|
||||
[node name="Label4" type="Button" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Count"
|
||||
|
||||
[node name="Label5" type="Button" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Total Bytes (descending)"
|
||||
|
||||
[node name="Label6" type="Button" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Percent"
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2" node_paths=PackedStringArray("type_sort_button", "object_sort_button", "target_sort_button", "count_sort_button", "usage_sort_button", "percent_sort_button", "profiler", "label_template")]
|
||||
layout_mode = 2
|
||||
script = ExtResource("4_bk6j0")
|
||||
type_sort_button = NodePath("../HBoxContainer/Label")
|
||||
object_sort_button = NodePath("../HBoxContainer/Label2")
|
||||
target_sort_button = NodePath("../HBoxContainer/Label3")
|
||||
count_sort_button = NodePath("../HBoxContainer/Label4")
|
||||
usage_sort_button = NodePath("../HBoxContainer/Label5")
|
||||
percent_sort_button = NodePath("../HBoxContainer/Label6")
|
||||
profiler = NodePath("../../../../../../../..")
|
||||
label_template = NodePath("PanelContainer")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer"]
|
||||
visible = false
|
||||
self_modulate = Color(0.734375, 0.734375, 0.734375, 1)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Data" type="HBoxContainer" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Type" type="RichTextLabel" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "Sync Var"
|
||||
fit_content = true
|
||||
|
||||
[node name="Object" type="RichTextLabel" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "Node123"
|
||||
fit_content = true
|
||||
|
||||
[node name="Target" type="RichTextLabel" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "Property Name"
|
||||
fit_content = true
|
||||
|
||||
[node name="Count" type="RichTextLabel" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "0"
|
||||
fit_content = true
|
||||
|
||||
[node name="Usage" type="RichTextLabel" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "0B"
|
||||
fit_content = true
|
||||
|
||||
[node name="Percentage" type="RichTextLabel" parent="VBoxContainer/TabContainer/Outgoing Details/ScrollContainer/VBoxContainer/HBoxContainer/VBoxContainer2/VBoxContainer/PanelContainer/Data"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
bbcode_enabled = true
|
||||
text = "0%"
|
||||
fit_content = true
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Start" to="." method="start"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Stop" to="." method="stop"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Clear" to="." method="clear"]
|
||||
[connection signal="toggled" from="VBoxContainer/HBoxContainer/AutoStart" to="." method="_on_auto_start_toggled"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/LatencySpinBox" to="." method="_on_artificial_latency_changed"]
|
||||
[connection signal="toggled" from="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer/HBoxContainer/HBoxContainer/VBoxContainer/MonitorButton" to="VBoxContainer/TabContainer/Connections/ScrollContainer/VBoxContainer/PanelContainer" method="_on_monitor_button_toggled"]
|
||||
207
addons/GD-Sync/UI/Profiler/ProfilerConnectionMonitor.gd
Normal file
207
addons/GD-Sync/UI/Profiler/ProfilerConnectionMonitor.gd
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
@tool
|
||||
extends Node
|
||||
|
||||
#Copyright (c) 2023-present GD-Sync.
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source form, with or without modification,
|
||||
#are permitted provided that the following conditions are met:
|
||||
#
|
||||
#1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
#2. Neither the name of GD-Sync nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific
|
||||
# prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
#EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
#OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
#SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
#TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
#ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
#SUCH DAMAGE.
|
||||
|
||||
signal stats_updated(client_id : int, stats : Dictionary)
|
||||
signal profiler_cleared
|
||||
|
||||
@export var profiler : Node = null : set = _set_profiler
|
||||
@export var button_template : Control = null
|
||||
@export var latency_graph_template : Control = null
|
||||
@export var jitter_graph_template : Control = null
|
||||
|
||||
var client_data : Dictionary = {}
|
||||
var client_buttons : Dictionary = {}
|
||||
var client_latency_graphs : Dictionary = {}
|
||||
var client_jitter_graphs : Dictionary = {}
|
||||
var own_id : int = -1
|
||||
var monitoring : bool = false
|
||||
|
||||
func _ready():
|
||||
button_template.visible = false
|
||||
|
||||
if profiler:
|
||||
_connect_signal()
|
||||
|
||||
func _set_profiler(v):
|
||||
if profiler == v: return
|
||||
if profiler:
|
||||
_disconnect_signal()
|
||||
profiler = v
|
||||
if profiler:
|
||||
_connect_signal()
|
||||
|
||||
func _connect_signal():
|
||||
if not profiler: return
|
||||
if profiler.has_signal("profiler_started") and not profiler.profiler_started.is_connected(_on_profiler_started):
|
||||
profiler.profiler_started.connect(_on_profiler_started)
|
||||
if profiler.has_signal("profiler_stopped") and not profiler.profiler_stopped.is_connected(_on_profiler_stopped):
|
||||
profiler.profiler_stopped.connect(_on_profiler_stopped)
|
||||
if profiler.has_signal("client_joined") and not profiler.client_joined.is_connected(_on_client_joined):
|
||||
profiler.client_joined.connect(_on_client_joined)
|
||||
if profiler.has_signal("client_left") and not profiler.client_left.is_connected(_on_client_left):
|
||||
profiler.client_left.connect(_on_client_left)
|
||||
if profiler.has_signal("ping_measured") and not profiler.ping_measured.is_connected(_on_ping_measured):
|
||||
profiler.ping_measured.connect(_on_ping_measured)
|
||||
if profiler.has_signal("profiler_cleared") and not profiler.profiler_cleared.is_connected(_on_profiler_cleared):
|
||||
profiler.profiler_cleared.connect(_on_profiler_cleared)
|
||||
if profiler.has_signal("custom_data_updated") and not profiler.custom_data_updated.is_connected(_on_custom_data):
|
||||
profiler.custom_data_updated.connect(_on_custom_data)
|
||||
|
||||
func _disconnect_signal():
|
||||
if not profiler: return
|
||||
if profiler.has_signal("profiler_started") and profiler.profiler_started.is_connected(_on_profiler_started):
|
||||
profiler.profiler_started.disconnect(_on_profiler_started)
|
||||
if profiler.has_signal("profiler_stopped") and profiler.profiler_stopped.is_connected(_on_profiler_stopped):
|
||||
profiler.profiler_stopped.disconnect(_on_profiler_stopped)
|
||||
if profiler.has_signal("client_joined") and profiler.client_joined.is_connected(_on_client_joined):
|
||||
profiler.client_joined.disconnect(_on_client_joined)
|
||||
if profiler.has_signal("client_left") and profiler.client_left.is_connected(_on_client_left):
|
||||
profiler.client_left.disconnect(_on_client_left)
|
||||
if profiler.has_signal("ping_measured") and profiler.ping_measured.is_connected(_on_ping_measured):
|
||||
profiler.ping_measured.disconnect(_on_ping_measured)
|
||||
if profiler.has_signal("profiler_cleared") and profiler.profiler_cleared.is_connected(_on_profiler_cleared):
|
||||
profiler.profiler_cleared.disconnect(_on_profiler_cleared)
|
||||
if profiler.has_signal("custom_data_updated") and profiler.custom_data_updated.is_connected(_on_custom_data):
|
||||
profiler.custom_data_updated.disconnect(_on_custom_data)
|
||||
|
||||
func _on_custom_data(data : Dictionary) -> void:
|
||||
if !data.has("client_id"): return
|
||||
own_id = data["client_id"]
|
||||
|
||||
func _on_monitor_button_toggled(toggled_on: bool) -> void:
|
||||
monitoring = toggled_on
|
||||
|
||||
if monitoring:
|
||||
profiler.start_monitoring_connections.emit()
|
||||
else:
|
||||
profiler.stop_monitoring_connections.emit()
|
||||
|
||||
func _on_profiler_started() -> void:
|
||||
if monitoring:
|
||||
profiler.start_monitoring_connections.emit()
|
||||
|
||||
func _on_profiler_stopped() -> void:
|
||||
profiler.stop_monitoring_connections.emit()
|
||||
|
||||
func _on_profiler_cleared() -> void:
|
||||
client_data.clear()
|
||||
|
||||
for button in client_buttons.values():
|
||||
button.queue_free()
|
||||
|
||||
for graph in client_latency_graphs.values():
|
||||
graph.queue_free()
|
||||
|
||||
for graph in client_jitter_graphs.values():
|
||||
graph.queue_free()
|
||||
|
||||
client_buttons.clear()
|
||||
client_latency_graphs.clear()
|
||||
client_jitter_graphs.clear()
|
||||
|
||||
latency_graph_template.visible = true
|
||||
jitter_graph_template.visible = true
|
||||
|
||||
profiler_cleared.emit()
|
||||
|
||||
func _on_client_joined(client_id : int) -> void:
|
||||
if client_id == own_id: return
|
||||
|
||||
client_data[client_id] = {"latency" : 0.0, "jitter" : 0.0}
|
||||
|
||||
var button : Button = button_template.duplicate()
|
||||
button_template.get_parent().add_child(button)
|
||||
|
||||
button.text = "Client %s" % [client_id]
|
||||
button.pressed.connect(_show_client_graph.bind(client_id))
|
||||
button.visible = true
|
||||
client_buttons[client_id] = button
|
||||
|
||||
var latency_graph : Control = latency_graph_template.duplicate()
|
||||
latency_graph_template.get_parent().add_child(latency_graph)
|
||||
|
||||
latency_graph.visible = true
|
||||
latency_graph.client_id = client_id
|
||||
latency_graph.data_series[0]["label"] = "Latency to client "+str(client_id)
|
||||
latency_graph.data_series[1]["label"] = "Perceived latency to client "+str(client_id)
|
||||
client_latency_graphs[client_id] = latency_graph
|
||||
|
||||
var jitter_graph : Control = jitter_graph_template.duplicate()
|
||||
jitter_graph_template.get_parent().add_child(jitter_graph)
|
||||
|
||||
jitter_graph.visible = true
|
||||
jitter_graph.client_id = client_id
|
||||
jitter_graph.data_series[0]["label"] = "Jitter to client "+str(client_id)
|
||||
client_jitter_graphs[client_id] = jitter_graph
|
||||
|
||||
if client_data.size() == 1:
|
||||
_show_client_graph(client_id)
|
||||
|
||||
func _show_client_graph(client_id : int) -> void:
|
||||
latency_graph_template.visible = false
|
||||
jitter_graph_template.visible = false
|
||||
|
||||
for graph in client_latency_graphs.values():
|
||||
graph.visible = false
|
||||
for graph in client_jitter_graphs.values():
|
||||
graph.visible = false
|
||||
|
||||
client_latency_graphs[client_id].visible = true
|
||||
client_jitter_graphs[client_id].visible = true
|
||||
|
||||
func _on_client_left(client_id : int) -> void:
|
||||
if client_data.has(client_id):
|
||||
client_data.erase(client_id)
|
||||
|
||||
if client_buttons.has(client_id):
|
||||
client_buttons[client_id].queue_free()
|
||||
client_buttons.erase(client_id)
|
||||
|
||||
if client_latency_graphs.has(client_id):
|
||||
client_latency_graphs[client_id].queue_free()
|
||||
client_latency_graphs.erase(client_id)
|
||||
|
||||
if client_jitter_graphs.has(client_id):
|
||||
client_jitter_graphs[client_id].queue_free()
|
||||
client_jitter_graphs.erase(client_id)
|
||||
|
||||
func _on_ping_measured(client_id : int, ping : float, perceived_ping : float) -> void:
|
||||
if !client_latency_graphs.has(client_id): return
|
||||
ping *= 1000.0
|
||||
perceived_ping *= 1000.0
|
||||
|
||||
ping = max(0, ping)
|
||||
perceived_ping = max(0, perceived_ping)
|
||||
|
||||
var data : Dictionary = client_data[client_id]
|
||||
var last_latency : float = data["latency"]
|
||||
var jitter : float = abs(last_latency-ping) if last_latency > 0 else 0.0
|
||||
data["latency"] = ping
|
||||
data["perceived_latency"] = perceived_ping
|
||||
data["jitter"] = jitter
|
||||
|
||||
stats_updated.emit(client_id, data)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://frgb8qcxxcoj
|
||||
216
addons/GD-Sync/UI/Profiler/ProfilerDetailsBar.gd
Normal file
216
addons/GD-Sync/UI/Profiler/ProfilerDetailsBar.gd
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
#Copyright (c) 2023-present GD-Sync.
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source form, with or without modification,
|
||||
#are permitted provided that the following conditions are met:
|
||||
#
|
||||
#1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
#2. Neither the name of GD-Sync nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific
|
||||
# prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
#EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
#OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
#SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
#TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
#ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
#SUCH DAMAGE.
|
||||
|
||||
@export var profiler : Node = null
|
||||
@export var listen_key : String = "up"
|
||||
@export var other_threshold : float = 2.0
|
||||
@export var bar_segment_template : Control = null
|
||||
@export var other_color : Color = Color("#888888")
|
||||
@export var color_palette : Array[Color] = [
|
||||
Color("#e6194b"), Color("#3cb44b"), Color("#ffe119"), Color("#4363d8"),
|
||||
Color("#f58231"), Color("#911eb4"), Color("#46f0f0"), Color("#f032e6"),
|
||||
Color("#bcf60c"), Color("#fabebe"), Color("#008080"), Color("#e6beff")
|
||||
]
|
||||
|
||||
var segment_cache : Dictionary = {}
|
||||
var data_cache : Dictionary = {}
|
||||
var rebuild_scheduled : bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
if bar_segment_template:
|
||||
bar_segment_template.visible = false
|
||||
|
||||
if profiler:
|
||||
_connect_signals()
|
||||
|
||||
func _connect_signals() -> void:
|
||||
if profiler.has_signal("message_details_updated") and not profiler.message_details_updated.is_connected(_on_details):
|
||||
profiler.message_details_updated.connect(_on_details)
|
||||
if profiler.has_signal("profiler_cleared") and not profiler.profiler_cleared.is_connected(_on_clear):
|
||||
profiler.profiler_cleared.connect(_on_clear)
|
||||
|
||||
func _disconnect_signals() -> void:
|
||||
if profiler and profiler.message_details_updated.is_connected(_on_details):
|
||||
profiler.message_details_updated.disconnect(_on_details)
|
||||
if profiler and profiler.profiler_cleared.is_connected(_on_clear):
|
||||
profiler.profiler_cleared.disconnect(_on_clear)
|
||||
|
||||
func _on_clear() -> void:
|
||||
for seg in segment_cache.values():
|
||||
seg.queue_free()
|
||||
segment_cache.clear()
|
||||
data_cache.clear()
|
||||
_schedule_rebuild()
|
||||
|
||||
func _on_details(details : Dictionary) -> void:
|
||||
if !details.has(listen_key): return
|
||||
var raw_data : Dictionary = details[listen_key]
|
||||
|
||||
var object_stats : Dictionary = {}
|
||||
for key in raw_data.keys():
|
||||
var entry = raw_data[key]
|
||||
var obj = entry.object
|
||||
if not object_stats.has(obj):
|
||||
object_stats[obj] = { "total_bytes": 0, "percent": 0.0, "keys": [] }
|
||||
object_stats[obj].total_bytes += entry.total_bytes
|
||||
object_stats[obj].keys.append(key)
|
||||
|
||||
var total_bytes : int = 0
|
||||
for obj in object_stats.keys():
|
||||
total_bytes += object_stats[obj].total_bytes
|
||||
|
||||
if total_bytes == 0:
|
||||
_clear_all_segments()
|
||||
return
|
||||
|
||||
for obj in object_stats.keys():
|
||||
var bytes = object_stats[obj].total_bytes
|
||||
object_stats[obj].percent = (bytes as float / total_bytes) * 100.0
|
||||
|
||||
var major_objects : Array = []
|
||||
var other_bytes : int = 0
|
||||
var other_keys : Array = []
|
||||
|
||||
for obj in object_stats.keys():
|
||||
var pct = object_stats[obj].percent
|
||||
if pct >= other_threshold:
|
||||
major_objects.append({
|
||||
"name": obj,
|
||||
"percent": pct,
|
||||
"bytes": object_stats[obj].total_bytes,
|
||||
"keys": object_stats[obj].keys
|
||||
})
|
||||
else:
|
||||
other_bytes += object_stats[obj].total_bytes
|
||||
other_keys.append_array(object_stats[obj].keys)
|
||||
|
||||
var other_pct = (other_bytes as float / total_bytes) * 100.0 if total_bytes > 0 else 0.0
|
||||
if other_pct > 0.0:
|
||||
major_objects.append({
|
||||
"name": "Other",
|
||||
"percent": other_pct,
|
||||
"bytes": other_bytes,
|
||||
"keys": other_keys
|
||||
})
|
||||
|
||||
major_objects.sort_custom(func(a, b): return a.percent > b.percent)
|
||||
|
||||
data_cache.clear()
|
||||
for item in major_objects:
|
||||
data_cache[item.name] = item
|
||||
|
||||
_schedule_rebuild()
|
||||
|
||||
func _schedule_rebuild() -> void:
|
||||
if rebuild_scheduled: return
|
||||
rebuild_scheduled = true
|
||||
call_deferred("_rebuild_bar_deferred")
|
||||
|
||||
func _rebuild_bar_deferred() -> void:
|
||||
if not rebuild_scheduled: return
|
||||
rebuild_scheduled = false
|
||||
|
||||
var ordered_names : Array = data_cache.keys()
|
||||
ordered_names.sort_custom(func(a, b):
|
||||
return data_cache[a].percent > data_cache[b].percent
|
||||
)
|
||||
|
||||
var total_percent : float = 0.0
|
||||
for item in data_cache.values():
|
||||
total_percent += item.percent
|
||||
total_percent = max(total_percent, 100.0)
|
||||
|
||||
var color_idx = 0
|
||||
for obj_name in ordered_names:
|
||||
var item = data_cache[obj_name]
|
||||
var seg = _get_or_create_segment(obj_name)
|
||||
|
||||
var col = other_color if obj_name == "Other" else color_palette[color_idx % color_palette.size()]
|
||||
seg.modulate = col
|
||||
color_idx += 1
|
||||
|
||||
var ratio = item.percent / total_percent * 100.0
|
||||
seg.size_flags_stretch_ratio = ratio
|
||||
|
||||
var tooltip = "%s\n%.2f%% (%s)" % [
|
||||
obj_name,
|
||||
item.percent,
|
||||
_format_bytes(item.bytes)
|
||||
]
|
||||
seg.tooltip_text = tooltip
|
||||
|
||||
seg.set_meta("keys", item.keys)
|
||||
|
||||
if seg.get_index() != get_child_count() - 1:
|
||||
move_child(seg, -1)
|
||||
|
||||
_remove_unused_segments(ordered_names)
|
||||
|
||||
func _get_or_create_segment(obj_name : String) -> Control:
|
||||
if segment_cache.has(obj_name):
|
||||
return segment_cache[obj_name]
|
||||
|
||||
var seg = bar_segment_template.duplicate()
|
||||
add_child(seg)
|
||||
seg.visible = true
|
||||
seg.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
seg.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
|
||||
seg.connect("mouse_entered", func():
|
||||
seg.modulate.a = 0.8
|
||||
)
|
||||
seg.connect("mouse_exited", func():
|
||||
seg.modulate.a = 1.0
|
||||
)
|
||||
|
||||
segment_cache[obj_name] = seg
|
||||
return seg
|
||||
|
||||
func _remove_unused_segments(current_objects : Array) -> void:
|
||||
var to_remove = []
|
||||
for name in segment_cache.keys():
|
||||
if !current_objects.has(name):
|
||||
to_remove.append(name)
|
||||
|
||||
for name in to_remove:
|
||||
segment_cache[name].queue_free()
|
||||
segment_cache.erase(name)
|
||||
|
||||
func _clear_all_segments() -> void:
|
||||
for seg in segment_cache.values():
|
||||
seg.queue_free()
|
||||
segment_cache.clear()
|
||||
|
||||
func _format_bytes(b : int) -> String:
|
||||
if b <= 0: return "0 B"
|
||||
var u = ["B","KB","MB","GB"]
|
||||
var i = 0
|
||||
var v = float(b)
|
||||
while v >= 1000.0 and i < 3:
|
||||
v /= 1000.0
|
||||
i += 1
|
||||
return "%.*f %s" % [1 if i > 0 else 0, v, u[i]]
|
||||
1
addons/GD-Sync/UI/Profiler/ProfilerDetailsBar.gd.uid
Normal file
1
addons/GD-Sync/UI/Profiler/ProfilerDetailsBar.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bvluikq25m4rv
|
||||
384
addons/GD-Sync/UI/Profiler/ProfilerDetailsDisplay.gd
Normal file
384
addons/GD-Sync/UI/Profiler/ProfilerDetailsDisplay.gd
Normal file
|
|
@ -0,0 +1,384 @@
|
|||
@tool
|
||||
extends Control
|
||||
|
||||
#Copyright (c) 2023-present GD-Sync.
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source form, with or without modification,
|
||||
#are permitted provided that the following conditions are met:
|
||||
#
|
||||
#1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
#2. Neither the name of GD-Sync nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific
|
||||
# prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
#EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
#OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
#SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
#TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
#ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
#SUCH DAMAGE.
|
||||
|
||||
@export var type_sort_button : Button
|
||||
@export var object_sort_button : Button
|
||||
@export var target_sort_button : Button
|
||||
@export var count_sort_button : Button
|
||||
@export var usage_sort_button : Button
|
||||
@export var percent_sort_button : Button
|
||||
@export var listen_key : String = "up"
|
||||
@export var profiler : Node = null
|
||||
@export var label_template : Node = null
|
||||
|
||||
var existing_labels : Dictionary = {}
|
||||
var current_sort_key : String = "total_bytes"
|
||||
var sort_reversed : bool = false
|
||||
var sorted_keys : Array = []
|
||||
var data_cache : Dictionary = {}
|
||||
|
||||
var sort_thread : Thread
|
||||
var data_mutex : Mutex
|
||||
var pending_data_update : Dictionary = {}
|
||||
var pending_remove_keys : Array = []
|
||||
var has_pending_changes : bool = false
|
||||
var should_stop_thread : bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
data_mutex = Mutex.new()
|
||||
|
||||
if label_template:
|
||||
label_template.visible = false
|
||||
|
||||
if profiler:
|
||||
_connect_signals()
|
||||
|
||||
_connect_sort_buttons()
|
||||
_update_button_states()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
_stop_thread()
|
||||
_disconnect_signals()
|
||||
|
||||
func _stop_thread() -> void:
|
||||
should_stop_thread = true
|
||||
if sort_thread and sort_thread.is_started():
|
||||
sort_thread.wait_to_finish()
|
||||
|
||||
func _start_thread_if_needed() -> void:
|
||||
if not sort_thread or not sort_thread.is_started():
|
||||
sort_thread = Thread.new()
|
||||
should_stop_thread = false
|
||||
sort_thread.start(_thread_process)
|
||||
|
||||
func _thread_process() -> void:
|
||||
while not should_stop_thread:
|
||||
data_mutex.lock()
|
||||
var has_changes = has_pending_changes
|
||||
var local_data_update = pending_data_update.duplicate(true)
|
||||
var local_remove_keys = pending_remove_keys.duplicate()
|
||||
var local_data_cache = data_cache.duplicate(true)
|
||||
var local_existing_keys = existing_labels.keys()
|
||||
var local_sort_key = current_sort_key
|
||||
var local_sort_reversed = sort_reversed
|
||||
|
||||
if has_changes:
|
||||
pending_data_update.clear()
|
||||
pending_remove_keys.clear()
|
||||
has_pending_changes = false
|
||||
data_mutex.unlock()
|
||||
|
||||
if has_changes:
|
||||
var new_data_cache = local_data_cache.duplicate(true)
|
||||
|
||||
for key in local_data_update.keys():
|
||||
new_data_cache[key] = {
|
||||
"type": local_data_update[key].type,
|
||||
"object": local_data_update[key].object,
|
||||
"target": local_data_update[key].target,
|
||||
"count": local_data_update[key].count,
|
||||
"total_bytes": local_data_update[key].total_bytes,
|
||||
"percent": local_data_update[key].percent
|
||||
}
|
||||
|
||||
for key in local_remove_keys:
|
||||
new_data_cache.erase(key)
|
||||
|
||||
var new_sorted_keys = local_existing_keys.duplicate()
|
||||
|
||||
if not local_sort_key.is_empty():
|
||||
new_sorted_keys.sort_custom(func(a, b):
|
||||
var va = _get_raw_sort_value_thread(a, new_data_cache, local_sort_key)
|
||||
var vb = _get_raw_sort_value_thread(b, new_data_cache, local_sort_key)
|
||||
|
||||
if va == vb:
|
||||
return a < b
|
||||
|
||||
if local_sort_reversed:
|
||||
return va > vb
|
||||
else:
|
||||
return va < vb
|
||||
)
|
||||
else:
|
||||
new_sorted_keys.sort()
|
||||
|
||||
call_deferred("_apply_thread_results", new_sorted_keys, new_data_cache)
|
||||
|
||||
OS.delay_msec(16)
|
||||
|
||||
func _get_raw_sort_value_thread(key : String, cache : Dictionary, sort_key : String) -> Variant:
|
||||
if not cache.has(key):
|
||||
return key
|
||||
var e = cache[key]
|
||||
match sort_key:
|
||||
"type": return e.type
|
||||
"object": return e.object
|
||||
"target": return e.target
|
||||
"count": return e.count
|
||||
"total_bytes": return e.total_bytes
|
||||
"percent": return e.percent
|
||||
_: return key
|
||||
|
||||
func _apply_thread_results(new_sorted_keys : Array, new_data_cache : Dictionary) -> void:
|
||||
data_mutex.lock()
|
||||
data_cache = new_data_cache
|
||||
sorted_keys = new_sorted_keys
|
||||
data_mutex.unlock()
|
||||
|
||||
_reorder_labels_ui()
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Signal handling
|
||||
# -------------------------------------------------------------------------
|
||||
func _connect_signals() -> void:
|
||||
if profiler.has_signal("message_details_updated") and not profiler.message_details_updated.is_connected(_on_message_details):
|
||||
profiler.message_details_updated.connect(_on_message_details)
|
||||
if profiler.has_signal("profiler_cleared") and not profiler.profiler_cleared.is_connected(_on_clear):
|
||||
profiler.profiler_cleared.connect(_on_clear)
|
||||
|
||||
func _disconnect_signals() -> void:
|
||||
if profiler and profiler.message_details_updated.is_connected(_on_message_details):
|
||||
profiler.message_details_updated.disconnect(_on_message_details)
|
||||
if profiler and profiler.profiler_cleared.is_connected(_on_clear):
|
||||
profiler.profiler_cleared.disconnect(_on_clear)
|
||||
|
||||
func _on_clear() -> void:
|
||||
data_mutex.lock()
|
||||
for l in existing_labels.values():
|
||||
l.queue_free()
|
||||
existing_labels.clear()
|
||||
data_cache.clear()
|
||||
sorted_keys.clear()
|
||||
pending_data_update.clear()
|
||||
pending_remove_keys.clear()
|
||||
has_pending_changes = false
|
||||
data_mutex.unlock()
|
||||
|
||||
current_sort_key = "total_bytes"
|
||||
sort_reversed = false
|
||||
_update_button_states()
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Sort-button handling
|
||||
# -------------------------------------------------------------------------
|
||||
func _connect_sort_buttons() -> void:
|
||||
var map = {
|
||||
"type": type_sort_button,
|
||||
"object": object_sort_button,
|
||||
"target": target_sort_button,
|
||||
"count": count_sort_button,
|
||||
"total_bytes": usage_sort_button,
|
||||
"percent": percent_sort_button
|
||||
}
|
||||
for k in map.keys():
|
||||
var btn = map[k]
|
||||
if btn and btn.pressed.get_connections().size() == 0:
|
||||
btn.pressed.connect(func(): _sort_by(k))
|
||||
|
||||
func _sort_by(key : String) -> void:
|
||||
if current_sort_key == key:
|
||||
sort_reversed = !sort_reversed # toggle direction
|
||||
else:
|
||||
current_sort_key = key
|
||||
sort_reversed = false # default = descending (biggest on top)
|
||||
_update_button_states()
|
||||
_schedule_rebuild()
|
||||
|
||||
func _update_button_states() -> void:
|
||||
var map = {
|
||||
"type": type_sort_button,
|
||||
"object": object_sort_button,
|
||||
"target": target_sort_button,
|
||||
"count": count_sort_button,
|
||||
"total_bytes": usage_sort_button,
|
||||
"percent": percent_sort_button
|
||||
}
|
||||
for k in map.keys():
|
||||
var btn = map[k]
|
||||
if btn:
|
||||
btn.text = _get_button_text(k)
|
||||
|
||||
func _get_button_text(key : String) -> String:
|
||||
var base = key.capitalize()
|
||||
if current_sort_key == key:
|
||||
return base + (" (descending)" if !sort_reversed else " (ascending)")
|
||||
return base
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Data → UI
|
||||
# -------------------------------------------------------------------------
|
||||
func _on_message_details(details : Dictionary) -> void:
|
||||
if !details.has(listen_key): return
|
||||
var data : Dictionary = details[listen_key]
|
||||
|
||||
data_mutex.lock()
|
||||
|
||||
var changed = false
|
||||
for k in data.keys():
|
||||
if not existing_labels.has(k):
|
||||
changed = true
|
||||
# Create label immediately on main thread
|
||||
var label = label_template.duplicate()
|
||||
add_child(label)
|
||||
label.visible = true
|
||||
existing_labels[k] = label
|
||||
|
||||
# Update UI immediately
|
||||
_populate_label(k, data[k])
|
||||
|
||||
# Queue data for thread processing
|
||||
pending_data_update[k] = {
|
||||
"type": data[k].type,
|
||||
"object": data[k].object,
|
||||
"target": data[k].target,
|
||||
"count": data[k].count,
|
||||
"total_bytes": data[k].total_bytes,
|
||||
"percent": data[k].percent
|
||||
}
|
||||
|
||||
# Find keys to remove
|
||||
var current_keys = data.keys()
|
||||
var to_remove = []
|
||||
for k in existing_labels.keys():
|
||||
if !current_keys.has(k):
|
||||
to_remove.append(k)
|
||||
changed = true
|
||||
|
||||
# Remove labels immediately from UI but keep in cache for thread
|
||||
for k in to_remove:
|
||||
existing_labels[k].queue_free()
|
||||
existing_labels.erase(k)
|
||||
pending_remove_keys.append(k)
|
||||
|
||||
if changed:
|
||||
has_pending_changes = true
|
||||
_start_thread_if_needed()
|
||||
|
||||
data_mutex.unlock()
|
||||
|
||||
func _populate_label(key : String, data : Dictionary) -> void:
|
||||
var label = existing_labels.get(key)
|
||||
if not label:
|
||||
return
|
||||
|
||||
label.get_node("Data/Object").text = get_final_segment(data["object"])
|
||||
label.get_node("Data/Object").tooltip_text = data["object"]
|
||||
label.get_node("Data/Target").text = data["target"]
|
||||
label.get_node("Data/Count").text = _format_number(data["count"])
|
||||
label.get_node("Data/Count").tooltip_text = "This message was sent %s times." % [_format_number(data["count"])]
|
||||
label.get_node("Data/Usage").text = _format_bytes(data["total_bytes"])
|
||||
label.get_node("Data/Usage").tooltip_text = "These messages have used %s of transfer." % [_format_bytes(data["total_bytes"])]
|
||||
|
||||
var percent : float = data["percent"]
|
||||
var color_value_yellow : float = percent / 100.0
|
||||
var color_value_red : float = color_value_yellow*2.0-1.0
|
||||
color_value_yellow = min(color_value_yellow*2.0, 1.0)
|
||||
color_value_red = max(color_value_red, 0.0)
|
||||
|
||||
var color = Color.CHARTREUSE.lerp(Color.GOLD, color_value_yellow).lerp(Color.TOMATO, color_value_red)
|
||||
var color_hex = color.to_html(false)
|
||||
|
||||
var percent_text = "[color=%s]%.*f%%[/color]" % [color_hex, 2, percent]
|
||||
label.get_node("Data/Percentage").text = percent_text
|
||||
label.get_node("Data/Percentage").tooltip_text = "These messages contributed %.*f%% of the total %s transfer." % [2, percent, "incoming" if listen_key == "down" else "outgoing"]
|
||||
|
||||
var type_tooltip : String = data["type"]
|
||||
var type_color : String = Color.WHITE.to_html(false)
|
||||
match(data["type"]):
|
||||
"internal":
|
||||
type_tooltip = "An internal message of GD-Sync which may provide extra functionality or optimizations."
|
||||
type_color = "#f5c2e7"
|
||||
"call_func":
|
||||
type_tooltip = "A script used call_func, call_func_on or call_func_all to remotely call a function on a Node or Resource."
|
||||
type_color = "#a6e3a1"
|
||||
"call_func optimized":
|
||||
type_tooltip = "A script used call_func, call_func_on or call_func_all to remotely call a function on a Node or Resource. \nThis is an optimized version which caches caches the NodePath and function name and replaces them with integers to save transfer."
|
||||
type_color = "#a6e3a1"
|
||||
"sync_var":
|
||||
type_tooltip = "A script used sync_var or sync_var_on to synchronize the value of a property on all clients."
|
||||
type_color = "#89b4fa"
|
||||
"sync_var optimized":
|
||||
type_tooltip = "A script used sync_var or sync_var_on to synchronize the value of a property on all clients. \nThis is an optimized version which caches caches the NodePath and property name and replaces them with integers to save transfer."
|
||||
type_color = "#89b4fa"
|
||||
label.get_node("Data/Type").text = "[color=%s]%s[/color]" % [type_color, data["type"]]
|
||||
label.get_node("Data/Type").tooltip_text = type_tooltip
|
||||
|
||||
var target_node = label.get_node("Data/Target")
|
||||
if data.has("last_details") and data["last_details"] is Array and not data["last_details"].is_empty():
|
||||
var details_list = data["last_details"]
|
||||
var tooltip_text = data["target"]
|
||||
tooltip_text += "\n\nLast messages:\n" + "─".repeat(20) + "\n"
|
||||
|
||||
for i in range(details_list.size() - 1, -1, -1):
|
||||
tooltip_text += details_list[i] + "\n"
|
||||
if i > 0:
|
||||
tooltip_text += "─".repeat(20) + "\n"
|
||||
|
||||
target_node.tooltip_text = tooltip_text
|
||||
else:
|
||||
target_node.tooltip_text = data["target"]
|
||||
|
||||
func get_final_segment(path: String) -> String:
|
||||
var parts = path.strip_edges().split("/")
|
||||
return parts[-1] if parts.size() > 0 else path
|
||||
|
||||
func _format_number(n : int) -> String:
|
||||
var s = str(abs(n))
|
||||
var result = ""
|
||||
for i in range(s.length() - 1, -1, -1):
|
||||
if (s.length() - 1 - i) % 3 == 0 and i < s.length() - 1:
|
||||
result = "." + result
|
||||
result = s[i] + result
|
||||
return ("-" if n < 0 else "") + result
|
||||
|
||||
func _format_bytes(b : int) -> String:
|
||||
if b <= 0: return "0 B"
|
||||
var u = ["B","KB","MB","GB"]
|
||||
var i = 0
|
||||
var v = float(b)
|
||||
while v >= 1000.0 and i < 3:
|
||||
v /= 1000.0
|
||||
i += 1
|
||||
return "%.*f %s" % [1 if i > 0 else 0, v, u[i]]
|
||||
|
||||
func _schedule_rebuild() -> void:
|
||||
data_mutex.lock()
|
||||
has_pending_changes = true
|
||||
data_mutex.unlock()
|
||||
_start_thread_if_needed()
|
||||
|
||||
func _reorder_labels_ui() -> void:
|
||||
data_mutex.lock()
|
||||
var local_sorted_keys = sorted_keys.duplicate()
|
||||
data_mutex.unlock()
|
||||
|
||||
var idx = get_child_count() - 1
|
||||
for k in local_sorted_keys:
|
||||
var label = existing_labels.get(k)
|
||||
if label and label.get_index() != idx:
|
||||
move_child(label, idx)
|
||||
idx -= 1
|
||||
1
addons/GD-Sync/UI/Profiler/ProfilerDetailsDisplay.gd.uid
Normal file
1
addons/GD-Sync/UI/Profiler/ProfilerDetailsDisplay.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://4b1i1ihfsqdf
|
||||
184
addons/GD-Sync/UI/Profiler/ProfilerGraph.gd
Normal file
184
addons/GD-Sync/UI/Profiler/ProfilerGraph.gd
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
@tool
|
||||
extends Control
|
||||
|
||||
#Copyright (c) 2023-present GD-Sync.
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source form, with or without modification,
|
||||
#are permitted provided that the following conditions are met:
|
||||
#
|
||||
#1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
#2. Neither the name of GD-Sync nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific
|
||||
# prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
#EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
#OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
#SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
#TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
#ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
#SUCH DAMAGE.
|
||||
|
||||
@export var profiler : Node = null : set = _set_profiler
|
||||
@export var client_id : int = -1
|
||||
@export var series : Array[Dictionary] = [
|
||||
{"key": "up_sec", "color": Color("#4ade80"), "label": "Upload"},
|
||||
{"key": "down_sec", "color": Color("#60a5fa"), "label": "Download"}
|
||||
]
|
||||
@export var history_seconds : int = 60
|
||||
@export var padding := Vector2(40, 30)
|
||||
@export var grid_color := Color(0.3, 0.3, 0.3, 0.5)
|
||||
@export var text_color := Color.WHITE
|
||||
@export var bg_color := Color(0.1, 0.1, 0.1, 0.8)
|
||||
@export var font_size := 12
|
||||
@export_enum("Bytes", "Milliseconds") var display_mode : int = 0:
|
||||
set = _set_display_mode
|
||||
|
||||
var data_series : Array = []
|
||||
|
||||
func _ready():
|
||||
_setup_series()
|
||||
if profiler:
|
||||
_connect_signal()
|
||||
|
||||
func _set_display_mode(mode):
|
||||
display_mode = mode
|
||||
queue_redraw()
|
||||
|
||||
func _set_profiler(v):
|
||||
if profiler == v: return
|
||||
if profiler:
|
||||
_disconnect_signal()
|
||||
profiler = v
|
||||
if profiler:
|
||||
_connect_signal()
|
||||
|
||||
func _setup_series():
|
||||
data_series.clear()
|
||||
for s in series:
|
||||
var ds = {
|
||||
"values": [],
|
||||
"color": s.color,
|
||||
"label": s.label
|
||||
}
|
||||
ds.values.resize(history_seconds)
|
||||
ds.values.fill(0.0)
|
||||
data_series.append(ds)
|
||||
|
||||
func _connect_signal():
|
||||
if not profiler: return
|
||||
if profiler.has_signal("stats_updated") and not profiler.stats_updated.is_connected(_on_stats_updated):
|
||||
profiler.stats_updated.connect(_on_stats_updated)
|
||||
if profiler.has_signal("profiler_cleared") and not profiler.profiler_cleared.is_connected(_on_clear):
|
||||
profiler.profiler_cleared.connect(_on_clear)
|
||||
|
||||
func _disconnect_signal():
|
||||
if not profiler: return
|
||||
if profiler.has_signal("stats_updated") and profiler.stats_updated.is_connected(_on_stats_updated):
|
||||
profiler.stats_updated.disconnect(_on_stats_updated)
|
||||
if profiler.has_signal("profiler_cleared") and profiler.profiler_cleared.is_connected(_on_clear):
|
||||
profiler.profiler_cleared.disconnect(_on_clear)
|
||||
|
||||
func _on_stats_updated(cid : int, stats : Dictionary):
|
||||
if client_id != -1 and cid != client_id: return
|
||||
if client_id == -1 and cid != -1: return
|
||||
for i in data_series.size():
|
||||
var key = series[i].key
|
||||
var val = stats.get(key, 0.0)
|
||||
var ds = data_series[i]
|
||||
ds.values.pop_back()
|
||||
ds.values.push_front(val)
|
||||
queue_redraw()
|
||||
|
||||
func _on_clear():
|
||||
_setup_series()
|
||||
queue_redraw()
|
||||
|
||||
func _nice_number(value : float, round_up : bool) -> float:
|
||||
var exponent = floor(log(value) / log(10.0))
|
||||
var fraction = value / pow(10.0, exponent)
|
||||
var nice_fraction = 10.0 if round_up else 1.0
|
||||
if fraction <= 1.0: nice_fraction = 1.0
|
||||
elif fraction <= 2.0: nice_fraction = 2.0
|
||||
elif fraction <= 5.0: nice_fraction = 5.0
|
||||
else: nice_fraction = 10.0
|
||||
return nice_fraction * pow(10.0, exponent)
|
||||
|
||||
func _draw():
|
||||
var rect = get_rect()
|
||||
draw_rect(rect, bg_color)
|
||||
|
||||
if data_series.is_empty(): return
|
||||
|
||||
var graph_rect = rect.grow_individual(-padding.x, -padding.y, -padding.x, -padding.y)
|
||||
var w = graph_rect.size.x
|
||||
var h = graph_rect.size.y
|
||||
var x0 = graph_rect.position.x
|
||||
var y0 = graph_rect.position.y
|
||||
|
||||
var all_vals : Array = []
|
||||
for ds in data_series:
|
||||
for v in ds.values:
|
||||
if v > 0: all_vals.append(v)
|
||||
var raw_max = all_vals.max() if not all_vals.is_empty() else 1000.0
|
||||
var max_val = _nice_number(raw_max * 1.05, true)
|
||||
max_val = max(max_val, 1.0)
|
||||
|
||||
var grid_levels = 5
|
||||
for i in range(grid_levels + 1):
|
||||
var y = y0 + h * i / float(grid_levels)
|
||||
draw_line(Vector2(x0, y), Vector2(x0 + w, y), grid_color, 1.0)
|
||||
var label_val = max_val * (1.0 - i / float(grid_levels))
|
||||
var label = _format_value(label_val, 1)
|
||||
draw_string(ThemeDB.fallback_font, Vector2(x0 - 5, y + 5), label, HORIZONTAL_ALIGNMENT_RIGHT, -1, font_size, text_color)
|
||||
|
||||
for idx in data_series.size():
|
||||
var ds = data_series[idx]
|
||||
var points : Array = []
|
||||
for i in history_seconds:
|
||||
var v = ds.values[i]
|
||||
var x = x0 + w * (1.0 - i / float(history_seconds - 1))
|
||||
var y = y0 + h * (1.0 - v / max_val)
|
||||
points.append(Vector2(x, y))
|
||||
if points.size() > 1:
|
||||
draw_polyline(points, ds.color, 2.0)
|
||||
|
||||
var total_width := 0.0
|
||||
var label_widths : Array = []
|
||||
for ds in data_series:
|
||||
var size = ThemeDB.fallback_font.get_string_size(ds.label, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size)
|
||||
label_widths.append(size.x)
|
||||
total_width += size.x
|
||||
total_width += (data_series.size() - 1) * 10
|
||||
var start_x = x0 + (w - total_width) / 2.0
|
||||
var legend_y = y0 + h + 14
|
||||
var current_x = start_x
|
||||
for i in data_series.size():
|
||||
var ds = data_series[i]
|
||||
draw_string(ThemeDB.fallback_font, Vector2(current_x, legend_y), ds.label, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, ds.color)
|
||||
current_x += label_widths[i] + 10
|
||||
|
||||
func _format_value(value : float, d := 1) -> String:
|
||||
match display_mode:
|
||||
0:
|
||||
return _format_bytes(value, d) + "/s"
|
||||
1:
|
||||
return "%.*f ms" % [d, value]
|
||||
_:
|
||||
return "%.*f" % [d, value]
|
||||
|
||||
func _format_bytes(b : float, d := 1) -> String:
|
||||
if b <= 0: return "0 B"
|
||||
var u = ["B","KB","MB","GB"]
|
||||
var i = 0
|
||||
var v = abs(b)
|
||||
while v >= 1000.0 and i < 3:
|
||||
v /= 1000.0
|
||||
i += 1
|
||||
return "%.*f %s" % [d, v, u[i]]
|
||||
1
addons/GD-Sync/UI/Profiler/ProfilerGraph.gd.uid
Normal file
1
addons/GD-Sync/UI/Profiler/ProfilerGraph.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://8618gttywoy6
|
||||
256
addons/GD-Sync/UI/Profiler/ProfilerLabel.gd
Normal file
256
addons/GD-Sync/UI/Profiler/ProfilerLabel.gd
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
@tool
|
||||
extends RichTextLabel
|
||||
|
||||
#Copyright (c) 2023-present GD-Sync.
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source form, with or without modification,
|
||||
#are permitted provided that the following conditions are met:
|
||||
#
|
||||
#1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
#2. Neither the name of GD-Sync nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific
|
||||
# prior written permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
#EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
#OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
#SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
#TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
#ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
#SUCH DAMAGE.
|
||||
|
||||
@export var profiler : Node = null : set = _set_profiler
|
||||
@export var client_id : int = -1
|
||||
@export var stat_key : String = "up_sec"
|
||||
@export var is_bytes : bool = true
|
||||
@export var decimal_places : int = 1
|
||||
@export var suffix : String = "/s"
|
||||
@export var color_hex : String = "#ffffff"
|
||||
@export var label_text : String = "Upload" : set = _set_label_text
|
||||
@export var show_label_text : bool = true
|
||||
@export_group("Custom Data")
|
||||
@export var use_custom_data : bool = false
|
||||
@export var show_missing : bool = true
|
||||
@export var missing_text : String = "N/A"
|
||||
|
||||
func _ready():
|
||||
bbcode_enabled = true
|
||||
_update_display()
|
||||
if profiler:
|
||||
_connect_signal()
|
||||
|
||||
func _set_profiler(v):
|
||||
if profiler == v: return
|
||||
if profiler:
|
||||
_disconnect_signal()
|
||||
profiler = v
|
||||
if profiler:
|
||||
_connect_signal()
|
||||
_update_display()
|
||||
|
||||
func _set_label_text(v):
|
||||
label_text = v
|
||||
_update_display()
|
||||
|
||||
func _connect_signal():
|
||||
if not profiler: return
|
||||
if profiler.has_signal("stats_updated") and not profiler.stats_updated.is_connected(_on_stats_updated):
|
||||
profiler.stats_updated.connect(_on_stats_updated)
|
||||
if profiler.has_signal("custom_data_updated") and not profiler.custom_data_updated.is_connected(_on_custom_data):
|
||||
profiler.custom_data_updated.connect(_on_custom_data)
|
||||
if profiler.has_signal("profiler_cleared") and not profiler.profiler_cleared.is_connected(_on_clear):
|
||||
profiler.profiler_cleared.connect(_on_clear)
|
||||
|
||||
func _disconnect_signal():
|
||||
if not profiler: return
|
||||
if profiler.has_signal("stats_updated") and profiler.stats_updated.is_connected(_on_stats_updated):
|
||||
profiler.stats_updated.disconnect(_on_stats_updated)
|
||||
if profiler.has_signal("custom_data_updated") and profiler.custom_data_updated.is_connected(_on_custom_data):
|
||||
profiler.custom_data_updated.disconnect(_on_custom_data)
|
||||
if profiler.has_signal("profiler_cleared") and profiler.profiler_cleared.is_connected(_on_clear):
|
||||
profiler.profiler_cleared.disconnect(_on_clear)
|
||||
|
||||
func _on_stats_updated(cid : int, stats : Dictionary):
|
||||
if use_custom_data: return
|
||||
if client_id != -1 and cid != client_id: return
|
||||
if client_id == -1 and cid != -1: return
|
||||
var val = stats.get(stat_key, 0.0)
|
||||
var value_str = _format_value(val)
|
||||
_set_text(value_str)
|
||||
|
||||
func _on_custom_data(data : Dictionary):
|
||||
if not use_custom_data: return
|
||||
_update_from_custom_data(data)
|
||||
|
||||
func _on_clear():
|
||||
if use_custom_data:
|
||||
_update_from_custom_data({})
|
||||
else:
|
||||
_update_display()
|
||||
|
||||
func _update_from_custom_data(data : Dictionary):
|
||||
var val = data.get(stat_key, null)
|
||||
if val == null:
|
||||
if show_missing:
|
||||
_set_text(missing_text)
|
||||
else:
|
||||
text = ""
|
||||
else:
|
||||
var formatted = _format_custom_value(val)
|
||||
_set_text(formatted)
|
||||
|
||||
func _update_display():
|
||||
if use_custom_data:
|
||||
_update_from_custom_data({})
|
||||
else:
|
||||
_set_text("...")
|
||||
|
||||
func _set_text(value_str : String):
|
||||
var prefix = label_text + ": " if show_label_text else ""
|
||||
text = "[color=%s]%s%s[/color]" % [color_hex, prefix, value_str]
|
||||
|
||||
func _format_value(b) -> String:
|
||||
if is_nan(b) or is_inf(b):
|
||||
return "0 B" + suffix
|
||||
if not is_bytes:
|
||||
return _format_number(int(b)) + suffix
|
||||
if b == 0:
|
||||
return "0 B" + suffix
|
||||
var u = ["B","KB","MB","GB"]
|
||||
var i = 0
|
||||
var v = abs(b)
|
||||
while v >= 1000.0 and i < 3:
|
||||
v /= 1000.0
|
||||
i += 1
|
||||
var formatted = "%.*f" % [decimal_places, v]
|
||||
var parts = formatted.split(".")
|
||||
var int_part = _format_number(int(parts[0]))
|
||||
var frac_part = ("." + parts[1]) if parts.size() > 1 else ""
|
||||
return ("-" if b < 0 else "") + int_part + frac_part + " " + u[i] + suffix
|
||||
|
||||
func _format_custom_value(val) -> String:
|
||||
match typeof(val):
|
||||
TYPE_FLOAT, TYPE_INT:
|
||||
if abs(val) >= 1000.0 and is_bytes:
|
||||
return _format_bytes(float(val), decimal_places)
|
||||
else:
|
||||
return "%.*f" % [decimal_places, val] if typeof(val) == TYPE_FLOAT else str(val)
|
||||
TYPE_BOOL:
|
||||
return "True" if val else "False"
|
||||
TYPE_STRING:
|
||||
return val
|
||||
TYPE_ARRAY, TYPE_PACKED_BYTE_ARRAY, TYPE_PACKED_INT32_ARRAY, TYPE_PACKED_INT64_ARRAY, \
|
||||
TYPE_PACKED_FLOAT32_ARRAY, TYPE_PACKED_FLOAT64_ARRAY, TYPE_PACKED_STRING_ARRAY, \
|
||||
TYPE_PACKED_VECTOR2_ARRAY, TYPE_PACKED_VECTOR3_ARRAY, TYPE_PACKED_VECTOR4_ARRAY, \
|
||||
TYPE_PACKED_COLOR_ARRAY:
|
||||
return _pretty_print_array(val)
|
||||
TYPE_DICTIONARY:
|
||||
return _pretty_print_dict(val)
|
||||
TYPE_COLOR:
|
||||
return _format_color(val)
|
||||
_:
|
||||
return str(val)
|
||||
|
||||
func _pretty_print_array(arr, indent_level := 0) -> String:
|
||||
if arr.is_empty():
|
||||
return "[]"
|
||||
var indent := " "
|
||||
var result := "[\n"
|
||||
for i in arr.size():
|
||||
var item = arr[i]
|
||||
var formatted = _pretty_print_value(item, indent_level + 1)
|
||||
result += indent.repeat(indent_level + 1) + formatted
|
||||
if i < arr.size() - 1:
|
||||
result += ","
|
||||
result += "\n"
|
||||
result += indent.repeat(indent_level) + "]"
|
||||
return result
|
||||
|
||||
func _pretty_print_dict(dict : Dictionary, indent_level := 0) -> String:
|
||||
if dict.is_empty():
|
||||
return "{}"
|
||||
var indent := " "
|
||||
var result := "{\n"
|
||||
var keys = dict.keys()
|
||||
keys.sort()
|
||||
for i in keys.size():
|
||||
var key = keys[i]
|
||||
var value = dict[key]
|
||||
var key_type = typeof(key)
|
||||
var key_str = _escape_string(str(key))
|
||||
var key_color = _get_type_color(key_type)
|
||||
var formatted = _pretty_print_value(value, indent_level + 1)
|
||||
result += indent.repeat(indent_level + 1) + "[color=%s]%s[/color]: %s" % [key_color, key_str, formatted]
|
||||
if i < keys.size() - 1:
|
||||
result += ","
|
||||
result += "\n"
|
||||
result += indent.repeat(indent_level) + "}"
|
||||
return result
|
||||
|
||||
func _pretty_print_value(val, indent_level := 0) -> String:
|
||||
match typeof(val):
|
||||
TYPE_ARRAY, TYPE_PACKED_BYTE_ARRAY, TYPE_PACKED_INT32_ARRAY, TYPE_PACKED_INT64_ARRAY, \
|
||||
TYPE_PACKED_FLOAT32_ARRAY, TYPE_PACKED_FLOAT64_ARRAY, TYPE_PACKED_STRING_ARRAY, \
|
||||
TYPE_PACKED_VECTOR2_ARRAY, TYPE_PACKED_VECTOR3_ARRAY, TYPE_PACKED_VECTOR4_ARRAY, \
|
||||
TYPE_PACKED_COLOR_ARRAY:
|
||||
return _pretty_print_array(val, indent_level)
|
||||
TYPE_DICTIONARY:
|
||||
return _pretty_print_dict(val, indent_level)
|
||||
TYPE_COLOR:
|
||||
return _format_color(val)
|
||||
TYPE_STRING:
|
||||
if val.is_valid_int() or val.is_valid_float():
|
||||
return "[color=#f5c2e7]%s[/color]" % _escape_string(val)
|
||||
else:
|
||||
return "[color=#a6e3a1]%s[/color]" % _escape_string(val)
|
||||
TYPE_INT, TYPE_FLOAT:
|
||||
return "[color=#89b4fa]%s[/color]" % _format_custom_value(val)
|
||||
TYPE_BOOL:
|
||||
return "[color=#f38ba8]Yes[/color]" if val else "[color=#f38ba8]No[/color]"
|
||||
_:
|
||||
return "[color=#cdd6f4]%s[/color]" % str(val)
|
||||
|
||||
func _format_color(col : Color) -> String:
|
||||
var hex = col.to_html(false)
|
||||
return "[color=#%s]██[/color] %s" % [hex, col]
|
||||
|
||||
func _escape_string(s : String) -> String:
|
||||
return "\"" + s.replace("\"", "\\\"") + "\""
|
||||
|
||||
func _get_type_color(t : int) -> String:
|
||||
match t:
|
||||
TYPE_STRING: return "#f5c2e7"
|
||||
TYPE_INT, TYPE_FLOAT: return "#89b4fa"
|
||||
TYPE_BOOL: return "#f38ba8"
|
||||
TYPE_ARRAY, TYPE_PACKED_BYTE_ARRAY, TYPE_PACKED_INT32_ARRAY, TYPE_PACKED_INT64_ARRAY, \
|
||||
TYPE_PACKED_FLOAT32_ARRAY, TYPE_PACKED_FLOAT64_ARRAY, TYPE_PACKED_STRING_ARRAY, \
|
||||
TYPE_PACKED_VECTOR2_ARRAY, TYPE_PACKED_VECTOR3_ARRAY, TYPE_PACKED_VECTOR4_ARRAY, \
|
||||
TYPE_PACKED_COLOR_ARRAY: return "#cba6f7"
|
||||
TYPE_DICTIONARY: return "#f9e2af"
|
||||
TYPE_COLOR: return "#94e2d5"
|
||||
_: return "#cdd6f4"
|
||||
|
||||
func _format_bytes(b : float, d := 1) -> String:
|
||||
if b <= 0: return "0 B"
|
||||
var u = ["B","KB","MB","GB"]
|
||||
var i = 0
|
||||
var v = abs(b)
|
||||
while v >= 1000.0 and i < 3:
|
||||
v /= 1000.0
|
||||
i += 1
|
||||
return "%.*f %s" % [d, v, u[i]]
|
||||
|
||||
func _format_number(n : float) -> String:
|
||||
var s = str(int(abs(n)))
|
||||
var result = ""
|
||||
for i in range(s.length() - 1, -1, -1):
|
||||
if (s.length() - 1 - i) % 3 == 0 and i < s.length() - 1:
|
||||
result = "." + result
|
||||
result = s[i] + result
|
||||
return ("-" if n < 0 else "") + result
|
||||
1
addons/GD-Sync/UI/Profiler/ProfilerLabel.gd.uid
Normal file
1
addons/GD-Sync/UI/Profiler/ProfilerLabel.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b3p26nyamgl8j
|
||||
Loading…
Add table
Add a link
Reference in a new issue