moved chat to new ChatPanel and added smooth bottom scrolling when new message is received

This commit is contained in:
2025-07-20 13:36:30 +02:00
parent 4fe629d012
commit 3cf036db42
8 changed files with 274 additions and 79 deletions
+26
View File
@@ -0,0 +1,26 @@
class_name ChatPanel
extends VBoxContainer
@onready var _chat_message_scene: PackedScene = preload("uid://docnx7algl78k")
@export_range(0.1, 1.0, 0.05) var auto_scroll_duration: float = 0.2
@export var message_container: VBoxContainer
@export var scroll_container: ScrollContainer
func put_chat_message(sender: String, message: String) -> void:
var scene: ChatMessage = _chat_message_scene.instantiate()
scene.set_message("<{sender}> {message}".format({
"sender": sender,
"message": message,
}))
message_container.add_child(scene)
# Wait a short time so that ScrollLayout receives new height because of newly added child
await get_tree().create_timer(0.05).timeout
_scroll_to_bottom()
func _scroll_to_bottom() -> void:
create_tween().set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT).tween_property(scroll_container, "scroll_vertical", scroll_container.get_v_scroll_bar().max_value - scroll_container.get_v_scroll_bar().size.y, auto_scroll_duration)
func _on_web_client_user_message_received(sender: String, message: String) -> void:
put_chat_message(sender, message)
+1
View File
@@ -0,0 +1 @@
uid://bfhknl0awlj22
+2 -7
View File
@@ -19,7 +19,8 @@ extends Control
@export var output: Label @export var output: Label
func _write_line(text: String) -> void: func _write_line(text: String) -> void:
output.text += text + "\n" #output.text += text + "\n"
pass
func _on_create_lobby_button_pressed() -> void: func _on_create_lobby_button_pressed() -> void:
client.create_lobby(name_input.text.strip_edges()) client.create_lobby(name_input.text.strip_edges())
@@ -63,12 +64,6 @@ func _on_web_client_tcp_client_joined_lobby(client_name: String, connected_clien
})) }))
_update_connected_players(connected_client_names) _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({
"client_name": client_name,
"message": message,
}))
func _on_web_client_tcp_client_left_lobby(client_name: String, 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) _update_connected_players(connected_client_names)
+11 -1
View File
@@ -1,6 +1,9 @@
class_name WebClientTCP class_name WebClientTCP
extends Node extends Node
## Sender tag for system messages displayed in the chat
const SENDER_SYSTEM: String = "SYSTEM"
#var _tcp := StreamPeerTCP.new() #var _tcp := StreamPeerTCP.new()
var _socket := WebSocketPeer.new() var _socket := WebSocketPeer.new()
@@ -58,6 +61,10 @@ signal received_end_game_request()
signal request_next_play() signal request_next_play()
signal request_next_round() signal request_next_round()
# new signals
## Emitted when a message that needs to be displayed to the player has been received.
signal user_message_received(sender: String, message: String)
enum ConnectionStatus { enum ConnectionStatus {
DISCONNECTED, DISCONNECTED,
ATTEMPTING_CONNECTION, ATTEMPTING_CONNECTION,
@@ -136,8 +143,11 @@ func _handle_response(response: String) -> void:
_connected_client_ids.assign(data["connected_client_ids"]) _connected_client_ids.assign(data["connected_client_ids"])
_connected_client_names.assign(data["connected_client_names"]) _connected_client_names.assign(data["connected_client_names"])
client_left_lobby.emit.call_deferred(data["client_name"], _connected_client_names) client_left_lobby.emit.call_deferred(data["client_name"], _connected_client_names)
## A chat message has been received
"receive_chat_message": "receive_chat_message":
received_chat_message.emit.call_deferred(data["client_name"], data["message"]) # Relay message to be displayed in the chat panel
user_message_received.emit.call_deferred(data["client_name"], data["message"])
"new_round_started": "new_round_started":
if data["current_round"] == 1: if data["current_round"] == 1:
+191 -71
View File
@@ -6,15 +6,12 @@
[ext_resource type="Script" uid="uid://utt8atbh7b2a" path="res://game_client.gd" id="3_feb5d"] [ext_resource type="Script" uid="uid://utt8atbh7b2a" path="res://game_client.gd" id="3_feb5d"]
[ext_resource type="Script" uid="uid://bipfa366flrfa" path="res://environment_manager.gd" id="4_7jktm"] [ext_resource type="Script" uid="uid://bipfa366flrfa" path="res://environment_manager.gd" id="4_7jktm"]
[ext_resource type="PackedScene" uid="uid://jlovgr2iojrg" path="res://elements/player_hand.tscn" id="4_fc0e3"] [ext_resource type="PackedScene" uid="uid://jlovgr2iojrg" path="res://elements/player_hand.tscn" id="4_fc0e3"]
[ext_resource type="Script" uid="uid://bfhknl0awlj22" path="res://chat_panel.gd" id="4_iotsf"]
[ext_resource type="Script" uid="uid://bokp83oigikj2" path="res://number_input.gd" id="4_vef74"] [ext_resource type="Script" uid="uid://bokp83oigikj2" path="res://number_input.gd" id="4_vef74"]
[ext_resource type="PackedScene" uid="uid://b55xpcxk7g5ph" path="res://cards/playing_card.tscn" id="6_eow3j"] [ext_resource type="PackedScene" uid="uid://b55xpcxk7g5ph" path="res://cards/playing_card.tscn" id="6_eow3j"]
[ext_resource type="PackedScene" uid="uid://dj1wye7o27vil" path="res://assets/table.glb" id="7_eow3j"] [ext_resource type="PackedScene" uid="uid://dj1wye7o27vil" path="res://assets/table.glb" id="7_eow3j"]
[ext_resource type="Script" uid="uid://c5bk4gjeyh7vy" path="res://card_stack.gd" id="8_j5wjh"] [ext_resource type="Script" uid="uid://c5bk4gjeyh7vy" path="res://card_stack.gd" id="8_j5wjh"]
[sub_resource type="SystemFont" id="SystemFont_80nbo"]
font_names = PackedStringArray("IBM Plex Mono")
font_weight = 500
[sub_resource type="Environment" id="Environment_fc0e3"] [sub_resource type="Environment" id="Environment_fc0e3"]
ambient_light_source = 2 ambient_light_source = 2
ambient_light_color = Color(1, 1, 1, 1) ambient_light_color = Color(1, 1, 1, 1)
@@ -22,7 +19,7 @@ ambient_light_energy = 0.15
[node name="Game" type="Node"] [node name="Game" type="Node"]
[node name="WebClientTCP" type="Node" parent="."] [node name="WebClient" type="Node" parent="."]
script = ExtResource("1_feb5d") script = ExtResource("1_feb5d")
[node name="Interface" type="Control" parent="."] [node name="Interface" type="Control" parent="."]
@@ -35,24 +32,23 @@ grow_vertical = 2
theme = ExtResource("2_hve3p") theme = ExtResource("2_hve3p")
metadata/_edit_use_anchors_ = true metadata/_edit_use_anchors_ = true
[node name="ClientInterface" type="ColorRect" parent="Interface" 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")] [node name="ClientInterface" type="ColorRect" parent="Interface" 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")]
custom_minimum_size = Vector2(316, 0) custom_minimum_size = Vector2(316, 0)
layout_mode = 2 layout_mode = 2
offset_right = 316.0 offset_right = 316.0
offset_bottom = 1080.0 offset_bottom = 429.0
color = Color(0.26, 0.2236, 0.230273, 1) color = Color(0.26, 0.2236, 0.230273, 1)
script = ExtResource("2_e2o6t") script = ExtResource("2_e2o6t")
client = NodePath("../../WebClientTCP") client = NodePath("../../WebClient")
connect_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/ConnectButton") connect_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/ConnectButton")
create_lobby_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton") create_lobby_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton")
join_lobby_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/JoinLobbyButton") join_lobby_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/JoinLobbyButton")
leave_lobby_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/LeaveLobbyButton") leave_lobby_button = NodePath("MarginContainer/VBoxContainer/ServerInputs/LeaveLobbyButton")
chat_message_input = NodePath("../ChatPanel/ChatContainer/MessageInput") chat_message_input = NodePath("../ChatPanel/InputContainer/MessageInput")
send_chat_message_button = NodePath("../ChatPanel/ChatContainer/SendMessageButton") send_chat_message_button = NodePath("../ChatPanel/InputContainer/SendMessageButton")
connected_players_label = NodePath("MarginContainer/VBoxContainer/ConnectedPlayersLabel") 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")
[node name="MarginContainer" type="MarginContainer" parent="Interface/ClientInterface"] [node name="MarginContainer" type="MarginContainer" parent="Interface/ClientInterface"]
layout_mode = 1 layout_mode = 1
@@ -75,7 +71,7 @@ layout_mode = 2
[node name="URLInput" type="LineEdit" parent="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs"] [node name="URLInput" type="LineEdit" parent="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs"]
layout_mode = 2 layout_mode = 2
text = "wss://denizk0461.dev/magsrv/" text = "127.0.0.1:9974"
placeholder_text = "URL" placeholder_text = "URL"
[node name="ConnectButton" type="Button" parent="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs"] [node name="ConnectButton" type="Button" parent="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs"]
@@ -110,45 +106,167 @@ text = "Disconnect"
[node name="ConnectedPlayersLabel" type="Label" parent="Interface/ClientInterface/MarginContainer/VBoxContainer"] [node name="ConnectedPlayersLabel" type="Label" parent="Interface/ClientInterface/MarginContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
[node name="ScrollContainer" type="ScrollContainer" parent="Interface/ClientInterface/MarginContainer/VBoxContainer"] [node name="ChatPanel" type="VBoxContainer" parent="Interface" node_paths=PackedStringArray("message_container", "scroll_container")]
layout_mode = 1
anchors_preset = -1
anchor_top = 0.478704
anchor_right = 0.234375
anchor_bottom = 1.0
grow_vertical = 0
script = ExtResource("4_iotsf")
auto_scroll_duration = 0.4
message_container = NodePath("ScrollContainer/MessageContainer")
scroll_container = NodePath("ScrollContainer")
metadata/_edit_use_anchors_ = true
[node name="ScrollContainer" type="ScrollContainer" parent="Interface/ChatPanel"]
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
horizontal_scroll_mode = 0 horizontal_scroll_mode = 0
vertical_scroll_mode = 4 vertical_scroll_mode = 4
[node name="Output" type="Label" parent="Interface/ClientInterface/MarginContainer/VBoxContainer/ScrollContainer"] [node name="MessageContainer" type="VBoxContainer" parent="Interface/ChatPanel/ScrollContainer"]
custom_minimum_size = Vector2(64, 1)
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 1 alignment = 2
theme_override_fonts/font = SubResource("SystemFont_80nbo")
autowrap_mode = 2
metadata/_edit_lock_ = true
[node name="ChatPanel" type="Control" parent="Interface"] [node name="Label" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 1 layout_mode = 2
anchor_top = 0.478704 text = "asdf"
anchor_right = 0.234375
anchor_bottom = 1.0
grow_vertical = 0
metadata/_edit_use_anchors_ = true
[node name="ChatContainer" type="HBoxContainer" parent="Interface/ChatPanel"] [node name="Label2" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 1 layout_mode = 2
anchors_preset = 12 text = "asdf"
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -31.0
grow_horizontal = 2
grow_vertical = 0
[node name="MessageInput" type="LineEdit" parent="Interface/ChatPanel/ChatContainer"] [node name="Label3" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label4" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label5" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label6" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label7" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label8" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label9" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label10" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label11" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label12" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label13" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label14" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label15" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label16" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label17" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label18" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label19" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label20" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label21" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label22" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label23" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label24" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label25" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label26" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label27" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label28" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label29" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label30" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label31" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="Label32" type="Label" parent="Interface/ChatPanel/ScrollContainer/MessageContainer"]
layout_mode = 2
text = "asdf"
[node name="InputContainer" type="HBoxContainer" parent="Interface/ChatPanel"]
layout_mode = 2
[node name="MessageInput" type="LineEdit" parent="Interface/ChatPanel/InputContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
placeholder_text = "Type chat message here" placeholder_text = "Type chat message here"
[node name="SendMessageButton" type="Button" parent="Interface/ChatPanel/ChatContainer"] [node name="SendMessageButton" type="Button" parent="Interface/ChatPanel/InputContainer"]
layout_mode = 2 layout_mode = 2
text = "Send" text = "Send"
@@ -156,6 +274,7 @@ text = "Send"
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = 485.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource("2_hve3p") theme = ExtResource("2_hve3p")
@@ -165,7 +284,7 @@ layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
mouse_filter = 2 mouse_filter = 2
script = ExtResource("3_feb5d") script = ExtResource("3_feb5d")
web_client = NodePath("../../WebClientTCP") web_client = NodePath("../../WebClient")
start_game_button = NodePath("StartGameButton") start_game_button = NodePath("StartGameButton")
play_card_button = NodePath("PlayCardButton") play_card_button = NodePath("PlayCardButton")
bet_container = NodePath("BetContainer") bet_container = NodePath("BetContainer")
@@ -297,7 +416,7 @@ text = "NOT ALLOWED!"
[node name="EnvironmentManager" type="Node3D" parent="." node_paths=PackedStringArray("web_client", "card_stack", "own_player_hand", "hand_markers_3", "hand_markers_4", "hand_markers_5", "hand_markers_6")] [node name="EnvironmentManager" type="Node3D" parent="." node_paths=PackedStringArray("web_client", "card_stack", "own_player_hand", "hand_markers_3", "hand_markers_4", "hand_markers_5", "hand_markers_6")]
script = ExtResource("4_7jktm") script = ExtResource("4_7jktm")
web_client = NodePath("../WebClientTCP") web_client = NodePath("../WebClient")
card_stack = NodePath("CardStack") card_stack = NodePath("CardStack")
own_player_hand = NodePath("PlayerHand0") own_player_hand = NodePath("PlayerHand0")
hand_markers_3 = [NodePath("HandMarker1"), NodePath("HandMarker2")] hand_markers_3 = [NodePath("HandMarker1"), NodePath("HandMarker2")]
@@ -345,44 +464,45 @@ transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -0.999999, -4.37114e-08,
script = ExtResource("8_j5wjh") script = ExtResource("8_j5wjh")
playing_card_scene = ExtResource("6_eow3j") playing_card_scene = ExtResource("6_eow3j")
[connection signal="cards_received" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_cards_received"] [connection signal="cards_received" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_cards_received"]
[connection signal="client_joined_lobby" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_client_joined_lobby"] [connection signal="client_joined_lobby" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_client_joined_lobby"]
[connection signal="client_joined_lobby" from="WebClientTCP" to="HBoxContainer/GameUI" method="_on_web_client_tcp_client_joined_lobby"] [connection signal="client_joined_lobby" from="WebClient" to="HBoxContainer/GameUI" method="_on_web_client_tcp_client_joined_lobby"]
[connection signal="client_left_lobby" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_client_left_lobby"] [connection signal="client_left_lobby" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_client_left_lobby"]
[connection signal="client_left_lobby" from="WebClientTCP" to="HBoxContainer/GameUI" method="_on_web_client_tcp_client_left_lobby"] [connection signal="client_left_lobby" from="WebClient" to="HBoxContainer/GameUI" method="_on_web_client_tcp_client_left_lobby"]
[connection signal="client_order_received" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_client_order_received"] [connection signal="client_order_received" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_client_order_received"]
[connection signal="connected_to_lobby" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_connected_to_lobby"] [connection signal="connected_to_lobby" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_connected_to_lobby"]
[connection signal="connected_to_server" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_connected_to_server"] [connection signal="connected_to_server" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_connected_to_server"]
[connection signal="connection_error_occurred" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_connection_error_occurred"] [connection signal="connection_error_occurred" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_connection_error_occurred"]
[connection signal="connection_status_changed" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_connection_status_changed"] [connection signal="connection_status_changed" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_connection_status_changed"]
[connection signal="disconnected_from_lobby" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_disconnected_from_lobby"] [connection signal="disconnected_from_lobby" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_disconnected_from_lobby"]
[connection signal="disconnected_from_server" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_disconnected_from_server"] [connection signal="disconnected_from_server" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_disconnected_from_server"]
[connection signal="new_round_started" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_new_round_started"] [connection signal="new_round_started" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_new_round_started"]
[connection signal="notify_play_card_request" from="WebClientTCP" to="HBoxContainer/GameUI" method="_on_web_client_tcp_notify_play_card_request"] [connection signal="notify_play_card_request" from="WebClient" to="HBoxContainer/GameUI" method="_on_web_client_tcp_notify_play_card_request"]
[connection signal="received_bet_request" from="WebClientTCP" to="HBoxContainer/GameUI" method="_on_web_client_tcp_received_bet_request"] [connection signal="received_bet_request" from="WebClient" to="HBoxContainer/GameUI" method="_on_web_client_tcp_received_bet_request"]
[connection signal="received_bet_request" from="WebClientTCP" to="HBoxContainer/GameUI/BetContainer/BetInput" method="_on_web_client_tcp_received_bet_request"] [connection signal="received_bet_request" from="WebClient" to="HBoxContainer/GameUI/BetContainer/BetInput" method="_on_web_client_tcp_received_bet_request"]
[connection signal="received_chat_message" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_received_chat_message"] [connection signal="received_chat_message" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_received_chat_message"]
[connection signal="received_client_id" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_received_client_id"] [connection signal="received_client_id" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_received_client_id"]
[connection signal="received_connection_message" from="WebClientTCP" to="Interface/ClientInterface" method="_on_web_client_tcp_received_connection_message"] [connection signal="received_connection_message" from="WebClient" to="Interface/ClientInterface" method="_on_web_client_tcp_received_connection_message"]
[connection signal="received_end_game_request" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_received_end_game_request"] [connection signal="received_end_game_request" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_received_end_game_request"]
[connection signal="received_expected_bet" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_received_expected_bet"] [connection signal="received_expected_bet" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_received_expected_bet"]
[connection signal="received_first_card" from="WebClientTCP" to="EnvironmentManager/PlayerHand0" method="_on_web_client_tcp_received_first_card"] [connection signal="received_first_card" from="WebClient" to="EnvironmentManager/PlayerHand0" method="_on_web_client_tcp_received_first_card"]
[connection signal="received_play_winner_request" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_received_play_winner_request"] [connection signal="received_play_winner_request" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_received_play_winner_request"]
[connection signal="received_played_card" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_received_played_card"] [connection signal="received_played_card" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_received_played_card"]
[connection signal="received_win" from="WebClientTCP" to="HBoxContainer/GameUI" method="_on_web_client_tcp_received_win"] [connection signal="received_win" from="WebClient" to="HBoxContainer/GameUI" method="_on_web_client_tcp_received_win"]
[connection signal="received_winning_client" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_received_winning_client"] [connection signal="received_winning_client" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_received_winning_client"]
[connection signal="request_next_play" from="WebClientTCP" to="HBoxContainer/GameUI" method="_on_web_client_tcp_request_next_play"] [connection signal="request_next_play" from="WebClient" to="HBoxContainer/GameUI" method="_on_web_client_tcp_request_next_play"]
[connection signal="request_next_round" from="WebClientTCP" to="HBoxContainer/GameUI" method="_on_web_client_tcp_request_next_round"] [connection signal="request_next_round" from="WebClient" to="HBoxContainer/GameUI" method="_on_web_client_tcp_request_next_round"]
[connection signal="reset_first_card" from="WebClientTCP" to="EnvironmentManager/PlayerHand0" method="_on_web_client_tcp_reset_first_card"] [connection signal="reset_first_card" from="WebClient" to="EnvironmentManager/PlayerHand0" method="_on_web_client_tcp_reset_first_card"]
[connection signal="trump_received" from="WebClientTCP" to="EnvironmentManager" method="_on_web_client_tcp_trump_received"] [connection signal="trump_received" from="WebClient" to="EnvironmentManager" method="_on_web_client_tcp_trump_received"]
[connection signal="trump_received" from="WebClientTCP" to="EnvironmentManager/PlayerHand0" method="_on_web_client_tcp_trump_received"] [connection signal="trump_received" from="WebClient" to="EnvironmentManager/PlayerHand0" method="_on_web_client_tcp_trump_received"]
[connection signal="user_message_received" from="WebClient" to="Interface/ChatPanel" method="_on_web_client_user_message_received"]
[connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/ConnectButton" to="Interface/ClientInterface" method="_on_connect_button_pressed"] [connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/ConnectButton" to="Interface/ClientInterface" method="_on_connect_button_pressed"]
[connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton" to="Interface/ClientInterface" method="_on_create_lobby_button_pressed"] [connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton" to="Interface/ClientInterface" method="_on_create_lobby_button_pressed"]
[connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton" to="HBoxContainer/GameUI" method="_on_create_lobby_button_pressed"] [connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/CreateLobbyButton" to="HBoxContainer/GameUI" method="_on_create_lobby_button_pressed"]
[connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/JoinLobbyButton" to="Interface/ClientInterface" method="_on_join_lobby_button_pressed"] [connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/JoinLobbyButton" to="Interface/ClientInterface" method="_on_join_lobby_button_pressed"]
[connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/JoinLobbyButton" to="HBoxContainer/GameUI" method="_on_join_lobby_button_pressed"] [connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/JoinLobbyButton" to="HBoxContainer/GameUI" method="_on_join_lobby_button_pressed"]
[connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/LeaveLobbyButton" to="Interface/ClientInterface" method="_on_disconnect_lobby_button_pressed"] [connection signal="pressed" from="Interface/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/LeaveLobbyButton" to="Interface/ClientInterface" method="_on_disconnect_lobby_button_pressed"]
[connection signal="pressed" from="Interface/ChatPanel/ChatContainer/SendMessageButton" to="Interface/ClientInterface" method="_on_send_message_button_pressed"] [connection signal="pressed" from="Interface/ChatPanel/InputContainer/SendMessageButton" to="Interface/ClientInterface" method="_on_send_message_button_pressed"]
[connection signal="pressed" from="HBoxContainer/GameUI/StartGameButton" to="HBoxContainer/GameUI" method="_on_start_game_button_pressed"] [connection signal="pressed" from="HBoxContainer/GameUI/StartGameButton" to="HBoxContainer/GameUI" method="_on_start_game_button_pressed"]
[connection signal="pressed" from="HBoxContainer/GameUI/PlayCardButton" to="EnvironmentManager/PlayerHand0" method="_on_play_card_button_pressed"] [connection signal="pressed" from="HBoxContainer/GameUI/PlayCardButton" to="EnvironmentManager/PlayerHand0" method="_on_play_card_button_pressed"]
[connection signal="text_changed" from="HBoxContainer/GameUI/BetContainer/BetInput" to="HBoxContainer/GameUI/BetContainer/BetInput" method="_on_text_changed"] [connection signal="text_changed" from="HBoxContainer/GameUI/BetContainer/BetInput" to="HBoxContainer/GameUI/BetContainer/BetInput" method="_on_text_changed"]
+7
View File
@@ -0,0 +1,7 @@
class_name ChatMessage
extends Control
@export var text_label: Label
func set_message(message: String) -> void:
text_label.text = message
+1
View File
@@ -0,0 +1 @@
uid://bacaxh2y0sjss
+35
View File
@@ -0,0 +1,35 @@
[gd_scene load_steps=2 format=3 uid="uid://docnx7algl78k"]
[ext_resource type="Script" uid="uid://bacaxh2y0sjss" path="res://ui/chat_message.gd" id="1_vmwh1"]
[node name="ChatMessage" type="MarginContainer" node_paths=PackedStringArray("text_label")]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 2
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 2
script = ExtResource("1_vmwh1")
text_label = NodePath("MarginContainer/Label")
[node name="ColorRect" type="ColorRect" parent="."]
show_behind_parent = true
layout_mode = 2
color = Color(1, 0.33, 0.33, 1)
metadata/_edit_use_anchors_ = true
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
theme_override_constants/margin_left = 2
theme_override_constants/margin_top = 2
theme_override_constants/margin_right = 2
theme_override_constants/margin_bottom = 2
[node name="Label" type="Label" parent="MarginContainer"]
custom_minimum_size = Vector2(20, 10)
layout_mode = 2
text = "asdf asdufasdoiufoias doifaosid ofiuasoi djhfas df as f"
autowrap_mode = 3