Proper mod management

This commit is contained in:
2026-04-04 23:37:23 +02:00
parent 0fe65f51a7
commit f1fd413c96
5 changed files with 233 additions and 20 deletions
+6 -4
View File
@@ -11,8 +11,9 @@ import {
import {
getInstalledMods,
discoverMods,
toggleMod,
enableMod,
installMod,
disableMod,
} from "@/lib/saturn";
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
@@ -60,8 +61,9 @@ const ModsSection: React.FC<ModsSectionProps> = ({ version }) => {
return () => clearTimeout(id);
}, [activeTab, version.id, searchQuery]);
const handleToggleMod = async (modId: string) => {
await toggleMod(modId);
const handleToggleMod = async (modId: string, enable: boolean) => {
if (enable) await enableMod(version.id, modId);
else await disableMod(version.id, modId);
const m = await getInstalledMods(version.id);
setMods(m);
};
@@ -171,7 +173,7 @@ const ModsSection: React.FC<ModsSectionProps> = ({ version }) => {
{activeTab === "installed" ? (
<>
<button
onClick={() => handleToggleMod(mod.id)}
onClick={() => handleToggleMod(mod.id, !mod.enabled)}
className={cn(
"flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium transition-all",
mod.enabled
-2
View File
@@ -39,8 +39,6 @@ const PlaySection: React.FC<PlaySectionProps> = ({ version, account }) => {
};
}, []);
console.log(isLaunching);
return (
<div className="h-full relative">
{/* Background Image */}
+11 -7
View File
@@ -6,8 +6,15 @@ export async function getInstalledMods(versionId: string): Promise<Mod[]> {
return await invoke("get_installed_mods", { versionId });
}
export async function toggleMod(modId: string): Promise<void> {
await invoke("toggle_mod", { modId });
export async function enableMod(version: string, modId: string): Promise<void> {
await invoke("enable_mod", { version, fileName: modId });
}
export async function disableMod(
version: string,
modId: string,
): Promise<void> {
await invoke("disable_mod", { version, fileName: modId });
}
export async function discoverMods(query: string): Promise<Mod[]> {
@@ -43,11 +50,8 @@ export async function discoverMods(query: string): Promise<Mod[]> {
);
}
export async function installMod(
mod: Mod,
versionsList: string[],
): Promise<void> {
await invoke("install_mod", { modItem: mod });
export async function installMod(mod: Mod, versions: string[]): Promise<void> {
await invoke("install_mod", { modMeta: mod, versions });
}
// --- Settings ---