Skip to content

Commit 68eabf4

Browse files
Make Configure Asset Panel Reactive [AARD-2074] (#1272)
Co-authored-by: Zach Rutman <[email protected]>
2 parents 27a46c2 + 2372681 commit 68eabf4

39 files changed

+104
-76
lines changed

fission/src/mirabuf/MirabufSceneObject.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
313313
if (this.miraType === MiraType.ROBOT || !cameraControls.focusProvider) {
314314
cameraControls.focusProvider = this
315315
}
316+
317+
MirabufObjectChangeEvent.dispatch(this)
316318
}
317319

318320
// Centered in xz plane, bottom surface of object
@@ -431,6 +433,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
431433
if (this._brain && this._brain instanceof SynthesisBrain) {
432434
this._brain.clearControls()
433435
}
436+
MirabufObjectChangeEvent.dispatch(null)
434437
}
435438

436439
public eject() {
@@ -986,3 +989,29 @@ export class RigidNodeAssociate extends BodyAssociate {
986989
}
987990

988991
export default MirabufSceneObject
992+
993+
export class MirabufObjectChangeEvent extends Event {
994+
private static _eventKey = "MirabufObjectChange"
995+
private _obj: MirabufSceneObject | null
996+
997+
private constructor(obj: MirabufSceneObject | null) {
998+
super(MirabufObjectChangeEvent._eventKey)
999+
this._obj = obj
1000+
}
1001+
1002+
public static addEventListener(cb: (object: MirabufSceneObject | null) => void): () => void {
1003+
const listener = (event: Event) => {
1004+
if (event instanceof MirabufObjectChangeEvent) {
1005+
cb(event._obj)
1006+
} else {
1007+
cb(null)
1008+
}
1009+
}
1010+
window.addEventListener(this._eventKey, listener)
1011+
return () => window.removeEventListener(this._eventKey, listener)
1012+
}
1013+
1014+
public static dispatch(obj: MirabufSceneObject | null) {
1015+
window.dispatchEvent(new MirabufObjectChangeEvent(obj))
1016+
}
1017+
}

fission/src/ui/UIProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import CloseIcon from "@mui/icons-material/Close"
2-
import { IconButton } from "./components/StyledComponents"
32
import type { SnackbarKey, SnackbarMessage, VariantType } from "notistack"
43
import { useSnackbar } from "notistack"
54
import type React from "react"
@@ -8,6 +7,7 @@ import { useCallback, useReducer, useState } from "react"
87
import { v4 as uuidv4 } from "uuid"
98
import type { ModalImplProps } from "./components/Modal"
109
import type { PanelImplProps } from "./components/Panel"
10+
import { IconButton } from "./components/StyledComponents"
1111
import {
1212
CloseType,
1313
type ConfigureScreenFn,

fission/src/ui/components/AnalyticsConsent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Box } from "@mui/material"
2-
import { Button } from "./StyledComponents"
32
import { AiOutlineClose } from "react-icons/ai"
43
import Label from "./Label"
4+
import { Button } from "./StyledComponents"
55

66
interface AnalyticsConsentProps {
77
onClose: () => void

fission/src/ui/components/ContextMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Divider, Stack } from "@mui/material"
2-
import { Button } from "./StyledComponents"
32
import type React from "react"
43
import { useEffect, useState } from "react"
54
import { type ContextData, ContextSupplierEvent } from "./ContextMenuData"
65
import { globalOpenModal, globalOpenPanel } from "./GlobalUIControls"
76
import Label from "./Label"
7+
import { Button } from "./StyledComponents"
88

99
interface ContextMenuStateData {
1010
data: ContextData

fission/src/ui/components/MainHUD.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Box, Stack } from "@mui/material"
2-
import { Button, IconButton } from "./StyledComponents"
32
import { motion } from "framer-motion"
43
import type React from "react"
54
import { useEffect, useState } from "react"
@@ -20,7 +19,7 @@ import DebugPanel from "../panels/DebugPanel"
2019
import DeveloperToolPanel from "../panels/DeveloperToolPanel"
2120
import ImportMirabufPanel from "../panels/mirabuf/ImportMirabufPanel"
2221
import { setAddToast, setOpenModal, setOpenPanel } from "./GlobalUIControls"
23-
import { SynthesisIcons } from "./StyledComponents"
22+
import { Button, IconButton, SynthesisIcons } from "./StyledComponents"
2423
import { TouchControlsEvent, TouchControlsEventKeys } from "./TouchControls"
2524
import UserIcon from "./UserIcon"
2625

fission/src/ui/components/Modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Card, CardActions, CardContent, CardHeader, Modal as MUIModal } from "@mui/material"
2-
import { Button } from "./StyledComponents"
32
import React, { type ReactElement } from "react"
43
import type { Modal as ModalType, Panel as PanelType } from "../helpers/UIProviderHelpers"
54
import { CloseType, useUIContext } from "../helpers/UIProviderHelpers"
5+
import { Button } from "./StyledComponents"
66

