Add option for download only
This commit is contained in:
parent
27b1c10206
commit
d50ccc6e55
|
@ -33,7 +33,6 @@ class App(QApplication):
|
|||
def __init__(self, args):
|
||||
super(App, self).__init__(sys.argv)
|
||||
self.args = args # add some options
|
||||
|
||||
# init Legendary
|
||||
try:
|
||||
self.core = LegendaryCore()
|
||||
|
@ -50,6 +49,11 @@ class App(QApplication):
|
|||
self.core.lgd.config.add_section("Legendary")
|
||||
self.core.lgd.save_config()
|
||||
|
||||
# workaround if egl sync enabled, but no programdata path
|
||||
if self.core.egl_sync_enabled and not os.path.exists(self.core.egl.programdata_path):
|
||||
self.core.lgd.config.remove_option("Legendary", "egl-sync")
|
||||
self.core.lgd.save_config()
|
||||
|
||||
# set Application name for settings
|
||||
self.mainwindow = None
|
||||
self.setApplicationName("Rare")
|
||||
|
|
|
@ -5,6 +5,7 @@ from PyQt5.QtWidgets import QDialog, QFormLayout, QVBoxLayout, QSpinBox, QFileDi
|
|||
|
||||
from custom_legendary.core import LegendaryCore
|
||||
from rare.utils.extra_widgets import PathEdit
|
||||
from rare.utils.utils import get_size
|
||||
|
||||
|
||||
class InstallDialog(QDialog):
|
||||
|
@ -46,6 +47,10 @@ class InstallDialog(QDialog):
|
|||
self.ignore_free_space.setChecked(False)
|
||||
self.form.addRow(QLabel(self.tr("Ignore free space (Warning!)")), self.ignore_free_space)
|
||||
|
||||
self.download_only = QCheckBox()
|
||||
self.download_only.setChecked(False)
|
||||
self.form.addRow(QLabel(self.tr("Do not install game")), self.download_only)
|
||||
|
||||
self.layout.addLayout(self.form)
|
||||
|
||||
self.ok_btn = QPushButton("Next")
|
||||
|
@ -69,7 +74,11 @@ class InstallDialog(QDialog):
|
|||
return self.infos
|
||||
|
||||
def ok(self):
|
||||
self.infos = self.install_path_field.text() if not self.update_game else None, self.max_workes.value(), self.force.isChecked(), self.ignore_free_space.isChecked()
|
||||
self.infos = self.install_path_field.text() if not self.update_game else None, \
|
||||
self.max_workes.value(), \
|
||||
self.force.isChecked(), \
|
||||
self.ignore_free_space.isChecked(), \
|
||||
self.download_only.isChecked()
|
||||
self.close()
|
||||
|
||||
|
||||
|
@ -80,8 +89,7 @@ class InstallInfoDialog(QDialog):
|
|||
super(InstallInfoDialog, self).__init__()
|
||||
self.layout = QVBoxLayout()
|
||||
self.infos = QLabel(self.tr(
|
||||
"Download size: {}GB\nInstall size: {}GB").format(round(dl_size / 1024 ** 3, 2),
|
||||
round(install_size / 1024 ** 3, 2)))
|
||||
"Download size: {}\nInstall size: {}").format(get_size(dl_size), get_size(install_size)))
|
||||
self.layout.addWidget(self.infos)
|
||||
|
||||
self.btn_layout = QHBoxLayout()
|
||||
|
|
|
@ -70,11 +70,10 @@ class TabWidget(QTabWidget):
|
|||
# show uninstalled info
|
||||
self.games_tab.default_widget.game_list.show_uninstalled_info.connect(self.games_tab.show_uninstalled)
|
||||
# install dlc
|
||||
self.games_tab.game_info.dlc_tab.install_dlc.connect(self.start_download)
|
||||
self.games_tab.game_info.dlc_tab.install_dlc.connect(self.install_game)
|
||||
|
||||
# install game
|
||||
self.games_tab.uninstalled_info_widget.info.install_game.connect(self.install_game)
|
||||
|
||||
# repair game
|
||||
self.games_tab.game_info.info.verify_game.connect(lambda app_name: self.downloadTab.install_game(
|
||||
InstallOptions(app_name, core.get_installed_game(app_name).install_path, repair=True)))
|
||||
|
@ -88,12 +87,14 @@ class TabWidget(QTabWidget):
|
|||
self.tabBarClicked.connect(lambda x: self.games_tab.layout.setCurrentIndex(0) if x == 0 else None)
|
||||
self.setIconSize(QSize(25, 25))
|
||||
|
||||
def install_game(self, app_name):
|
||||
infos = InstallDialog(app_name, self.core).get_information()
|
||||
def install_game(self, app_name, disable_path=False):
|
||||
|
||||
infos = InstallDialog(app_name, self.core, disable_path).get_information()
|
||||
if infos != 0:
|
||||
path, max_workers, force, ignore_free_space = infos
|
||||
path, max_workers, force, ignore_free_space, dl_only = infos
|
||||
options = InstallOptions(app_name=app_name, max_workers=max_workers, path=path, force=force,
|
||||
ignore_free_space=ignore_free_space)
|
||||
ignore_free_space=ignore_free_space, download_only=dl_only)
|
||||
self.setCurrentIndex(1)
|
||||
self.start_download(options)
|
||||
|
||||
def start_download(self, options):
|
||||
|
|
|
@ -139,17 +139,17 @@ class DownloadTab(QWidget):
|
|||
return
|
||||
|
||||
if self.active_game is None:
|
||||
self.start_installation(dlm, game, status_queue, igame, repair_file, options, analysis)
|
||||
self.start_installation(dlm, game, status_queue, igame, repair_file, options, analysis, options.download_only)
|
||||
else:
|
||||
self.dl_queue.append((dlm, game, status_queue, igame, repair_file, options, analysis))
|
||||
self.dl_queue.append((dlm, game, status_queue, igame, repair_file, options, analysis, options.download_only))
|
||||
self.queue_widget.update_queue(self.dl_queue)
|
||||
|
||||
def start_installation(self, dlm, game, status_queue, igame, repair_file, options: InstallOptions, analysis):
|
||||
def start_installation(self, dlm, game, status_queue, igame, repair_file, options: InstallOptions, analysis, dl_only):
|
||||
if self.dl_queue:
|
||||
self.dl_queue.pop(0)
|
||||
self.queue_widget.update_queue(self.dl_queue)
|
||||
self.active_game = game
|
||||
self.thread = DownloadThread(dlm, self.core, status_queue, igame, options.repair, repair_file)
|
||||
self.thread = DownloadThread(dlm, self.core, status_queue, igame, options.repair, repair_file, dl_only)
|
||||
self.thread.status.connect(self.status)
|
||||
self.thread.statistics.connect(self.statistics)
|
||||
self.thread.start()
|
||||
|
@ -259,8 +259,8 @@ class DownloadTab(QWidget):
|
|||
|
||||
def statistics(self, ui_update: UIUpdate):
|
||||
self.prog_bar.setValue(ui_update.progress)
|
||||
self.dl_speed.setText(self.tr("Download speed") + f": {ui_update.download_speed / 1024 / 1024:.02f}MB/s")
|
||||
self.cache_used.setText(self.tr("Cache used") + f": {ui_update.cache_usage / 1024 / 1024:.02f}MB")
|
||||
self.dl_speed.setText(self.tr("Download speed") + f": {get_size(ui_update.download_speed)}/s")
|
||||
self.cache_used.setText(self.tr("Cache used") + f": {get_size(ui_update.cache_usage) if ui_update.cache_usage > 1023 else '0KB'}")
|
||||
self.downloaded.setText(
|
||||
self.tr("Downloaded") + f": {get_size(ui_update.total_downloaded)} / {get_size(self.analysis.dl_size)}")
|
||||
self.time_left.setText(self.tr("Time left: ") + self.get_time(ui_update.estimated_time_left))
|
||||
|
@ -276,9 +276,9 @@ class DownloadTab(QWidget):
|
|||
self.install_game(InstallOptions(app_name=app_name), True)
|
||||
return
|
||||
if infos != 0:
|
||||
path, max_workers, force, ignore_free_space = infos
|
||||
path, max_workers, force, ignore_free_space, dl_only = infos
|
||||
self.install_game(InstallOptions(app_name=app_name, max_workers=max_workers, path=path,
|
||||
force=force, ignore_free_space=ignore_free_space), True)
|
||||
force=force, ignore_free_space=ignore_free_space, dl_only=dl_only), True)
|
||||
else:
|
||||
self.update_widgets[app_name].update_button.setDisabled(False)
|
||||
self.update_widgets[app_name].update_with_settings.setDisabled(False)
|
||||
|
|
|
@ -23,10 +23,11 @@ class DownloadThread(QThread):
|
|||
statistics = pyqtSignal(UIUpdate)
|
||||
|
||||
def __init__(self, dlm: DLManager, core: LegendaryCore, status_queue: MPQueue, igame, repair=False,
|
||||
repair_file=None):
|
||||
repair_file=None, dl_only=False):
|
||||
super(DownloadThread, self).__init__()
|
||||
self.dlm = dlm
|
||||
self.core = core
|
||||
self.dl_only = dl_only
|
||||
self.status_queue = status_queue
|
||||
self.igame = igame
|
||||
self.repair = repair
|
||||
|
@ -120,24 +121,26 @@ class DownloadThread(QThread):
|
|||
return
|
||||
self.status.emit("dl_finished")
|
||||
end_t = time.time()
|
||||
|
||||
logger.info(f"Download finished in {start_time-end_t}s")
|
||||
game = self.core.get_game(self.igame.app_name)
|
||||
postinstall = self.core.install_game(self.igame)
|
||||
if postinstall:
|
||||
self._handle_postinstall(postinstall, self.igame)
|
||||
|
||||
dlcs = self.core.get_dlc_for_game(self.igame.app_name)
|
||||
if dlcs:
|
||||
print('The following DLCs are available for this game:')
|
||||
for dlc in dlcs:
|
||||
print(f' - {dlc.app_title} (App name: {dlc.app_name}, version: {dlc.app_version})')
|
||||
print('Manually installing DLCs works the same; just use the DLC app name instead.')
|
||||
if not self.dl_only:
|
||||
postinstall = self.core.install_game(self.igame)
|
||||
if postinstall:
|
||||
self._handle_postinstall(postinstall, self.igame)
|
||||
|
||||
# install_dlcs = QMessageBox.question(self, "", "Do you want to install the prequisites", QMessageBox.Yes|QMessageBox.No) == QMessageBox.Yes
|
||||
# TODO
|
||||
if game.supports_cloud_saves and not game.is_dlc:
|
||||
logger.info('This game supports cloud saves, syncing is handled by the "sync-saves" command.')
|
||||
logger.info(f'To download saves for this game run "legendary sync-saves {game.app_name}"')
|
||||
dlcs = self.core.get_dlc_for_game(self.igame.app_name)
|
||||
if dlcs:
|
||||
print('The following DLCs are available for this game:')
|
||||
for dlc in dlcs:
|
||||
print(f' - {dlc.app_title} (App name: {dlc.app_name}, version: {dlc.app_version})')
|
||||
print('Manually installing DLCs works the same; just use the DLC app name instead.')
|
||||
|
||||
# install_dlcs = QMessageBox.question(self, "", "Do you want to install the prequisites", QMessageBox.Yes|QMessageBox.No) == QMessageBox.Yes
|
||||
# TODO
|
||||
if game.supports_cloud_saves and not game.is_dlc:
|
||||
logger.info('This game supports cloud saves, syncing is handled by the "sync-saves" command.')
|
||||
logger.info(f'To download saves for this game run "legendary sync-saves {game.app_name}"')
|
||||
old_igame = self.core.get_installed_game(game.app_name)
|
||||
if old_igame and self.repair and os.path.exists(self.repair_file):
|
||||
if old_igame.needs_verification:
|
||||
|
|
|
@ -6,13 +6,11 @@ from PyQt5.QtWidgets import QGroupBox, QHBoxLayout, QVBoxLayout, QScrollArea, QL
|
|||
|
||||
from custom_legendary.core import LegendaryCore
|
||||
from custom_legendary.models.game import Game
|
||||
from rare.components.dialogs.install_dialog import InstallDialog
|
||||
from rare.utils.models import InstallOptions
|
||||
from rare.utils.utils import download_image
|
||||
|
||||
|
||||
class DlcTab(QScrollArea):
|
||||
install_dlc = pyqtSignal(InstallOptions)
|
||||
install_dlc = pyqtSignal(str, bool)
|
||||
game: Game
|
||||
|
||||
def __init__(self, core: LegendaryCore, parent):
|
||||
|
@ -74,12 +72,7 @@ class DlcTab(QScrollArea):
|
|||
QMessageBox.warning(self, "Error", self.tr("Base Game is not installed. Please install {} first").format(
|
||||
self.game.app_title))
|
||||
return
|
||||
infos = InstallDialog(self.game.app_name, self.core, True).get_information()
|
||||
if infos != 0:
|
||||
path, max_workers, force, ignore_free_space = infos
|
||||
self.install_dlc.emit(
|
||||
InstallOptions(app_name=app_name, max_workers=max_workers, path=path, force=force,
|
||||
ignore_free_space=ignore_free_space))
|
||||
self.install_dlc.emit(app_name, True)
|
||||
|
||||
|
||||
class DLCWidget(QGroupBox):
|
||||
|
|
|
@ -93,7 +93,6 @@ class UninstalledInfo(QWidget):
|
|||
self.right_layout.addWidget(self.install_button)
|
||||
self.version = QLabel("Error")
|
||||
self.right_layout.addWidget(self.version)
|
||||
|
||||
self.right_layout.addStretch(1)
|
||||
self.top_layout.addLayout(self.right_layout)
|
||||
|
||||
|
@ -125,8 +124,10 @@ class UninstalledInfo(QWidget):
|
|||
self.image.setPixmap(pixmap)
|
||||
|
||||
self.version.setText(self.game.asset_info.build_version)
|
||||
|
||||
rating = self.grade_table[app_name]["grade"]
|
||||
try:
|
||||
rating = self.grade_table[app_name]["grade"]
|
||||
except KeyError:
|
||||
rating = "fail"
|
||||
if rating not in ["fail", "pending"]:
|
||||
self.rating.setText(self.tr("Rating from ProtonDB: ") + self.ratings[rating])
|
||||
else:
|
||||
|
|
|
@ -3,8 +3,6 @@ from logging import getLogger
|
|||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtWidgets import QGroupBox
|
||||
|
||||
from rare.components.dialogs.install_dialog import InstallDialog
|
||||
from rare.utils.models import InstallOptions
|
||||
|
||||
logger = getLogger("Uninstalled")
|
||||
|
||||
|
@ -23,11 +21,3 @@ class BaseUninstalledWidget(QGroupBox):
|
|||
|
||||
def install(self):
|
||||
self.show_uninstalled_info.emit(self.game.app_name)
|
||||
|
||||
def installl(self):
|
||||
infos = InstallDialog(self.game.app_name, self.core).get_information()
|
||||
if infos != 0:
|
||||
path, max_workers, force, ignore_free_space = infos
|
||||
self.show_uninstalled_info.emit(
|
||||
InstallOptions(app_name=self.game.app_name, max_workers=max_workers, path=path, force=force,
|
||||
ignore_free_space=ignore_free_space))
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,8 @@ import os
|
|||
class InstallOptions:
|
||||
def __init__(self, app_name: str, path: str = os.path.expanduser("~/legendary"),
|
||||
max_workers: int = os.cpu_count() * 2, repair: bool = False,
|
||||
download_only: bool = False, ignore_free_space: bool = False, force: bool = False):
|
||||
download_only: bool = False, ignore_free_space: bool = False, force: bool = False,
|
||||
):
|
||||
self.app_name = app_name
|
||||
self.path = path
|
||||
self.max_workers = max_workers
|
||||
|
@ -12,4 +13,3 @@ class InstallOptions:
|
|||
self.download_only = download_only
|
||||
self.ignore_free_space = ignore_free_space
|
||||
self.force = force
|
||||
|
||||
|
|
Loading…
Reference in a new issue