@roster-lock/match-agent 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/index-D2395vmC.css +1 -0
- package/client/dist/assets/index-DcKsa72V.js +125 -0
- package/client/dist/index.html +2 -2
- package/client/e2e/lib/env.ts +50 -0
- package/client/e2e/lib/fileDialog.ts +31 -0
- package/client/e2e/lib/mockGamepad.ts +71 -0
- package/client/e2e/lib/onscreenKeyboard.ts +32 -0
- package/client/e2e/playwright.config.ts +48 -0
- package/client/e2e/tests/gamepad-only.spec.ts +274 -0
- package/client/e2e/tests/keyboard-only.spec.ts +67 -0
- package/client/e2e/tsconfig.json +15 -0
- package/client/node_modules/.bin/playwright +17 -0
- package/client/node_modules/.bin/roster-lock-plugin-manager +17 -0
- package/client/node_modules/.vite/deps/@roster-lock_ts-client.js +2 -2
- package/client/node_modules/.vite/deps/@roster-lock_types.js +1 -1
- package/client/node_modules/.vite/deps/@roster-lock_utils.js +1 -1
- package/client/node_modules/.vite/deps/_metadata.json +18 -18
- package/client/node_modules/.vite/deps/{chunk-CKYX73LL.js → chunk-3HBL6DQ6.js} +1 -1
- package/client/node_modules/.vite/deps/{chunk-CKYX73LL.js.map → chunk-3HBL6DQ6.js.map} +2 -2
- package/client/node_modules/.vite/deps/{chunk-EDVVVQBR.js → chunk-QTQN6EZX.js} +2 -2
- package/client/node_modules/.vite/deps/chunk-QTQN6EZX.js.map +7 -0
- package/client/package.json +4 -1
- package/client/src/App.tsx +23 -14
- package/client/src/NavBar.tsx +15 -5
- package/client/src/api/matchAgent.ts +193 -5
- package/client/src/bridge/hostBridge.ts +15 -5
- package/client/src/components/FullScreenMenu.tsx +32 -0
- package/client/src/components/GameLauncherSettingsForm.tsx +80 -5
- package/client/src/components/InputHints.tsx +37 -0
- package/client/src/components/OnScreenFileDialog.tsx +83 -0
- package/client/src/components/OnScreenKeyboard.tsx +75 -0
- package/client/src/components/Selection/PieceCard.tsx +29 -4
- package/client/src/components/Selection/PiecePreviewPanel.tsx +48 -0
- package/client/src/components/Selection/PieceTypeSection.tsx +124 -46
- package/client/src/components/Selection/PlayerSelectionPanel.tsx +1 -5
- package/client/src/components/Selection/index.tsx +72 -47
- package/client/src/context/GlobalNavContext.tsx +340 -0
- package/client/src/context/SelectionSourceContext.tsx +26 -0
- package/client/src/hooks/useCursorInput.ts +66 -24
- package/client/src/hooks/useDownloadedPieceVersions.ts +39 -0
- package/client/src/hooks/useGridColumns.ts +29 -0
- package/client/src/hooks/useInView.ts +32 -0
- package/client/src/hooks/usePiecePreview.ts +124 -0
- package/client/src/pages/Controls/index.tsx +126 -0
- package/client/src/pages/Game/index.tsx +11 -15
- package/client/src/pages/MatchMaking/index.tsx +6 -3
- package/client/src/pages/PreviewRoster/index.tsx +118 -0
- package/client/src/styles/global.css +355 -6
- package/client/src/utils/inputLabels.ts +25 -0
- package/client/test-results/.last-run.json +4 -0
- package/client/tsconfig.tsbuildinfo +1 -1
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/inputBindings.js +40 -0
- package/dist/config/inputBindings.js.map +1 -0
- package/dist/config/manage.js +1 -0
- package/dist/config/manage.js.map +1 -1
- package/dist/handle-room/version-1/game-launcher/binaries.js +36 -0
- package/dist/handle-room/version-1/game-launcher/binaries.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/listing.js +24 -0
- package/dist/handle-room/version-1/game-launcher/listing.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/preview.js +38 -0
- package/dist/handle-room/version-1/game-launcher/preview.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/process.js +52 -0
- package/dist/handle-room/version-1/game-launcher/process.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/router.js +32 -0
- package/dist/handle-room/version-1/game-launcher/router.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/settings.js +49 -0
- package/dist/handle-room/version-1/game-launcher/settings.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/shared.js +28 -0
- package/dist/handle-room/version-1/game-launcher/shared.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/start.js +76 -0
- package/dist/handle-room/version-1/game-launcher/start.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/version.js +63 -0
- package/dist/handle-room/version-1/game-launcher/version.js.map +1 -0
- package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/ensurePieceExists.js +22 -9
- package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/ensurePieceExists.js.map +1 -1
- package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/schema.js +50 -1
- package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/schema.js.map +1 -1
- package/dist/handle-room/version-1/index.js +15 -16
- package/dist/handle-room/version-1/index.js.map +1 -1
- package/dist/handle-room/version-1/input-bindings.js +22 -0
- package/dist/handle-room/version-1/input-bindings.js.map +1 -0
- package/dist/handle-room/version-1/room-handler-bridge/exchange-and-download-selections.js +2 -1
- package/dist/handle-room/version-1/room-handler-bridge/exchange-and-download-selections.js.map +1 -1
- package/dist/handle-room/version-1/room-handler-bridge/http-handler.js +1 -1
- package/dist/handle-room/version-1/room-handler-bridge/http-handler.js.map +1 -1
- package/dist/handle-room/version-1/room-handler-bridge/steps.js +2 -1
- package/dist/handle-room/version-1/room-handler-bridge/steps.js.map +1 -1
- package/dist/handle-room/version-1/room-handler-bridge/ws-handler.js +2 -2
- package/dist/handle-room/version-1/room-handler-bridge/ws-handler.js.map +1 -1
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/dist/util-routers/file-system/env.js +3 -0
- package/dist/util-routers/file-system/env.js.map +1 -0
- package/dist/util-routers/file-system/index.js +31 -0
- package/dist/util-routers/file-system/index.js.map +1 -0
- package/dist/util-routers/file-system/list.js +50 -0
- package/dist/util-routers/file-system/list.js.map +1 -0
- package/dist/util-routers/file-system/resolve-within-root.js +18 -0
- package/dist/util-routers/file-system/resolve-within-root.js.map +1 -0
- package/dist/util-routers/file-system/roster-lock.js +56 -0
- package/dist/util-routers/file-system/roster-lock.js.map +1 -0
- package/dist/utils/pick-file.js +82 -0
- package/dist/utils/pick-file.js.map +1 -0
- package/dist/utils/pick-folder.js +84 -0
- package/dist/utils/pick-folder.js.map +1 -0
- package/package.json +9 -8
- package/src/config/index.ts +8 -3
- package/src/config/inputBindings.ts +56 -0
- package/src/config/manage.ts +7 -0
- package/src/handle-room/version-1/game-launcher/binaries.ts +52 -0
- package/src/handle-room/version-1/game-launcher/listing.ts +36 -0
- package/src/handle-room/version-1/game-launcher/preview.ts +54 -0
- package/src/handle-room/version-1/game-launcher/process.ts +75 -0
- package/src/handle-room/version-1/game-launcher/router.ts +42 -0
- package/src/handle-room/version-1/game-launcher/settings.ts +58 -0
- package/src/handle-room/version-1/game-launcher/shared.ts +34 -0
- package/src/handle-room/version-1/game-launcher/start.ts +113 -0
- package/src/handle-room/version-1/game-launcher/version.ts +85 -0
- package/src/handle-room/version-1/globals/FolderDB/SQLFolderDB/ensurePieceExists.ts +39 -14
- package/src/handle-room/version-1/globals/FolderDB/SQLFolderDB/schema.ts +83 -1
- package/src/handle-room/version-1/globals/FolderDB/types.ts +24 -0
- package/src/handle-room/version-1/globals/types.ts +24 -2
- package/src/handle-room/version-1/index.ts +27 -26
- package/src/handle-room/version-1/input-bindings.ts +19 -0
- package/src/handle-room/version-1/room-handler-bridge/exchange-and-download-selections.ts +4 -1
- package/src/handle-room/version-1/room-handler-bridge/http-handler.ts +4 -1
- package/src/handle-room/version-1/room-handler-bridge/steps.ts +8 -0
- package/src/handle-room/version-1/room-handler-bridge/ws-handler.ts +2 -2
- package/src/index.ts +42 -10
- package/src/util-routers/file-system/env.ts +7 -0
- package/src/util-routers/file-system/index.ts +23 -0
- package/src/util-routers/file-system/list.ts +62 -0
- package/src/util-routers/file-system/resolve-within-root.ts +25 -0
- package/src/util-routers/file-system/roster-lock.ts +74 -0
- package/src/utils/pick-file.ts +81 -0
- package/src/utils/pick-folder.ts +92 -0
- package/tests/integration/filesystem.test.ts +117 -0
- package/tests/integration/game-launcher-binaries.test.ts +263 -0
- package/tests/integration/game-launcher-game-complete.test.ts +111 -0
- package/tests/integration/game-launcher-preview.test.ts +107 -0
- package/tests/integration/game-launcher-settings.test.ts +123 -8
- package/tests/integration/game-processes-ws.test.ts +122 -0
- package/tests/integration/helpers/fakeFolderDB.ts +16 -0
- package/tests/integration/helpers/fakePluginRuntime.ts +10 -1
- package/tests/integration/helpers/server.ts +23 -3
- package/tests/integration/input-bindings.test.ts +94 -0
- package/tests/integration/piece-files.test.ts +1 -1
- package/tests/integration/roster-lock.test.ts +86 -0
- package/vitest.config.ts +7 -1
- package/client/dist/assets/index-CX6eCHuc.js +0 -125
- package/client/dist/assets/index-gxAuIfGQ.css +0 -1
- package/client/node_modules/.vite/deps/chunk-EDVVVQBR.js.map +0 -7
- package/dist/handle-room/version-1/game-launcher.js +0 -197
- package/dist/handle-room/version-1/game-launcher.js.map +0 -1
- package/src/handle-room/version-1/game-launcher.ts +0 -287
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { RefObject, useEffect, useState } from "react";
|
|
2
|
+
import { useMatchAgent } from "../context/MatchAgentContext";
|
|
3
|
+
import { useGlobalNav, FileDialogState } from "../context/GlobalNavContext";
|
|
4
|
+
import { listDirectory, DirectoryListing } from "../api/matchAgent";
|
|
5
|
+
import { backHint } from "../utils/inputLabels";
|
|
6
|
+
|
|
7
|
+
// A file picker rendered in the page itself - every row is a plain
|
|
8
|
+
// <button>, so it's reachable through the exact same Move/Select/Back
|
|
9
|
+
// scheme (GlobalNavContext) as everything else in the shell, unlike a
|
|
10
|
+
// native OS file dialog (pick-file.ts/api/matchAgent's
|
|
11
|
+
// pickRosterLockFile), which is a window outside the browser entirely and
|
|
12
|
+
// so has no way for a gamepad to reach it at all. Opened via
|
|
13
|
+
// useGlobalNav().pickFile(...), not mounted directly by callers.
|
|
14
|
+
export function OnScreenFileDialog({ containerRef, state }: {
|
|
15
|
+
containerRef: RefObject<HTMLDivElement | null>,
|
|
16
|
+
state: FileDialogState | null,
|
|
17
|
+
}) {
|
|
18
|
+
const { settings } = useMatchAgent();
|
|
19
|
+
const { inputDevice, keyboardBindings, gamepadBindings } = useGlobalNav();
|
|
20
|
+
const [currentPath, setCurrentPath] = useState<string | undefined>(undefined);
|
|
21
|
+
const [listing, setListing] = useState<DirectoryListing | null>(null);
|
|
22
|
+
const [error, setError] = useState<string | null>(null);
|
|
23
|
+
|
|
24
|
+
// Resets to the dialog's own starting folder each time it's (re)opened,
|
|
25
|
+
// rather than wherever a previous use of it left off.
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setCurrentPath(state?.startPath);
|
|
28
|
+
setListing(null);
|
|
29
|
+
setError(null);
|
|
30
|
+
}, [state]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!state) return;
|
|
34
|
+
let cancelled = false;
|
|
35
|
+
listDirectory(settings.url, settings.authCode, currentPath, state.extension)
|
|
36
|
+
.then((result) => { if (!cancelled) setListing(result); })
|
|
37
|
+
.catch((e) => { if (!cancelled) setError(e.message); });
|
|
38
|
+
return () => { cancelled = true; };
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [state, currentPath, settings.url, settings.authCode]);
|
|
41
|
+
|
|
42
|
+
// Re-focuses the first row once a (new) folder's listing actually
|
|
43
|
+
// renders - GlobalNavContext's own open-focus effect only fires when the
|
|
44
|
+
// dialog first opens, since it has no visibility into which folder is
|
|
45
|
+
// currently showing (that state lives here, not there).
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (listing) containerRef.current?.querySelector<HTMLElement>("button")?.focus();
|
|
48
|
+
}, [listing, containerRef]);
|
|
49
|
+
|
|
50
|
+
if (!state) return null;
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className="onscreen-keyboard-backdrop">
|
|
54
|
+
<div className="onscreen-file-dialog" ref={containerRef}>
|
|
55
|
+
<div className="onscreen-file-dialog-path">{listing?.path ?? currentPath ?? "Loading..."}</div>
|
|
56
|
+
{error && <p className="error">{error}</p>}
|
|
57
|
+
<div className="onscreen-file-dialog-list">
|
|
58
|
+
{listing?.parent !== null && listing && (
|
|
59
|
+
<button type="button" onClick={() => setCurrentPath(listing.parent!)}>.. (up a folder)</button>
|
|
60
|
+
)}
|
|
61
|
+
{listing?.entries.map((entry) => (
|
|
62
|
+
<button
|
|
63
|
+
key={entry.path}
|
|
64
|
+
type="button"
|
|
65
|
+
data-directory={entry.isDirectory}
|
|
66
|
+
onClick={() => (entry.isDirectory ? setCurrentPath(entry.path) : state.resolve(entry.path))}
|
|
67
|
+
>
|
|
68
|
+
{entry.name}{entry.isDirectory ? "/" : ""}
|
|
69
|
+
</button>
|
|
70
|
+
))}
|
|
71
|
+
{listing && listing.entries.length === 0 && listing.parent !== null && (
|
|
72
|
+
<p className="onscreen-file-dialog-empty">Nothing here{state.extensionLabel ? ` (showing ${state.extensionLabel})` : ""}.</p>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
<div className="onscreen-file-dialog-footer">
|
|
76
|
+
<button type="button" className="onscreen-file-dialog-cancel" onClick={() => state.resolve(null)}>
|
|
77
|
+
Cancel ({backHint(inputDevice, keyboardBindings, gamepadBindings)})
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import { useGlobalNav } from "../context/GlobalNavContext";
|
|
3
|
+
import { backHint } from "../utils/inputLabels";
|
|
4
|
+
|
|
5
|
+
// Punctuation matters here specifically because this app's own text
|
|
6
|
+
// fields need it - a matchmaker URL ("http://localhost:58732") or a saved
|
|
7
|
+
// IP address is unusable without ":", "/", and ".", and without this row a
|
|
8
|
+
// gamepad-only player (no physical keyboard to fall back to) would have no
|
|
9
|
+
// way to type one at all.
|
|
10
|
+
const ROWS = [
|
|
11
|
+
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
|
|
12
|
+
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
|
|
13
|
+
["a", "s", "d", "f", "g", "h", "j", "k", "l"],
|
|
14
|
+
["z", "x", "c", "v", "b", "n", "m"],
|
|
15
|
+
[".", ":", "/", "-", "_"],
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
// The standard trick for writing into a React-controlled input from outside
|
|
19
|
+
// React: assigning el.value directly is intercepted by React's own tracked
|
|
20
|
+
// setter, so the native setter has to be called explicitly before the
|
|
21
|
+
// "input" event is dispatched for React to pick the change up.
|
|
22
|
+
function setNativeValue(el: HTMLInputElement | HTMLTextAreaElement, value: string) {
|
|
23
|
+
const proto = el instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
|
|
24
|
+
const setter = Object.getOwnPropertyDescriptor(proto, "value")?.set;
|
|
25
|
+
setter?.call(el, value);
|
|
26
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Shown whenever a gamepad confirms a text field (see GlobalNavContext) -
|
|
30
|
+
// a controller has no other way to type into it. Only appends/removes at
|
|
31
|
+
// the end of the field rather than supporting mid-string cursor placement;
|
|
32
|
+
// for the short fields this is used on (player labels, a matchmaker URL)
|
|
33
|
+
// clearing and retyping is an acceptable trade-off against the complexity
|
|
34
|
+
// of gamepad-driven cursor placement.
|
|
35
|
+
export function OnScreenKeyboard({ containerRef, target, onClose }: {
|
|
36
|
+
containerRef: RefObject<HTMLDivElement | null>,
|
|
37
|
+
target: HTMLInputElement | HTMLTextAreaElement | null,
|
|
38
|
+
onClose: () => void,
|
|
39
|
+
}) {
|
|
40
|
+
const { inputDevice, keyboardBindings, gamepadBindings } = useGlobalNav();
|
|
41
|
+
if (!target) return null;
|
|
42
|
+
|
|
43
|
+
// Deliberately doesn't re-focus `target` afterwards: setNativeValue
|
|
44
|
+
// doesn't need it focused, and doing so would yank document.activeElement
|
|
45
|
+
// off whichever OSK button was just pressed - the next Move press (see
|
|
46
|
+
// GlobalNavContext) would then lose its place and reset to the start of
|
|
47
|
+
// the keyboard instead of continuing from a key that's probably still
|
|
48
|
+
// nearby.
|
|
49
|
+
const press = (key: string) => {
|
|
50
|
+
if (key === "back") setNativeValue(target, target.value.slice(0, -1));
|
|
51
|
+
else if (key === "space") setNativeValue(target, `${target.value} `);
|
|
52
|
+
else setNativeValue(target, `${target.value}${key}`);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className="onscreen-keyboard-backdrop">
|
|
57
|
+
<div className="onscreen-keyboard" ref={containerRef}>
|
|
58
|
+
{ROWS.map((row, i) => (
|
|
59
|
+
<div key={i} className="onscreen-keyboard-row">
|
|
60
|
+
{row.map((key) => (
|
|
61
|
+
<button key={key} type="button" onClick={() => press(key)}>{key}</button>
|
|
62
|
+
))}
|
|
63
|
+
</div>
|
|
64
|
+
))}
|
|
65
|
+
<div className="onscreen-keyboard-row">
|
|
66
|
+
<button type="button" className="onscreen-keyboard-space" onClick={() => press("space")}>Space</button>
|
|
67
|
+
<button type="button" onClick={() => press("back")}>Back</button>
|
|
68
|
+
<button type="button" className="onscreen-keyboard-done" onClick={onClose}>
|
|
69
|
+
Done ({backHint(inputDevice, keyboardBindings, gamepadBindings)})
|
|
70
|
+
</button>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -1,19 +1,44 @@
|
|
|
1
1
|
import { RosterLockPiece } from "@roster-lock/types";
|
|
2
|
+
import { useInView } from "../../hooks/useInView";
|
|
3
|
+
import { usePiecePreview, previewImage } from "../../hooks/usePiecePreview";
|
|
2
4
|
|
|
3
|
-
export function PieceCard({
|
|
5
|
+
export function PieceCard({
|
|
6
|
+
piece, pieceType, selected, orderNumber, downloaded, cursored, disabled, onClick, onHoverChange,
|
|
7
|
+
}: {
|
|
4
8
|
piece: RosterLockPiece,
|
|
9
|
+
pieceType: string,
|
|
5
10
|
selected: boolean,
|
|
6
11
|
orderNumber: number | undefined,
|
|
7
12
|
downloaded: boolean | undefined,
|
|
8
13
|
cursored: boolean,
|
|
9
14
|
disabled: boolean,
|
|
10
15
|
onClick: () => void,
|
|
16
|
+
onHoverChange?: (hovering: boolean) => void,
|
|
11
17
|
}) {
|
|
18
|
+
const [inViewRef, inView] = useInView<HTMLButtonElement>();
|
|
19
|
+
|
|
20
|
+
// Only a downloaded piece has assets for the game launcher to read a real
|
|
21
|
+
// portrait out of. Asking about an undownloaded one gets the plugin's
|
|
22
|
+
// generic engine placeholder instead (source "default"), which across a
|
|
23
|
+
// whole grid would paint every unowned piece with the same silhouette and
|
|
24
|
+
// hide the roster author's own thumbnails - so those cards don't ask, and
|
|
25
|
+
// the ones that do ignore a "default" answer. Gated on inView as well:
|
|
26
|
+
// each answer costs match-agent a sprite decode, and a several-hundred
|
|
27
|
+
// piece roster shouldn't pay for the rows nobody has scrolled to.
|
|
28
|
+
const preview = usePiecePreview({ pieceType, piece, enabled: inView && downloaded === true });
|
|
29
|
+
const launcherImage = preview.status === "ready" && preview.source === "piece"
|
|
30
|
+
? previewImage(preview.preview)
|
|
31
|
+
: undefined;
|
|
32
|
+
const image = launcherImage ?? piece.humanInfo.image;
|
|
33
|
+
|
|
12
34
|
return (
|
|
13
35
|
<button
|
|
36
|
+
ref={inViewRef}
|
|
14
37
|
type="button"
|
|
15
38
|
className="piece-card"
|
|
16
39
|
onClick={onClick}
|
|
40
|
+
onMouseEnter={() => onHoverChange?.(true)}
|
|
41
|
+
onMouseLeave={() => onHoverChange?.(false)}
|
|
17
42
|
disabled={disabled && !selected}
|
|
18
43
|
data-selected={selected}
|
|
19
44
|
data-cursored={cursored}
|
|
@@ -21,14 +46,14 @@ export function PieceCard({ piece, selected, orderNumber, downloaded, cursored,
|
|
|
21
46
|
>
|
|
22
47
|
<div className="piece-card-image">
|
|
23
48
|
{orderNumber !== undefined && <span className="piece-card-order-badge">{orderNumber}</span>}
|
|
24
|
-
{
|
|
25
|
-
<img src={
|
|
49
|
+
{image ? (
|
|
50
|
+
<img src={image} alt={piece.humanInfo.name} />
|
|
26
51
|
) : (
|
|
27
52
|
<span className="piece-card-placeholder">{piece.humanInfo.name.slice(0, 1).toUpperCase()}</span>
|
|
28
53
|
)}
|
|
29
54
|
</div>
|
|
30
55
|
<div className="piece-card-name">{piece.humanInfo.name}</div>
|
|
31
|
-
<div className="piece-card-status">
|
|
56
|
+
<div className="piece-card-status" data-downloaded={downloaded === undefined ? "unknown" : downloaded}>
|
|
32
57
|
{downloaded === undefined ? "" : downloaded ? "Downloaded" : "Not downloaded"}
|
|
33
58
|
</div>
|
|
34
59
|
</button>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RosterLockPiece } from "@roster-lock/types";
|
|
2
|
+
import { usePiecePreview, previewImage } from "../../hooks/usePiecePreview";
|
|
3
|
+
|
|
4
|
+
// The one large preview beside the grid, for whichever piece is hovered or
|
|
5
|
+
// under a player's cursor. Three images can answer for a piece, and they're
|
|
6
|
+
// not equally good:
|
|
7
|
+
//
|
|
8
|
+
// 1. the game launcher's own preview, read out of the piece's downloaded
|
|
9
|
+
// assets (Ikemen's 9000,1 select portrait, say) - the real thing,
|
|
10
|
+
// 2. humanInfo.image, the roster author's thumbnail baked into the lock
|
|
11
|
+
// file - always available, but only as good as the author made it,
|
|
12
|
+
// 3. the launcher's generic engine placeholder, which is all it can offer
|
|
13
|
+
// for a piece that isn't downloaded yet.
|
|
14
|
+
//
|
|
15
|
+
// Both (1) and (3) arrive as one PiecePreview; `source` is what separates
|
|
16
|
+
// them, and it's the reason a not-yet-downloaded piece still shows its own
|
|
17
|
+
// author thumbnail here instead of the same silhouette as everything else.
|
|
18
|
+
export function PiecePreviewPanel({ piece, pieceType }: {
|
|
19
|
+
piece: RosterLockPiece | null,
|
|
20
|
+
pieceType: string,
|
|
21
|
+
}) {
|
|
22
|
+
// priority: this is answering a piece the player is pointing at right now,
|
|
23
|
+
// so it jumps ahead of the card thumbnails queued behind it.
|
|
24
|
+
const preview = usePiecePreview({ pieceType, piece, priority: true });
|
|
25
|
+
|
|
26
|
+
if (!piece) return null;
|
|
27
|
+
|
|
28
|
+
const launcherImage = preview.status === "ready" ? previewImage(preview.preview) : undefined;
|
|
29
|
+
const image = (preview.status === "ready" && preview.source === "piece" && launcherImage)
|
|
30
|
+
|| piece.humanInfo.image
|
|
31
|
+
|| launcherImage;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className="piece-preview-panel">
|
|
35
|
+
<div className="piece-preview-frame">
|
|
36
|
+
{image ? (
|
|
37
|
+
<img className="piece-preview-image" src={image} alt={piece.humanInfo.name} />
|
|
38
|
+
) : preview.status === "loading" ? (
|
|
39
|
+
<span className="piece-preview-loading">Loading preview…</span>
|
|
40
|
+
) : (
|
|
41
|
+
<span className="piece-preview-placeholder">No preview</span>
|
|
42
|
+
)}
|
|
43
|
+
</div>
|
|
44
|
+
<div className="piece-preview-name">{piece.humanInfo.name}</div>
|
|
45
|
+
{piece.humanInfo.author && <div className="piece-preview-author">by {piece.humanInfo.author}</div>}
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -1,13 +1,34 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { RosterLockV1Config } from "@roster-lock/types";
|
|
3
3
|
import { PieceTypePlan } from "./selectionPlan";
|
|
4
4
|
import { PieceCard } from "./PieceCard";
|
|
5
|
+
import { PiecePreviewPanel } from "./PiecePreviewPanel";
|
|
5
6
|
import { InputSource } from "../../context/JoinSettingsContext";
|
|
6
7
|
import { useCursorInput } from "../../hooks/useCursorInput";
|
|
7
|
-
import {
|
|
8
|
+
import { useGridColumns } from "../../hooks/useGridColumns";
|
|
9
|
+
import { useDownloadedPieceVersions } from "../../hooks/useDownloadedPieceVersions";
|
|
10
|
+
|
|
11
|
+
// Rosters here run from a handful of pieces (a curated tournament lock) to
|
|
12
|
+
// several hundred (a full MUGEN-style collection), and one fixed card size
|
|
13
|
+
// serves neither end: large cards turn a 300-piece roster into an endless
|
|
14
|
+
// scroll, small ones leave a 6-piece roster as a row of stamps in a mostly
|
|
15
|
+
// empty panel. Density scales the cards off how many there are (the actual
|
|
16
|
+
// sizes live in global.css, keyed off data-density) and only the crowded
|
|
17
|
+
// tiers pay for a filter box and a height-capped scrolling grid.
|
|
18
|
+
const COZY_MAX_PIECES = 12;
|
|
19
|
+
const COMFY_MAX_PIECES = 60;
|
|
20
|
+
const FILTER_MIN_PIECES = 24;
|
|
21
|
+
|
|
22
|
+
type Density = "cozy" | "comfy" | "dense";
|
|
23
|
+
|
|
24
|
+
function densityFor(pieceCount: number): Density {
|
|
25
|
+
if (pieceCount <= COZY_MAX_PIECES) return "cozy";
|
|
26
|
+
if (pieceCount <= COMFY_MAX_PIECES) return "comfy";
|
|
27
|
+
return "dense";
|
|
28
|
+
}
|
|
8
29
|
|
|
9
30
|
export function PieceTypeSection({
|
|
10
|
-
rosterConfig, pieceType, plan, picks, onTogglePick, onReorderPick, inputSource,
|
|
31
|
+
rosterConfig, pieceType, plan, picks, onTogglePick, onReorderPick, inputSource,
|
|
11
32
|
}: {
|
|
12
33
|
rosterConfig: RosterLockV1Config,
|
|
13
34
|
pieceType: string,
|
|
@@ -16,65 +37,122 @@ export function PieceTypeSection({
|
|
|
16
37
|
onTogglePick: (pieceId: string) => void,
|
|
17
38
|
onReorderPick: (fromIndex: number, toIndex: number) => void,
|
|
18
39
|
inputSource: InputSource,
|
|
19
|
-
matchAgentUrl: string,
|
|
20
|
-
matchAgentAuth: string,
|
|
21
40
|
}) {
|
|
22
|
-
const
|
|
23
|
-
|
|
41
|
+
const allPieces = useMemo(
|
|
42
|
+
() => (rosterConfig.rosters[pieceType] ?? []).filter((piece) => !plan.banList.includes(piece.id)),
|
|
43
|
+
[rosterConfig, pieceType, plan]
|
|
44
|
+
);
|
|
45
|
+
const downloadedLogic = useDownloadedPieceVersions(rosterConfig, pieceType);
|
|
46
|
+
|
|
47
|
+
const [filter, setFilter] = useState("");
|
|
24
48
|
const [cursorIndex, setCursorIndex] = useState(0);
|
|
49
|
+
const [hoveredId, setHoveredId] = useState<string | null>(null);
|
|
50
|
+
const gridRef = useRef<HTMLDivElement>(null);
|
|
51
|
+
const columns = useGridColumns(gridRef);
|
|
25
52
|
|
|
53
|
+
const density = densityFor(allPieces.length);
|
|
54
|
+
const showFilter = allPieces.length >= FILTER_MIN_PIECES;
|
|
55
|
+
|
|
56
|
+
const pieces = useMemo(() => {
|
|
57
|
+
const needle = filter.trim().toLowerCase();
|
|
58
|
+
if (!needle) return allPieces;
|
|
59
|
+
return allPieces.filter((piece) => (
|
|
60
|
+
piece.humanInfo.name.toLowerCase().includes(needle) || piece.humanInfo.author.toLowerCase().includes(needle)
|
|
61
|
+
));
|
|
62
|
+
}, [allPieces, filter]);
|
|
63
|
+
|
|
64
|
+
// Narrowing the list renumbers everything under the cursor, so park it back
|
|
65
|
+
// at the top rather than leave it pointing at whatever now sits at that index.
|
|
66
|
+
useEffect(() => { setCursorIndex(0); }, [filter, pieceType]);
|
|
67
|
+
|
|
68
|
+
// Cursoring is useless if the card it lands on is below the fold of a
|
|
69
|
+
// height-capped grid.
|
|
26
70
|
useEffect(() => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
if (cancelled) return;
|
|
32
|
-
const byLogic = new Set(rows.map((r) => r.version.logic));
|
|
33
|
-
const next: Record<string, boolean> = {};
|
|
34
|
-
for (const piece of pieces) next[piece.id] = byLogic.has(piece.version.logic);
|
|
35
|
-
setDownloaded(next);
|
|
36
|
-
}).catch(() => {});
|
|
37
|
-
return () => { cancelled = true; };
|
|
38
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
-
}, [pieceType]);
|
|
71
|
+
gridRef.current
|
|
72
|
+
?.querySelector<HTMLElement>('[data-cursored="true"]')
|
|
73
|
+
?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
74
|
+
}, [cursorIndex]);
|
|
40
75
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
76
|
+
useCursorInput({
|
|
77
|
+
source: inputSource,
|
|
78
|
+
enabled: pieces.length > 0,
|
|
79
|
+
onMoveColumn: (delta) => setCursorIndex((i) => (i + delta + pieces.length) % pieces.length),
|
|
80
|
+
// Rows don't wrap: wrapping left/right is how a select screen has always
|
|
81
|
+
// behaved, but wrapping "down" off the last row back to the first is
|
|
82
|
+
// disorienting once the grid is tall enough to scroll. Off either end the
|
|
83
|
+
// cursor simply stays where it is, rather than clamping to index 0/last
|
|
84
|
+
// and so sliding sideways to another column.
|
|
85
|
+
onMoveRow: (delta) => setCursorIndex((i) => {
|
|
86
|
+
const next = i + delta * columns;
|
|
87
|
+
if (next >= 0 && next < pieces.length) return next;
|
|
88
|
+
// The one exception: pressing down out of a full row into a shorter
|
|
89
|
+
// last row should still reach it, at its final card.
|
|
90
|
+
const lastRow = Math.floor((pieces.length - 1) / columns);
|
|
91
|
+
if (delta > 0 && Math.floor(i / columns) < lastRow) return pieces.length - 1;
|
|
92
|
+
return i;
|
|
93
|
+
}),
|
|
94
|
+
onConfirm: () => {
|
|
95
|
+
const piece = pieces[cursorIndex];
|
|
96
|
+
if (piece) onTogglePick(piece.id);
|
|
97
|
+
},
|
|
98
|
+
});
|
|
48
99
|
|
|
100
|
+
const atMax = picks.length >= plan.max;
|
|
49
101
|
const countLabel = plan.min === plan.max
|
|
50
102
|
? `pick exactly ${plan.min}`
|
|
51
103
|
: plan.max === Number.POSITIVE_INFINITY
|
|
52
104
|
? `pick ${plan.min}-any`
|
|
53
105
|
: `pick ${plan.min}-${plan.max}`;
|
|
54
106
|
|
|
55
|
-
const pieceById = new Map(
|
|
107
|
+
const pieceById = new Map(allPieces.map((piece) => [piece.id, piece]));
|
|
108
|
+
|
|
109
|
+
// Mouse hover wins over keyboard/gamepad cursor while active, but either
|
|
110
|
+
// one alone is enough to drive the preview panel beside the grid - a
|
|
111
|
+
// controller-only player never hovers anything, so falling back to
|
|
112
|
+
// cursorIndex is what gives them a live preview at all.
|
|
113
|
+
const activePiece = pieceById.get(hoveredId ?? "") ?? pieces[cursorIndex] ?? null;
|
|
56
114
|
|
|
57
115
|
return (
|
|
58
|
-
<div className="piece-type-section">
|
|
116
|
+
<div className="piece-type-section" data-density={density}>
|
|
59
117
|
<div className="piece-type-header">
|
|
60
|
-
|
|
118
|
+
{showFilter && (
|
|
119
|
+
<input
|
|
120
|
+
className="piece-type-filter"
|
|
121
|
+
type="search"
|
|
122
|
+
value={filter}
|
|
123
|
+
placeholder={`Filter ${allPieces.length} ${pieceType}…`}
|
|
124
|
+
onChange={(e) => setFilter(e.target.value)}
|
|
125
|
+
aria-label={`Filter ${pieceType}`}
|
|
126
|
+
/>
|
|
127
|
+
)}
|
|
128
|
+
<span className="piece-type-count">
|
|
129
|
+
{countLabel} ({picks.length} picked{filter ? `, ${pieces.length} shown` : ""})
|
|
130
|
+
</span>
|
|
61
131
|
</div>
|
|
62
|
-
<div className="
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
132
|
+
<div className="piece-type-body">
|
|
133
|
+
<div className="card-grid" ref={gridRef}>
|
|
134
|
+
{pieces.map((piece, index) => {
|
|
135
|
+
const orderIndex = picks.indexOf(piece.id);
|
|
136
|
+
return (
|
|
137
|
+
<PieceCard
|
|
138
|
+
key={piece.id}
|
|
139
|
+
piece={piece}
|
|
140
|
+
pieceType={pieceType}
|
|
141
|
+
selected={orderIndex !== -1}
|
|
142
|
+
orderNumber={orderIndex === -1 ? undefined : orderIndex + 1}
|
|
143
|
+
downloaded={downloadedLogic ? downloadedLogic.has(piece.version.logic) : undefined}
|
|
144
|
+
cursored={index === cursorIndex}
|
|
145
|
+
disabled={atMax}
|
|
146
|
+
onClick={() => onTogglePick(piece.id)}
|
|
147
|
+
onHoverChange={(hovering) => setHoveredId(hovering ? piece.id : null)}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
})}
|
|
151
|
+
{pieces.length === 0 && (
|
|
152
|
+
<span className="card-grid-empty">No {pieceType} match “{filter}”</span>
|
|
153
|
+
)}
|
|
154
|
+
</div>
|
|
155
|
+
<PiecePreviewPanel piece={activePiece} pieceType={pieceType} />
|
|
78
156
|
</div>
|
|
79
157
|
{picks.length > 0 && (
|
|
80
158
|
<ol className="pick-order-list">
|
|
@@ -4,7 +4,7 @@ import { PieceTypePlan } from "./selectionPlan";
|
|
|
4
4
|
import { PieceTypeSection } from "./PieceTypeSection";
|
|
5
5
|
|
|
6
6
|
export function PlayerSelectionPanel({
|
|
7
|
-
rosterConfig, slot, pieceType, plan, picks, onTogglePick, onReorderPick,
|
|
7
|
+
rosterConfig, slot, pieceType, plan, picks, onTogglePick, onReorderPick,
|
|
8
8
|
}: {
|
|
9
9
|
rosterConfig: RosterLockV1Config,
|
|
10
10
|
slot: PlayerSlot,
|
|
@@ -13,8 +13,6 @@ export function PlayerSelectionPanel({
|
|
|
13
13
|
picks: Array<string>,
|
|
14
14
|
onTogglePick: (pieceId: string) => void,
|
|
15
15
|
onReorderPick: (fromIndex: number, toIndex: number) => void,
|
|
16
|
-
matchAgentUrl: string,
|
|
17
|
-
matchAgentAuth: string,
|
|
18
16
|
}) {
|
|
19
17
|
return (
|
|
20
18
|
<div className="player-selection-panel">
|
|
@@ -32,8 +30,6 @@ export function PlayerSelectionPanel({
|
|
|
32
30
|
onTogglePick={onTogglePick}
|
|
33
31
|
onReorderPick={onReorderPick}
|
|
34
32
|
inputSource={slot.input}
|
|
35
|
-
matchAgentUrl={matchAgentUrl}
|
|
36
|
-
matchAgentAuth={matchAgentAuth}
|
|
37
33
|
/>
|
|
38
34
|
</div>
|
|
39
35
|
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { useState, useMemo } from "react";
|
|
1
|
+
import { useState, useMemo, useEffect } from "react";
|
|
2
2
|
import { RosterLockV1Config, UserSelection } from "@roster-lock/types";
|
|
3
3
|
import { PlayerSlot } from "../../context/JoinSettingsContext";
|
|
4
4
|
import { PlayerSelectionPanel } from "./PlayerSelectionPanel";
|
|
5
|
+
import { SelectionSourceProvider } from "../../context/SelectionSourceContext";
|
|
6
|
+
import { useGlobalNav } from "../../context/GlobalNavContext";
|
|
5
7
|
import { PieceTypeTabs } from "./PieceTypeTabs";
|
|
6
8
|
import { planForPieceType, buildUserSelection, PieceTypePlan } from "./selectionPlan";
|
|
7
9
|
|
|
@@ -14,16 +16,36 @@ type PickablePlan = Extract<PieceTypePlan, { kind: "pickable" }>;
|
|
|
14
16
|
// inactive, so switching tabs never loses work. Used inline by
|
|
15
17
|
// pages/MatchMaking/Rooms/[roomId] once a room is ready to select in.
|
|
16
18
|
export function SelectionBoard({
|
|
17
|
-
rosterConfig, playerSlots, matchAgentUrl, matchAgentAuth, onConfirm,
|
|
19
|
+
rosterConfig, playerSlots, pluginName, matchAgentUrl, matchAgentAuth, onConfirm, onCancel,
|
|
18
20
|
}: {
|
|
19
21
|
rosterConfig: RosterLockV1Config,
|
|
20
22
|
playerSlots: Array<PlayerSlot>,
|
|
23
|
+
pluginName: string,
|
|
21
24
|
matchAgentUrl: string,
|
|
22
25
|
matchAgentAuth: string,
|
|
23
26
|
onConfirm: (playerSelections: Record<number, UserSelection>) => void,
|
|
27
|
+
onCancel: () => void,
|
|
24
28
|
}) {
|
|
25
29
|
const [picksBySlot, setPicksBySlot] = useState<Record<string, Record<string, Array<string>>>>({});
|
|
26
30
|
|
|
31
|
+
// Each player slot's own useCursorInput already polls its assigned
|
|
32
|
+
// gamepad (and, for whichever slot is on the keyboard, its arrow keys)
|
|
33
|
+
// for d-pad/arrows + confirm - the global menu/roving-focus nav
|
|
34
|
+
// (GlobalNavContext) would otherwise read the same presses a second time.
|
|
35
|
+
const { setNavSuspended } = useGlobalNav();
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setNavSuspended(true);
|
|
38
|
+
return () => setNavSuspended(false);
|
|
39
|
+
}, [setNavSuspended]);
|
|
40
|
+
|
|
41
|
+
// Handed down by context rather than by prop: the deepest consumers are the
|
|
42
|
+
// per-piece download lookup and PieceCard's own preview, several layers and
|
|
43
|
+
// one card-per-roster-entry below here.
|
|
44
|
+
const selectionSource = useMemo(
|
|
45
|
+
() => ({ pluginName, engine: rosterConfig.engine, matchAgentUrl, matchAgentAuth }),
|
|
46
|
+
[pluginName, rosterConfig, matchAgentUrl, matchAgentAuth]
|
|
47
|
+
);
|
|
48
|
+
|
|
27
49
|
const pieceTypePlans = useMemo(
|
|
28
50
|
() => Object.keys(rosterConfig.engine.pieceDefinitions).map((t) => [t, planForPieceType(rosterConfig, t)] as const),
|
|
29
51
|
[rosterConfig]
|
|
@@ -95,53 +117,56 @@ export function SelectionBoard({
|
|
|
95
117
|
};
|
|
96
118
|
|
|
97
119
|
return (
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
{pieceType}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{activePlan && (
|
|
119
|
-
<div className="selection-board-panels">
|
|
120
|
-
{playerSlots.map((slot) => (
|
|
121
|
-
<PlayerSelectionPanel
|
|
122
|
-
key={slot.id}
|
|
123
|
-
rosterConfig={rosterConfig}
|
|
124
|
-
slot={slot}
|
|
125
|
-
pieceType={activeType}
|
|
126
|
-
plan={activePlan}
|
|
127
|
-
picks={picksBySlot[slot.id]?.[activeType] ?? []}
|
|
128
|
-
onTogglePick={(pieceId) => togglePick(slot.id, activeType, pieceId)}
|
|
129
|
-
onReorderPick={(fromIndex, toIndex) => reorderPick(slot.id, activeType, fromIndex, toIndex)}
|
|
130
|
-
matchAgentUrl={matchAgentUrl}
|
|
131
|
-
matchAgentAuth={matchAgentAuth}
|
|
132
|
-
/>
|
|
133
|
-
))}
|
|
134
|
-
</div>
|
|
135
|
-
)}
|
|
120
|
+
<SelectionSourceProvider value={selectionSource}>
|
|
121
|
+
<div className="selection-board">
|
|
122
|
+
{infoTypes.length > 0 && (
|
|
123
|
+
<div className="selection-board-info">
|
|
124
|
+
{infoTypes.map(([pieceType, plan]) => (
|
|
125
|
+
<span key={pieceType} className="piece-type-info-chip">
|
|
126
|
+
{pieceType}: {plan.kind === "auto"
|
|
127
|
+
? (plan.reason === "mandatory" ? "included automatically" : plan.reason)
|
|
128
|
+
: `${plan.configType} (not user-selectable)`}
|
|
129
|
+
</span>
|
|
130
|
+
))}
|
|
131
|
+
</div>
|
|
132
|
+
)}
|
|
133
|
+
|
|
134
|
+
<PieceTypeTabs
|
|
135
|
+
types={pickableTypes.map(([pieceType]) => pieceType)}
|
|
136
|
+
activeType={activeType}
|
|
137
|
+
readyByType={readyByType}
|
|
138
|
+
onSelect={setActiveType}
|
|
139
|
+
/>
|
|
136
140
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
141
|
+
{activePlan && (
|
|
142
|
+
<div className="selection-board-panels">
|
|
143
|
+
{playerSlots.map((slot) => (
|
|
144
|
+
<PlayerSelectionPanel
|
|
145
|
+
key={slot.id}
|
|
146
|
+
rosterConfig={rosterConfig}
|
|
147
|
+
slot={slot}
|
|
148
|
+
pieceType={activeType}
|
|
149
|
+
plan={activePlan}
|
|
150
|
+
picks={picksBySlot[slot.id]?.[activeType] ?? []}
|
|
151
|
+
onTogglePick={(pieceId) => togglePick(slot.id, activeType, pieceId)}
|
|
152
|
+
onReorderPick={(fromIndex, toIndex) => reorderPick(slot.id, activeType, fromIndex, toIndex)}
|
|
153
|
+
/>
|
|
154
|
+
))}
|
|
155
|
+
</div>
|
|
140
156
|
)}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
157
|
+
|
|
158
|
+
<div className="selection-board-footer">
|
|
159
|
+
{!allValid && (
|
|
160
|
+
<span className="selection-board-hint">Still needs: {pendingTypes.join(", ")}</span>
|
|
161
|
+
)}
|
|
162
|
+
<button type="button" onClick={onCancel}>
|
|
163
|
+
Cancel
|
|
164
|
+
</button>
|
|
165
|
+
<button type="button" disabled={!allValid} onClick={handleConfirm}>
|
|
166
|
+
Confirm Selection
|
|
167
|
+
</button>
|
|
168
|
+
</div>
|
|
144
169
|
</div>
|
|
145
|
-
</
|
|
170
|
+
</SelectionSourceProvider>
|
|
146
171
|
);
|
|
147
172
|
}
|