Skip to content

Commit

Permalink
Re-implement installer!
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneWizard08 committed Mar 10, 2023
1 parent 3b8c7db commit b7e4ad8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 85 deletions.
4 changes: 2 additions & 2 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./App.scss";
import { Route, Router } from "preact-router";
import { Header } from "./components/Header";
import { Home } from "./routes/Home";
import { InstallProgressWrapper } from "./routes/InstallProgressWrapper";
import { InstallProgress } from "./routes/InstallProgress";
import { Instances } from "./routes/Instances";
import { Browse } from "./routes/mods/Browse";
import { FullMod } from "./routes/mods/FullMod";
Expand All @@ -21,7 +21,7 @@ export const App = () => {

<Route path="/mods" component={Browse} />
<Route path="/manage" component={Manage} />
<Route path="/install" component={InstallProgressWrapper} />
<Route path="/install" component={InstallProgress} />

<Route path="/mod/:mod" component={FullMod} />
<Route path="/instance/:instance" component={Instance} />
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Header = () => {
);

setManage(router.path == "/manage");
setSpacewarp(router.path == "/");
setSpacewarp(router.path == "/" || router.path == "/install");
}, [router.path]);

return (
Expand Down
5 changes: 4 additions & 1 deletion app/src/routes/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import "./Home.scss";
import banner from "../assets/background_banner.png";
import { route } from "preact-router";

export const Home = () => {
const doInstall = () => {};
const doInstall = () => {
route("/install", true);
};

return (
<div className="home-container">
Expand Down
14 changes: 7 additions & 7 deletions app/src/routes/InstallProgress.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
margin: 0;
padding: 0;

background-image: linear-gradient(to bottom, #7c7c7c, #fff);
background-color: #1f2120;

.logo {
width: 75%;
width: 50%;

margin: 4% 12.5%;
margin: 4% 25%;
border-radius: 8px;
}

Expand All @@ -27,10 +27,11 @@
}

.action {
border: none;
border: 2px solid #3c3c3e;
border-radius: 4px;
background-color: #bcbfbc;
background-color: transparent;

color: #dddfdc;
font-family: "manteka", serif;

width: 10%;
Expand All @@ -42,8 +43,7 @@
transition: color 0.5s ease, background-color 0.5s ease;

&:hover {
color: #dddfdc;
background-color: #3a3c3f;
background-color: #3c3c3e;
}
}
}
60 changes: 4 additions & 56 deletions app/src/routes/InstallProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,9 @@ import "./InstallProgress.scss";
import banner from "../assets/background_banner.png";
import { useState } from "preact/hooks";
import { invoke_proxy } from "../invoke";
import { FunctionalComponent } from "preact";
import { route } from "preact-router";

export enum InstallKind {
// eslint-disable-next-line no-unused-vars
BepInEx,

// eslint-disable-next-line no-unused-vars
Doorstop,
}

export enum InstallAction {
// eslint-disable-next-line no-unused-vars
Install,

// eslint-disable-next-line no-unused-vars
Uninstall,
}

export interface InstallProgressProps {
kind: InstallKind;
action: InstallAction;
}

export const InstallProgress: FunctionalComponent<InstallProgressProps> = ({
kind,
action,
}) => {
export const InstallProgress = () => {
const [status, setStatus] = useState({
percent: "0%",
message: "Waiting for start button...",
Expand All @@ -54,11 +29,7 @@ export const InstallProgress: FunctionalComponent<InstallProgressProps> = ({
const doInstall = async (): Promise<Error | null> => {
setStatus({ percent: "50%", message: "Installing SpaceWarp..." });

const res = await invoke_proxy(
kind == InstallKind.BepInEx
? "download_bepinex"
: "download_doorstop"
);
const res = await invoke_proxy("download_bepinex");

if (res == "Success") {
return null;
Expand All @@ -67,22 +38,6 @@ export const InstallProgress: FunctionalComponent<InstallProgressProps> = ({
return new Error(`Could not install SpaceWarp! More details: ${res}`);
};

const doUninstall = async (): Promise<Error | null> => {
setStatus({ percent: "50%", message: "Uninstalling SpaceWarp..." });

const res = await invoke_proxy(
kind == InstallKind.BepInEx
? "uninstall_bepinex"
: "uninstall_doorstop"
);

if (res == "Success") {
return null;
}

return new Error(`Could not uninstall SpaceWarp! More details: ${res}`);
};

const beginSetup = async () => {
let err = await getInstallDir();

Expand All @@ -91,13 +46,7 @@ export const InstallProgress: FunctionalComponent<InstallProgressProps> = ({
return;
}

if (action == InstallAction.Install) err = await doInstall();
else err = await doUninstall();

if (err) {
setStatus({ ...status, message: err.message });
return;
}
await doInstall();

setStatus({ percent: "100%", message: "Done!" });
setInstalled(true);
Expand All @@ -114,8 +63,7 @@ export const InstallProgress: FunctionalComponent<InstallProgressProps> = ({
<br />

<h1 className="title">
Installing SpaceWarp (
{kind == InstallKind.Doorstop ? "Standalone" : "BepInEx"})...
Installing SpaceWarp...
</h1>

<p className="progress">
Expand Down
18 changes: 0 additions & 18 deletions app/src/routes/InstallProgressWrapper.tsx

This file was deleted.

0 comments on commit b7e4ad8

Please sign in to comment.