Skip to content

Commit

Permalink
fix: Add value checker
Browse files Browse the repository at this point in the history
  • Loading branch information
SheffeyG committed Feb 7, 2024
1 parent 0fbb596 commit fcc4947
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/utils/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, ' ');
Expand Down
4 changes: 2 additions & 2 deletions src/views/Advanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' : '');
Expand All @@ -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' : '');
Expand Down
4 changes: 3 additions & 1 deletion src/views/Custom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import { Modals } from "./modals";


const Custom: VFC<{ appid: number }> = ({ appid }) => {
// local storage custom options list
const [cusOptList, setCusOptList] = useState<CustomOption[]>([]);
// launcher options
const [options, setOptions] = useState<Options>(new Options(""));

useEffect(() => {
Expand Down Expand Up @@ -115,7 +117,7 @@ const Custom: VFC<{ appid: number }> = ({ appid }) => {
<ToggleField
bottomSeparator="none"
label={<span className="CD_Label">{opt.label}</span>}
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 : '');
Expand Down

0 comments on commit fcc4947

Please sign in to comment.