Skip to content

Commit

Permalink
Use Custom legendary version, cloud saves bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Dummerle committed Mar 16, 2021
1 parent f7dc0cf commit 90b7d10
Show file tree
Hide file tree
Showing 53 changed files with 122 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Rare/Components/Dialogs/Login/BrowserLogin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QLabel, QLineEdit
from legendary.core import LegendaryCore
from custom_legendary.core import LegendaryCore

logger = getLogger("BrowserLogin")

Expand Down
2 changes: 1 addition & 1 deletion Rare/Components/Dialogs/Login/ImportWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QLabel, QButtonGroup, QRadioButton
from legendary.core import LegendaryCore
from custom_legendary.core import LegendaryCore

logger = getLogger("Import")

Expand Down
2 changes: 1 addition & 1 deletion Rare/Components/Dialogs/Login/LoginDialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QStackedLayout, QWidget, QPushButton
from legendary.core import LegendaryCore
from custom_legendary.core import LegendaryCore

# Login Opportunities: Browser, Import
from Rare.Components.Dialogs.Login.BrowserLogin import BrowserLogin
Expand Down
10 changes: 5 additions & 5 deletions Rare/Components/Launch/LaunchDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtWidgets import QDialog, QLabel, QProgressBar, QVBoxLayout
from legendary.core import LegendaryCore
from custom_legendary.core import LegendaryCore

from Rare.Components.Dialogs.Login.LoginDialog import LoginDialog
from Rare.utils.utils import download_images
Expand All @@ -27,7 +27,7 @@ def run(self):

class LoginThread(QThread):
login = pyqtSignal()
start_app = pyqtSignal(LegendaryCore)
start_app = pyqtSignal()

def __init__(self, core: LegendaryCore):
super(LoginThread, self).__init__()
Expand All @@ -38,7 +38,7 @@ def run(self):
try:
if self.core.login():
logger.info("You are logged in")
self.start_app.emit(self.core)
self.start_app.emit()
else:
self.run()
except ValueError:
Expand Down Expand Up @@ -72,8 +72,8 @@ def login(self):
else:
exit(0)

def launch(self, core: LegendaryCore):
self.core = core
def launch(self):
#self.core = core
self.info_pb.setMaximum(len(self.core.get_game_list()))
self.info_text.setText(self.tr("Downloading Images"))
self.thread = LaunchThread(self.core, self)
Expand Down
2 changes: 1 addition & 1 deletion Rare/Components/TabWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QTabWidget, QTabBar, QWidget, QToolButton, QWidgetAction, QMenu
from Rare.Components.Tabs.CloudSaves.CloudSaves import SyncSaves
from legendary.core import LegendaryCore
from custom_legendary.core import LegendaryCore
from qtawesome import icon

# from Rare.Components.Tabs.Account.AccountWidget import MiniWidget
Expand Down
2 changes: 1 addition & 1 deletion Rare/Components/Tabs/Account/AccountWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from PyQt5.QtCore import QCoreApplication
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QMessageBox, QLabel, QPushButton
from legendary.core import LegendaryCore
from custom_legendary.core import LegendaryCore


class MiniWidget(QWidget):
Expand Down
4 changes: 2 additions & 2 deletions Rare/Components/Tabs/CloudSaves/CloudSaves.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from PyQt5.QtCore import QThread, pyqtSignal, Qt
from PyQt5.QtWidgets import *
from legendary.core import LegendaryCore
from legendary.models.game import SaveGameStatus
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import SaveGameStatus

from Rare.Components.Dialogs.PathInputDialog import PathInputDialog
from Rare.Components.Tabs.CloudSaves.SyncWidget import SyncWidget
Expand Down
10 changes: 7 additions & 3 deletions Rare/Components/Tabs/CloudSaves/SyncWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QHBoxLayout, QLabel
from legendary.core import LegendaryCore
from legendary.models.game import InstalledGame, SaveGameStatus

from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import InstalledGame, SaveGameStatus


class _UploadThread(QThread):
Expand Down Expand Up @@ -48,7 +48,11 @@ def __init__(self, igame: InstalledGame, save, core: LegendaryCore):
self.igame = igame
self.has_save_path = True
if not igame.save_path:
save_path = self.core.get_save_path(igame.app_name)
try:
save_path = self.core.get_save_path(igame.app_name)
except Exception as e:
self.logger.error(e)
return
if '%' in save_path or '{' in save_path:
status = self.tr("Path not found")
self.logger.info("Could not find save path")
Expand Down
104 changes: 71 additions & 33 deletions Rare/Components/Tabs/Downloads/DownloadTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@
from logging import getLogger
from multiprocessing import Queue as MPQueue

from PyQt5.QtCore import QThread, pyqtSignal, Qt, QVariant
from PyQt5.QtWidgets import QWidget, QMessageBox, QVBoxLayout, QLabel, QGridLayout, QProgressBar, QPushButton, QDialog, QListWidget
from PyQt5.QtCore import QThread, pyqtSignal, Qt
from PyQt5.QtWidgets import QWidget, QMessageBox, QVBoxLayout, QLabel, QGridLayout, QProgressBar, QPushButton, QDialog, \
QListWidget, QHBoxLayout

