diff --git a/fission/src/ui/modals/configuring/theme-editor/AssignNewSchemeModal.tsx b/fission/src/ui/modals/configuring/theme-editor/AssignNewSchemeModal.tsx index 1f5c98bd2..668590791 100644 --- a/fission/src/ui/modals/configuring/theme-editor/AssignNewSchemeModal.tsx +++ b/fission/src/ui/modals/configuring/theme-editor/AssignNewSchemeModal.tsx @@ -6,8 +6,11 @@ import InputSystem from "@/systems/input/InputSystem" import SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain" import { SynthesisIcons } from "@/ui/components/StyledComponents" import { usePanelControlContext } from "@/ui/PanelContext" -import { ConfigurationType, setSelectedConfigurationType } from "@/ui/panels/configuring/assembly-config/ConfigurePanel" import { setSelectedScheme } from "@/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface" +import { + setSelectedConfigurationType, + ConfigurationType, +} from "@/ui/panels/configuring/assembly-config/ConfigurationType" const AssignNewSchemeModal: React.FC = ({ modalId }) => { const { openPanel } = usePanelControlContext() diff --git a/fission/src/ui/modals/configuring/theme-editor/NewInputSchemeModal.tsx b/fission/src/ui/modals/configuring/theme-editor/NewInputSchemeModal.tsx index 06b95d7a1..acbce6b5e 100644 --- a/fission/src/ui/modals/configuring/theme-editor/NewInputSchemeModal.tsx +++ b/fission/src/ui/modals/configuring/theme-editor/NewInputSchemeModal.tsx @@ -5,8 +5,11 @@ import InputSchemeManager from "@/systems/input/InputSchemeManager" import DefaultInputs from "@/systems/input/DefaultInputs" import { SynthesisIcons } from "@/ui/components/StyledComponents" import { usePanelControlContext } from "@/ui/PanelContext" -import { ConfigurationType, setSelectedConfigurationType } from "@/ui/panels/configuring/assembly-config/ConfigurePanel" import { setSelectedScheme } from "@/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface" +import { + ConfigurationType, + setSelectedConfigurationType, +} from "@/ui/panels/configuring/assembly-config/ConfigurationType" const NewInputSchemeModal: React.FC = ({ modalId }) => { const { openPanel } = usePanelControlContext() 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..9f240286f --- /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) + } +} 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..927beac56 --- /dev/null +++ b/fission/src/ui/panels/configuring/assembly-config/ConfigurationType.ts @@ -0,0 +1,15 @@ +export enum ConfigurationType { + ROBOT, + FIELD, + INPUTS, +} + +let selectedConfigurationType: ConfigurationType = ConfigurationType.ROBOT + +export function setSelectedConfigurationType(type: ConfigurationType) { + selectedConfigurationType = type +} + +export function getConfigurationType() { + return selectedConfigurationType +} diff --git a/fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx b/fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx index 9dbdb7e07..0c261a96f 100644 --- a/fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx @@ -19,6 +19,8 @@ import ConfigureSubsystemsInterface from "./interfaces/ConfigureSubsystemsInterf 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 @@ -125,7 +110,7 @@ class ConfigModeSelectionOption extends SelectMenuOption { } } -const robotModes = [ +const robotModes: ConfigModeSelectionOption[] = [ new ConfigModeSelectionOption("Intake", ConfigMode.INTAKE), new ConfigModeSelectionOption("Ejector", ConfigMode.EJECTOR), new ConfigModeSelectionOption( @@ -140,7 +125,9 @@ const robotModes = [ ), new ConfigModeSelectionOption("Controls", ConfigMode.CONTROLS), ] -const fieldModes = [new ConfigModeSelectionOption("Scoring Zones", ConfigMode.SCORING_ZONES)] +const fieldModes: ConfigModeSelectionOption[] = [ + new ConfigModeSelectionOption("Scoring Zones", ConfigMode.SCORING_ZONES), +] interface ConfigModeSelectionProps { configurationType: ConfigurationType @@ -207,23 +194,6 @@ const ConfigInterface: React.FC = ({ configMode, assembly, } } -/** 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) - } -} - const ConfigurePanel: React.FC = ({ panelId }) => { const { openPanel, closePanel } = usePanelControlContext() const [configurationType, setConfigurationType] = useState(getConfigurationType()) diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureGamepiecePickupInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureGamepiecePickupInterface.tsx index 0e7dea833..f15c2361a 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureGamepiecePickupInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureGamepiecePickupInterface.tsx @@ -15,9 +15,9 @@ import { ThreeMatrix4_Array, } from "@/util/TypeConversions" import { useTheme } from "@/ui/ThemeContext" -import { ConfigurationSavedEvent } from "../ConfigurePanel" import Button from "@/ui/components/Button" import { Spacer } from "@/ui/components/StyledComponents" +import { ConfigurationSavedEvent } from "../ConfigurationSavedEvent" // slider constants const MIN_ZONE_SIZE = 0.1 diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureShotTrajectoryInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureShotTrajectoryInterface.tsx index f5293e93c..74bd39db7 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureShotTrajectoryInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureShotTrajectoryInterface.tsx @@ -15,7 +15,7 @@ import { } from "@/util/TypeConversions" import { useTheme } from "@/ui/ThemeContext" import { RigidNodeId } from "@/mirabuf/MirabufParser" -import { ConfigurationSavedEvent } from "../ConfigurePanel" +import { ConfigurationSavedEvent } from "../ConfigurationSavedEvent" import Button from "@/ui/components/Button" import { Spacer } from "@/ui/components/StyledComponents" diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureSubsystemsInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureSubsystemsInterface.tsx index d2e98e94d..c034a446c 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureSubsystemsInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureSubsystemsInterface.tsx @@ -1,7 +1,7 @@ import MirabufSceneObject from "@/mirabuf/MirabufSceneObject" import SelectMenu, { SelectMenuOption } from "@/ui/components/SelectMenu" import React, { useMemo, useState } from "react" -import { ConfigurationSavedEvent } from "../ConfigurePanel" +import { ConfigurationSavedEvent } from "../ConfigurationSavedEvent" import World from "@/systems/World" import SliderDriver from "@/systems/simulation/driver/SliderDriver" import HingeDriver from "@/systems/simulation/driver/HingeDriver" diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/SequentialBehaviorsInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/SequentialBehaviorsInterface.tsx index bec98015d..575dc60db 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/SequentialBehaviorsInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/SequentialBehaviorsInterface.tsx @@ -8,7 +8,7 @@ import PreferencesSystem from "@/systems/preferences/PreferencesSystem" import SequenceableBehavior from "@/systems/simulation/behavior/synthesis/SequenceableBehavior" import GenericArmBehavior from "@/systems/simulation/behavior/synthesis/GenericArmBehavior" import SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain" -import { ConfigurationSavedEvent } from "../ConfigurePanel" +import { ConfigurationSavedEvent } from "../ConfigurationSavedEvent" import { SectionLabel, Spacer, SynthesisIcons } from "@/ui/components/StyledComponents" /** Grey label for a child behavior name */ diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface.tsx index 175bca83a..defb46722 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureInputsInterface.tsx @@ -1,5 +1,5 @@ import { useCallback, useEffect, useState } from "react" -import { ConfigurationSavedEvent } from "../../ConfigurePanel" +import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent" import SelectMenu, { SelectMenuOption } from "@/ui/components/SelectMenu" import InputSystem from "@/systems/input/InputSystem" import InputSchemeManager, { InputScheme } from "@/systems/input/InputSchemeManager" diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureSchemeInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureSchemeInterface.tsx index 220191cab..608aa1571 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureSchemeInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/inputs/ConfigureSchemeInterface.tsx @@ -2,7 +2,7 @@ import InputSchemeManager, { InputScheme } from "@/systems/input/InputSchemeMana import Checkbox from "@/ui/components/Checkbox" import EditInputInterface from "./EditInputInterface" import { useCallback, useEffect, useRef, useState } from "react" -import { ConfigurationSavedEvent } from "../../ConfigurePanel" +import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent" import { SectionDivider } from "@/ui/components/StyledComponents" interface ConfigSchemeProps { diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ConfigureScoringZonesInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ConfigureScoringZonesInterface.tsx index 069c287f7..12801b04e 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ConfigureScoringZonesInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ConfigureScoringZonesInterface.tsx @@ -7,7 +7,7 @@ import PreferencesSystem from "@/systems/preferences/PreferencesSystem" import { Box } from "@mui/material" import { ButtonIcon, SectionDivider, SectionLabel, SynthesisIcons } from "@/ui/components/StyledComponents" import { LabelSize } from "@/ui/components/Label" -import { ConfigurationSavedEvent } from "../../ConfigurePanel" +import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent" const saveZones = (zones: ScoringZonePreferences[] | undefined, field: MirabufSceneObject | undefined) => { if (!zones || !field) return diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ManageZonesInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ManageZonesInterface.tsx index a051cc112..ab9f47d6b 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ManageZonesInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ManageZonesInterface.tsx @@ -7,7 +7,7 @@ import PreferencesSystem from "@/systems/preferences/PreferencesSystem" import World from "@/systems/World" import MirabufSceneObject from "@/mirabuf/MirabufSceneObject" import { Box } from "@mui/material" -import { ConfigurationSavedEvent } from "../../ConfigurePanel" +import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent" import { AddButtonInteractiveColor, DeleteButton, EditButton } from "@/ui/components/StyledComponents" const saveZones = (zones: ScoringZonePreferences[] | undefined, field: MirabufSceneObject | undefined) => { diff --git a/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ZoneConfigInterface.tsx b/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ZoneConfigInterface.tsx index 409daeece..b6a375caa 100644 --- a/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ZoneConfigInterface.tsx +++ b/fission/src/ui/panels/configuring/assembly-config/interfaces/scoring/ZoneConfigInterface.tsx @@ -16,7 +16,7 @@ import { ToggleButton, ToggleButtonGroup } from "@/ui/components/ToggleButtonGro import { Alliance, ScoringZonePreferences } from "@/systems/preferences/PreferenceTypes" import { RigidNodeId } from "@/mirabuf/MirabufParser" import { DeltaFieldTransforms_PhysicalProp as DeltaFieldTransforms_VisualProperties } from "@/util/threejs/MeshCreation" -import { ConfigurationSavedEvent } from "../../ConfigurePanel" +import { ConfigurationSavedEvent } from "../../ConfigurationSavedEvent" /** * Saves ejector configuration to selected field.