Skip to content

Commit 5807353

Browse files
[HOTFIX 1] 7.0.0b1 (#1063)
* 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]>
1 parent e9fa957 commit 5807353

File tree

10 files changed

+89
-68
lines changed

10 files changed

+89
-68
lines changed

fission/src/Synthesis.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function Synthesis() {
9595

9696
World.InitWorld()
9797

98-
if (!PreferencesSystem.getGlobalPreference<boolean>("ReportAnalytics")) {
98+
if (!PreferencesSystem.getGlobalPreference<boolean>("ReportAnalytics") && !import.meta.env.DEV) {
9999
setConsentPopupDisable(false)
100100
}
101101

fission/src/systems/analytics/AnalyticsSystem.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class AnalyticsSystem extends WorldSystem {
2727
init({
2828
measurementId: "G-6XNCRD7QNC",
2929
debug: import.meta.env.DEV,
30-
sendPageViews: true,
30+
anonymizeIp: true,
31+
sendPageViews: false,
3132
trackingConsent: PreferencesSystem.getGlobalPreference<boolean>("ReportAnalytics"),
3233
})
3334

fission/src/systems/input/InputSchemeManager.ts

+1-15
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,10 @@ class InputSchemeManager {
122122

123123
/** Save all schemes that have been customized to local storage via preferences */
124124
public static saveSchemes() {
125-
const customizedSchemes = Array.from(InputSystem.brainIndexSchemeMap.values()).filter(s => {
125+
const customizedSchemes = this.allInputSchemes.filter(s => {
126126
return s.customized
127127
})
128128

129-
// Save default schemes that have been customized if a customized version does not already exist
130-
this.defaultInputSchemes.forEach(s => {
131-
if (!s.customized) return
132-
133-
if (
134-
customizedSchemes.some(c => {
135-
if (c.schemeName === s.schemeName) return true
136-
})
137-
)
138-
return
139-
140-
customizedSchemes.push(s)
141-
})
142-
143129
PreferencesSystem.setGlobalPreference("InputSchemes", customizedSchemes)
144130
PreferencesSystem.savePreferences()
145131
}

fission/src/ui/components/Button.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ const Button: React.FC<ButtonProps> = ({ value, colorOverrideClass, sizeOverride
2525
if (!sizeClassNames) {
2626
switch (size) {
2727
case ButtonSize.Small:
28-
sizeClassNames = "px-4 py-1"
28+
sizeClassNames = "w-fit h-fit px-4 py-1"
2929
break
3030
case ButtonSize.Medium:
31-
sizeClassNames = "px-6 py-1.5"
31+
sizeClassNames = "w-fit h-fit px-6 py-1.5"
3232
break
3333
case ButtonSize.Large:
34-
sizeClassNames = "px-8 py-2"
34+
sizeClassNames = "w-fit h-fit px-8 py-2"
3535
break
3636
case ButtonSize.XL:
37-
sizeClassNames = "px-10 py-2"
37+
sizeClassNames = "w-fit h-fit px-10 py-2"
3838
break
3939
}
4040
}
@@ -46,7 +46,7 @@ const Button: React.FC<ButtonProps> = ({ value, colorOverrideClass, sizeOverride
4646
colorOverrideClass
4747
? colorOverrideClass
4848
: "bg-gradient-to-r from-interactive-element-left via-interactive-element-right to-interactive-element-left bg-[length:200%_100%] active:bg-right"
49-
} w-fit h-fit ${sizeClassNames} rounded-sm font-semibold cursor-pointer duration-200 border-none focus-visible:outline-0 focus:outline-0 ${
49+
} ${sizeClassNames} rounded-sm font-semibold cursor-pointer duration-200 border-none focus-visible:outline-0 focus:outline-0 ${
5050
className || ""
5151
}`}
5252
>

fission/src/ui/components/MainHUD.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useState } from "react"
22
import {
33
FaGear,
4-
FaMagnifyingGlass,
4+
// FaMagnifyingGlass,
55
FaPlus,
66
FaGamepad,
77
FaBasketball,
@@ -103,7 +103,7 @@ const MainHUD: React.FC = () => {
103103
onClick={() => openModal("manage-assemblies")}
104104
/>
105105
<MainHUDButton value={"Settings"} icon={<FaGear />} onClick={() => openModal("settings")} />
106-
<MainHUDButton value={"View"} icon={<FaMagnifyingGlass />} onClick={() => openModal("view")} />
106+
{/* <MainHUDButton value={"View"} icon={<FaMagnifyingGlass />} onClick={() => openModal("view")} /> */}
107107
<MainHUDButton value={"Controls"} icon={<FaGamepad />} onClick={() => openModal("change-inputs")} />
108108
<MainHUDButton
109109
value={"Import Local Mira"}

fission/src/ui/components/Modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const Modal: React.FC<ModalProps> = ({
7070
id="content"
7171
className={`${contentClassName} ${
7272
!contentClassName?.includes("mx") ? "mx-[2rem]" : ""
73-
} flex flex-col gap-4 max-h-75vh`}
73+
} flex flex-col gap-4 max-h-75vh overflow-y-auto p-4`}
7474
>
7575
{children}
7676
</div>

fission/src/ui/modals/spawning/ManageAssembliesModal.tsx

+47-26
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,68 @@
1-
import React, { useReducer } from "react"
1+
import React, { useMemo, useReducer } from "react"
22
import Modal, { ModalPropsImpl } from "@/components/Modal"
33
import { FaWrench } from "react-icons/fa6"
4-
import Button from "@/components/Button"
4+
import Button, { ButtonProps } from "@/components/Button"
55
import Label, { LabelSize } from "@/components/Label"
66
import World from "@/systems/World"
77
import MirabufSceneObject from "@/mirabuf/MirabufSceneObject"
8+
import { usePanelControlContext } from "@/ui/PanelContext"
9+
import { setSelectedBrainIndexGlobal } from "@/ui/panels/configuring/ChooseInputSchemePanel"
10+
import SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain"
11+
import { useModalControlContext } from "@/ui/ModalContext"
12+
import InputSystem from "@/systems/input/InputSystem"
13+
import { IoTrashBin } from "react-icons/io5"
814

915
interface AssemblyCardProps {
1016
mira: MirabufSceneObject
1117
update: React.DispatchWithoutAction
1218
}
1319

20+
const ButtonSecondary: React.FC<ButtonProps> = ({ value, onClick }) => {
21+
return (
22+
<Button
23+
sizeOverrideClass="px-6 py-2"
24+
value={value}
25+
onClick={onClick}
26+
colorOverrideClass="bg-cancel-button hover:brightness-90"
27+
></Button>
28+
)
29+
}
30+
1431
const AssemblyCard: React.FC<AssemblyCardProps> = ({ mira, update }) => {
32+
const { openPanel } = usePanelControlContext()
33+
const { closeModal } = useModalControlContext()
34+
35+
const brain = useMemo(() => (mira.brain as SynthesisBrain)?.brainIndex, [mira])
36+
1537
return (
1638
<div
1739
key={mira.id}
1840
className="flex flex-row align-middle justify-between items-center bg-background rounded-sm p-2 gap-2"
1941
>
20-
<Label className="text-wrap break-all">{mira.assemblyName}</Label>
21-
<Button
22-
value="Delete"
23-
onClick={() => {
24-
World.SceneRenderer.RemoveSceneObject(mira.id)
25-
update()
26-
}}
27-
/>
42+
<Label className="text-wrap break-all">{`[${InputSystem.brainIndexSchemeMap.get(brain)?.schemeName ?? "-"}] ${mira.assemblyName}`}</Label>
43+
<div className="flex flex-row gap-4">
44+
<Button
45+
sizeOverrideClass="px-6 py-2"
46+
value="Set Scheme"
47+
onClick={() => {
48+
setSelectedBrainIndexGlobal(brain)
49+
openPanel("choose-scheme")
50+
closeModal()
51+
}}
52+
/>
53+
<ButtonSecondary
54+
value={<IoTrashBin />}
55+
onClick={() => {
56+
World.SceneRenderer.RemoveSceneObject(mira.id)
57+
update()
58+
}}
59+
/>
60+
</div>
2861
</div>
2962
)
3063
}
3164

3265
const ManageAssembliesModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
33-
// update tooltip based on type of drivetrain, receive message from Synthesis
34-
// const { showTooltip } = useTooltipControlContext()
35-
3666
const [_, update] = useReducer(x => !x, false)
3767

3868
const assemblies = [...World.SceneRenderer.sceneObjects.entries()]
@@ -43,23 +73,14 @@ const ManageAssembliesModal: React.FC<ModalPropsImpl> = ({ modalId }) => {
4373
.map(x => x[1] as MirabufSceneObject)
4474

4575
return (
46-
<Modal
47-
name={"Manage Assemblies"}
48-
icon={<FaWrench />}
49-
modalId={modalId}
50-
onAccept={() => {
51-
// showTooltip("controls", [
52-
// { control: "WASD", description: "Drive" },
53-
// { control: "E", description: "Intake" },
54-
// { control: "Q", description: "Dispense" },
55-
// ]);
56-
}}
57-
>
76+
<Modal name={"Manage Assemblies"} icon={<FaWrench />} modalId={modalId} acceptEnabled={false} cancelName="Back">
5877
<div className="flex overflow-y-auto flex-col gap-2 min-w-[50vw] max-h-[60vh] bg-background-secondary rounded-md p-2">
5978
<Label size={LabelSize.Medium} className="text-center border-b-[1pt] mt-[4pt] mb-[2pt] mx-[5%]">
6079
{assemblies ? `${assemblies.length} Assemblies` : "No Assemblies"}
6180
</Label>
62-
{assemblies.map(x => AssemblyCard({ mira: x, update: update }))}
81+
{assemblies.map(x => (
82+
<AssemblyCard key={x.id} mira={x} update={update} />
83+
))}
6384
</div>
6485
</Modal>
6586
)

fission/src/ui/panels/configuring/ChooseInputSchemePanel.tsx

+24-14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ import { useEffect, useReducer } from "react"
1313
import { AiOutlinePlus } from "react-icons/ai"
1414
import { IoCheckmark, IoPencil, IoTrashBin } from "react-icons/io5"
1515

16+
let selectedBrainIndexGlobal: number | undefined = undefined
17+
// eslint-disable-next-line react-refresh/only-export-components
18+
export function setSelectedBrainIndexGlobal(index: number | undefined) {
19+
selectedBrainIndexGlobal = index
20+
}
21+
22+
function getBrainIndex() {
23+
return selectedBrainIndexGlobal != undefined ? selectedBrainIndexGlobal : SynthesisBrain.brainIndexMap.size - 1
24+
}
25+
1626
const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
1727
const { closePanel } = usePanelControlContext()
1828
const { openModal } = useModalControlContext()
@@ -38,7 +48,8 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
3848

3949
/** If the panel is closed before a scheme is selected, defaults to the top of the list */
4050
return () => {
41-
const brainIndex = SynthesisBrain.brainIndexMap.size - 1
51+
const brainIndex = getBrainIndex()
52+
console.log(brainIndex)
4253

4354
if (InputSystem.brainIndexSchemeMap.has(brainIndex)) return
4455

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

5061
openModal("change-inputs")
5162
}
63+
// eslint-disable-next-line react-hooks/exhaustive-deps
64+
}, [])
65+
66+
useEffect(() => {
67+
return () => {
68+
selectedBrainIndexGlobal = undefined
69+
}
5270
}, [])
5371

5472
return (
@@ -58,7 +76,8 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
5876
openLocation={"right"}
5977
sidePadding={8}
6078
acceptEnabled={false}
61-
cancelEnabled={false}
79+
cancelEnabled={selectedBrainIndexGlobal != undefined}
80+
cancelName="Close"
6281
>
6382
{/** A scroll view with buttons to select default and custom input schemes */}
6483
<div className="flex overflow-y-auto flex-col gap-2 min-w-[20vw] max-h-[45vh] bg-background-secondary rounded-md p-2">
@@ -94,10 +113,7 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
94113
<Button
95114
value={SelectIcon}
96115
onClick={() => {
97-
InputSystem.brainIndexSchemeMap.set(
98-
SynthesisBrain.brainIndexMap.size - 1,
99-
scheme
100-
)
116+
InputSystem.brainIndexSchemeMap.set(getBrainIndex(), scheme)
101117
closePanel(panelId)
102118
}}
103119
colorOverrideClass="bg-accept-button hover:brightness-90"
@@ -106,10 +122,7 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
106122
<Button
107123
value={EditIcon}
108124
onClick={() => {
109-
InputSystem.brainIndexSchemeMap.set(
110-
SynthesisBrain.brainIndexMap.size - 1,
111-
scheme
112-
)
125+
InputSystem.brainIndexSchemeMap.set(getBrainIndex(), scheme)
113126
InputSystem.selectedScheme = scheme
114127
openModal("change-inputs")
115128
}}
@@ -152,10 +165,7 @@ const ChooseInputSchemePanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
152165
<Button
153166
value={AddIcon}
154167
onClick={() => {
155-
InputSystem.brainIndexSchemeMap.set(
156-
SynthesisBrain.brainIndexMap.size - 1,
157-
DefaultInputs.newBlankScheme
158-
)
168+
InputSystem.brainIndexSchemeMap.set(getBrainIndex(), DefaultInputs.newBlankScheme)
159169
openModal("assign-new-scheme")
160170
}}
161171
/>

fission/src/ui/panels/information/ScoreboardPanel.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import Stack, { StackDirection } from "@/components/Stack"
55
import { OnScoreChangedEvent } from "@/mirabuf/ScoringZoneSceneObject"
66
import { usePanelControlContext } from "@/ui/PanelContext"
77
import PreferencesSystem, { PreferenceEvent } from "@/systems/preferences/PreferencesSystem"
8+
import SimulationSystem from "@/systems/simulation/SimulationSystem"
89

910
const ScoreboardPanel: React.FC<PanelPropsImpl> = ({ panelId, openLocation, sidePadding }) => {
10-
const [redScore, setRedScore] = useState<number>(0)
11-
const [blueScore, setBlueScore] = useState<number>(0)
11+
const [redScore, setRedScore] = useState<number>(SimulationSystem.redScore)
12+
const [blueScore, setBlueScore] = useState<number>(SimulationSystem.blueScore)
1213
const [initialTime] = useState<number>(-1)
1314
const [startTime] = useState<number>(Date.now())
1415
const [time, setTime] = useState<number>(-1)

fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,10 @@ const ImportMirabufPanel: React.FC<PanelPropsImpl> = ({ panelId }) => {
282282
.catch(() => status.Fail())
283283

284284
closePanel(panelId)
285+
286+
if (type == MiraType.ROBOT) openPanel("choose-scheme")
285287
},
286-
[closePanel, panelId]
288+
[closePanel, panelId, openPanel]
287289
)
288290

289291
// Generate Item cards for cached robots.

0 commit comments

Comments
 (0)