From adf0ea3ec3a92b2a09214a54663eacb3b69a6a73 Mon Sep 17 00:00:00 2001 From: Nocccer Date: Sun, 14 Aug 2022 21:58:41 +0200 Subject: [PATCH 01/12] First poc --- electron/main.ts | 2 +- electron/tools.ts | 32 ++++++++++++++--- .../Settings/components/Tools/index.tsx | 36 +++++++++++++++++++ 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index 4c69d38b8d..0ece9194a7 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -624,7 +624,7 @@ ipcMain.handle( switch (tool) { case 'winetricks': - Winetricks.run(wineVersion, winePrefix) + Winetricks.run(wineVersion, winePrefix, event) break case 'winecfg': game.runWineCommand('winecfg') diff --git a/electron/tools.ts b/electron/tools.ts index 266ce3509b..650b820ce9 100644 --- a/electron/tools.ts +++ b/electron/tools.ts @@ -205,7 +205,11 @@ export const Winetricks = { logWarning('Error Downloading Winetricks', LogPrefix.Backend) }) }, - run: async (wineVersion: WineInstallation, baseWinePrefix: string) => { + run: async ( + wineVersion: WineInstallation, + baseWinePrefix: string, + event: Electron.IpcMainInvokeEvent + ) => { const winetricks = `${heroicToolsPath}/winetricks` const { winePrefix, wineBin } = getWineFromProton( @@ -221,6 +225,10 @@ export const Winetricks = { PATH: `${winepath}:${process.env.PATH}` } + const sendProgress = (running: boolean, info: string, error: string) => { + event.sender.send('progressOfWinetricks', { running, info, error }) + } + logInfo( `Running WINEPREFIX='${winePrefix}' PATH='${winepath}':$PATH ${winetricks} -q`, LogPrefix.WineTricks @@ -228,16 +236,30 @@ export const Winetricks = { 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) + if (data.includes('Executing')) { + sendProgress(true, 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) + sendProgress(true, '', data) }) child.on('error', (error) => { logError(`Winetricks throwed Error: ${error}`, LogPrefix.WineTricks) }) + + child.on('close', () => { + sendProgress(false, '', '') + }) + + child.on('exit', () => { + sendProgress(false, '', '') + }) } } diff --git a/src/screens/Settings/components/Tools/index.tsx b/src/screens/Settings/components/Tools/index.tsx index 6b292fad96..693bb3fc6c 100644 --- a/src/screens/Settings/components/Tools/index.tsx +++ b/src/screens/Settings/components/Tools/index.tsx @@ -8,6 +8,7 @@ import { getGameInfo, quoteIfNecessary } from 'src/helpers' import { ipcRenderer } from 'src/helpers' import { Runner } from 'src/types' +import { Dialog, DialogContent, DialogHeader } from 'src/components/UI/Dialog' interface Props { appName: string @@ -18,6 +19,19 @@ export default function Tools({ appName, runner }: Props) { const { t } = useTranslation() const [winecfgRunning, setWinecfgRunning] = useState(false) const [winetricksRunning, setWinetricksRunning] = useState(false) + const [progress, setProgress] = useState<{ + running: boolean + info: string + error: string + }>({ running: false, info: '', error: '' }) + + ipcRenderer.on('progressOfWinetricks', (e, status) => { + setProgress({ + running: status.running, + info: status.info ?? progress.info, + error: status.error ?? progress.error + }) + }) type Tool = 'winecfg' | 'winetricks' | string async function callTools(tool: Tool, exe?: string) { @@ -79,6 +93,28 @@ export default function Tools({ appName, runner }: Props) { return ( <>
+ {winetricksRunning || + (progress.running && ( + { + setProgress({ running: false, info: '', error: '' }) + }} + > + { + setProgress({ running: false, info: '', error: '' }) + }} + > +
Winetricks
+
+ +
Progress:
+ {progress.info} +
Error:
+ {progress.error} +
+
+ ))}
+
+
From b7649b8c257457fb95572178d0e6a4d42bd26ea6 Mon Sep 17 00:00:00 2001 From: Nocccer Date: Mon, 15 Aug 2022 18:12:49 +0200 Subject: [PATCH 06/12] lint fix --- src/screens/Settings/components/Tools/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/screens/Settings/components/Tools/index.tsx b/src/screens/Settings/components/Tools/index.tsx index 37d7301131..97fc1f2d3b 100644 --- a/src/screens/Settings/components/Tools/index.tsx +++ b/src/screens/Settings/components/Tools/index.tsx @@ -51,12 +51,12 @@ export default function Tools({ appName, runner }: Props) { }, [winetricksRunning]) const scrollToBottom = () => { - winetricksOutputBottomRef.current?.scrollIntoView({behavior: 'auto'}) + winetricksOutputBottomRef.current?.scrollIntoView({ behavior: 'auto' }) } useEffect(() => { scrollToBottom() - }, [progress]); + }, [progress]) const handleRunExe = async () => { let exe = '' @@ -137,8 +137,8 @@ export default function Tools({ appName, runner }: Props) { ) } })} -
-
+
+
From 6be9961d53a37301b921b7e1da69d261e6e0ed56 Mon Sep 17 00:00:00 2001 From: Ariel Juodziukynas Date: Mon, 15 Aug 2022 14:15:49 -0300 Subject: [PATCH 07/12] AutoScroll on/off for winetricks log --- .../Settings/components/Tools/index.tsx | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/screens/Settings/components/Tools/index.tsx b/src/screens/Settings/components/Tools/index.tsx index 97fc1f2d3b..4668e0773e 100644 --- a/src/screens/Settings/components/Tools/index.tsx +++ b/src/screens/Settings/components/Tools/index.tsx @@ -22,6 +22,8 @@ export default function Tools({ appName, runner }: Props) { const [winetricksRunning, setWinetricksRunning] = useState(false) const [progress, setProgress] = useState([]) const winetricksOutputBottomRef = useRef(null) + const logRef = useRef(null) + const [autoScroll, setAutoScroll] = useState(true) ipcRenderer.on('progressOfWinetricks', (e, messages) => { setProgress(messages) @@ -55,8 +57,26 @@ export default function Tools({ appName, runner }: Props) { } useEffect(() => { - scrollToBottom() - }, [progress]) + if (autoScroll) { + scrollToBottom() + } + }, [progress, autoScroll]) + + const onLogScroll = (ev: Event) => { + const target = ev.target as HTMLDivElement + + const atTheBottom = + target.scrollTop + target.getBoundingClientRect().height >= + target.scrollHeight + + setAutoScroll(atTheBottom) + } + + useEffect(() => { + if (logRef.current) { + logRef.current.addEventListener('scroll', onLogScroll) + } + }, [logRef.current]) const handleRunExe = async () => { let exe = '' @@ -115,7 +135,7 @@ export default function Tools({ appName, runner }: Props) {
Progress:
-
+
{progress.map((line, key) => { if (line.toLowerCase().includes(' err')) { return ( From a99d85ca1dd01e324888a4b2601649d16310e4f8 Mon Sep 17 00:00:00 2001 From: Nocccer Date: Mon, 15 Aug 2022 22:32:47 +0200 Subject: [PATCH 08/12] review suggestions --- electron/tools.ts | 4 ++-- public/locales/bg/translation.json | 3 ++- public/locales/ca/translation.json | 3 ++- public/locales/cs/translation.json | 3 ++- public/locales/de/translation.json | 3 ++- public/locales/el/translation.json | 3 ++- public/locales/en/translation.json | 3 ++- public/locales/es/translation.json | 3 ++- public/locales/et/translation.json | 3 ++- public/locales/fa/translation.json | 3 ++- public/locales/fi/translation.json | 3 ++- public/locales/fr/translation.json | 3 ++- public/locales/gl/translation.json | 3 ++- public/locales/hr/translation.json | 3 ++- public/locales/hu/translation.json | 3 ++- public/locales/id/translation.json | 3 ++- public/locales/it/translation.json | 3 ++- public/locales/ja/translation.json | 3 ++- public/locales/ko/translation.json | 3 ++- public/locales/ml/translation.json | 3 ++- public/locales/nl/translation.json | 3 ++- public/locales/pl/translation.json | 3 ++- public/locales/pt/translation.json | 3 ++- public/locales/pt_BR/translation.json | 3 ++- public/locales/ru/translation.json | 3 ++- public/locales/sv/translation.json | 3 ++- public/locales/ta/translation.json | 3 ++- public/locales/tr/translation.json | 3 ++- public/locales/uk/translation.json | 3 ++- public/locales/vi/translation.json | 3 ++- public/locales/zh_Hans/translation.json | 3 ++- public/locales/zh_Hant/translation.json | 3 ++- src/screens/Settings/components/Tools/index.tsx | 12 +++++++----- 33 files changed, 71 insertions(+), 38 deletions(-) diff --git a/electron/tools.ts b/electron/tools.ts index bf3f131113..b330da1584 100644 --- a/electron/tools.ts +++ b/electron/tools.ts @@ -264,12 +264,12 @@ export const Winetricks = { }) child.on('error', (error) => { - logError(`Winetricks throwed Error: ${error}`, LogPrefix.WineTricks) + logError(`Winetricks threw Error: ${error}`, LogPrefix.WineTricks) showErrorBoxModalAuto( i18next.t('box.error.winetricks.title', 'Winetricks error'), i18next.t('box.error.winetricks.message', { defaultValue: - 'Winetricks throwed following error during execution:{{newLine}}{{error}}', + 'Winetricks returned the following error during execution:{{newLine}}{{error}}', newLine: '\n', error: `${error}` }) diff --git a/public/locales/bg/translation.json b/public/locales/bg/translation.json index 3c3bcf7b12..7d883ab4da 100644 --- a/public/locales/bg/translation.json +++ b/public/locales/bg/translation.json @@ -77,7 +77,7 @@ "title": "Wine не е намерен" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Уиндоус" }, "Plugins": "Добавки", + "progress": "Progress", "Projects": "Проекти", "Recent": "Играно наскоро", "search": "Търсене на игри", diff --git a/public/locales/ca/translation.json b/public/locales/ca/translation.json index 1bf6a6e899..783ad6f3cc 100644 --- a/public/locales/ca/translation.json +++ b/public/locales/ca/translation.json @@ -77,7 +77,7 @@ "title": "No s'ha trobat el Wine" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Extensions", + "progress": "Progress", "Projects": "Projectes", "Recent": "Jugats fa poc", "search": "Cerca jocs", diff --git a/public/locales/cs/translation.json b/public/locales/cs/translation.json index ee68c7f9d4..fbce86254b 100644 --- a/public/locales/cs/translation.json +++ b/public/locales/cs/translation.json @@ -77,7 +77,7 @@ "title": "Wine nenalezen" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Projekty", "Recent": "Recently Played", "search": "Vyhledat hry", diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 659a48a061..357e82a938 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -77,7 +77,7 @@ "title": "Wine nicht gefunden" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Projekte", "Recent": "Zuletzt gespielte Spiele", "search": "Suche nach Spielen", diff --git a/public/locales/el/translation.json b/public/locales/el/translation.json index d194793935..1877c6ef20 100644 --- a/public/locales/el/translation.json +++ b/public/locales/el/translation.json @@ -77,7 +77,7 @@ "title": "Το Wine δεν βρέθηκε" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Πρότζεκτ", "Recent": "Παίχτηκε Πρόσφατα", "search": "Αναζήτηση για Παιχνίδια", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index c65b6f7050..7199d6fc0f 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -77,7 +77,7 @@ "title": "Wine Not Found" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Projects", "Recent": "Played Recently", "search": "Search for Games", diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index aa2208c8de..8db3bc6a47 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -77,7 +77,7 @@ "title": "No se ha encontrado Wine" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Proyectos", "Recent": "Jugado recientemente", "search": "Buscar juegos", diff --git a/public/locales/et/translation.json b/public/locales/et/translation.json index afd61bac53..b7b130c8ad 100644 --- a/public/locales/et/translation.json +++ b/public/locales/et/translation.json @@ -77,7 +77,7 @@ "title": "Wine'i ei leitud" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Pluginad", + "progress": "Progress", "Projects": "Projektid", "Recent": "Hiljuti mängitud", "search": "Otsi mänge", diff --git a/public/locales/fa/translation.json b/public/locales/fa/translation.json index 79ec3a3997..3552d84c83 100644 --- a/public/locales/fa/translation.json +++ b/public/locales/fa/translation.json @@ -77,7 +77,7 @@ "title": "Wine یافت نشد" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "ویندوز" }, "Plugins": "افزونهها", + "progress": "Progress", "Projects": "پروژهها", "Recent": "اخیرا بازی شده", "search": "جست و جو برای بازی ها", diff --git a/public/locales/fi/translation.json b/public/locales/fi/translation.json index f1d34394be..3cd344e503 100644 --- a/public/locales/fi/translation.json +++ b/public/locales/fi/translation.json @@ -77,7 +77,7 @@ "title": "Wineä ei löytynyt" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Laajennukset", + "progress": "Progress", "Projects": "Projektit", "Recent": "Viimeksi pelatut", "search": "Kirjoita tähän pelin nimi...", diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index dae5251b21..ed5db3e150 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -77,7 +77,7 @@ "title": "Wine non trouvé" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Projets", "Recent": "Joué récemment", "search": "Insérez le nom du jeu ici...", diff --git a/public/locales/gl/translation.json b/public/locales/gl/translation.json index 0969642047..a8aefb5cd5 100644 --- a/public/locales/gl/translation.json +++ b/public/locales/gl/translation.json @@ -77,7 +77,7 @@ "title": "No se atopou Wine" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Engadidos", + "progress": "Progress", "Projects": "Proxectos", "Recent": "Xogado recentemente", "search": "Escribe o nome do xogo aquí...", diff --git a/public/locales/hr/translation.json b/public/locales/hr/translation.json index e5270ff18b..2c057e57ff 100644 --- a/public/locales/hr/translation.json +++ b/public/locales/hr/translation.json @@ -77,7 +77,7 @@ "title": "Wine Not Found" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Projects", "Recent": "Played Recently", "search": "Traži igre", diff --git a/public/locales/hu/translation.json b/public/locales/hu/translation.json index aa3b15f061..0c45fd1e5f 100644 --- a/public/locales/hu/translation.json +++ b/public/locales/hu/translation.json @@ -77,7 +77,7 @@ "title": "Wine nem található" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,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", diff --git a/public/locales/id/translation.json b/public/locales/id/translation.json index 6c45adf49e..a1f6c8b36f 100644 --- a/public/locales/id/translation.json +++ b/public/locales/id/translation.json @@ -77,7 +77,7 @@ "title": "Wine Tidak Ditemukan" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Pengaya", + "progress": "Progress", "Projects": "Proyek", "Recent": "Dimainkan Baru-Baru Ini", "search": "Cari Gim", diff --git a/public/locales/it/translation.json b/public/locales/it/translation.json index 09c0cf171c..a28386fa3d 100644 --- a/public/locales/it/translation.json +++ b/public/locales/it/translation.json @@ -77,7 +77,7 @@ "title": "Wine non trovato" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Progetti", "Recent": "Giocato di recente", "search": "Cerca giochi", diff --git a/public/locales/ja/translation.json b/public/locales/ja/translation.json index cb1eb95c0a..2590237087 100644 --- a/public/locales/ja/translation.json +++ b/public/locales/ja/translation.json @@ -77,7 +77,7 @@ "title": "Wine Not Found" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "ウィンドウズ" }, "Plugins": "プラグイン", + "progress": "Progress", "Projects": "プロジェクト", "Recent": "最近のゲーム", "search": "ここにゲーム名を入力してください...", diff --git a/public/locales/ko/translation.json b/public/locales/ko/translation.json index 39e542921c..48c139b3ca 100644 --- a/public/locales/ko/translation.json +++ b/public/locales/ko/translation.json @@ -77,7 +77,7 @@ "title": "Wine을 찾을 수 없음" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "플러그인", + "progress": "Progress", "Projects": "프로젝트", "Recent": "최근 플레이한 게임", "search": "게임 검색", diff --git a/public/locales/ml/translation.json b/public/locales/ml/translation.json index 203eff589e..a9d1df3ffe 100644 --- a/public/locales/ml/translation.json +++ b/public/locales/ml/translation.json @@ -77,7 +77,7 @@ "title": "Wine Not Found" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "വിൻഡോസ്" }, "Plugins": "കൂടുതലുകള്", + "progress": "Progress", "Projects": "ഏര്പാടുകള്", "Recent": "പതിവ് കളികള്", "search": "കളിയുടെ പേര് ഇവിടെ എഴുതൂ...", diff --git a/public/locales/nl/translation.json b/public/locales/nl/translation.json index 25a2d80718..1277a28aa0 100644 --- a/public/locales/nl/translation.json +++ b/public/locales/nl/translation.json @@ -77,7 +77,7 @@ "title": "Wine Not Found" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "ramen" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Projecten", "Recent": "Recente Spellen", "search": "Voor je spel naam hier in...", diff --git a/public/locales/pl/translation.json b/public/locales/pl/translation.json index c586c79c46..52cdee9af9 100644 --- a/public/locales/pl/translation.json +++ b/public/locales/pl/translation.json @@ -77,7 +77,7 @@ "title": "Nie znaleziono Wine" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Rozszerzenia", + "progress": "Progress", "Projects": "Projekty", "Recent": "Ostatnio uruchamiane", "search": "Wyszukaj gry", diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json index 49dc08903c..216a31ad37 100644 --- a/public/locales/pt/translation.json +++ b/public/locales/pt/translation.json @@ -77,7 +77,7 @@ "title": "Wine Not Found" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "janelas" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Projetos", "Recent": "Played Recently", "search": "Digite o nome do jogo...", diff --git a/public/locales/pt_BR/translation.json b/public/locales/pt_BR/translation.json index e6f6ba75d7..ce787a216c 100644 --- a/public/locales/pt_BR/translation.json +++ b/public/locales/pt_BR/translation.json @@ -77,7 +77,7 @@ "title": "Wine Não Encontrado" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Projetos", "Recent": "Jogados Recentemente", "search": "Buscar jogos", diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index ef7c3848ed..983ce7d387 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -77,7 +77,7 @@ "title": "Wine не найден" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Плагины", + "progress": "Progress", "Projects": "Проекты", "Recent": "Запускались недавно", "search": "Поиск игр", diff --git a/public/locales/sv/translation.json b/public/locales/sv/translation.json index 0578f86088..645e1a77d8 100644 --- a/public/locales/sv/translation.json +++ b/public/locales/sv/translation.json @@ -77,7 +77,7 @@ "title": "Wine hittades ej" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugins", + "progress": "Progress", "Projects": "Projekt", "Recent": "Nyligen spelat", "search": "Sök efter spel", diff --git a/public/locales/ta/translation.json b/public/locales/ta/translation.json index 03eeb27bd0..d6fab3eeb2 100644 --- a/public/locales/ta/translation.json +++ b/public/locales/ta/translation.json @@ -77,7 +77,7 @@ "title": "Wine Not Found" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "விண்டோஸ்" }, "Plugins": "செருகுநிரல்கள்", + "progress": "Progress", "Projects": "செயல்திட்டம்", "Recent": "சமீபத்தில் விளையாடியவை", "search": "விளையாட்டுகளைத் தேடு", diff --git a/public/locales/tr/translation.json b/public/locales/tr/translation.json index 9bbd76db84..360287ec32 100644 --- a/public/locales/tr/translation.json +++ b/public/locales/tr/translation.json @@ -77,7 +77,7 @@ "title": "Wine Bulunamadı" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Eklentiler", + "progress": "Progress", "Projects": "Projeler", "Recent": "Son Oynanan", "search": "Oyun Ara", diff --git a/public/locales/uk/translation.json b/public/locales/uk/translation.json index d00f078c80..9973f7d7d8 100644 --- a/public/locales/uk/translation.json +++ b/public/locales/uk/translation.json @@ -77,7 +77,7 @@ "title": "Wine не знайдено" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Плагіни", + "progress": "Progress", "Projects": "Проєкти", "Recent": "Нещодавно зіграні", "search": "Пошук ігор", diff --git a/public/locales/vi/translation.json b/public/locales/vi/translation.json index b97af0b600..c35476b25e 100644 --- a/public/locales/vi/translation.json +++ b/public/locales/vi/translation.json @@ -77,7 +77,7 @@ "title": "Không tìm thấy Wine" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "Plugin", + "progress": "Progress", "Projects": "Project", "Recent": "Chơi gần đây", "search": "Tìm kiếm game", diff --git a/public/locales/zh_Hans/translation.json b/public/locales/zh_Hans/translation.json index 4046670260..50f7d79f4d 100644 --- a/public/locales/zh_Hans/translation.json +++ b/public/locales/zh_Hans/translation.json @@ -77,7 +77,7 @@ "title": "未找到 Wine" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "插件", + "progress": "Progress", "Projects": "项目", "Recent": "最近玩过", "search": "搜索游戏", diff --git a/public/locales/zh_Hant/translation.json b/public/locales/zh_Hant/translation.json index 264a23cf06..1cf1865942 100644 --- a/public/locales/zh_Hant/translation.json +++ b/public/locales/zh_Hant/translation.json @@ -77,7 +77,7 @@ "title": "未找到Wine" }, "winetricks": { - "message": "Winetricks throwed following error during execution:{{newLine}}{{error}}", + "message": "Winetricks returned the following error during execution:{{newLine}}{{error}}", "title": "Winetricks error" } }, @@ -360,6 +360,7 @@ "win": "Windows" }, "Plugins": "外掛插件", + "progress": "Progress", "Projects": "專案", "Recent": "最近遊玩的遊戲", "search": "搜尋遊戲", diff --git a/src/screens/Settings/components/Tools/index.tsx b/src/screens/Settings/components/Tools/index.tsx index 97fc1f2d3b..e3db0a8c4c 100644 --- a/src/screens/Settings/components/Tools/index.tsx +++ b/src/screens/Settings/components/Tools/index.tsx @@ -23,10 +23,6 @@ export default function Tools({ appName, runner }: Props) { const [progress, setProgress] = useState([]) const winetricksOutputBottomRef = useRef(null) - ipcRenderer.on('progressOfWinetricks', (e, messages) => { - setProgress(messages) - }) - type Tool = 'winecfg' | 'winetricks' | string async function callTools(tool: Tool, exe?: string) { if (tool === 'winetricks') { @@ -46,6 +42,12 @@ export default function Tools({ appName, runner }: Props) { setWinecfgRunning(false) } + useEffect(() => { + ipcRenderer.on('progressOfWinetricks', (e, messages) => { + setProgress(messages) + }) + }, []) + useEffect(() => { setProgress([]) }, [winetricksRunning]) @@ -114,7 +116,7 @@ export default function Tools({ appName, runner }: Props) {
Winetricks
-
Progress:
+
{t('progress', 'Progress')}:
{progress.map((line, key) => { if (line.toLowerCase().includes(' err')) { From be3227ae0b881ed173cc88392ecc755a9bbfd653 Mon Sep 17 00:00:00 2001 From: Nocccer Date: Thu, 18 Aug 2022 15:55:15 +0200 Subject: [PATCH 09/12] review suggestions (2) --- src/screens/Settings/components/Tools/index.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/screens/Settings/components/Tools/index.tsx b/src/screens/Settings/components/Tools/index.tsx index 1f4e4e453e..9b276c58b7 100644 --- a/src/screens/Settings/components/Tools/index.tsx +++ b/src/screens/Settings/components/Tools/index.tsx @@ -45,9 +45,16 @@ export default function Tools({ appName, runner }: Props) { } useEffect(() => { - ipcRenderer.on('progressOfWinetricks', (e, messages) => { + const onProgress = (e: Electron.IpcRendererEvent, messages: string[]) => { setProgress(messages) - }) + } + + ipcRenderer.on('progressOfWinetricks', onProgress) + + //useEffect unmount + return () => { + ipcRenderer.removeListener('progressOfWinetricks', onProgress) + } }, []) useEffect(() => { From db4adb3fef74cf80e81ee3e366f6e4008be69c28 Mon Sep 17 00:00:00 2001 From: Nocccer Date: Thu, 25 Aug 2022 20:57:24 +0200 Subject: [PATCH 10/12] Add new ProgressDialog component --- src/components/UI/ProgressDialog/index.css | 50 +++++++++++ src/components/UI/ProgressDialog/index.tsx | 82 +++++++++++++++++++ .../Settings/components/Tools/index.css | 51 ------------ .../Settings/components/Tools/index.tsx | 77 ++--------------- 4 files changed, 138 insertions(+), 122 deletions(-) create mode 100644 src/components/UI/ProgressDialog/index.css create mode 100644 src/components/UI/ProgressDialog/index.tsx diff --git a/src/components/UI/ProgressDialog/index.css b/src/components/UI/ProgressDialog/index.css new file mode 100644 index 0000000000..094603cb7f --- /dev/null +++ b/src/components/UI/ProgressDialog/index.css @@ -0,0 +1,50 @@ +.progressDialog { + max-width: min(700px, 85vw); + width: 100%; +} + +.progressDialog .Dialog__content { + width: 100%; +} + +.progressDialog .Dialog__headerClose { + display: none; +} + +.progressDialog.log-box { + background-color: #1e1e1e; + border-radius: 10px; + padding-block: 4px; + padding-inline: 6px; + height: 25em; + width: calc(90vw - var(--sidebar-width)); + overflow: auto; + user-select: text; +} + +.progressDialog.log-box.collapsed { + width: calc(90vw - var(--sidebar-width)); +} + +.progressDialog.log-error, +.progressDialog.log-warning, +.progressDialog.log-info { + text-align: left; + margin-block: 0; + min-height: 1em; + height: max-content; + white-space: pre; + font-family: monospace; +} + +.progressDialog.log-error { + color: #c18672; +} + +.progressDialog.log-warning { + color: #f5cf69; +} + +.progressDialog.log-info { + color: rgb(175, 172, 172); +} diff --git a/src/components/UI/ProgressDialog/index.tsx b/src/components/UI/ProgressDialog/index.tsx new file mode 100644 index 0000000000..1c19356443 --- /dev/null +++ b/src/components/UI/ProgressDialog/index.tsx @@ -0,0 +1,82 @@ +import './index.css' + +import React, { useEffect, useRef, useState } from 'react' +import { Dialog, DialogContent, DialogHeader } from 'src/components/UI/Dialog' +import { LinearProgress } from '@mui/material' +import classNames from 'classnames' +import { useTranslation } from 'react-i18next' + +export function ProgressDialog(props: { + title: string + progress: string[] + onClose: () => void +}) { + const { t } = useTranslation() + const winetricksOutputBottomRef = useRef(null) + const logRef = useRef(null) + const [autoScroll, setAutoScroll] = useState(true) + + const scrollToBottom = () => { + winetricksOutputBottomRef.current?.scrollIntoView({ behavior: 'auto' }) + } + + useEffect(() => { + if (autoScroll) { + scrollToBottom() + } + }, [props.progress, autoScroll]) + + const onLogScroll = (ev: Event) => { + const target = ev.target as HTMLDivElement + + const atTheBottom = + target.scrollTop + target.getBoundingClientRect().height >= + target.scrollHeight + + setAutoScroll(atTheBottom) + } + + useEffect(() => { + if (logRef.current) { + logRef.current.addEventListener('scroll', onLogScroll) + } + }, [logRef.current]) + + return ( + <> + + +
{props.title}
+
+ +
{t('progress', 'Progress')}:
+
+ {props.progress.map((line, key) => { + if (line.toLowerCase().includes(' err')) { + return ( +

+ {line} +

+ ) + } else if (line.toLowerCase().includes(' warn')) { + return ( +

+ {line} +

+ ) + } else { + return ( +

+ {line} +

+ ) + } + })} +
+
+ + +
+ + ) +} diff --git a/src/screens/Settings/components/Tools/index.css b/src/screens/Settings/components/Tools/index.css index 2a63801481..c0623d6868 100644 --- a/src/screens/Settings/components/Tools/index.css +++ b/src/screens/Settings/components/Tools/index.css @@ -51,54 +51,3 @@ color: var(--text-secondary); text-decoration: none; } - -.WinetricksProgress__dialog { - max-width: min(700px, 85vw); - width: 100%; -} - -.WinetricksProgress__dialog .Dialog__content { - width: 100%; -} - -.WinetricksProgress__dialog .Dialog__headerClose { - display: none; -} - -.winetricks.log-box { - background-color: #1e1e1e; - border-radius: 10px; - padding-block: 4px; - padding-inline: 6px; - height: 25em; - width: calc(90vw - var(--sidebar-width)); - overflow: auto; - user-select: text; -} - -.winetricks.log-box.collapsed { - width: calc(90vw - var(--sidebar-width)); -} - -.winetricks.log-error, -.winetricks.log-warning, -.winetricks.log-info { - text-align: left; - margin-block: 0; - min-height: 1em; - height: max-content; - white-space: pre; - font-family: monospace; -} - -.winetricks.log-error { - color: #c18672; -} - -.winetricks.log-warning { - color: #f5cf69; -} - -.winetricks.log-info { - color: rgb(175, 172, 172); -} diff --git a/src/screens/Settings/components/Tools/index.tsx b/src/screens/Settings/components/Tools/index.tsx index 9b276c58b7..baaefbe259 100644 --- a/src/screens/Settings/components/Tools/index.tsx +++ b/src/screens/Settings/components/Tools/index.tsx @@ -1,6 +1,6 @@ import './index.css' -import React, { useEffect, useRef, useState } from 'react' +import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import classNames from 'classnames' @@ -8,8 +8,7 @@ import { getGameInfo, quoteIfNecessary } from 'src/helpers' import { ipcRenderer } from 'src/helpers' import { Runner } from 'src/types' -import { Dialog, DialogContent, DialogHeader } from 'src/components/UI/Dialog' -import { LinearProgress } from '@mui/material' +import { ProgressDialog } from 'src/components/UI/ProgressDialog' interface Props { appName: string @@ -21,9 +20,6 @@ export default function Tools({ appName, runner }: Props) { const [winecfgRunning, setWinecfgRunning] = useState(false) const [winetricksRunning, setWinetricksRunning] = useState(false) const [progress, setProgress] = useState([]) - const winetricksOutputBottomRef = useRef(null) - const logRef = useRef(null) - const [autoScroll, setAutoScroll] = useState(true) type Tool = 'winecfg' | 'winetricks' | string async function callTools(tool: Tool, exe?: string) { @@ -61,32 +57,6 @@ export default function Tools({ appName, runner }: Props) { setProgress([]) }, [winetricksRunning]) - const scrollToBottom = () => { - winetricksOutputBottomRef.current?.scrollIntoView({ behavior: 'auto' }) - } - - useEffect(() => { - if (autoScroll) { - scrollToBottom() - } - }, [progress, autoScroll]) - - const onLogScroll = (ev: Event) => { - const target = ev.target as HTMLDivElement - - const atTheBottom = - target.scrollTop + target.getBoundingClientRect().height >= - target.scrollHeight - - setAutoScroll(atTheBottom) - } - - useEffect(() => { - if (logRef.current) { - logRef.current.addEventListener('scroll', onLogScroll) - } - }, [logRef.current]) - const handleRunExe = async () => { let exe = '' const gameinfo = await getGameInfo(appName, runner) @@ -129,48 +99,13 @@ export default function Tools({ appName, runner }: Props) { <>
{winetricksRunning && ( - { return }} - className={classNames('WinetricksProgress__dialog')} - > - { - return - }} - > -
Winetricks
-
- -
{t('progress', 'Progress')}:
-
- {progress.map((line, key) => { - if (line.toLowerCase().includes(' err')) { - return ( -

- {line} -

- ) - } else if (line.toLowerCase().includes(' warn')) { - return ( -

- {line} -

- ) - } else { - return ( -

- {line} -

- ) - } - })} -
-
- - -
+ /> )}
-
+ {showCloseButton && ( +
+ +
+ )}
) } diff --git a/src/components/UI/ProgressDialog/index.css b/src/components/UI/ProgressDialog/index.css index 094603cb7f..67139e978f 100644 --- a/src/components/UI/ProgressDialog/index.css +++ b/src/components/UI/ProgressDialog/index.css @@ -7,10 +7,6 @@ width: 100%; } -.progressDialog .Dialog__headerClose { - display: none; -} - .progressDialog.log-box { background-color: #1e1e1e; border-radius: 10px; diff --git a/src/components/UI/ProgressDialog/index.tsx b/src/components/UI/ProgressDialog/index.tsx index 1c19356443..50c57ec618 100644 --- a/src/components/UI/ProgressDialog/index.tsx +++ b/src/components/UI/ProgressDialog/index.tsx @@ -9,6 +9,7 @@ import { useTranslation } from 'react-i18next' export function ProgressDialog(props: { title: string progress: string[] + showCloseButton: boolean onClose: () => void }) { const { t } = useTranslation() @@ -45,7 +46,10 @@ export function ProgressDialog(props: { return ( <> - +
{props.title}
diff --git a/src/screens/Library/components/InstallModal/index.tsx b/src/screens/Library/components/InstallModal/index.tsx index 6a303e10ab..daa58ac108 100644 --- a/src/screens/Library/components/InstallModal/index.tsx +++ b/src/screens/Library/components/InstallModal/index.tsx @@ -409,7 +409,7 @@ export default function InstallModal({ > {title ? ( <> - + {title} {availablePlatforms.map((p) => ( ([]) + const [manuallyOutputShow, setManuallyOutputShow] = useState(false) const { t } = useTranslation() @@ -122,12 +125,10 @@ export default function GOGSyncSaves({ await ipcRenderer .invoke('syncGOGSaves', gogSaves, appName, syncType) - .then(async (res: { stderr: string }) => - ipcRenderer.invoke('openMessageBox', { - message: res.stderr, - title: 'Saves Sync' - }) - ) + .then(async (res: { stderr: string }) => { + setManuallyOutput(res.stderr.split('\n')) + setManuallyOutputShow(true) + }) setIsSyncing(false) } @@ -135,6 +136,16 @@ export default function GOGSyncSaves({ return ( <>

{t('settings.navbar.sync')}

+ {manuallyOutputShow && ( + { + setManuallyOutputShow(false) + }} + /> + )}
{t( diff --git a/src/screens/Settings/components/SyncSaves/legendary.tsx b/src/screens/Settings/components/SyncSaves/legendary.tsx index 8a462c6d32..9e54cab8b4 100644 --- a/src/screens/Settings/components/SyncSaves/legendary.tsx +++ b/src/screens/Settings/components/SyncSaves/legendary.tsx @@ -10,6 +10,7 @@ import { TextInputWithIconField, ToggleSwitch } from 'src/components/UI' +import { ProgressDialog } from 'src/components/UI/ProgressDialog' import { fixLegendarySaveFolder, getGameInfo, @@ -43,6 +44,8 @@ export default function LegendarySyncSaves({ const [isSyncing, setIsSyncing] = useState(false) const [isLoading, setLoading] = useState(false) const [syncType, setSyncType] = useState('--skip-upload') + const [manuallyOutput, setManuallyOutput] = useState([]) + const [manuallyOutputShow, setManuallyOutputShow] = useState(false) const { t } = useTranslation() const { platform } = useContext(ContextProvider) const isWin = platform === 'win32' @@ -109,11 +112,10 @@ export default function LegendarySyncSaves({ setIsSyncing(true) await syncSaves(savesPath, appName, 'legendary', syncType).then( - async (res: string) => - ipcRenderer.invoke('openMessageBox', { - message: res, - title: 'Saves Sync' - }) + (response: string) => { + setManuallyOutput(response.split('\n')) + setManuallyOutputShow(true) + } ) setIsSyncing(false) } @@ -121,6 +123,16 @@ export default function LegendarySyncSaves({ return ( <>

{t('settings.navbar.sync')}

+ {manuallyOutputShow && ( + { + setManuallyOutputShow(false) + }} + /> + )}
{t( diff --git a/src/screens/Settings/components/Tools/index.tsx b/src/screens/Settings/components/Tools/index.tsx index baaefbe259..4a7c68cab6 100644 --- a/src/screens/Settings/components/Tools/index.tsx +++ b/src/screens/Settings/components/Tools/index.tsx @@ -102,6 +102,7 @@ export default function Tools({ appName, runner }: Props) { { return }} From 3b3278db4d97f688db35dba6ddea64933b8f01ce Mon Sep 17 00:00:00 2001 From: Nocccer Date: Tue, 30 Aug 2022 16:45:59 +0200 Subject: [PATCH 12/12] Add margin --- src/components/UI/ProgressDialog/index.css | 13 +++++++++++++ src/components/UI/ProgressDialog/index.tsx | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/UI/ProgressDialog/index.css b/src/components/UI/ProgressDialog/index.css index 67139e978f..b15a785090 100644 --- a/src/components/UI/ProgressDialog/index.css +++ b/src/components/UI/ProgressDialog/index.css @@ -44,3 +44,16 @@ .progressDialog.log-info { color: rgb(175, 172, 172); } + +.progressDialog.header { + margin-bottom: 10px; +} + +.progressDialog.linearProgress { + margin-top: 10px; + background-color: var(--primary); +} + +.progressDialog.linearProgress > .MuiLinearProgress-bar { + background-color: var(--accent); +} diff --git a/src/components/UI/ProgressDialog/index.tsx b/src/components/UI/ProgressDialog/index.tsx index 50c57ec618..3540925caf 100644 --- a/src/components/UI/ProgressDialog/index.tsx +++ b/src/components/UI/ProgressDialog/index.tsx @@ -53,7 +53,9 @@ export function ProgressDialog(props: {
{props.title}
-
{t('progress', 'Progress')}:
+
+ {t('progress', 'Progress')}: +
{props.progress.map((line, key) => { if (line.toLowerCase().includes(' err')) { @@ -78,7 +80,7 @@ export function ProgressDialog(props: { })}
- +