diff --git a/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx b/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx index 0d5b549f3..315be12eb 100644 --- a/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx +++ b/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx @@ -18,8 +18,8 @@ import { useModalControlContext } from "@/ui/ModalContext" import { usePanelControlContext } from "@/ui/PanelContext" import { Box } from "@mui/material" import { useEffect, useReducer } from "react" -import { ConfigurationType, setSelectedConfigurationType } from "./assembly-config/ConfigurePanel" import { setSelectedScheme } from "./assembly-config/interfaces/inputs/ConfigureInputsInterface" +import { ConfigurationType, setSelectedConfigurationType } from "./assembly-config/ConfigurationType" /** We store the selected brain index globally to specify which robot the input scheme should be bound to. */ let selectedBrainIndexGlobal: number | undefined = undefined diff --git a/fission/src/ui/panels/configuring/assembly-config/ConfigurationSavedEvent.ts b/fission/src/ui/panels/configuring/assembly-config/ConfigurationSavedEvent.ts new file mode 100644 index 000000000..00758981a --- /dev/null +++ b/fission/src/ui/panels/configuring/assembly-config/ConfigurationSavedEvent.ts @@ -0,0 +1,16 @@ +/** An event to save whatever configuration interface is open when it is closed */ +export class ConfigurationSavedEvent extends Event { + public constructor() { + super("ConfigurationSaved") + + window.dispatchEvent(this) + } + + public static Listen(func: (e: Event) => void) { + window.addEventListener("ConfigurationSaved", func) + } + + public static RemoveListener(func: (e: Event) => void) { + window.removeEventListener("ConfigurationSaved", func) + } +} \ No newline at end of file diff --git a/fission/src/ui/panels/configuring/assembly-config/ConfigurationType.ts b/fission/src/ui/panels/configuring/assembly-config/ConfigurationType.ts new file mode 100644 index 000000000..a3f2345a3 --- /dev/null +++ b/fission/src/ui/panels/configuring/assembly-config/ConfigurationType.ts @@ -0,0 +1,16 @@ +// eslint-disable-next-line react-refresh/only-export-components +export enum ConfigurationType { + ROBOT, + FIELD, + INPUTS, +} + +let selectedConfigurationType: ConfigurationType = ConfigurationType.ROBOT +// eslint-disable-next-line react-refresh/only-export-components +export function setSelectedConfigurationType(type: ConfigurationType) { + selectedConfigurationType = type +} + +export function getConfigurationType() { + return selectedConfigurationType +} \ No newline at end of file diff --git a/fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx b/fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx index b1b2f2d94..8624e5cae 100644 --- a/fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx @@ -6,19 +6,21 @@ import Panel, { PanelPropsImpl } from "@/ui/components/Panel" import SelectMenu, { SelectMenuOption } from "@/ui/components/SelectMenu" import { ToggleButton, ToggleButtonGroup } from "@/ui/components/ToggleButtonGroup" import { useEffect, useMemo, useReducer, useState } from "react" -// import ConfigureScoringZonesInterface from "./interfaces/scoring/ConfigureScoringZonesInterface" -// import ChangeInputsInterface from "./interfaces/inputs/ConfigureInputsInterface" +import ConfigureScoringZonesInterface from "./interfaces/scoring/ConfigureScoringZonesInterface" +import ChangeInputsInterface from "./interfaces/inputs/ConfigureInputsInterface" import InputSystem from "@/systems/input/InputSystem" import SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain" import { usePanelControlContext } from "@/ui/PanelContext" import Button from "@/ui/components/Button" -// import { setSelectedBrainIndexGlobal } from "../ChooseInputSchemePanel" -// import ConfigureSchemeInterface from "./interfaces/inputs/ConfigureSchemeInterface" +import { setSelectedBrainIndexGlobal } from "../ChooseInputSchemePanel" +import ConfigureSchemeInterface from "./interfaces/inputs/ConfigureSchemeInterface" import { SynthesisIcons } from "@/ui/components/StyledComponents" -// import ConfigureSubsystemsInterface from "./interfaces/ConfigureSubsystemsInterface" -// import SequentialBehaviorsInterface from "./interfaces/SequentialBehaviorsInterface" -// import ConfigureShotTrajectoryInterface from "./interfaces/ConfigureShotTrajectoryInterface" +import ConfigureSubsystemsInterface from "./interfaces/ConfigureSubsystemsInterface" +import SequentialBehaviorsInterface from "./interfaces/SequentialBehaviorsInterface" +import ConfigureShotTrajectoryInterface from "./interfaces/ConfigureShotTrajectoryInterface" import ConfigureGamepiecePickupInterface from "./interfaces/ConfigureGamepiecePickupInterface" +import { ConfigurationSavedEvent } from "./ConfigurationSavedEvent" +import { ConfigurationType, getConfigurationType, setSelectedConfigurationType } from "./ConfigurationType" enum ConfigMode { SUBSYSTEMS, @@ -29,23 +31,6 @@ enum ConfigMode { SCORING_ZONES, } -// eslint-disable-next-line react-refresh/only-export-components -export enum ConfigurationType { - ROBOT, - FIELD, - INPUTS, -} - -let selectedConfigurationType: ConfigurationType = ConfigurationType.ROBOT -// eslint-disable-next-line react-refresh/only-export-components -export function setSelectedConfigurationType(type: ConfigurationType) { - selectedConfigurationType = type -} - -function getConfigurationType() { - return selectedConfigurationType -} - /** Option for selecting a robot of field */ class AssemblySelectionOption extends SelectMenuOption { assemblyObject: MirabufSceneObject @@ -173,60 +158,43 @@ const ConfigInterface: React.FC = ({ configMode, assembly, switch (configMode) { case ConfigMode.INTAKE: return - // case ConfigMode.EJECTOR: - // return - // case ConfigMode.SUBSYSTEMS: - // return - // case ConfigMode.CONTROLS: { - // const brainIndex = (assembly.brain as SynthesisBrain).brainIndex - // const scheme = InputSystem.brainIndexSchemeMap.get(brainIndex) + case ConfigMode.EJECTOR: + return + case ConfigMode.SUBSYSTEMS: + return + case ConfigMode.CONTROLS: { + const brainIndex = (assembly.brain as SynthesisBrain).brainIndex + const scheme = InputSystem.brainIndexSchemeMap.get(brainIndex) - // return ( - // <> - //