Game line names across languages; RSubtitle; editor in three columns
This commit is contained in:
@@ -17,9 +17,10 @@ import os
|
||||
import random
|
||||
|
||||
from .. import banks, classify, subtitles
|
||||
from ..catalog import (Catalog, available_archives, bank_sounds, hash_names, head_owners, is_shipped,
|
||||
from ..catalog import (Catalog, available_archives, bank_sounds, character_of, hash_names, head_owners, is_shipped,
|
||||
load_banks, load_characters, read_csv, scan_archive)
|
||||
from ..inject import read_target
|
||||
from ..paths import catalog_dir
|
||||
from ..wad import Wad
|
||||
|
||||
FOLDER_LANG = {"ENGLISH(US)": "INT", "ITALIAN": "ITA", "FRENCH(FRANCE)": "FRA", "GERMAN": "DEU",
|
||||
@@ -67,7 +68,7 @@ def _check_rows(rep, archive, rows, characters):
|
||||
g, c = _expected_category(s)
|
||||
if (s.group, s.category) != (g, c):
|
||||
rep.add(archive, "category", s.key, "%s/%s, rules give %s/%s" % (s.group, s.category, g, c))
|
||||
want = next((characters[a.lower()] for a in s.names() if a.lower() in characters), "")
|
||||
want = character_of(s, characters)
|
||||
if s.character != want:
|
||||
rep.add(archive, "character", s.key, "%r, curated list says %r" % (s.character, want))
|
||||
|
||||
@@ -80,6 +81,11 @@ def check_wad(rep, game, archive, rows, characters):
|
||||
rep.add(archive, "language", archive, "WAD in folder %s" % folder)
|
||||
_check_rows(rep, archive, rows, characters)
|
||||
fresh = {s.target: s for s in scan_archive(archive, path, characters=characters)}
|
||||
if is_shipped(game, archive): # shipped names are the game's line names (built from the banks)
|
||||
byk = {s.target: s for s in rows}
|
||||
for t, s in fresh.items():
|
||||
if t in byk:
|
||||
s.name, s.aliases = byk[t].name, byk[t].aliases
|
||||
cat = {s.target: s for s in rows}
|
||||
for t in sorted(set(fresh) - set(cat)):
|
||||
rep.add(archive, "missing", "%s:%s" % (archive, t), fresh[t].name)
|
||||
@@ -105,6 +111,12 @@ def check_banks(rep, game, rows, locations, characters, quick=False, sample=40,
|
||||
files = [f for f in files if f.startswith("SFX/")] + sorted(rnd.sample(pk, min(sample, len(pk))))
|
||||
col = subtitles.Collector()
|
||||
sc = banks.scan(game.cooked, progress, files=files, visit=col)
|
||||
known = {n.split("#")[0] for s in rows for n in s.names()} # BANK names
|
||||
for a in game.languages: # + speech line names of the catalogs
|
||||
p = os.path.join(catalog_dir(), "%s.csv" % a)
|
||||
if os.path.exists(p):
|
||||
known.update(n.split("#")[0] for s in read_csv(p) for n in s.names())
|
||||
col.resolve({n for n in sc.names | known if n.lower().startswith("speech_")})
|
||||
check_subtitles(rep, game, col, set(files), quick)
|
||||
owners = head_owners(game, sc)
|
||||
index = collections.defaultdict(set)
|
||||
@@ -184,7 +196,6 @@ def check_subtitles(rep, game, col, files, quick):
|
||||
def run(game, archives=None, quick=False, log=print, progress=None):
|
||||
"""Check the given archives (default: all). Returns a Report."""
|
||||
rep = Report()
|
||||
characters = load_characters()
|
||||
archives = archives or available_archives(game)
|
||||
cat = Catalog(game, archives, progress)
|
||||
by_arch = collections.defaultdict(list)
|
||||
@@ -192,11 +203,13 @@ def run(game, archives=None, quick=False, log=print, progress=None):
|
||||
by_arch[s.archive].append(s)
|
||||
for a in archives:
|
||||
log("checking %s ..." % a)
|
||||
characters = load_characters(lang=None if a == banks.ARCHIVE else a)
|
||||
if a == banks.ARCHIVE:
|
||||
rows = load_banks(game, progress)[0] # every language, not only the loaded one
|
||||
check_banks(rep, game, rows, cat.locations, characters, quick=quick, progress=progress)
|
||||
else:
|
||||
check_wad(rep, game, a, by_arch[a], characters)
|
||||
characters = load_characters(lang=game.language())
|
||||
known = {n.lower() for s in cat.sounds for n in s.names()}
|
||||
# speaker names are the same in every language; only meaningful for the build the lists were made for
|
||||
if any(a in game.languages and is_shipped(game, a) for a in archives):
|
||||
|
||||
Reference in New Issue
Block a user