Skip to content

Set Steam App ID variables when using the Runtime on Proton + fixup setting user-defined env vars on native games #1355

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 9 commits into from
May 25, 2022
40 changes: 28 additions & 12 deletions electron/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ async function prepareWineLaunch(game: LegendaryGame | GOGGame): Promise<{
}
}

const envVars = setupWineEnvVars(gameSettings)
const installFolderName = (await game.getGameInfo()).folder_name
const envVars = setupWineEnvVars(gameSettings, installFolderName)

return { success: true, envVars: envVars }
}
Expand All @@ -209,16 +210,28 @@ function setupEnvVars(gameSettings: GameSettings) {
if (gameSettings.audioFix) {
ret.PULSE_LATENCY_MSEC = '60'
}
if (gameSettings.otherOptions) {
gameSettings.otherOptions
.split(' ')
.filter((val) => val.indexOf('=') !== -1)
.forEach((envKeyAndVar) => {
const keyAndValueSplit = envKeyAndVar.split('=')
const key = keyAndValueSplit.shift()
const value = keyAndValueSplit.join('=')
ret[key] = value
})
}

return ret
}

/**
* Maps Wine-related settings to environment variables
* @param gameSettings The GameSettings to get the environment variables for
* @param gameId If Proton and the Steam Runtime are used, the SteamGameId variable will be set to `heroic-gameId`
* @returns A Record that can be passed to execAsync/spawn
*/
function setupWineEnvVars(gameSettings: GameSettings) {
function setupWineEnvVars(gameSettings: GameSettings, gameId = '0') {
const { wineVersion } = gameSettings

// Add WINEPREFIX / STEAM_COMPAT_DATA_PATH / CX_BOTTLE
Expand Down Expand Up @@ -246,16 +259,19 @@ function setupWineEnvVars(gameSettings: GameSettings) {
if (gameSettings.enableResizableBar) {
ret.VKD3D_CONFIG = 'upload_hvv'
}
if (gameSettings.otherOptions) {
gameSettings.otherOptions
.split(' ')
.filter((val) => val.indexOf('=') !== -1)
.forEach((envKeyAndVar) => {
const keyAndValueSplit = envKeyAndVar.split('=')
const key = keyAndValueSplit.shift()
const value = keyAndValueSplit.join('=')
ret[key] = value
})
if (gameSettings.useSteamRuntime) {
// If we don't set this, GE-Proton tries to guess the AppID from the prefix path, which doesn't work in our case
ret.STEAM_COMPAT_APP_ID = '0'
ret.SteamAppId = ret.STEAM_COMPAT_APP_ID
// This sets the name of the log file given when setting PROTON_LOG=1
ret.SteamGameId = `heroic-${gameId}`
ret.PROTON_LOG_DIR = flatPakHome

// Only set WINEDEBUG if PROTON_LOG is set since Proton will also log if just WINEDEBUG is set
if (gameSettings.otherOptions.includes('PROTON_LOG=')) {
// Stop Proton from overriding WINEDEBUG; this prevents logs growing to a few GB for some games
ret.WINEDEBUG = 'timestamp'
}
}
return ret
}
Expand Down
8 changes: 4 additions & 4 deletions flatpak/local.heroic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ modules:
- name: heroic
buildsystem: simple
build-commands:
- unappimage Heroic-2.3.1.AppImage
- rm Heroic-2.3.1.AppImage
- unappimage Heroic-2.3.3.AppImage
- rm Heroic-2.3.3.AppImage
- mv squashfs-root /app/bin/heroic
- install -D heroic-run -t /app/bin
sources:
Expand All @@ -135,9 +135,9 @@ modules:
- zypak-wrapper /app/bin/heroic/heroic "$@"

- type: file
filename: Heroic-2.3.1.AppImage
filename: Heroic-2.3.3.AppImage
# put right path here
path: ../dist/Heroic-2.3.1.AppImage
path: ../dist/Heroic-2.3.3.AppImage

- name: platform-bootstrap
buildsystem: simple
Expand Down