diff --git a/neutralino.config.json b/neutralino.config.json index df0eb89..4b15c2d 100644 --- a/neutralino.config.json +++ b/neutralino.config.json @@ -22,7 +22,7 @@ "fullScreen": false, "alwaysOnTop": false, "icon": "/public/icons/64x64.png", - "enableInspector": false, + "enableInspector": true, "borderless": false, "maximize": false, "hidden": true, diff --git a/public/locales/en-us.yaml b/public/locales/en-us.yaml index 3ebb834..06ab974 100644 --- a/public/locales/en-us.yaml +++ b/public/locales/en-us.yaml @@ -44,7 +44,7 @@ settings: dxvk: DXVK mangohud: MangoHUD - gamemode: GameMode + gamemode: Use GameMode fps_unlocker: Unlock FPS purge_dxvk_logs: Delete DXVK logs @@ -58,4 +58,13 @@ settings: dxvks: title: DXVK items: - recommended: Show recommendable only \ No newline at end of file + recommended: Show recommendable only + + # Shaders + shaders: + title: Shaders + items: + shaders: + title: Shaders + items: + none: None \ No newline at end of file diff --git a/public/locales/ru-ru.yaml b/public/locales/ru-ru.yaml index 900d5ee..088f73e 100644 --- a/public/locales/ru-ru.yaml +++ b/public/locales/ru-ru.yaml @@ -45,18 +45,27 @@ settings: mangohud: MangoHUD # TODO: add hints to the components so I could describe what these options means - gamemode: GameMode + gamemode: Использовать GameMode fps_unlocker: Разблокировать FPS purge_dxvk_logs: Удалять логи DXVK - # Runners + # Версии Wine runners: title: Версия Wine items: recommended: Показывать только рекомендуемое - # DXVKs + # DXVK dxvks: title: DXVK items: - recommended: Показывать только рекомендуемое \ No newline at end of file + recommended: Показывать только рекомендуемое + + # Шейдеры + shaders: + title: Шейдеры + items: + shaders: + title: Шейдеры + items: + none: Отключены \ No newline at end of file diff --git a/public/shaders/notahuman/shaders.json b/public/shaders/notahuman/shaders.json deleted file mode 100644 index d8a55ba..0000000 --- a/public/shaders/notahuman/shaders.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "Prime Preset v2", - "author": "notahuman", - "uri": "https://notabug.org/Krock/GI-on-Linux/issues/200", - "images": [ - { - "file": "preview.png", - "caption": { - "en": "Characters' faces", - "en-us": "Characters' faces", - "de": "Gesichter der Charaktere", - "ja": "キャラクターの顔", - "ko": "캐릭터의 얼굴", - "ru": "Лица персонажей" - } - } - ] -} \ No newline at end of file diff --git a/public/shaders/notahuman/shaders.yaml b/public/shaders/notahuman/shaders.yaml new file mode 100644 index 0000000..63477b3 --- /dev/null +++ b/public/shaders/notahuman/shaders.yaml @@ -0,0 +1,11 @@ +name: Prime Preset v2 +author: notahuman +uri: https://notabug.org/Krock/GI-on-Linux/issues/200 +images: + - file: preview.png + caption: + en-us: Characters' faces + de-de: Gesichter der Charaktere + ja-jp: キャラクターの顔 + ko-kr: 캐릭터의 얼굴 + ru-ru: Лица персонажей \ No newline at end of file diff --git a/public/shaders/yagocl/shaders.json b/public/shaders/yagocl/shaders.json deleted file mode 100644 index 3544b8e..0000000 --- a/public/shaders/yagocl/shaders.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Basic sharpening preset", - "author": "yagocl", - "uri": null, - "images": [] -} diff --git a/public/shaders/yagocl/shaders.yaml b/public/shaders/yagocl/shaders.yaml new file mode 100644 index 0000000..09177f0 --- /dev/null +++ b/public/shaders/yagocl/shaders.yaml @@ -0,0 +1,2 @@ +name: Basic sharpening preset +author: yagocl \ No newline at end of file diff --git a/src/components/SelectionBox.svelte b/src/components/SelectionBox.svelte index 1dc37be..4601379 100644 --- a/src/components/SelectionBox.svelte +++ b/src/components/SelectionBox.svelte @@ -6,6 +6,7 @@ export let prop: string = ''; export let lang: string = ''; export let items = {}; + export let valueChanged: (value: string) => void = () => {}; import Arrow from '../assets/svgs/arrow.svg'; diff --git a/src/components/ShadersSelection.svelte b/src/components/ShadersSelection.svelte new file mode 100644 index 0000000..9bdc7b5 --- /dev/null +++ b/src/components/ShadersSelection.svelte @@ -0,0 +1,27 @@ + + + diff --git a/src/defaultSettings.ts b/src/defaultSettings.ts index 9ebf979..44e788d 100644 --- a/src/defaultSettings.ts +++ b/src/defaultSettings.ts @@ -51,11 +51,11 @@ promisify(async () => { /** * vkBasalt preset to use * - * null if not in use. Otherwise it should be a folder name from the "shaders" folder + * "none" if not in use. Otherwise it should be a folder name from the "shaders" folder * - * @default null + * @default "none" */ - shaders: null, + shaders: 'none', /** * Discord RPC integration diff --git a/src/settings.svelte b/src/settings.svelte index eaa1602..252211f 100644 --- a/src/settings.svelte +++ b/src/settings.svelte @@ -2,10 +2,13 @@ import { onMount } from 'svelte'; import { _, locale, locales } from 'svelte-i18n'; + import Shaders from './ts/core/Shaders'; + import Checkbox from './components/Checkbox.svelte'; import SelectionBox from './components/SelectionBox.svelte'; import DXVKSelectionList from './components/DXVKSelectionList.svelte'; import RunnerSelectionList from './components/RunnerSelectionList.svelte'; + import ShadersSelection from './components/ShadersSelection.svelte'; import Window from './ts/neutralino/Window'; @@ -53,11 +56,15 @@ 'mangohud': 'settings.enhancements.items.hud.items.mangohud' }; + /** + * Menu items + */ const menuItems = [ 'general', 'enhancements', 'runners', - 'dxvks' + 'dxvks', + 'shaders' ]; /** @@ -160,5 +167,11 @@ + +
+

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

