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 : '');