diff --git a/client/Global.gd b/client/Global.gd index 758b535..468a1ca 100644 --- a/client/Global.gd +++ b/client/Global.gd @@ -1,12 +1,21 @@ extends Node +@export var environment: Environment +@export var camera_attributes: CameraAttributesPractical + var camera: Camera3D var player: Player +var viewport: Viewport +var window: Window var players: PlayerManager var account_id: String var auth_token: String var interacting_with_ui: bool var instance_id: int var username: String -var environment: Environment -var camera_attributes: CameraAttributesPractical + +func _enter_tree(): + instance_id = OS.get_process_id() % 4 + username = "user%d" % instance_id + viewport = get_viewport() + window = get_window() \ No newline at end of file diff --git a/client/Global.tscn b/client/Global.tscn new file mode 100644 index 0000000..c32cf4c --- /dev/null +++ b/client/Global.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=4 format=3 uid="uid://pt0ayry11q3a"] + +[ext_resource type="Script" path="res://Global.gd" id="1_tr8a5"] +[ext_resource type="Environment" uid="uid://dixa0yso2s1u3" path="res://world/Environment.tres" id="2_leqw1"] +[ext_resource type="CameraAttributesPractical" uid="uid://b835orxyqq6w5" path="res://world/CameraPractical.tres" id="3_tsbch"] + +[node name="Global" type="Node"] +script = ExtResource("1_tr8a5") +environment = ExtResource("2_leqw1") +camera_attributes = ExtResource("3_tsbch") diff --git a/client/Main.gd b/client/Main.gd index 3b93fb5..c9befbe 100644 --- a/client/Main.gd +++ b/client/Main.gd @@ -1,13 +1,5 @@ extends Node -@export var world_environment: WorldEnvironment - -func _enter_tree(): - Global.environment = world_environment.environment - Global.camera_attributes = world_environment.camera_attributes - Global.instance_id = OS.get_process_id() % 4 - Global.username = "user%d" % Global.instance_id - func _ready(): %Logout.success.emit() pause(true) diff --git a/client/Main.tscn b/client/Main.tscn index 8c3efac..b0992b9 100644 --- a/client/Main.tscn +++ b/client/Main.tscn @@ -32,9 +32,8 @@ size = Vector2(25, 25) [sub_resource type="BoxShape3D" id="BoxShape3D_yg2lt"] size = Vector3(100, 1, 100) -[node name="Main" type="Node" node_paths=PackedStringArray("world_environment")] +[node name="Main" type="Node"] script = ExtResource("1_cw3ws") -world_environment = NodePath("World/Environment") [node name="Client" type="Node" parent="."] unique_name_in_owner = true diff --git a/client/project.godot b/client/project.godot index e502f9b..02faba6 100644 --- a/client/project.godot +++ b/client/project.godot @@ -17,7 +17,7 @@ config/icon="res://ui/icon.svg" [autoload] -Global="*res://Global.gd" +Global="*res://Global.tscn" [debug] diff --git a/client/ui/UI.gd b/client/ui/UI.gd index bd302bb..9896607 100644 --- a/client/ui/UI.gd +++ b/client/ui/UI.gd @@ -3,17 +3,37 @@ extends Control signal chat_message_submitted(message: String) +var signals := [ + "login", + "logout", + "ping_changed", + "download_changed", + "upload_changed", + "message_received", +] + +var login: Signal +var logout: Signal var ping_changed: Signal var download_changed: Signal var upload_changed: Signal var message_received: Signal -var login: Signal -var logout: Signal func _enter_tree(): + if get_node_or_null("/root/Main"): + connect_main_scene() + else: + connect_fake() + +func connect_main_scene(): + login = %Login.success + logout = %Logout.success ping_changed = %Ping.changed download_changed = %Client.download_changed upload_changed = %Client.upload_changed message_received = %Chat.message_received - login = %Login.success - logout = %Logout.success \ No newline at end of file + +func connect_fake(): + for signal_name in signals: + set(signal_name, Signal(self, signal_name)) + add_user_signal(signal_name) \ No newline at end of file diff --git a/client/ui/chat/ChatInput.gd b/client/ui/chat/ChatInput.gd index d875cf0..2865279 100644 --- a/client/ui/chat/ChatInput.gd +++ b/client/ui/chat/ChatInput.gd @@ -1,7 +1,5 @@ extends LineEdit -signal chat_message_submitted(message: String) - func _unhandled_input(event): if Global.interacting_with_ui: return diff --git a/client/ui/debug/DebugLabelText.gd b/client/ui/debug/DebugLabelText.gd new file mode 100644 index 0000000..4de2109 --- /dev/null +++ b/client/ui/debug/DebugLabelText.gd @@ -0,0 +1,9 @@ +@tool +extends Label + +func _ready(): + text = get_parent().name + ":" + +func _get_configuration_warnings(): + text = get_parent().name + ":" + return [] diff --git a/client/ui/settings/Brightness.gd b/client/ui/settings/Brightness.gd index 32cfead..914a3ff 100644 --- a/client/ui/settings/Brightness.gd +++ b/client/ui/settings/Brightness.gd @@ -1,4 +1,4 @@ -extends Range +extends Slider func _ready(): set_value_no_signal(Global.environment.adjustment_brightness) diff --git a/client/ui/settings/Contrast.gd b/client/ui/settings/Contrast.gd index bab3d5d..b9721b5 100644 --- a/client/ui/settings/Contrast.gd +++ b/client/ui/settings/Contrast.gd @@ -1,4 +1,4 @@ -extends Range +extends Slider func _ready(): set_value_no_signal(Global.environment.adjustment_contrast) diff --git a/client/ui/settings/RenderScale.gd b/client/ui/settings/RenderScale.gd index 7021731..94bbe6f 100644 --- a/client/ui/settings/RenderScale.gd +++ b/client/ui/settings/RenderScale.gd @@ -3,7 +3,7 @@ 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 viewport_scale := Global.viewport.scaling_3d_scale var closest := -1 var closest_diff := 999.0 @@ -17,4 +17,4 @@ func _ready(): selected = closest func on_item_selected(index): - get_viewport().scaling_3d_scale = fsrQuality[index] \ No newline at end of file + Global.viewport.scaling_3d_scale = fsrQuality[index] \ No newline at end of file diff --git a/client/ui/settings/Saturation.gd b/client/ui/settings/Saturation.gd index fa0af6d..6583eaf 100644 --- a/client/ui/settings/Saturation.gd +++ b/client/ui/settings/Saturation.gd @@ -1,4 +1,4 @@ -extends Range +extends Slider func _ready(): set_value_no_signal(Global.environment.adjustment_saturation) diff --git a/client/ui/settings/ScaleMode.gd b/client/ui/settings/ScaleMode.gd index bdae9b6..4cd827e 100644 --- a/client/ui/settings/ScaleMode.gd +++ b/client/ui/settings/ScaleMode.gd @@ -1,9 +1,7 @@ extends OptionButton func _ready(): - var viewport = get_viewport() - - match viewport.scaling_3d_mode: + match Global.viewport.scaling_3d_mode: Viewport.SCALING_3D_MODE_BILINEAR: selected = 0 Viewport.SCALING_3D_MODE_FSR: @@ -12,12 +10,10 @@ func _ready(): selected = 2 func on_item_selected(index: int): - var viewport = get_viewport() - match index: 0: - viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_BILINEAR + Global.viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_BILINEAR 1: - viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_FSR + Global.viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_FSR 2: - viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_FSR2 + Global.viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_FSR2