from legendary.core import LegendaryCore
from legendary.models.game import Game
from legendary.models.downloading import UIUpdate
from legendary.utils.selective_dl import games


from custom_legendary.core import LegendaryCore
from custom_legendary.downloader.manager import DLManager
from custom_legendary.models.downloading import UIUpdate
from custom_legendary.models.game import Game
from custom_legendary.utils.selective_dl import games

from Rare.Components.Dialogs.InstallDialog import InstallInfoDialog
from Rare.utils.LegendaryApi import VerifyThread
from Rare.utils.Models import InstallOptions
from Rare.utils.Models import InstallOptions, KillDownloadException

logger = getLogger("Download")


class DownloadThread(QThread):
status = pyqtSignal(str)
statistics = pyqtSignal(UIUpdate)
kill = False

def __init__(self, dlm, core: LegendaryCore, status_queue: MPQueue, igame, repair=False, repair_file=None):
def __init__(self, dlm: DLManager, core: LegendaryCore, status_queue: MPQueue, igame, repair=False,
repair_file=None):
super(DownloadThread, self).__init__()
self.dlm = dlm
self.core = core
Expand All @@ -40,11 +45,23 @@ def run(self):
self.dlm.start()
time.sleep(1)
while self.dlm.is_alive():
if self.kill:
#raise KillDownloadException()
# TODO kill download queue, workers
pass
try:
self.statistics.emit(self.status_queue.get(timeout=0.1))
self.statistics.emit(self.status_queue.get(timeout=1))
except queue.Empty:
pass

self.dlm.join()

except KillDownloadException:
self.status.emit("stop")
logger.info("Downlaod can be continued later")
self.dlm.kill()
return

except Exception as e:
logger.error(f"Installation failed after {time.time() - start_time:.02f} seconds: {e}")
self.status.emit("error")
Expand Down Expand Up @@ -128,9 +145,18 @@ def __init__(self, core: LegendaryCore, updates: list):
self.info_layout.addWidget(self.downloaded, 1, 1)
self.layout.addLayout(self.info_layout)

self.mini_layout = QHBoxLayout()

self.prog_bar = QProgressBar()
self.prog_bar.setMaximum(100)
self.layout.addWidget(self.prog_bar)
self.mini_layout.addWidget(self.prog_bar)

self.kill_button = QPushButton(self.tr("Stop Download"))
# self.mini_layout.addWidget(self.kill_button)
self.kill_button.setDisabled(True)
self.kill_button.clicked.connect(self.stop_download)

self.layout.addLayout(self.mini_layout)

self.installing_game_widget = QLabel(self.tr("No active Download"))
self.layout.addWidget(self.installing_game_widget)
Expand All @@ -155,35 +181,38 @@ def __init__(self, core: LegendaryCore, updates: list):

self.setLayout(self.layout)

def stop_download(self):
self.thread.kill = True

