Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSSLoader Desktop 1.2.1 - Move to org and misc fix #29

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 47 additions & 81 deletions pages/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AlertDialog, LabelledInput, Tooltip } from "@components/Primitives";
import { AlertDialog, LabelledInput, ToggleSwitch, Tooltip } from "@components/Primitives";
import { killBackend, startBackend, storeRead, storeWrite, toast } from "backend";
import { useState, useEffect, useContext } from "react";
import { AiOutlineQuestionCircle } from "react-icons/ai";
Expand All @@ -12,13 +12,37 @@ import { fetch, Body } from "@tauri-apps/api/http";

export default function SettingsPage() {
const [token, setToken] = useState<string>("");
const [betaTranslationsState, setBetaTranslationsState] = useState<boolean>(false);

async function fetchToken() {
const res = await storeRead("shortToken");
if (res.success && res.result) {
setToken(res.result);
}
}

async function fetchBetaTranslationsState() {
const res = await storeRead("beta_translations");
if (res.success && res.result) {
setBetaTranslationsState(res.result === "1" ? true : false);
}
}

async function updateBetaTranslations(value: boolean) {
setOngoingAction(true);
const res = await storeWrite("beta_translations", value ? "1" : "0");
setOngoingAction(false);
if (!res.success) {
toast("Error Updating Beta Translations State");
return;
}
toast("Changes will apply after a restart.");
void fetchBetaTranslationsState();
}

useEffect(() => {
storeRead("shortToken").then((res) => {
if (res.success && res.result) {
setToken(res.result);
}
});
void fetchToken();
void fetchBetaTranslationsState();
}, []);

const { refreshThemes } = useContext(themeContext);
Expand Down Expand Up @@ -101,6 +125,22 @@ export default function SettingsPage() {
</button>
</div>
</div>
<div className="flex w-full flex-col gap-4">
<span className="text-lg font-bold">CSSLoader Settings</span>
<div className="flex w-full items-center justify-center rounded-xl border-2 border-borders-base1-dark p-6 transition hover:border-borders-base2-dark dark:bg-base-3-dark">
<div className="flex flex-col">
<span className="text-md font-bold">Enable Beta Steam CSS Translations</span>
<span className="text-sm">Enable this if you are on Steam Client Beta</span>
</div>
<div className="ml-auto flex items-center">
<ToggleSwitch
checked={betaTranslationsState}
disabled={ongoingAction}
onChange={updateBetaTranslations}
/>
</div>
</div>
</div>
<div className="flex w-full flex-col gap-4">
<span className="text-lg font-bold">Developer Settings</span>
<CreateTemplateTheme {...{ ongoingAction }} />
Expand Down Expand Up @@ -143,90 +183,16 @@ export default function SettingsPage() {
>
Open Backend Location
</button>
{/* <AlertDialog
cancelText="Go Back"
title="Wait A Second!"
description="This feature is meant for developers. If you do not understand exactly what you're doing, cancel this popup. Do not install files from untrusted sources."
actionText="I Know What I'm Doing"
actionClass="bg-dangerRed"
onAction={() => {
open({
directory: false,
multiple: false,
filters: [
{
name: "CSSLoader-Standalone-Headless.exe",
extensions: ["exe"],
},
],
// @ts-ignore
}).then(async (path: string) => {
if (!path) {
toast("Invalid Selection");
return;
}
setOngoingAction(true);
setInstallModalDesc("Installing " + path.slice(path.lastIndexOf("\\") + 1));
// TODO: This function assumes each function never fails, add some failsafes/error messages
setShowBackendInstallModal(true);
setInstallText("Stopping Backend");
await killBackend();
await sleep(2000);
setInstallText("Installing New Backend");
await copyBackend(path);
setInstallText("Pausing To Allow Windows To Figure Itself Out");
await startBackend();
await sleep(10000);
await startBackend();
setOngoingAction(false);
setShowBackendInstallModal(false);
setInstallModalDesc("");
refreshThemes();
});
}}
Trigger={
<>
<button
disabled={ongoingAction}
className="flex h-12 w-full items-center justify-center whitespace-nowrap rounded-xl bg-base-3-dark px-4"
>
{ongoingAction ? <ImSpinner5 /> : "Install Backend From File"}
</button>
</>
}
/>
{showBackendInstallModal && (
<GenericInstallBackendModal
titleText="Installed Backend From File"
descriptionText={installModalDesc}
installProg={1}
installText={installText}
dontClose
/>
)} */}
</>
)}
{/* This was a WIP thing that would print out the current app state to a txt file, doesn't seem needed */}
{/* <button
onClick={async () => {
console.log("Themes", themes);
console.log(
"Highest Support Manifest Version",
await getBackendVersion().then((res) => res.result)
);
console.log("AppData's Stored Standalone Version", await getStandaloneVersion());
}}
className="h-12 whitespace-nowrap rounded-xl bg-base-3-dark px-4"
>
Data Dump
</button> */}
</div>
<div className="flex w-full flex-col gap-4">
<span className="text-lg font-bold">Credits</span>
<ul>
<li>SuchMemeManySkill - Backend Dev</li>
<li>Beebles - Frontend Dev</li>
<li>Fero - Frontend Dev</li>
<li>Emerald - Frontend Dev</li>
</ul>
<div className="flex w-full flex-col items-start pb-8">
<button
Expand Down
Loading