fix: update game & voiceover now works properly.

This commit is contained in:
2022-07-13 13:52:57 +07:00
parent efc2abf858
commit 5066a4e2b3
3 changed files with 46 additions and 23 deletions

View File

@ -13,6 +13,7 @@ import worthless.constants as constants
class UI:
def __init__(self, gamedir: str, noconfirm: bool, tempdir: str | Path = None) -> None:
self._vo_version = None
self._noconfirm = noconfirm
self._gamedir = gamedir
self._launcher = Launcher(gamedir)
@ -34,6 +35,9 @@ class UI:
def override_game_version(self, version: str):
self._installer._version = version
def override_voiceover_version(self, version: str):
self._vo_version = version
async def get_game_version(self):
print(await self._installer.get_game_version())
@ -194,12 +198,12 @@ class UI:
print("Downloading game update (This will take a long time)...")
await self._installer.download_game_update()
print("Installing game update...")
await self.install_from_file(self._installer.temp_path.joinpath(res_info.game.latest.name))
await self.install_from_file(self._installer.temp_path.joinpath(diff_archive.get_name()))
async def update_voiceover(self, languages: str | list):
if isinstance(languages, str):
languages = languages.split(" ")
game_ver = await self._installer.get_game_version()
game_ver = self._vo_version or self._installer.get_game_version()
if not game_ver:
print("Couldn't detect current game installation, is game installed?")
return
@ -225,6 +229,9 @@ class UI:
await self.update_game()
await self.update_voiceover(languages)
async def update_voiceover_all(self):
await self.update_voiceover(await self._installer.get_installed_voiceovers())
async def update_all(self):
await self.update_game()
await self.update_voiceover(await self._installer.get_installed_voiceovers())
@ -295,6 +302,8 @@ async def main():
parser.add_argument("--check-telemetry", action="store_true", help="Check for the telemetry information")
parser.add_argument("--clear-cache", action="store_true", help="Clear cache used by worthless")
parser.add_argument("--from-ver", action="store", help="Override the detected game version", type=str, default=None)
parser.add_argument("--from-vo-ver", action="store", help="Override the detected game version for voiceover "
"detection", type=str, default=None)
parser.add_argument("--noconfirm", action="store_true",
help="Do not ask any for confirmation. (Ignored in interactive mode)")
args = parser.parse_args()