feat: Java Version editor (Should probably make it more intuitive though)

This commit is contained in:
LynithDev 2024-09-10 21:05:08 +02:00
parent 641a728918
commit bfaa6ceb3a
9 changed files with 110 additions and 74 deletions

62
Cargo.lock generated
View file

@ -3077,15 +3077,6 @@ dependencies = [
"cfb",
]
[[package]]
name = "infer"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc150e5ce2330295b8616ce0e3f53250e53af31759a9dbedad1621ba29151847"
dependencies = [
"cfb",
]
[[package]]
name = "inotify"
version = "0.9.6"
@ -4449,6 +4440,7 @@ dependencies = [
"tauri-plugin-updater",
"tauri-plugin-window-state",
"tauri-specta",
"tauri-utils",
"thiserror",
"tokio",
"tracing",
@ -7139,9 +7131,9 @@ dependencies = [
[[package]]
name = "tao"
version = "0.30.0"
version = "0.29.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a93f2c6b8fdaeb7f417bda89b5bc767999745c3052969664ae1fa65892deb7e"
checksum = "d3a97abbc7d6cfd0720da3e06fcb1cf2ac87cbfdb5bbbce103a1279a211c4d81"
dependencies = [
"bitflags 2.6.0",
"cocoa",
@ -7250,7 +7242,7 @@ dependencies = [
"tracing",
"tray-icon",
"url",
"urlpattern 0.2.0",
"urlpattern",
"uuid 1.10.0",
"webkit2gtk",
"webview2-com",
@ -7283,9 +7275,9 @@ dependencies = [
[[package]]
name = "tauri-codegen"
version = "2.0.0-rc.9"
version = "2.0.0-rc.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "467d3e95b57c860bea13b7c812820d9e7425e4b700e5e69b358d906f22022007"
checksum = "809ef6316726fc72593d296cf6f4e7461326e310c313d6a6c42b6e7f1e2671cf"
dependencies = [
"base64 0.22.1",
"brotli",
@ -7310,9 +7302,9 @@ dependencies = [
[[package]]
name = "tauri-macros"
version = "2.0.0-rc.8"
version = "2.0.0-rc.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4585a906bd96bf57d063c3d60c52577ccc5de592d08f9d112e873ada79af9b9"
checksum = "1359e8861d210d25731f8b1bfbb4d111dd06406cf73c59659366ef450364d811"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@ -7324,9 +7316,9 @@ dependencies = [
[[package]]
name = "tauri-plugin"
version = "2.0.0-rc.9"
version = "2.0.0-rc.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b905ecef194245bb35baba0447703f9fe40e4c03e946c7aba54c21c23e3452c7"
checksum = "a7dded420c86183f592d0fe925ef9447f41e26fa79f0bdfef8d3f17bfbcdbfb7"
dependencies = [
"anyhow",
"glob",
@ -7460,7 +7452,7 @@ dependencies = [
"flate2",
"futures-util",
"http 1.1.0",
"infer 0.15.0",
"infer",
"minisign-verify",
"reqwest 0.12.7",
"semver",
@ -7495,9 +7487,9 @@ dependencies = [
[[package]]
name = "tauri-runtime"
version = "2.0.0-rc.9"
version = "2.0.0-rc.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b72cd110a6699ef44963504d4fa4f6c535677bb0177da2d178f4f822a53058ed"
checksum = "75c72b844f387bfc3341c355f3e16b8cbf4161848fa4e348670effb222cd3ba5"
dependencies = [
"dpi",
"gtk",
@ -7514,9 +7506,9 @@ dependencies = [
[[package]]
name = "tauri-runtime-wry"
version = "2.0.0-rc.9"
version = "2.0.0-rc.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1eb325cca17496ccbb469e7e2fef7f3e31a1005ab0c658dc3331c7781a573401"
checksum = "73accf936a7cd01d1382de7850726fdf6c1f6ab3b01ccb7a0950cb852e332596"
dependencies = [
"cocoa",
"gtk",
@ -7568,9 +7560,9 @@ dependencies = [
[[package]]
name = "tauri-utils"
version = "2.0.0-rc.9"
version = "2.0.0-rc.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6746b87c4755f493b94920622e245aef2d771f001ddeffc203e315872d323e1c"
checksum = "d53d9fe87e985b273696ae22ce2b9f099a8f1b44bc8fb127467bda5fcb3e4371"
dependencies = [
"aes-gcm",
"brotli",
@ -7580,7 +7572,7 @@ dependencies = [
"getrandom 0.2.15",
"glob",
"html5ever",
"infer 0.16.0",
"infer",
"json-patch",
"kuchikiki",
"log",
@ -7600,7 +7592,7 @@ dependencies = [
"thiserror",
"toml 0.8.2",
"url",
"urlpattern 0.3.0",
"urlpattern",
"walkdir",
]
@ -8279,18 +8271,6 @@ dependencies = [
"url",
]
[[package]]
name = "urlpattern"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70acd30e3aa1450bc2eece896ce2ad0d178e9c079493819301573dae3c37ba6d"
dependencies = [
"regex",
"serde",
"unic-ucd-ident",
"url",
]
[[package]]
name = "user-facing-error-macros"
version = "0.1.0"
@ -9146,9 +9126,9 @@ dependencies = [
[[package]]
name = "wry"
version = "0.43.1"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4d715cf5fe88e9647f3d17b207b6d060d4a88e7171d4ccb2d2c657dd1d44728"
checksum = "49b8049c8f239cdbfaaea4bacb9646f6b208938ceec0acd5b3e99cd05f70903f"
dependencies = [
"base64 0.22.1",
"block",

View file

@ -42,6 +42,8 @@ tauri = { version = "=2.0.0-rc.8", features = [
"protocol-asset"
] }
# tauri-utils is a collection of utilities for tauri apps.
tauri-utils = { version = "=2.0.0-rc.7" }
# tauri-build is the codegen utility for our tauri buildscript.
tauri-build = { version = "=2.0.0-rc.7" }
# tauri-plugin-shell adds a bridge for opening urls and paths in the frontend.
@ -174,8 +176,8 @@ cocoa = { version = "0.26" }
objc = { version = "0.2" }
cc = { version = "1.1" }
libc = { version = "0.2" }
# https://github.com/tauri-apps/tauri/blob/tauri-v2.0.0-rc.0/core/tauri/Cargo.toml#L86
webkit2gtk = { version = "=2.0.1", features = [ "v2_38" ] }
# https://github.com/tauri-apps/tauri/blob/dev/crates/tauri/Cargo.toml#L102
webkit2gtk = { version = "=2.0.1", features = [ "v2_40" ] }
[workspace.dependencies.prisma-client-rust]
git = "https://github.com/brendonovich/prisma-client-rust"

View file

@ -28,6 +28,7 @@ tauri-plugin-updater = { workspace = true }
tauri-plugin-clipboard-manager = { workspace = true }
tauri-plugin-dialog = { workspace = true }
tauri-plugin-deep-link = { workspace = true }
tauri-utils = { workspace = true }
tauri-specta = { workspace = true }
specta = { workspace = true }
specta-typescript = { workspace = true }

View file

@ -1,11 +1,11 @@
import { ChevronDownIcon, Download01Icon, HeartIcon } from '@untitled-theme/icons-solid';
import useBrowser from '~ui/hooks/useBrowser';
import useSettings from '~ui/hooks/useSettings';
import { abbreviateNumber } from '~utils';
import { createSignal, For, Match, Show, Switch } from 'solid-js';
import { For, Match, Show, Switch, createSignal } from 'solid-js';
import type { Providers, SearchResult } from '@onelauncher/client/bindings';
import type { JSX } from 'solid-js';
import Button from '../base/Button';
import { abbreviateNumber } from '~utils';
import useSettings from '~ui/hooks/useSettings';
import useBrowser from '~ui/hooks/useBrowser';
interface SearchResultsContainerProps {
provider: Providers;

View file

@ -6,6 +6,12 @@ import {
RefreshCw01Icon,
SearchMdIcon,
} from '@untitled-theme/icons-solid';
import { For, Show, onMount } from 'solid-js';
import type { Cluster } from '@onelauncher/client/bindings';
import BannerBackground from '../../assets/images/header.png';
import Button from '../components/base/Button';
import TextField from '../components/base/TextField';
import ClusterRoot from './cluster/ClusterRoot';
import { bridge } from '~imports';
import ClusterCover from '~ui/components/game/ClusterCover';
@ -13,12 +19,6 @@ import { useClusterCreator } from '~ui/components/overlay/cluster/ClusterCreatio
import { useLaunchCluster, useRecentCluster } from '~ui/hooks/useCluster';
import useCommand from '~ui/hooks/useCommand';
import { formatAsDuration, upperFirst } from '~utils';
import { For, onMount, Show } from 'solid-js';
import type { Cluster } from '@onelauncher/client/bindings';
import BannerBackground from '../../assets/images/header.png';
import Button from '../components/base/Button';
import TextField from '../components/base/TextField';
import ClusterRoot from './cluster/ClusterRoot';
type GroupedClusters = Record<string, Cluster[]>;
@ -72,11 +72,13 @@ function HomePage() {
<Show
children={(
<For each={Object.entries(clusters() ?? {})}>
{([group, clusters]) => (
<ClusterGroup clusters={clusters} title={group} />
)}
</For>
<div class="flex flex-col gap-y-8 pb-8">
<For each={Object.entries(clusters() ?? {})}>
{([group, clusters]) => (
<ClusterGroup clusters={clusters} title={group} />
)}
</For>
</div>
)}
fallback={(
<div class="max-h-64 flex flex-1 flex-col items-center justify-center gap-y-4">

View file

@ -1,13 +1,13 @@
import { useBeforeLeave } from '@solidjs/router';
import { type Accessor, Show } from 'solid-js';
import type { Cluster } from '@onelauncher/client/bindings';
import { GameSettings, JvmSettings, LauncherSettings, ProcessSettings, createSetting } from '../settings/game/SettingsMinecraft';
import { bridge } from '~imports';
import ScrollableContainer from '~ui/components/ScrollableContainer';
import Sidebar from '~ui/components/Sidebar';
import useClusterContext from '~ui/hooks/useCluster';
import { tryResult } from '~ui/hooks/useCommand';
import useSettings from '~ui/hooks/useSettings';
import { type Accessor, Show } from 'solid-js';
import type { Cluster } from '@onelauncher/client/bindings';
import { createSetting, GameSettings, JvmSettings, LauncherSettings, ProcessSettings } from '../settings/game/SettingsMinecraft';
function ClusterSettings() {
const [cluster] = useClusterContext();
@ -40,6 +40,7 @@ function PageSettings(cluster: Accessor<Cluster>) {
const postCommand = createSetting(cluster().init_hooks?.post, settings().init_hooks.post ?? '');
// JVM
const javaVersion = createSetting(cluster().java?.custom_version || null);
const javaArgs = createSetting(cluster().java?.custom_arguments, settings().custom_java_args);
const envVars = createSetting(cluster().java?.custom_env_arguments, settings().custom_env_args);
@ -61,6 +62,7 @@ function PageSettings(cluster: Accessor<Cluster>) {
// JVM
java: {
custom_version: javaVersion.getRaw(),
custom_arguments: javaArgs.getRaw(),
custom_env_arguments: envVars.getRaw(),
},
@ -94,6 +96,8 @@ function PageSettings(cluster: Accessor<Cluster>) {
<JvmSettings
{...{
javaVersion,
javaVersions: undefined,
javaArgs,
envVars,
}}

View file

@ -1,11 +1,11 @@
import { InfoCircleIcon, Trash01Icon, UserPlus02Icon } from '@untitled-theme/icons-solid';
import { For, Match, Show, Switch, createSignal, mergeProps } from 'solid-js';
import Button from '~ui/components/base/Button';
import Tooltip from '~ui/components/base/Tooltip';
import PlayerHead from '~ui/components/game/PlayerHead';
import useAccountController from '~ui/components/overlay/account/AddAccountModal';
import ScrollableContainer from '~ui/components/ScrollableContainer';
import Sidebar from '~ui/components/Sidebar';
import { createSignal, For, Match, mergeProps, Show, Switch } from 'solid-js';
function SettingsAccounts() {
const controller = useAccountController();

View file

@ -1,4 +1,6 @@
import { ActivityIcon, CpuChip01Icon, Database01Icon, EyeIcon, FilePlus02Icon, FileX02Icon, LayoutTopIcon, Maximize01Icon, ParagraphWrapIcon, VariableIcon, XIcon } from '@untitled-theme/icons-solid';
import { type Accessor, For, type Setter, Show, createSignal, onMount, splitProps, untrack } from 'solid-js';
import type { JavaVersion, JavaVersions, Memory, Resolution } from '@onelauncher/client/bindings';
import TextField from '~ui/components/base/TextField';
import Toggle from '~ui/components/base/Toggle';
import ScrollableContainer from '~ui/components/ScrollableContainer';
@ -6,8 +8,8 @@ import BaseSettingsRow, { type SettingsRowProps } from '~ui/components/SettingsR
import Sidebar from '~ui/components/Sidebar';
import useSettings from '~ui/hooks/useSettings';
import { asEnvVariables } from '~utils';
import { type Accessor, createSignal, onMount, type Setter, Show, splitProps, untrack } from 'solid-js';
import type { Memory, Resolution } from '@onelauncher/client/bindings';
import Modal, { createModal } from '~ui/components/overlay/Modal';
import Button from '~ui/components/base/Button';
function SettingsMinecraft() {
return (
@ -291,9 +293,44 @@ export function ProcessSettings(props: {
}
export function JvmSettings(props: {
javaVersion: CreateSetting<JavaVersion> | undefined;
javaVersions: CreateSetting<JavaVersions> | undefined;
javaArgs: CreateSetting<string[]>;
envVars: CreateSetting<[string, string][]>;
}) {
const modal = createModal(controller => (
<Modal.Simple
title="Java Versions"
buttons={[
<Button
onClick={controller.hide}
buttonStyle="secondary"
children="Close"
/>,
]}
{...controller}
>
<div class="grid grid-cols-[80px_1fr] items-center gap-y-2">
<For each={Object.entries(props.javaVersions?.get() ?? {}).sort((a, b) => Number.parseFloat(b[1].version) - Number.parseFloat(a[1].version))}>
{([version, meta]) => {
const prettified = version.toLowerCase().replaceAll('_', ' ');
return (
<>
<span class="capitalize">{prettified}</span>
<TextField
value={meta.path}
onValidSubmit={(value) => {
props.javaVersions?.set({ ...props.javaVersions.get(), [version]: { ...meta, path: value } });
}}
/>
</>
);
}}
</For>
</div>
</Modal.Simple>
));
return (
<>
<BaseSettingsRow.Header>Java</BaseSettingsRow.Header>
@ -304,7 +341,13 @@ export function JvmSettings(props: {
isGlobal={() => true}
reset={() => {}}
title="Version"
/>
>
<Button
onClick={modal.show}
iconLeft={<Database01Icon />}
children="Configure"
/>
</SettingsRow>
<SettingsRow
description="Additional arguments passed to the JVM (Java Virtual Machine)."
@ -361,6 +404,7 @@ function PageSettings() {
const postCommand = createSetting(settings().init_hooks.post ?? '');
// JVM
const javaVersions = createSetting(settings().java_versions);
const javaArgs = createSetting(settings().custom_java_args);
const envVars = createSetting(settings().custom_env_args);
@ -382,6 +426,7 @@ function PageSettings() {
},
// JVM
java_versions: javaVersions.get(),
custom_java_args: javaArgs.get(),
custom_env_args: envVars.get(),
}));
@ -413,6 +458,8 @@ function PageSettings() {
<JvmSettings
{...{
javaVersion: undefined,
javaVersions,
javaArgs,
envVars,
}}

View file

@ -1,14 +1,14 @@
import { useBeforeLeave } from '@solidjs/router';
import { ColorsIcon, PackageIcon, PaintPourIcon, Speedometer04Icon } from '@untitled-theme/icons-solid';
import Button from '~ui/components/base/Button';
import { PackageIcon, Speedometer04Icon } from '@untitled-theme/icons-solid';
import { For, createSignal } from 'solid-js';
import SettingsRow from '../../../components/SettingsRow';
import Dropdown from '~ui/components/base/Dropdown';
import Toggle from '~ui/components/base/Toggle';
import ScrollableContainer from '~ui/components/ScrollableContainer';
import Sidebar from '~ui/components/Sidebar';
import useSettings from '~ui/hooks/useSettings';
import { BROWSER_VIEWS } from '~utils/browser';
import { createSignal, For } from 'solid-js';
import SettingsRow from '../../../components/SettingsRow';
import { upperFirst } from '~utils';
function SettingsAppearance() {
const { settings, saveOnLeave } = useSettings();
@ -30,17 +30,17 @@ function SettingsAppearance() {
<Sidebar.Page>
<h1>Appearance</h1>
<ScrollableContainer>
<div class="flex flex-row items-center">
{/* <div class="flex flex-row items-center">
<p>theme placeholder</p>
</div>
</div> */}
<SettingsRow
{/* <SettingsRow
description="The main color used across the launcher. This doesn't edit your theme."
icon={<PaintPourIcon />}
title="Accent Color"
>
<Button iconLeft={<ColorsIcon />}>#ff0000</Button>
</SettingsRow>
</SettingsRow> */}
<SettingsRow
description="Change the look of the package list."
@ -53,7 +53,7 @@ function SettingsAppearance() {
>
<For each={BROWSER_VIEWS}>
{view => (
<Dropdown.Row>{view}</Dropdown.Row>
<Dropdown.Row>{upperFirst(view)}</Dropdown.Row>
)}
</For>
</Dropdown>