D5/UI/main/ui_bottom_info.gd
2025-05-09 15:40:47 +08:00

39 lines
1.8 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends Control
@onready var save_button: Button = $HBoxContainer/Part_1/Save
@onready var play_menu_button: Button = $HBoxContainer/Part_4/Menu
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
save_button.pressed.connect(_on_save_button_pressed)
play_menu_button.pressed.connect(_on_play_menu_button_pressed)
# 当保存按钮被按下时调用的函数
func _on_save_button_pressed() -> void:
print("UI_Bottom_Info: Save button pressed by player.")
# 检查 SaveLoadManager 是否可用 (它应该是一个 Autoload 单例)
if SaveLoadManager:
print("UI_Bottom_Info: Calling SaveLoadManager.save_game(1)...")
# 调用存档管理器的 save_game 函数,暂时硬编码使用槽位 1
var save_successful: bool = SaveLoadManager.save_game(1)
# 根据存档结果输出反馈信息
if save_successful:
print("UI_Bottom_Info: SaveLoadManager reported save successful.")
var notice = get_tree().get_first_node_in_group("notice")
notice._start("保存成功", null)
# 这里可以添加更友好的用户反馈,例如显示一个短暂的 "保存成功" 标签
# get_tree().call_group("feedback_ui", "show_message", "保存成功!") # 示例假设有反馈UI组
else:
printerr("UI_Bottom_Info: SaveLoadManager reported save failed.")
# 这里可以添加用户反馈,例如显示 "保存失败"
# get_tree().call_group("feedback_ui", "show_message", "保存失败!请检查日志。") # 示例
else:
# 如果 SaveLoadManager 未正确配置为 Autoload则打印错误
printerr("UI_Bottom_Info Error: SaveLoadManager Autoload not found! Cannot save game.")
func _on_play_menu_button_pressed() -> void:
var play_menu = get_tree().get_first_node_in_group("play_menu")
play_menu.show_menu()