- 添加 SocketIOClient.gd 实现 Socket.IO 协议封装 - 添加 WebSocketManager.gd 管理连接生命周期和自动重连 - 添加 ChatManager.gd 实现聊天业务逻辑与会话管理 - 支持当前会话缓存(最多 100 条消息) - 支持历史消息按需加载(每次 100 条) - 每次登录/重连自动重置会话缓存 - 客户端频率限制(10 条/分钟) - Token 管理与认证 - 添加 ChatMessage.gd/tscn 消息气泡 UI 组件 - 添加 ChatUI.gd/tscn 聊天界面 - 在 EventNames.gd 添加 7 个聊天事件常量 - 在 AuthManager.gd 添加 game_token 管理方法 - 添加完整的单元测试(128 个测试用例) - test_socketio_client.gd (42 个测试) - test_websocket_manager.gd (38 个测试) - test_chat_manager.gd (48 个测试) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
78 lines
2.1 KiB
Plaintext
78 lines
2.1 KiB
Plaintext
[gd_scene load_steps=2 format=3 uid="uid://bv7k2m9n4xj8q"]
|
|
|
|
[ext_resource type="Script" path="res://scenes/ui/ChatUI.gd" id="1"]
|
|
|
|
[node name="ChatUI" type="Control"]
|
|
layout_mode = 3
|
|
anchors_preset = 15
|
|
anchor_right = 1.0
|
|
anchor_bottom = 1.0
|
|
grow_horizontal = 2
|
|
grow_vertical = 2
|
|
mouse_filter = 2
|
|
script = ExtResource("1")
|
|
|
|
[node name="ChatPanel" type="Panel" parent="."]
|
|
unique_name_in_owner = true
|
|
layout_mode = 1
|
|
anchors_preset = 3
|
|
anchor_left = 1.0
|
|
anchor_top = 1.0
|
|
anchor_right = 1.0
|
|
anchor_bottom = 1.0
|
|
offset_left = -450.0
|
|
offset_top = -400.0
|
|
grow_horizontal = 0
|
|
grow_vertical = 0
|
|
|
|
[node name="VBoxContainer" type="VBoxContainer" parent="ChatPanel"]
|
|
layout_mode = 1
|
|
anchors_preset = 15
|
|
anchor_right = 1.0
|
|
anchor_bottom = 1.0
|
|
grow_horizontal = 2
|
|
grow_vertical = 2
|
|
theme_override_constants/separation = 8
|
|
offset_left = 10.0
|
|
offset_top = 10.0
|
|
offset_right = -10.0
|
|
offset_bottom = -10.0
|
|
|
|
[node name="HeaderContainer" type="HBoxContainer" parent="ChatPanel/VBoxContainer"]
|
|
layout_mode = 2
|
|
|
|
[node name="StatusLabel" type="Label" parent="ChatPanel/VBoxContainer/HeaderContainer"]
|
|
unique_name_in_owner = true
|
|
layout_mode = 2
|
|
size_flags_horizontal = 3
|
|
theme_override_colors/font_color = Color(0.5, 0.5, 0.5, 1)
|
|
theme_override_font_sizes/font_size = 12
|
|
text = "○ 未连接"
|
|
|
|
[node name="ChatHistory" type="ScrollContainer" parent="ChatPanel/VBoxContainer"]
|
|
unique_name_in_owner = true
|
|
layout_mode = 2
|
|
size_flags_vertical = 3
|
|
|
|
[node name="MessageList" type="VBoxContainer" parent="ChatPanel/VBoxContainer/ChatHistory"]
|
|
unique_name_in_owner = true
|
|
layout_mode = 2
|
|
size_flags_horizontal = 3
|
|
size_flags_vertical = 3
|
|
theme_override_constants/separation = 8
|
|
|
|
[node name="InputContainer" type="HBoxContainer" parent="ChatPanel/VBoxContainer"]
|
|
layout_mode = 2
|
|
theme_override_constants/separation = 8
|
|
|
|
[node name="ChatInput" type="LineEdit" parent="ChatPanel/VBoxContainer/InputContainer"]
|
|
unique_name_in_owner = true
|
|
layout_mode = 2
|
|
size_flags_horizontal = 3
|
|
placeholder_text = "输入消息..."
|
|
|
|
[node name="SendButton" type="Button" parent="ChatPanel/VBoxContainer/InputContainer"]
|
|
unique_name_in_owner = true
|
|
layout_mode = 2
|
|
text = "发送"
|