Skip to content

[FIX] Install dxvk and vkd3d on new prefixes if enabled #2873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ import { GlobalConfig } from './config'
import { LegendaryUser } from 'backend/storeManagers/legendary/user'
import { GOGUser } from './storeManagers/gog/user'
import { NileUser } from './storeManagers/nile/user'
import setup from './storeManagers/gog/setup'
import nileSetup from './storeManagers/nile/setup'
import {
clearCache,
execAsync,
Expand Down Expand Up @@ -115,7 +113,7 @@ import {
} from './logger/logger'
import { gameInfoStore } from 'backend/storeManagers/legendary/electronStores'
import { getFonts } from 'font-list'
import { runWineCommand, verifyWinePrefix } from './launcher'
import { prepareWineLaunch, runWineCommand } from './launcher'
import shlex from 'shlex'
import { initQueue } from './downloadmanager/downloadqueue'
import {
Expand Down Expand Up @@ -149,7 +147,6 @@ import {
initStoreManagers,
libraryManagerMap
} from './storeManagers'
import { legendarySetup } from 'backend/storeManagers/legendary/setup'

import { logFileLocation as getLogFileLocation } from './storeManagers/storeManagerCommon/games'
import { addNewApp } from './storeManagers/sideload/library'
Expand Down Expand Up @@ -571,7 +568,7 @@ ipcMain.on('removeFolder', async (e, [path, folderName]) => {
})

async function runWineCommandOnGame(
runner: string,
runner: Runner,
appName: string,
{ commandParts, wait = false, protonVerb, startFolder }: WineCommandArgs
): Promise<ExecResult> {
Expand All @@ -582,6 +579,8 @@ async function runWineCommandOnGame(
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,
Expand All @@ -596,12 +595,10 @@ async function runWineCommandOnGame(
// 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)
const { wineVersion, winePrefix } = gameSettings
await verifyWinePrefix(gameSettings)

switch (tool) {
case 'winetricks':
await Winetricks.run(wineVersion, winePrefix, event)
await Winetricks.run(runner, appName, event)
break
case 'winecfg':
runWineCommandOnGame(runner, appName, {
Expand Down Expand Up @@ -1565,22 +1562,9 @@ ipcMain.handle('getFonts', async (event, reload) => {
ipcMain.handle(
'runWineCommandForGame',
async (event, { appName, commandParts, runner }) => {
const gameSettings = await gameManagerMap[runner].getSettings(appName)

if (isWindows) {
return execAsync(commandParts.join(' '))
}
const { updated } = await verifyWinePrefix(gameSettings)

if (runner === 'gog' && updated) {
await setup(appName)
}
if (runner === 'nile' && updated) {
await nileSetup(appName)
}
if (runner === 'legendary' && updated) {
await legendarySetup(appName)
}

// FIXME: Why are we using `runinprefix` here?
return runWineCommandOnGame(runner, appName, {
Expand Down
2 changes: 2 additions & 0 deletions src/backend/storeManagers/legendary/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,8 @@ export async function runWineCommandOnGame(
const { folder_name, install } = getGameInfo(appName)
const gameSettings = await getSettings(appName)

await prepareWineLaunch('legendary', appName)

return runWineCommandUtil({
gameSettings,
gameInstallPath: install.install_path,
Expand Down
14 changes: 8 additions & 6 deletions src/backend/storeManagers/storeManagerCommon/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
callRunner,
launchCleanup,
prepareLaunch,
prepareWineLaunch,
runWineCommand,
setupEnvVars,
setupWrapperEnvVars,
Expand Down Expand Up @@ -134,6 +135,8 @@ export async function launchGame(
steamRuntime
} = await prepareLaunch(gameSettings, gameInfo, isNative)

if (!isNative) await prepareWineLaunch(runner, appName)

const wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
Expand All @@ -154,12 +157,6 @@ export async function launchGame(
return false
}

const env = {
...process.env,
...setupWrapperEnvVars({ appName, appRunner: runner }),
...setupEnvVars(gameSettings)
}

// Native
if (isNative) {
logInfo(
Expand All @@ -181,6 +178,11 @@ export async function launchGame(
}

const commandParts = shlex.split(launcherArgs ?? '')
const env = {
...process.env,
...setupWrapperEnvVars({ appName, appRunner: runner }),
...setupEnvVars(gameSettings)
}

await callRunner(
commandParts,
Expand Down
38 changes: 24 additions & 14 deletions src/backend/tools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GameSettings, WineInstallation } from 'common/types'
import { GameSettings, Runner } from 'common/types'
import axios from 'axios'
import {
existsSync,
Expand All @@ -24,14 +24,20 @@ import i18next from 'i18next'
import { dirname, join } from 'path'
import { isOnline } from './online_monitor'
import { showDialogBoxModalAuto } from './dialog/dialog'
import { runWineCommand, validWine } from './launcher'
import {
runWineCommand,
setupEnvVars,
setupWineEnvVars,
validWine
} from './launcher'
import { chmod } from 'fs/promises'
import {
any_gpu_supports_version,
get_nvngx_path,
get_vulkan_instance_version
} from './utils/graphics/vulkan'
import { lt as semverLt } from 'semver'
import { gameManagerMap } from './storeManagers'

export const DXVK = {
getLatest: async () => {
Expand Down Expand Up @@ -420,11 +426,16 @@ export const Winetricks = {
}
},
runWithArgs: async (
wineVersion: WineInstallation,
baseWinePrefix: string,
runner: Runner,
appName: string,
args: string[],
event?: Electron.IpcMainInvokeEvent
) => {
const gameSettings = await gameManagerMap[runner].getSettings(appName)

const { wineVersion } = gameSettings
const baseWinePrefix = gameSettings.winePrefix

if (!(await validWine(wineVersion))) {
return
}
Expand All @@ -445,7 +456,9 @@ export const Winetricks = {
const linuxEnvs = {
...process.env,
WINEPREFIX: winePrefix,
PATH: `${winepath}:${process.env.PATH}`
PATH: `${winepath}:${process.env.PATH}`,
...setupEnvVars(gameSettings),
...setupWineEnvVars(gameSettings, appName)
}

const wineServer = join(winepath, 'wineserver')
Expand All @@ -456,7 +469,9 @@ export const Winetricks = {
WINESERVER: wineServer,
WINE: wineBin,
WINE64: wineBin,
PATH: `/opt/homebrew/bin:${process.env.PATH}`
PATH: `/opt/homebrew/bin:${process.env.PATH}`,
...setupEnvVars(gameSettings),
...setupWineEnvVars(gameSettings, appName)
}

const envs = isMac ? macEnvs : linuxEnvs
Expand Down Expand Up @@ -547,16 +562,11 @@ export const Winetricks = {
})
},
run: async (
wineVersion: WineInstallation,
baseWinePrefix: string,
runner: Runner,
appName: string,
event: Electron.IpcMainInvokeEvent
) => {
await Winetricks.runWithArgs(
wineVersion,
baseWinePrefix,
['--force', '-q'],
event
)
await Winetricks.runWithArgs(runner, appName, ['--force', '-q'], event)
}
}

Expand Down