From 9ba2db43edb63ce15124c1c9193aabc554b7f1e3 Mon Sep 17 00:00:00 2001 From: SimonShiki Date: Thu, 2 Nov 2023 15:24:21 +0000 Subject: [PATCH] :sparkles: feat: add settings page Signed-off-by: SimonShiki --- src/App.tsx | 17 +++-- src/home.tsx | 96 +++++++++++++-------------- src/settings.tsx | 168 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+), 53 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 07df7a6..3565577 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,7 @@ import Navigation from './navigation'; import Enabled from './enabled'; import Home from './home'; +import Settings from './settings'; import Gallary from './gallary'; import { createSignal, createEffect, onMount, Show } from 'solid-js'; @@ -10,9 +11,9 @@ export interface ExtensionInfo { } export interface SettingsInfo { - core: boolean; - patchRegisterExtensionPrimitives: boolean; - noPrompt: boolean; + convertProcCall: boolean; + dontExposeCtx: boolean; + noConfirmDialog: boolean; } export interface ClientInfo { @@ -99,6 +100,9 @@ function App () { navigateTo={navigateTo} />
+ + + - - + +
diff --git a/src/home.tsx b/src/home.tsx index 028551b..9541696 100644 --- a/src/home.tsx +++ b/src/home.tsx @@ -47,47 +47,47 @@ function Home () { alignItems: 'center', textAlign: 'center' }}> - + Load ANY Scratch extensions in ANY Scratch-based editors. - - + + Chibi loads extensions by directly injecting them into the Scratch virtual machine, which allows you to use your favorite extensions without being restricted by the editor itself. - - - - + + + - - - + + - - - + + - - - + + - - + + - + Write once, Run everywhere - - + + Chibi implements the loader independently, which means extensions have a unified implementation standard rather rely on the editor. - - - + + - + - + Compatible with most popular extension loading methods - - + + Chibi adds support for non-sandbox extensions and TurboWarp extensions. This means you can seamlessly sideload these extensions into your projects. - + ); diff --git a/src/settings.tsx b/src/settings.tsx index e69de29..0660905 100644 --- a/src/settings.tsx +++ b/src/settings.tsx @@ -0,0 +1,168 @@ +import { + Stack, + Card, + Box, + Switch, + Divider, + Typography +} from '@suid/material'; +import { createSignal, Show } from 'solid-js'; +import type { SettingsInfo, ClientInfo } from './App'; + +interface SettingsProps { + clientInfo(): ClientInfo | null; + settings(): Partial; +} + +function Settings (props: SettingsProps) { + return ( + + + + Project + + + + } + > + + + Convert Sideload Extension's Blocks Into Procedures Call + + {`Required Chibi >= 5`} + + + { + window.opener.postMessage({ + type: 'updateSettings', + item: { + name: 'convertProcCall', + value: value + } + }, '*'); + }} + disabled={!props.clientInfo() || props.clientInfo()!.version < 5} + /> + + + + + + + + Extension + + + + } + > + + + Don't Expose "Scratch" Object Globally + + {`Required Chibi >= 5`} + + + { + window.opener.postMessage({ + type: 'updateSettings', + item: { + name: 'dontExposeCtx', + value: value + } + }, '*'); + }} + disabled={!props.clientInfo() || props.clientInfo()!.version < 5} + /> + + + + No Confirmation Dialog While Loading Project + + {`Required Chibi >= 5`} + + + { + window.opener.postMessage({ + type: 'updateSettings', + item: { + name: 'noConfirmDialog', + value: value + } + }, '*'); + }} + disabled={!props.clientInfo() || props.clientInfo()!.version < 5} + /> + + + + Load From Gallery's Extensions Only + + {`Required Chibi >= 6`} + + + + + + + + + + ); +} + +export default Settings;