diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 0e4d313c4d..6d77c48ded 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -593,7 +593,7 @@ "esync": "Enable Esync", "exit-to-tray": "Exit to System Tray", "experimental_features": { - "automaticWinetricksFixes": "Apply known Winetricks fixes automatically", + "automaticWinetricksFixes": "Apply known fixes automatically", "enableHelp": "Help component", "enableNewDesign": "New design" }, diff --git a/src/backend/launcher.ts b/src/backend/launcher.ts index fe46eb9851..b7b1b92b25 100644 --- a/src/backend/launcher.ts +++ b/src/backend/launcher.ts @@ -11,7 +11,8 @@ import { WineInstallation, WineCommandArgs, SteamRuntime, - GameSettings + GameSettings, + KnowFixesInfo } from 'common/types' // This handles launching games, prefix creation etc.. @@ -75,6 +76,7 @@ import { } from './utils/aborthandler/aborthandler' import { download, isInstalled } from './wine/runtimes/runtimes' import { storeMap } from 'common/utils' +import { runWineCommandOnGame } from './storeManagers/legendary/games' async function prepareLaunch( gameSettings: GameSettings, @@ -403,23 +405,44 @@ async function installFixes(appName: string, runner: Runner) { if (!existsSync(fixPath)) return try { - const fixesContent = JSON.parse(readFileSync(fixPath).toString()) + const fixesContent = JSON.parse( + readFileSync(fixPath).toString() + ) as KnowFixesInfo - sendGameStatusUpdate({ - appName, - runner: runner, - status: 'winetricks' - }) + if (fixesContent.winetricks) { + sendGameStatusUpdate({ + appName, + runner: runner, + status: 'winetricks' + }) + + for (const winetricksPackage of fixesContent.winetricks) { + await Winetricks.install(runner, appName, winetricksPackage) + } + } + + if (fixesContent.runInPrefix) { + const gameInfo = gameManagerMap[runner].getGameInfo(appName) - for (const winetricksPackage of fixesContent.winetricks) { - await Winetricks.install(runner, appName, winetricksPackage) + sendGameStatusUpdate({ + appName, + runner: runner, + status: 'prerequisites' + }) + + for (const filePath of fixesContent.runInPrefix) { + const fullPath = join(gameInfo.install.install_path!, filePath) + await runWineCommandOnGame(appName, { + commandParts: [fullPath], + wait: true, + protonVerb: 'waitforexitandrun' + }) + } } } catch (error) { // if we fail to download the json file, it can be malformed causing // JSON.parse to throw an exception - logWarning( - `Known winetricks fixes could not be applied, ignoring.\n${error}` - ) + logWarning(`Known fixes could not be applied, ignoring.\n${error}`) } } diff --git a/src/common/types.ts b/src/common/types.ts index 0ffb986423..a71b654fec 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -776,3 +776,10 @@ export type InstallInfo = | LegendaryInstallInfo | GogInstallInfo | NileInstallInfo + +export interface KnowFixesInfo { + title: string + notes?: Record + winetricks?: string[] + runInPrefix?: string[] +} diff --git a/src/frontend/screens/Settings/components/ExperimentalFeatures.tsx b/src/frontend/screens/Settings/components/ExperimentalFeatures.tsx index 3d2c0db673..6204d76e39 100644 --- a/src/frontend/screens/Settings/components/ExperimentalFeatures.tsx +++ b/src/frontend/screens/Settings/components/ExperimentalFeatures.tsx @@ -37,7 +37,7 @@ const ExperimentalFeatures = () => { Translations: t('setting.experimental_features.enableNewDesign', 'New design') t('setting.experimental_features.enableHelp', 'Help component') - t('setting.experimental_features.automaticWinetricksFixes', 'Apply known Winetricks fixes automatically') + t('setting.experimental_features.automaticWinetricksFixes', 'Apply known fixes automatically') */ return (