Skip to content

Commit f03177a

Browse files
authored
Command Tool [AARD-2079] (#1274)
2 parents a7f43e4 + 4319a64 commit f03177a

File tree

13 files changed

+590
-3
lines changed

13 files changed

+590
-3
lines changed

fission/bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"colord": "^2.9.3",
2020
"electron-squirrel-startup": "^1.0.1",
2121
"framer-motion": "^10.18.0",
22+
"fuse.js": "^7.1.0",
2223
"lygia": "^1.3.3",
2324
"msw": "^2.10.4",
2425
"notistack": "^3.0.2",
@@ -1175,6 +1176,8 @@
11751176

11761177
"functions-have-names": ["[email protected]", "", {}, "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ=="],
11771178

1179+
"fuse.js": ["[email protected]", "", {}, "sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ=="],
1180+
11781181
"galactus": ["[email protected]", "", { "dependencies": { "debug": "^4.3.4", "flora-colossus": "^2.0.0", "fs-extra": "^10.1.0" } }, "sha512-R1fam6D4CyKQGNlvJne4dkNF+PvUUl7TAJInvTGa9fti9qAv95quQz29GXapA4d8Ec266mJJxFVh82M4GIIGDQ=="],
11791182

11801183
"gar": ["[email protected]", "", {}, "sha512-w4n9cPWyP7aHxKxYHFQMegj7WIAsL/YX/C4Bs5Rr8s1H9M1rNtRWRsw+ovYMkXDQ5S4ZbYHsHAPmevPjPgw44w=="],

fission/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"colord": "^2.9.3",
4646
"electron-squirrel-startup": "^1.0.1",
4747
"framer-motion": "^10.18.0",
48+
"fuse.js": "^7.1.0",
4849
"lygia": "^1.3.3",
4950
"peerjs": "^1.5.5",
5051
"msw": "^2.10.4",

fission/src/Synthesis.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import MainMenuModal from "./ui/modals/MainMenuModal.tsx"
2222
import { StateProvider } from "./ui/StateProvider.tsx"
2323
import { ThemeProvider } from "./ui/ThemeProvider.tsx"
2424
import { UIProvider } from "./ui/UIProvider.tsx"
25+
import CommandPalette from "@/ui/components/CommandPalette.tsx"
2526

2627
function Synthesis() {
2728
const [consentPopupDisable, setConsentPopupDisable] = useState<boolean>(true)
@@ -105,6 +106,7 @@ function Synthesis() {
105106
<MultiplayerHUD />
106107
<MainHUD key={"main-hud"} />
107108
<UIRenderer />
109+
<CommandPalette />
108110
<ProgressNotifications key={"progress-notifications"} />
109111
<WPILibConnectionStatus />
110112
<DragModeIndicator />

fission/src/systems/analytics/AnalyticsSystem.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export interface AnalyticsEvents {
5353
isCustomized: boolean
5454
schemeName: string
5555
}
56+
57+
"Command Executed": {
58+
command: string
59+
}
5660
}
5761

5862
class AnalyticsSystem extends WorldSystem {
@@ -77,6 +81,7 @@ class AnalyticsSystem extends WorldSystem {
7781
}
7882

7983
public event<K extends keyof AnalyticsEvents>(name: K, params?: AnalyticsEvents[K]) {
84+
console.log("AnalyticsEvent", name, params)
8085
event({ name: name, params: params ?? {} })
8186
}
8287

fission/src/systems/input/DefaultInputs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class DefaultInputs {
9191
ButtonInput.onKeyboard("eject", "KeyL"),
9292
ButtonInput.onKeyboard("unstick", "KeyK"),
9393

94-
AxisInput.onKeyboardSingleKey("joint 1", "Slash", negativeModifierKeys),
94+
AxisInput.onKeyboardSingleKey("joint 1", "Quote", negativeModifierKeys),
9595
AxisInput.onKeyboardSingleKey("joint 2", "Period", negativeModifierKeys),
9696
AxisInput.onKeyboardSingleKey("joint 3", "Comma", negativeModifierKeys),
9797
AxisInput.onKeyboardSingleKey("joint 4", "KeyM", negativeModifierKeys),

fission/src/systems/input/InputSystem.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class InputSystem extends WorldSystem {
1818
/** The keys currently being pressed. */
1919
private static _keysPressed: Partial<Record<KeyCode, boolean>> = {}
2020

21+
/** Whether the command palette is currently open, which blocks robot input */
22+
private static _isCommandPaletteOpen: boolean = false
23+
2124
private static _gpIndex: number | null
2225
public static gamepad: Gamepad | null
2326

@@ -35,6 +38,13 @@ class InputSystem extends WorldSystem {
3538
})
3639
}
3740

41+
/**
42+
* Sets whether the command palette is open, which blocks all robot inputs
43+
*/
44+
public static setCommandPaletteOpen(isOpen: boolean) {
45+
InputSystem._isCommandPaletteOpen = isOpen
46+
}
47+
3848
constructor() {
3949
super()
4050

@@ -159,6 +169,11 @@ class InputSystem extends WorldSystem {
159169
* @returns {number} A number between -1 and 1 based on the current state of the input.
160170
*/
161171
public static getInput(inputName: InputName, brainIndex: number): number {
172+
// Block all robot inputs when command palette is open
173+
if (InputSystem._isCommandPaletteOpen) {
174+
return 0
175+
}
176+
162177
const targetScheme = InputSystem.brainIndexSchemeMap.get(brainIndex)
163178

164179
const targetInput = targetScheme?.inputs.find(input => input.inputName == inputName) as Input

fission/src/systems/match_mode/MatchMode.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,26 @@ import type { MatchModeConfig } from "@/ui/panels/configuring/MatchModeConfigPan
1111
import { SoundPlayer } from "../sound/SoundPlayer"
1212
import { MatchModeType } from "./MatchModeTypes"
1313
import RobotDimensionTracker from "./RobotDimensionTracker"
14+
import CommandRegistry from "@/ui/components/CommandRegistry"
15+
import { globalAddToast, globalOpenPanel } from "@/ui/components/GlobalUIControls"
16+
17+
// Register command: Toggle Match Mode
18+
CommandRegistry.get().registerCommand({
19+
id: "toggle-match-mode",
20+
label: "Toggle Match Mode",
21+
description: "Toggle match mode, allowing you to simulate and run a full match.",
22+
keywords: ["match", "mode", "start", "play", "game", "simulate", "toggle"],
23+
perform: () => {
24+
if (MatchMode.getInstance().isMatchEnabled()) {
25+
MatchMode.getInstance().sandboxModeStart()
26+
globalAddToast("info", "Match Mode Cancelled")
27+
} else {
28+
import("@/ui/panels/configuring/MatchModeConfigPanel").then(m => {
29+
globalOpenPanel(m.default, undefined)
30+
})
31+
}
32+
},
33+
})
1434

1535
class MatchMode {
1636
private static _instance: MatchMode

0 commit comments

Comments
 (0)