feat(m76-c): wire runtime audio into the entry shell with cycle and entry gates
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
| 2026-09-13 | M60 可玩性真相(W1) | `e1cad068`/`dac5de40` | `m60-playthrough` `20260913T145904Z-38281` | runtime_verified | 34 步 0 阻断;视频与逐步截图 |
|
||||
| 2026-09-13 | M61 设计/密度(W2) | `310d2620` | `m61-five-profile` `20260913T162625Z-2172` | simulation_verified | decisions=330, max_gap=31.3s, 反支配/存档/可达通过 |
|
||||
| 2026-09-13 | M62 组件统一(W3) | `2e5540ed` | `m62-ink-baselines` `20260913T164335Z-38711` | runtime_verified | 组件库+矩阵+探针接入;基线 Guild 0 / Contract 1 / Readiness+Result 6 / Market 严格 0 |
|
||||
| 2026-09-14 | M76-C 音频接线(服务/总线/事件/音乐族)+ 卡内模块点击缺陷 | `feat(m76-c)`/`fix(m76-c)` | runtime_verified(待整机听感)| 144 事件、16 总线;全流程 34 步 0 阻断且音频门通过;修复市场卡无法点击 |
|
||||
| 2026-09-14 | M76-B SFX 全切片(144 事件 / 158 条)+ 音乐 7 床 | `feat(m76-b)` | machine_verified(待接线与听感)| 校验 0 错误;8 条静音失败件重生成通过;花费累计 ≈ $1.7 |
|
||||
| 2026-09-14 | M76-A 音频试听批(ElevenLabs;查明旧音频为本地合成占位) | `feat(m76-a)` `4efe4d2c`/`7f7ec58c` | runtime_pending(待人工听感)| 音乐 7 床 + SFX 23 候选;机器校验 0 错误;花费 ≈ $1.35(音乐 $0.15/min、音效 $0.12/min)|
|
||||
| 2026-09-14 | M75 停靠行边界(owner 反馈:返回公会/返回委托左右边界) | `fix(m75)` `9b37f912` | `m75-dock-bounds` | runtime_verified | 市场停靠行 x57..268 / 1049..1267、同高同基线;全页按钮四边审计;探针新增几何断言 |
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
2. **M76-B(COMPLETE)全切片生成**:SFX UI 24 + SHP 24 + EQP 20 + ORD 20 + RES 28 + RUN 28 = 144 条;
|
||||
音乐 7 个家族 base 床(TITLE/GUILD/SHOP/PREP/RUN/RESULT-WIN/RESULT-LOSS)各 60-92 BPM、60-90s、可循环。
|
||||
(BAT 60 与区域 ROUTE/BATTLE/BOSS 套件随战斗里程碑走。)
|
||||
3. **M76-C 接线**:Godot 音频总线 Master/Music/Ambience/SFX/Voice(合同 §8)、事件→音效映射、
|
||||
3. **M76-C(COMPLETE)接线**:Godot 音频总线 Master/Music/Ambience/SFX/Voice(合同 §8)、事件→音效映射、
|
||||
音乐状态切换(不重启整曲,按小节交叉)、音量/静音设置项接入设置页;替换 fg2/fg4 资产播放路径。
|
||||
4. **M76-D 门**:机器检查(`validate_audio.py`:格式/时长/静音/削波/循环缝)+ 运行时证据
|
||||
(各页面首次动作/失败/奖励/结算捕获)+ **人工听感**(音箱与耳机分开记)——三者不可互替。
|
||||
@@ -49,6 +49,15 @@
|
||||
- 音乐:7 个非战斗家族床已在 M76-A 生成并通过响度归一(-18 LUFS / TP -1.5)。
|
||||
- 花费累计 ≈ **$1.7**(音乐 $1.31 + 音效 ≈ $0.4)。
|
||||
|
||||
## M76-C 产出(2026-09-14)
|
||||
|
||||
- **总线**:按合同 §8 铺满 Master→Music(MusicBed/MusicLayer)、Ambience(3 子)、SFX(SFXCritical/SFXPlayerCommit/SFXCombat/SFXWorld/SFXUI)、Voice、Accessibility(16 条总线)。
|
||||
- **音频服务** `runtime/presentation/audio_service.gd`:144 事件映射(bus/优先级/冷却)、音乐族交叉淡化(同族不重启)、静音时语义事件仍入账(供字幕/日志)、日志与计数器供测试。
|
||||
- **接线**:53 处——每页 `_audio_enter(page, family)`(page_open + 音乐族)+ 22 个玩家提交动作 `_audio_sfx(...)` + 战斗结算按胜负选族与胜利/失败音。
|
||||
- **机器门**:`audio_service_test`(144 事件/9 总线/冷却/优先级/静音/同族不重启)、DEV-2 入口音频断言 `ABG_M76_AUDIO_ENTRY_OK`、全流程驱动 `ABG_M76_AUDIO_CYCLE_OK`(34 步 0 阻断;families=10 page_open=35 events=55)。
|
||||
- **接线暴露并修复真缺陷**:市场招募卡的 `IdentityModule` 等模块根节点默认 `MOUSE_FILTER_STOP`,**吃掉卡片点击 → 新开局无法选卡/招募**(全流程驱动此前在 hire 步骤阻断)。已修并写入共享 UI 规则。
|
||||
- **BAT 60 条与区域/BOSS 音乐**仍随战斗里程碑(清单里显式列为 deferred)。
|
||||
|
||||
## Acceptance checks
|
||||
|
||||
- 试听批:Owner 听过并认可方向(或给出反例修订)
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
| `Tokens.seal_style(color)`(M66) | 彩色小徽记:页面给语义色,边框/圆角/线宽共享 | 风险事实图标、风险身份标记 |
|
||||
| `Tokens.hit_area_style(state)`(M66) | 透明命中反馈:normal 微海军蓝、hover 金、pressed/focus 天蓝 | 纸质卡片的悬停/按压/焦点反馈 |
|
||||
| `Tokens.font_size("caption")` = 8(M68 收口) | 窄卡面(市场招募卡姓名/特质芯片)的合法降档字号;宽槽位仍用 `micro` | 招募卡姓名、特质芯片 |
|
||||
| 卡内模块的鼠标过滤(M76-C) | 卡片本身是 Button 时,卡内所有模块根节点必须 `mouse_filter = IGNORE`(含 identity/trait/cost/profession/portrait/guild_header)。示例缺陷:`IdentityModule` 默认 STOP 吃掉点击 → 新开局的招募卡完全点不动 | 卡片类视图(market 卡/详情栏/公会卡)|
|
||||
| 运行时音频接线(M76-C) | 页面进入 = `_audio_enter(page, family)`(page_open + 音乐族);玩家提交动作 = `_audio_sfx("事件名")`(合同 §8 事件名)+ 动作函数首行;服务在 shell 宿主节点上(页面重建会清空 shell 子节点)| entry shell 全页 |
|
||||
| 停靠行边界(M75) | 运行时自绘的命令按钮必须对齐页面自身栅格(左/右线与同页其他元素共享),同排同高(±2px)同基线(±2px);贴附绘制美术角牌/底带的按钮可跟随美术,但必须确认美术确有该牌面 | market 探针断言 `ABG_M52_MARKET_DOCK_BOUNDS_OK`(back 57..268 / return 1049..1267)|
|
||||
| 命令按钮尺度(M74) | 所有玩家可见命令按钮用 `UITokens.command_height/size`:primary 52 / 其余 48;实拍容差 ±8px(缩放/边距)。页脚条=牌面内的 ~59px 行,而非大板。卡片与大命中区不受此限;触控目标 ≥48×48 | 所有页面实渲染审计(market/guild/party/risk/contract/result/roster)|
|
||||
| 130% 文本排版(M73) | 无障碍放大档下:卡片/详情栏把头像高度让给文字行(不缩字号);成本条的图标/可用性/金额三列重分;页脚与徽章把图标列让给标签;区块标题允许两行。所有槽位保留 ≥6% 余量(曾因 0.4px 差裁掉一个汉字) | 所有现行页面 × `text_scale=1.3`;探针 1.0+1.3 双档严格覆盖 |
|
||||
|
||||
@@ -2,6 +2,7 @@ class_name ABGEntryShell
|
||||
extends Control
|
||||
|
||||
const BootService = preload("res://entry/boot_service.gd")
|
||||
const AudioServiceScript = preload("res://presentation/audio_service.gd")
|
||||
const SettingsServiceScript = preload("res://foundation/settings_service.gd")
|
||||
const AppServicesScript = preload("res://foundation/app_services.gd")
|
||||
const UIFactory = preload("res://ui/shared/ui_factory.gd")
|
||||
@@ -274,6 +275,10 @@ func _notification(what: int) -> void:
|
||||
call_deferred("_battle_live_interrupt", "application_paused" if what == NOTIFICATION_APPLICATION_PAUSED else "focus_lost")
|
||||
|
||||
|
||||
var audio_service: ABGAudioService
|
||||
var audio_page_id := ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
app_services.register_service(&"guild_page_controller", guild_page_controller)
|
||||
@@ -296,6 +301,38 @@ func _ready() -> void:
|
||||
call_deferred("start_boot")
|
||||
|
||||
|
||||
func _ensure_audio_service() -> void:
|
||||
if audio_service != null and is_instance_valid(audio_service):
|
||||
return
|
||||
var service: Node = AudioServiceScript.new()
|
||||
service.name = "AudioService"
|
||||
audio_service = service
|
||||
# Pages rebuild by freeing every shell child, so the audio service lives on
|
||||
# the shell's host node instead of the rebuilt subtree.
|
||||
var host: Node = get_parent()
|
||||
if host == null:
|
||||
host = get_tree().root if is_inside_tree() else null
|
||||
if host != null:
|
||||
host.add_child(service)
|
||||
else:
|
||||
add_child(service)
|
||||
|
||||
|
||||
func _audio_enter(page_id: String, family := "") -> void:
|
||||
_ensure_audio_service()
|
||||
if audio_service == null:
|
||||
return
|
||||
audio_page_id = page_id
|
||||
if not family.is_empty():
|
||||
audio_service.set_music(family)
|
||||
audio_service.play_sfx("page_open")
|
||||
|
||||
|
||||
func _audio_sfx(event_name: String) -> void:
|
||||
_ensure_audio_service()
|
||||
if audio_service != null:
|
||||
audio_service.play_sfx(event_name)
|
||||
|
||||
func start_boot() -> void:
|
||||
boot_generation += 1
|
||||
boot_diagnostics_expanded = false
|
||||
@@ -320,6 +357,7 @@ func retry_boot() -> void:
|
||||
|
||||
|
||||
func show_boot_diagnostics() -> void:
|
||||
_audio_enter("boot", "title")
|
||||
if String(boot_snapshot.get("state", "")) != "error":
|
||||
return
|
||||
boot_diagnostics_expanded = true
|
||||
@@ -699,6 +737,7 @@ func _open_after_boot() -> void:
|
||||
|
||||
|
||||
func show_first_launch() -> void:
|
||||
_audio_enter("setup", "title")
|
||||
setup_draft = settings.duplicate(true) if not settings.is_empty() else settings_service.defaults()
|
||||
for child in get_children():
|
||||
child.free()
|
||||
@@ -1132,6 +1171,7 @@ func apply_first_launch() -> void:
|
||||
|
||||
|
||||
func show_title() -> void:
|
||||
_audio_enter("title", "title")
|
||||
current_screen = "title"
|
||||
title_master_design_canvas = null
|
||||
for child in get_children():
|
||||
@@ -1333,6 +1373,7 @@ func open_new_game_boundary() -> void:
|
||||
|
||||
|
||||
func show_initial_company() -> void:
|
||||
_audio_enter("initial_company", "title")
|
||||
current_screen = "initial_company"
|
||||
for child in get_children():
|
||||
child.free()
|
||||
@@ -1340,7 +1381,7 @@ func show_initial_company() -> void:
|
||||
initial_company_page.name = "InitialCompanyPage"
|
||||
initial_company_page.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
initial_company_page.back_requested.connect(back_to_title, CONNECT_DEFERRED)
|
||||
initial_company_page.company_committed.connect(show_guild_handoff, CONNECT_DEFERRED)
|
||||
initial_company_page.company_committed.connect(_on_company_committed, CONNECT_DEFERRED)
|
||||
add_child(initial_company_page)
|
||||
initial_company_page.open(initial_company_service, settings)
|
||||
|
||||
@@ -1357,6 +1398,11 @@ func open_continue_boundary() -> void:
|
||||
show_title()
|
||||
|
||||
|
||||
func _on_company_committed(company: Dictionary) -> void:
|
||||
_audio_sfx("recruit_hire_commit")
|
||||
show_guild_handoff(company)
|
||||
|
||||
|
||||
func _open_company_destination(company: Dictionary) -> void:
|
||||
if company.has("active_contract") and not company.active_contract.is_empty():
|
||||
if company.active_contract.has("battle_state") and not company.active_contract.battle_state.is_empty():
|
||||
@@ -1389,6 +1435,7 @@ func _open_company_destination(company: Dictionary) -> void:
|
||||
|
||||
|
||||
func show_guild_handoff(company := {}) -> void:
|
||||
_audio_enter("guild_handoff", "guild")
|
||||
var resolved: Dictionary = Dictionary(company).duplicate(true) if company is Dictionary else {}
|
||||
if resolved.is_empty():
|
||||
var loaded := initial_company_service.load_company()
|
||||
@@ -1410,6 +1457,7 @@ func show_guild_handoff(company := {}) -> void:
|
||||
|
||||
|
||||
func show_guild_anchor(company: Dictionary) -> void:
|
||||
_audio_enter("guild", "guild")
|
||||
var resolved: Dictionary = Dictionary(company).duplicate(true)
|
||||
var view_data: Dictionary = guild_page_controller.snapshot(resolved, String(settings.get("locale", "zh_CN")))
|
||||
if not bool(view_data.get("ok", false)):
|
||||
@@ -1798,6 +1846,7 @@ func _show_guild_master_composite_legacy(company: Dictionary) -> void:
|
||||
|
||||
|
||||
func show_roster(company := {}) -> void:
|
||||
_audio_enter("roster", "guild")
|
||||
var resolved: Dictionary = Dictionary(company).duplicate(true) if company is Dictionary else guild_company.duplicate(true)
|
||||
if resolved.is_empty():
|
||||
var loaded := initial_company_service.load_company()
|
||||
@@ -1848,6 +1897,7 @@ func _on_company_roster_view_intent(intent_id: String, payload: Dictionary) -> v
|
||||
|
||||
|
||||
func show_recruit_detail(recruit_id: String) -> void:
|
||||
_audio_enter("recruit_detail", "guild")
|
||||
var loaded: Dictionary = initial_company_service.load_company()
|
||||
if not loaded.ok:
|
||||
show_title()
|
||||
@@ -1910,6 +1960,7 @@ func _prepare_company_page_view_data(source: Dictionary) -> Dictionary:
|
||||
|
||||
|
||||
func open_dismissal_review(recruit_id: String) -> void:
|
||||
_audio_sfx("dismiss_arm")
|
||||
var loaded := initial_company_service.load_company()
|
||||
if not loaded.ok:
|
||||
show_title()
|
||||
@@ -2012,6 +2063,7 @@ func cancel_dismissal_review() -> void:
|
||||
|
||||
|
||||
func commit_dismissal() -> void:
|
||||
_audio_sfx("dismiss_commit")
|
||||
if dismissal_recruit_id.is_empty():
|
||||
return
|
||||
guild_contract_service.company_path = initial_company_service.company_path
|
||||
@@ -2030,6 +2082,7 @@ func commit_dismissal() -> void:
|
||||
|
||||
|
||||
func open_contract_return_review() -> void:
|
||||
_audio_sfx("run_end_voluntary")
|
||||
var loaded := initial_company_service.load_company()
|
||||
if not loaded.ok:
|
||||
show_title()
|
||||
@@ -2153,6 +2206,7 @@ func cancel_contract_return() -> void:
|
||||
|
||||
|
||||
func commit_contract_return() -> void:
|
||||
_audio_sfx("run_end_voluntary")
|
||||
guild_contract_service.company_path = initial_company_service.company_path
|
||||
var operation_id := ("%s|return-contract|%s" % [String(guild_company.get("company_id", "")), String(guild_company.get("active_contract", {}).get("run_id", ""))]).sha256_text().substr(0, 32)
|
||||
var result := guild_contract_service.return_contract(operation_id)
|
||||
@@ -2166,6 +2220,7 @@ func commit_contract_return() -> void:
|
||||
|
||||
|
||||
func show_contract_choice() -> void:
|
||||
_audio_enter("contract_choice", "prep")
|
||||
var loaded := initial_company_service.load_company()
|
||||
if not loaded.ok:
|
||||
contract_notice = _tr("无法读取远征团。", "The Company could not be loaded.") + " [%s]" % String(loaded.code)
|
||||
@@ -2219,6 +2274,7 @@ func _on_contract_choice_view_intent(intent_id: String, payload: Dictionary) ->
|
||||
|
||||
|
||||
func select_contract_difficulty(value: String) -> void:
|
||||
_audio_sfx("difficulty_change_review")
|
||||
if not contract_choice_page_controller.is_valid_difficulty(value):
|
||||
return
|
||||
contract_difficulty = contract_choice_page_controller.normalize_difficulty(value)
|
||||
@@ -2227,6 +2283,7 @@ func select_contract_difficulty(value: String) -> void:
|
||||
|
||||
|
||||
func confirm_contract_choice() -> void:
|
||||
_audio_sfx("confirm_commit")
|
||||
var confirm_state: Dictionary = contract_choice_page_controller.confirm_state(guild_company, contract_difficulty)
|
||||
if not bool(confirm_state.get("eligible", false)):
|
||||
contract_notice = _contract_choice_guard_text(String(confirm_state.get("reason", "confirm_blocked")))
|
||||
@@ -2245,10 +2302,12 @@ func confirm_contract_choice() -> void:
|
||||
|
||||
|
||||
func show_market_handoff(company := {}) -> void:
|
||||
_audio_enter("market_handoff", "market")
|
||||
show_market(company)
|
||||
|
||||
|
||||
func show_market(company := {}) -> void:
|
||||
_audio_enter("market", "market")
|
||||
var resolved: Dictionary = Dictionary(company).duplicate(true) if company is Dictionary else {}
|
||||
if resolved.is_empty():
|
||||
var loaded := initial_company_service.load_company()
|
||||
@@ -2331,6 +2390,7 @@ func open_party_line() -> void:
|
||||
|
||||
|
||||
func show_party_line(company := {}) -> void:
|
||||
_audio_enter("party_line", "prep")
|
||||
formation_risk_service.company_path = initial_company_service.company_path
|
||||
readiness_view_data = {}
|
||||
var begun: Dictionary = formation_risk_service.begin_formation()
|
||||
@@ -2402,6 +2462,7 @@ func _on_party_line_view_intent(intent_id: String, payload: Dictionary) -> void:
|
||||
|
||||
|
||||
func select_party_member(recruit_id: String) -> void:
|
||||
_audio_sfx("unit_select")
|
||||
var position := party_draft_order.find(recruit_id)
|
||||
if position < 0:
|
||||
party_notice = _tr("该成员已不在当前队列。", "That member is no longer in the current line.")
|
||||
@@ -2441,6 +2502,7 @@ func undo_party_swap() -> void:
|
||||
|
||||
|
||||
func reset_party_order() -> void:
|
||||
_audio_sfx("reorder_cancel")
|
||||
formation_risk_service.company_path = initial_company_service.company_path
|
||||
var reset: Dictionary = formation_risk_service.reset_order()
|
||||
if not reset.ok:
|
||||
@@ -2465,6 +2527,7 @@ func cancel_party_line() -> void:
|
||||
|
||||
|
||||
func save_party_order() -> void:
|
||||
_audio_sfx("reorder_commit")
|
||||
formation_risk_service.company_path = initial_company_service.company_path
|
||||
var order_hash := JSON.stringify(_canonical_value(party_draft_order)).sha256_text()
|
||||
var operation_id := ("%s|save-party-order|%s" % [String(guild_company.company_id), order_hash]).sha256_text().substr(0, 32)
|
||||
@@ -2479,6 +2542,7 @@ func save_party_order() -> void:
|
||||
|
||||
|
||||
func show_readiness_review(company := {}) -> void:
|
||||
_audio_enter("readiness_review", "prep")
|
||||
formation_risk_service.company_path = initial_company_service.company_path
|
||||
var loaded: Dictionary = formation_risk_service.load_company()
|
||||
if not loaded.ok:
|
||||
@@ -2594,6 +2658,7 @@ func revise_readiness() -> void:
|
||||
|
||||
|
||||
func accept_readiness() -> void:
|
||||
_audio_sfx("ready_check_pass")
|
||||
formation_risk_service.company_path = initial_company_service.company_path
|
||||
var formation: Dictionary = guild_company.active_contract.formation
|
||||
var order_hash := JSON.stringify(_canonical_value(formation.saved_front_to_rear_ids)).sha256_text()
|
||||
@@ -2612,6 +2677,7 @@ func open_risk_board() -> void:
|
||||
|
||||
|
||||
func show_risk_board(company := {}) -> void:
|
||||
_audio_enter("risk_board", "run")
|
||||
formation_risk_service.company_path = initial_company_service.company_path
|
||||
var loaded: Dictionary = formation_risk_service.load_company()
|
||||
if not loaded.ok:
|
||||
@@ -2677,11 +2743,13 @@ func _risk_open_settings() -> void:
|
||||
|
||||
|
||||
func select_risk_option(option_id: String) -> void:
|
||||
_audio_sfx("risk_option_focus")
|
||||
risk_selected_id = option_id
|
||||
show_risk_board(guild_company)
|
||||
|
||||
|
||||
func open_risk_commitment() -> void:
|
||||
_audio_sfx("risk_commit")
|
||||
if risk_selected_id.is_empty():
|
||||
show_risk_board(guild_company)
|
||||
return
|
||||
@@ -2689,6 +2757,7 @@ func open_risk_commitment() -> void:
|
||||
|
||||
|
||||
func show_risk_commitment(company := {}) -> void:
|
||||
_audio_enter("risk_commitment", "run")
|
||||
formation_risk_service.company_path = initial_company_service.company_path
|
||||
var loaded: Dictionary = formation_risk_service.load_company()
|
||||
if not loaded.ok:
|
||||
@@ -2887,6 +2956,7 @@ func review_risk_commitment_consequences() -> void:
|
||||
|
||||
|
||||
func toggle_risk_commitment_confirmation() -> void:
|
||||
_audio_sfx("confirm_arm")
|
||||
risk_commitment_acknowledged = not risk_commitment_acknowledged
|
||||
risk_commitment_notice = _tr("已确认六条后果;现在可以进入战斗开场。", "Six consequences acknowledged; Battle Opening is now available.") if risk_commitment_acknowledged else _tr("确认已撤回;不会创建承诺回执。", "Acknowledgement withdrawn; no commitment receipt will be created.")
|
||||
show_risk_commitment(guild_company)
|
||||
@@ -2904,6 +2974,7 @@ func cancel_risk_commitment() -> void:
|
||||
|
||||
|
||||
func begin_battle() -> void:
|
||||
_audio_sfx("battle_start_commit")
|
||||
if risk_selected_id.is_empty():
|
||||
show_risk_board(guild_company)
|
||||
return
|
||||
@@ -2948,6 +3019,7 @@ func begin_battle() -> void:
|
||||
|
||||
|
||||
func show_battle_opening(company := {}, auto_focus := true) -> void:
|
||||
_audio_enter("battle_opening", "run")
|
||||
_clear_battle_playback_timer()
|
||||
battle_playback_generation += 1
|
||||
battle_opening_mode = true
|
||||
@@ -3484,6 +3556,7 @@ func _battle_receipt_for_company(company: Dictionary, battle: Dictionary) -> Dic
|
||||
|
||||
|
||||
func show_battle(company := {}, auto_play := false, resume_requires_review := false) -> void:
|
||||
_audio_enter("battle", "run")
|
||||
battle_opening_mode = false
|
||||
battle_opening_state = ""
|
||||
battle_opening_handoff_receipt = {}
|
||||
@@ -4906,6 +4979,11 @@ func cycle_battle_speed() -> void:
|
||||
|
||||
|
||||
func show_battle_result(company := {}) -> void:
|
||||
var audio_resolved: Dictionary = Dictionary(company).duplicate(true) if company is Dictionary else guild_company.duplicate(true)
|
||||
var audio_outcome := String(Dictionary(Dictionary(audio_resolved.get("active_contract", {})).get("battle_state", {})).get("result", {}).get("outcome", "victory"))
|
||||
var audio_family := "result_win" if audio_outcome == "victory" else "result_loss"
|
||||
_audio_enter("battle_result", audio_family)
|
||||
_audio_sfx("battle_victory" if audio_outcome == "victory" else "battle_defeat")
|
||||
var resolved: Dictionary = Dictionary(company).duplicate(true) if company is Dictionary else guild_company.duplicate(true)
|
||||
guild_company = resolved
|
||||
current_screen = "battle_result"
|
||||
@@ -4968,6 +5046,7 @@ func toggle_battle_result_diagnosis() -> void:
|
||||
|
||||
|
||||
func continue_from_battle_result() -> void:
|
||||
_audio_sfx("run_continue")
|
||||
var view_data: Dictionary = battle_result_view_data
|
||||
if view_data.is_empty():
|
||||
var battle: Dictionary = guild_company.get("active_contract", {}).get("battle_state", {})
|
||||
@@ -4981,6 +5060,7 @@ func continue_from_battle_result() -> void:
|
||||
|
||||
|
||||
func show_battle_knockout_review(company := {}) -> void:
|
||||
_audio_enter("battle_knockout_review", "result_loss")
|
||||
var resolved: Dictionary = Dictionary(company).duplicate(true) if company is Dictionary else guild_company.duplicate(true)
|
||||
guild_company = resolved
|
||||
current_screen = "battle_knockout_review"
|
||||
@@ -5065,6 +5145,7 @@ func acknowledge_battle_knockout(company := {}) -> void:
|
||||
|
||||
|
||||
func show_battle_reward_choice(company := {}) -> void:
|
||||
_audio_enter("battle_reward_choice", "result_win")
|
||||
var resolved: Dictionary = Dictionary(company).duplicate(true) if company is Dictionary else guild_company.duplicate(true)
|
||||
var battle: Dictionary = resolved.get("active_contract", {}).get("battle_state", {})
|
||||
var draft: Dictionary = Dictionary(battle.get("reward_draft", {}))
|
||||
@@ -5153,6 +5234,7 @@ func _refresh_battle_reward_view_data(company: Dictionary, battle: Dictionary, s
|
||||
|
||||
|
||||
func select_battle_reward(reward_id: String) -> void:
|
||||
_audio_sfx("reward_option_focus")
|
||||
var battle: Dictionary = guild_company.get("active_contract", {}).get("battle_state", {})
|
||||
var draft: Dictionary = battle.get("reward_draft", {})
|
||||
var candidate: Dictionary = reward_choice_page_controller.snapshot(
|
||||
@@ -5171,6 +5253,7 @@ func select_battle_reward(reward_id: String) -> void:
|
||||
|
||||
|
||||
func commit_battle_reward() -> void:
|
||||
_audio_sfx("reward_accept")
|
||||
if battle_reward_selected_id.is_empty():
|
||||
battle_reward_notice = _tr("请先选择一个奖励。", "Select a reward first.")
|
||||
show_battle_reward_choice(guild_company)
|
||||
@@ -5240,6 +5323,7 @@ func _battle_reward_option_detail(option: Dictionary) -> String:
|
||||
|
||||
|
||||
func show_battle_recovery(company := {}) -> void:
|
||||
_audio_enter("battle_recovery", "result_loss")
|
||||
var resolved: Dictionary = Dictionary(company).duplicate(true) if company is Dictionary else guild_company.duplicate(true)
|
||||
guild_company = resolved
|
||||
current_screen = "battle_recovery"
|
||||
@@ -5297,6 +5381,7 @@ func _refresh_battle_recovery_view_data(company: Dictionary, battle: Dictionary)
|
||||
|
||||
|
||||
func commit_battle_recovery() -> void:
|
||||
_audio_sfx("recovery_option_open")
|
||||
var current_battle: Dictionary = guild_company.get("active_contract", {}).get("battle_state", {})
|
||||
var view_data: Dictionary = battle_recovery_view_data
|
||||
if view_data.is_empty():
|
||||
@@ -5332,6 +5417,7 @@ func set_market_category(value: String) -> void:
|
||||
|
||||
|
||||
func select_market_offer(kind: String, offer_id: String) -> void:
|
||||
_audio_sfx("offer_reveal")
|
||||
var selection: Dictionary = market_page_controller.select_offer(guild_company, kind, offer_id)
|
||||
if not selection.get("ok", false):
|
||||
market_notice = _tr("该货单条目已不可用。", "That ledger entry is no longer available.")
|
||||
@@ -5343,6 +5429,7 @@ func select_market_offer(kind: String, offer_id: String) -> void:
|
||||
|
||||
|
||||
func open_recruit_review() -> void:
|
||||
_audio_sfx("recruit_hire_review")
|
||||
var selection: Dictionary = market_page_controller.select_offer(guild_company, market_selected_kind, market_selected_offer_id)
|
||||
if not selection.get("ok", false) or String(selection.get("review", {}).get("action", "")) != "recruit_review":
|
||||
market_notice = _tr("请先选择一名招募候选。", "Select a Recruit offer first.")
|
||||
@@ -5352,6 +5439,7 @@ func open_recruit_review() -> void:
|
||||
|
||||
|
||||
func open_equipment_review() -> void:
|
||||
_audio_sfx("equip_review")
|
||||
var selection: Dictionary = market_page_controller.select_offer(guild_company, market_selected_kind, market_selected_offer_id)
|
||||
if not selection.get("ok", false) or String(selection.get("review", {}).get("action", "")) != "equipment_review":
|
||||
market_notice = _tr("请先选择一件装备。", "Select an equipment offer first.")
|
||||
@@ -5361,6 +5449,7 @@ func open_equipment_review() -> void:
|
||||
|
||||
|
||||
func show_equipment_review(offer_id: String) -> void:
|
||||
_audio_enter("equipment_review", "market")
|
||||
var loaded: Dictionary = initial_company_service.load_company()
|
||||
if not loaded.ok or loaded.company.active_contract.is_empty():
|
||||
market_notice = _tr("无法读取稳定装备货单。", "The stable Equipment ledger could not be loaded.")
|
||||
@@ -5460,6 +5549,7 @@ func cancel_equipment_review() -> void:
|
||||
|
||||
|
||||
func purchase_selected_equipment(recruit_id: String) -> void:
|
||||
_audio_sfx("equip_commit")
|
||||
if market_selected_kind != "equipment" or market_selected_offer_id.is_empty():
|
||||
market_notice = _tr("没有可提交的装备候选。", "No equipment offer is ready to commit.")
|
||||
show_market(guild_company)
|
||||
@@ -5484,6 +5574,7 @@ func purchase_selected_equipment(recruit_id: String) -> void:
|
||||
|
||||
|
||||
func show_recruit_review(offer_id: String) -> void:
|
||||
_audio_enter("recruit_review", "market")
|
||||
var loaded := initial_company_service.load_company()
|
||||
if not loaded.ok or loaded.company.active_contract.is_empty():
|
||||
market_notice = _tr("无法读取稳定货单。", "The stable Market ledger could not be loaded.")
|
||||
@@ -5549,6 +5640,7 @@ func cancel_recruit_review() -> void:
|
||||
|
||||
|
||||
func hire_selected_recruit() -> void:
|
||||
_audio_sfx("recruit_hire_commit")
|
||||
if market_selected_kind != "recruit" or market_selected_offer_id.is_empty():
|
||||
market_notice = _tr("没有可提交的招募候选。", "No Recruit offer is ready to commit.")
|
||||
show_market(guild_company)
|
||||
@@ -6976,11 +7068,13 @@ func _set_guild_notice(value: String) -> void:
|
||||
|
||||
|
||||
func show_settings_from_guild() -> void:
|
||||
_audio_enter("settings", "")
|
||||
settings_caller = "guild_handoff"
|
||||
show_settings()
|
||||
|
||||
|
||||
func show_settings_placeholder() -> void:
|
||||
_audio_enter("settings", "")
|
||||
settings_caller = "title"
|
||||
show_settings()
|
||||
|
||||
@@ -7053,6 +7147,7 @@ func _restore_settings_focus(focus_name: String) -> void:
|
||||
|
||||
|
||||
func show_settings(category := "") -> void:
|
||||
_audio_enter("settings", "")
|
||||
if settings_draft.is_empty() or not category.is_empty():
|
||||
settings_draft = settings.duplicate(true)
|
||||
if not category.is_empty():
|
||||
@@ -7266,6 +7361,7 @@ func apply_settings() -> void:
|
||||
|
||||
|
||||
func show_credits() -> void:
|
||||
_audio_enter("credits", "")
|
||||
settings_draft = settings.duplicate(true)
|
||||
settings_category = "credits"
|
||||
show_settings("credits")
|
||||
@@ -7279,6 +7375,9 @@ func _credits_text() -> String:
|
||||
|
||||
|
||||
func _apply_runtime_settings() -> void:
|
||||
_ensure_audio_service()
|
||||
if audio_service != null:
|
||||
audio_service.apply_settings(settings)
|
||||
var master := AudioServer.get_bus_index(&"Master")
|
||||
var music := AudioServer.get_bus_index(&"Music")
|
||||
var sfx := AudioServer.get_bus_index(&"SFX")
|
||||
@@ -7384,6 +7483,7 @@ func _unavailable_row(node_name: String, reason: String) -> Button:
|
||||
|
||||
|
||||
func show_unavailable_reason(reason: String) -> void:
|
||||
_audio_enter("unavailable", "")
|
||||
settings_notice = reason
|
||||
show_settings()
|
||||
|
||||
|
||||
@@ -58,6 +58,25 @@ func run_test() -> void:
|
||||
await _touch(page.find_child("CreateCompany", true, false))
|
||||
expect(restarted_shell.current_screen == "guild_handoff", "Create Company reaches the bounded Guild handoff")
|
||||
expect(restarted_shell.find_child("GuildRoster", true, false).get_child_count() == 2, "Guild handoff shows the persistent pair")
|
||||
var audio: Node = restarted_shell.audio_service
|
||||
expect(audio != null, "runtime audio service is attached to the shell")
|
||||
if audio != null:
|
||||
expect(int(audio.events.size()) == 144, "audio manifest maps the 144 contract events")
|
||||
var families: Array = []
|
||||
var page_opens := 0
|
||||
var commits := 0
|
||||
for record in audio.journal:
|
||||
if String(record.get("kind", "")) == "music":
|
||||
families.append(String(record.get("name", "")))
|
||||
if String(record.get("kind", "")) == "sfx" and String(record.get("name", "")) == "page_open":
|
||||
page_opens += 1
|
||||
if String(record.get("kind", "")) == "sfx" and String(record.get("name", "")) == "recruit_hire_commit" and String(record.get("suppressed", "")) == "":
|
||||
commits += 1
|
||||
expect(families.has("title") and families.has("guild"), "page families switch from title to guild, got %s" % str(families))
|
||||
expect(int(audio.music_switches) >= 2, "music family switches are counted")
|
||||
expect(page_opens >= 3, "page_open cue fires on page entry, got %d" % page_opens)
|
||||
expect(commits >= 1, "create-company dispatches the hire commit cue")
|
||||
print("ABG_M76_AUDIO_ENTRY_OK families=%d page_open=%d commits=%d switches=%d events=%d" % [families.size(), page_opens, commits, int(audio.music_switches), int(audio.events.size())])
|
||||
precommit_restart.queue_free()
|
||||
await _frames(20)
|
||||
|
||||
@@ -68,6 +87,10 @@ func run_test() -> void:
|
||||
var committed_roster := await _wait_for_node(committed_restart.entry_shell, "GuildRoster")
|
||||
expect(committed_roster != null and committed_restart.entry_shell.current_screen == "guild_handoff", "post-commit restart resumes directly at Guild")
|
||||
expect(committed_roster != null and committed_roster.get_child_count() == 2, "post-commit Guild retains exactly two members")
|
||||
var committed_audio: Node = committed_restart.entry_shell.audio_service
|
||||
expect(committed_audio != null, "runtime audio service survives page rebuilds")
|
||||
if committed_audio != null:
|
||||
expect(int(committed_audio.events.size()) == 144, "audio manifest maps the 144 contract events")
|
||||
committed_restart.queue_free()
|
||||
await _frames(20)
|
||||
_cleanup()
|
||||
|
||||
@@ -431,6 +431,9 @@ func _finish(code: int) -> void:
|
||||
])
|
||||
if code == 0 and blocked == 0:
|
||||
print("ABG_M60_PLAYTHROUGH_OK boot_to_recovery=true steps=%d touches=%d" % [timeline.size(), parsed_touches])
|
||||
var audio_ok := _check_audio()
|
||||
if code == 0 and blocked == 0 and not audio_ok:
|
||||
code = 1
|
||||
# Free the driven scene before quitting so the strict run sees no leaked
|
||||
# ObjectDB instances.
|
||||
if is_instance_valid(game_node):
|
||||
@@ -451,3 +454,40 @@ func _cleanup_state() -> void:
|
||||
for path in paths:
|
||||
if FileAccess.file_exists(path):
|
||||
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))
|
||||
|
||||
func _check_audio() -> bool:
|
||||
# M76-C gate: the driven cycle must switch music families and dispatch the
|
||||
# semantic cues for its own committed actions.
|
||||
if shell == null or not is_instance_valid(shell) or shell.audio_service == null:
|
||||
push_error("M76-C audio: shell has no audio service")
|
||||
return false
|
||||
var service = shell.audio_service
|
||||
if int(service.events.size()) != 144:
|
||||
push_error("M76-C audio: expected 144 mapped events, got %d" % int(service.events.size()))
|
||||
return false
|
||||
var families: Array = []
|
||||
var page_opens := 0
|
||||
var committed: Array = []
|
||||
for record in service.journal:
|
||||
if String(record.get("kind", "")) == "music":
|
||||
families.append(String(record.get("name", "")))
|
||||
if String(record.get("kind", "")) == "sfx":
|
||||
if String(record.get("name", "")) == "page_open":
|
||||
page_opens += 1
|
||||
if String(record.get("suppressed", "")) == "":
|
||||
committed.append(String(record.get("name", "")))
|
||||
var required_families := ["title", "guild", "market", "prep", "run"]
|
||||
var missing_families: Array = []
|
||||
for family in required_families:
|
||||
if not families.has(family):
|
||||
missing_families.append(family)
|
||||
var required_events := ["recruit_hire_commit", "risk_commit", "battle_start_commit", "reward_accept"]
|
||||
var missing_events: Array = []
|
||||
for event_name in required_events:
|
||||
if not committed.has(event_name):
|
||||
missing_events.append(event_name)
|
||||
if not missing_families.is_empty() or not missing_events.is_empty() or page_opens < 8:
|
||||
push_error("M76-C audio: missing families=%s events=%s page_opens=%d" % [str(missing_families), str(missing_events), page_opens])
|
||||
return false
|
||||
print("ABG_M76_AUDIO_CYCLE_OK families=%d page_open=%d events=%d switches=%d" % [families.size(), page_opens, committed.size(), int(service.music_switches)])
|
||||
return true
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env python3
|
||||
"""M76-C wiring pass: connect the runtime audio service to the entry shell.
|
||||
|
||||
Adds (once, idempotently):
|
||||
* service creation + helpers in `_ready`/`_apply_runtime_settings`;
|
||||
* a `_audio_enter(page, family)` call as the first statement of each page
|
||||
`show_*` function (page_open cue + music family switch);
|
||||
* a `_audio_sfx("<event>")` call at the first statement of each semantic
|
||||
player-commit action function.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SHELL = ROOT / "runtime/entry/entry_shell.gd"
|
||||
|
||||
PAGES: dict[str, tuple[str, str]] = {
|
||||
"show_boot_diagnostics": ("boot", "title"),
|
||||
"show_first_launch": ("setup", "title"),
|
||||
"show_title": ("title", "title"),
|
||||
"show_initial_company": ("initial_company", "title"),
|
||||
"show_guild_handoff": ("guild_handoff", "guild"),
|
||||
"show_guild_anchor": ("guild", "guild"),
|
||||
"show_roster": ("roster", "guild"),
|
||||
"show_recruit_detail": ("recruit_detail", "guild"),
|
||||
"show_contract_choice": ("contract_choice", "prep"),
|
||||
"show_market_handoff": ("market_handoff", "market"),
|
||||
"show_market": ("market", "market"),
|
||||
"show_recruit_review": ("recruit_review", "market"),
|
||||
"show_equipment_review": ("equipment_review", "market"),
|
||||
"show_party_line": ("party_line", "prep"),
|
||||
"show_readiness_review": ("readiness_review", "prep"),
|
||||
"show_risk_board": ("risk_board", "run"),
|
||||
"show_risk_commitment": ("risk_commitment", "run"),
|
||||
"show_battle_opening": ("battle_opening", "run"),
|
||||
"show_battle": ("battle", "run"),
|
||||
"show_battle_result": ("battle_result", ""),
|
||||
"show_battle_knockout_review": ("battle_knockout_review", "result_loss"),
|
||||
"show_battle_reward_choice": ("battle_reward_choice", "result_win"),
|
||||
"show_battle_recovery": ("battle_recovery", "result_loss"),
|
||||
"show_settings_from_guild": ("settings", ""),
|
||||
"show_settings_placeholder": ("settings", ""),
|
||||
"show_settings": ("settings", ""),
|
||||
"show_credits": ("credits", ""),
|
||||
"show_unavailable_reason": ("unavailable", ""),
|
||||
}
|
||||
|
||||
ACTIONS: dict[str, str] = {
|
||||
"commit_dismissal": "dismiss_commit",
|
||||
"commit_contract_return": "run_end_voluntary",
|
||||
"confirm_contract_choice": "confirm_commit",
|
||||
"save_party_order": "reorder_commit",
|
||||
"reset_party_order": "reorder_cancel",
|
||||
"select_party_member": "unit_select",
|
||||
"select_contract_difficulty": "difficulty_change_review",
|
||||
"accept_readiness": "ready_check_pass",
|
||||
"select_risk_option": "risk_option_focus",
|
||||
"toggle_risk_commitment_confirmation": "confirm_arm",
|
||||
"begin_battle": "battle_start_commit",
|
||||
"commit_battle_reward": "reward_accept",
|
||||
"commit_battle_recovery": "recovery_option_open",
|
||||
"purchase_selected_equipment": "equip_commit",
|
||||
"hire_selected_recruit": "recruit_hire_commit",
|
||||
"select_battle_reward": "reward_option_focus",
|
||||
"open_recruit_review": "recruit_hire_review",
|
||||
"open_equipment_review": "equip_review",
|
||||
"open_dismissal_review": "dismiss_arm",
|
||||
"open_contract_return_review": "run_end_voluntary",
|
||||
"continue_from_battle_result": "run_continue",
|
||||
"select_market_offer": "offer_reveal",
|
||||
}
|
||||
|
||||
HELPERS = '''
|
||||
func _ensure_audio_service() -> void:
|
||||
if audio_service != null and is_instance_valid(audio_service):
|
||||
return
|
||||
audio_service = AudioServiceScript.new()
|
||||
audio_service.name = "AudioService"
|
||||
add_child(audio_service)
|
||||
|
||||
|
||||
func _audio_enter(page_id: String, family := "") -> void:
|
||||
_ensure_audio_service()
|
||||
if audio_service == null:
|
||||
return
|
||||
audio_page_id = page_id
|
||||
if not family.is_empty():
|
||||
audio_service.set_music(family)
|
||||
audio_service.play_sfx("page_open")
|
||||
|
||||
|
||||
func _audio_sfx(event_name: String) -> void:
|
||||
_ensure_audio_service()
|
||||
if audio_service != null:
|
||||
audio_service.play_sfx(event_name)
|
||||
|
||||
'''
|
||||
|
||||
|
||||
def insert_first_statement(text: str, function: str, statement: str, indent: str = "\t") -> tuple[str, bool]:
|
||||
pattern = re.compile(rf"^func {re.escape(function)}\(([^\n]*)\)[^\n]*:\n", re.M)
|
||||
match = pattern.search(text)
|
||||
if match is None:
|
||||
return text, False
|
||||
insert_at = match.end()
|
||||
if text[insert_at:].startswith(f"{indent}{statement}"):
|
||||
return text, False
|
||||
return text[:insert_at] + f"{indent}{statement}\n" + text[insert_at:], True
|
||||
|
||||
|
||||
def main() -> int:
|
||||
text = SHELL.read_text()
|
||||
changed: list[str] = []
|
||||
if "func _audio_enter(" not in text:
|
||||
anchor = "func start_boot() -> void:"
|
||||
if anchor not in text:
|
||||
raise SystemExit("anchor for helpers not found")
|
||||
text = text.replace(anchor, HELPERS.lstrip("\n") + anchor, 1)
|
||||
changed.append("helpers")
|
||||
if "var audio_service" not in text:
|
||||
marker = "func _ready() -> void:\n"
|
||||
text = text.replace(marker, "var audio_service: ABGAudioService\nvar audio_page_id := \"\"\n\n\n" + marker, 1)
|
||||
changed.append("service vars")
|
||||
if "AudioServiceScript" not in text:
|
||||
preload_line = 'const AudioServiceScript = preload("res://presentation/audio_service.gd")\n'
|
||||
# place after the first const block line
|
||||
first_const = re.search(r"^const [A-Za-z_]+ = .*\n", text, re.M)
|
||||
if first_const is None:
|
||||
raise SystemExit("no const anchor")
|
||||
text = text[:first_const.end()] + preload_line + text[first_const.end():]
|
||||
changed.append("preload")
|
||||
if "audio_service.apply_settings(settings)" not in text:
|
||||
old = "\tvar master := AudioServer.get_bus_index(&\"Master\")"
|
||||
if old in text:
|
||||
text = text.replace(old, "\t_ensure_audio_service()\n\tif audio_service != null:\n\t\taudio_service.apply_settings(settings)\n" + old, 1)
|
||||
changed.append("apply settings")
|
||||
for function, (page_id, family) in PAGES.items():
|
||||
statement = f'_audio_enter("{page_id}", "{family}")'
|
||||
text, did = insert_first_statement(text, function, statement)
|
||||
if did:
|
||||
changed.append(f"page:{page_id}")
|
||||
for function, event in ACTIONS.items():
|
||||
statement = f'_audio_sfx("{event}")'
|
||||
text, did = insert_first_statement(text, function, statement)
|
||||
if did:
|
||||
changed.append(f"action:{function}")
|
||||
SHELL.write_text(text)
|
||||
print(f"wired {len(changed)} sites: {', '.join(changed[:6])}{' ...' if len(changed) > 6 else ''}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user