import React, { useEffect, useState } from "react"; import { Play, Loader2 } from "lucide-react"; // import { launchGame } from "../services/SaturnApi"; import Bg from "@/assets/bg.png"; import { listen } from "@tauri-apps/api/event"; import { GameVersion } from "@/lib/types"; import { launch } from "@/lib/launcher"; import { MinecraftAccount } from "@/lib/auth"; import { cn } from "@/lib/utils"; interface PlaySectionProps { version: GameVersion | null; account: MinecraftAccount | null; } const PlaySection: React.FC = ({ version, account }) => { const [isLaunching, setIsLaunching] = useState(false); const [launchStatus, setLaunchStatus] = useState(""); const [progress, setProgress] = useState(0); useEffect(() => { const unlistenProgress = listen("launch-progress", (event) => { setProgress(event.payload); }); const unlistenLaunchStatus = listen("launch-status", (event) => { setLaunchStatus(event.payload); }); const unlistenIsLaunching = listen("is-launching", (event) => { setIsLaunching(event.payload === "true"); if (event.payload === "false") setProgress(0); // reset when done }); return () => { unlistenProgress.then((f) => f()); unlistenLaunchStatus.then((f) => f()); unlistenIsLaunching.then((f) => f()); }; }, []); console.log(isLaunching); return (
{/* Background Image */} Background {/* Centered Overlay */}
{
{progress}%
}
); }; export default PlaySection;