Compare commits
No commits in common. "80f1ea87d7760355699ee8eb6657cf8dd66bfc25" and "884236177bc2c860516c6244b7c60b24a1825ae0" have entirely different histories.
80f1ea87d7
...
884236177b
@ -3,9 +3,6 @@ Class wrapper for API endpoint /resource
|
||||
"""
|
||||
|
||||
|
||||
from vollerei.common.enums import VoicePackLanguage
|
||||
|
||||
|
||||
class Segment:
|
||||
"""
|
||||
A segment of the game archive.
|
||||
@ -44,7 +41,7 @@ class VoicePack:
|
||||
`name` maybe converted from `path` if the server returns empty string.
|
||||
|
||||
Attributes:
|
||||
language (VoicePackLanguage): Language of the voice pack.
|
||||
language (str): Language of the voice pack.
|
||||
name (str): Voice pack archive name.
|
||||
path (str): Voice pack download path.
|
||||
size (int): Voice pack size.
|
||||
@ -52,7 +49,7 @@ class VoicePack:
|
||||
package_size (int): Voice pack package size.
|
||||
"""
|
||||
|
||||
language: VoicePackLanguage
|
||||
language: str
|
||||
name: str
|
||||
path: str
|
||||
# str -> int
|
||||
@ -63,7 +60,7 @@ class VoicePack:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
language: VoicePackLanguage,
|
||||
language: str,
|
||||
name: str,
|
||||
path: str,
|
||||
size: int,
|
||||
@ -80,7 +77,7 @@ class VoicePack:
|
||||
@staticmethod
|
||||
def from_dict(data: dict) -> "VoicePack":
|
||||
return VoicePack(
|
||||
VoicePackLanguage.from_remote_str(data["language"]),
|
||||
data["language"],
|
||||
data["name"],
|
||||
data["path"],
|
||||
int(data["size"]),
|
||||
|
@ -1,27 +0,0 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class VoicePackLanguage(Enum):
|
||||
Japanese = "ja-jp"
|
||||
Chinese = "zh-cn"
|
||||
Taiwanese = "zh-tw"
|
||||
Korean = "ko-kr"
|
||||
English = "en-us"
|
||||
|
||||
@staticmethod
|
||||
def from_remote_str(s: str) -> "VoicePackLanguage":
|
||||
"""
|
||||
Converts a language string from remote server to a VoicePackLanguage enum.
|
||||
"""
|
||||
if s == "ja-jp":
|
||||
return VoicePackLanguage.Japanese
|
||||
elif s == "zh-cn":
|
||||
return VoicePackLanguage.Chinese
|
||||
elif s == "zh-tw":
|
||||
return VoicePackLanguage.Taiwanese
|
||||
elif s == "ko-kr":
|
||||
return VoicePackLanguage.Korean
|
||||
elif s == "en-us":
|
||||
return VoicePackLanguage.English
|
||||
else:
|
||||
raise ValueError(f"Invalid language string: {s}")
|
@ -13,13 +13,6 @@ _hdiff = HDiffPatch()
|
||||
def apply_update_archive(
|
||||
game: GameABC, archive_file: Path | IOBase, auto_repair: bool = True
|
||||
) -> None:
|
||||
"""
|
||||
Applies an update archive to the game, it can be the game update or a
|
||||
voicepack update.
|
||||
|
||||
Because this function is shared for all games, you should use the game's
|
||||
`apply_update_archive()` method instead.
|
||||
"""
|
||||
# Most code here are copied from worthless-launcher.
|
||||
# worthless-launcher uses asyncio for multithreading while this one uses
|
||||
# ThreadPoolExecutor, probably better for this use case.
|
||||
|
@ -224,9 +224,6 @@ class Game(GameABC):
|
||||
"""
|
||||
Gets the current installed game version as a string.
|
||||
|
||||
Because this method uses `get_version()`, you should read the docs of
|
||||
that method too.
|
||||
|
||||
Returns:
|
||||
str: The version as a string.
|
||||
"""
|
||||
@ -237,7 +234,7 @@ class Game(GameABC):
|
||||
Gets the current game channel.
|
||||
|
||||
Only works for Star Rail version 1.0.5, other versions will return the
|
||||
overridden channel or GameChannel.Overseas if no channel is overridden.
|
||||
overridden channel or None if no channel is overridden.
|
||||
|
||||
This is not needed for game patching, since the patcher will automatically
|
||||
detect the channel.
|
||||
@ -268,17 +265,7 @@ class Game(GameABC):
|
||||
# fallback to overseas.
|
||||
return self._channel_override or GameChannel.Overseas
|
||||
|
||||
def get_remote_game(self, pre_download: bool = False) -> resource.Game:
|
||||
"""
|
||||
Gets the current game information from remote.
|
||||
|
||||
Args:
|
||||
pre_download (bool): Whether to get the pre-download version.
|
||||
Defaults to False.
|
||||
|
||||
Returns:
|
||||
A `Game` object that contains the game information.
|
||||
"""
|
||||
def get_remote_game(self, pre_download: bool) -> resource.Game:
|
||||
channel = self._channel_override or self.get_channel()
|
||||
if pre_download:
|
||||
game = api.get_resource(channel=channel).pre_download_game
|
||||
@ -291,18 +278,13 @@ class Game(GameABC):
|
||||
"""
|
||||
Gets the current game update.
|
||||
|
||||
Args:
|
||||
pre_download (bool): Whether to get the pre-download version.
|
||||
Defaults to False.
|
||||
|
||||
Returns:
|
||||
A `Diff` object that contains the update information or
|
||||
`None` if the game is not installed or already up-to-date.
|
||||
Returns a `Diff` object that contains the update information or
|
||||
None if the game is not installed or already up-to-date.
|
||||
"""
|
||||
if not self.is_installed():
|
||||
return None
|
||||
version = (
|
||||
".".join(str(x) for x in self._version_override)
|
||||
".".join(x for x in self._version_override)
|
||||
if self._version_override
|
||||
else self.get_version_str()
|
||||
)
|
||||
@ -315,13 +297,8 @@ class Game(GameABC):
|
||||
"""
|
||||
Repairs a game file.
|
||||
|
||||
This will automatically handle backup and restore the file if the repair
|
||||
fails.
|
||||
|
||||
Args:
|
||||
file (PathLike): The file to repair.
|
||||
pre_download (bool): Whether to get the pre-download version.
|
||||
Defaults to False.
|
||||
"""
|
||||
if not self.is_installed():
|
||||
raise GameNotInstalledError("Game is not installed.")
|
||||
@ -363,7 +340,6 @@ class Game(GameABC):
|
||||
Args:
|
||||
archive_file (PathLike | IOBase): The archive file.
|
||||
auto_repair (bool, optional): Whether to repair the file if it's broken.
|
||||
Defaults to True.
|
||||
"""
|
||||
if not self.is_installed():
|
||||
raise GameNotInstalledError("Game is not installed.")
|
||||
@ -379,13 +355,10 @@ class Game(GameABC):
|
||||
Installs an update from a `Diff` object.
|
||||
|
||||
You may want to download the update manually and pass it to
|
||||
`apply_update_archive()` instead for better control, and after that
|
||||
execute `set_version_config()` to set the game version.
|
||||
`apply_update_archive()` instead for better control.
|
||||
|
||||
Args:
|
||||
update_info (Diff, optional): The update information. Defaults to None.
|
||||
auto_repair (bool, optional): Whether to repair the file if it's broken.
|
||||
Defaults to True.
|
||||
"""
|
||||
if not self.is_installed():
|
||||
raise GameNotInstalledError("Game is not installed.")
|
||||
|
Loading…
Reference in New Issue
Block a user