diff --git a/utage/names.py b/utage/names.py index 5c5f2e2..b6633f0 100644 --- a/utage/names.py +++ b/utage/names.py @@ -10,13 +10,24 @@ from multiprocessing import Pool def update_names(dir_in, old_path, languages, is_global): - names = extract_names(dir_in) + names = extract_names(dir_in, is_global) + + global_languages = {"enm": 1, "zh": 2, "ko": 3} + if is_global: + languages = global_languages.keys() # we have to update japanese like the rest because CustomData exists # and POKELABO deleted the wedding gear event stuff from the game files for l in languages: if l == "jpn": out_dict = dict(zip(names, names)) + elif l in global_languages.keys(): + out_dict = {} + for name in names: + spl = name.split("\t") + idx = global_languages[l] + val = spl[idx] if spl[idx] != "None" else "" + out_dict[spl[0]] = val else: out_dict = dict.fromkeys(names, "") @@ -34,13 +45,13 @@ def update_names(dir_in, old_path, languages, is_global): ) -def extract_names(dir_in): +def extract_names(dir_in, is_global): char_tsv_path = os.path.join(dir_in, "Diva", "Settings", "Character.tsv") if not os.path.isfile(char_tsv_path): raise FileNotFoundError("Character.tsv not found") - names, sets = read_char_tsv(char_tsv_path) + names, sets = read_char_tsv(char_tsv_path, is_global) files = [ f @@ -50,18 +61,20 @@ def extract_names(dir_in): if len(files) == 0: raise FileNotFoundError("No valid files found in directory: " + dir_in) - # tfw gil - # it's still faster on my machine so i'm keeping it - read_partial = partial(read_mission, char_names=names, char_sets=sets) - with Pool() as p: - new_names = p.map(read_partial, files) - for x in new_names: - names.update(x) + # TODO unsupported on global for now + if not is_global: + # tfw gil + # it's still faster on my machine so i'm keeping it + read_partial = partial(read_mission, char_names=names, char_sets=sets) + with Pool() as p: + new_names = p.map(read_partial, files) + for x in new_names: + names.update(x) return names -def read_char_tsv(char_tsv_path): +def read_char_tsv(char_tsv_path, is_global): char_names = set() char_sets = set() @@ -77,7 +90,12 @@ def read_char_tsv(char_tsv_path): and row["CharacterName"].strip() and row["NameText"].strip() ): - char_names.add(row["NameText"]) + if is_global: + char_names.add( + f"{row['NameText']}\t{row['CharaEnglish']}\t{row['CharaChinese']}\t{row['CharaKorean']}" + ) + else: + char_names.add(row["NameText"]) char_sets.add(row["CharacterName"]) return char_names, char_sets