diff --git a/src/DevMenu/ui/SourceFilesDev.tsx b/src/DevMenu/ui/SourceFilesDev.tsx index bc75cb288..d24a85f6a 100644 --- a/src/DevMenu/ui/SourceFilesDev.tsx +++ b/src/DevMenu/ui/SourceFilesDev.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; import Accordion from "@mui/material/Accordion"; import AccordionSummary from "@mui/material/AccordionSummary"; @@ -12,8 +12,11 @@ import ButtonGroup from "@mui/material/ButtonGroup"; // Update as additional BitNodes get implemented const validSFN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]; +const initialState = validSFN.reduce((obj, sfN) => ({ ...obj, [sfN]: "" }), { "": "" }); export function SourceFilesDev(): React.ReactElement { + const [sfData, setSfData] = useState(initialState); + function setSF(sfN: number, sfLvl: number) { return function () { if (sfN === 9) { @@ -21,9 +24,11 @@ export function SourceFilesDev(): React.ReactElement { } if (sfLvl === 0) { Player.sourceFiles.delete(sfN); + setSfData({ ...sfData, [sfN]: sfLvl }); return; } Player.sourceFiles.set(sfN, sfLvl); + setSfData({ ...sfData, [sfN]: sfLvl }); }; } @@ -39,6 +44,25 @@ export function SourceFilesDev(): React.ReactElement { Player.exploits = []; } + const setallButtonStyle = { borderColor: "", background: "black" }; + const ownedStyle = { borderColor: "green", background: "" }; + const notOwnedStyle = { borderColor: "", background: "black" }; + + const devLvls = [0, 1, 2, 3]; + + const buttonGroup = (sfN?: number) => + devLvls.map((lvl) => { + return ( + + ); + }); + return ( }> @@ -57,37 +81,19 @@ export function SourceFilesDev(): React.ReactElement { - All: + Set All: - - - - - - + {buttonGroup()} - {validSFN.map((i) => ( - + {validSFN.map((sfN) => ( + - SF-{i}: + SF-{sfN}: - - - - - - + {buttonGroup(sfN)} ))}