Version 3.1.0: voice lines linked across all languages from the game data

This commit is contained in:
2026-10-10 14:10:03 +02:00
parent ea3e44000a
commit fbde809370
56 changed files with 74728 additions and 73360 deletions

View File

@@ -30,7 +30,7 @@ def test_apply_in_place_and_revert_byte_identical(synth_game):
root, originals = synth_game
before = files(root)
ws = ws_for(root)
s = ws.sound("CHR_RadioScanner_2")
s = ws.sound("Speech_Synth_Radio_02")
x, sr = synth.tone(1.2, 24000, 900)
wem, info = ws.prepare(s, x, sr)
assert len(wem) <= ws.limit(s)
@@ -74,7 +74,7 @@ def test_size_limit_enforced(synth_game):
def test_reapply_uses_original_limit(synth_game):
root, _ = synth_game
ws = ws_for(root)
s = ws.sound("CHR_RadioScanner_2")
s = ws.sound("Speech_Synth_Radio_02")
lim = ws.limit(s)
ws.apply([(s, synth.wem(0.3, 1000), {})]) # much smaller
assert ws.limit(s) == lim # still the original's size
@@ -119,10 +119,44 @@ def test_full_backup_taken_once(synth_game):
assert rel in restored and ws.state(s) == W.ORIGINAL
def test_mod_from_another_language_matched_by_line(synth_game, tmp_path):
"""A voice line from another language is found through the game's line identity (its WAD position there
can differ); a voice line from a package without line identities is never guessed by name."""
import json
import zipfile
root, _ = synth_game
ws = ws_for(root, store_root=str(tmp_path / "store"))
s = ws.catalog.by_key["INT:%08X:1" % synth.SPEECH_ENTRY]
assert s.line and s.name == synth.SPEECH_EVENT # the game's line, named after its event
ws.apply([(s, synth.wem(0.3, 1000), {})])
pkg = str(tmp_path / "other_lang.acmod")
export_mod(ws, pkg, ws.modified_keys(), "t")
ws.revert_all()
def rewrite(change):
with zipfile.ZipFile(pkg) as z:
files = {n: z.read(n) for n in z.namelist()}
man = json.loads(files["manifest.json"])
change(man["items"][0])
files["manifest.json"] = json.dumps(man).encode()
with zipfile.ZipFile(pkg, "w") as z:
for n, b in files.items():
z.writestr(n, b)
def other_language(it): # as if made on the ITA game, at another position
it["archive"], it["target"], it["name"] = "ITA", "%08X:2" % synth.SPEECH_ENTRY, "Speech_Synth_Radio_02"
rewrite(other_language)
_, items = match_mod(ws, pkg)
assert items[0].how == "same line" and items[0].sound is s
rewrite(lambda it: it.pop("line")) # an older package: names alone are no proof
_, items = match_mod(ws, pkg)
assert items[0].how == "missing" and "older version" in items[0].note
def test_mod_export_import_roundtrip(synth_game, synth_template, tmp_path):
root, _ = synth_game
ws = ws_for(root)
a = ws.sound("CHR_RadioScanner_2")
a = ws.sound("Speech_Synth_Radio_02")
b = ws.catalog.by_key["SFX:%08X/%08X" % (synth.PACK_ID, synth.MEDIA[0])]
wa, wb = synth.wem(1.0, 820), synth.wem(2.5, 410, 48000, 2)
ws.apply([(a, wa, {}), (b, wb, {})])