Switched from UDP to TCP-based connection; implemented creating, joining, leaving lobbies
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://gqrdpjslr4np"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bfaxxdr7v0emr" path="res://components/web_client.gd" id="1_80nbo"]
|
||||
[ext_resource type="Script" uid="uid://p5gvnyhjqe6o" path="res://components/web_client_tcp.gd" id="1_feb5d"]
|
||||
[ext_resource type="Script" uid="uid://c0cqkatyo4uj1" path="res://components/client_interface.gd" id="2_e2o6t"]
|
||||
|
||||
[sub_resource type="SystemFont" id="SystemFont_80nbo"]
|
||||
@@ -9,16 +9,10 @@ font_weight = 500
|
||||
|
||||
[node name="Game" type="Node"]
|
||||
|
||||
[node name="WebClient" type="Node" parent="." node_paths=PackedStringArray("name_input", "session_code_input", "output", "create_lobby_button", "join_lobby_button", "disconnect_lobby_button")]
|
||||
script = ExtResource("1_80nbo")
|
||||
name_input = NodePath("../ClientInterface/HBoxContainer/VBoxContainer/NameInput")
|
||||
session_code_input = NodePath("../ClientInterface/HBoxContainer/VBoxContainer/SessionCodeInput")
|
||||
output = NodePath("../ClientInterface/HBoxContainer/Output")
|
||||
create_lobby_button = NodePath("../ClientInterface/HBoxContainer/VBoxContainer/CreateLobbyButton")
|
||||
join_lobby_button = NodePath("../ClientInterface/HBoxContainer/VBoxContainer/JoinLobbyButton")
|
||||
disconnect_lobby_button = NodePath("../ClientInterface/HBoxContainer/VBoxContainer/DisconnectLobbyButton")
|
||||
[node name="WebClientTCP" type="Node" parent="."]
|
||||
script = ExtResource("1_feb5d")
|
||||
|
||||
[node name="ClientInterface" type="Control" parent="."]
|
||||
[node name="ClientInterface" type="Control" parent="." node_paths=PackedStringArray("client", "connect_button", "create_lobby_button", "join_lobby_button", "leave_lobby_button", "name_input", "lobby_code_input")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -26,6 +20,13 @@ anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("2_e2o6t")
|
||||
client = NodePath("../WebClientTCP")
|
||||
connect_button = NodePath("HBoxContainer/VBoxContainer/ConnectButton")
|
||||
create_lobby_button = NodePath("HBoxContainer/VBoxContainer/CreateLobbyButton")
|
||||
join_lobby_button = NodePath("HBoxContainer/VBoxContainer/JoinLobbyButton")
|
||||
leave_lobby_button = NodePath("HBoxContainer/VBoxContainer/LeaveLobbyButton")
|
||||
name_input = NodePath("HBoxContainer/VBoxContainer/NameInput")
|
||||
lobby_code_input = NodePath("HBoxContainer/VBoxContainer/LobbyCodeInput")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="ClientInterface"]
|
||||
layout_mode = 1
|
||||
@@ -45,23 +46,31 @@ offset_bottom = 1080.0
|
||||
custom_minimum_size = Vector2(300, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ConnectButton" type="Button" parent="ClientInterface/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Connect to Server"
|
||||
|
||||
[node name="NameInput" type="LineEdit" parent="ClientInterface/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
placeholder_text = "Your Name"
|
||||
editable = false
|
||||
|
||||
[node name="CreateLobbyButton" type="Button" parent="ClientInterface/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Create Lobby"
|
||||
|
||||
[node name="SessionCodeInput" type="LineEdit" parent="ClientInterface/HBoxContainer/VBoxContainer"]
|
||||
[node name="LobbyCodeInput" type="LineEdit" parent="ClientInterface/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
placeholder_text = "Lobby Code"
|
||||
editable = false
|
||||
|
||||
[node name="JoinLobbyButton" type="Button" parent="ClientInterface/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Join Lobby"
|
||||
|
||||
[node name="DisconnectLobbyButton" type="Button" parent="ClientInterface/HBoxContainer/VBoxContainer"]
|
||||
[node name="LeaveLobbyButton" type="Button" parent="ClientInterface/HBoxContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Disconnect"
|
||||
@@ -74,6 +83,12 @@ size_flags_vertical = 1
|
||||
theme_override_fonts/font = SubResource("SystemFont_80nbo")
|
||||
autowrap_mode = 2
|
||||
|
||||
[connection signal="pressed" from="ClientInterface/HBoxContainer/VBoxContainer/CreateLobbyButton" to="WebClient" method="_on_create_lobby_button_pressed"]
|
||||
[connection signal="pressed" from="ClientInterface/HBoxContainer/VBoxContainer/JoinLobbyButton" to="WebClient" method="_on_join_lobby_button_pressed"]
|
||||
[connection signal="pressed" from="ClientInterface/HBoxContainer/VBoxContainer/DisconnectLobbyButton" to="WebClient" method="_on_disconnect_lobby_button_pressed"]
|
||||
[connection signal="connected_to_lobby" from="WebClientTCP" to="ClientInterface" method="_on_web_client_tcp_connected_to_lobby"]
|
||||
[connection signal="connected_to_server" from="WebClientTCP" to="ClientInterface" method="_on_web_client_tcp_connected_to_server"]
|
||||
[connection signal="connection_error_occurred" from="WebClientTCP" to="ClientInterface" method="_on_web_client_tcp_connection_error_occurred"]
|
||||
[connection signal="disconnected_from_lobby" from="WebClientTCP" to="ClientInterface" method="_on_web_client_tcp_disconnected_from_lobby"]
|
||||
[connection signal="disconnected_from_server" from="WebClientTCP" to="ClientInterface" method="_on_web_client_tcp_disconnected_from_server"]
|
||||
[connection signal="pressed" from="ClientInterface/HBoxContainer/VBoxContainer/ConnectButton" to="ClientInterface" method="_on_connect_button_pressed"]
|
||||
[connection signal="pressed" from="ClientInterface/HBoxContainer/VBoxContainer/CreateLobbyButton" to="ClientInterface" method="_on_create_lobby_button_pressed"]
|
||||
[connection signal="pressed" from="ClientInterface/HBoxContainer/VBoxContainer/JoinLobbyButton" to="ClientInterface" method="_on_join_lobby_button_pressed"]
|
||||
[connection signal="pressed" from="ClientInterface/HBoxContainer/VBoxContainer/LeaveLobbyButton" to="ClientInterface" method="_on_disconnect_lobby_button_pressed"]
|
||||
|
||||
Reference in New Issue
Block a user