def install_game(self, options: InstallOptions):
game = self.core.get_game(options.app_name, update_meta=True)
status_queue = MPQueue()
try:
dlm, analysis, game, igame, repair, repair_file = self.core.prepare_download(
app_name=options.app_name,
base_path=options.path,
force=False, # TODO allow overwrite
force=False, # TODO allow overwrite
no_install=options.download_only,
status_q=status_queue,
#max_shm=,
# max_shm=,
max_workers=options.max_workers,
#game_folder=,
#disable_patching=,
#override_manifest=,
#override_old_manifest=,
#override_base_url=,
#platform_override=,
#file_prefix_filter=,
#file_exclude_filter=,
#file_install_tag=,
#dl_optimizations=,
#dl_timeout=,
# game_folder=,
# disable_patching=,
# override_manifest=,
# override_old_manifest=,
# override_base_url=,
# platform_override=,
# file_prefix_filter=,
# file_exclude_filter=,
# file_install_tag=,
# dl_optimizations=,
# dl_timeout=,
repair=options.repair,
#repair_use_latest=,
#ignore_space_req=,
#disable_delta=,
#override_delta_manifest=,
#reset_sdl=,
# repair_use_latest=,
# ignore_space_req=,
# disable_delta=,
# override_delta_manifest=,
# reset_sdl=,
sdl_prompt=self.sdl_prompt)
except Exception as e:
QMessageBox.warning(self, self.tr("Error preparing download"),
Expand All @@ -202,6 +231,7 @@ def install_game(self, options: InstallOptions):
self.thread.status.connect(self.status)
self.thread.statistics.connect(self.statistics)
self.thread.start()
self.kill_button.setDisabled(False)
self.installing_game.setText("Installing Game: " + self.active_game.app_title)

def sdl_prompt(self, app_name: str = '', title: str = '') -> list:
Expand All @@ -223,7 +253,7 @@ def sdl_prompt(self, app_name: str = '', title: str = '') -> list:
tags.extend(games[app_name]['__required']['tags'])

# add available additional downloads to list
pack_list.addItems([ tag + ': ' + info['name'] for tag, info in games[app_name].items() if tag != '__required' ])
pack_list.addItems([tag + ': ' + info['name'] for tag, info in games[app_name].items() if tag != '__required'])

# enable checkboxes
for i in range(len(pack_list)):
Expand Down Expand Up @@ -265,11 +295,19 @@ def status(self, text):
elif text == "error":
QMessageBox.warning(self, "warn", "Download error")

elif text == "stop":
self.kill_button.setDisabled(True)
self.installing_game.setText(self.tr("Installing Game: No active download"))
self.prog_bar.setValue(0)
self.dl_speed.setText("")
self.cache_used.setText("")
self.downloaded.setText("")

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.downloaded.setText(self.tr("Downloaded") + f": {ui_update.total_downloaded/1024/1024:.02f}MB")
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.downloaded.setText(self.tr("Downloaded") + f": {ui_update.total_downloaded / 1024 / 1024:.02f}MB")

def update_game(self, app_name: str):
print("Update ", app_name)
Expand Down
4 changes: 2 additions & 2 deletions Rare/Components/Tabs/Games/GameInfo/GameInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from PyQt5.QtGui import QPixmap, QKeyEvent
from PyQt5.QtWidgets import QWidget, QPushButton, QVBoxLayout, QLabel, QHBoxLayout, QTabWidget, QMessageBox, \
QProgressBar, QStackedWidget
from legendary.core import LegendaryCore
from legendary.models.game import InstalledGame, Game
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import InstalledGame, Game
from qtawesome import icon

from Rare.Components.Tabs.Games.GameInfo.GameSettings import GameSettings
Expand Down
4 changes: 2 additions & 2 deletions Rare/Components/Tabs/Games/GameInfo/GameSettings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout, QComboBox, QFileDialog, QPushButton, QMessageBox
from legendary.core import LegendaryCore
from legendary.models.game import InstalledGame, Game
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import InstalledGame, Game

from Rare.Components.Tabs.Settings.Linux import LinuxSettings
from Rare.Components.Tabs.Settings.SettingsWidget import SettingsWidget
Expand Down
4 changes: 2 additions & 2 deletions Rare/Components/Tabs/Games/GameList.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PyQt5.QtCore import Qt, pyqtSignal, QSettings
from PyQt5.QtWidgets import *
from legendary.core import LegendaryCore
from custom_legendary.core import LegendaryCore

from Rare.Components.Tabs.Games.GameWidgetInstalled import GameWidgetInstalled
from Rare.Components.Tabs.Games.GameWidgetListUninstalled import UninstalledGameWidget
Expand Down Expand Up @@ -46,7 +46,7 @@ def init_ui(self, icon_view=True):
widget = GameWidget(game, self.core)
if widget.update_available:
self.updates.append(widget.game.app_name)
widget.update_game.connect(self.update_game.emit)
widget.update_game.connect(lambda: self.update_game.emit())
self.layout.addWidget(widget)
widget.update_list.connect(self.update_list)

Expand Down
4 changes: 2 additions & 2 deletions Rare/Components/Tabs/Games/GameWidgetInstalled.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from PyQt5.QtCore import QEvent, pyqtSignal, QSettings, QSize, Qt
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import *
from legendary.core import LegendaryCore
from legendary.models.game import InstalledGame
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import InstalledGame
from qtawesome import icon

from Rare.utils import LegendaryApi
Expand Down
7 changes: 3 additions & 4 deletions Rare/Components/Tabs/Games/GameWidgetListUninstalled.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
import subprocess
from logging import getLogger

from PyQt5.QtCore import QThread, pyqtSignal, QProcess, QSettings
from PyQt5.QtCore import pyqtSignal, QSettings
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QVBoxLayout, QPushButton, QMessageBox
from legendary.core import LegendaryCore
from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QVBoxLayout, QPushButton

from Rare.Components.Dialogs.InstallDialog import InstallDialog
from Rare.utils.Models import InstallOptions
from custom_legendary.core import LegendaryCore

logger = getLogger("Game")

Expand Down
4 changes: 2 additions & 2 deletions Rare/Components/Tabs/Games/GameWidgetUninstalled.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from PyQt5.QtCore import pyqtSignal, QSettings
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel
from legendary.core import LegendaryCore
from legendary.models.game import Game
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import Game

from Rare.Components.Dialogs.InstallDialog import InstallDialog
from Rare.utils.Models import InstallOptions
Expand Down
5 changes: 3 additions & 2 deletions Rare/Components/Tabs/Games/InstalledListWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from PyQt5.QtCore import QProcess, pyqtSignal, QSettings
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QPushButton, QStyle, QVBoxLayout
from legendary.core import LegendaryCore
from legendary.models.game import InstalledGame
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import InstalledGame

from Rare.utils import LegendaryApi

Expand All @@ -16,6 +16,7 @@ class GameWidget(QWidget):
proc: QProcess
signal = pyqtSignal(str)
update_list = pyqtSignal()
update_game = pyqtSignal()

# TODO Repair
def __init__(self, game: InstalledGame, core: LegendaryCore):
Expand Down
Loading

0 comments on commit 90b7d10

Please sign in to comment.