From 154d79b2e4f9964ab961736404405a54f26eebbe Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 3 Jun 2022 23:03:22 -0700 Subject: [PATCH] fix textboxes --- src/ui/App.tsx | 4 ++-- src/ui/components/common/TextInput.tsx | 1 - src/ui/components/menu/Options.tsx | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ui/App.tsx b/src/ui/App.tsx index 3d04264..581a48f 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -80,8 +80,8 @@ class App extends React.Component { const cert_generated = await getConfigOption('cert_generated') const game_exe = await getConfigOption('game_install_path') const custom_bg = await getConfigOption('customBackground') - const game_path = game_exe.substring(0, game_exe.replace(/\\/g, '/').lastIndexOf('/')) - const root_path = game_path.substring(0, game_path.replace(/\\/g, '/').lastIndexOf('/')) + const game_path = game_exe?.substring(0, game_exe.replace(/\\/g, '/').lastIndexOf('/')) || '' + const root_path = game_path?.substring(0, game_path.replace(/\\/g, '/').lastIndexOf('/')) || '' // Load a theme if it exists const theme = await getConfigOption('theme') diff --git a/src/ui/components/common/TextInput.tsx b/src/ui/components/common/TextInput.tsx index 607c111..e2009ea 100644 --- a/src/ui/components/common/TextInput.tsx +++ b/src/ui/components/common/TextInput.tsx @@ -53,7 +53,6 @@ export default class TextInput extends React.Component { this.props.clearable ?
{ // Run custom behaviour first - console.log('cleared') if (this.props.customClearBehaviour) return this.props.customClearBehaviour() this.setState({ value: '' }) diff --git a/src/ui/components/menu/Options.tsx b/src/ui/components/menu/Options.tsx index 1498823..a54062b 100644 --- a/src/ui/components/menu/Options.tsx +++ b/src/ui/components/menu/Options.tsx @@ -43,6 +43,9 @@ export default class Options extends React.Component { theme: '' } + this.setGameExec = this.setGameExec.bind(this) + this.setGrasscutterJar = this.setGrasscutterJar.bind(this) + this.setJavaPath = this.setJavaPath.bind(this) this.toggleGrasscutterWithGame = this.toggleGrasscutterWithGame.bind(this) this.setCustomBackground = this.setCustomBackground.bind(this) } @@ -68,14 +71,26 @@ export default class Options extends React.Component { setGameExec(value: string) { setConfigOption('game_install_path', value) + + this.setState({ + game_install_path: value + }) } setGrasscutterJar(value: string) { setConfigOption('grasscutter_path', value) + + this.setState({ + grasscutter_path: value + }) } setJavaPath(value: string) { setConfigOption('java_path', value) + + this.setState({ + java_path: value + }) } async setLanguage(value: string) {