Support chinese variant game version detection (not tested)
Also some minor improvements for preparation of installation features.
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
import re
|
||||
import appdirs
|
||||
from pathlib import Path
|
||||
from configparser import ConfigParser
|
||||
|
||||
from worthless import constants
|
||||
from worthless.launcher import Launcher
|
||||
|
||||
|
||||
@ -14,7 +17,10 @@ class Installer:
|
||||
|
||||
# https://gitlab.com/KRypt0n_/an-anime-game-launcher/-/blob/main/src/ts/Game.ts#L26
|
||||
def _read_version_from_game_file(self):
|
||||
globalgamemanagers = self._gamedir.joinpath("./GenshinImpact_Data/globalgamemanagers")
|
||||
if self._overseas:
|
||||
globalgamemanagers = self._gamedir.joinpath("./GenshinImpact_Data/globalgamemanagers")
|
||||
else:
|
||||
globalgamemanagers = self._gamedir.joinpath("./YuanShen_Data/globalgamemanagers")
|
||||
if globalgamemanagers.exists():
|
||||
with globalgamemanagers.open("rb") as f:
|
||||
data = f.read().decode("ascii")
|
||||
@ -23,10 +29,17 @@ class Installer:
|
||||
raise ValueError("Could not find version in game file")
|
||||
return result.group(1)
|
||||
|
||||
def __init__(self, gamedir: str | Path = Path.cwd(), overseas: bool = True):
|
||||
def __init__(self, gamedir: str | Path = Path.cwd(), overseas: bool = True, data_dir: str | Path = None):
|
||||
if isinstance(gamedir, str):
|
||||
gamedir = Path(gamedir)
|
||||
self._gamedir = gamedir
|
||||
if not data_dir:
|
||||
self._appdirs = appdirs.AppDirs(constants.APP_NAME, constants.APP_AUTHOR)
|
||||
self._temp_path = Path(self._appdirs.user_cache_dir).joinpath("Installer")
|
||||
else:
|
||||
if not isinstance(data_dir, Path):
|
||||
data_dir = Path(data_dir)
|
||||
self._temp_path = data_dir.joinpath("Temp/Installer/")
|
||||
config_file = self._gamedir.joinpath("config.ini")
|
||||
self._config_file = config_file.resolve()
|
||||
self._version = None
|
||||
|
||||
Reference in New Issue
Block a user