1
0
Fork 0
mirror of synced 2024-06-10 14:44:41 +12:00

Fix many bugs:

- launch command
- offline mode
- shop search results shows more than 1 game
This commit is contained in:
Dummerle 2021-12-09 20:03:34 +01:00
parent ba9ac234cd
commit e370841532
No known key found for this signature in database
GPG key ID: AB68CC59CA39F2F1
9 changed files with 37 additions and 21 deletions

View file

@ -134,8 +134,7 @@ class App(QApplication):
self.launch_dialog.start_app.connect(self.start_app)
self.launch_dialog.start_app.connect(self.launch_dialog.close)
if not self.args.silent or self.args.subparser == "launch":
self.launch_dialog.login()
self.launch_dialog.login()
def start_app(self):
self.mainwindow = MainWindow()
@ -148,6 +147,18 @@ class App(QApplication):
if not self.args.silent:
self.mainwindow.show()
if shared.args.subparser == "launch":
if shared.args.app_name in [i.app_name for i in self.core.get_installed_list()]:
logger.info("Launching " + self.core.get_installed_game(shared.args.app_name).title)
self.mainwindow.tab_widget.games_tab.game_utils.prepare_launch(shared.args.app_name)
else:
logger.error(
f"Could not find {shared.args.app_name} in Games or it is not installed")
QMessageBox.warning(self.mainwindow, "Warning",
self.tr(
"Could not find {} in installed games. Did you modify the shortcut? ").format(
shared.args.app_name))
def tray(self, reason):
if reason == QSystemTrayIcon.DoubleClick:
self.mainwindow.show()

View file

@ -106,7 +106,8 @@ class LaunchDialog(QDialog, Ui_LaunchDialog):
self.offline = True
finally:
if do_launch:
self.show()
if not shared.args.silent:
self.show()
self.launch()
else:
self.quit_app.emit(0)
@ -143,7 +144,14 @@ class LaunchDialog(QDialog, Ui_LaunchDialog):
else:
self.finished = 2
self.api_results.game_list, self.api_results.dlcs = self.core.get_game_and_dlc_list(False)
if self.core.lgd.assets:
self.api_results.game_list, self.api_results.dlcs = self.core.get_game_and_dlc_list(False)
self.api_results.bit32_games = list(map(lambda i: i.app_name, self.core.get_game_list(False, "Win32")))
self.api_results.mac_games = list(map(lambda i: i.app_name, self.core.get_game_list(False, "Mac")))
else:
logger.warning("No assets found. Falling back to empty game lists")
self.api_results.game_list, self.api_results.dlcs = [], {}
self.api_results.mac_games = self.api_results.bit32_games = []
self.finish()
def handle_api_worker_result(self, result, text):

View file

@ -55,14 +55,6 @@ class MainWindow(QMainWindow):
if not shared.args.offline:
self.rpc = DiscordRPC()
if shared.args.subparser == "launch":
if shared.args.app_name in [i.app_name for i in self.core.get_installed_list()]:
logger.info("Launching " + self.core.get_installed_game(shared.args.app_name).title)
self.tab_widget.games_tab.game_utils.prepare_launch(shared.args.app_name)
else:
logger.info(
f"Could not find {shared.args.app_name} in Games or it is not installed")
self.timer = QTimer()
self.timer.timeout.connect(self.timer_finished)
self.timer.start(1000)

View file

@ -10,7 +10,7 @@ from ..game_utils import GameUtils
class GameInfoTabs(SideTabWidget):
def __init__(self, dlcs: list, game_utils: GameUtils, parent=None):
def __init__(self, dlcs: dict, game_utils: GameUtils, parent=None):
super(GameInfoTabs, self).__init__(show_back=True, parent=parent)
self.core = shared.core
self.signals = shared.signals
@ -33,7 +33,7 @@ class GameInfoTabs(SideTabWidget):
self.settings.update_game(app_name)
# DLC Tab: Disable if no dlcs available
if len(self.dlc_list[self.core.get_game(app_name).catalog_item_id]) == 0:
if len(self.dlc_list.get(self.core.get_game(app_name).catalog_item_id, [])) == 0:
self.setTabEnabled(3, False)
else:
self.setTabEnabled(3, True)

View file

@ -15,7 +15,7 @@ class GameDlc(QWidget, Ui_GameDlc):
install_dlc = pyqtSignal(str, bool)
game: Game
def __init__(self, dlcs: list, game_utils: GameUtils, parent=None):
def __init__(self, dlcs: dict, game_utils: GameUtils, parent=None):
super(GameDlc, self).__init__(parent=parent)
self.setupUi(self)
self.game_utils = game_utils

View file

@ -44,10 +44,13 @@ class GameInfo(QWidget, Ui_GameInfo):
self.uninstall_button.clicked.connect(self.uninstall)
self.verify_button.clicked.connect(self.verify)
self.repair_button.clicked.connect(self.repair)
self.verify_pool = QThreadPool()
self.verify_pool.setMaxThreadCount(2)
if shared.args.offline:
self.repair_button.setDisabled(True)
else:
self.repair_button.clicked.connect(self.repair)
def uninstall(self):
if self.game_utils.uninstall_game(self.game.app_name):
@ -142,7 +145,8 @@ class GameInfo(QWidget, Ui_GameInfo):
else:
self.uninstall_button.setDisabled(False)
self.verify_button.setDisabled(False)
self.repair_button.setDisabled(False)
if not shared.args.offline:
self.repair_button.setDisabled(False)
self.game_actions_stack.setCurrentIndex(0)
if platform.system() != "Windows":

View file

@ -55,8 +55,9 @@ class BaseInstalledWidget(QGroupBox):
self.game_running = False
self.offline = shared.args.offline
self.update_available = False
if self.game.third_party_store != "Origin" or self.igame:
remote_version = self.core.get_asset(self.game.app_name, platform=self.igame.platform, update=False).build_version
if (self.game.third_party_store != "Origin" or self.igame) and self.core.lgd.assets:
remote_version = self.core.get_asset(self.game.app_name, platform=self.igame.platform,
update=False).build_version
if remote_version != self.igame.version:
self.update_available = True

View file

@ -71,7 +71,7 @@ class ShopApiCore(QObject):
def search_game(self, name, handle_func):
payload = {
"query": search_query,
"variables": {"category": "games/edition/base|bundles/games|editors|software/edition/base", "count": 1,
"variables": {"category": "games/edition/base|bundles/games|editors|software/edition/base", "count": 10,
"country": self.country_code, "keywords": name, "locale": self.locale, "sortDir": "DESC",
"allowCountries": self.country_code,
"start": 0, "tag": "", "withMapping": False, "withPrice": True}

View file

@ -96,7 +96,7 @@ class PathSpec:
@dataclass
class ApiResults:
game_list: list = None
dlcs: list = None
dlcs: dict = None
bit32_games: list = None
mac_games: list = None
no_asset_games: list = None