diff --git a/src/backend/main.ts b/src/backend/main.ts index 6d5f2deef5..464301fc94 100644 --- a/src/backend/main.ts +++ b/src/backend/main.ts @@ -6,8 +6,6 @@ import { DiskSpaceData, StatusPromise, GamepadInputEvent, - WineCommandArgs, - ExecResult, Runner } from 'common/types' import * as path from 'path' @@ -51,7 +49,6 @@ import { GOGUser } from './storeManagers/gog/user' import { NileUser } from './storeManagers/nile/user' import { clearCache, - execAsync, isEpicServiceOffline, handleExit, openUrlOrFile, @@ -109,7 +106,7 @@ import { } from './logger/logger' import { gameInfoStore } from 'backend/storeManagers/legendary/electronStores' import { getFonts } from 'font-list' -import { prepareWineLaunch, runWineCommand } from './launcher' +import { runWineCommand } from './launcher' import shlex from 'shlex' import { initQueue } from './downloadmanager/downloadqueue' import { @@ -591,31 +588,6 @@ ipcMain.on('removeFolder', async (e, [path, folderName]) => { removeFolder(path, folderName) }) -export async function runWineCommandOnGame( - runner: Runner, - appName: string, - { commandParts, wait = false, protonVerb, startFolder }: WineCommandArgs -): Promise { - if (gameManagerMap[runner].isNative(appName)) { - logError('runWineCommand called on native game!', LogPrefix.Gog) - return { stdout: '', stderr: '' } - } - const { folder_name, install } = gameManagerMap[runner].getGameInfo(appName) - const gameSettings = await gameManagerMap[runner].getSettings(appName) - - await prepareWineLaunch(runner, appName) - - return runWineCommand({ - gameSettings, - installFolderName: folder_name, - gameInstallPath: install.install_path, - commandParts, - wait, - protonVerb, - startFolder - }) -} - ipcMain.handle('runWineCommand', async (e, args) => runWineCommand(args)) /// IPC handlers begin here. @@ -1548,22 +1520,6 @@ ipcMain.handle('getFonts', async (event, reload) => { return cachedFonts }) -ipcMain.handle( - 'runWineCommandForGame', - async (event, { appName, commandParts, runner }) => { - if (isWindows) { - return execAsync(commandParts.join(' ')) - } - - // FIXME: Why are we using `runinprefix` here? - return runWineCommandOnGame(runner, appName, { - commandParts, - wait: false, - protonVerb: 'runinprefix' - }) - } -) - ipcMain.handle('getShellPath', async (event, path) => getShellPath(path)) ipcMain.handle('clipboardReadText', () => clipboard.readText()) diff --git a/src/backend/tools.ts b/src/backend/tools.ts index 74ace36c43..213a9e67ae 100644 --- a/src/backend/tools.ts +++ b/src/backend/tools.ts @@ -1,4 +1,4 @@ -import { GameSettings, Runner } from 'common/types' +import { ExecResult, GameSettings, Runner, WineCommandArgs } from 'common/types' import axios from 'axios' import { existsSync, @@ -25,6 +25,7 @@ import path, { dirname, join } from 'path' import { isOnline } from './online_monitor' import { showDialogBoxModalAuto } from './dialog/dialog' import { + prepareWineLaunch, runWineCommand, setupEnvVars, setupWineEnvVars, @@ -39,7 +40,6 @@ import { import { lt as semverLt } from 'semver' import { gameManagerMap } from './storeManagers' import { ipcMain } from 'electron' -import { runWineCommandOnGame } from './main' import { sendFrontendMessage } from './main_window' export const DXVK = { @@ -706,6 +706,47 @@ function getVkd3dUrl(): string { return 'https://api.github.com/repos/Heroic-Games-Launcher/vkd3d-proton/releases/latest' } +ipcMain.handle( + 'runWineCommandForGame', + async (event, { appName, commandParts, runner }) => { + if (isWindows) { + return execAsync(commandParts.join(' ')) + } + + // FIXME: Why are we using `runinprefix` here? + return runWineCommandOnGame(runner, appName, { + commandParts, + wait: false, + protonVerb: 'runinprefix' + }) + } +) + +async function runWineCommandOnGame( + runner: Runner, + appName: string, + { commandParts, wait = false, protonVerb, startFolder }: WineCommandArgs +): Promise { + if (gameManagerMap[runner].isNative(appName)) { + logError('runWineCommand called on native game!', LogPrefix.Gog) + return { stdout: '', stderr: '' } + } + const { folder_name, install } = gameManagerMap[runner].getGameInfo(appName) + const gameSettings = await gameManagerMap[runner].getSettings(appName) + + await prepareWineLaunch(runner, appName) + + return runWineCommand({ + gameSettings, + installFolderName: folder_name, + gameInstallPath: install.install_path, + commandParts, + wait, + protonVerb, + startFolder + }) +} + // Calls WineCFG or Winetricks. If is WineCFG, use the same binary as wine to launch it to dont update the prefix ipcMain.handle('callTool', async (event, { tool, exe, appName, runner }) => { const gameSettings = await gameManagerMap[runner].getSettings(appName)