import db import io import json import os def update_missions(dir_in, old_path, languages): qdb = db.QuestDB(dir_in) quest_mst(qdb, old_path, languages) scene_mst(qdb, old_path, languages) def scene_mst(qdb, old_path, languages): scenes = qdb.get_scenes() with io.open( os.path.join(old_path, "XduScene.json"), "w", newline="\n" ) as json_file: json.dump( scenes, json_file, ensure_ascii=False, indent="\t", sort_keys=True ) # TODO: reimplement folder finder for lang in languages: out_dict = {} if lang == "jpn": for key, value in scenes.items(): out_dict[key] = { "Name": value.name, "SummaryText": value.summaryText, "Credits": "POKELABO", "Enabled": False, } else: for key in scenes.keys(): out_dict[key] = { "Name": "", "SummaryText": "", "Credits": "", "Enabled": False, } langfile = os.path.join(old_path, f"XduSceneNames_{lang}.json") if os.path.isfile(langfile): with open(langfile, "r") as lang_file: lang_dict = json.load(lang_file) out_dict.update(lang_dict) with io.open(langfile, "w", newline="\n") as lang_file: json.dump( out_dict, lang_file, ensure_ascii=False, indent="\t", sort_keys=True, ) def quest_mst(qdb, old_path, languages): quests = qdb.get_quests() with io.open( os.path.join(old_path, "XduQuest.json"), "w", newline="\n" ) as json_file: json.dump( quests, json_file, ensure_ascii=False, indent="\t", sort_keys=True ) for lang in languages: out_dict = {} if lang == "jpn": for key, value in quests.items(): out_dict[key] = {"Name": value.name, "Enabled": False} else: for key, value in quests.items(): out_dict[key] = {"Name": "", "Enabled": False} langfile = os.path.join(old_path, f"XduQuestNames_{lang}.json") if os.path.isfile(langfile): with open(langfile, "r") as lang_file: lang_dict = json.load(lang_file) out_dict.update(lang_dict) with io.open(langfile, "w", newline="\n") as lang_file: json.dump( out_dict, lang_file, ensure_ascii=False, indent="\t", sort_keys=True, ) return quests