diff --git a/arkprts/assets/bundle.py b/arkprts/assets/bundle.py index 4832ac1..1cf3e1e 100644 --- a/arkprts/assets/bundle.py +++ b/arkprts/assets/bundle.py @@ -11,7 +11,6 @@ import io import json import logging -import os import pathlib import re import shlex @@ -33,7 +32,7 @@ UnityPyAsset = typing.Any UnityPyObject = typing.Any -UPDATED_FBS = {"cn": False, "yostar": False} +UPDATED_FBS = {"cn": False, "yostar": False, "tw": False} def asset_path_to_server_filename(path: str) -> str: @@ -124,16 +123,14 @@ def run_flatbuffers( return pathlib.Path(output_directory) / (pathlib.Path(fbs_path).stem + ".json") -def resolve_fbs_schema_directory(server: typing.Literal["cn", "yostar"]) -> pathlib.Path: +def resolve_fbs_schema_directory(server: typing.Literal["cn", "yostar", "tw"]) -> pathlib.Path: """Resolve the flatbuffers schema directory.""" - path = os.environ.get(f"FLATBUFFERS_SCHEMA_DIR_{server.upper()}") - if path: - return pathlib.Path(path) + if server == "tw": + return netn.APPDATA_DIR / "ArknightsFlatbuffers" / "tw" core_path = netn.APPDATA_DIR / "ArknightsFBS" core_path.mkdir(parents=True, exist_ok=True) path = core_path / server / "OpenArknightsFBS" / "FBS" - os.environ[f"FLATBUFFERS_SCHEMA_DIR_{server.upper()}"] = str(path) return path @@ -147,6 +144,12 @@ async def update_fbs_schema(*, force: bool = False) -> None: directory = resolve_fbs_schema_directory(server).parent # pyright: ignore[reportArgumentType] await git.download_repository("MooncellWiki/OpenArknightsFBS", directory, branch=branch, force=force) + if not UPDATED_FBS["tw"] or force: + UPDATED_FBS["tw"] = True + await git.download_repository( + "ArknightsAssets/ArknightsFlatbuffers", netn.APPDATA_DIR / "ArknightsFlatbuffers", force=force, + ) + def recursively_collapse_keys(obj: typing.Any) -> typing.Any: """Recursively collapse arknights flatc dictionaries.""" @@ -181,9 +184,9 @@ def decrypt_fbs_file( fbs_path = tempdir / (table_name + ".bytes") fbs_path.write_bytes(data) - fbs_schema_path = resolve_fbs_schema_directory(server="cn" if server in ("cn", "bili") else "yostar") / ( - table_name + ".fbs" - ) + fbs_schema_path = resolve_fbs_schema_directory( + server="cn" if server in ("cn", "bili") else "tw" if server == "tw" else "yostar", + ) / (table_name + ".fbs") output_directory = tempdir / "output" output_path = run_flatbuffers(fbs_path, fbs_schema_path, output_directory) diff --git a/setup.py b/setup.py index fd165ee..5b8b4db 100644 --- a/setup.py +++ b/setup.py @@ -13,10 +13,10 @@ package_data={"arkprts": ["py.typed"]}, install_requires=["aiohttp", "pydantic==2.*"], extras_require={ - "all": ["rsa", "pycryptodome", "UnityPy", "bson"], + "all": ["rsa", "pycryptodome", "UnityPy==1.10.18", "bson"], "rsa": ["rsa"], "aes": ["pycryptodome"], - "assets": ["UnityPy", "pycryptodome", "bson"], + "assets": ["UnityPy==1.10.18", "pycryptodome", "bson"], }, long_description=pathlib.Path("README.md").read_text(encoding="utf-8"), long_description_content_type="text/markdown",