From 082b596421a1356383ff1ee2feb4ceec479298a5 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Mon, 27 Dec 2021 18:39:40 +0200 Subject: [PATCH] Several changes - fixed `runners.json` `Wine-6.16-GE-1` URI - added recommendable only checkboxes for DXVK and runners lists - fixed empty config property creation - added runners installation, deletion and selection abilities - `Runners.current` field was reworked as a `Runners.current()` method to be able to change selected runner according to the config file --- public/locales/en-us.yaml | 6 +- public/locales/ru-ru.yaml | 6 +- public/runners.json | 2 +- src/components/Checkbox.svelte | 8 ++- src/components/DXVKSelectionList.svelte | 4 +- src/components/RunnerSelectionList.svelte | 81 +++++++++++++++++++---- src/sass/components/selectionList.sass | 3 + src/settings.svelte | 13 +++- src/ts/Voice.ts | 2 +- src/ts/core/Prefix.ts | 2 +- src/ts/core/Runners.ts | 43 ++++++++++-- src/ts/core/promisify.ts | 2 +- src/ts/launcher/states/Launch.ts | 2 +- 13 files changed, 142 insertions(+), 32 deletions(-) diff --git a/public/locales/en-us.yaml b/public/locales/en-us.yaml index 7a84f24..3ebb834 100644 --- a/public/locales/en-us.yaml +++ b/public/locales/en-us.yaml @@ -51,7 +51,11 @@ settings: # Runners runners: title: Wine version + items: + recommended: Show recommendable only # DXVKs dxvks: - title: DXVK \ No newline at end of file + title: DXVK + items: + recommended: Show recommendable only \ No newline at end of file diff --git a/public/locales/ru-ru.yaml b/public/locales/ru-ru.yaml index d405a19..900d5ee 100644 --- a/public/locales/ru-ru.yaml +++ b/public/locales/ru-ru.yaml @@ -52,7 +52,11 @@ settings: # Runners runners: title: Версия Wine + items: + recommended: Показывать только рекомендуемое # DXVKs dxvks: - title: DXVK \ No newline at end of file + title: DXVK + items: + recommended: Показывать только рекомендуемое \ No newline at end of file diff --git a/public/runners.json b/public/runners.json index dd9ebcf..0eba16d 100644 --- a/public/runners.json +++ b/public/runners.json @@ -215,7 +215,7 @@ "family": "Wine-GE", "name": "lutris-ge-6.16-1-x86_64", "title": "Wine-6.16-GE-1", - "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/6.16-GE-1/wine-lutris-ge-6.16-1-x86_64.tar.xz", + "uri": "https://github.com/GloriousEggroll/wine-ge-custom/releases/download/6.16-GE-1/lutris-ge-6.16-1-x86_64.tar.xz", "files": { "wine": "bin/wine64", "wineserver": "bin/wineserver", diff --git a/src/components/Checkbox.svelte b/src/components/Checkbox.svelte index c03f194..86f9278 100644 --- a/src/components/Checkbox.svelte +++ b/src/components/Checkbox.svelte @@ -6,6 +6,8 @@ export let prop: string = ''; export let lang: string = ''; + export let valueChanged: (value: boolean) => void = () => {}; + import Checkmark from '../assets/svgs/checkmark.svg'; import Configs from '../ts/Configs'; @@ -16,7 +18,11 @@ { active = !active; - Configs.set(prop, active); + if (prop) + Configs.set(prop, active); + + if (valueChanged) + valueChanged(active); } diff --git a/src/components/DXVKSelectionList.svelte b/src/components/DXVKSelectionList.svelte index 736053c..1e939c9 100644 --- a/src/components/DXVKSelectionList.svelte +++ b/src/components/DXVKSelectionList.svelte @@ -1,6 +1,8 @@ @@ -28,17 +66,32 @@

{ family.title }

