Skip to content

[Linux/MacOS] Split Enviroment Variable and Wrapper Option #1533

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 27 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dd049d9
First poc
Nocccer Jun 23, 2022
4c9f933
Fixes and small design update
Nocccer Jun 23, 2022
fe17937
Made Table component more generic
Nocccer Jun 24, 2022
4a84136
lint fix
Nocccer Jun 24, 2022
cd0163c
Wrong key fixes
Nocccer Jun 24, 2022
75b1143
Refactor TableInput two 2 Column table
Nocccer Jun 30, 2022
feb5f28
translation update
Nocccer Jun 30, 2022
30a636b
Table component style, some text changes
arielj Jul 3, 2022
2f6c56f
Added mapper for depcrecated otherOptions
Nocccer Jul 6, 2022
57de213
Merge branch 'improve-extra-env' of https://github.com/Heroic-Games-L…
Nocccer Jul 6, 2022
507a47b
Merge branch 'beta' into improve-extra-env
Nocccer Jul 7, 2022
97142e9
Merge branch 'beta' into improve-extra-env
Nocccer Jul 9, 2022
c353f87
Trim input to get rit of unessecary spaces
Nocccer Jul 9, 2022
918e6a1
remove quotes because spawn cares about
Nocccer Jul 10, 2022
d36759b
Remove console.log
Nocccer Jul 10, 2022
fb30a49
Merge branch 'beta' into improve-extra-env
Nocccer Jul 10, 2022
d03d6a6
Merge branch 'beta' into improve-extra-env
Nocccer Jul 10, 2022
93f793d
Implement suggestion
Nocccer Jul 10, 2022
19ef0c0
Merge branch 'beta' into improve-extra-env
Nocccer Jul 10, 2022
7fc5a57
Make Envs editable
Nocccer Jul 11, 2022
e012c01
yarn lint
Nocccer Jul 11, 2022
10e92e2
Merge branch 'beta' into improve-extra-env
Nocccer Jul 11, 2022
dc992bc
Added new util function removeQuoteIfNessecary
Nocccer Jul 11, 2022
00ab791
Small update on old school theme for contrast and
arielj Jul 12, 2022
e19e72a
Merge branch 'beta' into improve-extra-env
Nocccer Jul 12, 2022
02d8377
Small fixes
Nocccer Jul 12, 2022
a11702e
Merge branch 'beta' into improve-extra-env
Nocccer Jul 13, 2022
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
3 changes: 2 additions & 1 deletion electron/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ class GlobalConfigV0 extends GlobalConfig {
maxWorkers: 0,
minimizeOnLaunch: false,
nvidiaPrime: false,
otherOptions: '',
enviromentOptions: [],
wrapperOptions: [],
showUnrealMarket: false,
showFps: false,
useGameMode: false,
Expand Down
6 changes: 4 additions & 2 deletions electron/game_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ class GameConfigV0 extends GameConfig {
launcherArgs,
nvidiaPrime,
offlineMode,
otherOptions,
enviromentOptions,
wrapperOptions,
savesPath,
showFps,
showMangohud,
Expand All @@ -246,7 +247,8 @@ class GameConfigV0 extends GameConfig {
launcherArgs,
nvidiaPrime,
offlineMode,
otherOptions,
enviromentOptions: enviromentOptions,
wrapperOptions,
savesPath,
showFps,
showMangohud,
Expand Down
38 changes: 17 additions & 21 deletions electron/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ import { DXVK } from './tools'
import setup from './gog/setup'
import { GOGGame } from 'gog/games'
import { LegendaryGame } from 'legendary/games'
import { CallRunnerOptions, GameInfo, Runner } from './types'
import {
CallRunnerOptions,
GameInfo,
Runner,
EnviromentVariable,
WrapperVariable,
ExecResult,
GameSettings,
LaunchPreperationResult,
Expand Down Expand Up @@ -240,18 +244,11 @@ 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
})
if (gameSettings.enviromentOptions) {
gameSettings.enviromentOptions.forEach((envEntry: EnviromentVariable) => {
ret[envEntry.key] = quoteIfNecessary(envEntry.value)
})
}

return ret
}

Expand Down Expand Up @@ -298,7 +295,9 @@ function setupWineEnvVars(gameSettings: GameSettings, gameId = '0') {
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=')) {
if (
gameSettings.enviromentOptions.find((env) => env.key === 'PROTON_LOG')
) {
// Stop Proton from overriding WINEDEBUG; this prevents logs growing to a few GB for some games
ret.WINEDEBUG = 'timestamp'
}
Expand All @@ -313,14 +312,11 @@ function setupWrappers(
steamRuntime: string
): Array<string> {
const wrappers = Array<string>()
// Wrappers could be specified in the environment variable section as well
if (gameSettings.otherOptions) {
gameSettings.otherOptions
.split(' ')
.filter((val) => val.indexOf('=') === -1)
.forEach((val) => {
wrappers.push(val)
})
if (gameSettings.wrapperOptions) {
gameSettings.wrapperOptions.forEach((wrapperEntry: WrapperVariable) => {
wrappers.push(wrapperEntry.exe)
wrappers.push(...wrapperEntry.args)
})
}
if (gameSettings.showMangohud) {
// Mangohud needs some arguments in addition to the command, so we have to split here
Expand Down
2 changes: 2 additions & 0 deletions electron/legendary/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ class LegendaryGame extends Game {
...commandEnv,
...setupEnvVars(gameSettings)
}

wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
Expand Down Expand Up @@ -610,6 +611,7 @@ class LegendaryGame extends Game {
...setupEnvVars(gameSettings),
...wineEnvVars
}

wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
Expand Down
16 changes: 14 additions & 2 deletions electron/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export interface AppSettings {
minimizeOnLaunch: boolean
nvidiaPrime: boolean
offlineMode: boolean
otherOptions: string
enviromentOptions: EnviromentVariable[]
wrapperOptions: WrapperVariable[]
savesPath: string
showFps: boolean
showMangohud: boolean
Expand Down Expand Up @@ -149,7 +150,8 @@ export interface GameSettings {
launcherArgs: string
nvidiaPrime: boolean
offlineMode: boolean
otherOptions: string
enviromentOptions: EnviromentVariable[]
wrapperOptions: WrapperVariable[]
savesPath: string
showFps: boolean
showMangohud: boolean
Expand Down Expand Up @@ -374,3 +376,13 @@ export interface CallRunnerOptions {
wrappers?: string[]
onOutput?: (output: string) => void
}

export interface EnviromentVariable {
key: string
value: string
}

export interface WrapperVariable {
exe: string
args: string[]
}
6 changes: 5 additions & 1 deletion electron/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,11 @@ const formatEpicStoreUrl = (title: string) => {
}

function quoteIfNecessary(stringToQuote: string) {
if (stringToQuote.includes(' ')) {
if (
(stringToQuote.charAt(0) !== '"' ||
stringToQuote.charAt(stringToQuote.length - 1) !== '"') &&
stringToQuote.includes(' ')
) {
return `"${stringToQuote}"`
}
return stringToQuote
Expand Down
17 changes: 13 additions & 4 deletions public/locales/bg/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@
},
"infobox": {
"help": "Помощ",
"requirements": "Системни изисквания",
"wine-path": "Path"
"requirements": "Системни изисквания"
},
"install": {
"path": "Изберете местоположение за инсталиране"
Expand Down Expand Up @@ -244,12 +243,22 @@
},
"options": {
"advanced": {
"placeholder": "Тук можете да въведете други аргументи за пускане",
"title": "Разширени настройки (променливи на средата):"
"key": "Key",
"placeHolderKey": "ENVIORMENT",
"placeHolderValue": "E.g.: Path/To/ExtraFiles",
"title": "Разширени настройки (променливи на средата):",
"value": "Value"
},
"gameargs": {
"placeholder": "Въведете аргументите за пускане тук",
"title": "Аргументи за играта (които да се изпълнят след командата):"
},
"wrapper": {
"args": "Arguments",
"exe": "Exe",
"placeHolderKey": "Executable Path",
"placeHolderValue": "Arguments seperated by semicolon (;) e.g.: --arg; --extra-file=\"file-path/ with/spaces\"",
"title": "Wrapper additional arguments"
}
},
"other": {
Expand Down
17 changes: 13 additions & 4 deletions public/locales/ca/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@
},
"infobox": {
"help": "Ajuda",
"requirements": "Requisits del sistema",
"wine-path": "Path"
"requirements": "Requisits del sistema"
},
"install": {
"path": "Selecciona la ruta d'instal·lació"
Expand Down Expand Up @@ -244,12 +243,22 @@
},
"options": {
"advanced": {
"placeholder": "Introdueix altres opcions d'inici",
"title": "Opcions avançades (variables d'entorn):"
"key": "Key",
"placeHolderKey": "ENVIORMENT",
"placeHolderValue": "E.g.: Path/To/ExtraFiles",
"title": "Opcions avançades (variables d'entorn):",
"value": "Value"
},
"gameargs": {
"placeholder": "Introdueix aquí els arguments del llançador",
"title": "Arguments del joc (s'executaran després de l'ordre):"
},
"wrapper": {
"args": "Arguments",
"exe": "Exe",
"placeHolderKey": "Executable Path",
"placeHolderValue": "Arguments seperated by semicolon (;) e.g.: --arg; --extra-file=\"file-path/ with/spaces\"",
"title": "Wrapper additional arguments"
}
},
"other": {
Expand Down
17 changes: 13 additions & 4 deletions public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@
},
"infobox": {
"help": "Pomoc",
"requirements": "Systémové požadavky",
"wine-path": "Path"
"requirements": "Systémové požadavky"
},
"install": {
"path": "Vyberte cestu instalace"
Expand Down Expand Up @@ -244,12 +243,22 @@
},
"options": {
"advanced": {
"placeholder": "Sem vložte ostatní možnosti spuštění",
"title": "Pokročilé možnosti (Proměnné prostředí):"
"key": "Key",
"placeHolderKey": "ENVIORMENT",
"placeHolderValue": "E.g.: Path/To/ExtraFiles",
"title": "Pokročilé možnosti (Proměnné prostředí):",
"value": "Value"
},
"gameargs": {
"placeholder": "Sem vložte argumenty spouštěče",
"title": "Herní argumenty (Pro spuštění po příkazu):"
},
"wrapper": {
"args": "Arguments",
"exe": "Exe",
"placeHolderKey": "Executable Path",
"placeHolderValue": "Arguments seperated by semicolon (;) e.g.: --arg; --extra-file=\"file-path/ with/spaces\"",
"title": "Wrapper additional arguments"
}
},
"other": {
Expand Down
17 changes: 13 additions & 4 deletions public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@
},
"infobox": {
"help": "Hilfe",
"requirements": "Systemanforderungen",
"wine-path": "Path"
"requirements": "Systemanforderungen"
},
"install": {
"path": "Installationspfad auswählen"
Expand Down Expand Up @@ -244,12 +243,22 @@
},
"options": {
"advanced": {
"placeholder": "Gebe hier andere Startoptionen ein",
"title": "Erweiterte Optionen (Umgebungsvariablen):"
"key": "Key",
"placeHolderKey": "ENVIORMENT",
"placeHolderValue": "E.g.: Path/To/ExtraFiles",
"title": "Erweiterte Optionen (Umgebungsvariablen):",
"value": "Value"
},
"gameargs": {
"placeholder": "Lege hier die Spiel-Argumente fest",
"title": "Spiel-Argumente (Zur Ausführung nach dem Befehl):"
},
"wrapper": {
"args": "Arguments",
"exe": "Exe",
"placeHolderKey": "Executable Path",
"placeHolderValue": "Arguments seperated by semicolon (;) e.g.: --arg; --extra-file=\"file-path/ with/spaces\"",
"title": "Wrapper additional arguments"
}
},
"other": {
Expand Down
17 changes: 13 additions & 4 deletions public/locales/el/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@
},
"infobox": {
"help": "Βοήθεια",
"requirements": "Απαιτήσεις Συστήματος",
"wine-path": "Path"
"requirements": "Απαιτήσεις Συστήματος"
},
"install": {
"path": "Επιλέξτε διαδρομή εγκατάστασης"
Expand Down Expand Up @@ -244,12 +243,22 @@
},
"options": {
"advanced": {
"placeholder": "Εισαγάγετε άλλες επιλογές εκκίνησης εδώ",
"title": "Προχωρημένες ρυθμίσεις (Μεταβλητές περιβάλλοντος):"
"key": "Key",
"placeHolderKey": "ENVIORMENT",
"placeHolderValue": "E.g.: Path/To/ExtraFiles",
"title": "Προχωρημένες ρυθμίσεις (Μεταβλητές περιβάλλοντος):",
"value": "Value"
},
"gameargs": {
"placeholder": "Εισαγάγετε τα επιχειρήματα εκκινητή",
"title": "Επιχειρήματα παιχνιδιού (Εκτέλεση μετά την εντολή):"
},
"wrapper": {
"args": "Arguments",
"exe": "Exe",
"placeHolderKey": "Executable Path",
"placeHolderValue": "Arguments seperated by semicolon (;) e.g.: --arg; --extra-file=\"file-path/ with/spaces\"",
"title": "Wrapper additional arguments"
}
},
"other": {
Expand Down
17 changes: 13 additions & 4 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@
},
"infobox": {
"help": "Help",
"requirements": "System Requirements",
"wine-path": "Path"
"requirements": "System Requirements"
},
"install": {
"path": "Select Install Path"
Expand Down Expand Up @@ -244,12 +243,22 @@
},
"options": {
"advanced": {
"placeholder": "Put other launch options here",
"title": "Advanced Options (Environment Variables):"
"key": "Key",
"placeHolderKey": "ENVIORMENT",
"placeHolderValue": "E.g.: Path/To/ExtraFiles",
"title": "Advanced Options (Environment Variables):",
"value": "Value"
},
"gameargs": {
"placeholder": "Put here the Launcher Arguments",
"title": "Game Arguments (To run after the command):"
},
"wrapper": {
"args": "Arguments",
"exe": "Exe",
"placeHolderKey": "Executable Path",
"placeHolderValue": "Arguments seperated by semicolon (;) e.g.: --arg; --extra-file=\"file-path/ with/spaces\"",
"title": "Wrapper additional arguments"
}
},
"other": {
Expand Down
Loading