Skip to content

Commit

Permalink
[UX] Add support for autoinstallation of files from game folder (#3448)
Browse files Browse the repository at this point in the history
* Add support for autoinstallation of files from game folder

* Update experimental feature label to not say winetricks
  • Loading branch information
arielj authored Jan 29, 2024
1 parent 5fecd85 commit f6c7ec3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
47 changes: 35 additions & 12 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
WineInstallation,
WineCommandArgs,
SteamRuntime,
GameSettings
GameSettings,
KnowFixesInfo
} from 'common/types'
// This handles launching games, prefix creation etc..

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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}`)
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,3 +776,10 @@ export type InstallInfo =
| LegendaryInstallInfo
| GogInstallInfo
| NileInstallInfo

export interface KnowFixesInfo {
title: string
notes?: Record<string, string>
winetricks?: string[]
runInPrefix?: string[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit f6c7ec3

Please sign in to comment.