Improved signal handling
This commit is contained in:
parent
4e5b908f05
commit
4ad50e75db
@ -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()
|
10
client/Global.tscn
Normal file
10
client/Global.tscn
Normal file
@ -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")
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -17,7 +17,7 @@ config/icon="res://ui/icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
||||
Global="*res://Global.gd"
|
||||
Global="*res://Global.tscn"
|
||||
|
||||
[debug]
|
||||
|
||||
|
@ -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
|
||||
|
||||
func connect_fake():
|
||||
for signal_name in signals:
|
||||
set(signal_name, Signal(self, signal_name))
|
||||
add_user_signal(signal_name)
|
@ -1,7 +1,5 @@
|
||||
extends LineEdit
|
||||
|
||||
signal chat_message_submitted(message: String)
|
||||
|
||||
func _unhandled_input(event):
|
||||
if Global.interacting_with_ui:
|
||||
return
|
||||
|
9
client/ui/debug/DebugLabelText.gd
Normal file
9
client/ui/debug/DebugLabelText.gd
Normal file
@ -0,0 +1,9 @@
|
||||
@tool
|
||||
extends Label
|
||||
|
||||
func _ready():
|
||||
text = get_parent().name + ":"
|
||||
|
||||
func _get_configuration_warnings():
|
||||
text = get_parent().name + ":"
|
||||
return []
|
@ -1,4 +1,4 @@
|
||||
extends Range
|
||||
extends Slider
|
||||
|
||||
func _ready():
|
||||
set_value_no_signal(Global.environment.adjustment_brightness)
|
||||
|
@ -1,4 +1,4 @@
|
||||
extends Range
|
||||
extends Slider
|
||||
|
||||
func _ready():
|
||||
set_value_no_signal(Global.environment.adjustment_contrast)
|
||||
|
@ -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]
|
||||
Global.viewport.scaling_3d_scale = fsrQuality[index]
|
@ -1,4 +1,4 @@
|
||||
extends Range
|
||||
extends Slider
|
||||
|
||||
func _ready():
|
||||
set_value_no_signal(Global.environment.adjustment_saturation)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user