diff --git a/src/Core/MainGame.gd b/src/Core/MainGame.gd index d4a82c0..28cb79e 100644 --- a/src/Core/MainGame.gd +++ b/src/Core/MainGame.gd @@ -3,6 +3,9 @@ extends Node func _ready() -> void: + # 注册为游戏世界场景(供 TimeSystem 判断是否推进时间) + add_to_group("game_scene") + # 应用用户设置中的默认流速 TimeSystem.apply_default_speed() ## 顶部 HUD 的返回主菜单请求。 diff --git a/src/UI/HUD/top_bar_hud.gd b/src/UI/HUD/top_bar_hud.gd index ba3d628..b1c9988 100644 --- a/src/UI/HUD/top_bar_hud.gd +++ b/src/UI/HUD/top_bar_hud.gd @@ -5,18 +5,15 @@ extends Control ## 请求返回主菜单。 signal sign_return_mainmenu -## 激活档位按钮颜色。 -const ACTIVE_COLOR := Color(1.0, 1.0, 1.0) -## 未激活档位按钮颜色。 -const INACTIVE_COLOR := Color(0.55, 0.55, 0.55) - @onready var time_label: Label = %Value_Time @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(): - speed_buttons[i].button_up.connect(_on_speed_button_up.bind(i)) + 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) _update_speed_ui() time_label.text = TimeSystem.get_date_text() @@ -40,9 +37,11 @@ func _on_speed_button_up(index: int) -> void: TimeSystem.set_speed_index(index) _update_speed_ui() -## 刷新速度组 UI:暂停按钮文字与各档位高亮状态。 +## 刷新速度组 UI:暂停按钮文字与各档位按下状态。 +## 选中档位用 toggle 的 pressed 状态表达(原生高亮),暂停时禁用档位按钮。 func _update_speed_ui() -> void: pause_button.text = "继续" if TimeSystem.paused else "暂停" for i in speed_buttons.size(): - var active := (i == TimeSystem.speed_index) and not TimeSystem.paused - speed_buttons[i].modulate = ACTIVE_COLOR if active else INACTIVE_COLOR + var btn := speed_buttons[i] + btn.set_pressed_no_signal(i == TimeSystem.speed_index) + btn.disabled = TimeSystem.paused