@@ -24,6 +24,15 @@ import ProtectedZoneSceneObject, { ContactType } from "@/mirabuf/ProtectedZoneSc
2424import Dropdown from "@/ui/components/Dropdown"
2525import { MatchModeType } from "@/systems/MatchMode"
2626
27+ const MATCH_MODE_OPTIONS : MatchModeType [ ] = [
28+ MatchModeType . SANDBOX ,
29+ MatchModeType . AUTONOMOUS ,
30+ MatchModeType . TELEOP ,
31+ MatchModeType . ENDGAME ,
32+ ]
33+
34+ const CONTACT_TYPE_OPTIONS = Object . values ( ContactType )
35+
2736/**
2837 * Saves ejector configuration to selected field.
2938 *
@@ -271,45 +280,11 @@ const ZoneConfigInterface: React.FC<ZoneConfigProps> = ({ selectedField, selecte
271280 { /** Determines during what game state the protected zone is active */ }
272281 < Dropdown
273282 label = "Active During"
274- options = { [ "Sandbox" , "Autonomous" , "Teleop" , "Endgame" ] }
283+ options = { MATCH_MODE_OPTIONS }
275284 onSelect = { ( selectedOptions : string [ ] ) => {
276- const matchModes : MatchModeType [ ] = [ ]
277- selectedOptions . forEach ( option => {
278- switch ( option ) {
279- case "Sandbox" :
280- matchModes . push ( MatchModeType . SANDBOX )
281- break
282- case "Autonomous" :
283- matchModes . push ( MatchModeType . AUTONOMOUS )
284- break
285- case "Teleop" :
286- matchModes . push ( MatchModeType . TELEOP )
287- break
288- case "Endgame" :
289- matchModes . push ( MatchModeType . ENDGAME )
290- break
291- default :
292- break
293- }
294- } )
295- setActiveDuring ( matchModes )
285+ setActiveDuring ( selectedOptions as MatchModeType [ ] )
296286 } }
297- defaultValue = { activeDuring
298- . map ( mode => {
299- switch ( mode ) {
300- case MatchModeType . SANDBOX :
301- return "Sandbox"
302- case MatchModeType . AUTONOMOUS :
303- return "Autonomous"
304- case MatchModeType . TELEOP :
305- return "Teleop"
306- case MatchModeType . ENDGAME :
307- return "Endgame"
308- default :
309- return ""
310- }
311- } )
312- . filter ( val => val !== "" ) }
287+ defaultValue = { activeDuring }
313288 maxWidth = "15rem"
314289 multiSelect = { true }
315290 textAlign = "left"
@@ -318,44 +293,11 @@ const ZoneConfigInterface: React.FC<ZoneConfigProps> = ({ selectedField, selecte
318293 { /** Determines what type of contact is required for the penalty to apply */ }
319294 < Dropdown
320295 label = "Contact Type"
321- options = { [
322- "Robot Enters" ,
323- "Collision with Both Robots Inside" ,
324- "Collision with Opponent Robot Inside" ,
325- "Collision with Ally Robot Inside" ,
326- ] }
296+ options = { CONTACT_TYPE_OPTIONS }
327297 onSelect = { ( selectedOption : string ) => {
328- switch ( selectedOption ) {
329- case "Robot Enters" :
330- setContactType ( ContactType . ROBOT_ENTERS )
331- break
332- case "Collision with Both Robots Inside" :
333- setContactType ( ContactType . BOTH_ROBOTS_INSIDE )
334- break
335- case "Collision with Opponent Robot Inside" :
336- setContactType ( ContactType . OPPONENT_ROBOT_INSIDE )
337- break
338- case "Collision with Ally Robot Inside" :
339- setContactType ( ContactType . ALLY_ROBOT_INSIDE )
340- break
341- default :
342- break
343- }
298+ setContactType ( selectedOption as ContactType )
344299 } }
345- defaultValue = { ( ( ) => {
346- switch ( contactType ) {
347- case ContactType . ROBOT_ENTERS :
348- return "Robot Enters"
349- case ContactType . BOTH_ROBOTS_INSIDE :
350- return "Collision with Both Robots Inside"
351- case ContactType . OPPONENT_ROBOT_INSIDE :
352- return "Collision with Opponent Robot Inside"
353- case ContactType . ALLY_ROBOT_INSIDE :
354- return "Collision with Ally Robot Inside"
355- default :
356- return "Robot Enters"
357- }
358- } ) ( ) }
300+ defaultValue = { contactType }
359301 textAlign = "left"
360302 />
361303
0 commit comments