Skip to content

Commit

Permalink
[HOTFIX 1] 7.0.0b1 (#1063)
Browse files Browse the repository at this point in the history
* Adding dev flags to turn off certain analytics settings/ui while testing. Fixed modal overflow

* Fixed only one input scheme saving

* Trying to fix bug with selecting scheme

* Open the schoos scheme panel when an APS robot is spawned

* Fixed scheme selection, added text to show which scheme is being used

* Removing change to dropdown

* Removed changes to panel

* Adding dev flags to turn off certain analytics settings/ui while testing. Fixed modal overflow

* Fixed only one input scheme saving

* Trying to fix bug with selecting scheme

* Fixed scheme selection, added text to show which scheme is being used

* Removing change to dropdown

* Removed changes to panel

* Change delete button for manage assemblies, removed view button from MainHUD, fixed temp scoreboard reset

* Formatted

* Added cancel for reassigned scheme

---------

Co-authored-by: LucaHaverty <[email protected]>
  • Loading branch information
HunterBarclay and LucaHaverty authored Jul 30, 2024
1 parent e9fa957 commit 5807353
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 68 deletions.
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
10 changes: 5 additions & 5 deletions fission/src/ui/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ const Button: React.FC<ButtonProps> = ({ 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
}
}
Expand All @@ -46,7 +46,7 @@ const Button: React.FC<ButtonProps> = ({ 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 || ""
}`}
>
Expand Down
4 changes: 2 additions & 2 deletions fission/src/ui/components/MainHUD.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react"
import {
FaGear,
FaMagnifyingGlass,
// FaMagnifyingGlass,
FaPlus,
FaGamepad,
FaBasketball,
Expand Down Expand Up @@ -103,7 +103,7 @@ const MainHUD: React.FC = () => {
onClick={() => openModal("manage-assemblies")}
/>
<MainHUDButton value={"Settings"} icon={<FaGear />} onClick={() => openModal("settings")} />
<MainHUDButton value={"View"} icon={<FaMagnifyingGlass />} onClick={() => openModal("view")} />
{/* <MainHUDButton value={"View"} icon={<FaMagnifyingGlass />} onClick={() => openModal("view")} /> */}
<MainHUDButton value={"Controls"} icon={<FaGamepad />} onClick={() => openModal("change-inputs")} />
<MainHUDButton
value={"Import Local Mira"}
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
73 changes: 47 additions & 26 deletions fission/src/ui/modals/spawning/ManageAssembliesModal.tsx
Original file line number Diff line number Diff line change
@@ -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<ButtonProps> = ({ value, onClick }) => {
return (
<Button
sizeOverrideClass="px-6 py-2"
value={value}
onClick={onClick}
colorOverrideClass="bg-cancel-button hover:brightness-90"
></Button>
)
}

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
sizeOverrideClass="px-6 py-2"
value="Set Scheme"
onClick={() => {
setSelectedBrainIndexGlobal(brain)
openPanel("choose-scheme")
closeModal()
}}
/>
<ButtonSecondary
value={<IoTrashBin />}
onClick={() => {
World.SceneRenderer.RemoveSceneObject(mira.id)
update()
}}
/>
</div>
</div>
)
}

const ManageAssembliesModal: React.FC<ModalPropsImpl> = ({ 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()]
Expand All @@ -43,23 +73,14 @@ 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} acceptEnabled={false} cancelName="Back">
<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"}
</Label>
{assemblies.map(x => AssemblyCard({ mira: x, update: update }))}
{assemblies.map(x => (
<AssemblyCard key={x.id} mira={x} update={update} />
))}
</div>
</Modal>
)
Expand Down
38 changes: 24 additions & 14 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 All @@ -58,7 +76,8 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ 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 */}
<div className="flex overflow-y-auto flex-col gap-2 min-w-[20vw] max-h-[45vh] bg-background-secondary rounded-md p-2">
Expand Down Expand Up @@ -94,10 +113,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 +122,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 +165,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
5 changes: 3 additions & 2 deletions fission/src/ui/panels/information/ScoreboardPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import Stack, { StackDirection } from "@/components/Stack"
import { OnScoreChangedEvent } from "@/mirabuf/ScoringZoneSceneObject"
import { usePanelControlContext } from "@/ui/PanelContext"
import PreferencesSystem, { PreferenceEvent } from "@/systems/preferences/PreferencesSystem"
import SimulationSystem from "@/systems/simulation/SimulationSystem"

const ScoreboardPanel: React.FC<PanelPropsImpl> = ({ panelId, openLocation, sidePadding }) => {
const [redScore, setRedScore] = useState<number>(0)
const [blueScore, setBlueScore] = useState<number>(0)
const [redScore, setRedScore] = useState<number>(SimulationSystem.redScore)
const [blueScore, setBlueScore] = useState<number>(SimulationSystem.blueScore)
const [initialTime] = useState<number>(-1)
const [startTime] = useState<number>(Date.now())
const [time, setTime] = useState<number>(-1)
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

0 comments on commit 5807353

Please sign in to comment.