72 lines
2.7 KiB
GDScript
72 lines
2.7 KiB
GDScript
## 顶部信息栏 HUD(挂载于 TopBarHUD.tscn)。
|
|
## 显示灵石/时间/声望,提供时间流速控制与返回主菜单入口。
|
|
extends Control
|
|
|
|
## 请求返回主菜单。
|
|
signal sign_return_mainmenu
|
|
## 请求打开弟子名录面板。
|
|
signal sign_open_disciples
|
|
|
|
@onready var time_label: Label = %Value_Time
|
|
@onready var currency_label: Label = %Value_Currency
|
|
@onready var reputation_label: Label = %Value_Reputation
|
|
@onready var pause_button: Button = %Button_Pause
|
|
@onready var speed_buttons: Array[Button] = [%Button_Speed1, %Button_Speed5, %Button_Speed20]
|
|
|
|
func _ready() -> void:
|
|
for i in speed_buttons.size():
|
|
var btn := speed_buttons[i]
|
|
btn.toggle_mode = true
|
|
btn.button_up.connect(_on_speed_button_up.bind(i))
|
|
# 时间:每日推进时刷新日期
|
|
TimeSystem.day_passed.connect(_on_day_passed)
|
|
# 资源数值:信号仅在变化时触发,初始值需手动设置一次
|
|
SectManager.spirit_stones_changed.connect(_on_spirit_stones_changed)
|
|
SectManager.reputation_changed.connect(_on_reputation_changed)
|
|
currency_label.text = str(SectManager.spirit_stones)
|
|
reputation_label.text = str(SectManager.reputation)
|
|
time_label.text = TimeSystem.get_date_text()
|
|
_update_speed_ui()
|
|
|
|
## 每日推进时刷新日期显示。
|
|
func _on_day_passed(_year: int, _month: int, _day: int) -> void:
|
|
time_label.text = TimeSystem.get_date_text()
|
|
|
|
## 灵石数量变化时刷新显示。
|
|
## @param new_value: 变化后的灵石总量
|
|
func _on_spirit_stones_changed(new_value: int, _delta: int) -> void:
|
|
currency_label.text = str(new_value)
|
|
|
|
## 声望变化时刷新显示。
|
|
## @param new_value: 变化后的声望总量
|
|
func _on_reputation_changed(new_value: int, _delta: int) -> void:
|
|
reputation_label.text = str(new_value)
|
|
|
|
## 点击"返回"按钮。
|
|
func _on_button_return_button_up() -> void:
|
|
sign_return_mainmenu.emit()
|
|
|
|
## 点击"管理"按钮:请求打开弟子名录面板(由 MainGame 处理)。
|
|
func _on_button_staff_management_button_up() -> void:
|
|
sign_open_disciples.emit()
|
|
|
|
## 点击暂停/继续按钮,切换后刷新按钮状态。
|
|
func _on_button_pause_button_up() -> void:
|
|
TimeSystem.toggle_pause()
|
|
_update_speed_ui()
|
|
|
|
## 点击流速档位按钮。
|
|
## @param index: 目标档位索引(由 _ready 中 bind 传入)
|
|
func _on_speed_button_up(index: int) -> void:
|
|
TimeSystem.set_speed_index(index)
|
|
_update_speed_ui()
|
|
|
|
## 刷新速度组 UI:暂停按钮文字与各档位按下状态。
|
|
## 选中档位用 toggle 的 pressed 状态表达(原生高亮),暂停时禁用档位按钮。
|
|
func _update_speed_ui() -> void:
|
|
pause_button.text = "继续" if TimeSystem.paused else "暂停"
|
|
for i in speed_buttons.size():
|
|
var btn := speed_buttons[i]
|
|
btn.set_pressed_no_signal(i == TimeSystem.speed_index)
|
|
btn.disabled = TimeSystem.paused
|