Skip to content

Commit

Permalink
Moving Import Local Mirabuf (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Aug 12, 2024
2 parents 1a171c5 + 645ee2b commit 3a20e92
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
5 changes: 0 additions & 5 deletions fission/src/ui/components/MainHUD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ const MainHUD: React.FC = () => {
icon={SynthesisIcons.MagnifyingGlass}
onClick={() => openModal("view")}
/> */}
<MainHUDButton
value={"Import Local Asset"}
icon={SynthesisIcons.Import}
onClick={() => openModal("import-local-mirabuf")}
/>
<MainHUDButton
value={"Configure"}
icon={SynthesisIcons.Gear}
Expand Down
10 changes: 7 additions & 3 deletions fission/src/ui/modals/mirabuf/ImportLocalMirabufModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import MirabufCachingService, { MiraType } from "@/mirabuf/MirabufLoader"
import Dropdown from "@/ui/components/Dropdown"
import { CreateMirabuf } from "@/mirabuf/MirabufSceneObject"
import { SynthesisIcons } from "@/ui/components/StyledComponents"
import { usePanelControlContext } from "@/ui/PanelContext"

const ImportLocalMirabufModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
// update tooltip based on type of drivetrain, receive message from Synthesis
const { showTooltip } = useTooltipControlContext()
const { openPanel } = usePanelControlContext()

const fileUploadRef = useRef<HTMLInputElement>(null)

Expand Down Expand Up @@ -44,7 +46,7 @@ const ImportLocalMirabufModal: React.FC<ModalPropsImpl> = ({ modalId }) => {

return (
<Modal
name={"Import Local Assemblies"}
name={"Import From File"}
icon={SynthesisIcons.Import}
modalId={modalId}
acceptEnabled={selectedFile !== undefined && miraType !== undefined}
Expand All @@ -64,12 +66,14 @@ const ImportLocalMirabufModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
World.SceneRenderer.RegisterSceneObject(x)
}
})

if (miraType == MiraType.ROBOT) openPanel("choose-scheme")
}
}}
>
<div className="flex flex-col items-center gap-5">
<input ref={fileUploadRef} onChange={onInputChanged} type="file" hidden={true} />
<Button value="Upload" size={ButtonSize.Large} onClick={uploadClicked} />
<Button value="Upload File" size={ButtonSize.Large} onClick={uploadClicked} />
{selectedFile ? (
<Label
className="text-center"
Expand All @@ -79,7 +83,7 @@ const ImportLocalMirabufModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
<></>
)}
<Dropdown
label="Type"
label="File Type"
options={["None", "Robot", "Field"]}
onSelect={(selected: string) => {
typeSelected(selected)
Expand Down
11 changes: 11 additions & 0 deletions fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { CreateMirabuf } from "@/mirabuf/MirabufSceneObject"
import { Box } from "@mui/material"
import { ToggleButton, ToggleButtonGroup } from "@/ui/components/ToggleButtonGroup"
import { usePanelControlContext } from "@/ui/PanelContext"
import { useModalControlContext } from "@/ui/ModalContext"
import TaskStatus from "@/util/TaskStatus"
import {
PositiveButton,
Expand All @@ -23,9 +24,11 @@ import {
DeleteButton,
RefreshButton,
SynthesisIcons,
Spacer,
} from "@/ui/components/StyledComponents"
import { ProgressHandle } from "@/ui/components/ProgressNotificationData"
import Panel, { PanelPropsImpl } from "@/ui/components/Panel"
import Button from "@/ui/components/Button"

interface ItemCardProps {
id: string
Expand Down Expand Up @@ -100,6 +103,7 @@ function SpawnCachedMira(info: MirabufCacheInfo, type: MiraType, progressHandle?
const ImportMirabufPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
const { showTooltip } = useTooltipControlContext()
const { closePanel, openPanel } = usePanelControlContext()
const { openModal } = useModalControlContext()

const [cachedRobots, setCachedRobots] = useState(GetCacheInfo(MiraType.ROBOT))
const [cachedFields, setCachedFields] = useState(GetCacheInfo(MiraType.FIELD))
Expand Down Expand Up @@ -378,6 +382,10 @@ const ImportMirabufPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
</SectionLabel>
<SectionDivider />
{cachedFieldElements}
{Spacer(5)}
<Box alignSelf={"center"}>
<Button value="Import from File" onClick={() => openModal("import-local-mirabuf")} />
</Box>
</>
)}
<Box
Expand Down Expand Up @@ -419,6 +427,9 @@ const ImportMirabufPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
{remoteFieldElements}
</>
)}
<Box alignSelf={"center"}>
<Button value="Import from File" onClick={() => openModal("import-local-mirabuf")} />
</Box>
</div>
</Panel>
)
Expand Down

0 comments on commit 3a20e92

Please sign in to comment.