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 11 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 @@ -579,6 +579,7 @@ class LegendaryGame extends Game {
...commandEnv,
...setupEnvVars(gameSettings)
}

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

wrappers = setupWrappers(
gameSettings,
mangoHudCommand,
Expand Down
45 changes: 42 additions & 3 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
GamepadInputEventKey,
GamepadInputEventWheel,
GamepadInputEventMouse,
Runner
Runner,
AppSettings,
GameSettings
} from './types'
import * as path from 'path'
import {
Expand Down Expand Up @@ -705,11 +707,48 @@ ipcMain.handle('readConfig', async (event, config_class) => {
})

ipcMain.handle('requestSettings', async (event, appName) => {
// To the changes how we handle env and wrappers
// otherOptions is deprectaed and needs to be mapped
// to new approach.
// Can be removed if otherOptions is removed aswell
const mapOtherSettings = (config: AppSettings | GameSettings) => {
if (config.otherOptions) {
if (config.enviromentOptions.length <= 0) {
config.otherOptions
.split(' ')
.filter((val) => val.indexOf('=') !== -1)
.forEach((envKeyAndVar) => {
const keyAndValueSplit = envKeyAndVar.split('=')
const key = keyAndValueSplit.shift()
const value = keyAndValueSplit.join('=')
config.enviromentOptions.push({ key, value })
})
}

if (config.wrapperOptions.length <= 0) {
config.otherOptions
.split(' ')
.filter((val) => val.indexOf('=') === -1)
.forEach((val, index) => {
if (index === 0) {
config.wrapperOptions.push({ exe: val, args: [] })
} else {
config.wrapperOptions.at(0).args.push(val)
}
})
}

delete config.otherOptions
}
return config
}

if (appName === 'default') {
return GlobalConfig.get().config
return mapOtherSettings(GlobalConfig.get().config)
}
// We can't use .config since apparently its not loaded fast enough.
return GameConfig.get(appName).getSettings()
const config = await GameConfig.get(appName).getSettings()
return mapOtherSettings(config)
})

ipcMain.on('toggleDXVK', (event, [{ winePrefix, winePath }, action]) => {
Expand Down
18 changes: 16 additions & 2 deletions electron/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export interface AppSettings {
minimizeOnLaunch: boolean
nvidiaPrime: boolean
offlineMode: boolean
otherOptions: string
otherOptions: string //depricated
enviromentOptions: EnviromentVariable[]
wrapperOptions: WrapperVariable[]
savesPath: string
showFps: boolean
showMangohud: boolean
Expand Down Expand Up @@ -150,7 +152,9 @@ export interface GameSettings {
launcherArgs: string
nvidiaPrime: boolean
offlineMode: boolean
otherOptions: string
otherOptions: string //deprecated
enviromentOptions: EnviromentVariable[]
wrapperOptions: WrapperVariable[]
savesPath: string
showFps: boolean
showMangohud: boolean
Expand Down Expand Up @@ -375,3 +379,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
21 changes: 14 additions & 7 deletions public/locales/bg/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@
},
"general": "Синхронизирайте с EGS, в случай че вече имате работеща инсталация на Epic Games Launcher и искате да внесете игрите си от там, за да избегнете повторното им сваляне.",
"other": {
"part1": "Използвайте ",
"part2": "Разширените настройки",
"part3": "които да се викнат преди пускането на играта; ",
"part4": "Използвайте ",
"part5": "Аргументите за играта",
"part6": " които да се викнат след командата за пускане, например: ",
Expand All @@ -189,8 +186,7 @@
},
"infobox": {
"help": "Помощ",
"requirements": "Системни изисквания",
"wine-path": "Path"
"requirements": "Системни изисквания"
},
"install": {
"path": "Изберете местоположение за инсталиране"
Expand Down Expand Up @@ -244,12 +240,23 @@
},
"options": {
"advanced": {
"placeholder": "Тук можете да въведете други аргументи за пускане",
"title": "Разширени настройки (променливи на средата):"
"key": "Variable Name",
"placeHolderKey": "NAME",
"placeHolderValue": "E.g.: Path/To/ExtraFiles",
"title": "Разширени настройки (променливи на средата):",
"value": "Value"
},
"gameargs": {
"placeholder": "Въведете аргументите за пускане тук",
"title": "Аргументи за играта (които да се изпълнят след командата):"
},
"wrapper": {
"args": "Arguments",
"arguments_example": "Arguments example: --arg; --extra-file=\"file-path/ with/spaces\"",
"exe": "Wrapper",
"placeHolderKey": "New Wrapper",
"placeHolderValue": "Seperated by semicolon (;)",
"title": "Wrapper command:"
}
},
"other": {
Expand Down
21 changes: 14 additions & 7 deletions public/locales/ca/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@
},
"general": "Sincronitza amb l'EGL si ja tens instal·lat l'Epic Games Laucher en qualsevol altre lloc i vols importar els jocs sense haver de baixar-los de nou.",
"other": {
"part1": "Utilitza les ",
"part2": "opcions avançades",
"part3": "abans d'iniciar el joc; ",
"part4": "Utilitza els ",
"part5": "arguments del joc",
"part6": " després de l'ordre d'inici, per exemple: ",
Expand All @@ -189,8 +186,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 +240,23 @@
},
"options": {
"advanced": {
"placeholder": "Introdueix altres opcions d'inici",
"title": "Opcions avançades (variables d'entorn):"
"key": "Variable Name",
"placeHolderKey": "NAME",
"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",
"arguments_example": "Arguments example: --arg; --extra-file=\"file-path/ with/spaces\"",
"exe": "Wrapper",
"placeHolderKey": "New Wrapper",
"placeHolderValue": "Seperated by semicolon (;)",
"title": "Wrapper command:"
}
},
"other": {
Expand Down
21 changes: 14 additions & 7 deletions public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@
},
"general": "Synchronizujte s EGL v případě, že máte funkční instalaci Epic Games Launcher jinde a chcete své hry importovat, abyste se vyhnuli jejich opětovnému stahování.",
"other": {
"part1": "Použijte ",
"part2": "Pokročilé možnosti",
"part3": "které budou použity před spuštěním hry; ",
"part4": "Použijte ",
"part5": "Herní argumenty",
"part6": " které budou použity při spuštění hry, například: ",
Expand All @@ -189,8 +186,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 +240,23 @@
},
"options": {
"advanced": {
"placeholder": "Sem vložte ostatní možnosti spuštění",
"title": "Pokročilé možnosti (Proměnné prostředí):"
"key": "Variable Name",
"placeHolderKey": "NAME",
"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",
"arguments_example": "Arguments example: --arg; --extra-file=\"file-path/ with/spaces\"",
"exe": "Wrapper",
"placeHolderKey": "New Wrapper",
"placeHolderValue": "Seperated by semicolon (;)",
"title": "Wrapper command:"
}
},
"other": {
Expand Down
Loading