From 82b92dab45b672ef5d659bd2984b81002463b9da Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Thu, 12 May 2022 22:46:50 -0700 Subject: [PATCH] first config option! --- lang/en.json | 6 ++++++ src/ui/components/common/DirInput.tsx | 14 ++++++++++++-- src/ui/components/menu/Options.tsx | 24 +++++++++--------------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/lang/en.json b/lang/en.json index eb6fe93..cf6670a 100644 --- a/lang/en.json +++ b/lang/en.json @@ -4,5 +4,11 @@ "title": "Cultivation", "launch_button": "Launch", "gc_enable": "Connect via Grasscutter" + }, + "options": { + "game_exec": "Set Game Executable" + }, + "components": { + "select_file": "Select file or folder..." } } \ No newline at end of file diff --git a/src/ui/components/common/DirInput.tsx b/src/ui/components/common/DirInput.tsx index b144ef7..0901292 100644 --- a/src/ui/components/common/DirInput.tsx +++ b/src/ui/components/common/DirInput.tsx @@ -1,5 +1,6 @@ import React from 'react' import { open } from '@tauri-apps/api/dialog' +import { translate } from '../../../utils/language' import TextInput from './TextInput' import File from '../../../resources/icons/folder.svg' @@ -12,6 +13,7 @@ interface IProps { interface IState { value: string + placeholder: string } export default class DirInput extends React.Component { @@ -19,12 +21,20 @@ export default class DirInput extends React.Component { super(props) this.state = { - value: props.value || '' + value: props.value || '', + placeholder: 'Select file or folder...' } this.handleIconClick = this.handleIconClick.bind(this) } + async componentDidMount() { + const translation = await translate('components.select_file') + this.setState( { + placeholder: translation + }) + } + async handleIconClick() { let path = await open({ filters: [ @@ -45,7 +55,7 @@ export default class DirInput extends React.Component { render() { return (
- +
diff --git a/src/ui/components/menu/Options.tsx b/src/ui/components/menu/Options.tsx index c894852..6295089 100644 --- a/src/ui/components/menu/Options.tsx +++ b/src/ui/components/menu/Options.tsx @@ -1,9 +1,9 @@ import React from 'react' -import Checkbox from '../common/Checkbox' -import TextInput from '../common/TextInput' import DirInput from '../common/DirInput' import Menu from './Menu' +import Tr from '../../../utils/language' import './Options.css' +import { setConfigOption } from '../../../utils/configuration' interface IProps { closeFn: () => void; @@ -14,25 +14,19 @@ export default class Options extends React.Component { super(props) } + setGameExec(value: string) { + setConfigOption('game_path', value) + } + render() { return (
-
Test Option
-
- console.log('Test Option Changed')} /> +
+
-
-
-
Test Input
- -
-
-
-
Test File Input
-
- +