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

Many fixes, optimizations and improvements: Gameinfo page for origin games

This commit is contained in:
Dummerle 2021-09-15 22:16:50 +02:00
parent b951c1af5f
commit ffa5976805
14 changed files with 176 additions and 103 deletions

View file

@ -35,6 +35,11 @@ jobs:
sudo apt install python3-all python3-stdeb dh-python python3-setuptools python3-wheel
sudo pip install -r requirements.txt
run: |
git submodule init
git submodule update
python legendary/setup.py install
- name: run python setup
run: |
python3 setup.py sdist
@ -53,7 +58,6 @@ jobs:
overwrite: true
appimage:
if: "!github.event.release.prerelease"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
@ -67,6 +71,12 @@ jobs:
sudo wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /usr/local/bin/appimagetool
sudo chmod +x /usr/local/bin/appimagetool
sudo pip3 install appimage-builder
- name: Setup Submodule
run: |
git submodule init
git submodule update
python legendary/setup.py install
- name: Prepare Build directory
run: |
mkdir build
@ -102,6 +112,13 @@ jobs:
- name: cx_freeze
run: pip3 install --upgrade cx_freeze wheel
- name: Init Legendary
run: |
git submodule init
git submodule update
python legendary/setup.py install
- name: Build
run: python freeze.py bdist_msi

View file

