From 5ecbb1cf777c4af57b30dc0b56f4ab0f89a4e59e Mon Sep 17 00:00:00 2001 From: Flavio F Lima Date: Wed, 18 May 2022 13:44:22 +0200 Subject: [PATCH 1/3] fix: check for updates before launch --- electron/legendary/games.ts | 8 ++- src/helpers/library.ts | 52 ++++++++++--------- src/screens/Game/GamePage/index.tsx | 8 ++- .../Library/components/GameCard/index.tsx | 2 +- src/state/GlobalState.tsx | 3 +- 5 files changed, 43 insertions(+), 30 deletions(-) diff --git a/electron/legendary/games.ts b/electron/legendary/games.ts index 41943d1f9f..227295326d 100644 --- a/electron/legendary/games.ts +++ b/electron/legendary/games.ts @@ -521,7 +521,9 @@ class LegendaryGame extends Game { return res } - public async launch(launchArguments = ''): Promise { + public async launch(launchArguments: string): Promise { + console.log('launch', { launchArguments }) + const gameSettings = GameConfig.get(this.appName).config || (await GameConfig.get(this.appName).getSettings()) @@ -572,6 +574,7 @@ class LegendaryGame extends Game { steamRuntime ) } + // These options are required on both Windows and Mac commandParts = [ 'launch', @@ -623,7 +626,8 @@ class LegendaryGame extends Game { offlineFlag, ...wineFlag, ...winePrefixFlag, - launcherArgs + launcherArgs, + launchArguments ] } const command = getLegendaryCommand(commandParts, commandEnv, wrappers) diff --git a/src/helpers/library.ts b/src/helpers/library.ts index 54983d7067..a33ad59761 100644 --- a/src/helpers/library.ts +++ b/src/helpers/library.ts @@ -249,43 +249,45 @@ type LaunchOptions = { t: TFunction<'gamepage'> launchArguments?: string runner: Runner + hasUpdate: boolean } const launch = async ({ appName, t, launchArguments, - runner -}: LaunchOptions): Promise => - ipcRenderer + runner, + hasUpdate +}: LaunchOptions): Promise => { + if (hasUpdate) { + const args = { + buttons: [t('gamepage:box.yes'), t('box.no')], + message: t('gamepage:box.update.message'), + title: t('gamepage:box.update.title') + } + + const { response } = await ipcRenderer.invoke('openMessageBox', args) + + if (response === 0) { + return updateGame(appName, runner) + } + + return ipcRenderer.invoke('launch', { + appName, + runner, + launchArguments: runner === 'legendary' ? '--skip-version-check' : '' + }) + } + + return ipcRenderer .invoke('launch', { appName, launchArguments, runner }) .then(async (err: string | string[]) => { if (!err) { return } - - if ( - typeof err === 'string' && - err.includes('ERROR: Game is out of date') - ) { - const args = { - buttons: [t('gamepage:box.yes'), t('box.no')], - message: t('gamepage:box.update.message'), - title: t('gamepage:box.update.title') - } - - const { response } = await ipcRenderer.invoke('openMessageBox', args) - - if (response === 0) { - return updateGame(appName, runner) - } - await ipcRenderer.invoke('launch', { - appName, - runner, - launchArguments: '--skip-version-check' - }) - } + return ipcRenderer.invoke('showErrorBox', ['Error', `${err}`]) }) +} const updateGame = async (appName: string, runner: Runner): Promise => ipcRenderer.invoke('updateGame', appName, runner) diff --git a/src/screens/Game/GamePage/index.tsx b/src/screens/Game/GamePage/index.tsx index dfc2331900..84510d6136 100644 --- a/src/screens/Game/GamePage/index.tsx +++ b/src/screens/Game/GamePage/index.tsx @@ -536,7 +536,13 @@ export default function GamePage(): JSX.Element | null { await syncSaves(savesPath, appName) setIsSyncing(false) } - await launch({ appName, t, launchArguments, runner: gameInfo.runner }) + await launch({ + appName, + t, + launchArguments, + runner: gameInfo.runner, + hasUpdate + }) if (autoSyncSaves) { setIsSyncing(true) diff --git a/src/screens/Library/components/GameCard/index.tsx b/src/screens/Library/components/GameCard/index.tsx index 3275b2418a..328bfcedc4 100644 --- a/src/screens/Library/components/GameCard/index.tsx +++ b/src/screens/Library/components/GameCard/index.tsx @@ -361,7 +361,7 @@ const GameCard = ({ return sendKill(appName, runner) } if (isInstalled) { - return launch({ appName, t, runner }) + return launch({ appName, t, runner, hasUpdate }) } return } diff --git a/src/state/GlobalState.tsx b/src/state/GlobalState.tsx index 1bef2ebb76..d5815dcc6b 100644 --- a/src/state/GlobalState.tsx +++ b/src/state/GlobalState.tsx @@ -454,7 +454,8 @@ export class GlobalState extends PureComponent { )[0] if (!currentApp) { // Add finding a runner for games - return launch({ appName, t, runner }) + const hasUpdate = this.state.gameUpdates?.includes(appName) + return launch({ appName, t, runner, hasUpdate }) } }) From b3d8c8edf8ab68ccab8036889f4bb9fe3460acca Mon Sep 17 00:00:00 2001 From: Flavio F Lima Date: Wed, 18 May 2022 15:42:30 +0200 Subject: [PATCH 2/3] fix: pr comments --- electron/launcher.ts | 4 ++-- electron/legendary/games.ts | 2 -- src/helpers/library.ts | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/electron/launcher.ts b/electron/launcher.ts index 8012fa32ce..7297aa8258 100644 --- a/electron/launcher.ts +++ b/electron/launcher.ts @@ -373,7 +373,7 @@ async function runWineCommand( } } - let finalCommand = `${wineBin} ${command}` + let finalCommand = `"${wineBin}" ${command}` if (additional_command) { finalCommand += ` && ${additional_command}` } @@ -385,7 +385,7 @@ async function runWineCommand( return response }) .catch((error) => { - logError(['Error running Wine command:', error], LogPrefix.Legendary) + logError(['Error running Wine command:', error], LogPrefix.Backend) return { stderr: error, stdout: '' } }) } diff --git a/electron/legendary/games.ts b/electron/legendary/games.ts index 227295326d..cfb6615eb0 100644 --- a/electron/legendary/games.ts +++ b/electron/legendary/games.ts @@ -522,8 +522,6 @@ class LegendaryGame extends Game { } public async launch(launchArguments: string): Promise { - console.log('launch', { launchArguments }) - const gameSettings = GameConfig.get(this.appName).config || (await GameConfig.get(this.appName).getSettings()) diff --git a/src/helpers/library.ts b/src/helpers/library.ts index a33ad59761..9adfeeae18 100644 --- a/src/helpers/library.ts +++ b/src/helpers/library.ts @@ -275,7 +275,7 @@ const launch = async ({ return ipcRenderer.invoke('launch', { appName, runner, - launchArguments: runner === 'legendary' ? '--skip-version-check' : '' + launchArguments: '--skip-version-check' }) } From 5439661fbb33b0decccbd75cfd0d34a361128556 Mon Sep 17 00:00:00 2001 From: Flavio F Lima Date: Wed, 18 May 2022 15:57:36 +0200 Subject: [PATCH 3/3] chore: skip wineboot for proton --- electron/launcher.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/electron/launcher.ts b/electron/launcher.ts index 7297aa8258..039b216b5c 100644 --- a/electron/launcher.ts +++ b/electron/launcher.ts @@ -280,7 +280,7 @@ async function verifyWinePrefix( ): Promise<{ res: ExecResult; updated: boolean }> { const { winePrefix, wineVersion } = await game.getSettings() - if (wineVersion.type === 'crossover') { + if (!(wineVersion.type === 'wine')) { return { res: { stdout: '', stderr: '' }, updated: false } } @@ -363,7 +363,7 @@ async function runWineCommand( // Can't wait if we don't have a Wineserver if (wait) { if (wineVersion.wineserver) { - additional_command = `${wineVersion.wineserver} --wait` + additional_command = `"${wineVersion.wineserver}" --wait` } else { logWarning( 'Unable to wait on Wine command, no Wineserver!',