@pretty-chitty/core 2.0.0 → 2.1.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/README.md +8 -0
- package/dist/components/ActionLogDisplay.d.ts.map +1 -1
- package/dist/components/ActionLogDisplay.js +1 -1
- package/dist/components/ActionLogDisplay.js.map +1 -1
- package/dist/components/BottomBarButton.d.ts +3 -1
- package/dist/components/BottomBarButton.d.ts.map +1 -1
- package/dist/components/BottomBarButton.js +3 -2
- package/dist/components/BottomBarButton.js.map +1 -1
- package/dist/components/ContextGalleryDisplay.d.ts.map +1 -1
- package/dist/components/ContextGalleryDisplay.js +1 -1
- package/dist/components/ContextGalleryDisplay.js.map +1 -1
- package/dist/components/DemoWrapper.d.ts +30 -2
- package/dist/components/DemoWrapper.d.ts.map +1 -1
- package/dist/components/DemoWrapper.js +79 -36
- package/dist/components/DemoWrapper.js.map +1 -1
- package/dist/components/FullScreenGalleryDisplay.d.ts.map +1 -1
- package/dist/components/FullScreenGalleryDisplay.js +2 -2
- package/dist/components/FullScreenGalleryDisplay.js.map +1 -1
- package/dist/components/Gallery/BuiltItem.d.ts +6 -2
- package/dist/components/Gallery/BuiltItem.d.ts.map +1 -1
- package/dist/components/Gallery/BuiltItem.js +28 -9
- package/dist/components/Gallery/BuiltItem.js.map +1 -1
- package/dist/components/Gallery/GalleryController.d.ts +18 -0
- package/dist/components/Gallery/GalleryController.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryController.js +67 -0
- package/dist/components/Gallery/GalleryController.js.map +1 -1
- package/dist/components/Gallery/GalleryViewer.d.ts +6 -1
- package/dist/components/Gallery/GalleryViewer.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryViewer.js +48 -10
- package/dist/components/Gallery/GalleryViewer.js.map +1 -1
- package/dist/components/Gallery/LayoutManager.d.ts +6 -0
- package/dist/components/Gallery/LayoutManager.d.ts.map +1 -1
- package/dist/components/Gallery/LayoutManager.js +23 -3
- package/dist/components/Gallery/LayoutManager.js.map +1 -1
- package/dist/components/Gallery/constants.d.ts +2 -0
- package/dist/components/Gallery/constants.d.ts.map +1 -1
- package/dist/components/Gallery/constants.js +2 -0
- package/dist/components/Gallery/constants.js.map +1 -1
- package/dist/components/Gallery/registry.d.ts +34 -0
- package/dist/components/Gallery/registry.d.ts.map +1 -0
- package/dist/components/Gallery/registry.js +17 -0
- package/dist/components/Gallery/registry.js.map +1 -0
- package/dist/components/GameDesigner.d.ts.map +1 -1
- package/dist/components/GameDesigner.js +42 -10
- package/dist/components/GameDesigner.js.map +1 -1
- package/dist/components/InlineGalleryDisplay.d.ts.map +1 -1
- package/dist/components/InlineGalleryDisplay.js +2 -2
- package/dist/components/InlineGalleryDisplay.js.map +1 -1
- package/dist/components/LiveButton.d.ts.map +1 -1
- package/dist/components/LiveButton.js +5 -2
- package/dist/components/LiveButton.js.map +1 -1
- package/dist/components/MatchViewer.d.ts +6 -1
- package/dist/components/MatchViewer.d.ts.map +1 -1
- package/dist/components/MatchViewer.js +9 -3
- package/dist/components/MatchViewer.js.map +1 -1
- package/dist/components/Panel/MultiPanel.d.ts.map +1 -1
- package/dist/components/Panel/MultiPanel.js +18 -0
- package/dist/components/Panel/MultiPanel.js.map +1 -1
- package/dist/components/Panel/PanelContents.d.ts.map +1 -1
- package/dist/components/Panel/PanelContents.js +92 -23
- package/dist/components/Panel/PanelContents.js.map +1 -1
- package/dist/components/Panel/PanelTabStack.d.ts.map +1 -1
- package/dist/components/Panel/PanelTabStack.js +1 -1
- package/dist/components/Panel/PanelTabStack.js.map +1 -1
- package/dist/components/PanelSpark.d.ts.map +1 -1
- package/dist/components/PanelSpark.js +3 -2
- package/dist/components/PanelSpark.js.map +1 -1
- package/dist/components/Playground.d.ts.map +1 -1
- package/dist/components/Playground.js +10 -4
- package/dist/components/Playground.js.map +1 -1
- package/dist/components/PromptControls.d.ts.map +1 -1
- package/dist/components/PromptControls.js +4 -2
- package/dist/components/PromptControls.js.map +1 -1
- package/dist/components/SparkLineChart.d.ts.map +1 -1
- package/dist/components/SparkLineChart.js +22 -26
- package/dist/components/SparkLineChart.js.map +1 -1
- package/dist/components/TimeControlBar.d.ts.map +1 -1
- package/dist/components/TimeControlBar.js +5 -3
- package/dist/components/TimeControlBar.js.map +1 -1
- package/dist/components/TokenizedMarkdown.d.ts +23 -0
- package/dist/components/TokenizedMarkdown.d.ts.map +1 -0
- package/dist/components/TokenizedMarkdown.js +144 -0
- package/dist/components/TokenizedMarkdown.js.map +1 -0
- package/dist/components/TokenizedMessage.d.ts +6 -0
- package/dist/components/TokenizedMessage.d.ts.map +1 -1
- package/dist/components/TokenizedMessage.js +20 -19
- package/dist/components/TokenizedMessage.js.map +1 -1
- package/dist/components/TopBarPlayers.d.ts.map +1 -1
- package/dist/components/TopBarPlayers.js +1 -1
- package/dist/components/TopBarPlayers.js.map +1 -1
- package/dist/components/Tutorial/BrowserNarration.d.ts +55 -0
- package/dist/components/Tutorial/BrowserNarration.d.ts.map +1 -0
- package/dist/components/Tutorial/BrowserNarration.js +240 -0
- package/dist/components/Tutorial/BrowserNarration.js.map +1 -0
- package/dist/components/Tutorial/TutorialBox.d.ts +26 -0
- package/dist/components/Tutorial/TutorialBox.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialBox.js +239 -0
- package/dist/components/Tutorial/TutorialBox.js.map +1 -0
- package/dist/components/Tutorial/TutorialDevPanel.d.ts +9 -0
- package/dist/components/Tutorial/TutorialDevPanel.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialDevPanel.js +92 -0
- package/dist/components/Tutorial/TutorialDevPanel.js.map +1 -0
- package/dist/components/Tutorial/TutorialOverlay.d.ts +7 -0
- package/dist/components/Tutorial/TutorialOverlay.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialOverlay.js +1132 -0
- package/dist/components/Tutorial/TutorialOverlay.js.map +1 -0
- package/dist/components/Tutorial/targetRects.d.ts +67 -0
- package/dist/components/Tutorial/targetRects.d.ts.map +1 -0
- package/dist/components/Tutorial/targetRects.js +241 -0
- package/dist/components/Tutorial/targetRects.js.map +1 -0
- package/dist/game/Chit.d.ts +7 -0
- package/dist/game/Chit.d.ts.map +1 -1
- package/dist/game/Chit.js +20 -5
- package/dist/game/Chit.js.map +1 -1
- package/dist/game/ClientTimeState.d.ts +14 -0
- package/dist/game/ClientTimeState.d.ts.map +1 -1
- package/dist/game/ClientTimeState.js +17 -0
- package/dist/game/ClientTimeState.js.map +1 -1
- package/dist/game/Game.d.ts +6 -0
- package/dist/game/Game.d.ts.map +1 -1
- package/dist/game/GameTheme.d.ts +3 -0
- package/dist/game/GameTheme.d.ts.map +1 -1
- package/dist/game/GameTheme.js +2 -0
- package/dist/game/GameTheme.js.map +1 -1
- package/dist/game/Match.d.ts +8 -2
- package/dist/game/Match.d.ts.map +1 -1
- package/dist/game/Match.js +4 -1
- package/dist/game/Match.js.map +1 -1
- package/dist/game/Pick.d.ts +2 -0
- package/dist/game/Pick.d.ts.map +1 -1
- package/dist/game/Pick.js +17 -1
- package/dist/game/Pick.js.map +1 -1
- package/dist/game/PlayerPromptStatusChit.d.ts +8 -0
- package/dist/game/PlayerPromptStatusChit.d.ts.map +1 -1
- package/dist/game/PlayerPromptStatusChit.js +5 -1
- package/dist/game/PlayerPromptStatusChit.js.map +1 -1
- package/dist/game/Prompt.d.ts +15 -0
- package/dist/game/Prompt.d.ts.map +1 -1
- package/dist/game/Prompt.js +16 -0
- package/dist/game/Prompt.js.map +1 -1
- package/dist/game/Turn.d.ts +15 -4
- package/dist/game/Turn.d.ts.map +1 -1
- package/dist/game/Turn.js +173 -60
- package/dist/game/Turn.js.map +1 -1
- package/dist/game/TurnState.d.ts +12 -1
- package/dist/game/TurnState.d.ts.map +1 -1
- package/dist/game/TurnState.js +15 -3
- package/dist/game/TurnState.js.map +1 -1
- package/dist/game/ai/AiClientPrompts.d.ts +20 -3
- package/dist/game/ai/AiClientPrompts.d.ts.map +1 -1
- package/dist/game/ai/AiClientPrompts.js +42 -6
- package/dist/game/ai/AiClientPrompts.js.map +1 -1
- package/dist/game/ai/AiPlayerView.js +2 -0
- package/dist/game/ai/AiPlayerView.js.map +1 -1
- package/dist/game/clientTransport/ClientPrompts.d.ts +20 -1
- package/dist/game/clientTransport/ClientPrompts.d.ts.map +1 -1
- package/dist/game/clientTransport/ClientPrompts.js +30 -1
- package/dist/game/clientTransport/ClientPrompts.js.map +1 -1
- package/dist/game/clientTransport/ClientTime.d.ts +13 -0
- package/dist/game/clientTransport/ClientTime.d.ts.map +1 -1
- package/dist/game/clientTransport/ClientTime.js +51 -11
- package/dist/game/clientTransport/ClientTime.js.map +1 -1
- package/dist/game/tutorial/TutorialController.d.ts +300 -0
- package/dist/game/tutorial/TutorialController.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialController.js +1182 -0
- package/dist/game/tutorial/TutorialController.js.map +1 -0
- package/dist/game/tutorial/TutorialRuntime.d.ts +89 -0
- package/dist/game/tutorial/TutorialRuntime.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialRuntime.js +261 -0
- package/dist/game/tutorial/TutorialRuntime.js.map +1 -0
- package/dist/game/tutorial/TutorialTheme.d.ts +28 -0
- package/dist/game/tutorial/TutorialTheme.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialTheme.js +39 -0
- package/dist/game/tutorial/TutorialTheme.js.map +1 -0
- package/dist/game/tutorial/allowed.d.ts +2 -0
- package/dist/game/tutorial/allowed.d.ts.map +1 -0
- package/dist/game/tutorial/allowed.js +119 -0
- package/dist/game/tutorial/allowed.js.map +1 -0
- package/dist/game/tutorial/checks.d.ts +58 -0
- package/dist/game/tutorial/checks.d.ts.map +1 -0
- package/dist/game/tutorial/checks.js +144 -0
- package/dist/game/tutorial/checks.js.map +1 -0
- package/dist/game/tutorial/createDemoMatch.d.ts +47 -0
- package/dist/game/tutorial/createDemoMatch.d.ts.map +1 -0
- package/dist/game/tutorial/createDemoMatch.js +67 -0
- package/dist/game/tutorial/createDemoMatch.js.map +1 -0
- package/dist/game/tutorial/defineTutorial.d.ts +353 -0
- package/dist/game/tutorial/defineTutorial.d.ts.map +1 -0
- package/dist/game/tutorial/defineTutorial.js +86 -0
- package/dist/game/tutorial/defineTutorial.js.map +1 -0
- package/dist/game/tutorial/runTutorial.d.ts +63 -0
- package/dist/game/tutorial/runTutorial.d.ts.map +1 -0
- package/dist/game/tutorial/runTutorial.js +273 -0
- package/dist/game/tutorial/runTutorial.js.map +1 -0
- package/dist/hooks/usePanelNavigation.d.ts +28 -0
- package/dist/hooks/usePanelNavigation.d.ts.map +1 -0
- package/dist/hooks/usePanelNavigation.js +36 -0
- package/dist/hooks/usePanelNavigation.js.map +1 -0
- package/dist/hooks/useTimeController.d.ts +2 -1
- package/dist/hooks/useTimeController.d.ts.map +1 -1
- package/dist/hooks/useTimeController.js +6 -2
- package/dist/hooks/useTimeController.js.map +1 -1
- package/dist/hooks/useTutorial.d.ts +48 -0
- package/dist/hooks/useTutorial.d.ts.map +1 -0
- package/dist/hooks/useTutorial.js +16 -0
- package/dist/hooks/useTutorial.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +12 -0
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/main.0792d734cde2c688d5f7.hot-update.js +16991 -0
- package/dist/main.0792d734cde2c688d5f7.hot-update.js.map +1 -0
- package/dist/main.0792d734cde2c688d5f7.hot-update.json +1 -0
- package/dist/pretty-chitty.js +204513 -0
- package/dist/pretty-chitty.js.map +1 -0
- package/dist/rendering/CameraWrapperPerspective.d.ts +5 -0
- package/dist/rendering/CameraWrapperPerspective.d.ts.map +1 -1
- package/dist/rendering/CameraWrapperPerspective.js +16 -0
- package/dist/rendering/CameraWrapperPerspective.js.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.d.ts +1 -0
- package/dist/rendering/ChitGalleryItemInstance.d.ts.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.js +12 -0
- package/dist/rendering/ChitGalleryItemInstance.js.map +1 -1
- package/dist/rendering/ChitRenderInstance.d.ts +9 -1
- package/dist/rendering/ChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/ChitRenderInstance.js +28 -0
- package/dist/rendering/ChitRenderInstance.js.map +1 -1
- package/dist/rendering/RootChitRenderInstance.d.ts +2 -0
- package/dist/rendering/RootChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/RootChitRenderInstance.js +29 -0
- package/dist/rendering/RootChitRenderInstance.js.map +1 -1
- package/dist/utilities/Annotations.d.ts +15 -0
- package/dist/utilities/Annotations.d.ts.map +1 -1
- package/dist/utilities/Annotations.js +31 -7
- package/dist/utilities/Annotations.js.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.d.ts +2 -0
- package/dist/utilities/CanvasStack/CanvasStack.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.js +4 -0
- package/dist/utilities/CanvasStack/CanvasStack.js.map +1 -1
- package/dist/utilities/TokenizedText.d.ts +6 -0
- package/dist/utilities/TokenizedText.d.ts.map +1 -1
- package/dist/utilities/TokenizedText.js.map +1 -1
- package/dist/utilities/zIndex.d.ts +1 -0
- package/dist/utilities/zIndex.d.ts.map +1 -1
- package/dist/utilities/zIndex.js +1 -0
- package/dist/utilities/zIndex.js.map +1 -1
- package/package.json +3 -2
- package/src/library/components/ActionLogDisplay.tsx +1 -0
- package/src/library/components/BottomBarButton.tsx +5 -0
- package/src/library/components/ContextGalleryDisplay.tsx +2 -0
- package/src/library/components/DemoWrapper.tsx +147 -44
- package/src/library/components/FullScreenGalleryDisplay.tsx +3 -0
- package/src/library/components/Gallery/BuiltItem.ts +30 -9
- package/src/library/components/Gallery/GalleryController.ts +72 -1
- package/src/library/components/Gallery/GalleryViewer.tsx +54 -10
- package/src/library/components/Gallery/LayoutManager.ts +30 -6
- package/src/library/components/Gallery/constants.ts +2 -0
- package/src/library/components/Gallery/registry.ts +44 -0
- package/src/library/components/GameDesigner.tsx +121 -12
- package/src/library/components/InlineGalleryDisplay.tsx +5 -0
- package/src/library/components/LiveButton.tsx +8 -5
- package/src/library/components/MatchViewer.tsx +14 -3
- package/src/library/components/Panel/MultiPanel.tsx +21 -0
- package/src/library/components/Panel/PanelContents.tsx +70 -1
- package/src/library/components/Panel/PanelTabStack.tsx +1 -0
- package/src/library/components/PanelSpark.tsx +9 -4
- package/src/library/components/Playground.tsx +48 -21
- package/src/library/components/PromptControls.tsx +7 -3
- package/src/library/components/SparkLineChart.tsx +23 -27
- package/src/library/components/TimeControlBar.tsx +5 -3
- package/src/library/components/TokenizedMarkdown.tsx +224 -0
- package/src/library/components/TokenizedMessage.tsx +28 -32
- package/src/library/components/TopBarPlayers.tsx +12 -9
- package/src/library/components/Tutorial/BrowserNarration.ts +233 -0
- package/src/library/components/Tutorial/TutorialBox.tsx +506 -0
- package/src/library/components/Tutorial/TutorialDevPanel.tsx +297 -0
- package/src/library/components/Tutorial/TutorialOverlay.tsx +1301 -0
- package/src/library/components/Tutorial/targetRects.ts +273 -0
- package/src/library/game/Chit.ts +21 -5
- package/src/library/game/ClientTimeState.ts +18 -0
- package/src/library/game/Game.ts +7 -0
- package/src/library/game/GameTheme.ts +4 -0
- package/src/library/game/Match.ts +12 -2
- package/src/library/game/Pick.ts +16 -1
- package/src/library/game/PlayerPromptStatusChit.ts +5 -1
- package/src/library/game/Prompt.ts +20 -0
- package/src/library/game/Turn.ts +179 -61
- package/src/library/game/TurnState.ts +26 -3
- package/src/library/game/ai/AI_GUIDE.md +10 -0
- package/src/library/game/ai/AiClientPrompts.ts +60 -11
- package/src/library/game/ai/AiPlayerView.ts +2 -0
- package/src/library/game/clientTransport/ClientPrompts.ts +31 -1
- package/src/library/game/clientTransport/ClientTime.ts +54 -13
- package/src/library/game/serialize.test.ts +275 -0
- package/src/library/game/tutorial/TUTORIAL_GUIDE.md +411 -0
- package/src/library/game/tutorial/TutorialController.test.ts +731 -0
- package/src/library/game/tutorial/TutorialController.ts +1286 -0
- package/src/library/game/tutorial/TutorialRuntime.ts +311 -0
- package/src/library/game/tutorial/TutorialTheme.ts +67 -0
- package/src/library/game/tutorial/allowed.ts +145 -0
- package/src/library/game/tutorial/checks.ts +186 -0
- package/src/library/game/tutorial/createDemoMatch.ts +115 -0
- package/src/library/game/tutorial/defineTutorial.ts +414 -0
- package/src/library/game/tutorial/runTutorial.ts +331 -0
- package/src/library/game/undo.test.ts +282 -0
- package/src/library/hooks/usePanelNavigation.tsx +65 -0
- package/src/library/hooks/useTimeController.tsx +6 -2
- package/src/library/hooks/useTutorial.tsx +76 -0
- package/src/library/index.ts +57 -2
- package/src/library/rendering/CameraWrapperPerspective.ts +17 -0
- package/src/library/rendering/ChitGalleryItemInstance.ts +12 -0
- package/src/library/rendering/ChitRenderInstance.ts +34 -0
- package/src/library/rendering/RootChitRenderInstance.ts +30 -1
- package/src/library/utilities/Annotations.ts +35 -7
- package/src/library/utilities/CanvasStack/CanvasStack.ts +6 -1
- package/src/library/utilities/TokenizedText.ts +6 -0
- package/src/library/utilities/zIndex.ts +1 -0
|
@@ -1,11 +1,117 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import useLocalStorageState from "use-local-storage-state";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
AppBar,
|
|
5
|
+
Tabs,
|
|
6
|
+
Tab,
|
|
7
|
+
CssBaseline,
|
|
8
|
+
Stack,
|
|
9
|
+
Box,
|
|
10
|
+
Paper,
|
|
11
|
+
Select,
|
|
12
|
+
MenuItem,
|
|
13
|
+
FormControl,
|
|
14
|
+
IconButton,
|
|
15
|
+
Tooltip,
|
|
16
|
+
ToggleButton,
|
|
17
|
+
} from "@mui/material";
|
|
18
|
+
import { OpenInNew, Refresh, Tune } from "@mui/icons-material";
|
|
4
19
|
import CanvasLibraryViewer from "./CanvasLibraryViewer";
|
|
5
20
|
import { Game } from "../game/Game";
|
|
6
21
|
import ChitLibraryViewer from "./ChitLibraryViewer";
|
|
7
22
|
import Playground from "./Playground";
|
|
8
23
|
import { DemoWrapper } from "./DemoWrapper";
|
|
24
|
+
import { TutorialDevPanel } from "./Tutorial/TutorialDevPanel";
|
|
25
|
+
|
|
26
|
+
const NONE = "__none__";
|
|
27
|
+
|
|
28
|
+
/** The Demo tab: a demo game or any of the game's tutorials, with the tutorial workbench beside it. */
|
|
29
|
+
function DemoWorkbench({ game }: { game: Game<any, any> }) {
|
|
30
|
+
const tutorials = game.tutorials ?? [];
|
|
31
|
+
const [selected, setSelected] = useLocalStorageState<string>(`demo_${game.metadata.name}_tutorial`, {
|
|
32
|
+
defaultValue: tutorials[0] ? `${tutorials[0].id}|${tutorials[0].locale}` : NONE,
|
|
33
|
+
});
|
|
34
|
+
const [showDev, setShowDev] = useLocalStorageState<boolean>(`demo_${game.metadata.name}_devPanel`, {
|
|
35
|
+
defaultValue: true,
|
|
36
|
+
});
|
|
37
|
+
const [restartKey, setRestartKey] = useState(0);
|
|
38
|
+
const [startAt, setStartAt] = useState(0);
|
|
39
|
+
|
|
40
|
+
const [id, locale] = selected === NONE ? [undefined, undefined] : selected.split("|");
|
|
41
|
+
const spec = id ? tutorials.find((t) => t.id === id && t.locale === locale) : undefined;
|
|
42
|
+
const restart = (at = 0) => {
|
|
43
|
+
setStartAt(at);
|
|
44
|
+
setRestartKey((k) => k + 1);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const fullScreenUrl = spec ? `/demo?tutorial=${encodeURIComponent(spec.id)}&locale=${encodeURIComponent(spec.locale)}` : "/demo";
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Stack sx={{ height: "100%", minHeight: 0 }}>
|
|
51
|
+
<Paper elevation={3} sx={{ position: "relative", zIndex: 1 }}>
|
|
52
|
+
<Stack direction="row" alignItems="center" spacing={1} sx={{ p: 1 }}>
|
|
53
|
+
<FormControl sx={{ minWidth: 240 }}>
|
|
54
|
+
<Select
|
|
55
|
+
variant="standard"
|
|
56
|
+
value={spec ? selected : NONE}
|
|
57
|
+
onChange={(e) => {
|
|
58
|
+
setSelected(e.target.value);
|
|
59
|
+
restart(0);
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<MenuItem value={NONE}>Demo (no tutorial)</MenuItem>
|
|
63
|
+
{tutorials.map((t) => (
|
|
64
|
+
<MenuItem key={`${t.id}|${t.locale}`} value={`${t.id}|${t.locale}`}>
|
|
65
|
+
{t.title} ({t.locale}) · {t.steps.length} steps
|
|
66
|
+
</MenuItem>
|
|
67
|
+
))}
|
|
68
|
+
</Select>
|
|
69
|
+
</FormControl>
|
|
70
|
+
<Tooltip title="Restart">
|
|
71
|
+
<IconButton size="small" onClick={() => restart(0)}>
|
|
72
|
+
<Refresh />
|
|
73
|
+
</IconButton>
|
|
74
|
+
</Tooltip>
|
|
75
|
+
<Tooltip title="Open full screen">
|
|
76
|
+
<IconButton size="small" component="a" href={fullScreenUrl} target="_blank">
|
|
77
|
+
<OpenInNew />
|
|
78
|
+
</IconButton>
|
|
79
|
+
</Tooltip>
|
|
80
|
+
<Box flex={1} />
|
|
81
|
+
{spec && (
|
|
82
|
+
<Tooltip title="Tutorial workbench">
|
|
83
|
+
<ToggleButton size="small" value="dev" selected={showDev} onChange={() => setShowDev(!showDev)}>
|
|
84
|
+
<Tune fontSize="small" />
|
|
85
|
+
</ToggleButton>
|
|
86
|
+
</Tooltip>
|
|
87
|
+
)}
|
|
88
|
+
</Stack>
|
|
89
|
+
</Paper>
|
|
90
|
+
<Stack direction="row" sx={{ flex: 1, minHeight: 0 }}>
|
|
91
|
+
{/* The workbench sits beside the game, not over it: the tutorial's own layer (the dark start
|
|
92
|
+
screen, the box) stays inside the game and never covers the step list */}
|
|
93
|
+
<Box sx={{ flex: 1, minWidth: 0, position: "relative", display: "flex" }}>
|
|
94
|
+
<DemoWrapper key={`${selected}-${restartKey}`} game={game} tutorial={spec} startAt={startAt}>
|
|
95
|
+
{spec && showDev && (
|
|
96
|
+
<Box
|
|
97
|
+
sx={{
|
|
98
|
+
width: 360,
|
|
99
|
+
flexShrink: 0,
|
|
100
|
+
height: "100%",
|
|
101
|
+
bgcolor: "background.paper",
|
|
102
|
+
borderLeft: "1px solid rgba(0,0,0,0.12)",
|
|
103
|
+
overflow: "hidden",
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
<TutorialDevPanel onRestart={restart} />
|
|
107
|
+
</Box>
|
|
108
|
+
)}
|
|
109
|
+
</DemoWrapper>
|
|
110
|
+
</Box>
|
|
111
|
+
</Stack>
|
|
112
|
+
</Stack>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
9
115
|
|
|
10
116
|
export function GameDesigner({ game }: { game: Game<any, any> }) {
|
|
11
117
|
const [tabIndex, setTabIndex] = useLocalStorageState("selectedMainTab", {
|
|
@@ -15,9 +121,19 @@ export function GameDesigner({ game }: { game: Game<any, any> }) {
|
|
|
15
121
|
const isDemo = window.location.pathname.endsWith("/demo");
|
|
16
122
|
|
|
17
123
|
if (isDemo) {
|
|
124
|
+
const params = new URLSearchParams(window.location.search);
|
|
125
|
+
const tutorial = params.get("tutorial") ?? undefined;
|
|
126
|
+
const locale = params.get("locale") ?? undefined;
|
|
18
127
|
return (
|
|
19
128
|
<Stack sx={{ height: "100vh", maxHeight: "-webkit-fill-available", width: "100vw" }}>
|
|
20
|
-
<DemoWrapper
|
|
129
|
+
<DemoWrapper
|
|
130
|
+
game={game}
|
|
131
|
+
tutorial={tutorial}
|
|
132
|
+
locale={locale}
|
|
133
|
+
onBack={() => {
|
|
134
|
+
window.history.back();
|
|
135
|
+
}}
|
|
136
|
+
/>
|
|
21
137
|
</Stack>
|
|
22
138
|
);
|
|
23
139
|
}
|
|
@@ -29,13 +145,7 @@ export function GameDesigner({ game }: { game: Game<any, any> }) {
|
|
|
29
145
|
<AppBar position="static">
|
|
30
146
|
<Tabs
|
|
31
147
|
value={tabIndex}
|
|
32
|
-
onChange={(e, newValue) =>
|
|
33
|
-
if (newValue === 3) {
|
|
34
|
-
document.location.pathname = "/demo";
|
|
35
|
-
} else {
|
|
36
|
-
setTabIndex(newValue);
|
|
37
|
-
}
|
|
38
|
-
}}
|
|
148
|
+
onChange={(e, newValue) => setTabIndex(newValue)}
|
|
39
149
|
indicatorColor="secondary"
|
|
40
150
|
textColor="inherit"
|
|
41
151
|
variant="fullWidth"
|
|
@@ -44,13 +154,12 @@ export function GameDesigner({ game }: { game: Game<any, any> }) {
|
|
|
44
154
|
<Tab label="Chits" />
|
|
45
155
|
<Tab label="Playground" />
|
|
46
156
|
<Tab label="Demo" />
|
|
47
|
-
{/* <Tab label="Gallery" /> */}
|
|
48
157
|
</Tabs>
|
|
49
158
|
</AppBar>
|
|
50
159
|
{tabIndex === 0 && <CanvasLibraryViewer library={game.canvasLibrary} />}
|
|
51
160
|
{tabIndex === 1 && <ChitLibraryViewer library={game.chitLibrary} />}
|
|
52
161
|
{tabIndex === 2 && <Playground game={game} />}
|
|
53
|
-
{
|
|
162
|
+
{tabIndex === 3 && <DemoWorkbench game={game} />}
|
|
54
163
|
</Stack>
|
|
55
164
|
);
|
|
56
165
|
}
|
|
@@ -63,7 +63,9 @@ export function InlineGalleryDisplay() {
|
|
|
63
63
|
>
|
|
64
64
|
{
|
|
65
65
|
<>
|
|
66
|
+
{inlineSource && (
|
|
66
67
|
<IconButton
|
|
68
|
+
data-tutorial-target="gallery:toFullscreen"
|
|
67
69
|
sx={{
|
|
68
70
|
backgroundColor: theme.inlineGalleryButtonBackgroundColor,
|
|
69
71
|
position: "absolute",
|
|
@@ -80,8 +82,11 @@ export function InlineGalleryDisplay() {
|
|
|
80
82
|
>
|
|
81
83
|
<ScreenshotMonitor sx={{ color: theme.inlineGalleryButtonForegroundColor }} />
|
|
82
84
|
</IconButton>
|
|
85
|
+
)}
|
|
83
86
|
|
|
84
87
|
<GalleryViewer
|
|
88
|
+
kind="inline"
|
|
89
|
+
tutorialTarget="gallery:inline"
|
|
85
90
|
zFactor={0}
|
|
86
91
|
onClose={() => {}}
|
|
87
92
|
onLongPress={() => {
|
|
@@ -10,18 +10,21 @@ export default function LiveButton({ hideIfLive = true }: { hideIfLive?: boolean
|
|
|
10
10
|
const [targetClock] = useEventChannelState(timeState.targetClock);
|
|
11
11
|
const [maxClock] = useEventChannelState(timeController.maxClock);
|
|
12
12
|
const [live] = useEventChannelState(timeState.live);
|
|
13
|
+
// A tutorial holding the board counts as the end: there is nothing to skip to past it
|
|
14
|
+
const [hold] = useEventChannelState(timeState.timelineHold);
|
|
15
|
+
const end = hold === undefined ? maxClock.clock : Math.min(hold, maxClock.clock);
|
|
13
16
|
|
|
14
|
-
if (hideIfLive && targetClock >=
|
|
17
|
+
if (hideIfLive && targetClock >= end) {
|
|
15
18
|
return null;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
return (
|
|
19
22
|
<BottomBarButton
|
|
20
|
-
disabled={targetClock >=
|
|
23
|
+
disabled={targetClock >= end && live}
|
|
21
24
|
icon={SkipNext}
|
|
22
|
-
label={live && targetClock <
|
|
23
|
-
invisible={live && targetClock >=
|
|
24
|
-
onClick={() => timeState.goLive(
|
|
25
|
+
label={live && targetClock < end ? "Skip" : "Live"}
|
|
26
|
+
invisible={live && targetClock >= end}
|
|
27
|
+
onClick={() => timeState.goLive(end)}
|
|
25
28
|
/>
|
|
26
29
|
);
|
|
27
30
|
}
|
|
@@ -13,6 +13,7 @@ import { FullScreenGalleryDisplay } from "./FullScreenGalleryDisplay";
|
|
|
13
13
|
import { ActionLogDisplay } from "./ActionLogDisplay";
|
|
14
14
|
import { ActionLogHistoryDisplay } from "./ActionLogHistoryDisplay";
|
|
15
15
|
import { PanelContents } from "./Panel/PanelContents";
|
|
16
|
+
import { PanelNavigationHolder } from "../hooks/usePanelNavigation";
|
|
16
17
|
import useSize from "@react-hook/size";
|
|
17
18
|
import { SettingsDisplay } from "./SettingsDisplay";
|
|
18
19
|
import { ActionLogSidebar } from "./ActionLogSidebar";
|
|
@@ -20,6 +21,7 @@ import { InlineGalleryDisplay } from "./InlineGalleryDisplay";
|
|
|
20
21
|
import { useLoadingState } from "../hooks/useLoadingStates";
|
|
21
22
|
import { GameTheme } from "../game/GameTheme";
|
|
22
23
|
import { ModalState } from "../game/ModalState";
|
|
24
|
+
import { TutorialOverlay } from "./Tutorial/TutorialOverlay";
|
|
23
25
|
|
|
24
26
|
function createMuiTheme(gameTheme: GameTheme) {
|
|
25
27
|
return createTheme({
|
|
@@ -104,22 +106,31 @@ function InnerMatchViewer({ onBack }: { onBack?: () => void }) {
|
|
|
104
106
|
</Stack>
|
|
105
107
|
|
|
106
108
|
{largeEnoughToShowLogSidebar && showLog && <ActionLogSidebar />}
|
|
109
|
+
|
|
110
|
+
<TutorialOverlay />
|
|
107
111
|
</Stack>
|
|
108
112
|
);
|
|
109
113
|
}
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
/**
|
|
116
|
+
* @param skipReplay Open live instead of replaying the moves since the player's last answer (a
|
|
117
|
+
* tutorial uses it after rebuilding the match for Back)
|
|
118
|
+
*/
|
|
119
|
+
export function MatchViewer({ onBack, skipReplay = false }: { onBack?: () => void; skipReplay?: boolean }) {
|
|
112
120
|
const game = useGame();
|
|
113
121
|
const [modalState] = useState<ModalState>(new ModalState());
|
|
114
122
|
const muiTheme = useMemo(() => createMuiTheme(game.theme), [game.theme]);
|
|
115
123
|
return (
|
|
116
|
-
<TimeControllerProvider>
|
|
124
|
+
<TimeControllerProvider skipReplay={skipReplay}>
|
|
117
125
|
<PanelScaleProvider>
|
|
118
126
|
<ModalProvider modalState={modalState}>
|
|
119
127
|
<GameThemeProvider theme={game.theme}>
|
|
120
128
|
<ThemeProvider theme={muiTheme}>
|
|
121
129
|
<CssBaseline />
|
|
122
|
-
|
|
130
|
+
{/* the tutorial overlay sits beside the panels and switches them through this */}
|
|
131
|
+
<PanelNavigationHolder>
|
|
132
|
+
<InnerMatchViewer onBack={onBack} />
|
|
133
|
+
</PanelNavigationHolder>
|
|
123
134
|
</ThemeProvider>
|
|
124
135
|
</GameThemeProvider>
|
|
125
136
|
</ModalProvider>
|
|
@@ -16,6 +16,7 @@ import { PanelTabStack, TAB_HEIGHT } from "./PanelTabStack";
|
|
|
16
16
|
import { usePanelPositioning } from "../../hooks/usePanelPositioning";
|
|
17
17
|
import { useSmartDebouncedState } from "../../hooks/useSmartDebouncedState";
|
|
18
18
|
import { ViewerZoomControls } from "./ViewerZoomControls";
|
|
19
|
+
import { usePanelNavigation } from "../../hooks/usePanelNavigation";
|
|
19
20
|
|
|
20
21
|
const ANIMATION_DURATION = 0.125;
|
|
21
22
|
|
|
@@ -240,6 +241,26 @@ export function MultiPanel({
|
|
|
240
241
|
|
|
241
242
|
const focusedRoot = focusedPanel?.renderInstance as RootChitRenderInstance;
|
|
242
243
|
|
|
244
|
+
// Let the tutorial overlay bring any of our panels to the front
|
|
245
|
+
const navigation = usePanelNavigation();
|
|
246
|
+
const selectRef = useRef(manuallyChangeSelectedIndex);
|
|
247
|
+
selectRef.current = manuallyChangeSelectedIndex;
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
if (!navigation || !enabled) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const unregisters = chits.map((chit, index) =>
|
|
253
|
+
navigation.registerSelector(chit.id ?? "", () => {
|
|
254
|
+
selectRef.current(index);
|
|
255
|
+
// A tutorial asked for this panel: hold it against the automatic "show where something
|
|
256
|
+
// changed" switching for a while, prompt or not
|
|
257
|
+
setIgnoreChangesBefore(Date.now() + PANEL_ADJUST_IGNORE_DURATION);
|
|
258
|
+
}),
|
|
259
|
+
);
|
|
260
|
+
return () => unregisters.forEach((u) => u());
|
|
261
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
262
|
+
}, [navigation, chitIdsString, enabled]);
|
|
263
|
+
|
|
243
264
|
return (
|
|
244
265
|
<Stack
|
|
245
266
|
sx={{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useState, useEffect, useCallback, createContext, useContext } from "react";
|
|
1
|
+
import React, { useRef, useState, useEffect, useCallback, createContext, useContext, useMemo } from "react";
|
|
2
2
|
import { Box } from "@mui/material";
|
|
3
3
|
import useSize from "@react-hook/size";
|
|
4
4
|
import { useGameTheme } from "../../hooks/useGameTheme";
|
|
@@ -11,6 +11,7 @@ import { Chit } from "../../game/Chit";
|
|
|
11
11
|
import Hammer from "@egjs/hammerjs";
|
|
12
12
|
import { PanelPositioningContext, ViewerPosition } from "../../hooks/usePanelPositioning";
|
|
13
13
|
import { ViewerWrapper } from "./ViewerWrapper";
|
|
14
|
+
import { PanelNavigation, PanelNavigationContext, usePublishPanelNavigation } from "../../hooks/usePanelNavigation";
|
|
14
15
|
|
|
15
16
|
// Types for gesture handling
|
|
16
17
|
export interface ViewerGestureHandlers {
|
|
@@ -252,9 +253,76 @@ export function PanelContents({
|
|
|
252
253
|
fullChitList.push(rootChit);
|
|
253
254
|
}
|
|
254
255
|
|
|
256
|
+
// Panel navigation (used by the tutorial overlay to bring a chit's panel to the front)
|
|
257
|
+
const selectorsRef = useRef<Map<string, () => void>>(new Map());
|
|
258
|
+
const panelRootsRef = useRef<Chit[]>(tabChitList);
|
|
259
|
+
panelRootsRef.current = tabChitList;
|
|
260
|
+
const focusedPanelRef = useRef(focusedPanel);
|
|
261
|
+
focusedPanelRef.current = focusedPanel;
|
|
262
|
+
/** The panel root (a chit with its own viewer) that shows `chit` */
|
|
263
|
+
const panelOf = (chit: Chit): Chit | undefined => {
|
|
264
|
+
const roots = new Set(panelRootsRef.current.map((c) => c.id));
|
|
265
|
+
let panel: Chit | undefined = chit;
|
|
266
|
+
while (panel && !roots.has(panel.id)) {
|
|
267
|
+
panel = panel.parent;
|
|
268
|
+
}
|
|
269
|
+
return panel;
|
|
270
|
+
};
|
|
271
|
+
const navigation = useMemo<PanelNavigation>(
|
|
272
|
+
() => ({
|
|
273
|
+
registerSelector: (chitId, select) => {
|
|
274
|
+
selectorsRef.current.set(chitId, select);
|
|
275
|
+
return () => {
|
|
276
|
+
if (selectorsRef.current.get(chitId) === select) selectorsRef.current.delete(chitId);
|
|
277
|
+
};
|
|
278
|
+
},
|
|
279
|
+
panelRoots: () => panelRootsRef.current,
|
|
280
|
+
isFront: (chitId) => positionsRef.current.get(chitId)?.front ?? false,
|
|
281
|
+
revealChit: async (chit) => {
|
|
282
|
+
const panel = panelOf(chit);
|
|
283
|
+
if (!panel?.id) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
// Showing a panel full screen (the player zoomed in, or a tutorial focused it): that layout
|
|
287
|
+
// has every panel as a tab, so switch tabs there rather than leave it
|
|
288
|
+
const select = selectorsRef.current.get(panel.id);
|
|
289
|
+
if (select && !(positionsRef.current.get(panel.id)?.front ?? false)) {
|
|
290
|
+
select();
|
|
291
|
+
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
292
|
+
}
|
|
293
|
+
return true;
|
|
294
|
+
},
|
|
295
|
+
keepFront: (chit) => {
|
|
296
|
+
// Selecting the tab already in front changes nothing but re-arms its hold against the
|
|
297
|
+
// automatic "show where something changed" switching
|
|
298
|
+
const panel = panelOf(chit);
|
|
299
|
+
if (panel?.id && (positionsRef.current.get(panel.id)?.front ?? false)) selectorsRef.current.get(panel.id)?.();
|
|
300
|
+
},
|
|
301
|
+
focusedPanel: () => focusedPanelRef.current,
|
|
302
|
+
focusPanelOf: async (chit) => {
|
|
303
|
+
const panel = chit ? panelOf(chit) : undefined;
|
|
304
|
+
if (chit && !panel?.id) return false;
|
|
305
|
+
if (focusedPanelRef.current === panel) return true;
|
|
306
|
+
if (!panel) {
|
|
307
|
+
setFocusedPanel(undefined);
|
|
308
|
+
} else if (focusedPanelRef.current) {
|
|
309
|
+
selectorsRef.current.get(panel.id!)?.(); // already full screen: switch to its tab
|
|
310
|
+
} else {
|
|
311
|
+
setFocusedPanel(panel);
|
|
312
|
+
}
|
|
313
|
+
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
314
|
+
return true;
|
|
315
|
+
},
|
|
316
|
+
}),
|
|
317
|
+
[],
|
|
318
|
+
);
|
|
319
|
+
// The tutorial overlay is outside these panels: it reaches the navigation through the viewer
|
|
320
|
+
usePublishPanelNavigation(navigation);
|
|
321
|
+
|
|
255
322
|
return (
|
|
256
323
|
<GestureContext.Provider value={gestureContextValue}>
|
|
257
324
|
<PanelPositioningContext.Provider value={positioningContextValue}>
|
|
325
|
+
<PanelNavigationContext.Provider value={navigation}>
|
|
258
326
|
<Box
|
|
259
327
|
sx={{
|
|
260
328
|
position: "relative",
|
|
@@ -358,6 +426,7 @@ export function PanelContents({
|
|
|
358
426
|
})}
|
|
359
427
|
</Box>
|
|
360
428
|
</Box>
|
|
429
|
+
</PanelNavigationContext.Provider>
|
|
361
430
|
</PanelPositioningContext.Provider>
|
|
362
431
|
</GestureContext.Provider>
|
|
363
432
|
);
|
|
@@ -35,6 +35,7 @@ function PanelTab({ chit, onClick, selected }: { selected?: boolean; chit: Chit;
|
|
|
35
35
|
return (
|
|
36
36
|
<Box
|
|
37
37
|
onMouseDown={onClick}
|
|
38
|
+
data-tutorial-target={`panelTab:${chit.id}`}
|
|
38
39
|
sx={{ pt: 1, pb: 1, mt: -1, mb: -1, position: "relative", zIndex: ZINDEX_PANEL_CUTOUTS }}
|
|
39
40
|
>
|
|
40
41
|
<Box
|
|
@@ -42,10 +42,14 @@ export default function PanelSpark({ chit, paused, zIndex }: { zIndex: number; c
|
|
|
42
42
|
const key = `spark${chit.id ?? "no id"}`;
|
|
43
43
|
timeState.setAnimationState(key, true);
|
|
44
44
|
setFlashed(true);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
// As fast as the board's other animations when they are hurried (going live, skipping ahead)
|
|
46
|
+
setTimeout(
|
|
47
|
+
() => {
|
|
48
|
+
setFlashed(false);
|
|
49
|
+
timeState.setAnimationState(key, false);
|
|
50
|
+
},
|
|
51
|
+
DURATION * (timeState.animationSpeedOverrideMultiplier.value ?? 1),
|
|
52
|
+
);
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
}, [chit, timeState, paused, value, targetValue, DURATION]);
|
|
@@ -80,6 +84,7 @@ export default function PanelSpark({ chit, paused, zIndex }: { zIndex: number; c
|
|
|
80
84
|
return (
|
|
81
85
|
<Box
|
|
82
86
|
ref={ref}
|
|
87
|
+
data-tutorial-target={`spark:${chit.id}`}
|
|
83
88
|
sx={{
|
|
84
89
|
position: "relative",
|
|
85
90
|
background: flashed ? theme.sparkFlashColor : backgroundColor,
|
|
@@ -209,27 +209,54 @@ function NewMatchDialog({
|
|
|
209
209
|
))}
|
|
210
210
|
</FormGroup>
|
|
211
211
|
</FormControl>
|
|
212
|
-
{configOptions.map((option) =>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
212
|
+
{configOptions.map((option) => {
|
|
213
|
+
const setOption = (value: unknown) =>
|
|
214
|
+
setMatchOptions((prev: any) => ({ ...prev, [option.fieldName]: value }));
|
|
215
|
+
if (option.config.multiple) {
|
|
216
|
+
const selected: string[] = matchOptions[option.fieldName] ?? option.currentValue ?? [];
|
|
217
|
+
return (
|
|
218
|
+
<FormControl key={option.fieldName} component="fieldset">
|
|
219
|
+
<FormLabel component="legend">{option.config.label}</FormLabel>
|
|
220
|
+
<FormGroup>
|
|
221
|
+
{option.config.choices.map((choice) => (
|
|
222
|
+
<FormControlLabel
|
|
223
|
+
key={choice.id}
|
|
224
|
+
label={choice.label ?? choice.id}
|
|
225
|
+
control={
|
|
226
|
+
<Checkbox
|
|
227
|
+
checked={selected.includes(choice.id)}
|
|
228
|
+
onChange={(e) =>
|
|
229
|
+
setOption(
|
|
230
|
+
e.target.checked
|
|
231
|
+
? [...selected, choice.id]
|
|
232
|
+
: selected.filter((id) => id !== choice.id),
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
/>
|
|
236
|
+
}
|
|
237
|
+
/>
|
|
238
|
+
))}
|
|
239
|
+
</FormGroup>
|
|
240
|
+
</FormControl>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return (
|
|
244
|
+
<FormControl key={option.fieldName} fullWidth>
|
|
245
|
+
<InputLabel>{option.config.label}</InputLabel>
|
|
246
|
+
<Select
|
|
247
|
+
value={matchOptions[option.fieldName] ?? option.currentValue}
|
|
248
|
+
label={option.config.label}
|
|
249
|
+
onChange={(e) => setOption(e.target.value)}
|
|
250
|
+
>
|
|
251
|
+
{option.config.choices.map((choice) => (
|
|
252
|
+
<MenuItem key={choice.id} value={choice.id}>
|
|
253
|
+
{choice.label ?? choice.id}
|
|
254
|
+
</MenuItem>
|
|
255
|
+
))}
|
|
256
|
+
</Select>
|
|
257
|
+
</FormControl>
|
|
258
|
+
);
|
|
259
|
+
})}
|
|
233
260
|
</Stack>
|
|
234
261
|
</DialogContent>
|
|
235
262
|
<DialogActions>
|
|
@@ -99,6 +99,8 @@ export default function PromptControls({ collapsible }: { collapsible?: boolean
|
|
|
99
99
|
const speed = useAnimationSpeedMultiplier();
|
|
100
100
|
const clientPrompt = useClientPrompts();
|
|
101
101
|
const [prompt] = useEventChannelState(clientPrompt.currentPrompt);
|
|
102
|
+
const [undoOverride] = useEventChannelState(clientPrompt.undoOverride);
|
|
103
|
+
const canUndo = !!prompt?.canReset;
|
|
102
104
|
const [promptSpec] = useEventChannelState(clientPrompt.getPromptEventChannelForPlayer(playerId));
|
|
103
105
|
const [expandedBecauseOfPrompt, setExpandedBecauseOfPrompt] = useState(!!prompt);
|
|
104
106
|
const [live] = useEventChannelState(timeState.live);
|
|
@@ -127,6 +129,7 @@ export default function PromptControls({ collapsible }: { collapsible?: boolean
|
|
|
127
129
|
return (
|
|
128
130
|
<Stack
|
|
129
131
|
direction="row"
|
|
132
|
+
data-tutorial-target="prompt"
|
|
130
133
|
sx={{
|
|
131
134
|
position: collapsible ? "absolute" : "static",
|
|
132
135
|
overflow: "hidden",
|
|
@@ -167,12 +170,13 @@ export default function PromptControls({ collapsible }: { collapsible?: boolean
|
|
|
167
170
|
</GameDialog>
|
|
168
171
|
)} */}
|
|
169
172
|
|
|
170
|
-
{prompt
|
|
173
|
+
{prompt && canUndo && (
|
|
171
174
|
<BottomBarButton
|
|
172
175
|
icon={Replay}
|
|
173
176
|
label="Undo"
|
|
174
|
-
|
|
175
|
-
|
|
177
|
+
tutorialTarget="undo"
|
|
178
|
+
onClick={() => (undoOverride ? undoOverride.undo() : prompt.stepBack())}
|
|
179
|
+
onLongClick={() => (undoOverride ? undoOverride.undo() : prompt.stepBack(true))}
|
|
176
180
|
/>
|
|
177
181
|
)}
|
|
178
182
|
<Box flex={1} />
|
|
@@ -28,32 +28,30 @@ interface SparkLineChartProps {
|
|
|
28
28
|
width?: number;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const HALO_OPACITY = 0.
|
|
31
|
+
const HALO_OPACITY = 0.85;
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
// black and white read as arbitrary noise.
|
|
33
|
+
// The halo is the bg itself, made opaque — a knockout that cuts each line and
|
|
34
|
+
// label cleanly out of the grid and the lines it crosses, invisible against the
|
|
35
|
+
// bg. A halo opposite the bg reads as grey fuzz around everything.
|
|
37
36
|
function getUnifiedHaloColor(backgroundColor: string): string {
|
|
38
|
-
return Color(backgroundColor).
|
|
37
|
+
return Color(backgroundColor).alpha(1).hex();
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (candidate.contrast(halo) >= minRatio) return candidate.hex();
|
|
40
|
+
// A player colour too close to the bg's luminance (dark red on a dark dialog)
|
|
41
|
+
// would vanish, so step its HSL lightness away from the bg until WCAG contrast
|
|
42
|
+
// clears the large-text threshold (the 20px bold labels). Hue and saturation
|
|
43
|
+
// are kept, so the colour still reads as that player's; colours that already
|
|
44
|
+
// contrast are left untouched.
|
|
45
|
+
function adjustLineForBackground(lineColor: string, backgroundColor: string, minRatio = 3): string {
|
|
46
|
+
const bg = Color(backgroundColor).alpha(1);
|
|
47
|
+
const line = Color(lineColor).alpha(1);
|
|
48
|
+
if (line.contrast(bg) >= minRatio) return line.hex();
|
|
49
|
+
const step = bg.isDark() ? 5 : -5;
|
|
50
|
+
for (let l = line.lightness() + step; l > 0 && l < 100; l += step) {
|
|
51
|
+
const candidate = line.lightness(l);
|
|
52
|
+
if (candidate.contrast(bg) >= minRatio) return candidate.hex();
|
|
55
53
|
}
|
|
56
|
-
return
|
|
54
|
+
return bg.isDark() ? "#ffffff" : "#000000";
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
export function SparkLineChart({
|
|
@@ -168,14 +166,12 @@ export function SparkLineChart({
|
|
|
168
166
|
const getY = (value: number) => chartHeight - ((value - chartMinValue) / chartValueRange) * chartHeight;
|
|
169
167
|
const chartEndX = chartWidth;
|
|
170
168
|
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
// bg the halo is dark, all the light pastels keep their hue, and the lone
|
|
174
|
-
// dark line gets lightened until the dark halo can actually frame it.
|
|
169
|
+
// Lines keep their player colours unless they'd sink into the bg; the halo
|
|
170
|
+
// matches the bg so it separates without tinting anything.
|
|
175
171
|
const haloColor = getUnifiedHaloColor(backgroundColor);
|
|
176
172
|
const displayLines = lines.map((line) => ({
|
|
177
173
|
...line,
|
|
178
|
-
color:
|
|
174
|
+
color: adjustLineForBackground(line.color, backgroundColor),
|
|
179
175
|
}));
|
|
180
176
|
|
|
181
177
|
return (
|
|
@@ -231,7 +227,7 @@ export function SparkLineChart({
|
|
|
231
227
|
|
|
232
228
|
return (
|
|
233
229
|
<g key={line.id}>
|
|
234
|
-
{/*
|
|
230
|
+
{/* Bg-coloured knockout behind every line. */}
|
|
235
231
|
<path
|
|
236
232
|
d={extendedPathData}
|
|
237
233
|
fill="none"
|