Several changes

- changed shaders config file format
- added shaders selection menu section template
- made `Shaders` class to manage shaders
This commit is contained in:
Observer KRypt0n_ 2021-12-27 23:17:02 +02:00
parent 25e4c3f6f2
commit 35d9e82222
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
14 changed files with 183 additions and 36 deletions

View file

@ -22,7 +22,7 @@
"fullScreen": false, "fullScreen": false,
"alwaysOnTop": false, "alwaysOnTop": false,
"icon": "/public/icons/64x64.png", "icon": "/public/icons/64x64.png",
"enableInspector": false, "enableInspector": true,
"borderless": false, "borderless": false,
"maximize": false, "maximize": false,
"hidden": true, "hidden": true,

View file

@ -44,7 +44,7 @@ settings:
dxvk: DXVK dxvk: DXVK
mangohud: MangoHUD mangohud: MangoHUD
gamemode: GameMode gamemode: Use GameMode
fps_unlocker: Unlock FPS fps_unlocker: Unlock FPS
purge_dxvk_logs: Delete DXVK logs purge_dxvk_logs: Delete DXVK logs
@ -58,4 +58,13 @@ settings:
dxvks: dxvks:
title: DXVK title: DXVK
items: items:
recommended: Show recommendable only recommended: Show recommendable only
# Shaders
shaders:
title: Shaders
items:
shaders:
title: Shaders
items:
none: None

View file

@ -45,18 +45,27 @@ settings:
mangohud: MangoHUD mangohud: MangoHUD
# TODO: add hints to the components so I could describe what these options means # TODO: add hints to the components so I could describe what these options means
gamemode: GameMode gamemode: Использовать GameMode
fps_unlocker: Разблокировать FPS fps_unlocker: Разблокировать FPS
purge_dxvk_logs: Удалять логи DXVK purge_dxvk_logs: Удалять логи DXVK
# Runners # Версии Wine
runners: runners:
title: Версия Wine title: Версия Wine
items: items:
recommended: Показывать только рекомендуемое recommended: Показывать только рекомендуемое
# DXVKs # DXVK
dxvks: dxvks:
title: DXVK title: DXVK
items: items:
recommended: Показывать только рекомендуемое recommended: Показывать только рекомендуемое
# Шейдеры
shaders:
title: Шейдеры
items:
shaders:
title: Шейдеры
items:
none: Отключены

View file

@ -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": "Лица персонажей"
}
}
]
}

View file

@ -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: Лица персонажей

View file

@ -1,6 +0,0 @@
{
"name": "Basic sharpening preset",
"author": "yagocl",
"uri": null,
"images": []
}

View file

@ -0,0 +1,2 @@
name: Basic sharpening preset
author: yagocl

View file

@ -6,6 +6,7 @@
export let prop: string = ''; export let prop: string = '';
export let lang: string = ''; export let lang: string = '';
export let items = {}; export let items = {};
export let valueChanged: (value: string) => void = () => {}; export let valueChanged: (value: string) => void = () => {};
import Arrow from '../assets/svgs/arrow.svg'; import Arrow from '../assets/svgs/arrow.svg';

View file

@ -0,0 +1,27 @@
<script lang="ts">
import { _ } from 'svelte-i18n';
import type { Shader } from '../ts/types/Shaders';
import Shaders from '../ts/core/Shaders';
import SelectionBox from './SelectionBox.svelte';
let shaders: Shader[] = [],
shadersOptions = {
'none': 'settings.shaders.items.shaders.items.none'
};
Shaders.list().then((list) => {
shaders = list;
list.forEach((shader) => {
shadersOptions[shader.folder] = shader.name;
});
});
</script>
<SelectionBox
lang="settings.shaders.items.shaders.title"
prop="shaders"
items={shadersOptions}
/>

View file

@ -51,11 +51,11 @@ promisify(async () => {
/** /**
* vkBasalt preset to use * 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 * Discord RPC integration

View file

@ -2,10 +2,13 @@
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { _, locale, locales } from 'svelte-i18n'; import { _, locale, locales } from 'svelte-i18n';
import Shaders from './ts/core/Shaders';
import Checkbox from './components/Checkbox.svelte'; import Checkbox from './components/Checkbox.svelte';
import SelectionBox from './components/SelectionBox.svelte'; import SelectionBox from './components/SelectionBox.svelte';
import DXVKSelectionList from './components/DXVKSelectionList.svelte'; import DXVKSelectionList from './components/DXVKSelectionList.svelte';
import RunnerSelectionList from './components/RunnerSelectionList.svelte'; import RunnerSelectionList from './components/RunnerSelectionList.svelte';
import ShadersSelection from './components/ShadersSelection.svelte';
import Window from './ts/neutralino/Window'; import Window from './ts/neutralino/Window';
@ -53,11 +56,15 @@
'mangohud': 'settings.enhancements.items.hud.items.mangohud' 'mangohud': 'settings.enhancements.items.hud.items.mangohud'
}; };
/**
* Menu items
*/
const menuItems = [ const menuItems = [
'general', 'general',
'enhancements', 'enhancements',
'runners', 'runners',
'dxvks' 'dxvks',
'shaders'
]; ];
/** /**
@ -160,5 +167,11 @@
<DXVKSelectionList recommendable={dxvkRecommendable} /> <DXVKSelectionList recommendable={dxvkRecommendable} />
</div> </div>
<div class="settings-item" id="shaders">
<h1>{$_('settings.shaders.title')}</h1>
<ShadersSelection />
</div>
</div> </div>
{/if} {/if}

View file

@ -36,7 +36,7 @@ export default class Launcher
title: 'Settings', title: 'Settings',
width: 900, width: 900,
height: 600, height: 600,
enableInspector: false enableInspector: true
}); });
if (window.status) if (window.status)

87
src/ts/core/Shaders.ts Normal file
View file

@ -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<Shader|null>
{
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<Shader[]>
{
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<Shader|null> => {
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<Shader|null>
{
return new Promise((resolve) => {
Neutralino.filesystem.readFile(`${constants.paths.shadersDir}/${folder}/shaders.yaml`)
.then((shaders) => {
resolve(YAML.parse(shaders));
})
.catch(() => resolve(null));
});
}
};

12
src/ts/types/Shaders.d.ts vendored Normal file
View file

@ -0,0 +1,12 @@
type Shader = {
name: string;
folder: string;
author: string;
uri?: string;
images?: {
file: string;
captions?: string[];
}[];
};
export type { Shader };