Skip to content

Commit d24e878

Browse files
committed
fix: removed configurationType from global state
instead pass as prop just like configType and selectedAssembly - not sure why it wasn't that way before. fixes field configuration issue
1 parent f0c20f9 commit d24e878

File tree

14 files changed

+41
-46
lines changed

14 files changed

+41
-46
lines changed

fission/src/systems/input/InputSchemeManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class InputSchemeManager {
126126
const conflictingSchemes = scheme.inputs.flatMap(input =>
127127
input.keysUsed.flatMap(key => usedKeyMap.get(key) ?? [])
128128
)
129-
console.log(conflictingSchemes)
129+
// console.log(conflictingSchemes)
130130
if (conflictingSchemes.length > 0) {
131131
result[scheme.schemeName] ??= {
132132
scheme,

fission/src/systems/scene/SceneRenderer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import GizmoSceneObject from "./GizmoSceneObject"
2121
import SceneObject from "./SceneObject"
2222
import ScreenInteractionHandler, { InteractionEnd } from "./ScreenInteractionHandler"
2323
import ImportMirabufPanel from "@/ui/panels/mirabuf/ImportMirabufPanel"
24+
import { ConfigurationType } from "@/ui/panels/configuring/assembly-config/ConfigTypes"
2425

2526
const CLEAR_COLOR = 0x121212
2627
const GROUND_COLOR = 0xfffef0
@@ -538,7 +539,7 @@ class SceneRenderer extends WorldSystem {
538539
miraSupplierData.items.push({
539540
name: "Add",
540541
func: () => {
541-
globalOpenPanel(ImportMirabufPanel, undefined)
542+
globalOpenPanel(ImportMirabufPanel, { configurationType: "ROBOTS" as ConfigurationType })
542543
},
543544
})
544545
}

fission/src/ui/StateProvider.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import type React from "react"
22
import { useMemo, useState } from "react"
33
import type { InputScheme } from "@/systems/input/InputTypes"
44
import { StateContext, type StateProviderProps } from "./helpers/StateProviderHelpers"
5-
import type { ConfigurationType } from "./panels/configuring/assembly-config/ConfigTypes"
65

76
export const StateProvider: React.FC<StateProviderProps> = ({ children }) => {
87
const [unconfirmedImport, setUnconfirmedImport] = useState<boolean>(false)
98
const [selectedScheme, setSelectedScheme] = useState<InputScheme | undefined>(undefined)
10-
const [configurationType, setConfigurationType] = useState<ConfigurationType>("ROBOTS")
119
const [isMainMenuOpen, setIsMainMenuOpen] = useState<boolean>(true)
1210

1311
const stateContextValue = useMemo(
@@ -16,12 +14,10 @@ export const StateProvider: React.FC<StateProviderProps> = ({ children }) => {
1614
setUnconfirmedImport,
1715
selectedScheme,
1816
setSelectedScheme,
19-
configurationType,
20-
setConfigurationType,
2117
isMainMenuOpen,
2218
setIsMainMenuOpen,
2319
}),
24-
[unconfirmedImport, selectedScheme, configurationType, isMainMenuOpen]
20+
[unconfirmedImport, selectedScheme, isMainMenuOpen]
2521
)
2622

2723
return <StateContext.Provider value={stateContextValue}>{children}</StateContext.Provider>

fission/src/ui/components/DragModeIndicator.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const DragModeIndicator: React.FC = () => {
99

1010
useEffect(() => {
1111
const handleDragModeToggle = (event: CustomEvent) => {
12-
console.log("toggled")
1312
setEnabled(event.detail.enabled)
1413
}
1514

fission/src/ui/components/MainHUD.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import DeveloperToolPanel from "../panels/DeveloperToolPanel"
2222
import MatchModeConfigPanel from "../panels/configuring/MatchModeConfigPanel"
2323
import MatchMode, { MatchStateChangeEvent } from "@/systems/match_mode/MatchMode"
2424
import { useThemeContext } from "../helpers/ThemeProviderHelpers"
25+
import { ConfigurationType } from "../panels/configuring/assembly-config/ConfigTypes"
2526

2627
type ButtonProps = {
2728
value: string
@@ -205,7 +206,7 @@ const MainHUD: React.FC = () => {
205206
value={"Spawn Asset"}
206207
icon={SynthesisIcons.ADD}
207208
larger={true}
208-
onClick={() => openPanel(ImportMirabufPanel, undefined)}
209+
onClick={() => openPanel(ImportMirabufPanel, { configurationType: "ROBOTS" as ConfigurationType })}
209210
/>
210211
<Stack direction="column" sx={{ borderRadius: "7px", padding: "4px" }} bgcolor="primary.main" gap={0.5}>
211212
<MainHUDButton

fission/src/ui/helpers/StateProviderHelpers.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { createContext, type ReactNode, useContext } from "react"
22
import type { InputScheme } from "@/systems/input/InputTypes"
3-
import type { ConfigurationType } from "../panels/configuring/assembly-config/ConfigTypes"
43

54
export interface StateProviderProps {
65
children: ReactNode
@@ -13,9 +12,6 @@ export interface AppState {
1312
// ConfigureInputs stuff
1413
selectedScheme?: InputScheme
1514
setSelectedScheme: (_scheme: InputScheme) => void
16-
// Configure Panel
17-
configurationType: ConfigurationType
18-
setConfigurationType: (_type: ConfigurationType) => void
1915
// View Cube
2016
isMainMenuOpen: boolean
2117
setIsMainMenuOpen: (_state: boolean) => void
@@ -26,8 +22,6 @@ export const StateContext = createContext<AppState>({
2622
setUnconfirmedImport: () => {},
2723
selectedScheme: undefined,
2824
setSelectedScheme: () => {},
29-
configurationType: "ROBOTS",
30-
setConfigurationType: () => {},
3125
isMainMenuOpen: true,
3226
setIsMainMenuOpen: () => {},
3327
})

fission/src/ui/modals/configuring/inputs/NewInputSchemeModal.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Stack } from "@mui/system"
1212

1313
const NewInputSchemeModal: React.FC<ModalImplProps<void, void>> = ({ modal }) => {
1414
const { openPanel, configureScreen } = useUIContext()
15-
const { setSelectedScheme, setConfigurationType } = useStateContext()
15+
const { setSelectedScheme } = useStateContext()
1616

1717
const [name, setName] = useState<string>(InputSchemeManager.randomAvailableName)
1818
const [type, setType] = useState<DriveType>(DriveType.ARCADE)
@@ -24,22 +24,21 @@ const NewInputSchemeModal: React.FC<ModalImplProps<void, void>> = ({ modal }) =>
2424

2525
InputSchemeManager.addCustomScheme(scheme)
2626
InputSchemeManager.saveSchemes()
27-
console.log(InputSchemeManager.allInputSchemes)
2827

29-
setConfigurationType("INPUTS")
3028
setSelectedScheme(scheme)
3129
openPanel(
3230
ConfigurePanel,
3331
{
3432
configMode: undefined,
3533
selectedAssembly: undefined,
34+
configurationType: "INPUTS",
3635
},
3736
modal,
3837
{ position: "left" }
3938
)
4039
}
4140
configureScreen(modal!, { title: "New Input Scheme", hideCancel: true }, { onBeforeAccept })
42-
}, [name, setConfigurationType, setSelectedScheme, openPanel, modal])
41+
}, [name, setSelectedScheme, openPanel, modal])
4342

4443
return (
4544
<>

fission/src/ui/modals/mirabuf/ImportLocalMirabufModal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import ImportMirabufPanel from "@/ui/panels/mirabuf/ImportMirabufPanel"
1010
import { CloseType, useUIContext } from "@/ui/helpers/UIProviderHelpers"
1111
import { Button, Stack, styled, ToggleButton, ToggleButtonGroup } from "@mui/material"
1212
import { type ChangeEvent, useEffect, useState } from "react"
13+
import { ConfigurationType } from "@/ui/panels/configuring/assembly-config/ConfigTypes"
1314

1415
const VisuallyHiddenInput = styled("input")({
1516
clip: "rect(0 0 0 0)",
@@ -38,7 +39,9 @@ const ImportLocalMirabufModal: React.FC<ModalImplProps<void, void>> = ({ modal }
3839
}
3940

4041
useEffect(() => {
41-
const onCancel = () => openPanel(ImportMirabufPanel, undefined, undefined)
42+
const onCancel = () => {
43+
openPanel(ImportMirabufPanel, { configurationType: "ROBOTS" as ConfigurationType })
44+
}
4245

4346
const onBeforeAccept = async () => {
4447
if (selectedFile && miraType !== undefined) {

fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import NewInputSchemeModal from "@/ui/modals/configuring/inputs/NewInputSchemeMo
1616

1717
const ChooseInputSchemePanel: React.FC<PanelImplProps<void, void>> = ({ panel }) => {
1818
const { openModal, openPanel, closePanel, configureScreen } = useUIContext()
19-
const { setSelectedScheme, setConfigurationType } = useStateContext()
19+
const { setSelectedScheme } = useStateContext()
2020

2121
const targetAssembly = useMemo(() => {
2222
const assembly = getSpotlightAssembly()
@@ -44,7 +44,6 @@ const ChooseInputSchemePanel: React.FC<PanelImplProps<void, void>> = ({ panel })
4444
if (scheme) {
4545
InputSystem.brainIndexSchemeMap.set(brainIndex, scheme)
4646
}
47-
setConfigurationType("INPUTS")
4847
if (scheme) setSelectedScheme(scheme)
4948
}
5049
}, [closePanel, targetAssembly])

fission/src/ui/panels/configuring/assembly-config/ConfigurePanel.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type { FieldPreferences, MotorPreferences, RobotPreferences } from "@/sys
1212
import type SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain"
1313
import World from "@/systems/World"
1414
import type { PanelImplProps } from "@/ui/components/Panel"
15-
import { useStateContext } from "@/ui/helpers/StateProviderHelpers"
1615
import { CloseType, useUIContext, type UIScreen } from "@/ui/helpers/UIProviderHelpers"
1716
import ChooseInputSchemePanel from "../ChooseInputSchemePanel"
1817
import AssemblySelection, { type AssemblySelectionOption } from "./configure/AssemblySelection"
@@ -31,12 +30,7 @@ import ConfigureScoringZonesInterface from "./interfaces/scoring/ConfigureScorin
3130
import Label from "@/ui/components/Label"
3231
import DrivetrainSelectionInterface from "./interfaces/DrivetrainSelectionInterface"
3332
import TransformGizmoControl from "@/ui/components/TransformGizmoControl"
34-
import { ConfigMode, CONFIG_OPTS } from "./ConfigTypes"
35-
36-
export interface ConfigurePanelSettings {
37-
configMode?: ConfigMode
38-
selectedAssembly: MirabufSceneObject
39-
}
33+
import { ConfigMode, CONFIG_OPTS, ConfigurationType } from "./ConfigTypes"
4034

4135
interface ConfigInterfaceProps<T, P> {
4236
panel: UIScreen<T, P>
@@ -123,16 +117,21 @@ const ConfigInterface: React.FC<ConfigInterfaceProps<void, ConfigurePanelCustomP
123117
export interface ConfigurePanelCustomProps {
124118
selectedAssembly?: MirabufSceneObject
125119
configMode?: ConfigMode
120+
configurationType?: ConfigurationType
126121
}
127122

128123
const ConfigurePanel: React.FC<PanelImplProps<void, ConfigurePanelCustomProps>> = ({ panel }) => {
129124
const { configureScreen } = useUIContext()
130-
const { configurationType, setConfigurationType } = useStateContext()
131125

132-
const { configMode: initialConfigMode, selectedAssembly: initialSelectedAssembly } = panel!.props.custom
126+
const {
127+
configMode: initialConfigMode,
128+
selectedAssembly: initialSelectedAssembly,
129+
configurationType: initialConfigurationType,
130+
} = panel!.props.custom
133131

134132
const [selectedAssembly, setSelectedAssembly] = useState<MirabufSceneObject | undefined>(initialSelectedAssembly)
135133
const [configMode, setConfigMode] = useState<ConfigMode | undefined>(initialConfigMode)
134+
const [configurationType, setConfigurationType] = useState<ConfigurationType>(initialConfigurationType ?? "ROBOTS")
136135
const [pendingDeletes, setPendingDeletes] = useState<number[]>([])
137136

138137
const originalRobotPrefs = useRef<RobotPreferences | null>(null)
@@ -169,7 +168,6 @@ const ConfigurePanel: React.FC<PanelImplProps<void, ConfigurePanelCustomProps>>
169168
originalMotorPrefs.current = null
170169
originalInputSchemes.current = null
171170

172-
setConfigurationType(configurationType)
173171
new ConfigurationSavedEvent()
174172
}
175173
const onCancel = () => {
@@ -201,7 +199,7 @@ const ConfigurePanel: React.FC<PanelImplProps<void, ConfigurePanelCustomProps>>
201199
{ title: "Configure Assets", acceptText: "Save", cancelText: "Cancel" },
202200
{ onBeforeAccept, onCancel }
203201
)
204-
}, [configurationType, selectedAssembly, pendingDeletes])
202+
}, [selectedAssembly, pendingDeletes])
205203

206204
const modes = useMemo(() => {
207205
switch (configurationType) {

0 commit comments

Comments
 (0)