'use client' import { useEffect, useState } from 'react' import { Setting } from '@/componets/Setting' import { writeNormalConfig } from '@/lib/BazookaManager' import { useGlobal } from '@/app/GlobalProvider' import { copyToClipboard } from '@/lib/Clipboard' import { platform } from '@tauri-apps/plugin-os' export default function Settings () { const [allowNotifications, setAllowNotifications] = useState(false) const [alwaysShowGamesInSidebar, setAlwaysShowGamesInSidebar] = useState(false) const [useWineOnUnixWhenNeeded, setUseWineOnUnixWhenNeeded] = useState(false) const [wineOnUnixCommand, setWineOnUnixCommand] = useState('wine %path%') const [theme, setTheme] = useState(0) const [loaded, setLoaded] = useState(false) const { normalConfig, setNormalConfig, version } = useGlobal() useEffect(() => { ;(async () => { while (normalConfig != null) { setAllowNotifications(normalConfig.settings.allowNotifications) setAlwaysShowGamesInSidebar( normalConfig.settings.alwaysShowGamesInSidebar ) setUseWineOnUnixWhenNeeded( normalConfig.settings.useWineOnUnixWhenNeeded ) setWineOnUnixCommand(normalConfig.settings.wineOnUnixCommand) setTheme(normalConfig.settings.theme) setLoaded(true) break } })() }, [normalConfig]) return ( <>

Settings

{loaded && (
{ if (!normalConfig) return setAllowNotifications(!allowNotifications) setNormalConfig({ ...normalConfig, settings: { ...normalConfig.settings, allowNotifications: !allowNotifications } }) await writeNormalConfig({ ...normalConfig, settings: { ...normalConfig.settings, allowNotifications: !allowNotifications } }) }} title='This setting does as you expect, allow the launcher to send notifications for when stuff like downloading is done.' /> { if (!normalConfig) return setAlwaysShowGamesInSidebar(!alwaysShowGamesInSidebar) setNormalConfig({ ...normalConfig, settings: { ...normalConfig.settings, alwaysShowGamesInSidebar: !alwaysShowGamesInSidebar } }) await writeNormalConfig({ ...normalConfig, settings: { ...normalConfig.settings, alwaysShowGamesInSidebar: !alwaysShowGamesInSidebar } }) }} title="This setting will make it so when you are on a page like this, the games won't disappear." /> { if (!normalConfig) return setUseWineOnUnixWhenNeeded(!useWineOnUnixWhenNeeded) setNormalConfig({ ...normalConfig, settings: { ...normalConfig.settings, useWineOnUnixWhenNeeded: !useWineOnUnixWhenNeeded } }) await writeNormalConfig({ ...normalConfig, settings: { ...normalConfig.settings, useWineOnUnixWhenNeeded: !useWineOnUnixWhenNeeded } }) }} className={platform() == 'linux' ? '' : 'hidden'} /> { if (!normalConfig) return setWineOnUnixCommand(e.target.value) setNormalConfig({ ...normalConfig, settings: { ...normalConfig.settings, wineOnUnixCommand: e.target.value } }) await writeNormalConfig({ ...normalConfig, settings: { ...normalConfig.settings, wineOnUnixCommand: e.target.value } }) }} className={`input-field my-1 ${ platform() == 'linux' && useWineOnUnixWhenNeeded ? '' : 'hidden' }`} >
)}

{ await copyToClipboard(`v${version}`, normalConfig) }} title='The current launcher version.' > v{version}

) }