This commit is contained in:
2026-04-03 14:44:13 +02:00
parent 3c6c6ae749
commit 1fe9197b9b
19 changed files with 2351 additions and 246 deletions
+654 -69
View File
File diff suppressed because it is too large Load Diff
+10 -4
View File
@@ -10,17 +10,23 @@
"tauri": "tauri" "tauri": "tauri"
}, },
"dependencies": { "dependencies": {
"@tailwindcss/vite": "^4.2.2",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2",
"clsx": "^2.1.1",
"framer-motion": "^12.38.0",
"lucide-react": "^1.7.0",
"react": "^19.1.0", "react": "^19.1.0",
"react-dom": "^19.1.0", "react-dom": "^19.1.0",
"@tauri-apps/api": "^2", "tailwind-merge": "^3.5.0",
"@tauri-apps/plugin-opener": "^2" "tailwindcss": "^4.2.2"
}, },
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": "^2",
"@types/react": "^19.1.8", "@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6", "@types/react-dom": "^19.1.6",
"@vitejs/plugin-react": "^4.6.0", "@vitejs/plugin-react": "^4.6.0",
"typescript": "~5.8.3", "typescript": "~5.8.3",
"vite": "^7.0.4", "vite": "^7.0.4"
"@tauri-apps/cli": "^2"
} }
} }
-116
View File
@@ -1,116 +0,0 @@
.logo.vite:hover {
filter: drop-shadow(0 0 2em #747bff);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafb);
}
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;
color: #0f0f0f;
background-color: #f6f6f6;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
.container {
margin: 0;
padding-top: 10vh;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: 0.75s;
}
.logo.tauri:hover {
filter: drop-shadow(0 0 2em #24c8db);
}
.row {
display: flex;
justify-content: center;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
h1 {
text-align: center;
}
input,
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
color: #0f0f0f;
background-color: #ffffff;
transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}
button {
cursor: pointer;
}
button:hover {
border-color: #396cd8;
}
button:active {
border-color: #396cd8;
background-color: #e8e8e8;
}
input,
button {
outline: none;
}
#greet-input {
margin-right: 5px;
}
@media (prefers-color-scheme: dark) {
:root {
color: #f6f6f6;
background-color: #2f2f2f;
}
a:hover {
color: #24c8db;
}
input,
button {
color: #ffffff;
background-color: #0f0f0f98;
}
button:active {
background-color: #0f0f0f69;
}
}
+141 -41
View File
@@ -1,51 +1,151 @@
import { useState } from "react"; import React, { useState, useEffect } from 'react'
import reactLogo from "./assets/react.svg"; import { Play, Puzzle, Settings, ChevronDown, User, LogOut, Check } from 'lucide-react'
import { invoke } from "@tauri-apps/api/core"; import { launcherService, type GameVersion } from './services/LauncherService'
import "./App.css"; import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'
function App() { // Utility for merging tailwind classes
const [greetMsg, setGreetMsg] = useState(""); function cn(...inputs: ClassValue[]) {
const [name, setName] = useState(""); return twMerge(clsx(inputs))
async function greet() {
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
setGreetMsg(await invoke("greet", { name }));
} }
// Components
import PlaySection from './components/PlaySection'
import ModsSection from './components/ModsSection'
import SettingsSection from './components/SettingsSection'
type Section = 'play' | 'mods' | 'settings'
const App: React.FC = () => {
const [activeSection, setActiveSection] = useState<Section>('play')
const [versions, setVersions] = useState<GameVersion[]>([])
const [selectedVersion, setSelectedVersion] = useState<GameVersion | null>(null)
const [isVersionDropdownOpen, setIsVersionDropdownOpen] = useState(false)
const [isAccountDropdownOpen, setIsAccountDropdownOpen] = useState(false)
useEffect(() => {
const fetchVersions = async () => {
const v = await launcherService.getVersions()
setVersions(v)
if (v.length > 0) setSelectedVersion(v[0])
}
fetchVersions()
}, [])
return ( return (
<main className="container"> <div className="flex h-screen w-screen bg-saturn-bg text-saturn-text-primary overflow-hidden font-sans">
<h1>Welcome to Tauri + React</h1> {/* Sidebar */}
<aside className="w-16 border-r border-saturn-border flex flex-col items-center py-6 gap-6 bg-saturn-panel/50">
<div className="row"> <div className="mb-4">
<a href="https://vite.dev" target="_blank"> <div className="w-10 h-10 bg-saturn-accent rounded-xl flex items-center justify-center shadow-[0_0_20px_rgba(59,130,246,0.4)]">
<img src="/vite.svg" className="logo vite" alt="Vite logo" /> <span className="font-bold text-white text-xl">S</span>
</a> </div>
<a href="https://tauri.app" target="_blank">
<img src="/tauri.svg" className="logo tauri" alt="Tauri logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div> </div>
<p>Click on the Tauri, Vite, and React logos to learn more.</p>
<form <nav className="flex flex-col gap-4">
className="row" <button
onSubmit={(e) => { onClick={() => setActiveSection('play')}
e.preventDefault(); className={cn("sidebar-icon", activeSection === 'play' && "active")}
greet(); title="Play"
}}
> >
<input <Play size={22} fill={activeSection === 'play' ? "currentColor" : "none"} />
id="greet-input" </button>
onChange={(e) => setName(e.currentTarget.value)}
placeholder="Enter a name..." <button
/> onClick={() => setActiveSection('mods')}
<button type="submit">Greet</button> className={cn("sidebar-icon", activeSection === 'mods' && "active")}
</form> title="Mods"
<p>{greetMsg}</p> >
<Puzzle size={22} fill={activeSection === 'mods' ? "currentColor" : "none"} />
</button>
<button
onClick={() => setActiveSection('settings')}
className={cn("sidebar-icon", activeSection === 'settings' && "active")}
title="Settings"
>
<Settings size={22} fill={activeSection === 'settings' ? "currentColor" : "none"} />
</button>
</nav>
</aside>
{/* Main Content Area */}
<main className="flex-1 flex flex-col min-w-0">
{/* Top Bar */}
<header className="h-14 border-b border-saturn-border flex items-center justify-between px-6 bg-saturn-panel/30 backdrop-blur-md">
{/* Version Selector */}
<div className="relative">
<button
onClick={() => setIsVersionDropdownOpen(!isVersionDropdownOpen)}
className="flex items-center gap-2 px-3 py-1.5 rounded-md hover:bg-white/5 transition-colors text-sm font-medium border border-transparent hover:border-saturn-border"
>
<span className="text-saturn-text-secondary">Version:</span>
<span>{selectedVersion?.name || 'Loading...'}</span>
<ChevronDown size={14} className={cn("transition-transform", isVersionDropdownOpen && "rotate-180")} />
</button>
{isVersionDropdownOpen && (
<div className="absolute top-full left-0 mt-2 w-48 bg-saturn-panel border border-saturn-border rounded-lg shadow-2xl z-50 py-1 overflow-hidden">
{versions.map(v => (
<button
key={v.id}
onClick={() => {
setSelectedVersion(v)
setIsVersionDropdownOpen(false)
}}
className="w-full flex items-center justify-between px-4 py-2 text-sm hover:bg-saturn-accent/10 hover:text-saturn-accent transition-colors"
>
<span>{v.name}</span>
{selectedVersion?.id === v.id && <Check size={14} />}
</button>
))}
</div>
)}
</div>
{/* Account Display */}
<div className="relative">
<button
onClick={() => setIsAccountDropdownOpen(!isAccountDropdownOpen)}
className="flex items-center gap-3 px-2 py-1 rounded-full hover:bg-white/5 transition-colors border border-transparent hover:border-saturn-border"
>
<div className="text-right hidden sm:block">
<p className="text-xs font-bold leading-none">SaturnDev</p>
<p className="text-[10px] text-saturn-text-secondary leading-none mt-1">Microsoft Account</p>
</div>
<div className="w-8 h-8 rounded-md bg-zinc-800 border border-saturn-border overflow-hidden flex items-center justify-center">
<User size={18} className="text-saturn-text-secondary" />
</div>
</button>
{isAccountDropdownOpen && (
<div className="absolute top-full right-0 mt-2 w-48 bg-saturn-panel border border-saturn-border rounded-lg shadow-2xl z-50 py-1 overflow-hidden">
<div className="px-4 py-3 border-b border-saturn-border">
<p className="text-sm font-bold">SaturnDev</p>
<p className="text-xs text-saturn-text-secondary truncate">dev@saturnclient.com</p>
</div>
<button className="w-full flex items-center gap-2 px-4 py-2 text-sm hover:bg-white/5 transition-colors">
<User size={14} />
<span>Switch Account</span>
</button>
<button className="w-full flex items-center gap-2 px-4 py-2 text-sm hover:bg-red-500/10 text-red-400 transition-colors">
<LogOut size={14} />
<span>Logout</span>
</button>
</div>
)}
</div>
</header>
{/* Content Sections */}
<div className="flex-1 overflow-y-auto overflow-x-hidden p-8">
{activeSection === 'play' && selectedVersion && <PlaySection version={selectedVersion} />}
{activeSection === 'mods' && selectedVersion && <ModsSection version={selectedVersion} />}
{activeSection === 'settings' && <SettingsSection />}
</div>
</main> </main>
); </div>
)
} }
export default App; export default App
-1
View File
@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

Before

Width:  |  Height:  |  Size: 4.0 KiB

+236
View File
@@ -0,0 +1,236 @@
import React, { useState, useEffect } from 'react'
import { Search, Download, Trash2, ExternalLink, Package, Filter, CheckCircle2, XCircle, ChevronRight, X } from 'lucide-react'
import { launcherService, type Mod, type GameVersion } from '../services/LauncherService'
import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'
import { motion, AnimatePresence } from 'framer-motion'
function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
interface ModsSectionProps {
version: GameVersion
}
const ModsSection: React.FC<ModsSectionProps> = ({ version }) => {
const [activeTab, setActiveTab] = useState<'installed' | 'discover'>('installed')
const [searchQuery, setSearchQuery] = useState('')
const [mods, setMods] = useState<Mod[]>([])
const [isInstallDialogOpen, setIsInstallDialogOpen] = useState(false)
const [selectedModForInstall, setSelectedModForInstall] = useState<Mod | null>(null)
const [selectedVersionsForInstall, setSelectedVersionsForInstall] = useState<string[]>([])
const [allVersions, setAllVersions] = useState<GameVersion[]>([])
useEffect(() => {
const loadMods = async () => {
if (activeTab === 'installed') {
const m = await launcherService.getInstalledMods(version.id)
setMods(m)
} else {
const m = await launcherService.discoverMods(searchQuery)
setMods(m)
}
}
loadMods()
}, [activeTab, version.id, searchQuery])
useEffect(() => {
const loadAllVersions = async () => {
const v = await launcherService.getVersions()
setAllVersions(v)
}
loadAllVersions()
}, [])
const handleToggleMod = async (modId: string) => {
await launcherService.toggleMod(modId)
const m = await launcherService.getInstalledMods(version.id)
setMods(m)
}
const openInstallDialog = (mod: Mod) => {
setSelectedModForInstall(mod)
setSelectedVersionsForInstall([version.id])
setIsInstallDialogOpen(true)
}
const handleInstall = async () => {
if (selectedModForInstall && selectedVersionsForInstall.length > 0) {
await launcherService.installMod(selectedModForInstall, selectedVersionsForInstall)
setIsInstallDialogOpen(false)
if (activeTab === 'installed') {
const m = await launcherService.getInstalledMods(version.id)
setMods(m)
}
}
}
const toggleVersionSelection = (versionId: string) => {
setSelectedVersionsForInstall(prev =>
prev.includes(versionId)
? prev.filter(v => v !== versionId)
: [...prev, versionId]
)
}
return (
<div className="max-w-6xl mx-auto h-full flex flex-col gap-6">
<div className="flex items-center justify-between">
<div className="flex items-center gap-1 p-1 bg-saturn-panel border border-saturn-border rounded-lg">
<button
onClick={() => setActiveTab('installed')}
className={cn("px-4 py-1.5 text-sm font-medium rounded-md transition-all", activeTab === 'installed' ? "bg-white/5 text-white" : "text-saturn-text-secondary hover:text-white")}
>
Installed Mods
</button>
<button
onClick={() => setActiveTab('discover')}
className={cn("px-4 py-1.5 text-sm font-medium rounded-md transition-all", activeTab === 'discover' ? "bg-white/5 text-white" : "text-saturn-text-secondary hover:text-white")}
>
Discover
</button>
</div>
<div className="relative group">
<Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-saturn-text-secondary group-focus-within:text-saturn-accent transition-colors" />
<input
type="text"
placeholder={activeTab === 'installed' ? "Search installed mods..." : "Search CurseForge/Modrinth..."}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="bg-saturn-panel border border-saturn-border rounded-lg pl-10 pr-4 py-2 text-sm w-64 focus:outline-none focus:border-saturn-accent/50 focus:ring-1 focus:ring-saturn-accent/50 transition-all"
/>
</div>
</div>
<div className="flex-1 overflow-y-auto pr-2">
<div className="grid grid-cols-1 gap-3">
{mods.map(mod => (
<motion.div
layout
key={mod.id}
initial={{ opacity: 0, x: -10 }}
animate={{ opacity: 1, x: 0 }}
className="panel p-4 flex items-center gap-4 hover:border-white/10 transition-colors"
>
<div className="w-12 h-12 rounded-lg bg-zinc-800 border border-saturn-border flex items-center justify-center shrink-0">
<Package size={24} className="text-saturn-text-secondary" />
</div>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2">
<h3 className="font-bold text-sm truncate">{mod.name}</h3>
<span className="text-[10px] text-saturn-text-secondary font-medium px-1.5 py-0.5 rounded bg-white/5">v{mod.version}</span>
<span className="text-[10px] text-saturn-text-secondary">by {mod.author}</span>
</div>
<p className="text-xs text-saturn-text-secondary mt-1 truncate max-w-xl">{mod.description}</p>
</div>
<div className="flex items-center gap-3">
{activeTab === 'installed' ? (
<>
<button
onClick={() => handleToggleMod(mod.id)}
className={cn("flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium transition-all", mod.enabled ? "bg-green-500/10 text-green-400 border border-green-500/20" : "bg-red-500/10 text-red-400 border border-red-500/20")}
>
{mod.enabled ? <CheckCircle2 size={14} /> : <XCircle size={14} />}
{mod.enabled ? 'Enabled' : 'Disabled'}
</button>
<button className="p-2 text-saturn-text-secondary hover:text-red-400 transition-colors">
<Trash2 size={16} />
</button>
</>
) : (
<button
onClick={() => openInstallDialog(mod)}
className="flex items-center gap-2 px-4 py-1.5 bg-saturn-accent/10 text-saturn-accent hover:bg-saturn-accent hover:text-white rounded-md text-xs font-bold transition-all border border-saturn-accent/20"
>
<Download size={14} />
INSTALL
</button>
)}
</div>
</motion.div>
))}
{mods.length === 0 && (
<div className="h-64 flex flex-col items-center justify-center text-saturn-text-secondary opacity-50">
<Package size={48} className="mb-4" strokeWidth={1} />
<p>No mods found.</p>
</div>
)}
</div>
</div>
{/* Install Dialog */}
<AnimatePresence>
{isInstallDialogOpen && selectedModForInstall && (
<div className="fixed inset-0 bg-black/80 backdrop-blur-sm z-[100] flex items-center justify-center p-6">
<motion.div
initial={{ scale: 0.9, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.9, opacity: 0 }}
className="bg-saturn-panel border border-saturn-border rounded-xl w-full max-w-md shadow-2xl overflow-hidden"
>
<div className="p-6 border-b border-saturn-border flex items-center justify-between">
<div>
<h2 className="text-lg font-bold">Install {selectedModForInstall.name}</h2>
<p className="text-xs text-saturn-text-secondary">Select versions to install this mod to.</p>
</div>
<button onClick={() => setIsInstallDialogOpen(false)} className="text-saturn-text-secondary hover:text-white">
<X size={20} />
</button>
</div>
<div className="p-6 space-y-3 max-h-64 overflow-y-auto">
{allVersions.map(v => {
const isSupported = selectedModForInstall.supportedVersions.includes(v.id)
const isSelected = selectedVersionsForInstall.includes(v.id)
return (
<div
key={v.id}
onClick={() => isSupported && toggleVersionSelection(v.id)}
className={cn(
"flex items-center justify-between p-3 rounded-lg border transition-all cursor-pointer",
isSelected ? "bg-saturn-accent/10 border-saturn-accent/50" : "bg-white/5 border-transparent hover:border-white/10",
!isSupported && "opacity-40 cursor-not-allowed grayscale"
)}
>
<div className="flex items-center gap-3">
<div className={cn("w-5 h-5 rounded border flex items-center justify-center transition-all", isSelected ? "bg-saturn-accent border-saturn-accent" : "border-saturn-border")}>
{isSelected && <CheckCircle2 size={14} className="text-white" />}
</div>
<span className="text-sm font-medium">{v.name}</span>
</div>
{!isSupported && <span className="text-[10px] text-red-400 font-bold uppercase">Unsupported</span>}
</div>
)
})}
</div>
<div className="p-6 bg-white/5 flex gap-3">
<button
onClick={() => setIsInstallDialogOpen(false)}
className="flex-1 py-2 text-sm font-medium hover:bg-white/5 rounded-lg transition-colors"
>
Cancel
</button>
<button
onClick={handleInstall}
disabled={selectedVersionsForInstall.length === 0}
className="flex-1 py-2 text-sm font-bold bg-saturn-accent hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-all shadow-lg shadow-saturn-accent/20"
>
Confirm Install
</button>
</div>
</motion.div>
</div>
)}
</AnimatePresence>
</div>
)
}
export default ModsSection
+110
View File
@@ -0,0 +1,110 @@
import React, { useState } from 'react'
import { Play, Loader2, Info, ExternalLink } from 'lucide-react'
import { launcherService, type GameVersion } from '../services/LauncherService'
import { motion } from 'framer-motion'
interface PlaySectionProps {
version: GameVersion
}
const PlaySection: React.FC<PlaySectionProps> = ({ version }) => {
const [isLaunching, setIsLaunching] = useState(false)
const [launchStatus, setLaunchStatus] = useState('')
const handleLaunch = async () => {
setIsLaunching(true)
setLaunchStatus('Preparing...')
// Simulate launch steps
setTimeout(() => setLaunchStatus('Verifying assets...'), 500)
setTimeout(() => setLaunchStatus('Applying Saturn optimizations...'), 1200)
const result = await launcherService.launchGame(version.id)
if (result.success) {
setLaunchStatus('Game running')
// In a real app, we might minimize or close the launcher here
}
setTimeout(() => {
setIsLaunching(false)
setLaunchStatus('')
}, 3000)
}
return (
<div className="h-full flex flex-col items-center justify-center max-w-4xl mx-auto text-center">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="mb-12"
>
<h1 className="text-6xl font-black tracking-tighter mb-2 bg-gradient-to-b from-white to-white/40 bg-clip-text text-transparent">
SATURN
</h1>
<p className="text-saturn-text-secondary text-lg tracking-widest font-light uppercase">
Fabric-Only Optimization Client
</p>
</motion.div>
<div className="w-full grid grid-cols-1 md:grid-cols-3 gap-6 mb-12">
<div className="panel p-6 flex flex-col items-center gap-3">
<div className="w-10 h-10 rounded-full bg-white/5 flex items-center justify-center text-saturn-accent">
<Info size={20} />
</div>
<div>
<p className="text-xs text-saturn-text-secondary uppercase tracking-wider font-bold">Instance</p>
<p className="text-sm font-medium">Saturn Default</p>
</div>
</div>
<div className="panel p-6 flex flex-col items-center gap-3 border-saturn-accent/30 bg-saturn-accent/5">
<div className="w-10 h-10 rounded-full bg-saturn-accent/20 flex items-center justify-center text-saturn-accent">
<Play size={20} fill="currentColor" />
</div>
<div>
<p className="text-xs text-saturn-text-secondary uppercase tracking-wider font-bold">Current Version</p>
<p className="text-sm font-medium">{version.name}</p>
</div>
</div>
<div className="panel p-6 flex flex-col items-center gap-3">
<div className="w-10 h-10 rounded-full bg-white/5 flex items-center justify-center text-saturn-accent">
<ExternalLink size={20} />
</div>
<div>
<p className="text-xs text-saturn-text-secondary uppercase tracking-wider font-bold">Modloader</p>
<p className="text-sm font-medium">Fabric Loader</p>
</div>
</div>
</div>
<div className="relative group">
<div className="absolute -inset-1 bg-gradient-to-r from-blue-600 to-cyan-500 rounded-lg blur opacity-25 group-hover:opacity-50 transition duration-1000 group-hover:duration-200"></div>
<button
onClick={handleLaunch}
disabled={isLaunching}
className="relative btn-primary px-16 py-4 text-xl flex items-center gap-3 min-w-[240px] justify-center"
>
{isLaunching ? (
<>
<Loader2 size={24} className="animate-spin" />
<span>{launchStatus}</span>
</>
) : (
<>
<Play size={24} fill="currentColor" />
<span>PLAY</span>
</>
)}
</button>
</div>
<div className="mt-12 text-saturn-text-secondary text-xs max-w-md">
<p>Saturn Client is not affiliated with Mojang AB. Use at your own risk. Performance may vary based on hardware.</p>
</div>
</div>
)
}
export default PlaySection
+156
View File
@@ -0,0 +1,156 @@
import React, { useState, useEffect } from 'react'
import { Cpu, MemoryStick, Save, RefreshCcw, Info, AlertTriangle } from 'lucide-react'
import { launcherService, type LauncherSettings } from '../services/LauncherService'
import { motion } from 'framer-motion'
const SettingsSection: React.FC = () => {
const [settings, setSettings] = useState<LauncherSettings | null>(null)
const [isSaving, setIsSaving] = useState(false)
const [saveStatus, setSaveStatus] = useState('')
useEffect(() => {
const loadSettings = async () => {
const s = await launcherService.getSettings()
setSettings(s)
}
loadSettings()
}, [])
const handleSave = async () => {
if (!settings) return
setIsSaving(true)
setSaveStatus('Saving...')
await launcherService.updateSettings(settings)
setTimeout(() => {
setIsSaving(false)
setSaveStatus('Settings saved')
setTimeout(() => setSaveStatus(''), 2000)
}, 1000)
}
const handleReset = async () => {
// In a real app, this would reset to defaults in the service
const defaultSettings: LauncherSettings = {
jvmArguments: '-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200',
maxMemory: 4096,
}
setSettings(defaultSettings)
}
if (!settings) return null
return (
<div className="max-w-4xl mx-auto h-full flex flex-col gap-8">
<div className="flex items-center justify-between border-b border-saturn-border pb-6">
<div>
<h1 className="text-2xl font-bold">Performance Settings</h1>
<p className="text-sm text-saturn-text-secondary">Configure how Saturn Client interacts with your hardware.</p>
</div>
<div className="flex items-center gap-3">
<button
onClick={handleReset}
className="p-2 text-saturn-text-secondary hover:text-white transition-colors"
title="Reset to Defaults"
>
<RefreshCcw size={20} />
</button>
<button
onClick={handleSave}
disabled={isSaving}
className="btn-primary flex items-center gap-2 py-2 px-6 text-sm font-bold"
>
<Save size={16} />
{saveStatus || 'SAVE SETTINGS'}
</button>
</div>
</div>
<div className="grid grid-cols-1 gap-8">
{/* Memory Allocation */}
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
className="panel p-6 space-y-6"
>
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-lg bg-saturn-accent/10 flex items-center justify-center text-saturn-accent">
<MemoryStick size={18} />
</div>
<h2 className="text-lg font-bold">Memory Allocation</h2>
</div>
<div className="space-y-4">
<div className="flex justify-between items-center">
<span className="text-sm font-medium">Maximum Memory (RAM)</span>
<span className="text-lg font-bold text-saturn-accent">{(settings.maxMemory / 1024).toFixed(1)} GB</span>
</div>
<input
type="range"
min="1024"
max="16384"
step="512"
value={settings.maxMemory}
onChange={(e) => setSettings({ ...settings, maxMemory: parseInt(e.target.value) })}
className="w-full h-2 bg-saturn-border rounded-lg appearance-none cursor-pointer accent-saturn-accent"
/>
<div className="flex justify-between text-[10px] text-saturn-text-secondary font-bold uppercase tracking-widest">
<span>1 GB</span>
<span>4 GB</span>
<span>8 GB</span>
<span>12 GB</span>
<span>16 GB</span>
</div>
<div className="p-3 bg-blue-500/5 border border-blue-500/10 rounded-lg flex gap-3">
<Info size={16} className="text-blue-400 shrink-0 mt-0.5" />
<p className="text-xs text-blue-300/80 leading-relaxed">
Allocating too much memory can cause system instability, while too little can lead to performance issues or crashes. 4GB - 8GB is recommended for most users.
</p>
</div>
</div>
</motion.div>
{/* JVM Arguments */}
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.1 }}
className="panel p-6 space-y-6"
>
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-lg bg-saturn-accent/10 flex items-center justify-center text-saturn-accent">
<Cpu size={18} />
</div>
<h2 className="text-lg font-bold">Custom JVM Arguments</h2>
</div>
<div className="space-y-4">
<p className="text-xs text-saturn-text-secondary leading-relaxed">
Advanced flags for the Java Virtual Machine. Saturn Client includes optimized defaults, but you can override them here.
</p>
<textarea
value={settings.jvmArguments}
onChange={(e) => setSettings({ ...settings, jvmArguments: e.target.value })}
className="w-full h-32 bg-saturn-bg border border-saturn-border rounded-lg p-4 text-sm font-mono text-saturn-text-secondary focus:outline-none focus:border-saturn-accent/50 focus:ring-1 focus:ring-saturn-accent/50 transition-all resize-none"
placeholder="-XX:+UseG1GC..."
/>
<div className="p-3 bg-yellow-500/5 border border-yellow-500/10 rounded-lg flex gap-3">
<AlertTriangle size={16} className="text-yellow-500 shrink-0 mt-0.5" />
<p className="text-xs text-yellow-500/80 leading-relaxed">
Incorrect JVM arguments can prevent the game from starting. Only modify if you know what you're doing.
</p>
</div>
</div>
</motion.div>
</div>
</div>
)
}
export default SettingsSection
+55
View File
@@ -0,0 +1,55 @@
@import "tailwindcss";
@theme {
--color-saturn-bg: #0a0a0a;
--color-saturn-panel: #141414;
--color-saturn-accent: #3b82f6;
--color-saturn-accent-glow: rgba(59, 130, 246, 0.3);
--color-saturn-text-primary: #f4f4f5;
--color-saturn-text-secondary: #a1a1aa;
--color-saturn-border: #27272a;
}
@layer base {
body {
@apply bg-saturn-bg text-saturn-text-primary font-sans antialiased;
overflow: hidden;
user-select: none;
}
}
@layer components {
.btn-primary {
@apply bg-saturn-accent hover:bg-blue-600 text-white font-medium py-2 px-6 rounded-md transition-all duration-200 shadow-[0_0_15px_rgba(59,130,246,0.2)] hover:shadow-[0_0_20px_rgba(59,130,246,0.4)];
}
.sidebar-icon {
@apply w-10 h-10 flex items-center justify-center rounded-lg transition-all duration-200 text-saturn-text-secondary hover:text-white hover:bg-white/5 cursor-pointer;
}
.sidebar-icon.active {
@apply text-saturn-accent bg-saturn-accent/10;
}
.panel {
@apply bg-saturn-panel border border-saturn-border rounded-lg overflow-hidden;
}
}
/* Custom scrollbar for dense UI */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #27272a;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #3f3f46;
}
+8 -7
View File
@@ -1,9 +1,10 @@
import React from "react"; import { StrictMode } from 'react'
import ReactDOM from "react-dom/client"; import { createRoot } from 'react-dom/client'
import App from "./App"; import './index.css'
import App from './App.tsx'
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( createRoot(document.getElementById('root')!).render(
<React.StrictMode> <StrictMode>
<App /> <App />
</React.StrictMode>, </StrictMode>,
); )
+127
View File
@@ -0,0 +1,127 @@
// Saturn Client Launcher Centralized Service Layer
// Handles all data fetching, mod management, and launch logic.
export interface Mod {
id: string;
name: string;
version: string;
author: string;
description: string;
enabled: boolean;
icon?: string;
supportedVersions: string[];
}
export interface GameVersion {
id: string;
name: string;
releaseDate: string;
type: 'release' | 'snapshot';
}
export interface LauncherSettings {
jvmArguments: string;
maxMemory: number; // in MB
}
class LauncherService {
private versions: GameVersion[] = [
{ id: '1.20.1', name: 'Fabric 1.20.1', releaseDate: '2023-06-07', type: 'release' },
{ id: '1.20.4', name: 'Fabric 1.20.4', releaseDate: '2023-12-07', type: 'release' },
{ id: '1.21', name: 'Fabric 1.21', releaseDate: '2024-06-13', type: 'release' },
];
private installedMods: Mod[] = [
{
id: 'sodium',
name: 'Sodium',
version: '0.5.8',
author: 'jellysquid3',
description: 'Modern rendering engine for Minecraft.',
enabled: true,
supportedVersions: ['1.20.1', '1.20.4', '1.21']
},
{
id: 'iris',
name: 'Iris',
version: '1.7.0',
author: 'coderbot',
description: 'A modern shaders mod for Minecraft.',
enabled: true,
supportedVersions: ['1.20.1', '1.20.4', '1.21']
},
{
id: 'lithium',
name: 'Lithium',
version: '0.11.2',
author: 'jellysquid3',
description: 'General-purpose optimization mod for Minecraft.',
enabled: false,
supportedVersions: ['1.20.1', '1.20.4']
},
];
private settings: LauncherSettings = {
jvmArguments: '-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200',
maxMemory: 4096,
};
// --- Versions ---
async getVersions(): Promise<GameVersion[]> {
return [...this.versions];
}
// --- Mods ---
async getInstalledMods(versionId: string): Promise<Mod[]> {
// Filter mods by supported version
return this.installedMods.filter(mod => mod.supportedVersions.includes(versionId));
}
async toggleMod(modId: string): Promise<void> {
const mod = this.installedMods.find(m => m.id === modId);
if (mod) {
mod.enabled = !mod.enabled;
}
}
async discoverMods(query: string): Promise<Mod[]> {
// Mock discovery results
const allDiscoverable: Mod[] = [
{ id: 'modmenu', name: 'Mod Menu', version: '7.2.2', author: 'TerraformersMC', description: 'Adds a mod menu to view the list of installed mods.', enabled: false, supportedVersions: ['1.20.1', '1.20.4', '1.21'] },
{ id: 'starlight', name: 'Starlight', version: '1.1.2', author: 'Spottedleaf', description: 'Rewrites the light engine to fix performance issues.', enabled: false, supportedVersions: ['1.20.1'] },
{ id: 'ferritecore', name: 'FerriteCore', version: '6.0.1', author: 'malte0811', description: 'Memory usage optimizations.', enabled: false, supportedVersions: ['1.20.1', '1.20.4', '1.21'] },
];
if (!query) return allDiscoverable;
return allDiscoverable.filter(m => m.name.toLowerCase().includes(query.toLowerCase()));
}
async installMod(mod: Mod, versions: string[]): Promise<void> {
console.log(`Installing ${mod.name} to versions: ${versions.join(', ')}`);
// Mock install logic: add to installedMods if not already there
if (!this.installedMods.find(m => m.id === mod.id)) {
this.installedMods.push({ ...mod, enabled: true, supportedVersions: versions });
}
}
// --- Settings ---
async getSettings(): Promise<LauncherSettings> {
return { ...this.settings };
}
async updateSettings(newSettings: Partial<LauncherSettings>): Promise<void> {
this.settings = { ...this.settings, ...newSettings };
}
// --- Launch ---
async launchGame(versionId: string): Promise<{ success: boolean; message: string }> {
console.log(`Launching Saturn Client with version ${versionId}...`);
return new Promise((resolve) => {
setTimeout(() => {
resolve({ success: true, message: 'Game launched successfully!' });
}, 2000);
});
}
}
export const launcherService = new LauncherService();
+151
View File
@@ -0,0 +1,151 @@
import React, { useState, useEffect } from 'react'
import { Play, Puzzle, Settings, ChevronDown, User, LogOut, Check } from 'lucide-react'
import { launcherService, type GameVersion } from './services/LauncherService'
import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'
// Utility for merging tailwind classes
function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
// Components
import PlaySection from './components/PlaySection'
import ModsSection from './components/ModsSection'
import SettingsSection from './components/SettingsSection'
type Section = 'play' | 'mods' | 'settings'
const App: React.FC = () => {
const [activeSection, setActiveSection] = useState<Section>('play')
const [versions, setVersions] = useState<GameVersion[]>([])
const [selectedVersion, setSelectedVersion] = useState<GameVersion | null>(null)
const [isVersionDropdownOpen, setIsVersionDropdownOpen] = useState(false)
const [isAccountDropdownOpen, setIsAccountDropdownOpen] = useState(false)
useEffect(() => {
const fetchVersions = async () => {
const v = await launcherService.getVersions()
setVersions(v)
if (v.length > 0) setSelectedVersion(v[0])
}
fetchVersions()
}, [])
return (
<div className="flex h-screen w-screen bg-saturn-bg text-saturn-text-primary overflow-hidden font-sans">
{/* Sidebar */}
<aside className="w-16 border-r border-saturn-border flex flex-col items-center py-6 gap-6 bg-saturn-panel/50">
<div className="mb-4">
<div className="w-10 h-10 bg-saturn-accent rounded-xl flex items-center justify-center shadow-[0_0_20px_rgba(59,130,246,0.4)]">
<span className="font-bold text-white text-xl">S</span>
</div>
</div>
<nav className="flex flex-col gap-4">
<button
onClick={() => setActiveSection('play')}
className={cn("sidebar-icon", activeSection === 'play' && "active")}
title="Play"
>
<Play size={22} fill={activeSection === 'play' ? "currentColor" : "none"} />
</button>
<button
onClick={() => setActiveSection('mods')}
className={cn("sidebar-icon", activeSection === 'mods' && "active")}
title="Mods"
>
<Puzzle size={22} fill={activeSection === 'mods' ? "currentColor" : "none"} />
</button>
<button
onClick={() => setActiveSection('settings')}
className={cn("sidebar-icon", activeSection === 'settings' && "active")}
title="Settings"
>
<Settings size={22} fill={activeSection === 'settings' ? "currentColor" : "none"} />
</button>
</nav>
</aside>
{/* Main Content Area */}
<main className="flex-1 flex flex-col min-w-0">
{/* Top Bar */}
<header className="h-14 border-b border-saturn-border flex items-center justify-between px-6 bg-saturn-panel/30 backdrop-blur-md">
{/* Version Selector */}
<div className="relative">
<button
onClick={() => setIsVersionDropdownOpen(!isVersionDropdownOpen)}
className="flex items-center gap-2 px-3 py-1.5 rounded-md hover:bg-white/5 transition-colors text-sm font-medium border border-transparent hover:border-saturn-border"
>
<span className="text-saturn-text-secondary">Version:</span>
<span>{selectedVersion?.name || 'Loading...'}</span>
<ChevronDown size={14} className={cn("transition-transform", isVersionDropdownOpen && "rotate-180")} />
</button>
{isVersionDropdownOpen && (
<div className="absolute top-full left-0 mt-2 w-48 bg-saturn-panel border border-saturn-border rounded-lg shadow-2xl z-50 py-1 overflow-hidden">
{versions.map(v => (
<button
key={v.id}
onClick={() => {
setSelectedVersion(v)
setIsVersionDropdownOpen(false)
}}
className="w-full flex items-center justify-between px-4 py-2 text-sm hover:bg-saturn-accent/10 hover:text-saturn-accent transition-colors"
>
<span>{v.name}</span>
{selectedVersion?.id === v.id && <Check size={14} />}
</button>
))}
</div>
)}
</div>
{/* Account Display */}
<div className="relative">
<button
onClick={() => setIsAccountDropdownOpen(!isAccountDropdownOpen)}
className="flex items-center gap-3 px-2 py-1 rounded-full hover:bg-white/5 transition-colors border border-transparent hover:border-saturn-border"
>
<div className="text-right hidden sm:block">
<p className="text-xs font-bold leading-none">SaturnDev</p>
<p className="text-[10px] text-saturn-text-secondary leading-none mt-1">Microsoft Account</p>
</div>
<div className="w-8 h-8 rounded-md bg-zinc-800 border border-saturn-border overflow-hidden flex items-center justify-center">
<User size={18} className="text-saturn-text-secondary" />
</div>
</button>
{isAccountDropdownOpen && (
<div className="absolute top-full right-0 mt-2 w-48 bg-saturn-panel border border-saturn-border rounded-lg shadow-2xl z-50 py-1 overflow-hidden">
<div className="px-4 py-3 border-b border-saturn-border">
<p className="text-sm font-bold">SaturnDev</p>
<p className="text-xs text-saturn-text-secondary truncate">dev@saturnclient.com</p>
</div>
<button className="w-full flex items-center gap-2 px-4 py-2 text-sm hover:bg-white/5 transition-colors">
<User size={14} />
<span>Switch Account</span>
</button>
<button className="w-full flex items-center gap-2 px-4 py-2 text-sm hover:bg-red-500/10 text-red-400 transition-colors">
<LogOut size={14} />
<span>Logout</span>
</button>
</div>
)}
</div>
</header>
{/* Content Sections */}
<div className="flex-1 overflow-y-auto overflow-x-hidden p-8">
{activeSection === 'play' && selectedVersion && <PlaySection version={selectedVersion} />}
{activeSection === 'mods' && selectedVersion && <ModsSection version={selectedVersion} />}
{activeSection === 'settings' && <SettingsSection />}
</div>
</main>
</div>
)
}
export default App
+236
View File
@@ -0,0 +1,236 @@
import React, { useState, useEffect } from 'react'
import { Search, Download, Trash2, ExternalLink, Package, Filter, CheckCircle2, XCircle, ChevronRight, X } from 'lucide-react'
import { launcherService, type Mod, type GameVersion } from '../services/LauncherService'
import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'
import { motion, AnimatePresence } from 'framer-motion'
function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
interface ModsSectionProps {
version: GameVersion
}
const ModsSection: React.FC<ModsSectionProps> = ({ version }) => {
const [activeTab, setActiveTab] = useState<'installed' | 'discover'>('installed')
const [searchQuery, setSearchQuery] = useState('')
const [mods, setMods] = useState<Mod[]>([])
const [isInstallDialogOpen, setIsInstallDialogOpen] = useState(false)
const [selectedModForInstall, setSelectedModForInstall] = useState<Mod | null>(null)
const [selectedVersionsForInstall, setSelectedVersionsForInstall] = useState<string[]>([])
const [allVersions, setAllVersions] = useState<GameVersion[]>([])
useEffect(() => {
const loadMods = async () => {
if (activeTab === 'installed') {
const m = await launcherService.getInstalledMods(version.id)
setMods(m)
} else {
const m = await launcherService.discoverMods(searchQuery)
setMods(m)
}
}
loadMods()
}, [activeTab, version.id, searchQuery])
useEffect(() => {
const loadAllVersions = async () => {
const v = await launcherService.getVersions()
setAllVersions(v)
}
loadAllVersions()
}, [])
const handleToggleMod = async (modId: string) => {
await launcherService.toggleMod(modId)
const m = await launcherService.getInstalledMods(version.id)
setMods(m)
}
const openInstallDialog = (mod: Mod) => {
setSelectedModForInstall(mod)
setSelectedVersionsForInstall([version.id])
setIsInstallDialogOpen(true)
}
const handleInstall = async () => {
if (selectedModForInstall && selectedVersionsForInstall.length > 0) {
await launcherService.installMod(selectedModForInstall, selectedVersionsForInstall)
setIsInstallDialogOpen(false)
if (activeTab === 'installed') {
const m = await launcherService.getInstalledMods(version.id)
setMods(m)
}
}
}
const toggleVersionSelection = (versionId: string) => {
setSelectedVersionsForInstall(prev =>
prev.includes(versionId)
? prev.filter(v => v !== versionId)
: [...prev, versionId]
)
}
return (
<div className="max-w-6xl mx-auto h-full flex flex-col gap-6">
<div className="flex items-center justify-between">
<div className="flex items-center gap-1 p-1 bg-saturn-panel border border-saturn-border rounded-lg">
<button
onClick={() => setActiveTab('installed')}
className={cn("px-4 py-1.5 text-sm font-medium rounded-md transition-all", activeTab === 'installed' ? "bg-white/5 text-white" : "text-saturn-text-secondary hover:text-white")}
>
Installed Mods
</button>
<button
onClick={() => setActiveTab('discover')}
className={cn("px-4 py-1.5 text-sm font-medium rounded-md transition-all", activeTab === 'discover' ? "bg-white/5 text-white" : "text-saturn-text-secondary hover:text-white")}
>
Discover
</button>
</div>
<div className="relative group">
<Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-saturn-text-secondary group-focus-within:text-saturn-accent transition-colors" />
<input
type="text"
placeholder={activeTab === 'installed' ? "Search installed mods..." : "Search CurseForge/Modrinth..."}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="bg-saturn-panel border border-saturn-border rounded-lg pl-10 pr-4 py-2 text-sm w-64 focus:outline-none focus:border-saturn-accent/50 focus:ring-1 focus:ring-saturn-accent/50 transition-all"
/>
</div>
</div>
<div className="flex-1 overflow-y-auto pr-2">
<div className="grid grid-cols-1 gap-3">
{mods.map(mod => (
<motion.div
layout
key={mod.id}
initial={{ opacity: 0, x: -10 }}
animate={{ opacity: 1, x: 0 }}
className="panel p-4 flex items-center gap-4 hover:border-white/10 transition-colors"
>
<div className="w-12 h-12 rounded-lg bg-zinc-800 border border-saturn-border flex items-center justify-center shrink-0">
<Package size={24} className="text-saturn-text-secondary" />
</div>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2">
<h3 className="font-bold text-sm truncate">{mod.name}</h3>
<span className="text-[10px] text-saturn-text-secondary font-medium px-1.5 py-0.5 rounded bg-white/5">v{mod.version}</span>
<span className="text-[10px] text-saturn-text-secondary">by {mod.author}</span>
</div>
<p className="text-xs text-saturn-text-secondary mt-1 truncate max-w-xl">{mod.description}</p>
</div>
<div className="flex items-center gap-3">
{activeTab === 'installed' ? (
<>
<button
onClick={() => handleToggleMod(mod.id)}
className={cn("flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium transition-all", mod.enabled ? "bg-green-500/10 text-green-400 border border-green-500/20" : "bg-red-500/10 text-red-400 border border-red-500/20")}
>
{mod.enabled ? <CheckCircle2 size={14} /> : <XCircle size={14} />}
{mod.enabled ? 'Enabled' : 'Disabled'}
</button>
<button className="p-2 text-saturn-text-secondary hover:text-red-400 transition-colors">
<Trash2 size={16} />
</button>
</>
) : (
<button
onClick={() => openInstallDialog(mod)}
className="flex items-center gap-2 px-4 py-1.5 bg-saturn-accent/10 text-saturn-accent hover:bg-saturn-accent hover:text-white rounded-md text-xs font-bold transition-all border border-saturn-accent/20"
>
<Download size={14} />
INSTALL
</button>
)}
</div>
</motion.div>
))}
{mods.length === 0 && (
<div className="h-64 flex flex-col items-center justify-center text-saturn-text-secondary opacity-50">
<Package size={48} className="mb-4" strokeWidth={1} />
<p>No mods found.</p>
</div>
)}
</div>
</div>
{/* Install Dialog */}
<AnimatePresence>
{isInstallDialogOpen && selectedModForInstall && (
<div className="fixed inset-0 bg-black/80 backdrop-blur-sm z-[100] flex items-center justify-center p-6">
<motion.div
initial={{ scale: 0.9, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.9, opacity: 0 }}
className="bg-saturn-panel border border-saturn-border rounded-xl w-full max-w-md shadow-2xl overflow-hidden"
>
<div className="p-6 border-b border-saturn-border flex items-center justify-between">
<div>
<h2 className="text-lg font-bold">Install {selectedModForInstall.name}</h2>
<p className="text-xs text-saturn-text-secondary">Select versions to install this mod to.</p>
</div>
<button onClick={() => setIsInstallDialogOpen(false)} className="text-saturn-text-secondary hover:text-white">
<X size={20} />
</button>
</div>
<div className="p-6 space-y-3 max-h-64 overflow-y-auto">
{allVersions.map(v => {
const isSupported = selectedModForInstall.supportedVersions.includes(v.id)
const isSelected = selectedVersionsForInstall.includes(v.id)
return (
<div
key={v.id}
onClick={() => isSupported && toggleVersionSelection(v.id)}
className={cn(
"flex items-center justify-between p-3 rounded-lg border transition-all cursor-pointer",
isSelected ? "bg-saturn-accent/10 border-saturn-accent/50" : "bg-white/5 border-transparent hover:border-white/10",
!isSupported && "opacity-40 cursor-not-allowed grayscale"
)}
>
<div className="flex items-center gap-3">
<div className={cn("w-5 h-5 rounded border flex items-center justify-center transition-all", isSelected ? "bg-saturn-accent border-saturn-accent" : "border-saturn-border")}>
{isSelected && <CheckCircle2 size={14} className="text-white" />}
</div>
<span className="text-sm font-medium">{v.name}</span>
</div>
{!isSupported && <span className="text-[10px] text-red-400 font-bold uppercase">Unsupported</span>}
</div>
)
})}
</div>
<div className="p-6 bg-white/5 flex gap-3">
<button
onClick={() => setIsInstallDialogOpen(false)}
className="flex-1 py-2 text-sm font-medium hover:bg-white/5 rounded-lg transition-colors"
>
Cancel
</button>
<button
onClick={handleInstall}
disabled={selectedVersionsForInstall.length === 0}
className="flex-1 py-2 text-sm font-bold bg-saturn-accent hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-all shadow-lg shadow-saturn-accent/20"
>
Confirm Install
</button>
</div>
</motion.div>
</div>
)}
</AnimatePresence>
</div>
)
}
export default ModsSection
+110
View File
@@ -0,0 +1,110 @@
import React, { useState } from 'react'
import { Play, Loader2, Info, ExternalLink } from 'lucide-react'
import { launcherService, type GameVersion } from '../services/LauncherService'
import { motion } from 'framer-motion'
interface PlaySectionProps {
version: GameVersion
}
const PlaySection: React.FC<PlaySectionProps> = ({ version }) => {
const [isLaunching, setIsLaunching] = useState(false)
const [launchStatus, setLaunchStatus] = useState('')
const handleLaunch = async () => {
setIsLaunching(true)
setLaunchStatus('Preparing...')
// Simulate launch steps
setTimeout(() => setLaunchStatus('Verifying assets...'), 500)
setTimeout(() => setLaunchStatus('Applying Saturn optimizations...'), 1200)
const result = await launcherService.launchGame(version.id)
if (result.success) {
setLaunchStatus('Game running')
// In a real app, we might minimize or close the launcher here
}
setTimeout(() => {
setIsLaunching(false)
setLaunchStatus('')
}, 3000)
}
return (
<div className="h-full flex flex-col items-center justify-center max-w-4xl mx-auto text-center">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="mb-12"
>
<h1 className="text-6xl font-black tracking-tighter mb-2 bg-gradient-to-b from-white to-white/40 bg-clip-text text-transparent">
SATURN
</h1>
<p className="text-saturn-text-secondary text-lg tracking-widest font-light uppercase">
Fabric-Only Optimization Client
</p>
</motion.div>
<div className="w-full grid grid-cols-1 md:grid-cols-3 gap-6 mb-12">
<div className="panel p-6 flex flex-col items-center gap-3">
<div className="w-10 h-10 rounded-full bg-white/5 flex items-center justify-center text-saturn-accent">
<Info size={20} />
</div>
<div>
<p className="text-xs text-saturn-text-secondary uppercase tracking-wider font-bold">Instance</p>
<p className="text-sm font-medium">Saturn Default</p>
</div>
</div>
<div className="panel p-6 flex flex-col items-center gap-3 border-saturn-accent/30 bg-saturn-accent/5">
<div className="w-10 h-10 rounded-full bg-saturn-accent/20 flex items-center justify-center text-saturn-accent">
<Play size={20} fill="currentColor" />
</div>
<div>
<p className="text-xs text-saturn-text-secondary uppercase tracking-wider font-bold">Current Version</p>
<p className="text-sm font-medium">{version.name}</p>
</div>
</div>
<div className="panel p-6 flex flex-col items-center gap-3">
<div className="w-10 h-10 rounded-full bg-white/5 flex items-center justify-center text-saturn-accent">
<ExternalLink size={20} />
</div>
<div>
<p className="text-xs text-saturn-text-secondary uppercase tracking-wider font-bold">Modloader</p>
<p className="text-sm font-medium">Fabric Loader</p>
</div>
</div>
</div>
<div className="relative group">
<div className="absolute -inset-1 bg-gradient-to-r from-blue-600 to-cyan-500 rounded-lg blur opacity-25 group-hover:opacity-50 transition duration-1000 group-hover:duration-200"></div>
<button
onClick={handleLaunch}
disabled={isLaunching}
className="relative btn-primary px-16 py-4 text-xl flex items-center gap-3 min-w-[240px] justify-center"
>
{isLaunching ? (
<>
<Loader2 size={24} className="animate-spin" />
<span>{launchStatus}</span>
</>
) : (
<>
<Play size={24} fill="currentColor" />
<span>PLAY</span>
</>
)}
</button>
</div>
<div className="mt-12 text-saturn-text-secondary text-xs max-w-md">
<p>Saturn Client is not affiliated with Mojang AB. Use at your own risk. Performance may vary based on hardware.</p>
</div>
</div>
)
}
export default PlaySection
+156
View File
@@ -0,0 +1,156 @@
import React, { useState, useEffect } from 'react'
import { Cpu, MemoryStick, Save, RefreshCcw, Info, AlertTriangle } from 'lucide-react'
import { launcherService, type LauncherSettings } from '../services/LauncherService'
import { motion } from 'framer-motion'
const SettingsSection: React.FC = () => {
const [settings, setSettings] = useState<LauncherSettings | null>(null)
const [isSaving, setIsSaving] = useState(false)
const [saveStatus, setSaveStatus] = useState('')
useEffect(() => {
const loadSettings = async () => {
const s = await launcherService.getSettings()
setSettings(s)
}
loadSettings()
}, [])
const handleSave = async () => {
if (!settings) return
setIsSaving(true)
setSaveStatus('Saving...')
await launcherService.updateSettings(settings)
setTimeout(() => {
setIsSaving(false)
setSaveStatus('Settings saved')
setTimeout(() => setSaveStatus(''), 2000)
}, 1000)
}
const handleReset = async () => {
// In a real app, this would reset to defaults in the service
const defaultSettings: LauncherSettings = {
jvmArguments: '-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200',
maxMemory: 4096,
}
setSettings(defaultSettings)
}
if (!settings) return null
return (
<div className="max-w-4xl mx-auto h-full flex flex-col gap-8">
<div className="flex items-center justify-between border-b border-saturn-border pb-6">
<div>
<h1 className="text-2xl font-bold">Performance Settings</h1>
<p className="text-sm text-saturn-text-secondary">Configure how Saturn Client interacts with your hardware.</p>
</div>
<div className="flex items-center gap-3">
<button
onClick={handleReset}
className="p-2 text-saturn-text-secondary hover:text-white transition-colors"
title="Reset to Defaults"
>
<RefreshCcw size={20} />
</button>
<button
onClick={handleSave}
disabled={isSaving}
className="btn-primary flex items-center gap-2 py-2 px-6 text-sm font-bold"
>
<Save size={16} />
{saveStatus || 'SAVE SETTINGS'}
</button>
</div>
</div>
<div className="grid grid-cols-1 gap-8">
{/* Memory Allocation */}
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
className="panel p-6 space-y-6"
>
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-lg bg-saturn-accent/10 flex items-center justify-center text-saturn-accent">
<MemoryStick size={18} />
</div>
<h2 className="text-lg font-bold">Memory Allocation</h2>
</div>
<div className="space-y-4">
<div className="flex justify-between items-center">
<span className="text-sm font-medium">Maximum Memory (RAM)</span>
<span className="text-lg font-bold text-saturn-accent">{(settings.maxMemory / 1024).toFixed(1)} GB</span>
</div>
<input
type="range"
min="1024"
max="16384"
step="512"
value={settings.maxMemory}
onChange={(e) => setSettings({ ...settings, maxMemory: parseInt(e.target.value) })}
className="w-full h-2 bg-saturn-border rounded-lg appearance-none cursor-pointer accent-saturn-accent"
/>
<div className="flex justify-between text-[10px] text-saturn-text-secondary font-bold uppercase tracking-widest">
<span>1 GB</span>
<span>4 GB</span>
<span>8 GB</span>
<span>12 GB</span>
<span>16 GB</span>
</div>
<div className="p-3 bg-blue-500/5 border border-blue-500/10 rounded-lg flex gap-3">
<Info size={16} className="text-blue-400 shrink-0 mt-0.5" />
<p className="text-xs text-blue-300/80 leading-relaxed">
Allocating too much memory can cause system instability, while too little can lead to performance issues or crashes. 4GB - 8GB is recommended for most users.
</p>
</div>
</div>
</motion.div>
{/* JVM Arguments */}
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.1 }}
className="panel p-6 space-y-6"
>
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-lg bg-saturn-accent/10 flex items-center justify-center text-saturn-accent">
<Cpu size={18} />
</div>
<h2 className="text-lg font-bold">Custom JVM Arguments</h2>
</div>
<div className="space-y-4">
<p className="text-xs text-saturn-text-secondary leading-relaxed">
Advanced flags for the Java Virtual Machine. Saturn Client includes optimized defaults, but you can override them here.
</p>
<textarea
value={settings.jvmArguments}
onChange={(e) => setSettings({ ...settings, jvmArguments: e.target.value })}
className="w-full h-32 bg-saturn-bg border border-saturn-border rounded-lg p-4 text-sm font-mono text-saturn-text-secondary focus:outline-none focus:border-saturn-accent/50 focus:ring-1 focus:ring-saturn-accent/50 transition-all resize-none"
placeholder="-XX:+UseG1GC..."
/>
<div className="p-3 bg-yellow-500/5 border border-yellow-500/10 rounded-lg flex gap-3">
<AlertTriangle size={16} className="text-yellow-500 shrink-0 mt-0.5" />
<p className="text-xs text-yellow-500/80 leading-relaxed">
Incorrect JVM arguments can prevent the game from starting. Only modify if you know what you're doing.
</p>
</div>
</div>
</motion.div>
</div>
</div>
)
}
export default SettingsSection
+55
View File
@@ -0,0 +1,55 @@
@import "tailwindcss";
@theme {
--color-saturn-bg: #0a0a0a;
--color-saturn-panel: #141414;
--color-saturn-accent: #3b82f6;
--color-saturn-accent-glow: rgba(59, 130, 246, 0.3);
--color-saturn-text-primary: #f4f4f5;
--color-saturn-text-secondary: #a1a1aa;
--color-saturn-border: #27272a;
}
@layer base {
body {
@apply bg-saturn-bg text-saturn-text-primary font-sans antialiased;
overflow: hidden;
user-select: none;
}
}
@layer components {
.btn-primary {
@apply bg-saturn-accent hover:bg-blue-600 text-white font-medium py-2 px-6 rounded-md transition-all duration-200 shadow-[0_0_15px_rgba(59,130,246,0.2)] hover:shadow-[0_0_20px_rgba(59,130,246,0.4)];
}
.sidebar-icon {
@apply w-10 h-10 flex items-center justify-center rounded-lg transition-all duration-200 text-saturn-text-secondary hover:text-white hover:bg-white/5 cursor-pointer;
}
.sidebar-icon.active {
@apply text-saturn-accent bg-saturn-accent/10;
}
.panel {
@apply bg-saturn-panel border border-saturn-border rounded-lg overflow-hidden;
}
}
/* Custom scrollbar for dense UI */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #27272a;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #3f3f46;
}
+10
View File
@@ -0,0 +1,10 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
+127
View File
@@ -0,0 +1,127 @@
// Saturn Client Launcher Centralized Service Layer
// Handles all data fetching, mod management, and launch logic.
export interface Mod {
id: string;
name: string;
version: string;
author: string;
description: string;
enabled: boolean;
icon?: string;
supportedVersions: string[];
}
export interface GameVersion {
id: string;
name: string;
releaseDate: string;
type: 'release' | 'snapshot';
}
export interface LauncherSettings {
jvmArguments: string;
maxMemory: number; // in MB
}
class LauncherService {
private versions: GameVersion[] = [
{ id: '1.20.1', name: 'Fabric 1.20.1', releaseDate: '2023-06-07', type: 'release' },
{ id: '1.20.4', name: 'Fabric 1.20.4', releaseDate: '2023-12-07', type: 'release' },
{ id: '1.21', name: 'Fabric 1.21', releaseDate: '2024-06-13', type: 'release' },
];
private installedMods: Mod[] = [
{
id: 'sodium',
name: 'Sodium',
version: '0.5.8',
author: 'jellysquid3',
description: 'Modern rendering engine for Minecraft.',
enabled: true,
supportedVersions: ['1.20.1', '1.20.4', '1.21']
},
{
id: 'iris',
name: 'Iris',
version: '1.7.0',
author: 'coderbot',
description: 'A modern shaders mod for Minecraft.',
enabled: true,
supportedVersions: ['1.20.1', '1.20.4', '1.21']
},
{
id: 'lithium',
name: 'Lithium',
version: '0.11.2',
author: 'jellysquid3',
description: 'General-purpose optimization mod for Minecraft.',
enabled: false,
supportedVersions: ['1.20.1', '1.20.4']
},
];
private settings: LauncherSettings = {
jvmArguments: '-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200',
maxMemory: 4096,
};
// --- Versions ---
async getVersions(): Promise<GameVersion[]> {
return [...this.versions];
}
// --- Mods ---
async getInstalledMods(versionId: string): Promise<Mod[]> {
// Filter mods by supported version
return this.installedMods.filter(mod => mod.supportedVersions.includes(versionId));
}
async toggleMod(modId: string): Promise<void> {
const mod = this.installedMods.find(m => m.id === modId);
if (mod) {
mod.enabled = !mod.enabled;
}
}
async discoverMods(query: string): Promise<Mod[]> {
// Mock discovery results
const allDiscoverable: Mod[] = [
{ id: 'modmenu', name: 'Mod Menu', version: '7.2.2', author: 'TerraformersMC', description: 'Adds a mod menu to view the list of installed mods.', enabled: false, supportedVersions: ['1.20.1', '1.20.4', '1.21'] },
{ id: 'starlight', name: 'Starlight', version: '1.1.2', author: 'Spottedleaf', description: 'Rewrites the light engine to fix performance issues.', enabled: false, supportedVersions: ['1.20.1'] },
{ id: 'ferritecore', name: 'FerriteCore', version: '6.0.1', author: 'malte0811', description: 'Memory usage optimizations.', enabled: false, supportedVersions: ['1.20.1', '1.20.4', '1.21'] },
];
if (!query) return allDiscoverable;
return allDiscoverable.filter(m => m.name.toLowerCase().includes(query.toLowerCase()));
}
async installMod(mod: Mod, versions: string[]): Promise<void> {
console.log(`Installing ${mod.name} to versions: ${versions.join(', ')}`);
// Mock install logic: add to installedMods if not already there
if (!this.installedMods.find(m => m.id === mod.id)) {
this.installedMods.push({ ...mod, enabled: true, supportedVersions: versions });
}
}
// --- Settings ---
async getSettings(): Promise<LauncherSettings> {
return { ...this.settings };
}
async updateSettings(newSettings: Partial<LauncherSettings>): Promise<void> {
this.settings = { ...this.settings, ...newSettings };
}
// --- Launch ---
async launchGame(versionId: string): Promise<{ success: boolean; message: string }> {
console.log(`Launching Saturn Client with version ${versionId}...`);
return new Promise((resolve) => {
setTimeout(() => {
resolve({ success: true, message: 'Game launched successfully!' });
}, 2000);
});
}
}
export const launcherService = new LauncherService();
+2 -1
View File
@@ -1,12 +1,13 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
// @ts-expect-error process is a nodejs global // @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST; const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig(async () => ({ export default defineConfig(async () => ({
plugins: [react()], plugins: [react(), tailwindcss()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// //