feat: HUD 增加时间流速控制,新增 Settings 持久化
- 顶栏改为暂停/1x/5x/20x 按钮组,当前档位高亮 - TimeSystem 支持暂停与档位切换 - 新增 Settings 单例,存档默认流速并开机应用 - GameState 补充年月日,支持 12x30 历法推进
This commit is contained in:
@@ -61,6 +61,35 @@ size_flags_horizontal = 3
|
||||
size_flags_vertical = 8
|
||||
label_settings = SubResource("LabelSettings_bn2o5")
|
||||
|
||||
[node name="SpeedGroup" type="HBoxContainer" parent="HBoxContainer" unique_id=2144893126]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[node name="Button_Pause" type="Button" parent="HBoxContainer/SpeedGroup" unique_id=2144893127]
|
||||
custom_minimum_size = Vector2(64, 0)
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("1_pa2rn")
|
||||
text = "暂停"
|
||||
|
||||
[node name="Button_Speed1" type="Button" parent="HBoxContainer/SpeedGroup" unique_id=2144893128]
|
||||
custom_minimum_size = Vector2(48, 0)
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("1_pa2rn")
|
||||
text = "1x"
|
||||
|
||||
[node name="Button_Speed5" type="Button" parent="HBoxContainer/SpeedGroup" unique_id=2144893129]
|
||||
custom_minimum_size = Vector2(48, 0)
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("1_pa2rn")
|
||||
text = "5x"
|
||||
|
||||
[node name="Button_Speed20" type="Button" parent="HBoxContainer/SpeedGroup" unique_id=2144893130]
|
||||
custom_minimum_size = Vector2(48, 0)
|
||||
layout_mode = 2
|
||||
theme_override_fonts/font = ExtResource("1_pa2rn")
|
||||
text = "20x"
|
||||
|
||||
[node name="placeholder_1" type="Label" parent="HBoxContainer" unique_id=1042446504]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
@@ -117,4 +146,5 @@ size_flags_horizontal = 3
|
||||
theme_override_fonts/font = ExtResource("1_pa2rn")
|
||||
text = "返回"
|
||||
|
||||
[connection signal="button_up" from="HBoxContainer/SpeedGroup/Button_Pause" to="." method="_on_button_pause_button_up"]
|
||||
[connection signal="button_up" from="HBoxContainer/Button_Return" to="." method="_on_button_return_button_up"]
|
||||
|
||||
@@ -2,7 +2,31 @@ extends Control
|
||||
|
||||
signal sign_return_mainmenu
|
||||
|
||||
const SPEED_BUTTONS := ["Button_Speed1", "Button_Speed5", "Button_Speed20"]
|
||||
const ACTIVE_COLOR := Color(1.0, 1.0, 1.0)
|
||||
const INACTIVE_COLOR := Color(0.55, 0.55, 0.55)
|
||||
|
||||
func _ready() -> void:
|
||||
for i in SPEED_BUTTONS.size():
|
||||
var btn: Button = $HBoxContainer/SpeedGroup.get_node(SPEED_BUTTONS[i])
|
||||
btn.button_up.connect(_on_speed_button_up.bind(i))
|
||||
_update_speed_ui()
|
||||
|
||||
func _on_button_return_button_up() -> void:
|
||||
sign_return_mainmenu.emit()
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_button_pause_button_up() -> void:
|
||||
TimeSystem.toggle_pause()
|
||||
_update_speed_ui()
|
||||
|
||||
func _on_speed_button_up(index: int) -> void:
|
||||
TimeSystem.set_speed_index(index)
|
||||
_update_speed_ui()
|
||||
|
||||
func _update_speed_ui() -> void:
|
||||
var pause_btn: Button = $HBoxContainer/SpeedGroup/Button_Pause
|
||||
pause_btn.text = "继续" if TimeSystem.paused else "暂停"
|
||||
for i in SPEED_BUTTONS.size():
|
||||
var btn: Button = $HBoxContainer/SpeedGroup.get_node(SPEED_BUTTONS[i])
|
||||
var active := (i == TimeSystem.speed_index) and not TimeSystem.paused
|
||||
btn.modulate = ACTIVE_COLOR if active else INACTIVE_COLOR
|
||||
|
||||
Reference in New Issue
Block a user