Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions fission/src/aps/APS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class APS {
} catch (e) {
console.error(e)
World.analyticsSystem?.exception("APS Login Failure")
globalAddToast?.("error", "Error signing in.", "Please try again.")
globalAddToast("error", "Error signing in.", "Please try again.")
}
})
}
Expand Down Expand Up @@ -236,7 +236,7 @@ class APS {
const json = await res.json()
if (!res.ok) {
if (shouldRelog) {
globalAddToast?.("warning", "Must Re-signin.", json.userMessage)
globalAddToast("warning", "Must Re-signin.", json.userMessage)
this._auth = undefined
await this.requestAuthCode()
return false
Expand All @@ -249,13 +249,13 @@ class APS {
if (this._auth) {
await this.loadUserInfo(this._auth)
if (APS.userInfo) {
globalAddToast?.("info", "ADSK Login", `Hello, ${APS.userInfo.givenName}`)
globalAddToast("info", "ADSK Login", `Hello, ${APS.userInfo.givenName}`)
}
}
return true
} catch (e) {
World.analyticsSystem?.exception("APS Login Failure")
globalAddToast?.("error", "Error signing in.", "Please try again.")
globalAddToast("error", "Error signing in.", "Please try again.")
this._auth = undefined
await this.requestAuthCode()
return false
Expand All @@ -281,7 +281,7 @@ class APS {
const json = await res.json()
if (!res.ok) {
World.analyticsSystem?.exception("APS Login Failure")
globalAddToast?.("error", "Error signing in.", json.userMessage)
globalAddToast("error", "Error signing in.", json.userMessage)
this._auth = undefined
return
}
Expand All @@ -293,7 +293,7 @@ class APS {
if (auth) {
await this.loadUserInfo(auth)
if (APS.userInfo) {
globalAddToast?.("info", "ADSK Login", `Hello, ${APS.userInfo.givenName}`)
globalAddToast("info", "ADSK Login", `Hello, ${APS.userInfo.givenName}`)
}
} else {
console.error("Couldn't get auth data.")
Expand All @@ -306,7 +306,7 @@ class APS {
if (retryLogin) {
this._auth = undefined
World.analyticsSystem?.exception("APS Login Failure")
globalAddToast?.("error", "Error signing in.", "Please try again.")
globalAddToast("error", "Error signing in.", "Please try again.")
}
}

Expand All @@ -327,7 +327,7 @@ class APS {
const json = await res.json()
if (!res.ok) {
World.analyticsSystem?.exception("APS Failure: User Info")
globalAddToast?.("error", "Error fetching user data.", json.userMessage)
globalAddToast("error", "Error fetching user data.", json.userMessage)
this._auth = undefined
await this.requestAuthCode()
return
Expand All @@ -343,7 +343,7 @@ class APS {
} catch (e) {
console.error(e)
World.analyticsSystem?.exception("APS Login Failure: User Info")
globalAddToast?.("error", "Error signing in.", "Please try again.")
globalAddToast("error", "Error signing in.", "Please try again.")
this._auth = undefined
}
}
Expand All @@ -359,7 +359,7 @@ class APS {
} catch (e) {
console.error(e)
World.analyticsSystem?.exception("APS Login Failure: Code Challenge")
globalAddToast?.("error", "Error signing in.", "Please try again.")
globalAddToast("error", "Error signing in.", "Please try again.")
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions fission/src/aps/APSDataManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ export async function getHubs(): Promise<Hub[] | undefined> {
console.log(auth)
console.log(APS.userInfo)
if (e instanceof APSDataError) {
globalAddToast?.("error", e.title, e.detail)
globalAddToast("error", e.title, e.detail)
} else if (e instanceof Error) {
globalAddToast?.("error", "Failed to get hubs.", e.message)
globalAddToast("error", "Failed to get hubs.", e.message)
}
return undefined
}
Expand Down Expand Up @@ -179,7 +179,7 @@ export async function getProjects(hub: Hub): Promise<Project[] | undefined> {
} catch (e) {
console.error("Failed to get hubs")
if (e instanceof Error) {
globalAddToast?.("error", "Failed to get hubs.", e.message)
globalAddToast("error", "Failed to get hubs.", e.message)
}
return undefined
}
Expand Down Expand Up @@ -224,7 +224,7 @@ export async function getFolderData(project: Project, folder: Folder): Promise<D
} catch (e) {
console.error("Failed to get folder data")
if (e instanceof Error) {
globalAddToast?.("error", "Failed to get folder data.", e.message)
globalAddToast("error", "Failed to get folder data.", e.message)
}
return undefined
}
Expand All @@ -250,7 +250,7 @@ export async function searchFolder(project: Project, folder: Folder, filters?: F
},
})
if (!res.ok) {
globalAddToast?.("error", "Error getting cloud files.", "Please sign in again.")
globalAddToast("error", "Error getting cloud files.", "Please sign in again.")
return []
}
const json = await res.json()
Expand Down
2 changes: 1 addition & 1 deletion fission/src/mirabuf/MirabufLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class MirabufCachingService {

if (cached) return cached

globalAddToast?.("error", "Cache Fallback", `Unable to cache “${fetchLocation}”. Using raw buffer instead.`)
globalAddToast("error", "Cache Fallback", `Unable to cache “${fetchLocation}”. Using raw buffer instead.`)

// fallback: return raw buffer wrapped in MirabufCacheInfo
return {
Expand Down
12 changes: 6 additions & 6 deletions fission/src/mirabuf/MirabufSceneObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import JOLT from "@/util/loading/JoltSyncLoader"
import { BodyAssociate, LayerReserve } from "@/systems/physics/PhysicsSystem"
import Mechanism from "@/systems/physics/Mechanism"
import {
Alliance,
EjectorPreferences,
FieldPreferences,
IntakePreferences,
ScoringZonePreferences,
ProtectedZonePreferences,
ScoringZonePreferences,
} from "@/systems/preferences/PreferenceTypes"
import PreferencesSystem from "@/systems/preferences/PreferencesSystem"
import { MiraType } from "./MirabufLoader"
Expand All @@ -40,7 +41,6 @@ import {
} from "@/ui/panels/configuring/assembly-config/ConfigurationType"
import { SimConfigData } from "@/ui/panels/simulation/SimConfigShared"
import WPILibBrain from "@/systems/simulation/wpilib_brain/WPILibBrain"
import { Alliance } from "@/systems/preferences/PreferenceTypes"
import { OnContactAddedEvent } from "@/systems/physics/ContactEvents"

const DEBUG_BODIES = false
Expand Down Expand Up @@ -524,7 +524,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
const now = Date.now()
if (now - this._lastEjectableToastTime > MirabufSceneObject.EJECTABLE_TOAST_COOLDOWN_MS) {
console.log(`Configure an ejectable first.`)
globalAddToast?.("info", "Configure Ejectable", "Configure an ejectable first.")
globalAddToast("info", "Configure Ejectable", "Configure an ejectable first.")
this._lastEjectableToastTime = now
}

Expand Down Expand Up @@ -710,7 +710,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
configMode: ConfigMode.MOVE,
selectedAssembly: this,
})
globalOpenPanel?.("configure")
globalOpenPanel("configure")
},
},
{
Expand All @@ -723,7 +723,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
configMode: undefined,
selectedAssembly: this,
})
globalOpenPanel?.("configure")
globalOpenPanel("configure")
},
}
)
Expand All @@ -732,7 +732,7 @@ class MirabufSceneObject extends SceneObject implements ContextSupplier {
data.items.push({
name: "Auto Testing",
func: () => {
globalOpenPanel?.("auto-test")
globalOpenPanel("auto-test")
},
})
}
Expand Down
4 changes: 2 additions & 2 deletions fission/src/systems/PerformanceMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export class PerformanceMonitoringSystem extends WorldSystem {
if (this.isCritical) {
PreferencesSystem.resetGraphicsPreferences()
World.sceneRenderer.changeCSMSettings(PreferencesSystem.getGraphicsPreferences())
globalOpenPanel?.("graphics-settings")
globalAddToast?.("warning", "Performance Issues Detected", "Reverting to simple graphics")
globalOpenPanel("graphics-settings")
globalAddToast("warning", "Performance Issues Detected", "Reverting to simple graphics")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion fission/src/systems/scene/SceneRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class SceneRenderer extends WorldSystem {
miraSupplierData.items.push({
name: "Add",
func: () => {
globalOpenPanel?.("import-mirabuf")
globalOpenPanel("import-mirabuf")
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion fission/src/systems/simulation/SimulationSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SimulationSystem extends WorldSystem {

public static robotPenalty(robot: MirabufSceneObject, penaltyPoints: number, penaltyInfo: string): void {
// Display a toast showing that a penalty was committed
globalAddToast?.(
globalAddToast(
"warning",
"PENALTY COMMITTED",
`Robot ${robot.nameTag?.text()} (${robot.assemblyName}), Committed Penalty: ${penaltyInfo}`
Expand Down
2 changes: 1 addition & 1 deletion fission/src/ui/components/DragModeIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const DragModeIndicator: React.FC = () => {

const handleClick = () => {
window.dispatchEvent(new CustomEvent("disableDragMode"))
globalAddToast?.("info", "Drag Mode", "Drag mode has been disabled")
globalAddToast("info", "Drag Mode", "Drag mode has been disabled")
}

return enabled ? (
Expand Down
6 changes: 3 additions & 3 deletions fission/src/ui/components/GlobalUIComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ const GlobalUIComponent: React.FC = () => {
setOpenModal(openModal)

return () => {
setOpenModal(undefined)
setOpenModal(() => {})
}
}, [openModal])

useEffect(() => {
setOpenPanel(openPanel)

return () => {
setOpenPanel(undefined)
setOpenPanel(() => {})
}
}, [openPanel])

useEffect(() => {
setAddToast(addToast)

return () => {
setAddToast(undefined)
setAddToast(() => {})
}
}, [addToast])

Expand Down
6 changes: 3 additions & 3 deletions fission/src/ui/components/GlobalUIControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import { ToastType } from "@/ui/ToastContext"

export let globalAddToast: ((type: ToastType, title: string, description: string) => void) | undefined = undefined
export let globalOpenPanel: ((panelId: string) => void) | undefined = undefined
export let globalOpenModal: ((modalId: string) => void) | undefined = undefined
export let globalAddToast: (type: ToastType, title: string, description: string) => void = () => {}
export let globalOpenPanel: (panelId: string) => void = () => {}
export let globalOpenModal: (modalId: string) => void = () => {}

export function setAddToast(func: typeof globalAddToast) {
globalAddToast = func
Expand Down
2 changes: 1 addition & 1 deletion fission/src/ui/components/MainHUD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const MainHUD: React.FC = () => {
larger={true}
onClick={() => {
MatchMode.getInstance().isMatchEnabled()
? globalAddToast?.(
? globalAddToast(
"error",
"Match Mode Already Running",
"You can't start match mode if its already running"
Expand Down
2 changes: 1 addition & 1 deletion fission/src/ui/modals/MainMenuModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const MainMenuModal: React.FC<ModalPropsImpl & { startSingleplayerCallback: () =
<Button
value={"Multiplayer"}
onClick={() => {
globalAddToast?.("error", "Not Supported", "Multiplayer is not yet supported. Come back soon!")
globalAddToast("error", "Not Supported", "Multiplayer is not yet supported. Come back soon!")
}}
className="w-full mt-1 mb-3"
/>
Expand Down
2 changes: 1 addition & 1 deletion fission/src/ui/modals/configuring/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const SettingsModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
const save = () => {
SoundPlayer.changeVolume()
PreferencesSystem.savePreferences()
globalAddToast?.("info", "Settings Saved", "")
globalAddToast("info", "Settings Saved", "")
}
return (
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const ImportLocalMirabufModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
if (x) {
World.sceneRenderer.registerSceneObject(x)

globalOpenPanel?.("initial-config")
globalOpenPanel("initial-config")
}
})
.finally(() =>
Expand Down
4 changes: 2 additions & 2 deletions fission/src/ui/panels/DebugPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function toggleDragMode() {
if (dragSystem) {
dragSystem.enabled = !dragSystem.enabled
const status = dragSystem.enabled ? "enabled" : "disabled"
globalAddToast?.("info", "Drag Mode", `Drag mode has been ${status}`)
globalAddToast("info", "Drag Mode", `Drag mode has been ${status}`)
}
}

Expand Down Expand Up @@ -63,7 +63,7 @@ const DebugPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
value={"Toasts"}
onClick={() => {
const type: ToastType = ["info", "warning", "error"][Math.floor(random() * 3)] as ToastType
globalAddToast?.(type, type, "This is a test toast to test the toast system")
globalAddToast(type, type, "This is a test toast to test the toast system")
}}
className="w-full"
/>
Expand Down
8 changes: 2 additions & 6 deletions fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function spawnCachedMira(info: MirabufCacheInfo, type: MiraType, progressHandle?
World.sceneRenderer.registerSceneObject(x)
progressHandle.done()

globalOpenPanel?.("initial-config")
globalOpenPanel("initial-config")
} else {
progressHandle.fail()
}
Expand Down Expand Up @@ -166,11 +166,7 @@ const ImportMirabufPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
useLayoutEffect(() => {
if (mirabufPanelState.hasUnconfirmedImport) {
closePanel("import-mirabuf")
globalAddToast?.(
"warning",
"You're already importing a model!",
"Confirm that one before importing another."
)
globalAddToast("warning", "You're already importing a model!", "Confirm that one before importing another.")
return
}
closePanel("configure")
Expand Down
18 changes: 9 additions & 9 deletions fission/src/ui/panels/simulation/WiringPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import Panel, { PanelPropsImpl } from "@/components/Panel"
import { SectionDivider, SectionLabel, SynthesisIcons } from "@/ui/components/StyledComponents"
import React, { ComponentType, useCallback, useEffect, useMemo, useReducer, useState } from "react"
import {
ReactFlow,
Node as FlowNode,
Edge as FlowEdge,
useNodesState,
useEdgesState,
NodeProps,
Connection,
Edge as FlowEdge,
FinalConnectionState,
useReactFlow,
Node as FlowNode,
NodeProps,
ReactFlow,
ReactFlowProvider,
useEdgesState,
useNodesState,
useReactFlow,
} from "@xyflow/react"
import {
ConfigState,
Expand All @@ -22,6 +22,7 @@ import {
NODE_ID_SIM_IN,
NODE_ID_SIM_OUT,
SimConfig,
SimConfigData,
} from "./SimConfigShared"
import Label, { LabelSize } from "@/ui/components/Label"
import ScrollView from "@/ui/components/ScrollView"
Expand All @@ -31,7 +32,6 @@ import World from "@/systems/World"
import Button from "@/ui/components/Button"
import { usePanelControlContext } from "@/ui/helpers/UsePanelManager"
import { globalAddToast } from "@/ui/components/GlobalUIControls"
import { SimConfigData } from "./SimConfigShared"
import FlowControls from "./FlowControls"
import WiringNode from "./WiringNode"
import { SimType } from "@/systems/simulation/wpilib_brain/WPILibBrain"
Expand Down Expand Up @@ -401,7 +401,7 @@ const WiringPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
return miraObjs[0][1] as MirabufSceneObject
} else {
// TEMPORARY: Will be moved to config panel to ensure selected assembly
globalAddToast?.("warning", "Missing Robot", "Must have at least one robot spawned for selection.")
globalAddToast("warning", "Missing Robot", "Must have at least one robot spawned for selection.")
closePanel(panelId)
}
}, [closePanel, panelId])
Expand Down
Loading