@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,124 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { PiecePreview, RosterLockPiece } from "@roster-lock/types";
|
|
3
|
+
import { getGameLauncherPreview, PiecePreviewResult } from "../api/matchAgent";
|
|
4
|
+
import { useSelectionSource } from "../context/SelectionSourceContext";
|
|
5
|
+
|
|
6
|
+
// What a caller sees. "idle" is a disabled/unasked hook (nothing hovered, a
|
|
7
|
+
// card still below the fold) and is deliberately distinct from a resolved
|
|
8
|
+
// "ready" with a null preview, which means match-agent answered and this
|
|
9
|
+
// piece genuinely has none - only the latter should make a UI commit to its
|
|
10
|
+
// fallback.
|
|
11
|
+
export type PiecePreviewState =
|
|
12
|
+
| { status: "idle" }
|
|
13
|
+
| { status: "loading" }
|
|
14
|
+
| ({ status: "ready" } & PiecePreviewResult);
|
|
15
|
+
|
|
16
|
+
const IDLE: PiecePreviewState = { status: "idle" };
|
|
17
|
+
const LOADING: PiecePreviewState = { status: "loading" };
|
|
18
|
+
const NO_PREVIEW: PiecePreviewResult = { preview: null, source: null };
|
|
19
|
+
|
|
20
|
+
// Module-level (not per-component) so repeated hovers of the same piece
|
|
21
|
+
// across renders/remounts don't refetch, and concurrent hovers of the same
|
|
22
|
+
// piece dedupe onto one in-flight request. A resolved null preview (piece not
|
|
23
|
+
// downloaded and the plugin has no useDefaultPreview, unsupported sprite
|
|
24
|
+
// format, no getPreview at all, ...) is cached too - same shape as a real
|
|
25
|
+
// preview, just empty - so a piece that can't produce one doesn't get
|
|
26
|
+
// re-queried on every hover.
|
|
27
|
+
const previewCache = new Map<string, Promise<PiecePreviewResult>>();
|
|
28
|
+
|
|
29
|
+
// Every on-screen card asks for its own thumbnail, and on the match-agent
|
|
30
|
+
// side each answer means reading and decoding a sprite out of that piece's
|
|
31
|
+
// own assets. A few hundred of those fired at once would bury the same agent
|
|
32
|
+
// the rest of the selection screen is talking to, so cards queue behind this
|
|
33
|
+
// limit. The hover/focus panel asks with priority: it's answering a question
|
|
34
|
+
// the player just asked, and shouldn't sit behind a screenful of thumbnails.
|
|
35
|
+
const MAX_IN_FLIGHT = 4;
|
|
36
|
+
type QueueEntry = { key: string, start: () => void };
|
|
37
|
+
const waiting: Array<QueueEntry> = [];
|
|
38
|
+
let inFlight = 0;
|
|
39
|
+
|
|
40
|
+
function pump(): void {
|
|
41
|
+
while (inFlight < MAX_IN_FLIGHT && waiting.length > 0) waiting.shift()!.start();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function promote(key: string): void {
|
|
45
|
+
const index = waiting.findIndex((entry) => entry.key === key);
|
|
46
|
+
if (index > 0) waiting.unshift(waiting.splice(index, 1)[0]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function requestPreview(
|
|
50
|
+
key: string, priority: boolean, run: () => Promise<PiecePreviewResult>
|
|
51
|
+
): Promise<PiecePreviewResult> {
|
|
52
|
+
const cached = previewCache.get(key);
|
|
53
|
+
if (cached) {
|
|
54
|
+
// Already queued at the back by some card - a hover on that same piece
|
|
55
|
+
// should still jump it forward rather than start a second request.
|
|
56
|
+
if (priority) promote(key);
|
|
57
|
+
return cached;
|
|
58
|
+
}
|
|
59
|
+
const promise = new Promise<PiecePreviewResult>((resolve) => {
|
|
60
|
+
const entry: QueueEntry = {
|
|
61
|
+
key,
|
|
62
|
+
start: () => {
|
|
63
|
+
inFlight += 1;
|
|
64
|
+
run().catch(() => NO_PREVIEW).then((result) => {
|
|
65
|
+
inFlight -= 1;
|
|
66
|
+
resolve(result);
|
|
67
|
+
pump();
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
if (priority) waiting.unshift(entry);
|
|
72
|
+
else waiting.push(entry);
|
|
73
|
+
pump();
|
|
74
|
+
});
|
|
75
|
+
previewCache.set(key, promise);
|
|
76
|
+
return promise;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function cacheKey(pluginName: string, pieceType: string, piece: Pick<RosterLockPiece, "version">): string {
|
|
80
|
+
return `${pluginName}\x00${pieceType}\x00${piece.version.logic}\x00${piece.version.media}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// `piece` is null when nothing is currently hovered/cursored, and `enabled`
|
|
84
|
+
// is false for a card that hasn't scrolled into view or isn't downloaded yet
|
|
85
|
+
// - both report "idle" without making any request.
|
|
86
|
+
export function usePiecePreview(args: {
|
|
87
|
+
pieceType: string,
|
|
88
|
+
piece: Pick<RosterLockPiece, "version" | "pathVariables"> | null,
|
|
89
|
+
enabled?: boolean,
|
|
90
|
+
priority?: boolean,
|
|
91
|
+
}): PiecePreviewState {
|
|
92
|
+
const { pieceType, piece, enabled = true, priority = false } = args;
|
|
93
|
+
const { pluginName, engine, matchAgentUrl, matchAgentAuth } = useSelectionSource();
|
|
94
|
+
const [state, setState] = useState<PiecePreviewState>(IDLE);
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!piece || !enabled) {
|
|
98
|
+
setState(IDLE);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const key = cacheKey(pluginName, pieceType, piece);
|
|
102
|
+
const pending = requestPreview(key, priority, () => getGameLauncherPreview(
|
|
103
|
+
matchAgentUrl, matchAgentAuth, pluginName, engine, pieceType, piece
|
|
104
|
+
));
|
|
105
|
+
|
|
106
|
+
let cancelled = false;
|
|
107
|
+
setState(LOADING);
|
|
108
|
+
pending.then((result) => {
|
|
109
|
+
if (!cancelled) setState({ status: "ready", ...result });
|
|
110
|
+
});
|
|
111
|
+
return () => { cancelled = true; };
|
|
112
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
|
+
}, [pluginName, pieceType, enabled, priority, piece?.version.logic, piece?.version.media]);
|
|
114
|
+
|
|
115
|
+
return state;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// The one image a UI should actually show for a preview, or undefined if
|
|
119
|
+
// there isn't one. PiecePreview also has a "model" kind for a future 3D
|
|
120
|
+
// engine plugin; until something renders those, an <img> caller treats one
|
|
121
|
+
// the same as no preview at all rather than pointing src at a model URI.
|
|
122
|
+
export function previewImage(preview: PiecePreview | null | undefined): string | undefined {
|
|
123
|
+
return preview?.kind === "image" ? preview.dataUri : undefined;
|
|
124
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { NavAction, useGlobalNav } from "../../context/GlobalNavContext";
|
|
3
|
+
import { gamepadButtonLabel, keyLabel } from "../../utils/inputLabels";
|
|
4
|
+
|
|
5
|
+
const ACTIONS: Array<{ action: NavAction, label: string }> = [
|
|
6
|
+
{ action: "select", label: "Select" },
|
|
7
|
+
{ action: "back", label: "Back" },
|
|
8
|
+
{ action: "menu", label: "Menu" },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
type Capture = { device: "keyboard" | "gamepad", action: NavAction };
|
|
12
|
+
|
|
13
|
+
// Lets a player rebind the three single-press actions GlobalNavContext
|
|
14
|
+
// drives the shell with (Move stays fixed to arrow keys/d-pad+stick - it's
|
|
15
|
+
// a pair of directions, not a single press to capture). While capturing,
|
|
16
|
+
// global nav is suspended so the very key/button being captured doesn't
|
|
17
|
+
// also fire as that action with its *old* binding.
|
|
18
|
+
export function ControlsPage() {
|
|
19
|
+
const {
|
|
20
|
+
keyboardBindings, gamepadBindings, setKeyboardBinding, setGamepadBinding, resetBindings, setNavSuspended,
|
|
21
|
+
} = useGlobalNav();
|
|
22
|
+
const [capture, setCapture] = useState<Capture | null>(null);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!capture) return;
|
|
26
|
+
setNavSuspended(true);
|
|
27
|
+
|
|
28
|
+
const cancel = (e: KeyboardEvent) => {
|
|
29
|
+
if (e.key === "Escape") setCapture(null);
|
|
30
|
+
};
|
|
31
|
+
window.addEventListener("keydown", cancel);
|
|
32
|
+
|
|
33
|
+
if (capture.device === "keyboard") {
|
|
34
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
35
|
+
if (e.key === "Escape") return;
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
setKeyboardBinding(capture.action, e.key);
|
|
38
|
+
setCapture(null);
|
|
39
|
+
};
|
|
40
|
+
window.addEventListener("keydown", onKeyDown);
|
|
41
|
+
return () => {
|
|
42
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
43
|
+
window.removeEventListener("keydown", cancel);
|
|
44
|
+
setNavSuspended(false);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// A button might still read as physically pressed on the very first
|
|
49
|
+
// poll - e.g. the gamepad confirm button, if that's what the player
|
|
50
|
+
// used to click into this capture in the first place. Such a button is
|
|
51
|
+
// only accepted once it's been seen released and pressed again, so
|
|
52
|
+
// rebinding an action to its own current button still requires an
|
|
53
|
+
// actual new press rather than just reusing the one already in flight.
|
|
54
|
+
let frame: number;
|
|
55
|
+
let baseline: Set<number> | null = null;
|
|
56
|
+
const releasedSinceStart = new Set<number>();
|
|
57
|
+
const poll = () => {
|
|
58
|
+
const pads = navigator.getGamepads?.() ?? [];
|
|
59
|
+
const pressedNow = new Set<number>();
|
|
60
|
+
for (const pad of pads) {
|
|
61
|
+
if (!pad) continue;
|
|
62
|
+
pad.buttons.forEach((button, index) => { if (button.pressed) pressedNow.add(index); });
|
|
63
|
+
}
|
|
64
|
+
if (baseline === null) baseline = new Set(pressedNow);
|
|
65
|
+
for (let i = 0; i < 32; i++) {
|
|
66
|
+
if (!pressedNow.has(i)) releasedSinceStart.add(i);
|
|
67
|
+
}
|
|
68
|
+
for (const index of pressedNow) {
|
|
69
|
+
if (!baseline.has(index) || releasedSinceStart.has(index)) {
|
|
70
|
+
setGamepadBinding(capture.action, index);
|
|
71
|
+
setCapture(null);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
frame = requestAnimationFrame(poll);
|
|
76
|
+
};
|
|
77
|
+
frame = requestAnimationFrame(poll);
|
|
78
|
+
return () => {
|
|
79
|
+
cancelAnimationFrame(frame);
|
|
80
|
+
window.removeEventListener("keydown", cancel);
|
|
81
|
+
setNavSuspended(false);
|
|
82
|
+
};
|
|
83
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
84
|
+
}, [capture]);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div className="page">
|
|
88
|
+
<h1>Controls</h1>
|
|
89
|
+
<p>
|
|
90
|
+
Select a button below, then press the key or gamepad button you want for that action. Press Escape to
|
|
91
|
+
cancel.
|
|
92
|
+
</p>
|
|
93
|
+
<table className="controls-table">
|
|
94
|
+
<thead>
|
|
95
|
+
<tr>
|
|
96
|
+
<th>Action</th>
|
|
97
|
+
<th>Keyboard</th>
|
|
98
|
+
<th>Gamepad</th>
|
|
99
|
+
</tr>
|
|
100
|
+
</thead>
|
|
101
|
+
<tbody>
|
|
102
|
+
{ACTIONS.map(({ action, label }) => (
|
|
103
|
+
<tr key={action}>
|
|
104
|
+
<td>{label}</td>
|
|
105
|
+
<td>
|
|
106
|
+
<button type="button" onClick={() => setCapture({ device: "keyboard", action })}>
|
|
107
|
+
{capture?.device === "keyboard" && capture.action === action
|
|
108
|
+
? "Press a key..."
|
|
109
|
+
: keyLabel(keyboardBindings[action])}
|
|
110
|
+
</button>
|
|
111
|
+
</td>
|
|
112
|
+
<td>
|
|
113
|
+
<button type="button" onClick={() => setCapture({ device: "gamepad", action })}>
|
|
114
|
+
{capture?.device === "gamepad" && capture.action === action
|
|
115
|
+
? "Press a button..."
|
|
116
|
+
: gamepadButtonLabel(gamepadBindings[action])}
|
|
117
|
+
</button>
|
|
118
|
+
</td>
|
|
119
|
+
</tr>
|
|
120
|
+
))}
|
|
121
|
+
</tbody>
|
|
122
|
+
</table>
|
|
123
|
+
<button type="button" onClick={resetBindings}>Reset to defaults</button>
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import { useMatchAgent } from "../../context/MatchAgentContext";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const POLL_INTERVAL_MS = 2000;
|
|
3
|
+
import { subscribeToGameProcesses, stopGameLauncher, GameProcessSummary } from "../../api/matchAgent";
|
|
6
4
|
|
|
7
5
|
// Every game process this machine's match-agent has started, regardless of
|
|
8
6
|
// which page launched it (today that's only pages/Download's "Start Match"
|
|
9
7
|
// button) - lets a player see a game is actually running, and close it,
|
|
10
|
-
// without having to go find the real game window.
|
|
8
|
+
// without having to go find the real game window. Status is pushed over WS
|
|
9
|
+
// (see gameProcessesWs) rather than polled, including the update once a
|
|
10
|
+
// closed/exited process's status actually flips.
|
|
11
11
|
export function GameStatusPage() {
|
|
12
12
|
const { settings } = useMatchAgent();
|
|
13
13
|
const [processes, setProcesses] = useState<Array<GameProcessSummary>>([]);
|
|
@@ -15,15 +15,13 @@ export function GameStatusPage() {
|
|
|
15
15
|
const [error, setError] = useState<string | null>(null);
|
|
16
16
|
|
|
17
17
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const interval = setInterval(poll, POLL_INTERVAL_MS);
|
|
26
|
-
return () => { cancelled = true; clearInterval(interval); };
|
|
18
|
+
setError(null);
|
|
19
|
+
const unsubscribe = subscribeToGameProcesses(
|
|
20
|
+
settings.url, settings.authCode,
|
|
21
|
+
(next) => setProcesses(next),
|
|
22
|
+
(e) => setError(e.message)
|
|
23
|
+
);
|
|
24
|
+
return unsubscribe;
|
|
27
25
|
}, [settings]);
|
|
28
26
|
|
|
29
27
|
const handleClose = async (proc: GameProcessSummary) => {
|
|
@@ -31,8 +29,6 @@ export function GameStatusPage() {
|
|
|
31
29
|
setError(null);
|
|
32
30
|
try {
|
|
33
31
|
await stopGameLauncher(settings.url, settings.authCode, proc.pluginName, proc.handleId);
|
|
34
|
-
const next = await listGameProcesses(settings.url, settings.authCode);
|
|
35
|
-
setProcesses(next);
|
|
36
32
|
} catch (e) {
|
|
37
33
|
setError((e as Error).message);
|
|
38
34
|
} finally {
|
|
@@ -41,7 +41,7 @@ export function MatchMakingPage() {
|
|
|
41
41
|
const [selectedSaved, setSelectedSaved] = useState("");
|
|
42
42
|
const [connectedUrl, setConnectedUrl] = useState<string | null>(null);
|
|
43
43
|
const [connecting, setConnecting] = useState(false);
|
|
44
|
-
const [iframeLoaded, setIframeLoaded] = useState(
|
|
44
|
+
const [iframeLoaded, setIframeLoaded] = useState(-1);
|
|
45
45
|
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
|
46
46
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
47
47
|
|
|
@@ -69,7 +69,7 @@ export function MatchMakingPage() {
|
|
|
69
69
|
|
|
70
70
|
const handleConnect = (targetUrl: string = url) => {
|
|
71
71
|
localStorage.setItem(STORAGE_KEY, targetUrl);
|
|
72
|
-
setIframeLoaded(
|
|
72
|
+
setIframeLoaded(-1);
|
|
73
73
|
setErrorMessage(null);
|
|
74
74
|
setConnectedUrl(targetUrl);
|
|
75
75
|
setConnecting(true);
|
|
@@ -91,6 +91,7 @@ export function MatchMakingPage() {
|
|
|
91
91
|
// than leaving `connecting` true against a URL that's no longer shown.
|
|
92
92
|
setConnecting(false);
|
|
93
93
|
setErrorMessage(null);
|
|
94
|
+
setIframeLoaded(-1);
|
|
94
95
|
};
|
|
95
96
|
|
|
96
97
|
const handleIframeError = () => {
|
|
@@ -164,7 +165,7 @@ export function MatchMakingPage() {
|
|
|
164
165
|
src={connectedUrl}
|
|
165
166
|
className="matchmaker-frame"
|
|
166
167
|
title="Matchmaker"
|
|
167
|
-
onLoad={() => setIframeLoaded(
|
|
168
|
+
onLoad={() => setIframeLoaded(Date.now())}
|
|
168
169
|
onError={handleIframeError}
|
|
169
170
|
/>
|
|
170
171
|
</div>
|
|
@@ -183,9 +184,11 @@ export function MatchMakingPage() {
|
|
|
183
184
|
<SelectionBoard
|
|
184
185
|
rosterConfig={pendingLightbox.rosterConfig}
|
|
185
186
|
playerSlots={playerSlots.slice(0, pendingLightbox.numPlayers)}
|
|
187
|
+
pluginName={pendingLightbox.pluginName}
|
|
186
188
|
matchAgentUrl={matchAgent.settings.url}
|
|
187
189
|
matchAgentAuth={matchAgent.settings.authCode}
|
|
188
190
|
onConfirm={resolveSelectionLightbox}
|
|
191
|
+
onCancel={cancelSelectionLightbox}
|
|
189
192
|
/>
|
|
190
193
|
</Lightbox>
|
|
191
194
|
)}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { RosterLockV1Config, UserSelection } from "@roster-lock/types";
|
|
3
|
+
import { useMatchAgent } from "../../context/MatchAgentContext";
|
|
4
|
+
import { useJoinSettings } from "../../context/JoinSettingsContext";
|
|
5
|
+
import { useGlobalNav } from "../../context/GlobalNavContext";
|
|
6
|
+
import { readRosterLock, listAvailableGameLaunchers, AvailableGameLauncher } from "../../api/matchAgent";
|
|
7
|
+
import { SelectionBoard } from "../../components/Selection";
|
|
8
|
+
|
|
9
|
+
// Opens a SelectionBoard against a roster-lock config read straight off
|
|
10
|
+
// this machine's disk - no matchmaker, room, or live service (and so none
|
|
11
|
+
// of the Docker services/real login flow those need) involved at all.
|
|
12
|
+
// Before this page existed, SelectionBoard could only ever be reached via
|
|
13
|
+
// a live bridge.requestSelection round-trip (see MatchMakingPage's
|
|
14
|
+
// pendingLightbox) - which made even just trying out a roster's selection
|
|
15
|
+
// board, let alone a future save/load-a-preset feature, dependent on a
|
|
16
|
+
// whole matchmaker setup it has nothing to do with.
|
|
17
|
+
export function PreviewRosterPage() {
|
|
18
|
+
const { settings } = useMatchAgent();
|
|
19
|
+
const { playerSlots } = useJoinSettings();
|
|
20
|
+
const { pickFile } = useGlobalNav();
|
|
21
|
+
|
|
22
|
+
const [path, setPath] = useState("");
|
|
23
|
+
const [busy, setBusy] = useState(false);
|
|
24
|
+
const [error, setError] = useState<string | null>(null);
|
|
25
|
+
|
|
26
|
+
const [launchers, setLaunchers] = useState<Array<AvailableGameLauncher>>([]);
|
|
27
|
+
const [pluginName, setPluginName] = useState("");
|
|
28
|
+
|
|
29
|
+
const [rosterConfig, setRosterConfig] = useState<RosterLockV1Config | null>(null);
|
|
30
|
+
const [result, setResult] = useState<Record<number, UserSelection> | null>(null);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
listAvailableGameLaunchers(settings.url, settings.authCode)
|
|
34
|
+
.then((list) => {
|
|
35
|
+
setLaunchers(list);
|
|
36
|
+
setPluginName((current) => current || list[0]?.pluginName || "");
|
|
37
|
+
})
|
|
38
|
+
.catch((e) => setError(e.message));
|
|
39
|
+
}, [settings]);
|
|
40
|
+
|
|
41
|
+
const browse = async () => {
|
|
42
|
+
setError(null);
|
|
43
|
+
const picked = await pickFile({
|
|
44
|
+
startPath: path || undefined, extension: ".roster-lock.json", extensionLabel: "roster-lock files",
|
|
45
|
+
});
|
|
46
|
+
if (picked) setPath(picked);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const load = async () => {
|
|
50
|
+
setBusy(true);
|
|
51
|
+
setError(null);
|
|
52
|
+
setResult(null);
|
|
53
|
+
try {
|
|
54
|
+
setRosterConfig(await readRosterLock(settings.url, settings.authCode, path));
|
|
55
|
+
} catch (e) {
|
|
56
|
+
setError((e as Error).message);
|
|
57
|
+
} finally {
|
|
58
|
+
setBusy(false);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (rosterConfig && pluginName) {
|
|
63
|
+
if (result) {
|
|
64
|
+
return (
|
|
65
|
+
<div className="page">
|
|
66
|
+
<h1>Preview Roster</h1>
|
|
67
|
+
<p>Confirmed - this is just a preview, so nothing further happens with this selection.</p>
|
|
68
|
+
<pre className="preview-roster-result">{JSON.stringify(result, null, 2)}</pre>
|
|
69
|
+
<button type="button" onClick={() => setResult(null)}>Back to selection</button>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return (
|
|
74
|
+
<div className="page">
|
|
75
|
+
<h1>Preview Roster</h1>
|
|
76
|
+
<SelectionBoard
|
|
77
|
+
rosterConfig={rosterConfig}
|
|
78
|
+
playerSlots={playerSlots}
|
|
79
|
+
pluginName={pluginName}
|
|
80
|
+
matchAgentUrl={settings.url}
|
|
81
|
+
matchAgentAuth={settings.authCode}
|
|
82
|
+
onConfirm={setResult}
|
|
83
|
+
onCancel={() => setRosterConfig(null)}
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div className="page">
|
|
91
|
+
<h1>Preview Roster</h1>
|
|
92
|
+
<p>
|
|
93
|
+
Load a roster-lock config straight off this machine's disk and try out its selection board - no
|
|
94
|
+
matchmaker, room, or live service needed.
|
|
95
|
+
</p>
|
|
96
|
+
<div style={{ display: "flex", flexDirection: "row", gap: "0.5rem" }}>
|
|
97
|
+
<input
|
|
98
|
+
style={{ flexGrow: 1 }}
|
|
99
|
+
placeholder="Path to a .roster-lock.json file"
|
|
100
|
+
value={path}
|
|
101
|
+
onChange={(e) => setPath(e.target.value)}
|
|
102
|
+
/>
|
|
103
|
+
<button type="button" disabled={busy} onClick={browse}>Browse...</button>
|
|
104
|
+
</div>
|
|
105
|
+
<label>
|
|
106
|
+
Game launcher
|
|
107
|
+
<select value={pluginName} onChange={(e) => setPluginName(e.target.value)}>
|
|
108
|
+
{launchers.length === 0 && <option value="">No game-launcher plugins installed</option>}
|
|
109
|
+
{launchers.map((l) => (
|
|
110
|
+
<option key={l.pluginName} value={l.pluginName}>{l.publicInfo.title}</option>
|
|
111
|
+
))}
|
|
112
|
+
</select>
|
|
113
|
+
</label>
|
|
114
|
+
<button type="button" disabled={busy || !path || !pluginName} onClick={load}>Load</button>
|
|
115
|
+
{error && <p className="error">{error}</p>}
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
}
|