Skip to content

[UI] Show winetricks progress output and Sync-Saves output via React Dialog #1730

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 14 commits into from
Aug 30, 2022
2 changes: 1 addition & 1 deletion electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ ipcMain.handle(

switch (tool) {
case 'winetricks':
Winetricks.run(wineVersion, winePrefix)
await Winetricks.run(wineVersion, winePrefix, event)
break
case 'winecfg':
game.runWineCommand('winecfg')
Expand Down
99 changes: 74 additions & 25 deletions electron/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,39 +205,88 @@ export const Winetricks = {
logWarning('Error Downloading Winetricks', LogPrefix.Backend)
})
},
run: async (wineVersion: WineInstallation, baseWinePrefix: string) => {
const winetricks = `${heroicToolsPath}/winetricks`
run: async (
wineVersion: WineInstallation,
baseWinePrefix: string,
event: Electron.IpcMainInvokeEvent
) => {
return new Promise<void>((resolve) => {
const winetricks = `${heroicToolsPath}/winetricks`

const { winePrefix, wineBin } = getWineFromProton(
wineVersion,
baseWinePrefix
)
const { winePrefix, wineBin } = getWineFromProton(
wineVersion,
baseWinePrefix
)

const winepath = dirname(wineBin)
const winepath = dirname(wineBin)

const envs = {
...process.env,
WINEPREFIX: winePrefix,
PATH: `${winepath}:${process.env.PATH}`
}
const envs = {
...process.env,
WINEPREFIX: winePrefix,
PATH: `${winepath}:${process.env.PATH}`
}

logInfo(
`Running WINEPREFIX='${winePrefix}' PATH='${winepath}':$PATH ${winetricks} -q`,
LogPrefix.WineTricks
)
const executeMessages = [] as string[]
let progressUpdated = false
const appendMessage = (message: string) => {
// Don't store more than 100 messages, to not
// fill the storage and make render still fast
if (executeMessages.length > 100) {
executeMessages.shift()
}
executeMessages.push(message)
progressUpdated = true
}
const sendProgress = setInterval(() => {
if (progressUpdated) {
event.sender.send('progressOfWinetricks', executeMessages)
progressUpdated = false
}
}, 1000)

logInfo(
`Running WINEPREFIX='${winePrefix}' PATH='${winepath}':$PATH ${winetricks} -q`,
LogPrefix.WineTricks
)

const child = spawn(winetricks, ['-q'], { env: envs })
const child = spawn(winetricks, ['-q'], { env: envs })

child.stdout.on('data', (data: Buffer) => {
logInfo(data.toString(), LogPrefix.WineTricks)
})
child.stdout.setEncoding('utf8')
child.stdout.on('data', (data: string) => {
logInfo(data, LogPrefix.WineTricks)
appendMessage(data)
})

child.stderr.on('data', (data: Buffer) => {
logError(data.toString(), LogPrefix.WineTricks)
})
child.stderr.setEncoding('utf8')
child.stderr.on('data', (data: string) => {
logError(data, LogPrefix.WineTricks)
appendMessage(data)
})

child.on('error', (error) => {
logError(`Winetricks throwed Error: ${error}`, LogPrefix.WineTricks)
child.on('error', (error) => {
logError(`Winetricks threw Error: ${error}`, LogPrefix.WineTricks)
showErrorBoxModalAuto(
i18next.t('box.error.winetricks.title', 'Winetricks error'),
i18next.t('box.error.winetricks.message', {
defaultValue:
'Winetricks returned the following error during execution:{{newLine}}{{error}}',
newLine: '\n',
error: `${error}`
})
)
clearInterval(sendProgress)
resolve()
})

child.on('exit', () => {
clearInterval(sendProgress)
resolve()
})

child.on('close', () => {
clearInterval(sendProgress)
resolve()
})
})
}
}
5 changes: 5 additions & 0 deletions public/locales/bg/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "Няма избрана версия на Wine. Проверете настройките на играта!",
"title": "Wine не е намерен"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Уиндоус"
},
"Plugins": "Добавки",
"progress": "Progress",
"Projects": "Проекти",
"Recent": "Играно наскоро",
"search": "Търсене на игри",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/ca/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "No s'ha seleccionat cap versió del Wine. Comprova la configuració del joc.",
"title": "No s'ha trobat el Wine"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Extensions",
"progress": "Progress",
"Projects": "Projectes",
"Recent": "Jugats fa poc",
"search": "Cerca jocs",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "Není vybrána žádná verze Wine. Zkontrolujte nastavení hry!",
"title": "Wine nenalezen"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Plugins",
"progress": "Progress",
"Projects": "Projekty",
"Recent": "Recently Played",
"search": "Vyhledat hry",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "Keine Wine Version ausgewählt. Überprüfe die Spieleinstellungen!",
"title": "Wine nicht gefunden"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Plugins",
"progress": "Progress",
"Projects": "Projekte",
"Recent": "Zuletzt gespielte Spiele",
"search": "Suche nach Spielen",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/el/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "Δεν επιλέχθηκε έκδοση Wine. Ελέγξτε τις ρυθμίσεις παιχνιδιού!",
"title": "Το Wine δεν βρέθηκε"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Plugins",
"progress": "Progress",
"Projects": "Πρότζεκτ",
"Recent": "Παίχτηκε Πρόσφατα",
"search": "Αναζήτηση για Παιχνίδια",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "No Wine Version Selected. Check Game Settings!",
"title": "Wine Not Found"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Plugins",
"progress": "Progress",
"Projects": "Projects",
"Recent": "Played Recently",
"search": "Search for Games",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "No se ha seleccionado la versión de Wine. ¡Comprueba la configuración del juego!",
"title": "No se ha encontrado Wine"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Plugins",
"progress": "Progress",
"Projects": "Proyectos",
"Recent": "Jugado recientemente",
"search": "Buscar juegos",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/et/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "Wine'i versiooni pole valitud. Kontrolli mängu seadeid!",
"title": "Wine'i ei leitud"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Pluginad",
"progress": "Progress",
"Projects": "Projektid",
"Recent": "Hiljuti mängitud",
"search": "Otsi mänge",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/fa/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "نسخه ای از Wine انتخاب نشده است. تنظیمات بازی را چک کنید!",
"title": "Wine یافت نشد"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "ویندوز"
},
"Plugins": "افزونهها",
"progress": "Progress",
"Projects": "پروژهها",
"Recent": "اخیرا بازی شده",
"search": "جست و جو برای بازی ها",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/fi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "Winen versiota ei ole valittu. Tarkista peliasetukset!",
"title": "Wineä ei löytynyt"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Laajennukset",
"progress": "Progress",
"Projects": "Projektit",
"Recent": "Viimeksi pelatut",
"search": "Kirjoita tähän pelin nimi...",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "No Wine Version Selected. Check Game Settings!",
"title": "Wine non trouvé"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Plugins",
"progress": "Progress",
"Projects": "Projets",
"Recent": "Joué récemment",
"search": "Insérez le nom du jeu ici...",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/gl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "No se seleccionou a versión de Wine. ¡Comprueba a configuración do xogo!",
"title": "No se atopou Wine"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Engadidos",
"progress": "Progress",
"Projects": "Proxectos",
"Recent": "Xogado recentemente",
"search": "Escribe o nome do xogo aquí...",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/hr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "No Wine Version Selected. Check Game Settings!",
"title": "Wine Not Found"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Plugins",
"progress": "Progress",
"Projects": "Projects",
"Recent": "Played Recently",
"search": "Traži igre",
Expand Down
5 changes: 5 additions & 0 deletions public/locales/hu/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"wine-not-found": {
"message": "Nincs kiválasztott Wine verzió. Ellenőrizd a játék beállításait!",
"title": "Wine nem található"
},
"winetricks": {
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
"title": "Winetricks error"
}
},
"info": {
Expand Down Expand Up @@ -356,6 +360,7 @@
"win": "Windows"
},
"Plugins": "Beépülők",
"progress": "Progress",
"Projects": "Projektek",
"Recent": "Nemrég játszott",
"search": "Játékok keresése",
Expand Down
Loading