Fixed states
This commit is contained in:
@@ -246,7 +246,7 @@ const ModsSection: React.FC<ModsSectionProps> = ({ version }) => {
|
|||||||
<div className="p-6 space-y-3 max-h-64 overflow-y-auto">
|
<div className="p-6 space-y-3 max-h-64 overflow-y-auto">
|
||||||
{allVersions.map((v) => {
|
{allVersions.map((v) => {
|
||||||
const isSupported =
|
const isSupported =
|
||||||
selectedModForInstall.supportedVersions.includes(v.id);
|
selectedModForInstall.supported_versions.includes(v.id);
|
||||||
const isSelected = selectedVersionsForInstall.includes(v.id);
|
const isSelected = selectedVersionsForInstall.includes(v.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,75 +1,89 @@
|
|||||||
import React, { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from "react";
|
||||||
import { Cpu, MemoryStick, Save, RefreshCcw, Info, AlertTriangle } from 'lucide-react'
|
import {
|
||||||
import { getSettings, updateSettings, type LauncherSettings } from '../services/LauncherService'
|
Cpu,
|
||||||
import { motion } from 'framer-motion'
|
MemoryStick,
|
||||||
|
Save,
|
||||||
|
RefreshCcw,
|
||||||
|
Info,
|
||||||
|
AlertTriangle,
|
||||||
|
} from "lucide-react";
|
||||||
|
import {
|
||||||
|
getSettings,
|
||||||
|
updateSettings,
|
||||||
|
type LauncherSettings,
|
||||||
|
} from "../services/LauncherService";
|
||||||
|
import { motion } from "framer-motion";
|
||||||
|
|
||||||
const SettingsSection: React.FC = () => {
|
const SettingsSection: React.FC = () => {
|
||||||
const [settings, setSettings] = useState<LauncherSettings | null>(null)
|
const [settings, setSettings] = useState<LauncherSettings | null>(null);
|
||||||
const [isSaving, setIsSaving] = useState(false)
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
const [saveStatus, setSaveStatus] = useState('')
|
const [saveStatus, setSaveStatus] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadSettings = async () => {
|
const loadSettings = async () => {
|
||||||
const s = await getSettings()
|
const s = await getSettings();
|
||||||
setSettings(s)
|
setSettings(s);
|
||||||
}
|
};
|
||||||
loadSettings()
|
loadSettings();
|
||||||
}, [])
|
}, []);
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!settings) return
|
if (!settings) return;
|
||||||
setIsSaving(true)
|
setIsSaving(true);
|
||||||
setSaveStatus('Saving...')
|
setSaveStatus("Saving...");
|
||||||
|
|
||||||
await updateSettings(settings)
|
await updateSettings(settings);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsSaving(false)
|
setIsSaving(false);
|
||||||
setSaveStatus('Settings saved')
|
setSaveStatus("Settings saved");
|
||||||
setTimeout(() => setSaveStatus(''), 2000)
|
setTimeout(() => setSaveStatus(""), 2000);
|
||||||
}, 1000)
|
}, 1000);
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleReset = async () => {
|
const handleReset = async () => {
|
||||||
// In a real app, this would reset to defaults in the service
|
// In a real app, this would reset to defaults in the service
|
||||||
const defaultSettings: LauncherSettings = {
|
const defaultSettings: LauncherSettings = {
|
||||||
jvmArguments: '-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200',
|
jvm_arguments:
|
||||||
maxMemory: 4096,
|
"-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200",
|
||||||
}
|
max_memory: 4096,
|
||||||
setSettings(defaultSettings)
|
};
|
||||||
}
|
setSettings(defaultSettings);
|
||||||
|
};
|
||||||
|
|
||||||
if (!settings) return null
|
if (!settings) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-4xl mx-auto h-full flex flex-col gap-8">
|
<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 className="flex items-center justify-between border-b border-saturn-border pb-6">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold">Performance Settings</h1>
|
<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>
|
<p className="text-sm text-saturn-text-secondary">
|
||||||
|
Configure how Saturn Client interacts with your hardware.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<button
|
<button
|
||||||
onClick={handleReset}
|
onClick={handleReset}
|
||||||
className="p-2 text-saturn-text-secondary hover:text-white transition-colors"
|
className="p-2 text-saturn-text-secondary hover:text-white transition-colors"
|
||||||
title="Reset to Defaults"
|
title="Reset to Defaults"
|
||||||
>
|
>
|
||||||
<RefreshCcw size={20} />
|
<RefreshCcw size={20} />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
disabled={isSaving}
|
disabled={isSaving}
|
||||||
className="btn-primary flex items-center gap-2 py-2 px-6 text-sm font-bold"
|
className="btn-primary flex items-center gap-2 py-2 px-6 text-sm font-bold"
|
||||||
>
|
>
|
||||||
<Save size={16} />
|
<Save size={16} />
|
||||||
{saveStatus || 'SAVE SETTINGS'}
|
{saveStatus || "SAVE SETTINGS"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 gap-8">
|
<div className="grid grid-cols-1 gap-8">
|
||||||
{/* Memory Allocation */}
|
{/* Memory Allocation */}
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0, y: 10 }}
|
initial={{ opacity: 0, y: 10 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
className="panel p-6 space-y-6"
|
className="panel p-6 space-y-6"
|
||||||
@@ -84,19 +98,26 @@ const SettingsSection: React.FC = () => {
|
|||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="flex justify-between items-center">
|
<div className="flex justify-between items-center">
|
||||||
<span className="text-sm font-medium">Maximum Memory (RAM)</span>
|
<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>
|
<span className="text-lg font-bold text-saturn-accent">
|
||||||
|
{(settings.max_memory / 1024).toFixed(1)} GB
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="range"
|
||||||
min="1024"
|
min="1024"
|
||||||
max="16384"
|
max="16384"
|
||||||
step="512"
|
step="512"
|
||||||
value={settings.maxMemory}
|
value={settings.max_memory}
|
||||||
onChange={(e) => setSettings({ ...settings, maxMemory: parseInt(e.target.value) })}
|
onChange={(e) =>
|
||||||
|
setSettings({
|
||||||
|
...settings,
|
||||||
|
max_memory: parseInt(e.target.value),
|
||||||
|
})
|
||||||
|
}
|
||||||
className="w-full h-2 bg-saturn-border rounded-lg appearance-none cursor-pointer accent-saturn-accent"
|
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">
|
<div className="flex justify-between text-[10px] text-saturn-text-secondary font-bold uppercase tracking-widest">
|
||||||
<span>1 GB</span>
|
<span>1 GB</span>
|
||||||
<span>4 GB</span>
|
<span>4 GB</span>
|
||||||
@@ -108,14 +129,16 @@ const SettingsSection: React.FC = () => {
|
|||||||
<div className="p-3 bg-blue-500/5 border border-blue-500/10 rounded-lg flex gap-3">
|
<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" />
|
<Info size={16} className="text-blue-400 shrink-0 mt-0.5" />
|
||||||
<p className="text-xs text-blue-300/80 leading-relaxed">
|
<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.
|
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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
{/* JVM Arguments */}
|
{/* JVM Arguments */}
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ opacity: 0, y: 10 }}
|
initial={{ opacity: 0, y: 10 }}
|
||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
transition={{ delay: 0.1 }}
|
transition={{ delay: 0.1 }}
|
||||||
@@ -130,27 +153,34 @@ const SettingsSection: React.FC = () => {
|
|||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<p className="text-xs text-saturn-text-secondary leading-relaxed">
|
<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.
|
Advanced flags for the Java Virtual Machine. Saturn Client
|
||||||
|
includes optimized defaults, but you can override them here.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
value={settings.jvmArguments}
|
value={settings.jvm_arguments}
|
||||||
onChange={(e) => setSettings({ ...settings, jvmArguments: e.target.value })}
|
onChange={(e) =>
|
||||||
|
setSettings({ ...settings, jvm_arguments: 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"
|
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..."
|
placeholder="-XX:+UseG1GC..."
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="p-3 bg-yellow-500/5 border border-yellow-500/10 rounded-lg flex gap-3">
|
<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" />
|
<AlertTriangle
|
||||||
|
size={16}
|
||||||
|
className="text-yellow-500 shrink-0 mt-0.5"
|
||||||
|
/>
|
||||||
<p className="text-xs text-yellow-500/80 leading-relaxed">
|
<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.
|
Incorrect JVM arguments can prevent the game from starting. Only
|
||||||
|
modify if you know what you're doing.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default SettingsSection
|
export default SettingsSection;
|
||||||
|
|||||||
@@ -1,28 +1,5 @@
|
|||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import { GameVersion, LauncherSettings, Mod } from "./Types";
|
||||||
// --- Types ---
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Versions ---
|
// --- Versions ---
|
||||||
export async function getVersions(): Promise<GameVersion[]> {
|
export async function getVersions(): Promise<GameVersion[]> {
|
||||||
@@ -47,7 +24,7 @@ export async function discoverMods(query: string): Promise<Mod[]> {
|
|||||||
author: "TerraformersMC",
|
author: "TerraformersMC",
|
||||||
description: "Adds a mod menu to view the list of installed mods.",
|
description: "Adds a mod menu to view the list of installed mods.",
|
||||||
enabled: false,
|
enabled: false,
|
||||||
supportedVersions: ["1.20.1", "1.20.4", "1.21"],
|
supported_versions: ["1.20.1", "1.20.4", "1.21"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "starlight",
|
id: "starlight",
|
||||||
@@ -56,7 +33,7 @@ export async function discoverMods(query: string): Promise<Mod[]> {
|
|||||||
author: "Spottedleaf",
|
author: "Spottedleaf",
|
||||||
description: "Rewrites the light engine to fix performance issues.",
|
description: "Rewrites the light engine to fix performance issues.",
|
||||||
enabled: false,
|
enabled: false,
|
||||||
supportedVersions: ["1.20.1"],
|
supported_versions: ["1.20.1"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "ferritecore",
|
id: "ferritecore",
|
||||||
@@ -65,7 +42,7 @@ export async function discoverMods(query: string): Promise<Mod[]> {
|
|||||||
author: "malte0811",
|
author: "malte0811",
|
||||||
description: "Memory usage optimizations.",
|
description: "Memory usage optimizations.",
|
||||||
enabled: false,
|
enabled: false,
|
||||||
supportedVersions: ["1.20.1", "1.20.4", "1.21"],
|
supported_versions: ["1.20.1", "1.20.4", "1.21"],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
export interface Mod {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
author: string;
|
||||||
|
description: string;
|
||||||
|
enabled: boolean;
|
||||||
|
icon?: string;
|
||||||
|
supported_versions: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GameVersion {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
release_date: string;
|
||||||
|
type: "release" | "snapshot";
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LauncherSettings {
|
||||||
|
jvm_arguments: string;
|
||||||
|
max_memory: number;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user