From 1cbfd12574607b7da0615d493e98b77ac82def52 Mon Sep 17 00:00:00 2001 From: chen Date: Mon, 3 Aug 2026 22:37:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9C=BA=E6=99=AF=E5=88=86=E7=BB=84?= =?UTF-8?q?=E6=94=B9=E4=BB=A3=E7=A0=81=E6=B3=A8=E5=86=8C=EF=BC=8CHUD=20?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=E6=8C=89=E9=92=AE=E6=94=B9=20toggle=20?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MainGame 用 add_to_group 注册 game_scene,修复分组未生效导致时间不推进 - 速度按钮改用 toggle_mode + pressed 状态高亮,暂停时禁用 --- src/Core/MainGame.gd | 3 +++ src/UI/HUD/top_bar_hud.gd | 17 ++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) 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