{#each family.runners as runner} -
+
{ + if (installedRunners[runner.name]) + { + selectedVersion = runner.name; + + Runners.current(runner); + } + }} + > { runner.title }
- + {progress[runner.name] ?? ''} - + deleteRunner(runner)}> - + downloadRunner(runner)}>
{/each} diff --git a/src/sass/components/selectionList.sass b/src/sass/components/selectionList.sass index 1fd33b7..867bd9f 100644 --- a/src/sass/components/selectionList.sass +++ b/src/sass/components/selectionList.sass @@ -63,6 +63,9 @@ img filter: invert(70%) sepia(13%) saturate(241%) hue-rotate(196deg) brightness(97%) contrast(91%) + .list-item-hidden + display: none + .list-item-downloading img display: none !important diff --git a/src/settings.svelte b/src/settings.svelte index a9e19a3..eaa1602 100644 --- a/src/settings.svelte +++ b/src/settings.svelte @@ -87,6 +87,9 @@ selectedItem = visibleElement.getAttribute('id'); }; + let dxvkRecommendable = true, + runnersRecommendable = true; + // Do some stuff when all the content will be loaded onMount(() => { Window.current.show(); @@ -143,13 +146,19 @@

{$_('settings.runners.title')}

- + runnersRecommendable = value} /> + +

{$_('settings.dxvks.title')}

- + dxvkRecommendable = value} /> + +

+ +
{/if} diff --git a/src/ts/Voice.ts b/src/ts/Voice.ts index 70e9936..94ec4f7 100644 --- a/src/ts/Voice.ts +++ b/src/ts/Voice.ts @@ -86,7 +86,7 @@ export default class Voice /** * Get updated voice data from the specified version to the latest * - * @returns Latest voice pack if current is out of date + * @returns null if the difference can't be calculated * @returns Error object if company's servers are unreachable or they responded with an error */ public static getDiff(version: string): Promise diff --git a/src/ts/core/Prefix.ts b/src/ts/core/Prefix.ts index 07ed47a..100b55f 100644 --- a/src/ts/core/Prefix.ts +++ b/src/ts/core/Prefix.ts @@ -72,7 +72,7 @@ export default class Prefix ]; return new Promise((resolve) => { - Runners.current.then((runner) => { + Runners.current().then((runner) => { if (runner === null) resolve(false); diff --git a/src/ts/core/Runners.ts b/src/ts/core/Runners.ts index 9306e29..927fa49 100644 --- a/src/ts/core/Runners.ts +++ b/src/ts/core/Runners.ts @@ -23,16 +23,29 @@ class Runners { /** * Get the current using runner according to the config file + * or set the new one */ - public static get current(): Promise + public static current(runner: Runner|Runner['name']|null = null): Promise { - return new Promise((resolve) => { - Configs.get('runner').then((runner) => { - if (typeof runner === 'string') - Runners.get(runner).then((runner) => resolve(runner)); + return new Promise(async (resolve) => { + if (runner === null) + { + Configs.get('runner').then((runner) => { + if (typeof runner === 'string') + Runners.get(runner).then((runner) => resolve(runner)); - else resolve(null); - }); + else resolve(null); + }); + } + + else + { + Configs.set('runner', typeof runner === 'string' ? + runner : runner.name); + + resolve(typeof runner === 'string' ? + await this.get(runner) : runner); + } }); } @@ -121,6 +134,22 @@ class Runners else resolve(new Stream(runner)); }); } + + /** + * Delete specified runner + */ + public static delete(runner: Runner|Runner['name']): Promise + { + return new Promise(async (resolve) => { + const name = typeof runner !== 'string' ? + runner.name : runner; + + Process.run(`rm -rf '${Process.addSlashes(await constants.paths.runnersDir + '/' + name)}'`) + .then((process) => { + process.finish(() => resolve()); + }); + }); + } } export default Runners; diff --git a/src/ts/core/promisify.ts b/src/ts/core/promisify.ts index e663b7f..b60e499 100644 --- a/src/ts/core/promisify.ts +++ b/src/ts/core/promisify.ts @@ -22,7 +22,7 @@ type PromiseOptions = { }; /** - * Make a promise from the provided function(s) and run it/them + * Make a promise from the provided function(s) and run it(them) */ export default function promisify(callback: callback|Promise|PromiseOptions): Promise { diff --git a/src/ts/launcher/states/Launch.ts b/src/ts/launcher/states/Launch.ts index 6897f4a..42a1123 100644 --- a/src/ts/launcher/states/Launch.ts +++ b/src/ts/launcher/states/Launch.ts @@ -12,7 +12,7 @@ export default (): Promise => { */ let wineExeutable = 'wine'; - const runner = await Runners.current; + const runner = await Runners.current(); if (runner !== null) {