From bcb50488d434dd4376321949db67cde2cc2f9f4a Mon Sep 17 00:00:00 2001 From: Caleb Smith Date: Mon, 27 Jun 2022 12:42:01 -0500 Subject: [PATCH] Folder pick improvements Also version bump --- Cargo.toml | 2 +- bcml/__version__.py | 2 +- bcml/_api.py | 43 +++++++++++++++++++++++++++++-------------- bcml/util.py | 13 +++++++++++++ pyproject.toml | 2 +- setup.py | 2 +- 6 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 11481a19..506a2b2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bcml" authors = ["Caleb Smith"] -version = "3.9.12" +version = "3.9.13" edition = "2021" readme = "docs/README.md" diff --git a/bcml/__version__.py b/bcml/__version__.py index 7b7888c2..34e97134 100644 --- a/bcml/__version__.py +++ b/bcml/__version__.py @@ -1,6 +1,6 @@ _MAJOR=3 _MINOR=9 -_PATCH="12" +_PATCH="13" VERSION = f"{_MAJOR}.{_MINOR}.{_PATCH}" USER_VERSION = f"""{_MAJOR}.{_MINOR}.{_PATCH[0:1]} { diff --git a/bcml/_api.py b/bcml/_api.py index fca0f468..d92a4a09 100644 --- a/bcml/_api.py +++ b/bcml/_api.py @@ -16,7 +16,7 @@ from tempfile import NamedTemporaryFile, mkdtemp from time import sleep from threading import Thread -from typing import List +from typing import List, Optional from xml.dom import minidom import requests @@ -140,20 +140,35 @@ def parse_cemu_settings(self, params): cemu = Path(params["folder"]) set_path = cemu / "settings.xml" settings: minidom = util.parse_cemu_settings(set_path) - game_dir: Path - for entry in settings.getElementsByTagName("GameCache")[ - 0 - ].getElementsByTagName("Entry"): - entry: minidom.Element - path = entry.getElementsByTagName("path")[0].childNodes[0].data - if "U-King" in path: - game_dir = Path(path).parent.parent / "content" - break + game_dir: Optional[Path] = None + mlc_path: Path + try: + for entry in settings.getElementsByTagName("GameCache")[ + 0 + ].getElementsByTagName("Entry"): + entry: minidom.Element + path: str = entry.getElementsByTagName("path")[0].childNodes[0].data + if "U-King" in path: + if SYSTEM == "Linux" and path[1:3] == ":\\": + path = path[2:].replace("\\", "/") + game_dir = Path(path).parent.parent / "content" + break + except IndexError: + pass + try: + mlc_str: str = settings.getElementsByTagName("mlc_path")[0].childNodes[0].data + if SYSTEM == "Linux" and mlc_str[1:3] == ":\\": + mlc_path = Path(mlc_str[2:].replace("\\", "/")) + else: + mlc_path = Path(mlc_str) + except IndexError: + mlc_path = cemu / "mlc01" + if not mlc_path.exists(): + return {} if not game_dir: - return {} - mlc_path = Path( - settings.getElementsByTagName("mlc_path")[0].childNodes[0].data - ) + game_dir = util.guess_game_dir(mlc_path) + if not game_dir: + return {} update_dir = util.guess_update_dir(mlc_path, game_dir) dlc_dir = util.guess_aoc_dir(mlc_path, game_dir) return { diff --git a/bcml/util.py b/bcml/util.py index bd142ade..a5111ebb 100644 --- a/bcml/util.py +++ b/bcml/util.py @@ -687,6 +687,19 @@ def set_site_meta(site_meta: str): save_settings() +def guess_game_dir(mlc_dir: Path) -> Optional[Path]: + ids = { + ("00050000", "101C9400"), + ("00050000", "101C9500"), + ("00050000", "101C9300"), + } + for (id1, id2) in ids: + target = mlc_dir / "usr" / "title" / id1 / id2 / "content" + if target.exists(): + return target + return None + + @lru_cache(None) def get_title_id(game_dir: Path = None) -> Tuple[str, str]: title_id = "00050000101C9400" diff --git a/pyproject.toml b/pyproject.toml index 36c04b3d..40b161e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "bcml" -version = "3.9.12" +version = "3.9.13" description = "A mod manager for The Legend of Zelda: Breath of the Wild" author = "NiceneNerd" author_email = "macadamiadaze@gmail.com" diff --git a/setup.py b/setup.py index 8287f8d8..3505485f 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name="bcml", - version="3.9.12", + version="3.9.13", author="NiceneNerd", author_email="macadamiadaze@gmail.com", description="A mod manager for The Legend of Zelda: Breath of the Wild",