From fcc4947f7afc29dc50c3945333e5db05f4e80c67 Mon Sep 17 00:00:00 2001 From: sheffey <57262511+SheffeyG@users.noreply.github.com> Date: Wed, 7 Feb 2024 23:48:41 +0800 Subject: [PATCH] fix: Add value checker --- package.json | 2 +- src/utils/Options.tsx | 4 ++++ src/views/Advanced.tsx | 4 ++-- src/views/Custom/index.tsx | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 46a29ae..fec01e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cheatdeck", - "version": "0.3.0", + "version": "0.3.1", "description": "Launch games with cheat or trainer and manage your launch options.", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/src/utils/Options.tsx b/src/utils/Options.tsx index 1fff7f2..d80fa65 100644 --- a/src/utils/Options.tsx +++ b/src/utils/Options.tsx @@ -23,6 +23,10 @@ export class Options { return key in this.options; } + hasFieldValue(key: string, value: string): boolean { + return key in this.options && this.options[key] === value; + } + getFieldValue(key: string): string { if (key in this.options) { return this.options[key].replace(/^"(.*)"$/, '\$1').replace(/\\ /g, ' '); diff --git a/src/views/Advanced.tsx b/src/views/Advanced.tsx index 6cf3698..729bdb5 100644 --- a/src/views/Advanced.tsx +++ b/src/views/Advanced.tsx @@ -59,7 +59,7 @@ const Advanced: VFC<{ appid: number }> = ({ appid }) => { label="DXVK_ASYNC" description="Enable shaders pre-calculate for ProtonGE below 7-45" bottomSeparator={"standard"} - checked={options.hasField("DXVK_ASYNC")} + checked={options.hasFieldValue("DXVK_ASYNC", "1")} onChange={(enable: boolean) => { const updatedOptions = new Options(options.getOptionsString()); updatedOptions.setFieldValue('DXVK_ASYNC', enable ? '1' : ''); @@ -71,7 +71,7 @@ const Advanced: VFC<{ appid: number }> = ({ appid }) => { label="RADV_PERFTEST" description="Enable shaders pre-calculate for ProtonGE above 7-45" bottomSeparator={"standard"} - checked={options.hasField("RADV_PERFTEST")} + checked={options.hasFieldValue("RADV_PERFTEST", "gpl")} onChange={(enable: boolean) => { const updatedOptions = new Options(options.getOptionsString()); updatedOptions.setFieldValue('RADV_PERFTEST', enable ? 'gpl' : ''); diff --git a/src/views/Custom/index.tsx b/src/views/Custom/index.tsx index 8af8181..759bdc3 100644 --- a/src/views/Custom/index.tsx +++ b/src/views/Custom/index.tsx @@ -17,7 +17,9 @@ import { Modals } from "./modals"; const Custom: VFC<{ appid: number }> = ({ appid }) => { + // local storage custom options list const [cusOptList, setCusOptList] = useState([]); + // launcher options const [options, setOptions] = useState(new Options("")); useEffect(() => { @@ -115,7 +117,7 @@ const Custom: VFC<{ appid: number }> = ({ appid }) => { {opt.label}} - checked={options.hasField(opt.field)} + checked={options.hasFieldValue(opt.field, opt.value)} onChange={(enable: boolean) => { const updatedOptions = new Options(options.getOptionsString()); updatedOptions.setFieldValue(opt.field, enable ? opt.value : '');