client now displays currently connected players by name
This commit is contained in:
@@ -11,6 +11,8 @@ extends Control
|
|||||||
@export var chat_message_input: LineEdit
|
@export var chat_message_input: LineEdit
|
||||||
@export var send_chat_message_button: Button
|
@export var send_chat_message_button: Button
|
||||||
|
|
||||||
|
@export var connected_players_label: Label
|
||||||
|
|
||||||
@export var name_input: LineEdit
|
@export var name_input: LineEdit
|
||||||
@export var lobby_code_input: LineEdit
|
@export var lobby_code_input: LineEdit
|
||||||
|
|
||||||
@@ -54,11 +56,12 @@ func _on_web_client_tcp_connected_to_lobby(lobby_id: String) -> void:
|
|||||||
func _on_web_client_tcp_disconnected_from_lobby() -> void:
|
func _on_web_client_tcp_disconnected_from_lobby() -> void:
|
||||||
_write_line("You disconnected from the lobby")
|
_write_line("You disconnected from the lobby")
|
||||||
|
|
||||||
func _on_web_client_tcp_client_joined_lobby(client_name: String, currently_connected_client_names: Array) -> void:
|
func _on_web_client_tcp_client_joined_lobby(client_name: String, connected_client_names: Array) -> void:
|
||||||
_write_line("{client_name} joined the lobby{you}".format({
|
_write_line("{client_name} joined the lobby{you}".format({
|
||||||
"client_name": client_name,
|
"client_name": client_name,
|
||||||
"you": " (that's you!)" if client_name == name_input.text.strip_edges() else ""
|
"you": " (that's you!)" if client_name == name_input.text.strip_edges() else ""
|
||||||
}))
|
}))
|
||||||
|
_update_connected_players(connected_client_names)
|
||||||
|
|
||||||
func _on_web_client_tcp_received_chat_message(client_name: String, message: String) -> void:
|
func _on_web_client_tcp_received_chat_message(client_name: String, message: String) -> void:
|
||||||
_write_line("<{client_name}> {message}".format({
|
_write_line("<{client_name}> {message}".format({
|
||||||
@@ -66,8 +69,9 @@ func _on_web_client_tcp_received_chat_message(client_name: String, message: Stri
|
|||||||
"message": message,
|
"message": message,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
func _on_web_client_tcp_client_left_lobby(client_name: String, currently_connected_client_names: Array) -> void:
|
func _on_web_client_tcp_client_left_lobby(client_name: String, connected_client_names: Array) -> void:
|
||||||
_write_line("{client_name} left the lobby".format({"client_name": client_name}))
|
_write_line("{client_name} left the lobby".format({"client_name": client_name}))
|
||||||
|
_update_connected_players(connected_client_names)
|
||||||
|
|
||||||
func _on_web_client_tcp_connection_status_changed(new_status: WebClientTCP.ConnectionStatus) -> void:
|
func _on_web_client_tcp_connection_status_changed(new_status: WebClientTCP.ConnectionStatus) -> void:
|
||||||
match new_status:
|
match new_status:
|
||||||
@@ -124,6 +128,8 @@ func _on_web_client_tcp_connection_status_changed(new_status: WebClientTCP.Conne
|
|||||||
chat_message_input.editable = true
|
chat_message_input.editable = true
|
||||||
send_chat_message_button.disabled = false
|
send_chat_message_button.disabled = false
|
||||||
|
|
||||||
|
|
||||||
func _on_web_client_tcp_received_connection_message(message: String) -> void:
|
func _on_web_client_tcp_received_connection_message(message: String) -> void:
|
||||||
_write_line(message)
|
_write_line(message)
|
||||||
|
|
||||||
|
func _update_connected_players(new_client_names: Array[String]) -> void:
|
||||||
|
connected_players_label.text = "Connected Players:\n" + "\n".join(new_client_names)
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ signal disconnected_from_server()
|
|||||||
signal connected_to_lobby(lobby_id: String)
|
signal connected_to_lobby(lobby_id: String)
|
||||||
signal disconnected_from_lobby()
|
signal disconnected_from_lobby()
|
||||||
|
|
||||||
signal client_joined_lobby(client_name: String, currently_connected_client_names: Array[String])
|
signal client_joined_lobby(client_name: String, connected_client_names: Array[String])
|
||||||
signal client_left_lobby(client_name: String, currently_connected_client_names: Array[String])
|
signal client_left_lobby(client_name: String, connected_client_names: Array[String])
|
||||||
|
|
||||||
signal received_connection_message(message: String)
|
signal received_connection_message(message: String)
|
||||||
signal received_chat_message(client_name: String, message: String)
|
signal received_chat_message(client_name: String, message: String)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ anchor_bottom = 1.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="ClientInterface" type="ColorRect" parent="HBoxContainer" node_paths=PackedStringArray("client", "connect_button", "create_lobby_button", "join_lobby_button", "leave_lobby_button", "chat_message_input", "send_chat_message_button", "name_input", "lobby_code_input", "output")]
|
[node name="ClientInterface" type="ColorRect" parent="HBoxContainer" node_paths=PackedStringArray("client", "connect_button", "create_lobby_button", "join_lobby_button", "leave_lobby_button", "chat_message_input", "send_chat_message_button", "connected_players_label", "name_input", "lobby_code_input", "output")]
|
||||||
custom_minimum_size = Vector2(316, 0)
|
custom_minimum_size = Vector2(316, 0)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
color = Color(0.26, 0.2236, 0.230273, 1)
|
color = Color(0.26, 0.2236, 0.230273, 1)
|
||||||
@@ -32,6 +32,7 @@ join_lobby_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/JoinLob
|
|||||||
leave_lobby_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/LeaveLobbyButton")
|
leave_lobby_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/LeaveLobbyButton")
|
||||||
chat_message_input = NodePath("MarginContainer/VBoxContainer/ChatContainer/MessageInput")
|
chat_message_input = NodePath("MarginContainer/VBoxContainer/ChatContainer/MessageInput")
|
||||||
send_chat_message_button = NodePath("MarginContainer/VBoxContainer/ChatContainer/SendMessageButton")
|
send_chat_message_button = NodePath("MarginContainer/VBoxContainer/ChatContainer/SendMessageButton")
|
||||||
|
connected_players_label = NodePath("MarginContainer/VBoxContainer/ConnectedPlayersLabel")
|
||||||
name_input = NodePath("MarginContainer/VBoxContainer/ServerInputs/NameInput")
|
name_input = NodePath("MarginContainer/VBoxContainer/ServerInputs/NameInput")
|
||||||
lobby_code_input = NodePath("MarginContainer/VBoxContainer/ServerInputs/LobbyCodeInput")
|
lobby_code_input = NodePath("MarginContainer/VBoxContainer/ServerInputs/LobbyCodeInput")
|
||||||
output = NodePath("MarginContainer/VBoxContainer/ScrollContainer/Output")
|
output = NodePath("MarginContainer/VBoxContainer/ScrollContainer/Output")
|
||||||
@@ -97,6 +98,14 @@ layout_mode = 2
|
|||||||
disabled = true
|
disabled = true
|
||||||
text = "Disconnect"
|
text = "Disconnect"
|
||||||
|
|
||||||
|
[node name="ConnectedPlayersLabel" type="Label" parent="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Divider" type="ColorRect" parent="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(0, 2)
|
||||||
|
layout_mode = 2
|
||||||
|
color = Color(0.55, 0.3905, 0.3905, 1)
|
||||||
|
|
||||||
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer"]
|
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|||||||
Reference in New Issue
Block a user