Skip to content
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

[HOTFIX 1] 7.0.0b1 #1063

Merged
merged 17 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
2 changes: 1 addition & 1 deletion fission/src/Synthesis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function Synthesis() {

World.InitWorld()

if (!PreferencesSystem.getGlobalPreference<boolean>("ReportAnalytics")) {
if (!PreferencesSystem.getGlobalPreference<boolean>("ReportAnalytics") && !import.meta.env.DEV) {
setConsentPopupDisable(false)
}

Expand Down
3 changes: 2 additions & 1 deletion fission/src/systems/analytics/AnalyticsSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>("ReportAnalytics"),
})

Expand Down
16 changes: 1 addition & 15 deletions fission/src/systems/input/InputSchemeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion fission/src/ui/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Modal: React.FC<ModalProps> = ({
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}
</div>
Expand Down
51 changes: 30 additions & 21 deletions fission/src/ui/modals/spawning/ManageAssembliesModal.tsx
HunterBarclay marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,30 +1,50 @@
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 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"

interface AssemblyCardProps {
mira: MirabufSceneObject
update: React.DispatchWithoutAction
}

const AssemblyCard: React.FC<AssemblyCardProps> = ({ mira, update }) => {
const { openPanel } = usePanelControlContext()
const { closeModal } = useModalControlContext()

const brain = useMemo(() => (mira.brain as SynthesisBrain)?.brainIndex, [mira])

return (
<div
key={mira.id}
className="flex flex-row align-middle justify-between items-center bg-background rounded-sm p-2 gap-2"
>
<Label className="text-wrap break-all">{mira.assemblyName}</Label>
<Button
value="Delete"
onClick={() => {
World.SceneRenderer.RemoveSceneObject(mira.id)
update()
}}
/>
<Label className="text-wrap break-all">{`[${InputSystem.brainIndexSchemeMap.get(brain)?.schemeName ?? "-"}] ${mira.assemblyName}`}</Label>
<div className="flex flex-row gap-4">
<Button
value="Set Scheme"
HunterBarclay marked this conversation as resolved.
Show resolved Hide resolved
onClick={() => {
HunterBarclay marked this conversation as resolved.
Show resolved Hide resolved
setSelectedBrainIndexGlobal(brain)
openPanel("choose-scheme")
closeModal()
}}
/>
<Button
value="Delete"
onClick={() => {
World.SceneRenderer.RemoveSceneObject(mira.id)
update()
}}
/>
</div>
</div>
)
}
Expand All @@ -43,18 +63,7 @@ const ManageAssembliesModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
.map(x => x[1] as MirabufSceneObject)

return (
<Modal
name={"Manage Assemblies"}
icon={<FaWrench />}
modalId={modalId}
onAccept={() => {
// showTooltip("controls", [
// { control: "WASD", description: "Drive" },
// { control: "E", description: "Intake" },
// { control: "Q", description: "Dispense" },
// ]);
}}
>
<Modal name={"Manage Assemblies"} icon={<FaWrench />} modalId={modalId}>
<div className="flex overflow-y-auto flex-col gap-2 min-w-[50vw] max-h-[60vh] bg-background-secondary rounded-md p-2">
<Label size={LabelSize.Medium} className="text-center border-b-[1pt] mt-[4pt] mb-[2pt] mx-[5%]">
{assemblies ? `${assemblies.length} Assemblies` : "No Assemblies"}
Expand Down
35 changes: 22 additions & 13 deletions fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PanelPropsImpl> = ({ panelId }) => {
const { closePanel } = usePanelControlContext()
const { openModal } = useModalControlContext()
Expand All @@ -38,7 +48,8 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ 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

Expand All @@ -49,6 +60,13 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {

openModal("change-inputs")
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

useEffect(() => {
return () => {
selectedBrainIndexGlobal = undefined
}
}, [])

return (
Expand Down Expand Up @@ -94,10 +112,7 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
<Button
value={SelectIcon}
onClick={() => {
InputSystem.brainIndexSchemeMap.set(
SynthesisBrain.brainIndexMap.size - 1,
scheme
)
InputSystem.brainIndexSchemeMap.set(getBrainIndex(), scheme)
closePanel(panelId)
}}
colorOverrideClass="bg-accept-button hover:brightness-90"
Expand All @@ -106,10 +121,7 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
<Button
value={EditIcon}
onClick={() => {
InputSystem.brainIndexSchemeMap.set(
SynthesisBrain.brainIndexMap.size - 1,
scheme
)
InputSystem.brainIndexSchemeMap.set(getBrainIndex(), scheme)
InputSystem.selectedScheme = scheme
openModal("change-inputs")
}}
Expand Down Expand Up @@ -152,10 +164,7 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
<Button
value={AddIcon}
onClick={() => {
InputSystem.brainIndexSchemeMap.set(
SynthesisBrain.brainIndexMap.size - 1,
DefaultInputs.newBlankScheme
)
InputSystem.brainIndexSchemeMap.set(getBrainIndex(), DefaultInputs.newBlankScheme)
openModal("assign-new-scheme")
}}
/>
Expand Down
4 changes: 3 additions & 1 deletion fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ const ImportMirabufPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
.catch(() => status.Fail())

closePanel(panelId)

if (type == MiraType.ROBOT) openPanel("choose-scheme")
},
[closePanel, panelId]
[closePanel, panelId, openPanel]
)

// Generate Item cards for cached robots.
Expand Down
Loading