diff --git a/src/Programs/ui/ProgramsRoot.tsx b/src/Programs/ui/ProgramsRoot.tsx index b203a3490..9ac85a80d 100644 --- a/src/Programs/ui/ProgramsRoot.tsx +++ b/src/Programs/ui/ProgramsRoot.tsx @@ -28,24 +28,28 @@ export function ProgramsRoot(): React.ReactElement { at any time. Your progress will be saved and you can continue later. - - {getAvailableCreatePrograms(player).map((program) => { - const create = program.create; - if (create === null) return <>; - return ( - + {getAvailableCreatePrograms(player).map((program) => { + const create = program.create; + if (create === null) return <>; + + return ( + + - ); - })} - +
+ + ); + })} ); diff --git a/src/ScriptEditor/ui/OptionsModal.tsx b/src/ScriptEditor/ui/OptionsModal.tsx new file mode 100644 index 000000000..7cd84b59b --- /dev/null +++ b/src/ScriptEditor/ui/OptionsModal.tsx @@ -0,0 +1,56 @@ +import React, { useState } from "react"; +import { Options } from "./Options"; +import { StdButton } from "../../ui/React/StdButton"; +import { removePopup } from "../../ui/React/createPopup"; +import { Modal } from "../../ui/React/Modal"; + +import Button from "@mui/material/Button"; +import Box from "@mui/material/Box"; +import Typography from "@mui/material/Typography"; +import Select from "@mui/material/Select"; +import Switch from "@mui/material/Switch"; +import MenuItem from "@mui/material/MenuItem"; + +interface IProps { + options: Options; + save: (options: Options) => void; + onClose: () => void; + open: boolean; +} + +export function OptionsModal(props: IProps): React.ReactElement { + const [theme, setTheme] = useState(props.options.theme); + const [insertSpaces, setInsertSpaces] = useState(props.options.insertSpaces); + + function save(): void { + props.save({ + theme: theme, + insertSpaces: insertSpaces, + }); + props.onClose(); + } + + return ( + + + Theme: + + + + + Use whitespace over tabs: + setInsertSpaces(event.target.checked)} checked={insertSpaces} /> + +
+ +
+ ); +} diff --git a/src/ScriptEditor/ui/OptionsPopup.tsx b/src/ScriptEditor/ui/OptionsPopup.tsx deleted file mode 100644 index 1ba843cc5..000000000 --- a/src/ScriptEditor/ui/OptionsPopup.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React, { useState } from "react"; -import { Options } from "./Options"; -import { StdButton } from "../../ui/React/StdButton"; -import { removePopup } from "../../ui/React/createPopup"; - -interface IProps { - id: string; - options: Options; - save: (options: Options) => void; -} - -export function OptionsPopup(props: IProps): React.ReactElement { - const [theme, setTheme] = useState(props.options.theme); - const [insertSpaces, setInsertSpaces] = useState(props.options.insertSpaces); - - function save(): void { - props.save({ - theme: theme, - insertSpaces: insertSpaces, - }); - removePopup(props.id); - } - - return ( -
-
-

Theme:

- -
-
-

Use whitespace over tabs:

- setInsertSpaces(event.target.checked)} checked={insertSpaces} /> -
-
- -
- ); -} diff --git a/src/ScriptEditor/ui/Root.tsx b/src/ScriptEditor/ui/Root.tsx index 25450dd60..de1318a1e 100644 --- a/src/ScriptEditor/ui/Root.tsx +++ b/src/ScriptEditor/ui/Root.tsx @@ -4,7 +4,7 @@ import Editor from "@monaco-editor/react"; import * as monaco from "monaco-editor"; type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor; import { createPopup } from "../../ui/React/createPopup"; -import { OptionsPopup } from "./OptionsPopup"; +import { OptionsModal } from "./OptionsModal"; import { Options } from "./Options"; import { js_beautify as beautifyCode } from "js-beautify"; import { isValidFilePath } from "../../Terminal/DirectoryHelpers"; @@ -24,6 +24,14 @@ import { WorkerScript } from "../../Netscript/WorkerScript"; import { Settings } from "../../Settings/Settings"; import { iTutorialNextStep, ITutorial, iTutorialSteps } from "../../InteractiveTutorial"; +import Button from "@mui/material/Button"; +import Typography from "@mui/material/Typography"; +import Link from "@mui/material/Link"; +import Box from "@mui/material/Box"; +import TextField from "@mui/material/TextField"; +import IconButton from "@mui/material/IconButton"; +import SettingsIcon from "@mui/icons-material/Settings"; + let loaded = false; let symbols: string[] = []; (function () { @@ -78,6 +86,7 @@ export function Root(props: IProps): React.ReactElement { const [filename, setFilename] = useState(props.filename ? props.filename : lastFilename); const [code, setCode] = useState(props.filename ? props.code : lastCode); const [ram, setRAM] = useState("RAM: ???"); + const [optionsOpen, setOptionsOpen] = useState(false); const [options, setOptions] = useState({ theme: Settings.MonacoTheme, insertSpaces: Settings.MonacoInsertSpaces, @@ -198,24 +207,6 @@ export function Root(props: IProps): React.ReactElement { setFilename(event.target.value); } - function openOptions(): void { - const id = "script-editor-options-popup"; - const newOptions = { - theme: "", - insertSpaces: false, - }; - Object.assign(newOptions, options); - createPopup(id, OptionsPopup, { - id: id, - options: newOptions, - save: (options: Options) => { - setOptions(options); - Settings.MonacoTheme = options.theme; - Settings.MonacoInsertSpaces = options.insertSpaces; - }, - }); - } - function updateCode(newCode?: string): void { if (newCode === undefined) return; lastCode = newCode; @@ -307,21 +298,16 @@ export function Root(props: IProps): React.ReactElement { return ( <> -
-

- {" "} - Script name: -

- - -
+ + Script name: + + setOptionsOpen(true)}> + <> + + options + + + - + + + setOptionsOpen(false)} + options={{ + theme: Settings.MonacoTheme, + insertSpaces: Settings.MonacoInsertSpaces, + }} + save={(options: Options) => { + setOptions(options); + Settings.MonacoTheme = options.theme; + Settings.MonacoInsertSpaces = options.insertSpaces; + }} + /> ); }