129 lines
4.6 KiB
GDScript
129 lines
4.6 KiB
GDScript
# VERTICAL SLICE - NOT FOR PRODUCTION
|
|
# Date: 2026-09-29(迭代 8 卡④ 最小设置面)
|
|
# 设置覆盖层(纯视图边界规范 1.3 同款):音量滑杆/全屏/减动效三件+返回(退出游戏已提级开始菜单)。
|
|
# 生效与持久化全经 SettingsStore 单点(实时应用+即改即存);本类零核心触碰。
|
|
# 减动效转正承载(测试调整板旧开关退役——设置面唯一入口,卡④ AC③)。
|
|
# 探针接缝:retarget(store) = 隔离存档换注口(同 camp 换注先例);控件引用公有只读供断言。
|
|
class_name SettingsOverlay
|
|
extends Control
|
|
|
|
signal closed
|
|
|
|
var _store
|
|
var _volume: HSlider
|
|
var _volume_val: Label
|
|
var _fs_btn: Button
|
|
var _motion_btn: Button
|
|
|
|
|
|
func _init(store) -> void:
|
|
_store = store
|
|
_build()
|
|
_sync()
|
|
visible = false
|
|
|
|
|
|
# 探针隔离换注(冒烟/探针禁碰真实 user://settings.cfg——换注后按新 store 重挂控件态)
|
|
func retarget(store) -> void:
|
|
_store = store
|
|
_sync()
|
|
|
|
|
|
func _build() -> void:
|
|
var dim := ColorRect.new()
|
|
dim.color = UiKit.BG_OVERLAY
|
|
dim.set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
add_child(dim)
|
|
var center := CenterContainer.new()
|
|
center.set_anchors_preset(Control.PRESET_FULL_RECT)
|
|
dim.add_child(center)
|
|
var box := VBoxContainer.new()
|
|
box.custom_minimum_size = Vector2(560, 0)
|
|
box.add_theme_constant_override("separation", 8)
|
|
center.add_child(box)
|
|
|
|
var title := UiKit.label("设置", 26, true)
|
|
title.add_theme_color_override("font_color", UiKit.WARM)
|
|
box.add_child(title)
|
|
var hint := UiKit.label("系统级设置——独立存储不随存档(一安装一份,删游戏才消失)", 13, false)
|
|
hint.add_theme_color_override("font_color", UiKit.WARM_SOFT)
|
|
box.add_child(hint)
|
|
box.add_child(HSeparator.new())
|
|
|
|
# 音量(master bus 实时生效——入口归设置、生效口径归 音频.md)
|
|
var vol_row := HBoxContainer.new()
|
|
box.add_child(vol_row)
|
|
vol_row.add_child(UiKit.label("音量", 15, false))
|
|
_volume = HSlider.new()
|
|
_volume.min_value = 0
|
|
_volume.max_value = 100
|
|
_volume.step = 1
|
|
_volume.custom_minimum_size = Vector2(280, 24)
|
|
_volume.value_changed.connect(_on_volume_changed)
|
|
vol_row.add_child(_volume)
|
|
_volume_val = UiKit.label("100%", 15, true)
|
|
_volume_val.custom_minimum_size = Vector2(60, 0)
|
|
vol_row.add_child(_volume_val)
|
|
|
|
# 开关形态(二轮修改批 D2 2026-09-29 用户目检——原生 CheckButton 暗底不显眼,
|
|
# 换 UiKit 按钮形态 toggle:文字「全屏:开/关」随态换面)
|
|
_fs_btn = UiKit.button("全屏:关")
|
|
_fs_btn.toggle_mode = true
|
|
_fs_btn.toggled.connect(_on_fullscreen_toggled)
|
|
box.add_child(_fs_btn)
|
|
|
|
# 减动效(battle.md §Transitions 承诺转正——时长减半,结算逐行兑现=信息载体不整体跳过)
|
|
# 文案由 _sync_motion_text 按状态装配(构造串仅占位——_sync 启动即覆盖)
|
|
_motion_btn = UiKit.button("结算演出动画")
|
|
_motion_btn.toggle_mode = true
|
|
_motion_btn.toggled.connect(_on_motion_toggled)
|
|
box.add_child(_motion_btn)
|
|
|
|
box.add_child(HSeparator.new())
|
|
# 退出游戏已提级开始菜单(D1——设置面不再承载,用户裁决「退出只在一级菜单出现」)
|
|
var close_btn := UiKit.button("返回")
|
|
close_btn.pressed.connect(_emit_closed)
|
|
box.add_child(close_btn)
|
|
|
|
|
|
func _sync() -> void:
|
|
_volume.set_value_no_signal(roundf(_store.volume_linear * 100.0))
|
|
_volume_val.text = "%d%%" % roundi(_store.volume_linear * 100.0)
|
|
_fs_btn.set_pressed_no_signal(_store.fullscreen)
|
|
_fs_btn.text = "全屏:%s" % ("开" if _store.fullscreen else "关")
|
|
_motion_btn.set_pressed_no_signal(_store.reduced_motion)
|
|
_sync_motion_text()
|
|
|
|
|
|
# T17 修复:文案随状态即时刷新(旧 bug=切换后文案恒「开」,玩家无法得知当前态)+语义命名
|
|
# (「减动效」玩家读不懂——实称「结算演出动画」速度档)+操作提示内联(所见即所得)。
|
|
func _sync_motion_text() -> void:
|
|
if _store.reduced_motion:
|
|
_motion_btn.text = "结算演出动画:快速(时长减半——运动敏感/演示用)· 点击改回完整"
|
|
else:
|
|
_motion_btn.text = "结算演出动画:完整 · 点击改为快速(时长减半——运动敏感/演示用)"
|
|
|
|
|
|
func _on_volume_changed(v: float) -> void:
|
|
_store.volume_linear = v / 100.0
|
|
_store.apply()
|
|
_store.save_settings()
|
|
_volume_val.text = "%d%%" % int(v)
|
|
|
|
|
|
func _on_fullscreen_toggled(on: bool) -> void:
|
|
_store.fullscreen = on
|
|
_store.apply()
|
|
_store.save_settings()
|
|
|
|
|
|
func _on_motion_toggled(on: bool) -> void:
|
|
_store.reduced_motion = on
|
|
_store.apply()
|
|
_store.save_settings()
|
|
_sync_motion_text() # T17 修复:切换即时刷新文案(旧版漏刷新=状态文字恒「开」)
|
|
|
|
|
|
func _emit_closed() -> void:
|
|
closed.emit()
|