'use client'
import { Setting } from '@/components/Setting'
import { useGlobal } from '@/providers/GlobalProvider'
import { copyToClipboard } from '@/lib/clipboard'
import { platform } from '@tauri-apps/plugin-os'
import { open } from '@tauri-apps/plugin-dialog'
import { invoke } from '@tauri-apps/api/core'
import Dropdown from '@/components/Dropdown'
export default function Settings () {
const {
settings,
version,
notificationsAllowed,
sidebarAlwaysShowGames,
linuxUseWine,
linuxWineCommand,
theme,
customDataLocation,
downloadProgress,
setMovingData
} = useGlobal()
return (
<>
Settings
{
await settings?.set('notificationsAllowed', !notificationsAllowed)
}}
title='This setting does as you expect, allow the launcher to send notifications for when stuff like downloading is done.'
/>
{
await settings?.set(
'sidebarAlwaysShowGames',
!sidebarAlwaysShowGames
)
}}
title="This setting will make it so when you are on a page like this, the games won't disappear."
/>
{
await settings?.set('linuxUseWine', !linuxUseWine)
}}
className={platform() == 'linux' ? '' : 'hidden'}
/>
Wine Command:
await settings?.set('linuxWineCommand', e.target.value)
}
className='input-field my-1'
hidden={!(platform() == 'linux' && linuxUseWine)}
>
0}
onChange={async () => {
if (customDataLocation) {
try {
setMovingData(true)
await invoke('move_game_data', { destination: '' })
await settings?.set('customDataLocation', '')
await invoke('restart_app')
} catch {
setMovingData(false)
}
} else {
const selected = await open({
directory: true,
title: 'Select data location'
})
if (!selected || typeof selected !== 'string') return
try {
setMovingData(true)
await invoke('move_game_data', { destination: selected })
await settings?.set('customDataLocation', selected)
await invoke('restart_app')
} catch {
setMovingData(false)
}
}
}}
title='Move game data to a custom storage location, like a different disk.'
/>
{customDataLocation && (
{customDataLocation}
)}
Theme:
{
await settings?.set('theme', val)
}}
/>
await copyToClipboard(`v${version}`, notificationsAllowed)
}
title='The current launcher version.'
>
v{version}