diff --git a/fission/src/Synthesis.tsx b/fission/src/Synthesis.tsx index 51e9c4db05..1b3d308176 100644 --- a/fission/src/Synthesis.tsx +++ b/fission/src/Synthesis.tsx @@ -95,7 +95,7 @@ function Synthesis() { World.InitWorld() - if (!PreferencesSystem.getGlobalPreference("ReportAnalytics")) { + if (!PreferencesSystem.getGlobalPreference("ReportAnalytics") && !import.meta.env.DEV) { setConsentPopupDisable(false) } diff --git a/fission/src/systems/analytics/AnalyticsSystem.ts b/fission/src/systems/analytics/AnalyticsSystem.ts index 778a60b69f..6fd1d04a9d 100644 --- a/fission/src/systems/analytics/AnalyticsSystem.ts +++ b/fission/src/systems/analytics/AnalyticsSystem.ts @@ -27,7 +27,8 @@ class AnalyticsSystem extends WorldSystem { init({ measurementId: "G-6XNCRD7QNC", debug: import.meta.env.DEV, - sendPageViews: true, + anonymizeIp: true, + sendPageViews: false, trackingConsent: PreferencesSystem.getGlobalPreference("ReportAnalytics"), }) diff --git a/fission/src/systems/input/InputSchemeManager.ts b/fission/src/systems/input/InputSchemeManager.ts index 76c433c962..23a5ede69d 100644 --- a/fission/src/systems/input/InputSchemeManager.ts +++ b/fission/src/systems/input/InputSchemeManager.ts @@ -122,24 +122,10 @@ class InputSchemeManager { /** Save all schemes that have been customized to local storage via preferences */ public static saveSchemes() { - const customizedSchemes = Array.from(InputSystem.brainIndexSchemeMap.values()).filter(s => { + const customizedSchemes = this.allInputSchemes.filter(s => { return s.customized }) - // Save default schemes that have been customized if a customized version does not already exist - this.defaultInputSchemes.forEach(s => { - if (!s.customized) return - - if ( - customizedSchemes.some(c => { - if (c.schemeName === s.schemeName) return true - }) - ) - return - - customizedSchemes.push(s) - }) - PreferencesSystem.setGlobalPreference("InputSchemes", customizedSchemes) PreferencesSystem.savePreferences() } diff --git a/fission/src/ui/components/Button.tsx b/fission/src/ui/components/Button.tsx index 3f6f5ada7e..997a2081af 100644 --- a/fission/src/ui/components/Button.tsx +++ b/fission/src/ui/components/Button.tsx @@ -25,16 +25,16 @@ const Button: React.FC = ({ value, colorOverrideClass, sizeOverride if (!sizeClassNames) { switch (size) { case ButtonSize.Small: - sizeClassNames = "px-4 py-1" + sizeClassNames = "w-fit h-fit px-4 py-1" break case ButtonSize.Medium: - sizeClassNames = "px-6 py-1.5" + sizeClassNames = "w-fit h-fit px-6 py-1.5" break case ButtonSize.Large: - sizeClassNames = "px-8 py-2" + sizeClassNames = "w-fit h-fit px-8 py-2" break case ButtonSize.XL: - sizeClassNames = "px-10 py-2" + sizeClassNames = "w-fit h-fit px-10 py-2" break } } @@ -46,7 +46,7 @@ const Button: React.FC = ({ value, colorOverrideClass, sizeOverride colorOverrideClass ? colorOverrideClass : "bg-gradient-to-r from-interactive-element-left via-interactive-element-right to-interactive-element-left bg-[length:200%_100%] active:bg-right" - } w-fit h-fit ${sizeClassNames} rounded-sm font-semibold cursor-pointer duration-200 border-none focus-visible:outline-0 focus:outline-0 ${ + } ${sizeClassNames} rounded-sm font-semibold cursor-pointer duration-200 border-none focus-visible:outline-0 focus:outline-0 ${ className || "" }`} > diff --git a/fission/src/ui/components/MainHUD.tsx b/fission/src/ui/components/MainHUD.tsx index af55290eab..e25a7c6570 100644 --- a/fission/src/ui/components/MainHUD.tsx +++ b/fission/src/ui/components/MainHUD.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from "react" import { FaGear, - FaMagnifyingGlass, + // FaMagnifyingGlass, FaPlus, FaGamepad, FaBasketball, @@ -103,7 +103,7 @@ const MainHUD: React.FC = () => { onClick={() => openModal("manage-assemblies")} /> } onClick={() => openModal("settings")} /> - } onClick={() => openModal("view")} /> + {/* } onClick={() => openModal("view")} /> */} } onClick={() => openModal("change-inputs")} /> = ({ id="content" className={`${contentClassName} ${ !contentClassName?.includes("mx") ? "mx-[2rem]" : "" - } flex flex-col gap-4 max-h-75vh`} + } flex flex-col gap-4 max-h-75vh overflow-y-auto p-4`} > {children} diff --git a/fission/src/ui/modals/spawning/ManageAssembliesModal.tsx b/fission/src/ui/modals/spawning/ManageAssembliesModal.tsx index 4f4451da78..b5b3d9b4e3 100644 --- a/fission/src/ui/modals/spawning/ManageAssembliesModal.tsx +++ b/fission/src/ui/modals/spawning/ManageAssembliesModal.tsx @@ -1,38 +1,68 @@ -import React, { useReducer } from "react" +import React, { useMemo, useReducer } from "react" import Modal, { ModalPropsImpl } from "@/components/Modal" import { FaWrench } from "react-icons/fa6" -import Button from "@/components/Button" +import Button, { ButtonProps } from "@/components/Button" import Label, { LabelSize } from "@/components/Label" import World from "@/systems/World" import MirabufSceneObject from "@/mirabuf/MirabufSceneObject" +import { usePanelControlContext } from "@/ui/PanelContext" +import { setSelectedBrainIndexGlobal } from "@/ui/panels/configuring/ChooseInputSchemePanel" +import SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain" +import { useModalControlContext } from "@/ui/ModalContext" +import InputSystem from "@/systems/input/InputSystem" +import { IoTrashBin } from "react-icons/io5" interface AssemblyCardProps { mira: MirabufSceneObject update: React.DispatchWithoutAction } +const ButtonSecondary: React.FC = ({ value, onClick }) => { + return ( + + ) +} + const AssemblyCard: React.FC = ({ mira, update }) => { + const { openPanel } = usePanelControlContext() + const { closeModal } = useModalControlContext() + + const brain = useMemo(() => (mira.brain as SynthesisBrain)?.brainIndex, [mira]) + return (
- -
) } const ManageAssembliesModal: React.FC = ({ modalId }) => { - // update tooltip based on type of drivetrain, receive message from Synthesis - // const { showTooltip } = useTooltipControlContext() - const [_, update] = useReducer(x => !x, false) const assemblies = [...World.SceneRenderer.sceneObjects.entries()] @@ -43,23 +73,14 @@ const ManageAssembliesModal: React.FC = ({ modalId }) => { .map(x => x[1] as MirabufSceneObject) return ( - } - modalId={modalId} - onAccept={() => { - // showTooltip("controls", [ - // { control: "WASD", description: "Drive" }, - // { control: "E", description: "Intake" }, - // { control: "Q", description: "Dispense" }, - // ]); - }} - > + } modalId={modalId} acceptEnabled={false} cancelName="Back">
- {assemblies.map(x => AssemblyCard({ mira: x, update: update }))} + {assemblies.map(x => ( + + ))}
) diff --git a/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx b/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx index c6cfdceab3..ab42a35daa 100644 --- a/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx +++ b/fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx @@ -13,6 +13,16 @@ import { useEffect, useReducer } from "react" import { AiOutlinePlus } from "react-icons/ai" import { IoCheckmark, IoPencil, IoTrashBin } from "react-icons/io5" +let selectedBrainIndexGlobal: number | undefined = undefined +// eslint-disable-next-line react-refresh/only-export-components +export function setSelectedBrainIndexGlobal(index: number | undefined) { + selectedBrainIndexGlobal = index +} + +function getBrainIndex() { + return selectedBrainIndexGlobal != undefined ? selectedBrainIndexGlobal : SynthesisBrain.brainIndexMap.size - 1 +} + const ChooseInputSchemePanel: React.FC = ({ panelId }) => { const { closePanel } = usePanelControlContext() const { openModal } = useModalControlContext() @@ -38,7 +48,8 @@ const ChooseInputSchemePanel: React.FC = ({ panelId }) => { /** If the panel is closed before a scheme is selected, defaults to the top of the list */ return () => { - const brainIndex = SynthesisBrain.brainIndexMap.size - 1 + const brainIndex = getBrainIndex() + console.log(brainIndex) if (InputSystem.brainIndexSchemeMap.has(brainIndex)) return @@ -49,6 +60,13 @@ const ChooseInputSchemePanel: React.FC = ({ panelId }) => { openModal("change-inputs") } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) + + useEffect(() => { + return () => { + selectedBrainIndexGlobal = undefined + } }, []) return ( @@ -58,7 +76,8 @@ const ChooseInputSchemePanel: React.FC = ({ panelId }) => { openLocation={"right"} sidePadding={8} acceptEnabled={false} - cancelEnabled={false} + cancelEnabled={selectedBrainIndexGlobal != undefined} + cancelName="Close" > {/** A scroll view with buttons to select default and custom input schemes */}
@@ -94,10 +113,7 @@ const ChooseInputSchemePanel: React.FC = ({ panelId }) => {