Added a settings menu

This commit is contained in:
Eduard Urbach 2024-02-05 23:42:04 +01:00
parent 08292dc20a
commit 81670e7df5
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
11 changed files with 215 additions and 45 deletions

View File

@ -1,6 +1,7 @@
extends Node extends Node
func _ready(): func _ready():
%Logout.success.emit()
pause(true) pause(true)
Global.instance_id = OS.get_process_id() % 4 Global.instance_id = OS.get_process_id() % 4

View File

@ -90,22 +90,6 @@ autostart = true
[node name="World" type="Node3D" parent="."] [node name="World" type="Node3D" parent="."]
[node name="Follow" type="Node3D" parent="World"]
[node name="Pivot" type="Node3D" parent="World/Follow"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
[node name="Camera" type="Camera3D" parent="World/Follow/Pivot" node_paths=PackedStringArray("follow", "pivot")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.5, 7.5)
current = true
fov = 30.0
size = 10.0
far = 1000.0
script = ExtResource("18_wogcj")
follow = NodePath("../..")
pivot = NodePath("..")
follow_speed = 5.0
[node name="Sun" type="DirectionalLight3D" parent="World"] [node name="Sun" type="DirectionalLight3D" parent="World"]
transform = Transform3D(0.984808, 0.122788, -0.122788, 0, 0.707107, 0.707107, 0.173648, -0.696364, 0.696364, 0, 3, 0) transform = Transform3D(0.984808, 0.122788, -0.122788, 0, 0.707107, 0.707107, 0.173648, -0.696364, 0.696364, 0, 3, 0)
light_energy = 0.1 light_energy = 0.1
@ -149,6 +133,21 @@ material_override = ExtResource("18_tja64")
cast_shadow = 0 cast_shadow = 0
multimesh = ExtResource("19_ae26a") multimesh = ExtResource("19_ae26a")
[node name="Follow" type="Node3D" parent="World"]
[node name="Pivot" type="Node3D" parent="World/Follow"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
[node name="Camera" type="Camera3D" parent="World/Follow/Pivot" node_paths=PackedStringArray("follow_node", "pivot_node")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.5, 7.5)
current = true
fov = 30.0
size = 10.0
far = 1000.0
script = ExtResource("18_wogcj")
follow_node = NodePath("../..")
pivot_node = NodePath("..")
[node name="Players" type="Node3D" parent="."] [node name="Players" type="Node3D" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
script = ExtResource("16_dp6bj") script = ExtResource("16_dp6bj")

View File

@ -1,18 +1,25 @@
extends Camera3D extends Camera3D
@export var follow: Node3D @export_group("Main")
@export var pivot: Node3D @export var follow_node: Node3D
@export var pivot_node: Node3D
@export_group("Follow")
@export var follow_enabled: bool
@export var follow_speed: float @export var follow_speed: float
func _ready(): func _ready():
Global.camera = self Global.camera = self
look_at(pivot.position) look_at(pivot_node.position)
func _process(delta): func _process(delta):
if Global.player == null: if Global.player == null:
return return
follow.position = lerp(follow.position, Global.player.position, follow_speed * delta) if follow_enabled:
follow_node.position = lerp(follow_node.position, Global.player.position, follow_speed * delta)
else:
follow_node.position = Global.player.position
# @export var shake_strength: float # @export var shake_strength: float
# var noise = FastNoiseLite.new() # var noise = FastNoiseLite.new()

View File

@ -111,4 +111,5 @@ common/physics_ticks_per_second=100
[rendering] [rendering]
anti_aliasing/quality/use_taa=true scaling_3d/mode=2
scaling_3d/scale=0.77

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://dagn5bf7ou3sd"] [gd_scene load_steps=13 format=3 uid="uid://dagn5bf7ou3sd"]
[ext_resource type="PackedScene" uid="uid://cch67vqpsmtej" path="res://ui/debug/DebugLabel.tscn" id="1_7s8uu"] [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"] [ext_resource type="Script" path="res://ui/UI.gd" id="1_l5b6o"]
@ -11,30 +11,31 @@
[ext_resource type="Script" path="res://ui/debug/UploadLabel.gd" id="7_cfnpx"] [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"] [ext_resource type="Script" path="res://ui/debug/DownloadLabel.gd" id="8_ogt38"]
[ext_resource type="Script" path="res://ui/connect/ConnectPanel.gd" id="11_cwl0t"] [ext_resource type="Script" path="res://ui/connect/ConnectPanel.gd" id="11_cwl0t"]
[ext_resource type="PackedScene" uid="uid://bqpbrju7mc7d5" path="res://ui/settings/Settings.tscn" id="11_rt7sl"]
[node name="UI" type="Control"] [node name="UI" type="Control"]
layout_mode = 3 layout_mode = 3
anchors_preset = 0 anchors_preset = 0
script = ExtResource("1_l5b6o") script = ExtResource("1_l5b6o")
[node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="Canvas" type="CanvasLayer" parent="."]
[node name="TopLeft" type="MarginContainer" parent="CanvasLayer"] [node name="TopLeft" type="MarginContainer" parent="Canvas"]
offset_right = 40.0 offset_right = 40.0
offset_bottom = 50.0 offset_bottom = 50.0
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/TopLeft"] [node name="VBoxContainer" type="VBoxContainer" parent="Canvas/TopLeft"]
layout_mode = 2 layout_mode = 2
[node name="FPS" parent="CanvasLayer/TopLeft/VBoxContainer" instance=ExtResource("1_7s8uu")] [node name="FPS" parent="Canvas/TopLeft/VBoxContainer" instance=ExtResource("1_7s8uu")]
layout_mode = 2 layout_mode = 2
script = ExtResource("2_i200p") script = ExtResource("2_i200p")
[node name="Ping" parent="CanvasLayer/TopLeft/VBoxContainer" instance=ExtResource("1_7s8uu")] [node name="Ping" parent="Canvas/TopLeft/VBoxContainer" instance=ExtResource("1_7s8uu")]
layout_mode = 2 layout_mode = 2
script = ExtResource("3_xjdws") script = ExtResource("3_xjdws")
[node name="BottomLeft" type="MarginContainer" parent="CanvasLayer"] [node name="BottomLeft" type="MarginContainer" parent="Canvas"]
anchors_preset = 2 anchors_preset = 2
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
@ -42,22 +43,22 @@ offset_top = -134.0
offset_right = 263.0 offset_right = 263.0
grow_vertical = 0 grow_vertical = 0
[node name="Chat" type="VBoxContainer" parent="CanvasLayer/BottomLeft"] [node name="Chat" type="VBoxContainer" parent="Canvas/BottomLeft"]
layout_mode = 2 layout_mode = 2
alignment = 2 alignment = 2
[node name="ChatBox" type="RichTextLabel" parent="CanvasLayer/BottomLeft/Chat"] [node name="ChatBox" type="RichTextLabel" parent="Canvas/BottomLeft/Chat"]
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
bbcode_enabled = true bbcode_enabled = true
scroll_following = true scroll_following = true
script = ExtResource("5_43juw") script = ExtResource("5_43juw")
[node name="ChatInput" type="LineEdit" parent="CanvasLayer/BottomLeft/Chat"] [node name="ChatInput" type="LineEdit" parent="Canvas/BottomLeft/Chat"]
layout_mode = 2 layout_mode = 2
script = ExtResource("6_cg2h5") script = ExtResource("6_cg2h5")
[node name="BottomRight" type="MarginContainer" parent="CanvasLayer"] [node name="BottomRight" type="MarginContainer" parent="Canvas"]
anchors_preset = 3 anchors_preset = 3
anchor_left = 1.0 anchor_left = 1.0
anchor_top = 1.0 anchor_top = 1.0
@ -68,21 +69,21 @@ offset_top = -54.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 0 grow_vertical = 0
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/BottomRight"] [node name="VBoxContainer" type="VBoxContainer" parent="Canvas/BottomRight"]
layout_mode = 2 layout_mode = 2
alignment = 2 alignment = 2
[node name="Send" parent="CanvasLayer/BottomRight/VBoxContainer" instance=ExtResource("1_7s8uu")] [node name="Send" parent="Canvas/BottomRight/VBoxContainer" instance=ExtResource("1_7s8uu")]
layout_mode = 2 layout_mode = 2
alignment = 2 alignment = 2
script = ExtResource("7_cfnpx") script = ExtResource("7_cfnpx")
[node name="Receive" parent="CanvasLayer/BottomRight/VBoxContainer" instance=ExtResource("1_7s8uu")] [node name="Receive" parent="Canvas/BottomRight/VBoxContainer" instance=ExtResource("1_7s8uu")]
layout_mode = 2 layout_mode = 2
alignment = 2 alignment = 2
script = ExtResource("8_ogt38") script = ExtResource("8_ogt38")
[node name="TopRight" type="MarginContainer" parent="CanvasLayer"] [node name="TopRight" type="MarginContainer" parent="Canvas"]
anchors_preset = 1 anchors_preset = 1
anchor_left = 1.0 anchor_left = 1.0
anchor_right = 1.0 anchor_right = 1.0
@ -90,20 +91,21 @@ offset_left = -79.0
offset_bottom = 102.0 offset_bottom = 102.0
grow_horizontal = 0 grow_horizontal = 0
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/TopRight"] [node name="VBoxContainer" type="VBoxContainer" parent="Canvas/TopRight"]
layout_mode = 2 layout_mode = 2
[node name="Position" parent="CanvasLayer/TopRight/VBoxContainer" instance=ExtResource("1_7s8uu")] [node name="Position" parent="Canvas/TopRight/VBoxContainer" instance=ExtResource("1_7s8uu")]
layout_mode = 2 layout_mode = 2
alignment = 2 alignment = 2
script = ExtResource("4_beqf6") script = ExtResource("4_beqf6")
[node name="Velocity" parent="CanvasLayer/TopRight/VBoxContainer" instance=ExtResource("1_7s8uu")] [node name="Velocity" parent="Canvas/TopRight/VBoxContainer" instance=ExtResource("1_7s8uu")]
layout_mode = 2 layout_mode = 2
alignment = 2 alignment = 2
script = ExtResource("5_8lm6a") script = ExtResource("5_8lm6a")
[node name="ConnectPanel" type="Panel" parent="CanvasLayer"] [node name="ConnectPanel" type="Panel" parent="Canvas"]
visible = false
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
@ -111,7 +113,7 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("11_cwl0t") script = ExtResource("11_cwl0t")
[node name="ConnectLabel" type="Label" parent="CanvasLayer/ConnectPanel"] [node name="ConnectLabel" type="Label" parent="Canvas/ConnectPanel"]
layout_mode = 1 layout_mode = 1
anchors_preset = 8 anchors_preset = 8
anchor_left = 0.5 anchor_left = 0.5
@ -126,6 +128,9 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
text = "Connecting..." text = "Connecting..."
[connection signal="focus_entered" from="CanvasLayer/BottomLeft/Chat/ChatInput" to="CanvasLayer/BottomLeft/Chat/ChatInput" method="_on_focus_entered"] [node name="Settings" parent="Canvas" instance=ExtResource("11_rt7sl")]
[connection signal="focus_exited" from="CanvasLayer/BottomLeft/Chat/ChatInput" to="CanvasLayer/BottomLeft/Chat/ChatInput" method="_on_focus_exited"] visible = false
[connection signal="text_submitted" from="CanvasLayer/BottomLeft/Chat/ChatInput" to="CanvasLayer/BottomLeft/Chat/ChatInput" method="_on_text_submitted"]
[connection signal="focus_entered" from="Canvas/BottomLeft/Chat/ChatInput" to="Canvas/BottomLeft/Chat/ChatInput" method="_on_focus_entered"]
[connection signal="focus_exited" from="Canvas/BottomLeft/Chat/ChatInput" to="Canvas/BottomLeft/Chat/ChatInput" method="_on_focus_exited"]
[connection signal="text_submitted" from="Canvas/BottomLeft/Chat/ChatInput" to="Canvas/BottomLeft/Chat/ChatInput" method="_on_text_submitted"]

View File

@ -0,0 +1,11 @@
extends CheckButton
var environment: Environment
func _ready():
var world_environment := get_node("/root/Main/World/Environment") as WorldEnvironment
environment = world_environment.environment
set_pressed_no_signal(environment.glow_enabled)
func on_toggled(toggled_on: bool):
environment.glow_enabled = toggled_on

View File

@ -0,0 +1,20 @@
extends OptionButton
var fsrQuality: Array[float] = [0.50, 0.59, 0.67, 0.77, 1.0]
func _ready():
var viewport_scale := get_viewport().scaling_3d_scale
var closest := -1
var closest_diff := 999.0
for index in range(item_count):
var diff: float = abs(viewport_scale - fsrQuality[index])
if diff < closest_diff:
closest = index
closest_diff = diff
selected = closest
func on_item_selected(index):
get_viewport().scaling_3d_scale = fsrQuality[index]

View File

@ -0,0 +1,23 @@
extends OptionButton
func _ready():
var viewport = get_viewport()
match viewport.scaling_3d_mode:
Viewport.SCALING_3D_MODE_BILINEAR:
selected = 0
Viewport.SCALING_3D_MODE_FSR:
selected = 1
Viewport.SCALING_3D_MODE_FSR2:
selected = 2
func on_item_selected(index: int):
var viewport = get_viewport()
match index:
0:
viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_BILINEAR
1:
viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_FSR
2:
viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_FSR2

View File

@ -0,0 +1,5 @@
extends Control
func _unhandled_input(event):
if event.is_action_pressed("menu"):
visible = !visible

View File

@ -0,0 +1,98 @@
[gd_scene load_steps=5 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"]
[ext_resource type="Script" path="res://ui/settings/ScaleMode.gd" id="2_7a2hi"]
[ext_resource type="Script" path="res://ui/settings/RenderScale.gd" id="3_o5ei3"]
[node name="Settings" type="Control"]
layout_mode = 3
anchor_left = 0.25
anchor_top = 0.25
anchor_right = 0.75
anchor_bottom = 0.75
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_gx3lf")
[node name="TabContainer" type="TabContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Video" type="MarginContainer" parent="TabContainer"]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Video"]
layout_mode = 2
[node name="HBoxContainer3" type="HBoxContainer" parent="TabContainer/Video/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/Video/VBoxContainer/HBoxContainer3"]
layout_mode = 2
size_flags_horizontal = 3
text = "Render Scale"
[node name="RenderScale2" type="OptionButton" parent="TabContainer/Video/VBoxContainer/HBoxContainer3"]
layout_mode = 2
size_flags_horizontal = 3
item_count = 5
popup/item_0/text = "Performance"
popup/item_0/id = 0
popup/item_1/text = "Balanced"
popup/item_1/id = 1
popup/item_2/text = "Quality"
popup/item_2/id = 2
popup/item_3/text = "Ultra Quality"
popup/item_3/id = 3
popup/item_4/text = "Native"
popup/item_4/id = 4
script = ExtResource("3_o5ei3")
[node name="HBoxContainer2" type="HBoxContainer" parent="TabContainer/Video/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/Video/VBoxContainer/HBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 3
text = "Scale Mode"
[node name="ScaleMode" type="OptionButton" parent="TabContainer/Video/VBoxContainer/HBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 3
item_count = 3
popup/item_0/text = "Bilinear"
popup/item_0/id = 0
popup/item_1/text = "FSR 1.0"
popup/item_1/id = 1
popup/item_2/text = "FSR 2.2"
popup/item_2/id = 2
script = ExtResource("2_7a2hi")
[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/Video/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="TabContainer/Video/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "Glow"
[node name="Glow" type="CheckButton" parent="TabContainer/Video/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
script = ExtResource("1_vkhbt")
[node name="Audio" type="MarginContainer" parent="TabContainer"]
visible = false
layout_mode = 2
[node name="Volume" type="HSlider" parent="TabContainer/Audio"]
layout_mode = 2
[connection signal="item_selected" from="TabContainer/Video/VBoxContainer/HBoxContainer3/RenderScale2" to="TabContainer/Video/VBoxContainer/HBoxContainer3/RenderScale2" method="on_item_selected"]
[connection signal="item_selected" from="TabContainer/Video/VBoxContainer/HBoxContainer2/ScaleMode" to="TabContainer/Video/VBoxContainer/HBoxContainer2/ScaleMode" method="on_item_selected"]
[connection signal="toggled" from="TabContainer/Video/VBoxContainer/HBoxContainer/Glow" to="TabContainer/Video/VBoxContainer/HBoxContainer/Glow" method="on_toggled"]