@ -74,6 +74,10 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Setup Submodule
run: |
git submodule init
git submodule update
- name: Install dependencies
run: |
python -m pip install --upgrade pip
@ -84,3 +88,62 @@ jobs:
run: |
pylint -E rare --disable=E0611 --ignore=ui,singleton.py --extension-pkg-whitelist=PyQt5
appimage:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: install Deps
run: |
sudo apt update
sudo apt install python3 python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse
- name: install appimage-builder
run: |
sudo wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /usr/local/bin/appimagetool
sudo chmod +x /usr/local/bin/appimagetool
sudo pip3 install appimage-builder
- name: Init Submodule
run: |
git submodule init
git submodule update
python legendary/setup.py install
- name: Prepare Build directory
run: |
mkdir build
cp AppImageBuilder.yml build/
cd build
- name: Build Appimage
run: |
appimage-builder --skip-test
mv Rare-*.AppImage Rare.AppImage
cx_freeze:
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Dependencies
run: pip3 install -r requirements.txt
- name: cx_freeze
run: pip3 install --upgrade cx_freeze wheel
- name: Init Legendary
run: |
git submodule init
git submodule update
python legendary/setup.py install
- name: Build
run: python freeze.py bdist_msi
- name: Rename File
run: mv dist/* dist/Rare.msi

View file

@ -117,7 +117,7 @@ class TabWidget(QTabWidget):
def mouse_clicked(self, tab_num):
if tab_num == 0:
self.games_tab.layout.setCurrentIndex(0)
self.games_tab.layout().setCurrentIndex(0)
if tab_num == 3:
self.store.load()

View file

@ -95,7 +95,7 @@ class SyncWidget(QGroupBox):
self.res, (self.dt_local, dt_remote) = self.core.check_savegame_state(igame.save_path, save)
if self.res == SaveGameStatus.NO_SAVE:
self.logger.info('No cloud or local savegame found.')
self.logger.debug('No cloud or local savegame found.')
return
# game_title = QLabel(f"<h2>{igame.title}</h2>")
@ -111,7 +111,7 @@ class SyncWidget(QGroupBox):
cloud_save_date = QLabel(self.tr("No Cloud saves"))
if self.res == SaveGameStatus.SAME_AGE:
self.logger.info(f'Save game for "{igame.title}" is up to date')
self.logger.debug(f'Save game for "{igame.title}" is up to date')
status = self.tr("Game is up to date")
self.upload_button = QPushButton(self.tr("Upload anyway"))
self.download_button = QPushButton(self.tr("Download anyway"))
@ -120,12 +120,12 @@ class SyncWidget(QGroupBox):
self.download_button = QPushButton(self.tr("Download Cloud saves"))
self.download_button.setObjectName("success")
self.upload_button = QPushButton(self.tr("Upload Saves"))
self.logger.info(f'Cloud save for "{igame.title}" is newer:')
self.logger.info(f'- Cloud save date: {dt_remote.strftime("%Y-%m-%d %H:%M:%S")}')
self.logger.debug(f'Cloud save for "{igame.title}" is newer:')
self.logger.debug(f'- Cloud save date: {dt_remote.strftime("%Y-%m-%d %H:%M:%S")}')
if self.dt_local:
self.logger.info(f'- Local save date: {self.dt_local.strftime("%Y-%m-%d %H:%M:%S")}')
self.logger.debug(f'- Local save date: {self.dt_local.strftime("%Y-%m-%d %H:%M:%S")}')
else:
self.logger.info('- Local save date: N/A')
self.logger.debug('- Local save date: N/A')
self.upload_button.setDisabled(True)
self.upload_button.setToolTip("No local save")
@ -136,11 +136,11 @@ class SyncWidget(QGroupBox):
self.download_button = QPushButton(self.tr("Download saves"))
self.logger.info(f'Local save for "{igame.title}" is newer')
if dt_remote:
self.logger.info(f'- Cloud save date: {dt_remote.strftime("%Y-%m-%d %H:%M:%S")}')
self.logger.debug(f'- Cloud save date: {dt_remote.strftime("%Y-%m-%d %H:%M:%S")}')
else:
self.logger.info('- Cloud save date: N/A')
self.logger.debug('- Cloud save date: N/A')
self.download_button.setDisabled(True)
self.logger.info(f'- Local save date: {self.dt_local.strftime("%Y-%m-%d %H:%M:%S")}')
self.logger.debug(f'- Local save date: {self.dt_local.strftime("%Y-%m-%d %H:%M:%S")}')
else:
self.logger.error(self.res)
return

View file

@ -69,7 +69,7 @@ class DlQueueWidget(QGroupBox):
self.layout().addWidget(self.text)
def update_queue(self, dl_queue: list):
logger.info("Update Queue " + ", ".join(i.download.game.app_title for i in dl_queue))
logger.debug("Update Queue " + ", ".join(i.download.game.app_title for i in dl_queue))
self.dl_queue = dl_queue
for item in (self.layout().itemAt(i) for i in range(self.layout().count())):
@ -122,7 +122,7 @@ class DlQueueWidget(QGroupBox):
index = i
break
else:
logger.warning("Could not find appname" + app_name)
logger.warning("infoCould not find appname" + app_name)
return
self.dl_queue.insert(index + 1, self.dl_queue.pop(index))
self.update_list.emit(self.dl_queue)

View file

@ -14,49 +14,47 @@ from rare.utils.extra_widgets import SelectViewWidget
class GameTab(QWidget):
def __init__(self, core, parent, offline):
super(GameTab, self).__init__(parent=parent)
self.layout = QStackedLayout()
self.setLayout(QStackedLayout())
self.default_widget = Games(core, self, offline)
# Signal to show info
self.default_widget.game_list.show_game_info.connect(self.show_info)
self.default_widget.head_bar.import_game.clicked.connect(lambda: self.layout.setCurrentIndex(2))
self.layout.addWidget(self.default_widget)
self.default_widget.head_bar.import_game.clicked.connect(lambda: self.layout().setCurrentIndex(2))
self.layout().addWidget(self.default_widget)
self.game_info = InfoTabs(core, self)
self.game_info.info.update_list.connect(self.update_list)
self.layout.addWidget(self.game_info)
self.layout().addWidget(self.game_info)
self.default_widget.head_bar.refresh_list.clicked.connect(self.update_list)
self.import_widget = ImportWidget(core, self)
self.layout.addWidget(self.import_widget)
self.import_widget.back_button.clicked.connect(lambda: self.layout.setCurrentIndex(0))
self.layout().addWidget(self.import_widget)
self.import_widget.back_button.clicked.connect(lambda: self.layout().setCurrentIndex(0))
self.import_widget.update_list.connect(self.update_list)
self.uninstalled_info_widget = UninstalledTabInfo(core, self)
self.layout.addWidget(self.uninstalled_info_widget)
# self.uninstalled_info_widget.back.clicked.connect(lambda: self.layout.setCurrentIndex(0))
self.setLayout(self.layout)
self.layout().addWidget(self.uninstalled_info_widget)
# self.uninstalled_info_widget.back.clicked.connect(lambda: self.layout().setCurrentIndex(0))
def update_list(self, app_name=None):
self.default_widget.game_list.update_list(app_name)
self.layout.setCurrentIndex(0)
self.layout().setCurrentIndex(0)
def show_uninstalled(self, game: Game):
self.uninstalled_info_widget.update_game(game)
self.uninstalled_info_widget.setCurrentIndex(1)
self.layout.setCurrentIndex(3)
self.layout().setCurrentIndex(3)
def show_info(self, app_name):
self.game_info.update_game(app_name, self.default_widget.game_list.dlcs)
def show_info(self, game: Game):
self.game_info.update_game(game, self.default_widget.game_list.dlcs)
self.game_info.setCurrentIndex(1)
self.layout.setCurrentIndex(1)
self.layout().setCurrentIndex(1)
class Games(QWidget):
def __init__(self, core, parent, offline):
super(Games, self).__init__(parent=parent)
self.layout = QVBoxLayout()
self.setLayout(QVBoxLayout())
self.head_bar = GameListHeadBar(self)
self.head_bar.setObjectName("head_bar")
@ -68,12 +66,11 @@ class Games(QWidget):
self.head_bar.filter_changed_signal.connect(self.game_list.filter)
self.head_bar.filter_changed(self.head_bar.filter.currentIndex())
self.layout.addWidget(self.head_bar)
self.layout.addWidget(self.game_list)
# self.layout.addStretch(1)
self.layout().addWidget(self.head_bar)
self.layout().addWidget(self.game_list)
# self.layout().addStretch(1)
self.head_bar.view.toggled.connect(self.toggle_view)
self.setLayout(self.layout)
def toggle_view(self):
self.game_list.setCurrentIndex(1 if self.head_bar.view.isChecked() else 0)
@ -86,7 +83,7 @@ class GameListHeadBar(QWidget):
def __init__(self, parent):
super(GameListHeadBar, self).__init__(parent=parent)
self.layout = QHBoxLayout()
self.setLayout(QHBoxLayout())
# self.installed_only = QCheckBox(self.tr("Installed only"))
self.settings = QSettings()
# self.installed_only.setChecked(self.settings.value("installed_only", False, bool))
@ -97,8 +94,8 @@ class GameListHeadBar(QWidget):
self.tr("Installed only"),
self.tr("Offline Games"),
self.tr("32 Bit Games"),
self.tr("Installable Games")])
self.layout.addWidget(self.filter)
self.tr("Exclude Origin")])
self.layout().addWidget(self.filter)
try:
self.filter.setCurrentIndex(self.settings.value("filter", 0, int))
@ -106,34 +103,32 @@ class GameListHeadBar(QWidget):
self.settings.setValue("filter", 0)
self.filter.currentIndexChanged.connect(self.filter_changed)
self.layout.addStretch(1)
self.layout().addStretch(1)
self.import_game = QPushButton(icon("mdi.import"), self.tr("Import Game"))
self.layout.addWidget(self.import_game)
self.layout().addWidget(self.import_game)
self.layout.addStretch(1)
self.layout().addStretch(1)
self.search_bar = QLineEdit()
self.search_bar.setObjectName("search_bar")
self.search_bar.setFrame(False)
icon_label = QLabel()
icon_label.setPixmap(icon("fa.search").pixmap(QSize(20, 20)))
self.layout.addWidget(icon_label)
self.layout().addWidget(icon_label)
self.search_bar.setMinimumWidth(200)
self.search_bar.setPlaceholderText(self.tr("Search Game"))
self.layout.addWidget(self.search_bar)
self.layout().addWidget(self.search_bar)
self.layout.addStretch(2)
self.layout().addStretch(2)
checked = QSettings().value("icon_view", True, bool)
self.view = SelectViewWidget(checked)
self.layout.addWidget(self.view)
self.layout.addStretch(1)
self.layout().addWidget(self.view)
self.layout().addStretch(1)
self.refresh_list = QPushButton()
self.refresh_list.setIcon(icon("fa.refresh")) # Reload icon
self.layout.addWidget(self.refresh_list)
self.setLayout(self.layout)
self.layout().addWidget(self.refresh_list)
def filter_changed(self, i):
self.filter_changed_signal.emit(["", "installed", "offline", "32bit", "installable"][i])

View file

@ -1,6 +1,7 @@
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QKeyEvent
from PyQt5.QtWidgets import QWidget, QTabWidget
from legendary.models.game import Game
from qtawesome import icon
from rare.components.tabs.games.game_info.game_dlc import GameDlc
@ -18,7 +19,7 @@ class InfoTabs(QTabWidget):
self.setTabPosition(QTabWidget.West)
self.addTab(QWidget(), icon("mdi.keyboard-backspace"), self.tr("Back"))
self.tabBarClicked.connect(lambda x: self.parent().layout.setCurrentIndex(0) if x == 0 else None)
self.tabBarClicked.connect(lambda x: self.parent().layout().setCurrentIndex(0) if x == 0 else None)
self.info = GameInfo(core, self)
self.addTab(self.info, self.tr("Information"))
@ -30,21 +31,21 @@ class InfoTabs(QTabWidget):
self.dlc = GameDlc(core, self)
self.addTab(self.dlc, self.tr("Downloadable Content"))
def update_game(self, app_name, dlcs: list):
def update_game(self, game: Game, dlcs: list):
self.info.update_game(app_name)
self.settings.update_game(app_name)
self.info.update_game(game)
self.settings.update_game(game)
# DLC Tab: Disable if no dlcs available
if dlcs:
if len(dlcs[self.core.get_game(app_name).asset_info.catalog_item_id]) == 0:
if len(dlcs[game.asset_info.catalog_item_id]) == 0:
self.setTabEnabled(3, False)
else:
self.setTabEnabled(3, True)
self.dlc.update_dlcs(app_name, dlcs)
self.dlc.update_dlcs(game.app_name, dlcs)
else:
self.setTabEnabled(3, False)
def keyPressEvent(self, e: QKeyEvent):
if e.key() == Qt.Key_Escape:
self.parent().layout.setCurrentIndex(0)
self.parent().layout().setCurrentIndex(0)

View file

@ -1,4 +1,3 @@
import json
import os
import platform
@ -7,7 +6,6 @@ from PyQt5.QtWidgets import QWidget, QMessageBox
from legendary.core import LegendaryCore
from legendary.models.game import Game, InstalledGame
from rare import data_dir
from rare.ui.components.tabs.games.game_info.game_info import Ui_GameInfo
from rare.utils.legendary_utils import VerifyThread
from rare.utils.steam_grades import SteamWorker
@ -27,17 +25,6 @@ class GameInfo(QWidget, Ui_GameInfo):
self.setupUi(self)
self.core = core
self.ratings = {"platinum": self.tr("Platinum"),
"gold": self.tr("Gold"),
"silver": self.tr("Silver"),
"bronze": self.tr("Bronze"),
"fail": self.tr("Could not get grade"),
"pending": self.tr("Not enough reports")}
if os.path.exists(p := os.path.join(data_dir, "game_list.json")):
self.grade_table = json.load(open(p))
else:
self.grade_table = {}
if platform.system() == "Windows":
self.lbl_grade.setVisible(False)
self.grade.setVisible(False)
@ -92,12 +79,12 @@ class GameInfo(QWidget, Ui_GameInfo):
self.verify_widget.setCurrentIndex(0)
self.verify_threads.pop(app_name)
def update_game(self, app_name):
self.game = self.core.get_game(app_name)
self.igame = self.core.get_installed_game(app_name)
def update_game(self, game: Game):
self.game = game
self.igame = self.core.get_installed_game(game.app_name)
self.game_title.setText(f'<h2>{self.game.app_title}</h2>')
pixmap = get_pixmap(app_name)
pixmap = get_pixmap(game.app_name)
w = 200
pixmap = pixmap.scaled(w, int(w * 4 / 3))
self.image.setPixmap(pixmap)
@ -105,18 +92,24 @@ class GameInfo(QWidget, Ui_GameInfo):
self.app_name.setText(self.game.app_name)
self.version.setText(self.game.app_version)
self.dev.setText(self.game.metadata["developer"])
self.install_size.setText(get_size(self.igame.install_size))
self.install_path.setText(self.igame.install_path)
if self.igame:
self.install_size.setText(get_size(self.igame.install_size))
self.install_path.setText(self.igame.install_path)
self.install_size.setVisible(True)
self.install_path.setVisible(True)
else:
self.install_size.setVisible(False)
self.install_path.setVisible(False)
if platform.system() != "Windows":
self.grade.setText(self.tr("Loading"))
self.steam_worker.set_app_name(app_name)
self.steam_worker.set_app_name(game.app_name)
self.steam_worker.start()
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(app_name):
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(game.app_name):
self.verify_widget.setCurrentIndex(0)
elif self.verify_threads.get(app_name):
elif self.verify_threads.get(game.app_name):
self.verify_widget.setCurrentIndex(1)
self.verify_progress.setValue(
self.verify_threads[app_name].num / self.verify_threads[app_name].total * 100
self.verify_threads[game.app_name].num / self.verify_threads[game.app_name].total * 100
)

View file

@ -176,21 +176,24 @@ class GameSettings(QWidget, Ui_GameSettings):
self.core.lgd.config.set(self.game.app_name + ".env", "STEAM_COMPAT_DATA_PATH", text)
self.core.lgd.save_config()
def update_game(self, app_name):
def update_game(self, game: Game):
self.change = False
self.game = self.core.get_game(app_name)
self.igame = self.core.get_installed_game(app_name)
self.game = game
self.igame = self.core.get_installed_game(game.app_name)
app_name = game.app_name
if self.igame:
if self.igame.can_run_offline:
offline = self.core.lgd.config.get(self.game.app_name, "offline", fallback="unset")
if offline == "true":
self.offline.setCurrentIndex(1)
elif offline == "false":
self.offline.setCurrentIndex(2)
else:
self.offline.setCurrentIndex(0)
if self.igame.can_run_offline:
offline = self.core.lgd.config.get(self.game.app_name, "offline", fallback="unset")
if offline == "true":
self.offline.setCurrentIndex(1)
elif offline == "false":
self.offline.setCurrentIndex(2)
self.offline.setEnabled(True)
else:
self.offline.setCurrentIndex(0)
self.offline.setEnabled(True)
self.offline.setEnabled(False)
else:
self.offline.setEnabled(False)

View file

@ -21,7 +21,7 @@ logger = getLogger("Game list")
class GameList(QStackedWidget):
install_game = pyqtSignal(InstallOptionsModel)
show_game_info = pyqtSignal(str)
show_game_info = pyqtSignal(Game)
update_game = pyqtSignal()
game_exited = pyqtSignal(str)
game_started = pyqtSignal(str)

View file

@ -5,7 +5,7 @@ from logging import getLogger
from PyQt5.QtCore import pyqtSignal, QProcess, QSettings, Qt, QByteArray, QProcessEnvironment
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QGroupBox, QMessageBox, QAction, QLabel
from PyQt5.QtWidgets import QGroupBox, QMessageBox, QAction, QLabel, QPushButton
from legendary.core import LegendaryCore
from legendary.models.game import InstalledGame, Game
@ -19,7 +19,7 @@ logger = getLogger("Game")
class BaseInstalledWidget(QGroupBox):
launch_signal = pyqtSignal(str)
show_info = pyqtSignal(str)
show_info = pyqtSignal(Game)
finish_signal = pyqtSignal(str)
update_list = pyqtSignal()
proc: QProcess()
@ -201,7 +201,15 @@ class BaseInstalledWidget(QGroupBox):
def finished(self, exit_code):
logger.info("Game exited with exit code: " + str(exit_code))
if exit_code == 53 and self.is_origin:
QMessageBox.warning(self, "Error", "Origin is not installed. Please install it manually")
msg_box = QMessageBox()
msg_box.setText(self.tr("Origin is not installed. Do you want to download installer file? "))
msg_box.addButton(QPushButton("Download"), QMessageBox.YesRole)
msg_box.addButton(QPushButton("Cancel"), QMessageBox.RejectRole)
resp = msg_box.exec()
# click install button
if resp == 0:
webbrowser.open("https://www.dm.origin.com/download")
self.finish_signal.emit(self.game.app_name)
self.game_running = False
if self.settings.value("show_console", False, bool):

View file

@ -14,7 +14,6 @@ logger = getLogger("GameWidgetInstalled")
class InstalledIconWidget(BaseInstalledWidget):
update_list = pyqtSignal(str)
show_info = pyqtSignal(str)
update_game = pyqtSignal()
def __init__(self, igame: InstalledGame, core: LegendaryCore, pixmap, offline, is_origin: bool = False,
@ -54,7 +53,7 @@ class InstalledIconWidget(BaseInstalledWidget):
self.menu_btn.setObjectName("menu_button")
self.menu_btn.clicked.connect(lambda: self.show_info.emit(self.game.app_name))
self.menu_btn.clicked.connect(lambda: self.show_info.emit(self.game))
self.menu_btn.setFixedWidth(17)
minilayout.addWidget(self.menu_btn)
minilayout.addStretch(1)
@ -97,10 +96,3 @@ class InstalledIconWidget(BaseInstalledWidget):
# right
elif e.button() == 2:
pass # self.showMenu(e)
"""def showMenu(self, event):
menu = QMenu()
desktop_link = menu.addAction("Add Desktop link")
action = menu.exec_(self.mapToGlobal(event.pos()))
if action == desktop_link:
print("LOL")"""

View file

@ -41,7 +41,7 @@ class InstalledListWidget(BaseInstalledWidget):
self.launch_button.setFixedWidth(120)
self.info = QPushButton("Info")
self.info.clicked.connect(lambda: self.show_info.emit(self.game.app_name))
self.info.clicked.connect(lambda: self.show_info.emit(self.game))
self.info.setFixedWidth(80)
self.childLayout.addWidget(self.title_widget)

View file

@ -240,6 +240,7 @@ class ShopWidget(QScrollArea, Ui_ShopWidget):
if data:
for game in data:
print(game)
w = GameWidget(self.path, game, 275)
self.game_widget.layout().addWidget(w)
w.show_info.connect(self.show_game.emit)