diff --git a/desktop/src-tauri/src/api/commands.rs b/desktop/src-tauri/src/api/commands.rs index 32fa0d99..a416dc4d 100644 --- a/desktop/src-tauri/src/api/commands.rs +++ b/desktop/src-tauri/src/api/commands.rs @@ -67,6 +67,12 @@ pub async fn create_cluster(props: CreateCluster) -> Result { } } +// #[specta::specta] +// #[tauri::command] +// pub fn update_cluster(cluster: Cluster) -> Result<(), String> { + +// } + fn placeholder_cluster() -> Cluster { let path = ClusterPath("test".into()); Cluster { diff --git a/desktop/src/ui/components/SettingsRow.tsx b/desktop/src/ui/components/SettingsRow.tsx index d5bb35c1..1062d4ff 100644 --- a/desktop/src/ui/components/SettingsRow.tsx +++ b/desktop/src/ui/components/SettingsRow.tsx @@ -22,7 +22,7 @@ function SettingsRow(props: SettingsRowProps) {

{props.description}

-
+
{props.children}
diff --git a/desktop/src/ui/pages/cluster/ClusterRoot.tsx b/desktop/src/ui/pages/cluster/ClusterRoot.tsx index e5ecabe1..ecb1b01c 100644 --- a/desktop/src/ui/pages/cluster/ClusterRoot.tsx +++ b/desktop/src/ui/pages/cluster/ClusterRoot.tsx @@ -1,6 +1,6 @@ import { Route, useSearchParams } from '@solidjs/router'; import type { ParentProps } from 'solid-js'; -import { EyeIcon, File06Icon, Globe04Icon, Image03Icon, Settings04Icon, Tool02Icon } from '@untitled-theme/icons-solid'; +import { EyeIcon, File06Icon, Globe04Icon, Image03Icon, Settings04Icon } from '@untitled-theme/icons-solid'; import Sidebar from '../../components/Sidebar'; import AnimatedRoutes from '../../components/AnimatedRoutes'; import ErrorBoundary from '../../components/ErrorBoundary'; @@ -8,6 +8,7 @@ import ClusterOverview from './cluster/ClusterOverview'; import ClusterLogs from './cluster/ClusterLogs'; import ClusterMods from './cluster/ClusterMods'; import ClusterScreenshots from './cluster/ClusterScreenshots'; +import ClusterSettings from './cluster/ClusterSettings'; import useClusterContext, { ClusterProvider } from '~ui/hooks/useCluster'; function ClusterRoutes() { @@ -17,6 +18,7 @@ function ClusterRoutes() { + ); } @@ -58,10 +60,7 @@ function ClusterSidebar() { [, 'Screenshots', '/screenshots'], [, 'Worlds', '/worlds'], [, 'Logs', '/logs'], - ], - Settings: [ - [, 'Java', '/java'], - [, 'Miscellaneous', '/misc'], + [, 'Game Settings', '/settings'], ], }} /> diff --git a/desktop/src/ui/pages/cluster/cluster/ClusterSettings.tsx b/desktop/src/ui/pages/cluster/cluster/ClusterSettings.tsx new file mode 100644 index 00000000..e987a21b --- /dev/null +++ b/desktop/src/ui/pages/cluster/cluster/ClusterSettings.tsx @@ -0,0 +1,34 @@ +import ScrollableContainer from '~ui/components/ScrollableContainer'; +import Sidebar from '~ui/components/Sidebar'; +import useClusterContext from '~ui/hooks/useCluster'; +import useSettingsContext from '~ui/hooks/useSettings'; +import SettingsMinecraft from '~ui/pages/settings/game/SettingsMinecraft'; + +function ClusterSettings() { + const cluster = useClusterContext(); + const settings = useSettingsContext(); + + // TODO: Save cluster settings + + return ( + +

Overview

+ + cluster.force_fullscreen = value, + isGlobal: cluster.force_fullscreen === null, + }} + resolution={{ + get: cluster.resolution ?? settings.resolution, + set: value => cluster.resolution = value, + isGlobal: cluster.resolution === undefined || cluster.resolution === null, + }} + /> + +
+ ); +} + +export default ClusterSettings; diff --git a/desktop/src/ui/pages/settings/game/SettingsMinecraft.tsx b/desktop/src/ui/pages/settings/game/SettingsMinecraft.tsx index e547cbba..5827a67f 100644 --- a/desktop/src/ui/pages/settings/game/SettingsMinecraft.tsx +++ b/desktop/src/ui/pages/settings/game/SettingsMinecraft.tsx @@ -1,7 +1,10 @@ -import { EyeIcon, LayoutTopIcon, Maximize01Icon, XIcon } from '@untitled-theme/icons-solid'; +import { EyeIcon, FlipBackwardIcon, Globe02Icon, InfoCircleIcon, LayoutTopIcon, Maximize01Icon, XIcon } from '@untitled-theme/icons-solid'; +import { Show } from 'solid-js'; +import Button from '~ui/components/base/Button'; import Dropdown from '~ui/components/base/Dropdown'; import TextField from '~ui/components/base/TextField'; import Toggle from '~ui/components/base/Toggle'; +import Tooltip from '~ui/components/base/Tooltip'; import ScrollableContainer from '~ui/components/ScrollableContainer'; import SettingsRow from '~ui/components/SettingsRow'; import Sidebar from '~ui/components/Sidebar'; @@ -14,18 +17,54 @@ function SettingsMinecraft() {

Global Minecraft Settings

+ settings.force_fullscreen = value, + }} + resolution={{ + get: settings.resolution, + set: value => settings.resolution = value, + }} + hide_on_launch={{ + get: settings.hide_on_launch ?? false, + set: value => settings.hide_on_launch = value, + }} + /> + +
+ ); +} +interface SettingsEntryType { + get: T; + set: (value: T) => any; + isGlobal?: boolean; // TODO: Ask how "global settings sync" should work on pages like ClusterSettings +}; + +interface SettingsProps { + fullscreen: SettingsEntryType; + resolution: SettingsEntryType<[number, number]>; + hide_on_launch: SettingsEntryType; +}; + +SettingsMinecraft.Settings = function (props: Partial) { + return ( + <> + } > settings.force_fullscreen = value} + defaultChecked={props.fullscreen!.get} + onChecked={props.fullscreen!.set} /> + + { - settings.resolution = [Number.parseInt(value), settings.resolution[1]]; + props.resolution!.set([Number.parseInt(value), props.resolution!.get[1]]); }} /> { - settings.resolution = [settings.resolution[0], Number.parseInt(value)]; + props.resolution!.set([props.resolution!.get[0], Number.parseInt(value)]); }} /> + + } > - { - switch (selected) { - case 0: - settings.hide_on_launch = false; - break; - case 1: - settings.hide_on_launch = true; - break; - case 2: - break; - } - }} - > - Visible - Hide - Close (// TODO) - + - - - + + ); -} +}; export default SettingsMinecraft; diff --git a/eslint.config.js b/eslint.config.js index 23f8eddf..91e8ab54 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -21,6 +21,7 @@ export default petal({ '**/*.svg', '*.rs', 'pnpm-lock.yaml', + '**/node_modules', 'desktop/src/bindings.ts', ], }).append([