From 43678cc64d0c90c2be6793245370906168731e55 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Fri, 8 May 2026 17:11:31 -0700 Subject: [PATCH] Add relaunch, reset, delete download cache, delete invalid games buttons to settings page --- src-tauri/capabilities/default.json | 1 + src/app/main/settings/page.tsx | 367 +++++++++++++++++++--------- 2 files changed, 257 insertions(+), 111 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index a03efc8..425b40c 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -20,6 +20,7 @@ "core:window:allow-request-user-attention", "core:webview:allow-create-webview-window", "fs:default", + "fs:allow-remove", "dialog:default", "dialog:allow-open", "notification:default", diff --git a/src/app/main/settings/page.tsx b/src/app/main/settings/page.tsx index fe66386..8521d62 100644 --- a/src/app/main/settings/page.tsx +++ b/src/app/main/settings/page.tsx @@ -4,15 +4,20 @@ 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 { message, open } from '@tauri-apps/plugin-dialog' import { invoke } from '@tauri-apps/api/core' import Dropdown from '@/components/Dropdown' import { WebviewWindow } from '@tauri-apps/api/webviewWindow' +import { relaunch } from '@tauri-apps/plugin-process' +import { BaseDirectory, exists, readDir, remove } from '@tauri-apps/plugin-fs' export default function Settings () { const { settings, + versions, + account, version, + versionsList, notificationsAllowed, sidebarAlwaysShowGames, linuxUseWine, @@ -26,121 +31,261 @@ export default function Settings () { 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'} - /> - {platform() == 'linux' && linuxUseWine && ( - <> -

Wine Command:

- - await settings?.set('linuxWineCommand', e.target.value) - } - className='input-field my-1' - > - - )} - 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) - - const window = await WebviewWindow.getByLabel( - 'berrydashleaderboards' +
+
+ { + 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 ) - if (window) { - await window.close() - - new WebviewWindow('berrydashleaderboards', { - title: 'Berry Dash Leaderboards', - url: - 'https://games.lncvrt.xyz/game/berry-dash/leaderboards?launcher=1&theme=' + - val, - width: 800, - height: 600, - resizable: false, - maximizable: false + }} + 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'} + /> + {platform() == 'linux' && linuxUseWine && ( + <> +

Wine Command:

+ + await settings?.set('linuxWineCommand', e.target.value) + } + className='input-field my-1' + > + + )} + 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) + + const window = await WebviewWindow.getByLabel( + 'berrydashleaderboards' + ) + if (window) { + await window.close() + + new WebviewWindow('berrydashleaderboards', { + title: 'Berry Dash Leaderboards', + url: + 'https://games.lncvrt.xyz/game/berry-dash/leaderboards?launcher=1&theme=' + + val, + width: 800, + height: 600, + resizable: false, + maximizable: false + }) + } + }} + /> +
+
+
+ + + + +

Hover buttons for descriptions