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 send_chat_message_button: Button
|
||||
|
||||
@export var connected_players_label: Label
|
||||
|
||||
@export var name_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:
|
||||
_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({
|
||||
"client_name": client_name,
|
||||
"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:
|
||||
_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,
|
||||
}))
|
||||
|
||||
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}))
|
||||
_update_connected_players(connected_client_names)
|
||||
|
||||
func _on_web_client_tcp_connection_status_changed(new_status: WebClientTCP.ConnectionStatus) -> void:
|
||||
match new_status:
|
||||
@@ -124,6 +128,8 @@ func _on_web_client_tcp_connection_status_changed(new_status: WebClientTCP.Conne
|
||||
chat_message_input.editable = true
|
||||
send_chat_message_button.disabled = false
|
||||
|
||||
|
||||
func _on_web_client_tcp_received_connection_message(message: String) -> void:
|
||||
_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)
|
||||
|
||||
Reference in New Issue
Block a user