1
0
Fork 0
mirror of synced 2024-06-02 10:44:40 +12:00

Cloud saves basics(date bug), Download Tab update, in progress

This commit is contained in:
Dummerle 2021-02-28 12:06:33 +01:00
parent d77808ee05
commit 6a55ebed2c
5 changed files with 63 additions and 16 deletions

View file

@ -13,24 +13,28 @@ from Rare.Components.Tabs.Settings.SettingsTab import SettingsTab
class TabWidget(QTabWidget):
def __init__(self, core: LegendaryCore):
super(TabWidget, self).__init__()
self.setTabBar(TabBar(3))
disabled_tab = 2
self.setTabBar(TabBar(disabled_tab))
self.settings = SettingsTab(core)
self.game_list = GameTab(core)
updates = self.game_list.default_widget.game_list.updates
self.addTab(self.game_list, self.tr("Games"))
self.downloadTab = DownloadTab(core)
self.downloadTab = DownloadTab(core, updates)
self.addTab(self.downloadTab, "Downloads")
self.downloadTab.finished.connect(self.game_list.default_widget.game_list.update_list)
self.game_list.default_widget.game_list.install_game.connect(lambda x: self.downloadTab.install_game(x))
self.cloud_saves = SyncSaves(core)
self.addTab(self.cloud_saves, "Cloud Saves")
# Commented, because it is not finished
#self.cloud_saves = SyncSaves(core)
#self.addTab(self.cloud_saves, "Cloud Saves")
# Space Tab
self.addTab(QWidget(), "")
self.setTabEnabled(3, False)
self.setTabEnabled(disabled_tab, False)
self.account = QWidget()
self.addTab(self.account, "")
self.setTabEnabled(4, False)
self.setTabEnabled(disabled_tab+1, False)
# self.settings = SettingsTab(core)
self.addTab(self.settings, QIcon(style_path + "/Icons/settings.png"), None)

View file

@ -60,7 +60,8 @@ class SyncSaves(QScrollArea):
logger.info(f'Got {len(latest_save)} remote save game(s)')
if len(latest_save) == 0:
QMessageBox.information(self.tr("No Games Found"), self.tr("Your games don't support cloud save"))
self.close()
self.widget = QLabel("No Games found, supporting cloud saves")
self.setWidget(self.widget)
return
self.widgets = []

View file

@ -4,7 +4,7 @@ import time
from logging import getLogger
from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtWidgets import QWidget, QMessageBox, QVBoxLayout, QLabel, QGridLayout, QProgressBar
from PyQt5.QtWidgets import QWidget, QMessageBox, QVBoxLayout, QLabel, QGridLayout, QProgressBar, QPushButton
from legendary.core import LegendaryCore
from legendary.models.game import Game
from notifypy import Notify
@ -78,7 +78,7 @@ class DownloadTab(QWidget):
finished = pyqtSignal()
thread: QThread
def __init__(self, core: LegendaryCore):
def __init__(self, core: LegendaryCore, updates: list):
super(DownloadTab, self).__init__()
self.core = core
self.layout = QVBoxLayout()
@ -99,13 +99,32 @@ class DownloadTab(QWidget):
self.layout.addLayout(self.info_layout)
self.prog_bar = QProgressBar()
self.layout.addWidget(self.prog_bar)
self.layout.addWidget(QLabel(
"WARNING: This feature is not implemented. It is normal, if there is no progress. The progress is in console"))
label = QLabel(
"<b>WARNING</b>: The progress bar is not implemented. It is normal, if there is no progress. The "
"progress is visible in console, because Legendary prints output to console. A pull request is active to "
"get output")
label.setWordWrap(True)
self.layout.addWidget(label)
self.installing_game_widget = QLabel("No active Download")
self.layout.addWidget(self.installing_game_widget)
self.update_title = QLabel("<h2>Updates</h2>")
self.update_title.setStyleSheet("""
QLabel{
margin-top: 20px;
}
""")
self.layout.addWidget(self.update_title)
if not updates:
self.update_text = QLabel("No updates available")
self.layout.addWidget(self.update_text)
else:
for i in updates:
widget = UpdateWidget(core, i)
self.layout.addWidget(widget)
widget.update.connect(self.update_game)
self.layout.addStretch(1)
self.setLayout(self.layout)
@ -159,3 +178,22 @@ class DownloadTab(QWidget):
def update_game(self, app_name: str):
print("Update ", app_name)
class UpdateWidget(QWidget):
update = pyqtSignal(str)
def __init__(self, core: LegendaryCore, app_name):
super(UpdateWidget, self).__init__()
self.core = core
self.game = core.get_installed_game(app_name)
self.layout = QVBoxLayout()
self.title = QLabel(self.game.title)
self.layout.addWidget(self.title)
self.update_button = QPushButton("Update Game")
self.update_button.clicked.connect(lambda :self.update.emit(app_name))
self.layout.addWidget(self.update_button)
self.setLayout(self.layout)

View file

@ -26,12 +26,15 @@ class GameList(QScrollArea):
self.widget = QWidget()
self.widgets = []
self.layout = FlowLayout()
self.updates = []
# Installed Games
for game in sorted(self.core.get_installed_list(), key=lambda x: x.title):
# continue
widget = GameWidgetInstalled(self.core, game)
if widget.update_available:
self.updates.append(widget.game.app_name)
self.layout.addWidget(widget)
widget.update_list.connect(self.update_list)
widget.show_info.connect(lambda app_name: self.show_game_info.emit(app_name))
uninstalled_games = []

View file

@ -26,12 +26,13 @@ class GameWidgetInstalled(QWidget):
self.game = game
self.running = False
settings = QSettings()
self.info_text = ""
self.IMAGE_DIR = settings.value("img_dir", os.path.expanduser("~/.cache/rare"))
self.update_available = self.core.get_asset(self.game.app_name, True).build_version != game.version
if self.update_available:
logger.info("Update available for game: " + self.game.app_name)
self.info_text = "Update available"
if os.path.exists(f"{self.IMAGE_DIR}/{game.app_name}/FinalArt.png"):
pixmap = QPixmap(f"{self.IMAGE_DIR}/{game.app_name}/FinalArt.png")
@ -70,7 +71,7 @@ class GameWidgetInstalled(QWidget):
minilayout.addStretch(1)
self.layout.addLayout(minilayout)
self.info_label = QLabel("")
self.info_label = QLabel(self.info_text)
self.info_label.setObjectName("info_label")
self.layout.addWidget(self.info_label)
@ -82,7 +83,7 @@ class GameWidgetInstalled(QWidget):
self.info_label.setText("Start Game")
def leaveEvent(self, a0: QEvent) -> None:
self.info_label.setText("")
self.info_label.setText(self.info_text)
def mousePressEvent(self, a0) -> None:
self.launch()