继续更新UI

This commit is contained in:
2025-09-24 15:06:30 +08:00
parent 26b856d74e
commit df57f3c5ec
59 changed files with 1415 additions and 2898 deletions

View File

@@ -17,6 +17,8 @@ extends Panel
@onready var accept_dialog: AcceptDialog = $'../../DiaLog/AcceptDialog'
@onready var tcp_network_manager_panel: Panel = $'../../BigPanel/TCPNetworkManagerPanel'
@onready var http_texture_rect: HTTPTextureRect = $VBox1/HBox1/HTTPTextureRect
# 存储待执行的操作类型
var pending_action = ""
@@ -188,11 +190,14 @@ func _refresh_player_info():
user_password_input.text = main_game.user_password if main_game.user_password != "" else ""
# 优先从 login_data 获取数据,如果没有则从 data 获取
var player_data = main_game.login_data #if main_game.login_data.size() > 0 else main_game.data
var player_data = main_game.login_data
player_name_input.text = player_data.get("玩家昵称", "")
farm_name_input.text = player_data.get("农场名称", "")
personal_profile_input.text = player_data.get("个人简介", "")
# 尝试加载玩家头像(使用用户名/QQ号加载头像而不是显示名
if user_name_input.text.is_valid_int():
http_texture_rect.load_from_url("http://q1.qlogo.cn/g?b=qq&nk=" + user_name_input.text + "&s=100")
#显示消息提示

View File

@@ -81,9 +81,6 @@ func send_broadcast_message():
if success:
# 清空输入框
input_message.text = ""
Toast.show("消息发送成功", Color.GREEN, 2.0, 1.0)
else:
Toast.show("消息发送失败", Color.RED, 2.0, 1.0)
# 统一的消息处理函数
func _add_message_to_history(data: Dictionary):
@@ -241,9 +238,6 @@ func receive_history_messages(data: Dictionary):
# 保存到本地
save_chat_history()
Toast.show("历史消息加载完成,共%d条消息" % messages.size(), Color.GREEN, 2.0, 1.0)
else:
Toast.show("没有找到历史消息", Color.YELLOW, 2.0, 1.0)
# 保存聊天历史记录
func save_chat_history():
@@ -278,7 +272,7 @@ func clear_message_history():
# 获取最新消息用于主界面显示
func get_latest_message() -> String:
print("get_latest_message 被调用,消息历史大小: ", message_history.size())
#print("get_latest_message 被调用,消息历史大小: ", message_history.size())
if message_history.size() > 0:
# 确保消息按时间排序
message_history.sort_custom(func(a, b): return a.get("timestamp", 0) < b.get("timestamp", 0))
@@ -286,5 +280,5 @@ func get_latest_message() -> String:
var result = latest.get("display_name", "匿名") + ": " + latest.get("content", "")
print("返回最新消息: ", result)
return result
print("没有消息历史,返回'暂无消息'")
#print("没有消息历史,返回'暂无消息'")
return "暂无消息"

View File

@@ -88,10 +88,10 @@ func _get_pet_texture(pet_name: String) -> Texture2D:
if pet_config.has(pet_name):
var pet_info = pet_config[pet_name]
var scene_path = pet_info.get("pet_image", "") # 使用服务器数据的pet_image字段
print("宠物信息面板 ", pet_name, " 的图片路径:", scene_path)
#print("宠物信息面板 ", pet_name, " 的图片路径:", scene_path)
if scene_path != "" and ResourceLoader.exists(scene_path):
print("宠物信息面板开始加载宠物场景:", scene_path)
#print("宠物信息面板开始加载宠物场景:", scene_path)
var pet_scene = load(scene_path)
if pet_scene:
var pet_instance = pet_scene.instantiate()
@@ -103,7 +103,7 @@ func _get_pet_texture(pet_name: String) -> Texture2D:
var frame_count = pet_instance.sprite_frames.get_frame_count(default_animation)
if frame_count > 0:
var texture = pet_instance.sprite_frames.get_frame_texture(default_animation, 0)
print("宠物信息面板成功获取宠物纹理:", pet_name)
#print("宠物信息面板成功获取宠物纹理:", pet_name)
pet_instance.queue_free()
return texture
else:
@@ -119,22 +119,6 @@ func _get_pet_texture(pet_name: String) -> Texture2D:
print("宠物信息面板配置中没有找到:", pet_name)
return null
# 加载宠物配置数据
func _load_pet_config() -> Dictionary:
var file = FileAccess.open("res://Data/pet_data.json", FileAccess.READ)
if file == null:
return {}
var json = JSON.new()
var json_string = file.get_as_text()
file.close()
var parse_result = json.parse(json_string)
if parse_result != OK:
return {}
return json.data
# 设置宠物详细信息使用bbcode美化- 新格式
func _set_pet_detailed_info(pet_name: String, pet_data: Dictionary):
# 计算宠物年龄