fixed diva quest
This commit is contained in:
parent
c811af1d08
commit
7f33acf8ea
3 changed files with 49 additions and 26 deletions
|
|
@ -23,7 +23,7 @@ class BaseDB(object):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
self.quest_conn.close()
|
self.conn.close()
|
||||||
|
|
||||||
def attach_dbs(self, databases, path):
|
def attach_dbs(self, databases, path):
|
||||||
for d in databases:
|
for d in databases:
|
||||||
|
|
|
||||||
24
db/quest.py
24
db/quest.py
|
|
@ -1,16 +1,24 @@
|
||||||
from .base import BaseDB
|
from .base import BaseDB
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
"QuestMst.db": "Quest",
|
def get_dbs_by_lang(language=None):
|
||||||
"QuestSceneMst.db": "QuestScene",
|
databases = {
|
||||||
"QuestPartMst.db": "QuestPart",
|
"QuestMst": "Quest",
|
||||||
"ResourceEntry.db": "ResourceEntry",
|
"QuestSceneMst": "QuestScene",
|
||||||
}
|
"QuestPartMst": "QuestPart",
|
||||||
|
"ResourceEntry": "ResourceEntry",
|
||||||
|
}
|
||||||
|
for key in list(databases):
|
||||||
|
if not language:
|
||||||
|
databases[key + ".db"] = databases.pop(key)
|
||||||
|
else:
|
||||||
|
databases[key + "_" + language + ".db"] = databases.pop(key)
|
||||||
|
return databases
|
||||||
|
|
||||||
|
|
||||||
class QuestDB(BaseDB):
|
class QuestDB(BaseDB):
|
||||||
def __init__(self, path):
|
def __init__(self, path, language=None):
|
||||||
super().__init__(path, DATABASES)
|
super().__init__(path, get_dbs_by_lang(language))
|
||||||
|
|
||||||
def get_quests(self):
|
def get_quests(self):
|
||||||
self.cursor.execute(
|
self.cursor.execute(
|
||||||
|
|
|
||||||
|
|
@ -10,15 +10,22 @@ from glob import glob
|
||||||
def update_missions(dir_in, old_path, languages, is_global, utage_in=None):
|
def update_missions(dir_in, old_path, languages, is_global, utage_in=None):
|
||||||
if not utage_in:
|
if not utage_in:
|
||||||
utage_in = os.path.join(dir_in, "Common/Asset/Utage")
|
utage_in = os.path.join(dir_in, "Common/Asset/Utage")
|
||||||
|
if is_global:
|
||||||
|
languages = ["enm", "zho", "kor"]
|
||||||
|
for lang in languages:
|
||||||
|
qdb = db.QuestDB(dir_in, lang)
|
||||||
|
quest_mst(qdb, old_path, [lang], is_global)
|
||||||
|
scene_mst(qdb, old_path, [lang], utage_in, is_global)
|
||||||
|
else:
|
||||||
qdb = db.QuestDB(dir_in)
|
qdb = db.QuestDB(dir_in)
|
||||||
quest_mst(qdb, old_path, languages)
|
quest_mst(qdb, old_path, languages, is_global)
|
||||||
scene_mst(qdb, old_path, dir_in, languages, utage_in)
|
scene_mst(qdb, old_path, languages, utage_in, is_global)
|
||||||
|
|
||||||
|
|
||||||
def scene_mst(qdb, old_path, dir_in, languages, utage_in):
|
def scene_mst(qdb, old_path, languages, utage_in, is_global):
|
||||||
scenes = qdb.get_scenes()
|
scenes = qdb.get_scenes()
|
||||||
|
|
||||||
locations = load_locations(dir_in, utage_in)
|
locations = load_locations(utage_in)
|
||||||
|
|
||||||
for id, scene in scenes.items():
|
for id, scene in scenes.items():
|
||||||
i = 0
|
i = 0
|
||||||
|
|
@ -28,18 +35,23 @@ def scene_mst(qdb, old_path, dir_in, languages, utage_in):
|
||||||
except KeyError as exc:
|
except KeyError as exc:
|
||||||
i += 1
|
i += 1
|
||||||
if i == len(scene["Parts"]):
|
if i == len(scene["Parts"]):
|
||||||
|
if is_global:
|
||||||
|
break
|
||||||
raise KeyError(f"Could not find folder for scene {id}") from exc
|
raise KeyError(f"Could not find folder for scene {id}") from exc
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if not is_global:
|
||||||
with io.open(
|
with io.open(
|
||||||
os.path.join(old_path, "XduScene.json"), "w", encoding="utf-8"
|
os.path.join(old_path, "XduScene.json"), "w", encoding="utf-8"
|
||||||
) as json_file:
|
) as json_file:
|
||||||
json.dump(scenes, json_file, ensure_ascii=False, indent="\t", sort_keys=True)
|
json.dump(
|
||||||
|
scenes, json_file, ensure_ascii=False, indent="\t", sort_keys=True
|
||||||
|
)
|
||||||
|
|
||||||
for lang in languages:
|
for lang in languages:
|
||||||
out_dict = {}
|
out_dict = {}
|
||||||
if lang == "jpn":
|
if lang == "jpn" or is_global:
|
||||||
for key, value in scenes.items():
|
for key, value in scenes.items():
|
||||||
out_dict[key] = {
|
out_dict[key] = {
|
||||||
"Name": value["Name"],
|
"Name": value["Name"],
|
||||||
|
|
@ -68,17 +80,20 @@ def scene_mst(qdb, old_path, dir_in, languages, utage_in):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def quest_mst(qdb, old_path, languages):
|
def quest_mst(qdb, old_path, languages, is_global):
|
||||||
quests = qdb.get_quests()
|
quests = qdb.get_quests()
|
||||||
|
|
||||||
|
if not is_global:
|
||||||
with io.open(
|
with io.open(
|
||||||
os.path.join(old_path, "XduQuest.json"), "w", encoding="utf-8"
|
os.path.join(old_path, "XduQuest.json"), "w", encoding="utf-8"
|
||||||
) as json_file:
|
) as json_file:
|
||||||
json.dump(quests, json_file, ensure_ascii=False, indent="\t", sort_keys=True)
|
json.dump(
|
||||||
|
quests, json_file, ensure_ascii=False, indent="\t", sort_keys=True
|
||||||
|
)
|
||||||
|
|
||||||
for lang in languages:
|
for lang in languages:
|
||||||
out_dict = {}
|
out_dict = {}
|
||||||
if lang == "jpn":
|
if lang == "jpn" or is_global:
|
||||||
for key, value in quests.items():
|
for key, value in quests.items():
|
||||||
out_dict[key] = {"Name": value["Name"], "Enabled": False}
|
out_dict[key] = {"Name": value["Name"], "Enabled": False}
|
||||||
else:
|
else:
|
||||||
|
|
@ -99,7 +114,7 @@ def quest_mst(qdb, old_path, languages):
|
||||||
return quests
|
return quests
|
||||||
|
|
||||||
|
|
||||||
def load_locations(dir_in, utage_in):
|
def load_locations(utage_in):
|
||||||
locations = {}
|
locations = {}
|
||||||
settings = glob("{}/**/Settings/Scenario.tsv".format(utage_in), recursive=True,)
|
settings = glob("{}/**/Settings/Scenario.tsv".format(utage_in), recursive=True,)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue