feat(hsr): support continue download & apply-archive
This commit is contained in:
parent
6f030e79ce
commit
6db85bc439
@ -3,7 +3,7 @@ from vollerei.cli import hsr
|
|||||||
|
|
||||||
application = Application()
|
application = Application()
|
||||||
for command in hsr.commands:
|
for command in hsr.commands:
|
||||||
application.add(command)
|
application.add(command())
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
from cleo.commands.command import Command
|
from cleo.commands.command import Command
|
||||||
from cleo.helpers import option
|
from cleo.helpers import option, argument
|
||||||
from platform import system
|
from platform import system
|
||||||
from vollerei.hsr.launcher.enums import GameChannel
|
from vollerei.hsr.launcher.enums import GameChannel
|
||||||
from vollerei.paths import set_base_path, base_paths
|
|
||||||
from vollerei.cli import utils
|
from vollerei.cli import utils
|
||||||
from vollerei.exceptions.game import GameError
|
from vollerei.exceptions.game import GameError
|
||||||
from vollerei.hsr import Game, Patcher
|
from vollerei.hsr import Game, Patcher
|
||||||
from vollerei.exceptions.patcher import PatcherError, PatchUpdateError
|
from vollerei.exceptions.patcher import PatcherError, PatchUpdateError
|
||||||
from vollerei.hsr.patcher import PatchType
|
from vollerei.hsr.patcher import PatchType
|
||||||
from tqdm import tqdm
|
|
||||||
import requests
|
|
||||||
|
|
||||||
patcher = Patcher()
|
patcher = Patcher()
|
||||||
|
|
||||||
|
|
||||||
default_options = [
|
default_options = [
|
||||||
option("channel", "c", description="Game channel", flag=False, default="overseas"),
|
option("channel", "c", description="Game channel", flag=False, default="overseas"),
|
||||||
|
option("force", "f", description="Force the command to run"),
|
||||||
option(
|
option(
|
||||||
"game-path",
|
"game-path",
|
||||||
"g",
|
"g",
|
||||||
@ -289,12 +287,60 @@ class UpdateCommand(Command):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
progress.finish("<comment>Update applied.</comment>")
|
progress.finish("<comment>Update applied.</comment>")
|
||||||
|
self.line("Setting version config... ")
|
||||||
|
self.set_version_config()
|
||||||
|
self.line(
|
||||||
|
f"The game has been updated to version: <comment>{State.game.get_version_str()}</comment>"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ApplyUpdateArchive(Command):
|
||||||
|
name = "hsr update apply-archive"
|
||||||
|
description = "Applies the update archive to the local game"
|
||||||
|
arguments = [argument("path", description="Path to the update archive")]
|
||||||
|
options = default_options + [
|
||||||
|
option(
|
||||||
|
"auto-repair", "R", description="Automatically repair the game if needed"
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
def handle(self):
|
||||||
|
callback(command=self)
|
||||||
|
auto_repair = self.option("auto-repair")
|
||||||
|
update_archive = self.argument("path")
|
||||||
|
if auto_repair:
|
||||||
|
self.line("<comment>Auto-repair is enabled.</comment>")
|
||||||
|
progress = utils.ProgressIndicator(self)
|
||||||
|
progress.start("Applying update package...")
|
||||||
|
try:
|
||||||
|
State.game.apply_update_archive(update_archive, auto_repair=auto_repair)
|
||||||
|
except Exception as e:
|
||||||
|
progress.finish(
|
||||||
|
f"<error>Couldn't apply update: {e} ({e.__context__})</error>"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
progress.finish("<comment>Update applied.</comment>")
|
||||||
|
self.line("Setting version config... ")
|
||||||
|
try:
|
||||||
|
State.game.set_version_config()
|
||||||
|
except Exception as e:
|
||||||
|
self.line_error(f"<warn>Couldn't set version config: {e}</warn>")
|
||||||
|
self.line_error(
|
||||||
|
"This won't affect the overall experience, but if you're using the official launcher"
|
||||||
|
)
|
||||||
|
self.line_error(
|
||||||
|
"you may have to edit the file 'config.ini' manually to reflect the latest version."
|
||||||
|
)
|
||||||
|
self.line(
|
||||||
|
f"The game has been updated to version: <comment>{State.game.get_version_str()}</comment>"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
commands = [
|
commands = [
|
||||||
UpdateCommand(),
|
ApplyUpdateArchive,
|
||||||
PatchTypeCommand(),
|
UpdateCommand,
|
||||||
UpdatePatchCommand(),
|
PatchTypeCommand,
|
||||||
PatchInstallCommand(),
|
UpdatePatchCommand,
|
||||||
GetVersionCommand(),
|
PatchInstallCommand,
|
||||||
|
GetVersionCommand,
|
||||||
]
|
]
|
||||||
|
@ -347,7 +347,6 @@ class Game(GameABC):
|
|||||||
archive_file = Path(archive_file)
|
archive_file = Path(archive_file)
|
||||||
# Hello hell again, dealing with HDiffPatch and all the things again.
|
# Hello hell again, dealing with HDiffPatch and all the things again.
|
||||||
functions.apply_update_archive(self, archive_file, auto_repair=auto_repair)
|
functions.apply_update_archive(self, archive_file, auto_repair=auto_repair)
|
||||||
self.set_version_config()
|
|
||||||
|
|
||||||
def install_update(
|
def install_update(
|
||||||
self, update_info: resource.Diff = None, auto_repair: bool = True
|
self, update_info: resource.Diff = None, auto_repair: bool = True
|
||||||
@ -370,3 +369,4 @@ class Game(GameABC):
|
|||||||
archive_file = self._cache.joinpath(update_info.name)
|
archive_file = self._cache.joinpath(update_info.name)
|
||||||
download(update_info.path, archive_file)
|
download(update_info.path, archive_file)
|
||||||
self.apply_update_archive(archive_file=archive_file, auto_repair=auto_repair)
|
self.apply_update_archive(archive_file=archive_file, auto_repair=auto_repair)
|
||||||
|
self.set_version_config()
|
||||||
|
Loading…
Reference in New Issue
Block a user