Skip to content

Commit b845ce5

Browse files
Nocccerarielj
andauthored
[UI] Show winetricks progress output and Sync-Saves output via React Dialog (#1730)
* First poc * Improved sending output to frontend * Don't set winetricksRunning false dialog backdrop * CSS tweaks in winetricks dialog log * Scroll always to bottom * lint fix * AutoScroll on/off for winetricks log * review suggestions * review suggestions (2) * Add new ProgressDialog component * Make use of ProgressDialog for Sync-Saves * Add margin Co-authored-by: Ariel Juodziukynas <arieljuod@gmail.com>
1 parent df31007 commit b845ce5

40 files changed

Lines changed: 454 additions & 44 deletions

electron/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ ipcMain.handle(
627627

628628
switch (tool) {
629629
case 'winetricks':
630-
Winetricks.run(wineVersion, winePrefix)
630+
await Winetricks.run(wineVersion, winePrefix, event)
631631
break
632632
case 'winecfg':
633633
game.runWineCommand('winecfg')

electron/tools.ts

Lines changed: 74 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -205,39 +205,88 @@ export const Winetricks = {
205205
logWarning('Error Downloading Winetricks', LogPrefix.Backend)
206206
})
207207
},
208-
run: async (wineVersion: WineInstallation, baseWinePrefix: string) => {
209-
const winetricks = `${heroicToolsPath}/winetricks`
208+
run: async (
209+
wineVersion: WineInstallation,
210+
baseWinePrefix: string,
211+
event: Electron.IpcMainInvokeEvent
212+
) => {
213+
return new Promise<void>((resolve) => {
214+
const winetricks = `${heroicToolsPath}/winetricks`
210215

211-
const { winePrefix, wineBin } = getWineFromProton(
212-
wineVersion,
213-
baseWinePrefix
214-
)
216+
const { winePrefix, wineBin } = getWineFromProton(
217+
wineVersion,
218+
baseWinePrefix
219+
)
215220

216-
const winepath = dirname(wineBin)
221+
const winepath = dirname(wineBin)
217222

218-
const envs = {
219-
...process.env,
220-
WINEPREFIX: winePrefix,
221-
PATH: `${winepath}:${process.env.PATH}`
222-
}
223+
const envs = {
224+
...process.env,
225+
WINEPREFIX: winePrefix,
226+
PATH: `${winepath}:${process.env.PATH}`
227+
}
223228

224-
logInfo(
225-
`Running WINEPREFIX='${winePrefix}' PATH='${winepath}':$PATH ${winetricks} -q`,
226-
LogPrefix.WineTricks
227-
)
229+
const executeMessages = [] as string[]
230+
let progressUpdated = false
231+
const appendMessage = (message: string) => {
232+
// Don't store more than 100 messages, to not
233+
// fill the storage and make render still fast
234+
if (executeMessages.length > 100) {
235+
executeMessages.shift()
236+
}
237+
executeMessages.push(message)
238+
progressUpdated = true
239+
}
240+
const sendProgress = setInterval(() => {
241+
if (progressUpdated) {
242+
event.sender.send('progressOfWinetricks', executeMessages)
243+
progressUpdated = false
244+
}
245+
}, 1000)
246+
247+
logInfo(
248+
`Running WINEPREFIX='${winePrefix}' PATH='${winepath}':$PATH ${winetricks} -q`,
249+
LogPrefix.WineTricks
250+
)
228251

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

231-
child.stdout.on('data', (data: Buffer) => {
232-
logInfo(data.toString(), LogPrefix.WineTricks)
233-
})
254+
child.stdout.setEncoding('utf8')
255+
child.stdout.on('data', (data: string) => {
256+
logInfo(data, LogPrefix.WineTricks)
257+
appendMessage(data)
258+
})
234259

235-
child.stderr.on('data', (data: Buffer) => {
236-
logError(data.toString(), LogPrefix.WineTricks)
237-
})
260+
child.stderr.setEncoding('utf8')
261+
child.stderr.on('data', (data: string) => {
262+
logError(data, LogPrefix.WineTricks)
263+
appendMessage(data)
264+
})
238265

239-
child.on('error', (error) => {
240-
logError(`Winetricks throwed Error: ${error}`, LogPrefix.WineTricks)
266+
child.on('error', (error) => {
267+
logError(`Winetricks threw Error: ${error}`, LogPrefix.WineTricks)
268+
showErrorBoxModalAuto(
269+
i18next.t('box.error.winetricks.title', 'Winetricks error'),
270+
i18next.t('box.error.winetricks.message', {
271+
defaultValue:
272+
'Winetricks returned the following error during execution:{{newLine}}{{error}}',
273+
newLine: '\n',
274+
error: `${error}`
275+
})
276+
)
277+
clearInterval(sendProgress)
278+
resolve()
279+
})
280+
281+
child.on('exit', () => {
282+
clearInterval(sendProgress)
283+
resolve()
284+
})
285+
286+
child.on('close', () => {
287+
clearInterval(sendProgress)
288+
resolve()
289+
})
241290
})
242291
}
243292
}

public/locales/bg/translation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"wine-not-found": {
7676
"message": "Няма избрана версия на Wine. Проверете настройките на играта!",
7777
"title": "Wine не е намерен"
78+
},
79+
"winetricks": {
80+
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
81+
"title": "Winetricks error"
7882
}
7983
},
8084
"info": {
@@ -372,6 +376,7 @@
372376
"win": "Уиндоус"
373377
},
374378
"Plugins": "Добавки",
379+
"progress": "Progress",
375380
"Projects": "Проекти",
376381
"Recent": "Играно наскоро",
377382
"search": "Търсене на игри",

public/locales/ca/translation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"wine-not-found": {
7676
"message": "No s'ha seleccionat cap versió del Wine. Comprova la configuració del joc.",
7777
"title": "No s'ha trobat el Wine"
78+
},
79+
"winetricks": {
80+
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
81+
"title": "Winetricks error"
7882
}
7983
},
8084
"info": {
@@ -372,6 +376,7 @@
372376
"win": "Windows"
373377
},
374378
"Plugins": "Extensions",
379+
"progress": "Progress",
375380
"Projects": "Projectes",
376381
"Recent": "Jugats fa poc",
377382
"search": "Cerca jocs",

public/locales/cs/translation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"wine-not-found": {
7676
"message": "Není vybrána žádná verze Wine. Zkontrolujte nastavení hry!",
7777
"title": "Wine nenalezen"
78+
},
79+
"winetricks": {
80+
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
81+
"title": "Winetricks error"
7882
}
7983
},
8084
"info": {
@@ -372,6 +376,7 @@
372376
"win": "Windows"
373377
},
374378
"Plugins": "Plugins",
379+
"progress": "Progress",
375380
"Projects": "Projekty",
376381
"Recent": "Recently Played",
377382
"search": "Vyhledat hry",

