feat: implement DEV-1 essential settings
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
## Current State
|
||||
|
||||
- Stage: `HANDDRAWN_ENTRY_FLOW_APPROVED`
|
||||
- Active implementation step: `DEV-1D_IN_PROGRESS`
|
||||
- Active implementation step: `DEV-1E_IN_PROGRESS`
|
||||
- Planning baseline: `d59555c5a3cf95fc44de79ba06c02e650eb3df3b`
|
||||
- Documentation consolidation baseline:
|
||||
`53824d2394e7facdc8dca19aa20a690a5c960aca`
|
||||
@@ -43,6 +43,6 @@
|
||||
|
||||
## Next Action
|
||||
|
||||
Implement and narrowly verify `DEV-1D`: SET-001..006 and SYS-008 with real
|
||||
persisted behavior, precise unavailable reasons and exact Title return. Keep
|
||||
later gameplay pages frozen until Settings/Credits are committed and pushed.
|
||||
Complete `DEV-1E`: verify the real Boot-to-Title/settings input path, required
|
||||
landscape/language/130% layouts, reset/restart behavior, strict regression and
|
||||
normal-render evidence. Gameplay pages and delivery remain frozen.
|
||||
|
||||
@@ -432,7 +432,7 @@ until that entry path is runnable, verified, committed and pushed.
|
||||
## FG-4 Japanese 2D Hand-Drawn Redevelopment Plan
|
||||
|
||||
> Status: `OWNER_APPROVED`
|
||||
> Active implementation step: `DEV-1D_IN_PROGRESS`
|
||||
> Active implementation step: `DEV-1E_IN_PROGRESS`
|
||||
> Goal: `06_DEVELOPMENT_AND_REVIEW.md`
|
||||
> Contract: `06_DEVELOPMENT_AND_REVIEW.md`
|
||||
> Page plan: `03_PAGES_AND_UX.md`
|
||||
@@ -494,8 +494,8 @@ Only one row may be `IN_PROGRESS`. A failed check keeps that row active.
|
||||
| `DEV-1A` SYS-001 Boot | `COMPLETE` | New entry controller, resource/settings/save verification, named progress, recoverable error, Retry and safe diagnostics | `ABG_DEV1_BOOT_OK`; `ABG_DEV1_BOOT_RUNTIME_OK`; strict attempt runner PASS | Focused Boot implementation, test, plan/checkpoint update and push |
|
||||
| `DEV-1B` SYS-002 First launch | `COMPLETE` | Persistent language, safe area, 100/115/130% text, reduced motion/flashes, captions and usable first-launch completion | `ABG_DEV1_FIRST_LAUNCH_OK`; Boot runtime handoff regression PASS | Focused setup implementation, persistence/layout test, plan/checkpoint update and push |
|
||||
| `DEV-1C` SYS-003 Title | `COMPLETE` | Painted guild-threshold Title, truthful New Game/Continue/Settings/Credits state and exact return/back behavior | `ABG_DEV1_TITLE_OK`; first-launch regression PASS | Focused Title implementation, state/navigation test, plan/checkpoint update and push |
|
||||
| `DEV-1D` SET-001..006 + SYS-008 | `IN_PROGRESS` | Settings index, display/text, motion/flash/power, audio/captions, controls, language/locale, credits/licenses/data notice | Every visible control changes real persisted state or exposes a precise unavailable reason; Apply/Discard and exact caller return pass | Focused Settings/Credits implementation, behavior/localization test, plan/checkpoint update and push |
|
||||
| `DEV-1E` Entry-flow candidate | `PENDING` | End-to-end player order, responsive refinement, restart/reset fixtures and candidate evidence | Boot-to-Title real input path; 760x360, 844x390, 1280x720; English/Chinese; 100/130%; reduced modes; normal rendering; full applicable regression; strict diagnostics | Candidate docs/evidence closure commit and push |
|
||||
| `DEV-1D` SET-001..006 + SYS-008 | `COMPLETE` | Settings index, display/text, motion/flash/power, audio/captions, controls, language/locale, credits/licenses/data notice | `ABG_DEV1_SETTINGS_OK`; Title and first-launch regressions PASS | Focused Settings/Credits implementation, behavior/localization test, plan/checkpoint update and push |
|
||||
| `DEV-1E` Entry-flow candidate | `IN_PROGRESS` | End-to-end player order, responsive refinement, restart/reset fixtures and candidate evidence | Boot-to-Title real input path; 760x360, 844x390, 1280x720; English/Chinese; 100/130%; reduced modes; normal rendering; full applicable regression; strict diagnostics | Candidate docs/evidence closure commit and push |
|
||||
|
||||
<!-- markdownlint-enable MD013 -->
|
||||
|
||||
@@ -617,3 +617,15 @@ they are not duplicated here.
|
||||
state the unavailable downstream review instead of silently doing nothing.
|
||||
- Settings/Credits return exactly to Title, while Back opens a non-destructive
|
||||
exit review. `ABG_DEV1_TITLE_OK` passes with no-save and resumable fixtures.
|
||||
|
||||
### 2026-08-17 - DEV-1D Settings And Credits Implemented
|
||||
|
||||
- SET-001..006 provide stable category navigation and persisted display/text,
|
||||
motion/flash/power, audio/caption, control and locale behavior with explicit
|
||||
Apply/Discard handling and exact Title return.
|
||||
- Master mute plus Music/SFX levels apply to real Godot buses. Absent separate
|
||||
Ambience/Voice assets and conflict-safe remapping remain visible with precise
|
||||
unavailable reasons rather than inert controls.
|
||||
- SYS-008 names authorship, bundled SIL font license, offline behavior, local
|
||||
data/privacy and the no-external-link policy. `ABG_DEV1_SETTINGS_OK` and the
|
||||
preceding Title/first-launch regressions pass.
|
||||
|
||||
@@ -22,6 +22,9 @@ var retry_button: Button
|
||||
var diagnostics_label: Label
|
||||
var current_screen := "boot"
|
||||
var title_notice := ""
|
||||
var settings_draft: Dictionary = {}
|
||||
var settings_category := "display"
|
||||
var settings_notice := ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -375,11 +378,276 @@ func open_continue_boundary() -> void:
|
||||
|
||||
|
||||
func show_settings_placeholder() -> void:
|
||||
_show_child_placeholder("settings", _tr("设置", "SETTINGS"), _tr("基础设置分类将在下一子步启用。", "Essential Settings categories open in the next substep."))
|
||||
show_settings()
|
||||
|
||||
|
||||
func show_credits_placeholder() -> void:
|
||||
_show_child_placeholder("credits", _tr("制作人员、许可与数据", "CREDITS, LICENSES AND DATA"), _tr("完整的作者、许可与离线数据说明将在下一子步启用。", "Authorship, licenses and offline data details open in the next substep."))
|
||||
show_credits()
|
||||
|
||||
|
||||
func show_settings(category := "") -> void:
|
||||
current_screen = "settings"
|
||||
if settings_draft.is_empty() or not category.is_empty():
|
||||
settings_draft = settings.duplicate(true)
|
||||
if not category.is_empty():
|
||||
settings_category = category
|
||||
_build_world_base()
|
||||
var safe := MarginContainer.new()
|
||||
safe.name = "SettingsSafeArea"
|
||||
safe.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
var margin := int(settings_draft.get("safe_area", 24)) + 20
|
||||
safe.add_theme_constant_override("margin_left", margin)
|
||||
safe.add_theme_constant_override("margin_right", margin)
|
||||
safe.add_theme_constant_override("margin_top", 24)
|
||||
safe.add_theme_constant_override("margin_bottom", 24)
|
||||
add_child(safe)
|
||||
var outer := VBoxContainer.new()
|
||||
outer.name = "SettingsOuter"
|
||||
outer.add_theme_constant_override("separation", 8)
|
||||
safe.add_child(outer)
|
||||
var heading := HBoxContainer.new()
|
||||
heading.name = "SettingsHeading"
|
||||
outer.add_child(heading)
|
||||
var title := _label(_tr("设置", "SETTINGS"), _scaled(26), Color("#f3f6f2"))
|
||||
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
heading.add_child(title)
|
||||
heading.add_child(_label(_tr("来源:标题首页", "Caller: Title"), _scaled(13), Color("#d7e0dd")))
|
||||
var workspace := HBoxContainer.new()
|
||||
workspace.name = "SettingsWorkspace"
|
||||
workspace.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
workspace.add_theme_constant_override("separation", 14)
|
||||
outer.add_child(workspace)
|
||||
var rail := VBoxContainer.new()
|
||||
rail.name = "SettingsCategories"
|
||||
rail.custom_minimum_size = Vector2(174, 0)
|
||||
rail.add_theme_constant_override("separation", 4)
|
||||
workspace.add_child(rail)
|
||||
for row in [
|
||||
["display", _tr("显示与文字", "Display & Text")],
|
||||
["motion", _tr("动态与省电", "Motion & Power")],
|
||||
["audio", _tr("音频与字幕", "Audio & Captions")],
|
||||
["controls", _tr("控制", "Controls")],
|
||||
["language", _tr("语言", "Language")],
|
||||
["credits", _tr("制作人员与数据", "Credits & Data")],
|
||||
]:
|
||||
var button := _tool_button("SettingsCategory_%s" % row[0], row[1], open_settings_category.bind(row[0]))
|
||||
button.custom_minimum_size = Vector2(174, 44)
|
||||
button.disabled = settings_category == row[0]
|
||||
rail.add_child(button)
|
||||
var scroll := ScrollContainer.new()
|
||||
scroll.name = "SettingsScroll"
|
||||
scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
workspace.add_child(scroll)
|
||||
var content := VBoxContainer.new()
|
||||
content.name = "SettingsContent"
|
||||
content.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
content.add_theme_constant_override("separation", 6)
|
||||
scroll.add_child(content)
|
||||
_build_settings_category(content)
|
||||
var footer := HBoxContainer.new()
|
||||
footer.name = "SettingsFooter"
|
||||
footer.add_theme_constant_override("separation", 8)
|
||||
outer.add_child(footer)
|
||||
var notice := _label(settings_notice, _scaled(13), Color("#ffe1a6"))
|
||||
notice.name = "SettingsNotice"
|
||||
notice.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
footer.add_child(notice)
|
||||
footer.add_child(_tool_button("SettingsBack", _tr("返回", "Back"), request_settings_back))
|
||||
footer.add_child(_tool_button("SettingsDiscard", _tr("放弃并返回", "Discard & Back"), discard_settings))
|
||||
footer.add_child(_action_button("SettingsApply", _tr("应用", "Apply"), apply_settings))
|
||||
|
||||
|
||||
func _build_settings_category(content: VBoxContainer) -> void:
|
||||
match settings_category:
|
||||
"display":
|
||||
content.add_child(_settings_heading(_tr("显示与文字", "DISPLAY & TEXT")))
|
||||
content.add_child(_choice_button("SettingSafeArea", _tr("安全区域", "Safe area"), "%d px" % int(settings_draft.safe_area), cycle_setting_safe_area))
|
||||
content.add_child(_choice_button("SettingTextScale", _tr("文字大小", "Text size"), "%d%%" % int(round(float(settings_draft.text_scale) * 100.0)), cycle_setting_text_scale))
|
||||
content.add_child(_slider_row("SettingBrightness", _tr("亮度", "Brightness"), float(settings_draft.brightness), 0.7, 1.2, 0.1, set_brightness))
|
||||
content.add_child(_check_button("SettingHighContrast", _tr("高对比轮廓", "High-contrast contours"), bool(settings_draft.high_contrast), set_high_contrast))
|
||||
content.add_child(_check_button("SettingColorCues", _tr("颜色以外的形状提示", "Shape cues beyond color"), bool(settings_draft.color_cues), set_color_cues))
|
||||
"motion":
|
||||
content.add_child(_settings_heading(_tr("动态、闪烁与省电", "MOTION, FLASHES & POWER")))
|
||||
content.add_child(_check_button("SettingReducedMotion", _tr("减少动画", "Reduced motion"), bool(settings_draft.reduced_motion), set_reduced_motion))
|
||||
content.add_child(_check_button("SettingReducedFlashes", _tr("减少闪烁", "Reduced flashes"), bool(settings_draft.reduced_flashes), set_reduced_flashes))
|
||||
content.add_child(_slider_row("SettingShake", _tr("镜头震动", "Camera shake"), float(settings_draft.shake_intensity), 0.0, 1.0, 0.25, set_shake))
|
||||
content.add_child(_check_button("SettingHitPause", _tr("命中停顿", "Hit pause"), bool(settings_draft.hit_pause), set_hit_pause))
|
||||
content.add_child(_choice_button("SettingParticles", _tr("粒子密度", "Particles"), _tr("低", "Low") if settings_draft.particle_density == "low" else _tr("标准", "Standard"), cycle_particles))
|
||||
content.add_child(_check_button("SettingLowPower", _tr("低功耗模式", "Low-power mode"), bool(settings_draft.low_power), set_low_power))
|
||||
"audio":
|
||||
content.add_child(_settings_heading(_tr("音频与字幕", "AUDIO & CAPTIONS")))
|
||||
content.add_child(_check_button("SettingMasterMute", _tr("主静音", "Master mute"), bool(settings_draft.master_muted), set_master_mute))
|
||||
content.add_child(_slider_row("SettingMusic", _tr("音乐", "Music"), float(settings_draft.music_volume), 0.0, 1.0, 0.1, set_music_volume))
|
||||
content.add_child(_slider_row("SettingSFX", _tr("音效", "SFX"), float(settings_draft.sfx_volume), 0.0, 1.0, 0.1, set_sfx_volume))
|
||||
content.add_child(_unavailable_row("SettingAmbienceUnavailable", _tr("环境音:DEV-1 未集成独立总线", "Ambience: no separate DEV-1 bus is integrated")))
|
||||
content.add_child(_unavailable_row("SettingVoiceUnavailable", _tr("语音:当前没有语音资产", "Voice: no voice assets are present")))
|
||||
content.add_child(_check_button("SettingCaptions", _tr("字幕", "Captions"), bool(settings_draft.captions), set_captions))
|
||||
content.add_child(_choice_button("SettingCaptionDetail", _tr("字幕细节", "Caption detail"), _tr("完整", "Full") if settings_draft.caption_detail == "full" else _tr("关键事件", "Critical"), cycle_caption_detail))
|
||||
content.add_child(_choice_button("SettingDynamicRange", _tr("动态范围", "Dynamic range"), String(settings_draft.dynamic_range).capitalize(), cycle_dynamic_range))
|
||||
"controls":
|
||||
content.add_child(_settings_heading(_tr("控制", "CONTROLS")))
|
||||
content.add_child(_label(_tr("触控、键鼠与控制器共享确认、取消和导航语义。", "Touch, keyboard/mouse and controller share confirm, cancel and navigation semantics."), _scaled(15), Color("#d7e0dd")))
|
||||
content.add_child(_slider_row("SettingHoldDuration", _tr("长按确认时间", "Hold duration"), float(settings_draft.hold_duration), 0.3, 1.5, 0.1, set_hold_duration))
|
||||
content.add_child(_check_button("SettingVibration", _tr("震动", "Vibration"), bool(settings_draft.vibration), set_vibration))
|
||||
content.add_child(_unavailable_row("SettingRemapUnavailable", _tr("按键重映射:DEV-1 仅提供默认入口映射;完整冲突检查属于后续控制页面", "Remapping: DEV-1 uses the default entry map; conflict-safe remapping belongs to the later Controls page")))
|
||||
"language":
|
||||
content.add_child(_settings_heading(_tr("语言与地区格式", "LANGUAGE & LOCALE")))
|
||||
content.add_child(_choice_button("SettingLocale", _tr("界面语言", "Interface language"), _tr("简体中文", "English"), cycle_setting_locale))
|
||||
content.add_child(_label(_tr("日期 2026-08-17 · 数字 1,234.5 · 文本可换行", "Date 2026-08-17 · Number 1,234.5 · Text may wrap"), _scaled(16), Color("#f3f6f2")))
|
||||
"credits":
|
||||
content.add_child(_settings_heading(_tr("制作人员、许可与数据", "CREDITS, LICENSES & DATA")))
|
||||
content.add_child(_label(_credits_text(), _scaled(14), Color("#f3f6f2")))
|
||||
|
||||
|
||||
func open_settings_category(category: String) -> void:
|
||||
settings_category = category
|
||||
show_settings()
|
||||
|
||||
|
||||
func request_settings_back() -> void:
|
||||
if settings_draft != settings:
|
||||
settings_notice = _tr("有未保存的更改。请选择应用或放弃并返回。", "Unsaved changes. Choose Apply or Discard & Back.")
|
||||
show_settings()
|
||||
else:
|
||||
back_to_title()
|
||||
|
||||
|
||||
func discard_settings() -> void:
|
||||
settings_draft = {}
|
||||
settings_notice = ""
|
||||
back_to_title()
|
||||
|
||||
|
||||
func apply_settings() -> void:
|
||||
var saved: Dictionary = settings_store.save_settings(settings_draft)
|
||||
if not saved.ok:
|
||||
settings_notice = _tr("设置保存失败,请重试。", "Settings save failed. Retry.") + " [%s]" % String(saved.code)
|
||||
show_settings()
|
||||
return
|
||||
settings = saved.settings.duplicate(true)
|
||||
settings_draft = settings.duplicate(true)
|
||||
_apply_runtime_settings()
|
||||
settings_notice = _tr("设置已应用", "Settings applied")
|
||||
show_settings()
|
||||
|
||||
|
||||
func show_credits() -> void:
|
||||
settings_draft = settings.duplicate(true)
|
||||
settings_category = "credits"
|
||||
show_settings("credits")
|
||||
|
||||
|
||||
func _credits_text() -> String:
|
||||
return _tr(
|
||||
"Aetherbound Guild · 原创游戏与运行实现\n字体:Noto Sans SC,SIL Open Font License 1.1(完整许可随游戏提供)\n数据:核心游戏完全离线;DEV-1 不收集分析数据,不创建账户,不打开外部链接。\n隐私:设置与远征记录只保存在本地。",
|
||||
"Aetherbound Guild · original game and runtime implementation\nFont: Noto Sans SC, SIL Open Font License 1.1 (full license included)\nData: core play is fully offline; DEV-1 collects no analytics, creates no account and opens no external links.\nPrivacy: settings and expedition records remain local."
|
||||
)
|
||||
|
||||
|
||||
func _apply_runtime_settings() -> void:
|
||||
var master := AudioServer.get_bus_index(&"Master")
|
||||
var music := AudioServer.get_bus_index(&"Music")
|
||||
var sfx := AudioServer.get_bus_index(&"SFX")
|
||||
if master >= 0:
|
||||
AudioServer.set_bus_mute(master, bool(settings.master_muted))
|
||||
if music >= 0:
|
||||
AudioServer.set_bus_volume_db(music, linear_to_db(maxf(0.001, float(settings.music_volume))))
|
||||
if sfx >= 0:
|
||||
AudioServer.set_bus_volume_db(sfx, linear_to_db(maxf(0.001, float(settings.sfx_volume))))
|
||||
|
||||
|
||||
func cycle_setting_safe_area() -> void:
|
||||
settings_draft.safe_area = _next_value(SettingsStore.SAFE_AREA_PRESETS, int(settings_draft.safe_area))
|
||||
show_settings()
|
||||
|
||||
|
||||
func cycle_setting_text_scale() -> void:
|
||||
settings_draft.text_scale = _next_float(SettingsStore.TEXT_SCALES, float(settings_draft.text_scale))
|
||||
show_settings()
|
||||
|
||||
|
||||
func cycle_setting_locale() -> void:
|
||||
settings_draft.locale = "en" if String(settings_draft.locale) == "zh_CN" else "zh_CN"
|
||||
setup_draft = settings_draft.duplicate(true)
|
||||
show_settings()
|
||||
|
||||
|
||||
func cycle_particles() -> void:
|
||||
settings_draft.particle_density = "low" if settings_draft.particle_density == "standard" else "standard"
|
||||
show_settings()
|
||||
|
||||
|
||||
func cycle_caption_detail() -> void:
|
||||
settings_draft.caption_detail = "full" if settings_draft.caption_detail == "critical" else "critical"
|
||||
show_settings()
|
||||
|
||||
|
||||
func cycle_dynamic_range() -> void:
|
||||
settings_draft.dynamic_range = _next_value(["wide", "standard", "night"], String(settings_draft.dynamic_range))
|
||||
show_settings()
|
||||
|
||||
|
||||
func set_brightness(value: float) -> void: settings_draft.brightness = value
|
||||
func set_high_contrast(value: bool) -> void: settings_draft.high_contrast = value
|
||||
func set_color_cues(value: bool) -> void: settings_draft.color_cues = value
|
||||
func set_reduced_motion(value: bool) -> void: settings_draft.reduced_motion = value
|
||||
func set_reduced_flashes(value: bool) -> void: settings_draft.reduced_flashes = value
|
||||
func set_shake(value: float) -> void: settings_draft.shake_intensity = value
|
||||
func set_hit_pause(value: bool) -> void: settings_draft.hit_pause = value
|
||||
func set_low_power(value: bool) -> void: settings_draft.low_power = value
|
||||
func set_master_mute(value: bool) -> void: settings_draft.master_muted = value
|
||||
func set_music_volume(value: float) -> void: settings_draft.music_volume = value
|
||||
func set_sfx_volume(value: float) -> void: settings_draft.sfx_volume = value
|
||||
func set_captions(value: bool) -> void: settings_draft.captions = value
|
||||
func set_hold_duration(value: float) -> void: settings_draft.hold_duration = value
|
||||
func set_vibration(value: bool) -> void: settings_draft.vibration = value
|
||||
|
||||
|
||||
func _next_value(options: Array, current: Variant) -> Variant:
|
||||
return options[(options.find(current) + 1) % options.size()]
|
||||
|
||||
|
||||
func _next_float(options: Array, current: float) -> float:
|
||||
for index in range(options.size()):
|
||||
if is_equal_approx(float(options[index]), current):
|
||||
return float(options[(index + 1) % options.size()])
|
||||
return float(options[0])
|
||||
|
||||
|
||||
func _settings_heading(text_value: String) -> Label:
|
||||
return _label(text_value, _scaled(20), Color("#f3f6f2"))
|
||||
|
||||
|
||||
func _slider_row(node_name: String, text_value: String, value: float, minimum: float, maximum: float, step: float, callback: Callable) -> HBoxContainer:
|
||||
var row := HBoxContainer.new()
|
||||
row.name = node_name
|
||||
row.custom_minimum_size.y = 42
|
||||
var label := _label("%s %.1f" % [text_value, value], _scaled(15), Color("#f3f6f2"))
|
||||
label.custom_minimum_size.x = 190
|
||||
row.add_child(label)
|
||||
var slider := HSlider.new()
|
||||
slider.name = "Slider"
|
||||
slider.min_value = minimum
|
||||
slider.max_value = maximum
|
||||
slider.step = step
|
||||
slider.value = value
|
||||
slider.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
slider.value_changed.connect(callback)
|
||||
row.add_child(slider)
|
||||
return row
|
||||
|
||||
|
||||
func _unavailable_row(node_name: String, reason: String) -> Button:
|
||||
var button := _choice_button(node_name, reason, _tr("不可用", "Unavailable"), show_unavailable_reason.bind(reason))
|
||||
button.disabled = true
|
||||
button.tooltip_text = reason
|
||||
return button
|
||||
|
||||
|
||||
func show_unavailable_reason(reason: String) -> void:
|
||||
settings_notice = reason
|
||||
show_settings()
|
||||
|
||||
|
||||
func _show_child_placeholder(screen_id: String, heading: String, body: String) -> void:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class_name ABGEntrySettingsStore
|
||||
extends RefCounted
|
||||
|
||||
const SETTINGS_VERSION := 1
|
||||
const SETTINGS_VERSION := 2
|
||||
const DEFAULT_PATH := "user://aetherbound_guild_settings.json"
|
||||
const TEXT_SCALES := [1.0, 1.15, 1.3]
|
||||
const SAFE_AREA_PRESETS := [0, 24, 48]
|
||||
@@ -16,8 +16,13 @@ func defaults() -> Dictionary:
|
||||
"locale": "zh_CN",
|
||||
"safe_area": 24,
|
||||
"text_scale": 1.0,
|
||||
"brightness": 1.0,
|
||||
"color_cues": true,
|
||||
"reduced_motion": false,
|
||||
"reduced_flashes": false,
|
||||
"shake_intensity": 1.0,
|
||||
"hit_pause": true,
|
||||
"particle_density": "standard",
|
||||
"captions": true,
|
||||
"high_contrast": false,
|
||||
"low_power": false,
|
||||
@@ -40,6 +45,16 @@ func load_settings() -> Dictionary:
|
||||
var parse_error := parser.parse(FileAccess.get_file_as_string(path))
|
||||
if parse_error != OK or not parser.data is Dictionary:
|
||||
return {"ok": false, "code": "SETTINGS_FILE_INVALID"}
|
||||
if int(parser.data.get("settings_version", 0)) == 1:
|
||||
var migrated := defaults()
|
||||
for key in parser.data.keys():
|
||||
if migrated.has(key):
|
||||
migrated[key] = parser.data[key]
|
||||
migrated.settings_version = SETTINGS_VERSION
|
||||
var migration_save := save_settings(migrated)
|
||||
if not migration_save.ok:
|
||||
return {"ok": false, "code": "SETTINGS_MIGRATION_FAILED"}
|
||||
return {"ok": true, "code": "migrated_v1", "settings": migrated}
|
||||
var validation := validate(parser.data)
|
||||
if not validation.ok:
|
||||
return validation
|
||||
@@ -93,6 +108,12 @@ func validate(value: Dictionary) -> Dictionary:
|
||||
return {"ok": false, "code": "SETTINGS_DYNAMIC_RANGE_INVALID"}
|
||||
if String(value.caption_detail) not in ["critical", "full"]:
|
||||
return {"ok": false, "code": "SETTINGS_CAPTION_DETAIL_INVALID"}
|
||||
if String(value.particle_density) not in ["low", "standard"]:
|
||||
return {"ok": false, "code": "SETTINGS_PARTICLES_INVALID"}
|
||||
if float(value.brightness) < 0.7 or float(value.brightness) > 1.2:
|
||||
return {"ok": false, "code": "SETTINGS_BRIGHTNESS_INVALID"}
|
||||
if float(value.shake_intensity) < 0.0 or float(value.shake_intensity) > 1.0:
|
||||
return {"ok": false, "code": "SETTINGS_SHAKE_INVALID"}
|
||||
for key in ["music_volume", "ambience_volume", "sfx_volume", "voice_volume"]:
|
||||
if float(value[key]) < 0.0 or float(value[key]) > 1.0:
|
||||
return {"ok": false, "code": "SETTINGS_VOLUME_INVALID"}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
extends SceneTree
|
||||
|
||||
const EntryShell = preload("res://entry/entry_shell.gd")
|
||||
const SettingsStore = preload("res://entry/settings_store.gd")
|
||||
const SETTINGS_PATH := "user://dev1_settings_credits_test.json"
|
||||
|
||||
var failures: Array[String] = []
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("run_test")
|
||||
|
||||
|
||||
func run_test() -> void:
|
||||
_cleanup()
|
||||
var shell = EntryShell.new()
|
||||
shell.auto_start = false
|
||||
shell.settings_store.path = SETTINGS_PATH
|
||||
root.add_child(shell)
|
||||
await process_frame
|
||||
shell.settings = shell.settings_store.defaults()
|
||||
shell.settings.setup_completed = true
|
||||
shell.settings.locale = "en"
|
||||
shell.show_title()
|
||||
shell.show_settings()
|
||||
await process_frame
|
||||
verify_categories(shell)
|
||||
verify_apply_discard_and_runtime(shell)
|
||||
verify_credits(shell)
|
||||
shell.queue_free()
|
||||
await process_frame
|
||||
_cleanup()
|
||||
if failures.is_empty():
|
||||
print("ABG_DEV1_SETTINGS_OK set=001,002,003,004,005,006 sys=008 persisted=true apply_discard=true caller=title unavailable_reasons=true audio_bus=true")
|
||||
quit(0)
|
||||
else:
|
||||
for failure in failures:
|
||||
push_error(failure)
|
||||
quit(1)
|
||||
|
||||
|
||||
func verify_categories(shell) -> void:
|
||||
for category in ["display", "motion", "audio", "controls", "language", "credits"]:
|
||||
shell.open_settings_category(category)
|
||||
expect(shell.get_node_or_null("SettingsSafeArea/SettingsOuter/SettingsWorkspace/SettingsScroll/SettingsContent") != null, "category %s opens" % category)
|
||||
shell.open_settings_category("audio")
|
||||
var content = shell.get_node("SettingsSafeArea/SettingsOuter/SettingsWorkspace/SettingsScroll/SettingsContent")
|
||||
expect(content.get_node("SettingAmbienceUnavailable").disabled and not content.get_node("SettingAmbienceUnavailable").tooltip_text.is_empty(), "absent ambience has a precise reason")
|
||||
expect(content.get_node("SettingVoiceUnavailable").disabled and not content.get_node("SettingVoiceUnavailable").tooltip_text.is_empty(), "absent voice has a precise reason")
|
||||
shell.open_settings_category("controls")
|
||||
content = shell.get_node("SettingsSafeArea/SettingsOuter/SettingsWorkspace/SettingsScroll/SettingsContent")
|
||||
expect(content.get_node("SettingRemapUnavailable").disabled and "later" in content.get_node("SettingRemapUnavailable").tooltip_text, "remapping names its later-page boundary")
|
||||
|
||||
|
||||
func verify_apply_discard_and_runtime(shell) -> void:
|
||||
shell.settings_category = "display"
|
||||
shell.settings_draft.safe_area = 48
|
||||
shell.settings_draft.text_scale = 1.3
|
||||
shell.settings_draft.brightness = 0.9
|
||||
shell.settings_draft.high_contrast = true
|
||||
shell.settings_draft.color_cues = false
|
||||
shell.settings_draft.reduced_motion = true
|
||||
shell.settings_draft.reduced_flashes = true
|
||||
shell.settings_draft.low_power = true
|
||||
shell.settings_draft.master_muted = true
|
||||
shell.settings_draft.music_volume = 0.4
|
||||
shell.settings_draft.sfx_volume = 0.5
|
||||
shell.settings_draft.captions = false
|
||||
shell.settings_draft.caption_detail = "full"
|
||||
shell.settings_draft.dynamic_range = "night"
|
||||
shell.settings_draft.hold_duration = 1.0
|
||||
shell.settings_draft.vibration = false
|
||||
shell.apply_settings()
|
||||
var loaded: Dictionary = shell.settings_store.load_settings()
|
||||
expect(loaded.ok and int(loaded.settings.safe_area) == 48 and is_equal_approx(float(loaded.settings.text_scale), 1.3), "display settings persist")
|
||||
expect(loaded.settings.reduced_motion and loaded.settings.reduced_flashes and loaded.settings.low_power, "motion settings persist")
|
||||
expect(loaded.settings.master_muted and not loaded.settings.captions and loaded.settings.dynamic_range == "night", "audio/caption settings persist")
|
||||
expect(is_equal_approx(float(loaded.settings.hold_duration), 1.0) and not loaded.settings.vibration, "control settings persist")
|
||||
expect(AudioServer.is_bus_mute(AudioServer.get_bus_index(&"Master")), "Master mute applies to the real audio bus")
|
||||
shell.settings_draft.safe_area = 0
|
||||
shell.request_settings_back()
|
||||
expect("Unsaved" in shell.settings_notice, "Back with changes requires Apply or Discard")
|
||||
shell.discard_settings()
|
||||
expect(shell.current_screen == "title" and int(shell.settings.safe_area) == 48, "Discard returns to exact caller without applying")
|
||||
shell.show_settings()
|
||||
|
||||
|
||||
func verify_credits(shell) -> void:
|
||||
shell.show_credits()
|
||||
var content = shell.get_node("SettingsSafeArea/SettingsOuter/SettingsWorkspace/SettingsScroll/SettingsContent")
|
||||
var combined := ""
|
||||
for child in content.get_children():
|
||||
if child is Label:
|
||||
combined += child.text
|
||||
expect("SIL Open Font License" in combined and "offline" in combined and "no analytics" in combined, "Credits states authorship, license, offline and privacy facts")
|
||||
shell.discard_settings()
|
||||
expect(shell.current_screen == "title", "Credits returns to Title")
|
||||
|
||||
|
||||
func _cleanup() -> void:
|
||||
for path in [SETTINGS_PATH, "%s.bak" % SETTINGS_PATH, "%s.candidate" % SETTINGS_PATH]:
|
||||
if FileAccess.file_exists(path):
|
||||
DirAccess.remove_absolute(path)
|
||||
|
||||
|
||||
func expect(condition: bool, message: String) -> void:
|
||||
if not condition:
|
||||
failures.append("DEV-1 Settings: %s" % message)
|
||||
Reference in New Issue
Block a user