Wrap game resource info from the server

Also add function to get the diff archive (for faster updating)

Download function soon, although I can't make sure that the download function will work properly (like pause, resume download etc.)
This commit is contained in:
2022-02-16 22:18:56 +07:00
parent 81fbdec553
commit da3ee30ab1
14 changed files with 227 additions and 84 deletions

View File

@ -3,17 +3,24 @@
import argparse
import appdirs
from pathlib import Path
import constants
from worthless.launcher import Launcher
from worthless.installer import Installer
import worthless.constants as constants
class UI:
def __init__(self, gamedir: str, noconfirm: bool) -> None:
self._noconfirm = noconfirm
self._gamedir = gamedir
self._launcher = Launcher(gamedir)
self._installer = Installer(gamedir)
def _ask(self, title, description):
raise NotImplementedError()
def get_game_version(self):
print(self._installer.get_game_version())
def install_game(self):
# TODO
raise NotImplementedError("Install game is not implemented.")
@ -38,7 +45,7 @@ def main():
help="Specify the temporary directory (default {} and {})".format(default_dirs.user_data_dir,
default_dirs.user_cache_dir))
parser.add_argument("-S", "--install", action="store_true",
help="Install the game (if not already installed, else do nothing)")
help="Install/update the game (if not already installed, else do nothing)")
parser.add_argument("-U", "--install-from-file", action="store_true",
help="Install the game from the game archive (if not already installed, \
else update from archive)")
@ -46,21 +53,28 @@ def main():
help="Patch the game (if not already patched, else do nothing)")
parser.add_argument("-Sy", "--update", action="store_true",
help="Update the game and specified voiceover pack only (or install if not found)")
parser.add_argument("-Sv", "--update-voiceover", action="store_true",
help="Update the voiceover pack only (or install if not found)")
parser.add_argument("-Syu", "--update-all", action="store_true",
help="Update the game and all installed voiceover packs (or install if not found)")
parser.add_argument("-Rs", "--remove", action="store_true", help="Remove the game (if installed)")
parser.add_argument("-Rp", "--remove-patch", action="store_true", help="Revert the game patch (if patched)")
parser.add_argument("-Rv", "--remove-voiceover", action="store_true", help="Remove a Voiceover pack (if installed)")
parser.add_argument("--get-game-version", action="store_true", help="Get the current game version")
parser.add_argument("--no-overseas", action="store_true", help="Don't use overseas server")
parser.add_argument("--noconfirm", action="store_true",
help="Do not ask any for confirmation. (Ignored in interactive mode)")
args = parser.parse_args()
interactive_mode = not args.install and not args.install_from_file and not args.patch and not args.update and not \
args.remove and not args.remove_patch and not args.remove_voiceover
args.remove and not args.remove_patch and not args.remove_voiceover and not args.get_game_version
ui = UI(args.dir, args.noconfirm)
if args.install and args.update:
raise ValueError("Cannot specify both --install and --update arguments.")
if args.get_game_version:
ui.get_game_version()
if args.install:
ui.install_game()