public/locales/de/translation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"wine-not-found": {
7676
"message": "Keine Wine Version ausgewählt. Überprüfe die Spieleinstellungen!",
7777
"title": "Wine nicht gefunden"
78+
},
79+
"winetricks": {
80+
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
81+
"title": "Winetricks error"
7882
}
7983
},
8084
"info": {
@@ -372,6 +376,7 @@
372376
"win": "Windows"
373377
},
374378
"Plugins": "Plugins",
379+
"progress": "Progress",
375380
"Projects": "Projekte",
376381
"Recent": "Zuletzt gespielte Spiele",
377382
"search": "Suche nach Spielen",

public/locales/el/translation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"wine-not-found": {
7676
"message": "Δεν επιλέχθηκε έκδοση Wine. Ελέγξτε τις ρυθμίσεις παιχνιδιού!",
7777
"title": "Το Wine δεν βρέθηκε"
78+
},
79+
"winetricks": {
80+
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
81+
"title": "Winetricks error"
7882
}
7983
},
8084
"info": {
@@ -372,6 +376,7 @@
372376
"win": "Windows"
373377
},
374378
"Plugins": "Plugins",
379+
"progress": "Progress",
375380
"Projects": "Πρότζεκτ",
376381
"Recent": "Παίχτηκε Πρόσφατα",
377382
"search": "Αναζήτηση για Παιχνίδια",

public/locales/en/translation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"wine-not-found": {
7676
"message": "No Wine Version Selected. Check Game Settings!",
7777
"title": "Wine Not Found"
78+
},
79+
"winetricks": {
80+
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
81+
"title": "Winetricks error"
7882
}
7983
},
8084
"info": {
@@ -372,6 +376,7 @@
372376
"win": "Windows"
373377
},
374378
"Plugins": "Plugins",
379+
"progress": "Progress",
375380
"Projects": "Projects",
376381
"Recent": "Played Recently",
377382
"search": "Search for Games",

public/locales/es/translation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"wine-not-found": {
7676
"message": "No se ha seleccionado la versión de Wine. ¡Comprueba la configuración del juego!",
7777
"title": "No se ha encontrado Wine"
78+
},
79+
"winetricks": {
80+
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
81+
"title": "Winetricks error"
7882
}
7983
},
8084
"info": {
@@ -372,6 +376,7 @@
372376
"win": "Windows"
373377
},
374378
"Plugins": "Plugins",
379+
"progress": "Progress",
375380
"Projects": "Proyectos",
376381
"Recent": "Jugado recientemente",
377382
"search": "Buscar juegos",

public/locales/et/translation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
"wine-not-found": {
7676
"message": "Wine'i versiooni pole valitud. Kontrolli mängu seadeid!",
7777
"title": "Wine'i ei leitud"
78+
},
79+
"winetricks": {
80+
"message": "Winetricks returned the following error during execution:{{newLine}}{{error}}",
81+
"title": "Winetricks error"
7882
}
7983
},
8084
"info": {
@@ -372,6 +376,7 @@
372376
"win": "Windows"
373377
},
374378
"Plugins": "Pluginad",
379+
"progress": "Progress",
375380
"Projects": "Projektid",
376381
"Recent": "Hiljuti mängitud",
377382
"search": "Otsi mänge",

0 commit comments

Comments
 (0)