From 0d78b752c9673ede5a962f54c52198b810b54daf Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Wed, 14 Jan 2026 16:38:02 +0800 Subject: feat: enhance VersionsView with modded version support and filtering options --- ui/src/components/VersionsView.svelte | 268 +++++++++++++++++++++++++++++----- 1 file changed, 231 insertions(+), 37 deletions(-) (limited to 'ui/src/components/VersionsView.svelte') diff --git a/ui/src/components/VersionsView.svelte b/ui/src/components/VersionsView.svelte index 98261b8..1ea4878 100644 --- a/ui/src/components/VersionsView.svelte +++ b/ui/src/components/VersionsView.svelte @@ -1,55 +1,249 @@

Versions

- - -
- {#if gameState.versions.length === 0} -
Loading versions...
- {:else if filteredVersions.length === 0 && normalizedQuery.length > 0} -
No versions found matching "{searchQuery}"
- {:else} - {#each filteredVersions as version} +
+ +
+ +
+ +
+ + +
- {/each} - {/if} + + + +
+ + +
+ {#if gameState.versions.length === 0} +
Loading versions...
+ {:else if filteredVersions().length === 0} +
+ {#if normalizedQuery.length > 0} + No versions found matching "{searchQuery}" + {:else} + No versions in this category + {/if} +
+ {:else} + {#each filteredVersions() as version} + {@const badge = getVersionBadge(version.type)} + + {/each} + {/if} +
+
+ + +
+ + {#if gameState.selectedVersion} +
+

Selected

+

+ {gameState.selectedVersion} +

+
+ {/if} + + + + + +
+

💡 Tip

+

+ Select a vanilla Minecraft version, then use the Mod Loader panel to + install Fabric or Forge. Installed modded versions will appear in the + list with colored badges. +

+
+
+ -- cgit v1.2.3-70-g09d2 From eed52135e7d6ffbbbd64070cf567bcf08653c7d5 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Wed, 14 Jan 2026 18:15:31 +0800 Subject: feat: Enhance UI components and add visual effects - Updated Sidebar component styles for improved aesthetics and usability. - Refactored VersionsView component with a new layout and enhanced version filtering. - Improved DownloadMonitor and GameConsole components for better performance and visual consistency. - Added new settings for GPU acceleration and visual effects in settings store. - Introduced ParticleBackground component with customizable effects (Constellation and Saturn). - Implemented ConstellationEffect and SaturnEffect classes for dynamic background animations. --- src-tauri/Cargo.toml | 1 + src-tauri/capabilities/default.json | 3 +- src-tauri/src/core/config.rs | 8 + src-tauri/src/main.rs | 1 + ui/package.json | 1 + ui/pnpm-lock.yaml | 10 + ui/src/App.svelte | 145 +++++++++++--- ui/src/components/BottomBar.svelte | 79 ++++---- ui/src/components/HomeView.svelte | 57 ++++-- ui/src/components/ModLoaderSelector.svelte | 214 ++++++++++----------- ui/src/components/ParticleBackground.svelte | 57 ++++++ ui/src/components/SettingsView.svelte | 282 ++++++++++++++++++++-------- ui/src/components/Sidebar.svelte | 76 ++++---- ui/src/components/VersionsView.svelte | 184 +++++++++--------- ui/src/lib/DownloadMonitor.svelte | 2 +- ui/src/lib/GameConsole.svelte | 2 +- ui/src/lib/effects/ConstellationEffect.ts | 163 ++++++++++++++++ ui/src/lib/effects/SaturnEffect.ts | 194 +++++++++++++++++++ ui/src/stores/settings.svelte.ts | 3 + ui/src/types/index.ts | 4 + 20 files changed, 1080 insertions(+), 406 deletions(-) create mode 100644 ui/src/components/ParticleBackground.svelte create mode 100644 ui/src/lib/effects/ConstellationEffect.ts create mode 100644 ui/src/lib/effects/SaturnEffect.ts (limited to 'ui/src/components/VersionsView.svelte') diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d7319a7..1d4ccc5 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -23,6 +23,7 @@ sha1 = "0.10" hex = "0.4" zip = "2.2.2" serde_urlencoded = "0.7.1" +tauri-plugin-dialog = "2.5.0" [build-dependencies] tauri-build = { version = "2.0", features = [] } diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 894b905..4d8b907 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -12,6 +12,7 @@ "core:app:allow-version", "core:path:default", "core:window:default", - "shell:allow-open" + "shell:allow-open", + "dialog:default" ] } diff --git a/src-tauri/src/core/config.rs b/src-tauri/src/core/config.rs index d6d594f..27e0011 100644 --- a/src-tauri/src/core/config.rs +++ b/src-tauri/src/core/config.rs @@ -13,6 +13,10 @@ pub struct LauncherConfig { pub width: u32, pub height: u32, pub download_threads: u32, // concurrent download threads (1-128) + pub custom_background_path: Option, + pub enable_gpu_acceleration: bool, + pub enable_visual_effects: bool, + pub active_effect: String, } impl Default for LauncherConfig { @@ -24,6 +28,10 @@ impl Default for LauncherConfig { width: 854, height: 480, download_threads: 32, + custom_background_path: None, + enable_gpu_acceleration: false, + enable_visual_effects: true, + active_effect: "constellation".to_string(), } } } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ba16f7a..f7a391a 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1004,6 +1004,7 @@ async fn install_forge( fn main() { tauri::Builder::default() + .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_shell::init()) .manage(core::auth::AccountState::new()) .manage(MsRefreshTokenState::new()) diff --git a/ui/package.json b/ui/package.json index 0806781..03cc405 100644 --- a/ui/package.json +++ b/ui/package.json @@ -29,6 +29,7 @@ }, "dependencies": { "@tauri-apps/api": "^2.9.1", + "@tauri-apps/plugin-dialog": "^2.5.0", "@tauri-apps/plugin-shell": "^2.3.4" } } diff --git a/ui/pnpm-lock.yaml b/ui/pnpm-lock.yaml index d48c01e..23d4ee2 100644 --- a/ui/pnpm-lock.yaml +++ b/ui/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@tauri-apps/api': specifier: ^2.9.1 version: 2.9.1 + '@tauri-apps/plugin-dialog': + specifier: ^2.5.0 + version: 2.5.0 '@tauri-apps/plugin-shell': specifier: ^2.3.4 version: 2.3.4 @@ -296,6 +299,9 @@ packages: '@tauri-apps/api@2.9.1': resolution: {integrity: sha512-IGlhP6EivjXHepbBic618GOmiWe4URJiIeZFlB7x3czM0yDHHYviH1Xvoiv4FefdkQtn6v7TuwWCRfOGdnVUGw==} + '@tauri-apps/plugin-dialog@2.5.0': + resolution: {integrity: sha512-I0R0ygwRd9AN8Wj5GnzCogOlqu2+OWAtBd0zEC4+kQCI32fRowIyuhPCBoUv4h/lQt2bM39kHlxPHD5vDcFjiA==} + '@tauri-apps/plugin-shell@2.3.4': resolution: {integrity: sha512-ktsRWf8wHLD17aZEyqE8c5x98eNAuTizR1FSX475zQ4TxaiJnhwksLygQz+AGwckJL5bfEP13nWrlTNQJUpKpA==} @@ -808,6 +814,10 @@ snapshots: '@tauri-apps/api@2.9.1': {} + '@tauri-apps/plugin-dialog@2.5.0': + dependencies: + '@tauri-apps/api': 2.9.1 + '@tauri-apps/plugin-shell@2.3.4': dependencies: '@tauri-apps/api': 2.9.1 diff --git a/ui/src/App.svelte b/ui/src/App.svelte index 3750f11..d93374e 100644 --- a/ui/src/App.svelte +++ b/ui/src/App.svelte @@ -1,6 +1,7 @@
- + +
+ {#if settingsState.settings.custom_background_path} + Background + +
+ {:else if settingsState.settings.enable_visual_effects} + +
- -
- - -
- -
- - -
{#if uiState.currentView === "home"} - - {:else if uiState.currentView === "versions"} - - {:else if uiState.currentView === "settings"} - + {/if} + +
+ {/if} + + +
+
+ + +
+ + + + +
+ + +
- -
+ +
+ +
+ {#if uiState.currentView === "home"} + + {:else if uiState.currentView === "versions"} + + {:else if uiState.currentView === "settings"} + + {/if} +
+ + +
+
+ +
+
+ + + +
+
+
- - + + {#if uiState.showConsole} + +
+
+ + +
+
+ {/if}
+ + diff --git a/ui/src/components/BottomBar.svelte b/ui/src/components/BottomBar.svelte index dcad9e8..dd218f3 100644 --- a/ui/src/components/BottomBar.svelte +++ b/ui/src/components/BottomBar.svelte @@ -5,18 +5,19 @@
-
+ +
authState.openLoginModal()} role="button" tabindex="0" onkeydown={(e) => e.key === "Enter" && authState.openLoginModal()} >
{#if authState.currentAccount} {:else} - ? + ? {/if}
-
- {authState.currentAccount ? authState.currentAccount.username : "Click to Login"} +
+ {authState.currentAccount ? authState.currentAccount.username : "Login"}
-
+
- {authState.currentAccount ? "Ready" : "Guest"} + {authState.currentAccount ? "Ready to play" : "Guest Mode"}
+ +
+
-
+ +
Selected Version - +
+ +
+
diff --git a/ui/src/components/HomeView.svelte b/ui/src/components/HomeView.svelte index e876c14..036c03a 100644 --- a/ui/src/components/HomeView.svelte +++ b/ui/src/components/HomeView.svelte @@ -1,26 +1,47 @@ - -
-
+
+ + +
+
-
-

+ +
- MINECRAFT -

-
- JAVA EDITION - Release 1.20.4 + MINECRAFT + + +
+
+ Java Edition +
+
+ Latest Release 1.21 +
+
+
+ + +
+ +
+ Ready to play. Select version below or hit Launch. +
diff --git a/ui/src/components/ModLoaderSelector.svelte b/ui/src/components/ModLoaderSelector.svelte index 06eb6ae..4a59916 100644 --- a/ui/src/components/ModLoaderSelector.svelte +++ b/ui/src/components/ModLoaderSelector.svelte @@ -112,134 +112,134 @@ } -
-

Mod Loader

+
+
+

Select Mod Loader

+
- -
+ +
- {#if selectedLoader === "vanilla"} -

- Launch the selected Minecraft version without any mod loaders. -

- {:else if !selectedGameVersion} -

- Select a Minecraft version first to see available {selectedLoader} versions. -

- {:else if isLoading} -
- - - - - Loading {selectedLoader} versions... -
- {:else if error} -

{error}

- {:else if selectedLoader === "fabric"} -
-
- - -
- -
- {:else if selectedLoader === "forge"} -
- {#if forgeVersions.length === 0} -

- No Forge versions available for Minecraft {selectedGameVersion} -

- {:else} + +
+ {#if selectedLoader === "vanilla"} +
+ No mod loader selected.
Pure vanilla experience. +
+ + {:else if !selectedGameVersion} +
+ ⚠️ Please select a base Minecraft version first. +
+ + {:else if isLoading} +
+
+ Loading {selectedLoader} versions... +
+ + {:else if error} +
+ {error} +
+ + {:else if selectedLoader === "fabric"} +
- - + +
+ +
+
+ - {/if} -
- {/if} +
+ + {:else if selectedLoader === "forge"} +
+ {#if forgeVersions.length === 0} +
+ No Forge versions available for {selectedGameVersion} +
+ {:else} +
+ +
+ +
+
+
+ + + {/if} +
+ {/if} +
diff --git a/ui/src/components/ParticleBackground.svelte b/ui/src/components/ParticleBackground.svelte new file mode 100644 index 0000000..080f1f2 --- /dev/null +++ b/ui/src/components/ParticleBackground.svelte @@ -0,0 +1,57 @@ + + + diff --git a/ui/src/components/SettingsView.svelte b/ui/src/components/SettingsView.svelte index 801970b..4c92220 100644 --- a/ui/src/components/SettingsView.svelte +++ b/ui/src/components/SettingsView.svelte @@ -1,150 +1,274 @@ -
-

Settings

+
+
+

Settings

+
+ +
-
- -
- -
- - + +
+

+ Appearance +

+ +
+
+ + +
+ +
+ {#if settingsState.settings.custom_background_path} + Background Preview + {:else} +
+
Default Gradient
+ {/if} +
+ + +
+ + + {#if settingsState.settings.custom_background_path} + + {/if} +
+
+

+ Select an image from your computer to replace the default gradient background. + Supported formats: PNG, JPG, WEBP, GIF. +

+
+ + +
+
+
+

Visual Effects

+

Enable particle effects and animated gradients. (Default: On)

+
+ +
+ + {#if settingsState.settings.enable_visual_effects} +
+
+

Theme Effect

+

Select the active visual theme.

+
+ +
+ {/if} + +
+
+

GPU Acceleration

+

Enable GPU acceleration for the interface. (Default: Off, Requires Restart)

+
+ +
+
+
+ + +
+

+ Java Environment +

+
+
+ +
+ + +
+
{#if settingsState.javaInstallations.length > 0}
-

Detected Java Installations:

+

Detected Installations

{#each settingsState.javaInstallations as java} {/each}
{/if} - -

- The command or path to the Java Runtime Environment. Click "Auto Detect" to find installed Java versions. -

+
-
-

Memory Allocation (RAM)

- +
+

+ Memory Allocation (RAM) +

- +
- +
-
-

Game Window Size

+
+

+ Game Window Size +

- +
- +
-
-

Download Settings

-
- - -

- Number of concurrent download threads (1-128). Higher values increase download speed but use more bandwidth and system resources. Default: 32 -

-
+
+

+ Network +

+
+ + +

Higher values usually mean faster downloads but use more CPU/Network.

+
-
+
diff --git a/ui/src/components/Sidebar.svelte b/ui/src/components/Sidebar.svelte index a4f4e35..7976f6a 100644 --- a/ui/src/components/Sidebar.svelte +++ b/ui/src/components/Sidebar.svelte @@ -3,64 +3,56 @@ diff --git a/ui/src/components/VersionsView.svelte b/ui/src/components/VersionsView.svelte index 1ea4878..00ac281 100644 --- a/ui/src/components/VersionsView.svelte +++ b/ui/src/components/VersionsView.svelte @@ -73,15 +73,15 @@ function getVersionBadge(type: string) { switch (type) { case "release": - return { text: "Release", class: "bg-green-600" }; + return { text: "Release", class: "bg-emerald-500/20 text-emerald-300 border-emerald-500/30" }; case "snapshot": - return { text: "Snapshot", class: "bg-yellow-600" }; + return { text: "Snapshot", class: "bg-amber-500/20 text-amber-300 border-amber-500/30" }; case "fabric": - return { text: "Fabric", class: "bg-blue-600" }; + return { text: "Fabric", class: "bg-indigo-500/20 text-indigo-300 border-indigo-500/30" }; case "forge": - return { text: "Forge", class: "bg-orange-600" }; + return { text: "Forge", class: "bg-orange-500/20 text-orange-300 border-orange-500/30" }; default: - return { text: type, class: "bg-zinc-600" }; + return { text: type, class: "bg-zinc-500/20 text-zinc-300 border-zinc-500/30" }; } } @@ -114,101 +114,92 @@ }); -
-

Versions

+
+
+

Version Manager

+
Select a version to play or modify
+
-
+
-
- +
+
- +
+ 🔍 + +
- -
- - - - + +
+ {#each ['all', 'release', 'snapshot', 'modded'] as filter} + + {/each}
- -
+ +
{#if gameState.versions.length === 0} -
Loading versions...
+
+ Fetching manifest... +
{:else if filteredVersions().length === 0} -
- {#if normalizedQuery.length > 0} - No versions found matching "{searchQuery}" - {:else} - No versions in this category - {/if} +
+ 👻 + No matching versions found
{:else} {#each filteredVersions() as version} {@const badge = getVersionBadge(version.type)} + {@const isSelected = gameState.selectedVersion === version.id} {/each} @@ -217,32 +208,29 @@
-
- - {#if gameState.selectedVersion} -
-

Selected

-

- {gameState.selectedVersion} -

-
- {/if} - - - - - -
-

💡 Tip

-

- Select a vanilla Minecraft version, then use the Mod Loader panel to - install Fabric or Forge. Installed modded versions will appear in the - list with colored badges. -

+
+ +
+
+ +

Current Selection

+ {#if gameState.selectedVersion} +

+ {gameState.selectedVersion} +

+ {:else} +

None selected

+ {/if}
+ + +
+ +
+
diff --git a/ui/src/lib/DownloadMonitor.svelte b/ui/src/lib/DownloadMonitor.svelte index 52c935c..860952c 100644 --- a/ui/src/lib/DownloadMonitor.svelte +++ b/ui/src/lib/DownloadMonitor.svelte @@ -156,7 +156,7 @@ {#if visible}

Downloads

diff --git a/ui/src/lib/GameConsole.svelte b/ui/src/lib/GameConsole.svelte index 281dc85..8d5e0ce 100644 --- a/ui/src/lib/GameConsole.svelte +++ b/ui/src/lib/GameConsole.svelte @@ -75,7 +75,7 @@ {#if visible} -
+
Logs diff --git a/ui/src/lib/effects/ConstellationEffect.ts b/ui/src/lib/effects/ConstellationEffect.ts new file mode 100644 index 0000000..2cc702e --- /dev/null +++ b/ui/src/lib/effects/ConstellationEffect.ts @@ -0,0 +1,163 @@ + +export class ConstellationEffect { + private canvas: HTMLCanvasElement; + private ctx: CanvasRenderingContext2D; + private width: number = 0; + private height: number = 0; + private particles: Particle[] = []; + private animationId: number = 0; + private mouseX: number = -1000; + private mouseY: number = -1000; + + // Configuration + private readonly particleCount = 100; + private readonly connectionDistance = 150; + private readonly particleSpeed = 0.5; + + constructor(canvas: HTMLCanvasElement) { + this.canvas = canvas; + this.ctx = canvas.getContext("2d", { alpha: true })!; + + // Bind methods + this.animate = this.animate.bind(this); + this.handleMouseMove = this.handleMouseMove.bind(this); + + // Initial setup + this.resize(window.innerWidth, window.innerHeight); + this.initParticles(); + + // Mouse interaction + window.addEventListener("mousemove", this.handleMouseMove); + + // Start animation + this.animate(); + } + + resize(width: number, height: number) { + const dpr = window.devicePixelRatio || 1; + this.width = width; + this.height = height; + + this.canvas.width = width * dpr; + this.canvas.height = height * dpr; + this.canvas.style.width = `${width}px`; + this.canvas.style.height = `${height}px`; + + this.ctx.scale(dpr, dpr); + + // Re-initialize if screen size changes significantly to maintain density + if (this.particles.length === 0) { + this.initParticles(); + } + } + + private initParticles() { + this.particles = []; + // Adjust density based on screen area + const area = this.width * this.height; + const density = Math.floor(area / 15000); // 1 particle per 15000px² + const count = Math.min(Math.max(density, 50), 200); // Clamp between 50 and 200 + + for (let i = 0; i < count; i++) { + this.particles.push(new Particle(this.width, this.height, this.particleSpeed)); + } + } + + private handleMouseMove(e: MouseEvent) { + const rect = this.canvas.getBoundingClientRect(); + this.mouseX = e.clientX - rect.left; + this.mouseY = e.clientY - rect.top; + } + + animate() { + this.ctx.clearRect(0, 0, this.width, this.height); + + // Update and draw particles + this.particles.forEach(p => { + p.update(this.width, this.height); + p.draw(this.ctx); + }); + + // Draw lines + this.drawConnections(); + + this.animationId = requestAnimationFrame(this.animate); + } + + private drawConnections() { + this.ctx.lineWidth = 1; + + for (let i = 0; i < this.particles.length; i++) { + const p1 = this.particles[i]; + + // Connect to mouse if close + const distMouse = Math.hypot(p1.x - this.mouseX, p1.y - this.mouseY); + if (distMouse < this.connectionDistance + 50) { + const alpha = 1 - (distMouse / (this.connectionDistance + 50)); + this.ctx.strokeStyle = `rgba(255, 255, 255, ${alpha * 0.4})`; // Brighter near mouse + this.ctx.beginPath(); + this.ctx.moveTo(p1.x, p1.y); + this.ctx.lineTo(this.mouseX, this.mouseY); + this.ctx.stroke(); + + // Gently attract to mouse + if (distMouse > 10) { + p1.x += (this.mouseX - p1.x) * 0.005; + p1.y += (this.mouseY - p1.y) * 0.005; + } + } + + // Connect to other particles + for (let j = i + 1; j < this.particles.length; j++) { + const p2 = this.particles[j]; + const dist = Math.hypot(p1.x - p2.x, p1.y - p2.y); + + if (dist < this.connectionDistance) { + const alpha = 1 - (dist / this.connectionDistance); + this.ctx.strokeStyle = `rgba(255, 255, 255, ${alpha * 0.15})`; + this.ctx.beginPath(); + this.ctx.moveTo(p1.x, p1.y); + this.ctx.lineTo(p2.x, p2.y); + this.ctx.stroke(); + } + } + } + } + + destroy() { + cancelAnimationFrame(this.animationId); + window.removeEventListener("mousemove", this.handleMouseMove); + } +} + +class Particle { + x: number; + y: number; + vx: number; + vy: number; + size: number; + + constructor(w: number, h: number, speed: number) { + this.x = Math.random() * w; + this.y = Math.random() * h; + this.vx = (Math.random() - 0.5) * speed; + this.vy = (Math.random() - 0.5) * speed; + this.size = Math.random() * 2 + 1; + } + + update(w: number, h: number) { + this.x += this.vx; + this.y += this.vy; + + // Bounce off walls + if (this.x < 0 || this.x > w) this.vx *= -1; + if (this.y < 0 || this.y > h) this.vy *= -1; + } + + draw(ctx: CanvasRenderingContext2D) { + ctx.fillStyle = "rgba(255, 255, 255, 0.4)"; + ctx.beginPath(); + ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2); + ctx.fill(); + } +} diff --git a/ui/src/lib/effects/SaturnEffect.ts b/ui/src/lib/effects/SaturnEffect.ts new file mode 100644 index 0000000..8a1c11f --- /dev/null +++ b/ui/src/lib/effects/SaturnEffect.ts @@ -0,0 +1,194 @@ +// Optimized Saturn Effect for low-end hardware +// Uses TypedArrays for memory efficiency and reduced particle density + +export class SaturnEffect { + private canvas: HTMLCanvasElement; + private ctx: CanvasRenderingContext2D; + private width: number = 0; + private height: number = 0; + + // Data-oriented design for performance + // xyz: Float32Array where [i*3, i*3+1, i*3+2] corresponds to x, y, z + private xyz: Float32Array | null = null; + // types: Uint8Array where 0 = planet, 1 = ring + private types: Uint8Array | null = null; + private count: number = 0; + + private animationId: number = 0; + private angle: number = 0; + private scaleFactor: number = 1; + + constructor(canvas: HTMLCanvasElement) { + this.canvas = canvas; + this.ctx = canvas.getContext('2d', { + alpha: true, + desynchronized: false // default is usually fine, 'desynchronized' can help latency but might flicker + })!; + + // Initial resize will set up everything + this.resize(window.innerWidth, window.innerHeight); + this.initParticles(); + + this.animate = this.animate.bind(this); + this.animate(); + } + + resize(width: number, height: number) { + const dpr = window.devicePixelRatio || 1; + this.width = width; + this.height = height; + + this.canvas.width = width * dpr; + this.canvas.height = height * dpr; + this.canvas.style.width = `${width}px`; + this.canvas.style.height = `${height}px`; + + this.ctx.scale(dpr, dpr); + + // Dynamic scaling based on screen size + const minDim = Math.min(width, height); + this.scaleFactor = minDim * 0.45; + } + + initParticles() { + // Significantly reduced particle count for CPU optimization + // Planet: 1800 -> 1000 + // Rings: 5000 -> 2500 + // Total approx 3500 vs 6800 previously (approx 50% reduction) + const planetCount = 1000; + const ringCount = 2500; + this.count = planetCount + ringCount; + + // Use TypedArrays for better memory locality + this.xyz = new Float32Array(this.count * 3); + this.types = new Uint8Array(this.count); + + let idx = 0; + + // 1. Planet + for (let i = 0; i < planetCount; i++) { + const theta = Math.random() * Math.PI * 2; + const phi = Math.acos((Math.random() * 2) - 1); + const r = 1.0; + + // x, y, z + this.xyz[idx * 3] = r * Math.sin(phi) * Math.cos(theta); + this.xyz[idx * 3 + 1] = r * Math.sin(phi) * Math.sin(theta); + this.xyz[idx * 3 + 2] = r * Math.cos(phi); + + this.types[idx] = 0; // 0 for planet + idx++; + } + + // 2. Rings + const ringInner = 1.4; + const ringOuter = 2.3; + + for (let i = 0; i < ringCount; i++) { + const angle = Math.random() * Math.PI * 2; + const dist = Math.sqrt(Math.random() * (ringOuter*ringOuter - ringInner*ringInner) + ringInner*ringInner); + + // x, y, z + this.xyz[idx * 3] = dist * Math.cos(angle); + this.xyz[idx * 3 + 1] = (Math.random() - 0.5) * 0.05; + this.xyz[idx * 3 + 2] = dist * Math.sin(angle); + + this.types[idx] = 1; // 1 for ring + idx++; + } + } + + animate() { + this.ctx.clearRect(0, 0, this.width, this.height); + + // Normal blending + this.ctx.globalCompositeOperation = 'source-over'; + + // Slower rotation (from 0.0015 to 0.0005) + this.angle += 0.0005; + + const cx = this.width * 0.6; + const cy = this.height * 0.5; + + // Pre-calculate rotation matrices + const rotationY = this.angle; + const rotationX = 0.4; + const rotationZ = 0.15; + + const sinY = Math.sin(rotationY); + const cosY = Math.cos(rotationY); + const sinX = Math.sin(rotationX); + const cosX = Math.cos(rotationX); + const sinZ = Math.sin(rotationZ); + const cosZ = Math.cos(rotationZ); + + const fov = 1500; + const scaleFactor = this.scaleFactor; + + if (!this.xyz || !this.types) return; + + for (let i = 0; i < this.count; i++) { + const x = this.xyz[i * 3]; + const y = this.xyz[i * 3 + 1]; + const z = this.xyz[i * 3 + 2]; + + // Apply Scale + const px = x * scaleFactor; + const py = y * scaleFactor; + const pz = z * scaleFactor; + + // 1. Rotate Y + const x1 = px * cosY - pz * sinY; + const z1 = pz * cosY + px * sinY; + // y1 = py + + // 2. Rotate X + const y2 = py * cosX - z1 * sinX; + const z2 = z1 * cosX + py * sinX; + // x2 = x1 + + // 3. Rotate Z + const x3 = x1 * cosZ - y2 * sinZ; + const y3 = y2 * cosZ + x1 * sinZ; + const z3 = z2; + + const scale = fov / (fov + z3); + + if (z3 > -fov) { + const x2d = cx + x3 * scale; + const y2d = cy + y3 * scale; + + // Size calculation - slightly larger dots to compensate for lower count + // Previously Planet 2.0 -> 2.4, Ring 1.3 -> 1.5 + const type = this.types[i]; + const sizeBase = type === 0 ? 2.4 : 1.5; + const size = sizeBase * scale; + + // Opacity + let alpha = (scale * scale * scale); + if (alpha > 1) alpha = 1; + if (alpha < 0.15) continue; // Skip very faint particles for performance + + // Optimization: Planet color vs Ring color + if (type === 0) { + // Planet: Warn White + this.ctx.fillStyle = `rgba(255, 240, 220, ${alpha})`; + } else { + // Ring: Cool White + this.ctx.fillStyle = `rgba(220, 240, 255, ${alpha})`; + } + + // Render as squares (fillRect) instead of circles (arc) + // This is significantly faster for software rendering and reduces GPU usage. + this.ctx.fillRect(x2d, y2d, size, size); + } + } + + this.animationId = requestAnimationFrame(this.animate); + } + + destroy() { + cancelAnimationFrame(this.animationId); + } +} + diff --git a/ui/src/stores/settings.svelte.ts b/ui/src/stores/settings.svelte.ts index 397b9a6..c59bf3c 100644 --- a/ui/src/stores/settings.svelte.ts +++ b/ui/src/stores/settings.svelte.ts @@ -10,6 +10,9 @@ export class SettingsState { width: 854, height: 480, download_threads: 32, + enable_gpu_acceleration: false, + enable_visual_effects: true, + active_effect: "constellation", }); javaInstallations = $state([]); isDetectingJava = $state(false); diff --git a/ui/src/types/index.ts b/ui/src/types/index.ts index 933aab5..fa48075 100644 --- a/ui/src/types/index.ts +++ b/ui/src/types/index.ts @@ -30,6 +30,10 @@ export interface LauncherConfig { width: number; height: number; download_threads: number; + custom_background_path?: string; + enable_gpu_acceleration: boolean; + enable_visual_effects: boolean; + active_effect: string; } export interface JavaInstallation { -- cgit v1.2.3-70-g09d2 From 74849ad2d18586736d9677dfd10af4875f4ef2ca Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Wed, 14 Jan 2026 18:40:01 +0800 Subject: feat: enhance dark mode support across UI components - Updated BottomBar, HomeView, LoginModal, ModLoaderSelector, SettingsView, Sidebar, StatusToast, and VersionsView components for improved dark mode styling. - Adjusted color schemes for various elements to ensure better visibility and aesthetics in dark mode. - Added a theme property to settings to enforce dark mode as the default. - Refactored version badges in VersionsView for better color differentiation. - Enhanced button and input styles for consistency in both light and dark themes. --- assets/image.jpg | Bin 172906 -> 161028 bytes src-tauri/src/core/config.rs | 2 + src-tauri/src/main.rs | 4 -- src-tauri/tauri.conf.json | 4 +- ui/src/App.svelte | 39 +++++++++++++------ ui/src/components/BottomBar.svelte | 20 +++++----- ui/src/components/HomeView.svelte | 10 ++--- ui/src/components/LoginModal.svelte | 30 +++++++-------- ui/src/components/ModLoaderSelector.svelte | 40 +++++++++---------- ui/src/components/SettingsView.svelte | 60 ++++++++++++++++++++--------- ui/src/components/Sidebar.svelte | 8 ++-- ui/src/components/StatusToast.svelte | 10 ++--- ui/src/components/VersionsView.svelte | 48 +++++++++++------------ ui/src/stores/settings.svelte.ts | 6 +++ ui/src/types/index.ts | 1 + 15 files changed, 163 insertions(+), 119 deletions(-) (limited to 'ui/src/components/VersionsView.svelte') diff --git a/assets/image.jpg b/assets/image.jpg index 28cffe1..ddda96f 100644 Binary files a/assets/image.jpg and b/assets/image.jpg differ diff --git a/src-tauri/src/core/config.rs b/src-tauri/src/core/config.rs index 27e0011..510b126 100644 --- a/src-tauri/src/core/config.rs +++ b/src-tauri/src/core/config.rs @@ -17,6 +17,7 @@ pub struct LauncherConfig { pub enable_gpu_acceleration: bool, pub enable_visual_effects: bool, pub active_effect: String, + pub theme: String, } impl Default for LauncherConfig { @@ -32,6 +33,7 @@ impl Default for LauncherConfig { enable_gpu_acceleration: false, enable_visual_effects: true, active_effect: "constellation".to_string(), + theme: "dark".to_string(), } } } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index f7a391a..8a955a5 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -854,8 +854,6 @@ async fn get_recommended_java( Ok(core::java::get_recommended_java(required_major_version)) } -// ==================== Fabric Loader Commands ==================== - /// Get Minecraft versions supported by Fabric #[tauri::command] async fn get_fabric_game_versions() -> Result, String> { @@ -949,8 +947,6 @@ async fn is_fabric_installed( )) } -// ==================== Forge Loader Commands ==================== - /// Get Minecraft versions supported by Forge #[tauri::command] async fn get_forge_game_versions() -> Result, String> { diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 9145e1b..682acb0 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -14,8 +14,8 @@ "title": "Minecraft DropOut Launcher", "width": 1024, "height": 768, - "minWidth": 800, - "minHeight": 600, + "minWidth": 905, + "minHeight": 575, "resizable": true } ], diff --git a/ui/src/App.svelte b/ui/src/App.svelte index d93374e..2160b85 100644 --- a/ui/src/App.svelte +++ b/ui/src/App.svelte @@ -31,12 +31,22 @@ onMount(async () => { authState.checkAccount(); - settingsState.loadSettings(); + await settingsState.loadSettings(); gameState.loadVersions(); getVersion().then((v) => (uiState.appVersion = v)); window.addEventListener("mousemove", handleMouseMove); }); + $effect(() => { + if (settingsState.settings.theme === 'light') { + document.documentElement.classList.remove('dark'); + document.documentElement.setAttribute('data-theme', 'light'); + } else { + document.documentElement.classList.add('dark'); + document.documentElement.setAttribute('data-theme', 'dark'); + } + }); + onDestroy(() => { if (typeof window !== 'undefined') window.removeEventListener("mousemove", handleMouseMove); @@ -44,10 +54,10 @@
-
+
{#if settingsState.settings.custom_background_path}
{:else if settingsState.settings.enable_visual_effects} - -
+ + {#if settingsState.settings.theme === 'dark'} +
+ {:else} + +
+ {/if} {#if uiState.currentView === "home"} {/if}
{/if} -
+
-
+
diff --git a/ui/src/components/BottomBar.svelte b/ui/src/components/BottomBar.svelte index dd218f3..0178111 100644 --- a/ui/src/components/BottomBar.svelte +++ b/ui/src/components/BottomBar.svelte @@ -5,7 +5,7 @@
@@ -17,7 +17,7 @@ onkeydown={(e) => e.key === "Enter" && authState.openLoginModal()} >
{#if authState.currentAccount}
-
+
{authState.currentAccount ? authState.currentAccount.username : "Login"}
-
+
{authState.currentAccount ? "Ready to play" : "Guest Mode"}
-
+
@@ -28,7 +28,7 @@
@@ -61,12 +61,12 @@ type="text" bind:value={authState.offlineUsername} placeholder="Offline Username" - class="w-full bg-zinc-950 border border-zinc-700 rounded p-3 text-white focus:border-indigo-500 outline-none" + class="w-full bg-gray-50 border-zinc-200 dark:bg-zinc-950 dark:border-zinc-700 rounded p-3 text-gray-900 dark:text-white focus:border-indigo-500 outline-none" onkeydown={(e) => e.key === "Enter" && authState.performOfflineLogin()} /> @@ -80,18 +80,18 @@
{:else if authState.deviceCodeData}
-

1. Go to this URL:

+

1. Go to this URL:

-

2. Enter this code:

+

2. Enter this code:

e.key === 'Enter' && navigator.clipboard.writeText(authState.deviceCodeData?.user_code || "")} @@ -106,8 +106,8 @@
-
- {authState.msLoginStatus} +
+ {authState.msLoginStatus}

This window will update automatically.

diff --git a/ui/src/components/ModLoaderSelector.svelte b/ui/src/components/ModLoaderSelector.svelte index 4a59916..fd26382 100644 --- a/ui/src/components/ModLoaderSelector.svelte +++ b/ui/src/components/ModLoaderSelector.svelte @@ -114,16 +114,16 @@
-

Select Mod Loader

+

Select Mod Loader

-
+
@@ -81,39 +81,39 @@ {/if}
-

+

Select an image from your computer to replace the default gradient background. Supported formats: PNG, JPG, WEBP, GIF.

-
+
-

Visual Effects

-

Enable particle effects and animated gradients. (Default: On)

+

Visual Effects

+

Enable particle effects and animated gradients. (Default: On)

{#if settingsState.settings.enable_visual_effects} -
+
-

Theme Effect

-

Select the active visual theme.

+

Theme Effect

+

Select the active visual theme.

-
+
{#each ['all', 'release', 'snapshot', 'modded'] as filter} diff --git a/ui/src/components/VersionsView.svelte b/ui/src/components/VersionsView.svelte index 8f3a568..99cc296 100644 --- a/ui/src/components/VersionsView.svelte +++ b/ui/src/components/VersionsView.svelte @@ -158,7 +158,7 @@ Fetching manifest...
{:else if filteredVersions().length === 0} -
+
👻 No matching versions found
diff --git a/ui/src/lib/effects/SaturnEffect.ts b/ui/src/lib/effects/SaturnEffect.ts index 8a1c11f..a370936 100644 --- a/ui/src/lib/effects/SaturnEffect.ts +++ b/ui/src/lib/effects/SaturnEffect.ts @@ -171,7 +171,7 @@ export class SaturnEffect { // Optimization: Planet color vs Ring color if (type === 0) { - // Planet: Warn White + // Planet: Warm White this.ctx.fillStyle = `rgba(255, 240, 220, ${alpha})`; } else { // Ring: Cool White -- cgit v1.2.3-70-g09d2