From d8d0c690bde1fb90ba3fb34ad6eeeb4b7b4c0d40 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 12 Feb 2024 12:38:31 +0100 Subject: [PATCH] Improved UI --- client/ui/UI.tscn | 11 ++++++++- client/ui/debug/PerformanceLabel.gd | 5 +++- client/ui/settings/Preset.gd | 18 ++++----------- client/ui/settings/Settings.tscn | 36 +++++++++++++++++++---------- 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/client/ui/UI.tscn b/client/ui/UI.tscn index c681aea..efcc381 100644 --- a/client/ui/UI.tscn +++ b/client/ui/UI.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://dagn5bf7ou3sd"] +[gd_scene load_steps=15 format=3 uid="uid://dagn5bf7ou3sd"] [ext_resource type="PackedScene" uid="uid://cch67vqpsmtej" path="res://ui/debug/DebugLabel.tscn" id="1_7s8uu"] [ext_resource type="Script" path="res://ui/UI.gd" id="1_l5b6o"] @@ -7,6 +7,7 @@ [ext_resource type="Script" path="res://ui/debug/PositionLabel.gd" id="4_beqf6"] [ext_resource type="Script" path="res://ui/debug/VelocityLabel.gd" id="5_8lm6a"] [ext_resource type="Script" path="res://ui/chat/ChatBox.gd" id="5_43juw"] +[ext_resource type="Script" path="res://ui/debug/PerformanceLabel.gd" id="5_ab7ln"] [ext_resource type="Script" path="res://ui/chat/ChatInput.gd" id="6_cg2h5"] [ext_resource type="Script" path="res://ui/debug/UploadLabel.gd" id="7_cfnpx"] [ext_resource type="Script" path="res://ui/debug/DownloadLabel.gd" id="8_ogt38"] @@ -32,6 +33,14 @@ layout_mode = 2 layout_mode = 2 script = ExtResource("2_i200p") +[node name="Frame" parent="Canvas/TopLeft/VBoxContainer" instance=ExtResource("1_7s8uu")] +layout_mode = 2 +script = ExtResource("5_ab7ln") +monitor = 1 +multiply = 1000.0 +precision = 0.1 +suffix = " ms" + [node name="Ping" parent="Canvas/TopLeft/VBoxContainer" instance=ExtResource("1_7s8uu")] layout_mode = 2 script = ExtResource("3_xjdws") diff --git a/client/ui/debug/PerformanceLabel.gd b/client/ui/debug/PerformanceLabel.gd index b11cde3..76aaf34 100644 --- a/client/ui/debug/PerformanceLabel.gd +++ b/client/ui/debug/PerformanceLabel.gd @@ -1,6 +1,9 @@ extends DebugLabel @export var monitor: Performance.Monitor +@export var multiply := 1.0 +@export var precision := 0.1 +@export var suffix := "" func _process(_delta): - text = str(Performance.get_monitor(monitor)) + text = str(snapped(Performance.get_monitor(monitor) * multiply, precision)) + suffix diff --git a/client/ui/settings/Preset.gd b/client/ui/settings/Preset.gd index d081f6e..d667285 100644 --- a/client/ui/settings/Preset.gd +++ b/client/ui/settings/Preset.gd @@ -1,15 +1,4 @@ -extends OptionButton - -func on_item_selected(index: int): - match index: - 0: - preset_low() - 1: - preset_medium() - 2: - preset_high() - - get_tree().call_group("video_preset_setting", "_ready") +extends Node func preset_low(): get_viewport().scaling_3d_mode = Viewport.SCALING_3D_MODE_BILINEAR @@ -20,6 +9,7 @@ func preset_low(): Global.environment.volumetric_fog_enabled = false Global.camera_attributes.dof_blur_far_enabled = false Global.camera_attributes.dof_blur_near_enabled = false + get_tree().call_group("video_preset_setting", "_ready") func preset_medium(): get_viewport().scaling_3d_mode = Viewport.SCALING_3D_MODE_FSR2 @@ -30,6 +20,7 @@ func preset_medium(): Global.environment.volumetric_fog_enabled = false Global.camera_attributes.dof_blur_far_enabled = false Global.camera_attributes.dof_blur_near_enabled = false + get_tree().call_group("video_preset_setting", "_ready") func preset_high(): get_viewport().scaling_3d_mode = Viewport.SCALING_3D_MODE_FSR2 @@ -39,4 +30,5 @@ func preset_high(): Global.environment.ssil_enabled = true Global.environment.volumetric_fog_enabled = true Global.camera_attributes.dof_blur_far_enabled = true - Global.camera_attributes.dof_blur_near_enabled = true \ No newline at end of file + Global.camera_attributes.dof_blur_near_enabled = true + get_tree().call_group("video_preset_setting", "_ready") \ No newline at end of file diff --git a/client/ui/settings/Settings.tscn b/client/ui/settings/Settings.tscn index c96a4a7..63c11f4 100644 --- a/client/ui/settings/Settings.tscn +++ b/client/ui/settings/Settings.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=3 uid="uid://bqpbrju7mc7d5"] +[gd_scene load_steps=14 format=3 uid="uid://bqpbrju7mc7d5"] [ext_resource type="Script" path="res://ui/settings/Settings.gd" id="1_gx3lf"] [ext_resource type="Script" path="res://ui/settings/Glow.gd" id="1_vkhbt"] @@ -12,6 +12,7 @@ [ext_resource type="Script" path="res://ui/settings/SSIL.gd" id="7_wt6tg"] [ext_resource type="Script" path="res://ui/settings/Contrast.gd" id="8_q4hif"] [ext_resource type="Script" path="res://ui/settings/Saturation.gd" id="9_wbvcu"] +[ext_resource type="Script" path="res://ui/settings/VolumetricFog.gd" id="10_enf67"] [node name="Settings" type="Control"] layout_mode = 3 @@ -47,17 +48,26 @@ size_flags_horizontal = 3 text = "Preset:" script = ExtResource("2_72a3s") -[node name="OptionButton" type="OptionButton" parent="TabContainer/Video/VBoxContainer/Preset"] +[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/Video/VBoxContainer/Preset"] layout_mode = 2 size_flags_horizontal = 3 -item_count = 3 -selected = 2 -popup/item_0/text = "Low" -popup/item_0/id = 0 -popup/item_1/text = "Medium" -popup/item_1/id = 1 -popup/item_2/text = "High" -popup/item_2/id = 2 + +[node name="Low" type="Button" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Low" + +[node name="Medium" type="Button" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Medium" + +[node name="High" type="Button" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "High" + +[node name="Preset" type="Node" parent="TabContainer/Video/VBoxContainer/Preset/HBoxContainer"] script = ExtResource("3_6lki0") [node name="Render Scale" type="HBoxContainer" parent="TabContainer/Video/VBoxContainer"] @@ -181,7 +191,7 @@ script = ExtResource("2_72a3s") [node name="CheckButton" type="CheckButton" parent="TabContainer/Video/VBoxContainer/Volumetric Fog" groups=["video_preset_setting"]] layout_mode = 2 size_flags_horizontal = 3 -script = ExtResource("7_wt6tg") +script = ExtResource("10_enf67") [node name="Brightness" type="HBoxContainer" parent="TabContainer/Video/VBoxContainer"] custom_minimum_size = Vector2(0, 32) @@ -244,7 +254,9 @@ layout_mode = 2 [node name="Volume" type="HSlider" parent="TabContainer/Audio"] layout_mode = 2 -[connection signal="item_selected" from="TabContainer/Video/VBoxContainer/Preset/OptionButton" to="TabContainer/Video/VBoxContainer/Preset/OptionButton" method="on_item_selected"] +[connection signal="pressed" from="TabContainer/Video/VBoxContainer/Preset/HBoxContainer/Low" to="TabContainer/Video/VBoxContainer/Preset/HBoxContainer/Preset" method="preset_low"] +[connection signal="pressed" from="TabContainer/Video/VBoxContainer/Preset/HBoxContainer/Medium" to="TabContainer/Video/VBoxContainer/Preset/HBoxContainer/Preset" method="preset_medium"] +[connection signal="pressed" from="TabContainer/Video/VBoxContainer/Preset/HBoxContainer/High" to="TabContainer/Video/VBoxContainer/Preset/HBoxContainer/Preset" method="preset_high"] [connection signal="item_selected" from="TabContainer/Video/VBoxContainer/Render Scale/OptionButton" to="TabContainer/Video/VBoxContainer/Render Scale/OptionButton" method="on_item_selected"] [connection signal="item_selected" from="TabContainer/Video/VBoxContainer/Scale Mode/OptionButton" to="TabContainer/Video/VBoxContainer/Scale Mode/OptionButton" method="on_item_selected"] [connection signal="toggled" from="TabContainer/Video/VBoxContainer/Glow/CheckButton" to="TabContainer/Video/VBoxContainer/Glow/CheckButton" method="on_toggled"]