+ + +
{/if} diff --git a/src/ts/Launcher.ts b/src/ts/Launcher.ts index 384beff..93ab051 100644 --- a/src/ts/Launcher.ts +++ b/src/ts/Launcher.ts @@ -36,7 +36,7 @@ export default class Launcher title: 'Settings', width: 900, height: 600, - enableInspector: false + enableInspector: true }); if (window.status) diff --git a/src/ts/core/Shaders.ts b/src/ts/core/Shaders.ts new file mode 100644 index 0000000..fbb60c4 --- /dev/null +++ b/src/ts/core/Shaders.ts @@ -0,0 +1,87 @@ +import YAML from 'yaml'; + +import type { Shader } from '../types/Shaders'; + +import Configs from '../Configs'; +import constants from '../Constants'; +import promisify from './promisify'; + +declare const Neutralino; + +export default class Shaders +{ + /** + * Get or set shaders to the config file + */ + public static current(shader: Shader|null = null): Promise + { + return new Promise(async (resolve) => { + if (shader === null) + { + Configs.get('shaders').then(async (shader) => { + resolve(shader ? await this.get(shader as string) : null); + }); + } + + else + { + Configs.set('shaders', typeof shader === 'string' ? shader : shader.folder); + + resolve(typeof shader === 'string' ? await this.get(shader) : shader); + } + }); + } + + /** + * Get list of available shaders + */ + public static list(): Promise + { + return new Promise((resolve) => { + Neutralino.filesystem.readDirectory(constants.paths.shadersDir) + .then((dirs) => { + let callbacks: any[] = []; + + dirs.forEach((dir) => { + if (dir.entry != '.' && dir.entry != '..') + { + callbacks.push((): Promise => { + return new Promise((resolve) => { + Neutralino.filesystem.readFile(`${constants.paths.shadersDir}/${dir.entry}/shaders.yaml`) + .then((shaders) => resolve({ + ...YAML.parse(shaders), + folder: dir.entry + })) + .catch(() => resolve(null)); + }); + }); + } + }); + + const pipeline = promisify({ + callbacks, + callAtOnce: true + }); + + pipeline.then((output: object) => { + resolve(Object.values(output).filter((shader) => shader !== null)); + }); + }) + .catch(() => resolve([])); + }); + } + + /** + * Get shader info + */ + public static get(folder: string): Promise + { + return new Promise((resolve) => { + Neutralino.filesystem.readFile(`${constants.paths.shadersDir}/${folder}/shaders.yaml`) + .then((shaders) => { + resolve(YAML.parse(shaders)); + }) + .catch(() => resolve(null)); + }); + } +}; diff --git a/src/ts/types/Shaders.d.ts b/src/ts/types/Shaders.d.ts new file mode 100644 index 0000000..6f1b35e --- /dev/null +++ b/src/ts/types/Shaders.d.ts @@ -0,0 +1,12 @@ +type Shader = { + name: string; + folder: string; + author: string; + uri?: string; + images?: { + file: string; + captions?: string[]; + }[]; +}; + +export type { Shader };