Skip to content

Create Load Default Option for Field and Robot with Gizmo and Assembl… #1189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 5, 2025
26 changes: 26 additions & 0 deletions fission/src/ui/modals/MainMenuModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { SynthesisIcons } from "../components/StyledComponents"
import Button from "@/components/Button.tsx"
import { useModalControlContext } from "../helpers/UseModalManager"
import { Global_AddToast } from "@/components/GlobalUIControls.ts"
import { SpawnCachedMira } from "@/ui/panels/mirabuf/ImportMirabufPanel"
import { MiraType } from "@/mirabuf/MirabufLoader"
import MirabufCachingService from "@/mirabuf/MirabufLoader"

const MainMenuModal: React.FC<ModalPropsImpl & { startSingleplayerCallback: () => void }> = ({
modalId,
Expand All @@ -30,6 +33,29 @@ const MainMenuModal: React.FC<ModalPropsImpl & { startSingleplayerCallback: () =
}}
className="w-full my-1"
/>
<Button
value={"Load Default"}
onClick={() => {
closeModal()
startSingleplayerCallback()
MirabufCachingService.CacheRemote(
"/api/mira/fields/FRC Field 2018_v13.mira",
MiraType.FIELD
).then(cacheInfoField => {
if (cacheInfoField) {
SpawnCachedMira(cacheInfoField, MiraType.FIELD)
}
})
MirabufCachingService.CacheRemote("/api/mira/robots/Dozer_v9.mira", MiraType.ROBOT).then(
cacheInfoRobot => {
if (cacheInfoRobot) {
SpawnCachedMira(cacheInfoRobot, MiraType.ROBOT)
}
}
)
}}
className="w-full my-1"
/>
<Button
value={"Multiplayer"}
onClick={() => {
Expand Down
4 changes: 2 additions & 2 deletions fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ export type MiraManifest = {
fields: MirabufRemoteInfo[]
}

function GetCacheInfo(miraType: MiraType): MirabufCacheInfo[] {
export function GetCacheInfo(miraType: MiraType): MirabufCacheInfo[] {
return Object.values(
canOPFS ? MirabufCachingService.GetCacheMap(miraType) : miraType == MiraType.ROBOT ? backUpRobots : backUpFields
)
}

function SpawnCachedMira(info: MirabufCacheInfo, type: MiraType, progressHandle?: ProgressHandle) {
export function SpawnCachedMira(info: MirabufCacheInfo, type: MiraType, progressHandle?: ProgressHandle) {
// If spawning a field, then remove all other fields
if (type == MiraType.FIELD) {
World.SceneRenderer.RemoveAllFields()
Expand Down
Loading