77
export type ModalImplProps<T, P> = Partial<{
88
modal: ModalType<T, P>

fission/src/ui/components/Panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Card, CardActions, CardContent, CardHeader } from "@mui/material"
2-
import { Button } from "./StyledComponents"
32
import React, { type ReactElement } from "react"
43
import Draggable from "react-draggable"
54
import {
@@ -9,6 +8,7 @@ import {
98
type Panel as PanelType,
109
useUIContext,
1110
} from "../helpers/UIProviderHelpers"
11+
import { Button } from "./StyledComponents"
1212

1313
// biome-ignore-start lint/suspicious/noExplicitAny: need to be able to extend
1414
export type PanelImplProps<T, P> = Partial<{

fission/src/ui/components/SelectButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import type Jolt from "@azaleacolburn/jolt-physics"
22
import { Stack } from "@mui/material"
3-
import { Button } from "./StyledComponents"
43
import type React from "react"
54
import { useCallback, useEffect, useRef, useState } from "react"
65
import World from "@/systems/World"
76
import { convertThreeVector3ToJoltVec3 } from "@/util/TypeConversions"
8-
import { LabelWithTooltip } from "./StyledComponents"
7+
import { Button, LabelWithTooltip } from "./StyledComponents"
98

109
// raycasting constants
1110
const RAY_MAX_LENGTH = 20.0

fission/src/ui/components/SelectMenu.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Divider, Stack } from "@mui/material"
2-
import { Button, IconButton } from "./StyledComponents"
32
import type React from "react"
43
import { useEffect, useState } from "react"
54
import Label from "./Label"
6-
import { CustomTooltip, Spacer, SynthesisIcons } from "./StyledComponents"
5+
import { Button, CustomTooltip, IconButton, Spacer, SynthesisIcons } from "./StyledComponents"
76

87
/** Extend this to make a type that contains custom data */
98
export class SelectMenuOption {

fission/src/ui/components/StyledComponents.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import InfoIcon from "@mui/icons-material/Info"
22
import {
33
Box,
4-
Button as MuiButton,
54
type ButtonProps,
6-
IconButton as MuiIconButton,
75
type IconButtonProps,
8-
Stack,
9-
Tooltip,
6+
Button as MuiButton,
7+
IconButton as MuiIconButton,
108
ToggleButton as MuiToggleButton,
11-
type ToggleButtonProps,
129
ToggleButtonGroup as MuiToggleButtonGroup,
10+
Stack,
1311
type ToggleButtonGroupProps,
12+
type ToggleButtonProps,
13+
Tooltip,
1414
} from "@mui/material"
15-
import { SoundPlayer } from "@/systems/sound/SoundPlayer"
1615
import { AiFillWarning, AiOutlineDoubleRight, AiOutlineInfoCircle } from "react-icons/ai"
1716
import { BiRefresh } from "react-icons/bi"
1817
import { BsCodeSquare } from "react-icons/bs"
@@ -38,6 +37,7 @@ import { GiSteeringWheel } from "react-icons/gi"
3837
import { GrConnect } from "react-icons/gr"
3938
import { HiDownload } from "react-icons/hi"
4039
import { IoCheckmark, IoPencil, IoPeople, IoPlayOutline, IoTrashBin } from "react-icons/io5"
40+
import { SoundPlayer } from "@/systems/sound/SoundPlayer"
4141
import Label from "./Label"
4242

4343
export class SynthesisIcons {

0 commit comments

Comments
 (0)