Some fixes:
- Fixes for macOS - Use app_name to update games in GameInfo - Check wine executable at game launch
This commit is contained in:
parent
a9ce9df758
commit
206733b468
|
@ -69,7 +69,10 @@ class InstallDialog(QDialog, Ui_InstallDialog):
|
|||
self.platform_combo_box.currentIndexChanged.connect(lambda: self.option_changed(None))
|
||||
self.platform_combo_box.currentIndexChanged.connect(lambda i: QMessageBox.warning(self, "Warning", self.tr(
|
||||
"You will not be able to run the Game if you choose {}").format(self.platform_combo_box.itemText(i)))
|
||||
if (self.platform_combo_box.currentText() == "Mac" and platform.system() != "Darwin") else None)
|
||||
if (self.platform_combo_box.currentText() == "Mac" and platform.system() != "Darwin") else None)
|
||||
|
||||
if platform.system() == "Darwin" and "Mac" in platforms:
|
||||
self.platform_combo_box.setCurrentIndex(platforms.index("Mac"))
|
||||
|
||||
if self.core.lgd.config.has_option("Legendary", "max_workers"):
|
||||
max_workers = self.core.lgd.config.get("Legendary", "max_workers")
|
||||
|
|
|
@ -130,8 +130,8 @@ class GamesTab(QStackedWidget, Ui_GamesTab):
|
|||
self.setCurrentIndex(2)
|
||||
self.import_sync_tabs.show_egl_sync()
|
||||
|
||||
def show_game_info(self, game):
|
||||
self.game_info_tabs.update_game(game)
|
||||
def show_game_info(self, app_name):
|
||||
self.game_info_tabs.update_game(app_name)
|
||||
self.setCurrentIndex(1)
|
||||
|
||||
def show_uninstalled_info(self, game):
|
||||
|
|
|
@ -2,7 +2,6 @@ from PyQt5.QtCore import Qt
|
|||
from PyQt5.QtGui import QKeyEvent
|
||||
|
||||
import rare.shared as shared
|
||||
from legendary.models.game import Game
|
||||
from rare.utils.extra_widgets import SideTabWidget
|
||||
from .game_dlc import GameDlc
|
||||
from .game_info import GameInfo
|
||||
|
@ -28,17 +27,17 @@ class GameInfoTabs(SideTabWidget):
|
|||
|
||||
self.tabBar().setCurrentIndex(1)
|
||||
|
||||
def update_game(self, game: Game):
|
||||
def update_game(self, app_name: str):
|
||||
self.setCurrentIndex(1)
|
||||
self.info.update_game(game)
|
||||
self.settings.update_game(game)
|
||||
self.info.update_game(app_name)
|
||||
self.settings.update_game(app_name)
|
||||
|
||||
# DLC Tab: Disable if no dlcs available
|
||||
if len(self.dlc_list[game.asset_infos["Windows"].catalog_item_id]) == 0:
|
||||
if len(self.dlc_list[self.core.get_game(app_name).catalog_item_id]) == 0:
|
||||
self.setTabEnabled(3, False)
|
||||
else:
|
||||
self.setTabEnabled(3, True)
|
||||
self.dlc.update_dlcs(game.app_name)
|
||||
self.dlc.update_dlcs(app_name)
|
||||
|
||||
def keyPressEvent(self, e: QKeyEvent):
|
||||
if e.key() == Qt.Key_Escape:
|
||||
|
|
|
@ -102,12 +102,12 @@ class GameInfo(QWidget, Ui_GameInfo):
|
|||
self.verify_widget.setCurrentIndex(0)
|
||||
self.verify_threads.pop(app_name)
|
||||
|
||||
def update_game(self, game: Game):
|
||||
self.game = game
|
||||
self.igame = self.core.get_installed_game(game.app_name)
|
||||
def update_game(self, app_name: str):
|
||||
self.game = self.core.get_game(app_name)
|
||||
self.igame = self.core.get_installed_game(self.game.app_name)
|
||||
self.game_title.setText(f'<h2>{self.game.app_title}</h2>')
|
||||
|
||||
pixmap = get_pixmap(game.app_name)
|
||||
pixmap = get_pixmap(self.game.app_name)
|
||||
w = 200
|
||||
pixmap = pixmap.scaled(w, int(w * 4 / 3))
|
||||
self.image.setPixmap(pixmap)
|
||||
|
@ -141,13 +141,13 @@ class GameInfo(QWidget, Ui_GameInfo):
|
|||
|
||||
if platform.system() != "Windows":
|
||||
self.grade.setText(self.tr("Loading"))
|
||||
self.steam_worker.set_app_name(game.app_name)
|
||||
self.steam_worker.set_app_name(self.game.app_name)
|
||||
QThreadPool.globalInstance().start(self.steam_worker)
|
||||
|
||||
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(game.app_name):
|
||||
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(self.game.app_name):
|
||||
self.verify_widget.setCurrentIndex(0)
|
||||
elif self.verify_threads.get(game.app_name):
|
||||
elif self.verify_threads.get(self.game.app_name):
|
||||
self.verify_widget.setCurrentIndex(1)
|
||||
self.verify_progress.setValue(
|
||||
self.verify_threads[game.app_name].num / self.verify_threads[game.app_name].total * 100
|
||||
self.verify_threads[self.game.app_name].num / self.verify_threads[self.game.app_name].total * 100
|
||||
)
|
||||
|
|
|
@ -111,10 +111,8 @@ class GameSettings(QWidget, Ui_GameSettings):
|
|||
self.linux_settings_contents_layout.addWidget(self.linux_settings)
|
||||
self.linux_settings_contents_layout.setAlignment(Qt.AlignTop)
|
||||
else:
|
||||
self.game_settings_layout.setAlignment(Qt.AlignTop)
|
||||
self.linux_settings_scroll.setVisible(False)
|
||||
|
||||
# skip_update_check
|
||||
self.game_settings_layout.setAlignment(Qt.AlignTop)
|
||||
|
||||
def compute_save_path(self):
|
||||
if self.core.is_installed(self.game.app_name) and self.game.supports_cloud_saves:
|
||||
|
@ -252,11 +250,10 @@ 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, game: Game):
|
||||
def update_game(self, app_name: str):
|
||||
self.change = False
|
||||
self.game = game
|
||||
self.igame = self.core.get_installed_game(game.app_name)
|
||||
app_name = game.app_name
|
||||
self.game = self.core.get_game(app_name)
|
||||
self.igame = self.core.get_installed_game(self.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")
|
||||
|
@ -281,6 +278,11 @@ class GameSettings(QWidget, Ui_GameSettings):
|
|||
else:
|
||||
self.skip_update.setCurrentIndex(0)
|
||||
|
||||
if self.igame and self.igame.platform == "Mac":
|
||||
self.linux_settings_scroll.setVisible(False)
|
||||
else:
|
||||
self.linux_settings_scroll.setVisible(True)
|
||||
|
||||
wrapper = self.core.lgd.config.get(self.game.app_name, "wrapper", fallback="")
|
||||
self.wrapper.setText(wrapper)
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import webbrowser
|
||||
from dataclasses import dataclass
|
||||
from logging import getLogger
|
||||
|
@ -161,6 +162,7 @@ class GameUtils(QObject):
|
|||
environment.insert(env, value)
|
||||
|
||||
if platform.system() != "Windows":
|
||||
# wine prefixes
|
||||
for env in ["STEAM_COMPAT_DATA_PATH", "WINEPREFIX"]:
|
||||
if val := full_env.get(env):
|
||||
if not os.path.exists(val):
|
||||
|
@ -168,18 +170,24 @@ class GameUtils(QObject):
|
|||
os.makedirs(val)
|
||||
except PermissionError as e:
|
||||
logger.error(str(e))
|
||||
if QMessageBox.question(None, "Error",
|
||||
self.tr(
|
||||
"Error while launching {}. No permission to create {} for {}\nLaunch anyway?").format(
|
||||
game.app_title, val, env),
|
||||
buttons=QMessageBox.Yes | QMessageBox.No,
|
||||
defaultButton=QMessageBox.Yes) == QMessageBox.No:
|
||||
process.deleteLater()
|
||||
return
|
||||
QMessageBox.warning(None, "Error",
|
||||
self.tr(
|
||||
"Error while launching {}. No permission to create {} for {}").format(
|
||||
game.app_title, val, env))
|
||||
process.deleteLater()
|
||||
return
|
||||
# check wine executable
|
||||
if shutil.which(full_params[0]) is None:
|
||||
# wine binary does not exist
|
||||
QMessageBox.warning(None, "Warning", self.tr(
|
||||
"Wine executable '{}' does not exist. Please change it in Settings").format(full_params[0]))
|
||||
process.deleteLater()
|
||||
return
|
||||
|
||||
process.setProcessEnvironment(environment)
|
||||
process.game_finished.connect(self.game_finished)
|
||||
running_game = RunningGameModel(process=process, app_name=app_name, always_ask_sync=ask_always_sync)
|
||||
|
||||
process.start(full_params[0], full_params[1:])
|
||||
self.game_launched.emit(app_name)
|
||||
logger.info(f"{game.app_title} launched")
|
||||
|
@ -197,9 +205,18 @@ class GameUtils(QObject):
|
|||
fallback=os.path.expanduser("~/.wine"))
|
||||
if not wine_bin:
|
||||
wine_bin = self.core.lgd.config.get(game.app_name, 'wine_executable', fallback="/usr/bin/wine")
|
||||
|
||||
if shutil.which(wine_bin) is None:
|
||||
# wine binary does not exist
|
||||
QMessageBox.warning(None, "Warning",
|
||||
self.tr("Wine executable '{}' does not exist. Please change it in Settings").format(
|
||||
wine_bin))
|
||||
process.deleteLater()
|
||||
return
|
||||
|
||||
env = self.core.get_app_environment(game.app_name, wine_pfx=wine_pfx)
|
||||
|
||||
if not wine_bin or not env.get('WINEPREFIX') and not os.path.exists("/usr/bin/wine"):
|
||||
if not env.get('WINEPREFIX') and not os.path.exists("/usr/bin/wine"):
|
||||
logger.error(f'In order to launch Origin correctly you must specify the wine binary and prefix '
|
||||
f'to use in the configuration file or command line. See the README for details.')
|
||||
self.finished.emit(app_name, self.tr("No wine executable selected. Please set it in settings"))
|
||||
|
@ -215,14 +232,9 @@ class GameUtils(QObject):
|
|||
if QSettings().value("show_console", False, bool):
|
||||
self.console.show()
|
||||
process.readyReadStandardOutput.connect(lambda: self.console.log(
|
||||
bytes(process.readAllStandardOutput()).decode("utf-8", errors="ignore")))
|
||||
str(process.readAllStandardOutput().data(), "utf-8", "ignore")))
|
||||
process.readyReadStandardError.connect(lambda: self.console.error(
|
||||
bytes(process.readAllStandardOutput()).decode("utf-8", errors="ignore")))
|
||||
else:
|
||||
process.readyReadStandardOutput.connect(
|
||||
lambda: print(bytes(process.readAllStandardOutput()).decode("utf-8", errors="ignore")))
|
||||
process.readyReadStandardError.connect(
|
||||
lambda: print(bytes(process.readAllStandardError()).decode("utf-8", errors="ignore")))
|
||||
str(process.readAllStandardError().data(), "utf-8", "ignore")))
|
||||
|
||||
def game_finished(self, exit_code, app_name):
|
||||
logger.info("Game exited with exit code: " + str(exit_code))
|
||||
|
|
|
@ -6,7 +6,6 @@ from PyQt5.QtCore import pyqtSignal, QProcess, QSettings, Qt, QByteArray
|
|||
from PyQt5.QtGui import QPixmap
|
||||
from PyQt5.QtWidgets import QGroupBox, QMessageBox, QAction, QLabel
|
||||
|
||||
from legendary.models.game import Game
|
||||
from rare import shared
|
||||
from rare.components.tabs.games.game_utils import GameUtils
|
||||
from rare.utils import utils
|
||||
|
@ -17,7 +16,7 @@ logger = getLogger("Game")
|
|||
|
||||
class BaseInstalledWidget(QGroupBox):
|
||||
launch_signal = pyqtSignal(str, QProcess, list)
|
||||
show_info = pyqtSignal(Game)
|
||||
show_info = pyqtSignal(str)
|
||||
finish_signal = pyqtSignal(str, int)
|
||||
proc: QProcess()
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class InstalledIconWidget(BaseInstalledWidget):
|
|||
|
||||
self.menu_btn.setObjectName("menu_button")
|
||||
|
||||
self.menu_btn.clicked.connect(lambda: self.show_info.emit(self.game))
|
||||
self.menu_btn.clicked.connect(lambda: self.show_info.emit(self.game.app_name))
|
||||
self.menu_btn.setFixedWidth(17)
|
||||
minilayout.addWidget(self.menu_btn)
|
||||
minilayout.addStretch(1)
|
||||
|
@ -86,6 +86,8 @@ class InstalledIconWidget(BaseInstalledWidget):
|
|||
self.info_label.setText(self.texts["default"]["syncing"])
|
||||
elif self.update_available:
|
||||
self.info_label.setText(self.texts["default"]["update_available"])
|
||||
elif self.igame and self.igame.needs_verification:
|
||||
self.info_label.setText(self.texts["needs_verification"])
|
||||
else:
|
||||
self.info_label.setText("")
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class InstalledListWidget(BaseInstalledWidget):
|
|||
self.launch_button.setFixedWidth(150)
|
||||
|
||||
self.info = QPushButton("Info")
|
||||
self.info.clicked.connect(lambda: self.show_info.emit(self.game))
|
||||
self.info.clicked.connect(lambda: self.show_info.emit(self.game.app_name))
|
||||
self.info.setFixedWidth(80)
|
||||
|
||||
self.info_label = QLabel("")
|
||||
|
|
Loading…
Reference in a new issue