import TitleBar from "renderer/components/title-bar/title-bar.component"; import { useService } from "renderer/hooks/use-service.hook"; import { useEffect, useState } from "react" import { WindowManagerService } from "renderer/services/window-manager.service"; import { IpcService } from "renderer/services/ipc.service"; import { take } from "rxjs"; import { BSLauncherService } from "renderer/services/bs-launcher.service"; import { BsmImage } from "renderer/components/shared/bsm-image.component"; import defaultImage from "../../../assets/images/default-version-img.jpg"; import { useObservable } from "renderer/hooks/use-observable.hook"; import { useOnUpdate } from "renderer/hooks/use-on-update.hook"; import { BsNoteFill } from "renderer/components/svgs/icons/bs-note-fill.component"; import { useThemeColor } from "renderer/hooks/use-theme-color.hook"; import { BsmButton } from "renderer/components/shared/bsm-button.component"; import { motion } from "framer-motion" import { BSLaunchError, BSLaunchEventType } from "shared/models/bs-launch"; import { NotificationService } from "renderer/services/notification.service"; import { useTranslation } from "renderer/hooks/use-translation.hook"; import { useWindowControls } from "renderer/hooks/use-window-controls.hook"; export default function ShortcutLaunch() { const windows = useService(WindowManagerService); const ipc = useService(IpcService); const bsLauncher = useService(BSLauncherService); const notification = useService(NotificationService); const { close: closeWindow } = useWindowControls(); const t = useTranslation(); const color = useThemeColor("second-color"); const launchOptions = useObservable(() => ipc.sendV2("shortcut-launch-options").pipe(take(1)), null) const [rotation, setRotation] = useState(0); const [status, setStatus] = useState(); useEffect(() => { const interval = setInterval(() => { setRotation(rotation => rotation + 45 * 3); }, 1500); return () => { clearInterval(interval); } }, []); useOnUpdate(() => { if(!launchOptions) { return; } const sub = bsLauncher.doLaunch(launchOptions).subscribe({ next: event => { setStatus(event.type); }, error: err => { if(!Object.values(BSLaunchError).includes(err.type)){ notification.notifySystem({title: t("notifications.bs-launch.errors.titles.UNKNOWN_ERROR"), body: t("notifications.bs-launch.errors.msg.UNKNOWN_ERROR")}); } else { notification.notifySystem({title: t(`notifications.bs-launch.errors.titles.${err.type}`), body: t(`notifications.bs-launch.errors.msg.${err.type}`)}) } } }); sub.add(() => { closeWindow(); }); return () => sub.unsubscribe(); }, [launchOptions]); return (

{t("bs-shortcut-launch.beat-saber-launching")}

{[launchOptions?.version?.BSVersion, launchOptions?.version?.name].join(" ")}

{t("bs-shortcut-launch.launching")} {( status ? t(`bs-shortcut-launch.status-text.success.${status}`) : t("bs-shortcut-launch.status-text.init") )}
windows.openWindowOrFocus("index.html")}/>
) }