@pretty-chitty/core 1.1.2 → 1.2.1
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/dist/components/BottomBarButton.d.ts +2 -1
- package/dist/components/BottomBarButton.d.ts.map +1 -1
- package/dist/components/BottomBarButton.js +2 -1
- package/dist/components/BottomBarButton.js.map +1 -1
- package/dist/components/ClientTrustMatchViewer.d.ts +4 -1
- package/dist/components/ClientTrustMatchViewer.d.ts.map +1 -1
- package/dist/components/ClientTrustMatchViewer.js +11 -4
- package/dist/components/ClientTrustMatchViewer.js.map +1 -1
- package/dist/components/ContextGalleryDisplay.js +1 -1
- package/dist/components/ContextGalleryDisplay.js.map +1 -1
- package/dist/components/DemoWrapper.d.ts +9 -0
- package/dist/components/DemoWrapper.d.ts.map +1 -0
- package/dist/components/DemoWrapper.js +76 -0
- package/dist/components/DemoWrapper.js.map +1 -0
- package/dist/components/FullScreenGalleryDisplay.d.ts +2 -0
- package/dist/components/FullScreenGalleryDisplay.d.ts.map +1 -0
- package/dist/components/FullScreenGalleryDisplay.js +56 -0
- package/dist/components/FullScreenGalleryDisplay.js.map +1 -0
- package/dist/components/Gallery/AnimationController.d.ts +19 -0
- package/dist/components/Gallery/AnimationController.d.ts.map +1 -0
- package/dist/components/Gallery/AnimationController.js +82 -0
- package/dist/components/Gallery/AnimationController.js.map +1 -0
- package/dist/components/Gallery/BuiltItem.d.ts +58 -0
- package/dist/components/Gallery/BuiltItem.d.ts.map +1 -0
- package/dist/components/Gallery/BuiltItem.js +313 -0
- package/dist/components/Gallery/BuiltItem.js.map +1 -0
- package/dist/components/Gallery/CameraManager.d.ts +14 -0
- package/dist/components/Gallery/CameraManager.d.ts.map +1 -0
- package/dist/components/Gallery/CameraManager.js +43 -0
- package/dist/components/Gallery/CameraManager.js.map +1 -0
- package/dist/components/Gallery/GalleryController.d.ts +30 -0
- package/dist/components/Gallery/GalleryController.d.ts.map +1 -0
- package/dist/components/Gallery/GalleryController.js +137 -0
- package/dist/components/Gallery/GalleryController.js.map +1 -0
- package/dist/components/Gallery/GalleryViewer.d.ts +18 -0
- package/dist/components/Gallery/GalleryViewer.d.ts.map +1 -0
- package/dist/components/Gallery/GalleryViewer.js +141 -0
- package/dist/components/Gallery/GalleryViewer.js.map +1 -0
- package/dist/components/Gallery/LayoutManager.d.ts +49 -0
- package/dist/components/Gallery/LayoutManager.d.ts.map +1 -0
- package/dist/components/Gallery/LayoutManager.js +132 -0
- package/dist/components/Gallery/LayoutManager.js.map +1 -0
- package/dist/components/Gallery/constants.d.ts +13 -0
- package/dist/components/Gallery/constants.d.ts.map +1 -0
- package/dist/components/Gallery/constants.js +13 -0
- package/dist/components/Gallery/constants.js.map +1 -0
- package/dist/components/Gallery/index.d.ts +3 -0
- package/dist/components/Gallery/index.d.ts.map +1 -0
- package/dist/components/Gallery/index.js +2 -0
- package/dist/components/Gallery/index.js.map +1 -0
- package/dist/components/Gallery/types.d.ts +45 -0
- package/dist/components/Gallery/types.d.ts.map +1 -0
- package/dist/components/Gallery/types.js +2 -0
- package/dist/components/Gallery/types.js.map +1 -0
- package/dist/components/GalleryPlayground.js +1 -1
- package/dist/components/GalleryPlayground.js.map +1 -1
- package/dist/components/GalleryViewer.d.ts +2 -47
- package/dist/components/GalleryViewer.d.ts.map +1 -1
- package/dist/components/GalleryViewer.js +3 -569
- package/dist/components/GalleryViewer.js.map +1 -1
- package/dist/components/GameDesigner.d.ts.map +1 -1
- package/dist/components/GameDesigner.js +13 -2
- package/dist/components/GameDesigner.js.map +1 -1
- package/dist/components/InlineGalleryDisplay.d.ts +2 -0
- package/dist/components/InlineGalleryDisplay.d.ts.map +1 -0
- package/dist/components/InlineGalleryDisplay.js +69 -0
- package/dist/components/InlineGalleryDisplay.js.map +1 -0
- package/dist/components/LiveButton.d.ts.map +1 -1
- package/dist/components/LiveButton.js +1 -1
- package/dist/components/LiveButton.js.map +1 -1
- package/dist/components/MatchViewer.d.ts +0 -1
- package/dist/components/MatchViewer.d.ts.map +1 -1
- package/dist/components/MatchViewer.js +20 -10
- package/dist/components/MatchViewer.js.map +1 -1
- package/dist/components/Panel/MultiPanel.d.ts.map +1 -1
- package/dist/components/Panel/MultiPanel.js +14 -7
- package/dist/components/Panel/MultiPanel.js.map +1 -1
- package/dist/components/Panel/PanelContents.d.ts +2 -1
- package/dist/components/Panel/PanelContents.d.ts.map +1 -1
- package/dist/components/Panel/PanelContents.js +16 -11
- package/dist/components/Panel/PanelContents.js.map +1 -1
- package/dist/components/Panel/SinglePanel.d.ts.map +1 -1
- package/dist/components/Panel/SinglePanel.js +4 -3
- package/dist/components/Panel/SinglePanel.js.map +1 -1
- package/dist/components/Panel/ViewerWrapper.d.ts +1 -3
- package/dist/components/Panel/ViewerWrapper.d.ts.map +1 -1
- package/dist/components/Panel/ViewerWrapper.js +2 -3
- package/dist/components/Panel/ViewerWrapper.js.map +1 -1
- package/dist/components/Playground.d.ts.map +1 -1
- package/dist/components/Playground.js +353 -50
- package/dist/components/Playground.js.map +1 -1
- package/dist/components/PromptControls.d.ts.map +1 -1
- package/dist/components/PromptControls.js +39 -6
- package/dist/components/PromptControls.js.map +1 -1
- package/dist/components/ServerTrustMatchViewer.d.ts +11 -0
- package/dist/components/ServerTrustMatchViewer.d.ts.map +1 -0
- package/dist/components/ServerTrustMatchViewer.js +26 -0
- package/dist/components/ServerTrustMatchViewer.js.map +1 -0
- package/dist/components/Viewer.d.ts.map +1 -1
- package/dist/components/Viewer.js +54 -14
- package/dist/components/Viewer.js.map +1 -1
- package/dist/game/Chit.d.ts +6 -2
- package/dist/game/Chit.d.ts.map +1 -1
- package/dist/game/Chit.js +50 -6
- package/dist/game/Chit.js.map +1 -1
- package/dist/game/ClientTimeState.d.ts +1 -0
- package/dist/game/ClientTimeState.d.ts.map +1 -1
- package/dist/game/ClientTimeState.js +4 -1
- package/dist/game/ClientTimeState.js.map +1 -1
- package/dist/game/GalleryItemChitChildrenSource.d.ts +1 -0
- package/dist/game/GalleryItemChitChildrenSource.d.ts.map +1 -1
- package/dist/game/GalleryItemChitChildrenSource.js +1 -0
- package/dist/game/GalleryItemChitChildrenSource.js.map +1 -1
- package/dist/game/GalleryItemRawSource.d.ts +1 -0
- package/dist/game/GalleryItemRawSource.d.ts.map +1 -1
- package/dist/game/GalleryItemRawSource.js +1 -0
- package/dist/game/GalleryItemRawSource.js.map +1 -1
- package/dist/game/Game.d.ts +2 -1
- package/dist/game/Game.d.ts.map +1 -1
- package/dist/game/GameButton.d.ts +1 -0
- package/dist/game/GameButton.d.ts.map +1 -1
- package/dist/game/GameButton.js +2 -0
- package/dist/game/GameButton.js.map +1 -1
- package/dist/game/GameDeckChit.d.ts +6 -0
- package/dist/game/GameDeckChit.d.ts.map +1 -1
- package/dist/game/GameDeckChit.js +32 -5
- package/dist/game/GameDeckChit.js.map +1 -1
- package/dist/game/GameMetaData.d.ts +18 -0
- package/dist/game/GameMetaData.d.ts.map +1 -0
- package/dist/game/GameMetaData.js +2 -0
- package/dist/game/GameMetaData.js.map +1 -0
- package/dist/game/GameTheme.d.ts +11 -0
- package/dist/game/GameTheme.d.ts.map +1 -1
- package/dist/game/GameTheme.js +19 -4
- package/dist/game/GameTheme.js.map +1 -1
- package/dist/game/Match.d.ts +2 -1
- package/dist/game/Match.d.ts.map +1 -1
- package/dist/game/Match.js +4 -3
- package/dist/game/Match.js.map +1 -1
- package/dist/game/MatchStorage.d.ts +10 -0
- package/dist/game/MatchStorage.d.ts.map +1 -1
- package/dist/game/MatchStorage.js +29 -0
- package/dist/game/MatchStorage.js.map +1 -1
- package/dist/game/ModalState.d.ts +1 -0
- package/dist/game/ModalState.d.ts.map +1 -1
- package/dist/game/ModalState.js +1 -0
- package/dist/game/ModalState.js.map +1 -1
- package/dist/game/OrderedOutlet.d.ts.map +1 -1
- package/dist/game/OrderedOutlet.js +6 -6
- package/dist/game/OrderedOutlet.js.map +1 -1
- package/dist/game/Pick.d.ts +11 -1
- package/dist/game/Pick.d.ts.map +1 -1
- package/dist/game/Pick.js +83 -1
- package/dist/game/Pick.js.map +1 -1
- package/dist/game/PlayerChit.d.ts +2 -1
- package/dist/game/PlayerChit.d.ts.map +1 -1
- package/dist/game/PlayerChit.js +13 -1
- package/dist/game/PlayerChit.js.map +1 -1
- package/dist/game/PlayerInfo.d.ts +2 -1
- package/dist/game/PlayerInfo.d.ts.map +1 -1
- package/dist/game/PlayerInfo.js +20 -3
- package/dist/game/PlayerInfo.js.map +1 -1
- package/dist/game/Prompt.d.ts +1 -11
- package/dist/game/Prompt.d.ts.map +1 -1
- package/dist/game/Prompt.js +0 -32
- package/dist/game/Prompt.js.map +1 -1
- package/dist/game/RootChit.d.ts +4 -0
- package/dist/game/RootChit.d.ts.map +1 -1
- package/dist/game/RootChit.js +36 -1
- package/dist/game/RootChit.js.map +1 -1
- package/dist/game/Turn.d.ts +9 -8
- package/dist/game/Turn.d.ts.map +1 -1
- package/dist/game/Turn.js +34 -34
- package/dist/game/Turn.js.map +1 -1
- package/dist/game/TurnState.d.ts +3 -2
- package/dist/game/TurnState.d.ts.map +1 -1
- package/dist/game/TurnState.js +22 -2
- package/dist/game/TurnState.js.map +1 -1
- package/dist/game/badAiTransport/BadAIClientPrompts.d.ts +14 -0
- package/dist/game/badAiTransport/BadAIClientPrompts.d.ts.map +1 -0
- package/dist/game/badAiTransport/BadAIClientPrompts.js +50 -0
- package/dist/game/badAiTransport/BadAIClientPrompts.js.map +1 -0
- package/dist/game/clientTransport/ClientTime.js +1 -1
- package/dist/game/clientTransport/ClientTime.js.map +1 -1
- package/dist/game/serverTransport/ServerTime.d.ts.map +1 -1
- package/dist/game/serverTransport/ServerTime.js +1 -1
- package/dist/game/serverTransport/ServerTime.js.map +1 -1
- package/dist/hooks/useButtonGalleriesOptions.d.ts +4 -0
- package/dist/hooks/useButtonGalleriesOptions.d.ts.map +1 -0
- package/dist/hooks/useButtonGalleriesOptions.js +7 -0
- package/dist/hooks/useButtonGalleriesOptions.js.map +1 -0
- package/dist/hooks/useEventChannelState.js +1 -1
- package/dist/hooks/useEventChannelState.js.map +1 -1
- package/dist/hooks/useLoadingStates.d.ts +17 -0
- package/dist/hooks/useLoadingStates.d.ts.map +1 -0
- package/dist/hooks/useLoadingStates.js +44 -0
- package/dist/hooks/useLoadingStates.js.map +1 -0
- package/dist/hooks/useModalState.d.ts +2 -1
- package/dist/hooks/useModalState.d.ts.map +1 -1
- package/dist/hooks/useModalState.js +2 -2
- package/dist/hooks/useModalState.js.map +1 -1
- package/dist/hooks/usePanelPositioning.d.ts +0 -1
- package/dist/hooks/usePanelPositioning.d.ts.map +1 -1
- package/dist/hooks/usePanelPositioning.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/rendering/CameraWrapperPerspective.d.ts.map +1 -1
- package/dist/rendering/CameraWrapperPerspective.js +1 -1
- package/dist/rendering/CameraWrapperPerspective.js.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.d.ts +2 -0
- package/dist/rendering/ChitGalleryItemInstance.d.ts.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.js +2 -0
- package/dist/rendering/ChitGalleryItemInstance.js.map +1 -1
- package/dist/rendering/ChitRenderInstance.d.ts +13 -2
- package/dist/rendering/ChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/ChitRenderInstance.js +95 -47
- package/dist/rendering/ChitRenderInstance.js.map +1 -1
- package/dist/rendering/ChitRenderSpec.d.ts +3 -0
- package/dist/rendering/ChitRenderSpec.d.ts.map +1 -1
- package/dist/rendering/ChitRenderSpec.js +3 -0
- package/dist/rendering/ChitRenderSpec.js.map +1 -1
- package/dist/rendering/RootChitRenderInstance.d.ts +5 -2
- package/dist/rendering/RootChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/RootChitRenderInstance.js +76 -13
- package/dist/rendering/RootChitRenderInstance.js.map +1 -1
- package/dist/rendering/SplayCounter.d.ts.map +1 -1
- package/dist/rendering/SplayCounter.js +1 -1
- package/dist/rendering/SplayCounter.js.map +1 -1
- package/dist/rendering/TextureReferenceCounter.d.ts +1 -1
- package/dist/rendering/TextureReferenceCounter.d.ts.map +1 -1
- package/dist/rendering/TextureReferenceCounter.js +10 -10
- package/dist/rendering/TextureReferenceCounter.js.map +1 -1
- package/dist/rendering/outline/passes/DepthOcclusionPass.js +1 -1
- package/dist/rendering/outline/passes/DepthOcclusionPass.js.map +1 -1
- package/dist/utilities/Annotations.d.ts +59 -0
- package/dist/utilities/Annotations.d.ts.map +1 -1
- package/dist/utilities/Annotations.js +63 -0
- package/dist/utilities/Annotations.js.map +1 -1
- package/dist/utilities/CanvasStack/CanvasOperations.d.ts +10 -1
- package/dist/utilities/CanvasStack/CanvasOperations.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/CanvasOperations.js +8 -0
- package/dist/utilities/CanvasStack/CanvasOperations.js.map +1 -1
- package/dist/utilities/CanvasStack/ReactCanvas.d.ts +4 -2
- package/dist/utilities/CanvasStack/ReactCanvas.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/ReactCanvas.js +5 -2
- package/dist/utilities/CanvasStack/ReactCanvas.js.map +1 -1
- package/dist/utilities/CanvasStack/RichTextRenderer.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/RichTextRenderer.js +12 -4
- package/dist/utilities/CanvasStack/RichTextRenderer.js.map +1 -1
- package/dist/utilities/EventChannel.d.ts.map +1 -1
- package/dist/utilities/EventChannel.js +2 -3
- package/dist/utilities/EventChannel.js.map +1 -1
- package/dist/utilities/GlbLoader.d.ts +15 -0
- package/dist/utilities/GlbLoader.d.ts.map +1 -0
- package/dist/utilities/GlbLoader.js +212 -0
- package/dist/utilities/GlbLoader.js.map +1 -0
- package/dist/utilities/LayoutHelper.js +23 -2
- package/dist/utilities/LayoutHelper.js.map +1 -1
- package/dist/utilities/ObjectWithProps.d.ts.map +1 -1
- package/dist/utilities/ObjectWithProps.js +32 -3
- package/dist/utilities/ObjectWithProps.js.map +1 -1
- package/package.json +6 -5
- package/src/library/components/BottomBarButton.tsx +3 -0
- package/src/library/components/ClientTrustMatchViewer.tsx +23 -8
- package/src/library/components/ContextGalleryDisplay.tsx +2 -2
- package/src/library/components/DemoWrapper.tsx +113 -0
- package/src/library/components/{GalleryDisplay.tsx → FullScreenGalleryDisplay.tsx} +28 -2
- package/src/library/components/Gallery/AnimationController.ts +110 -0
- package/src/library/components/Gallery/BuiltItem.ts +385 -0
- package/src/library/components/Gallery/CameraManager.ts +54 -0
- package/src/library/components/Gallery/GalleryController.ts +193 -0
- package/src/library/components/Gallery/GalleryViewer.tsx +211 -0
- package/src/library/components/Gallery/LayoutManager.ts +166 -0
- package/src/library/components/Gallery/constants.ts +12 -0
- package/src/library/components/Gallery/index.ts +2 -0
- package/src/library/components/Gallery/types.ts +55 -0
- package/src/library/components/GalleryPlayground.tsx +1 -1
- package/src/library/components/GalleryViewer.tsx +4 -773
- package/src/library/components/GameDesigner.tsx +21 -4
- package/src/library/components/InlineGalleryDisplay.tsx +101 -0
- package/src/library/components/LiveButton.tsx +2 -1
- package/src/library/components/MatchViewer.tsx +32 -14
- package/src/library/components/Panel/MultiPanel.tsx +20 -8
- package/src/library/components/Panel/PanelContents.tsx +17 -12
- package/src/library/components/Panel/SinglePanel.tsx +5 -4
- package/src/library/components/Panel/ViewerWrapper.tsx +0 -5
- package/src/library/components/Playground.tsx +692 -119
- package/src/library/components/PromptControls.tsx +61 -8
- package/src/library/components/ServerTrustMatchViewer.tsx +53 -0
- package/src/library/components/Viewer.tsx +60 -20
- package/src/library/game/Chit.ts +53 -6
- package/src/library/game/ClientTimeState.ts +5 -1
- package/src/library/game/GalleryItemChitChildrenSource.ts +2 -0
- package/src/library/game/GalleryItemRawSource.ts +2 -0
- package/src/library/game/Game.ts +3 -1
- package/src/library/game/GameButton.ts +3 -0
- package/src/library/game/GameDeckChit.ts +36 -5
- package/src/library/game/GameMetaData.ts +19 -0
- package/src/library/game/GameTheme.ts +23 -5
- package/src/library/game/Match.ts +4 -3
- package/src/library/game/MatchStorage.ts +37 -0
- package/src/library/game/ModalState.ts +1 -0
- package/src/library/game/OrderedOutlet.ts +6 -6
- package/src/library/game/Pick.ts +98 -2
- package/src/library/game/PlayerChit.ts +13 -1
- package/src/library/game/PlayerInfo.ts +22 -3
- package/src/library/game/Prompt.ts +1 -36
- package/src/library/game/RootChit.ts +41 -1
- package/src/library/game/Turn.ts +37 -40
- package/src/library/game/TurnState.ts +22 -3
- package/src/library/game/badAiTransport/BadAIClientPrompts.ts +60 -0
- package/src/library/game/clientTransport/ClientTime.ts +1 -1
- package/src/library/game/serverTransport/ServerTime.ts +2 -2
- package/src/library/hooks/useButtonGalleriesOptions.tsx +9 -0
- package/src/library/hooks/useEventChannelState.ts +1 -1
- package/src/library/hooks/useLoadingStates.tsx +55 -0
- package/src/library/hooks/useModalState.tsx +2 -2
- package/src/library/hooks/usePanelPositioning.tsx +0 -1
- package/src/library/index.ts +21 -1
- package/src/library/rendering/CameraWrapperPerspective.ts +10 -12
- package/src/library/rendering/ChitGalleryItemInstance.ts +2 -0
- package/src/library/rendering/ChitRenderInstance.ts +119 -61
- package/src/library/rendering/ChitRenderSpec.ts +4 -0
- package/src/library/rendering/RootChitRenderInstance.ts +87 -13
- package/src/library/rendering/SplayCounter.tsx +2 -1
- package/src/library/rendering/TextureReferenceCounter.ts +9 -9
- package/src/library/rendering/outline/passes/DepthOcclusionPass.ts +1 -1
- package/src/library/utilities/Annotations.ts +99 -0
- package/src/library/utilities/CanvasStack/CanvasOperations.tsx +19 -1
- package/src/library/utilities/CanvasStack/ReactCanvas.tsx +10 -3
- package/src/library/utilities/CanvasStack/RichTextRenderer.ts +14 -4
- package/src/library/utilities/EventChannel.ts +2 -4
- package/src/library/utilities/GlbLoader.ts +292 -0
- package/src/library/utilities/LayoutHelper.ts +28 -2
- package/src/library/utilities/ObjectWithProps.ts +27 -3
- package/dist/components/GalleryDisplay.d.ts +0 -2
- package/dist/components/GalleryDisplay.d.ts.map +0 -1
- package/dist/components/GalleryDisplay.js +0 -42
- package/dist/components/GalleryDisplay.js.map +0 -1
- package/dist/utilities/OutlineCanvas.d.ts +0 -12
- package/dist/utilities/OutlineCanvas.d.ts.map +0 -1
- package/dist/utilities/OutlineCanvas.js +0 -31
- package/dist/utilities/OutlineCanvas.js.map +0 -1
- package/dist/utilities/OutlineGeometry.d.ts +0 -3
- package/dist/utilities/OutlineGeometry.d.ts.map +0 -1
- package/dist/utilities/OutlineGeometry.js +0 -57
- package/dist/utilities/OutlineGeometry.js.map +0 -1
- package/src/library/utilities/OutlineCanvas.tsx +0 -45
- package/src/library/utilities/OutlineGeometry.ts +0 -69
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { ChevronRight, ChevronLeft, Replay
|
|
2
|
+
import { ChevronRight, ChevronLeft, Replay } from "@mui/icons-material";
|
|
3
3
|
import { Box, Stack } from "@mui/material";
|
|
4
4
|
import BottomBarButton from "./BottomBarButton";
|
|
5
5
|
import { useGameTheme } from "../hooks/useGameTheme";
|
|
@@ -7,23 +7,64 @@ import BottomBarBreak from "./BottomBarBreak";
|
|
|
7
7
|
import { useEventChannelState } from "../hooks/useEventChannelState";
|
|
8
8
|
import { useAnimationSpeedMultiplier, useClientPrompts, useTimeState } from "../hooks/useTimeController";
|
|
9
9
|
import { usePlayerId } from "../hooks/usePlayer";
|
|
10
|
-
import GameDialog from "./GameDialog";
|
|
11
|
-
import Markdown from "react-markdown";
|
|
12
10
|
import { ZINDEX_PROMPT_CONTROLS } from "../utilities/zIndex";
|
|
13
11
|
import { GameButton, ToggleGalleryButton } from "../game/GameButton";
|
|
14
12
|
import { useModalState } from "../hooks/useModalState";
|
|
15
13
|
import { ContextGalleryDisplay } from "./ContextGalleryDisplay";
|
|
16
14
|
import { NoValidMovesPrompt } from "../game/Prompt";
|
|
15
|
+
import { useButtonGalleriesOptions } from "../hooks/useButtonGalleriesOptions";
|
|
16
|
+
|
|
17
|
+
function SimpleToggle({ checked }: { checked: boolean }) {
|
|
18
|
+
const gameTheme = useGameTheme();
|
|
19
|
+
const trackWidth = 28;
|
|
20
|
+
const trackHeight = 10;
|
|
21
|
+
const thumbSize = 6;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Box
|
|
25
|
+
sx={{
|
|
26
|
+
width: trackWidth,
|
|
27
|
+
height: trackHeight,
|
|
28
|
+
borderRadius: trackHeight / 2,
|
|
29
|
+
backgroundColor: checked ? gameTheme.actionBarToggleSelectedColor : "rgba(0,0,0,.25)",
|
|
30
|
+
position: "relative",
|
|
31
|
+
transition: "background-color 0.2s ease",
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
<Box
|
|
35
|
+
sx={{
|
|
36
|
+
width: thumbSize,
|
|
37
|
+
height: thumbSize,
|
|
38
|
+
borderRadius: "50%",
|
|
39
|
+
backgroundColor: gameTheme.barTextColor,
|
|
40
|
+
boxShadow: "0 2px 4px 0 rgb(0 35 11 / 20%)",
|
|
41
|
+
position: "absolute",
|
|
42
|
+
top: (trackHeight - thumbSize) / 2,
|
|
43
|
+
left: checked ? trackWidth - thumbSize - 2 : 2,
|
|
44
|
+
transition: "left 0.2s ease",
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
</Box>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
17
50
|
|
|
18
51
|
function GameButtonWrapper({ button }: { button: GameButton }) {
|
|
19
52
|
const modalState = useModalState();
|
|
20
53
|
const [source, setSource] = useEventChannelState(modalState.gallerySource);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
let cb = button.cb;
|
|
54
|
+
const [inlineSource, setInlineSource] = useEventChannelState(modalState.inlineGallerySource);
|
|
55
|
+
const [galleryDisplayMode] = useButtonGalleriesOptions();
|
|
24
56
|
|
|
25
57
|
if (button instanceof ToggleGalleryButton) {
|
|
58
|
+
let highlight = false;
|
|
59
|
+
let cb = button.cb;
|
|
60
|
+
|
|
26
61
|
if (
|
|
62
|
+
(button.galleryItemSource === inlineSource && inlineSource) ||
|
|
63
|
+
(inlineSource?.backingObject && button.galleryItemSource?.backingObject === inlineSource.backingObject)
|
|
64
|
+
) {
|
|
65
|
+
highlight = true;
|
|
66
|
+
cb = () => setInlineSource(undefined);
|
|
67
|
+
} else if (
|
|
27
68
|
(button.galleryItemSource === source && source) ||
|
|
28
69
|
(source?.backingObject && button.galleryItemSource?.backingObject === source.backingObject)
|
|
29
70
|
) {
|
|
@@ -31,11 +72,23 @@ function GameButtonWrapper({ button }: { button: GameButton }) {
|
|
|
31
72
|
cb = () => setSource(undefined);
|
|
32
73
|
} else if (button.galleryItemSource) {
|
|
33
74
|
const source = button.galleryItemSource;
|
|
34
|
-
cb = () => setSource(source);
|
|
75
|
+
cb = () => (galleryDisplayMode === "inline" ? setInlineSource(source) : setSource(source));
|
|
35
76
|
}
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Box sx={{ position: "relative" }}>
|
|
80
|
+
<BottomBarButton icon={button.icon} label={button.label} onClick={cb} />
|
|
81
|
+
|
|
82
|
+
<Stack direction={"row"} sx={{ fontSize: 5, zIndex: -1, position: "absolute", bottom: 4, left: 0, right: 0 }}>
|
|
83
|
+
<Box flex={1} />
|
|
84
|
+
<SimpleToggle checked={highlight} />
|
|
85
|
+
<Box flex={1} />
|
|
86
|
+
</Stack>
|
|
87
|
+
</Box>
|
|
88
|
+
);
|
|
36
89
|
}
|
|
37
90
|
|
|
38
|
-
return <BottomBarButton
|
|
91
|
+
return <BottomBarButton icon={button.icon} label={button.label} onClick={button.cb} />;
|
|
39
92
|
}
|
|
40
93
|
|
|
41
94
|
export default function PromptControls({ collapsible }: { collapsible?: boolean }) {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { Game } from "../game/Game";
|
|
3
|
+
import { ConnectionProvider } from "../hooks/useConnection";
|
|
4
|
+
import { GameProvider } from "../hooks/useGame";
|
|
5
|
+
import { PlayerProvider } from "../hooks/usePlayer";
|
|
6
|
+
import { MatchViewer } from "./MatchViewer";
|
|
7
|
+
import { Connection } from "../game/Connection";
|
|
8
|
+
import { ConnectionTransport } from "../game/ConnectionTransport";
|
|
9
|
+
import { LoadingStateProvider, LoadingStates, LoadingStatesCallback } from "../hooks/useLoadingStates";
|
|
10
|
+
|
|
11
|
+
export function ServerTrustMatchViewer({
|
|
12
|
+
playerId,
|
|
13
|
+
game,
|
|
14
|
+
transport,
|
|
15
|
+
onBack,
|
|
16
|
+
onLoadProgress,
|
|
17
|
+
}: {
|
|
18
|
+
playerId: string;
|
|
19
|
+
game: Game<any, any>;
|
|
20
|
+
transport: ConnectionTransport;
|
|
21
|
+
onBack?: () => void;
|
|
22
|
+
onLoadProgress?: LoadingStatesCallback;
|
|
23
|
+
}) {
|
|
24
|
+
const [loadingStates] = useState<LoadingStates>(new LoadingStates());
|
|
25
|
+
const [localConnection, setLocalConnection] = useState<Connection | undefined>();
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const newConnection = new Connection(transport);
|
|
29
|
+
setLocalConnection(newConnection);
|
|
30
|
+
}, [transport]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (onLoadProgress) {
|
|
34
|
+
return loadingStates.onChange(onLoadProgress);
|
|
35
|
+
}
|
|
36
|
+
}, [loadingStates, onLoadProgress]);
|
|
37
|
+
|
|
38
|
+
if (!localConnection) {
|
|
39
|
+
return null; // loading...
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<LoadingStateProvider loadingStates={loadingStates}>
|
|
44
|
+
<GameProvider game={game}>
|
|
45
|
+
<ConnectionProvider connection={localConnection}>
|
|
46
|
+
<PlayerProvider playerId={playerId}>
|
|
47
|
+
<MatchViewer onBack={onBack} />
|
|
48
|
+
</PlayerProvider>
|
|
49
|
+
</ConnectionProvider>
|
|
50
|
+
</GameProvider>
|
|
51
|
+
</LoadingStateProvider>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -13,6 +13,8 @@ import { useGameTheme } from "../hooks/useGameTheme";
|
|
|
13
13
|
import { requestSharedAnimationFrame } from "../utilities/RequestSharedAnimationFrame";
|
|
14
14
|
import PersistentCanvas from "./PersistentCanvas";
|
|
15
15
|
import { useGestureContext, ViewerGestureHandlers } from "./Panel/PanelContents";
|
|
16
|
+
import { useLoadingState } from "../hooks/useLoadingStates";
|
|
17
|
+
import { DragHandler } from "../rendering/ChitRenderInstance";
|
|
16
18
|
|
|
17
19
|
let ID_COUNTER = 1;
|
|
18
20
|
|
|
@@ -41,6 +43,7 @@ export default function Viewer({
|
|
|
41
43
|
refContainer?: React.RefObject<HTMLElement> | null;
|
|
42
44
|
enableGestures?: boolean;
|
|
43
45
|
}) {
|
|
46
|
+
const loadingState = useLoadingState();
|
|
44
47
|
const playerId = usePlayerId();
|
|
45
48
|
const [id] = useState(`Viewer${ID_COUNTER++}`);
|
|
46
49
|
const timeState = useTimeState();
|
|
@@ -50,6 +53,10 @@ export default function Viewer({
|
|
|
50
53
|
const rendererWrapper = useWebGlRenderer();
|
|
51
54
|
const theme = useGameTheme();
|
|
52
55
|
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
loadingState.setLoading(id, true);
|
|
58
|
+
}, [id, loadingState]);
|
|
59
|
+
|
|
53
60
|
const modalState = useModalState();
|
|
54
61
|
const [chitRenderInstance, setChitRenderInstance] = useState<RootChitRenderInstance | null>(null);
|
|
55
62
|
|
|
@@ -134,6 +141,8 @@ export default function Viewer({
|
|
|
134
141
|
return;
|
|
135
142
|
}
|
|
136
143
|
|
|
144
|
+
loadingState.setLoading(id, true);
|
|
145
|
+
|
|
137
146
|
const context = canvas.getContext("2d");
|
|
138
147
|
if (!context) {
|
|
139
148
|
return;
|
|
@@ -160,18 +169,17 @@ export default function Viewer({
|
|
|
160
169
|
) {
|
|
161
170
|
if (!hardPaused) {
|
|
162
171
|
// Clear canvas and render
|
|
163
|
-
rendererWrapper.render(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
context,
|
|
167
|
-
theme,
|
|
168
|
-
);
|
|
172
|
+
rendererWrapper.render(chitRenderInstance.sceneWrapper, chitRenderInstance.camera, context, theme);
|
|
173
|
+
|
|
174
|
+
loadingState.setLoading(id, false);
|
|
169
175
|
|
|
170
176
|
// Clear snapshot after first render at new size
|
|
171
177
|
const canvasEl = canvas as any;
|
|
172
178
|
if (canvasEl.clearSnapshot) {
|
|
173
179
|
canvasEl.clearSnapshot();
|
|
174
180
|
}
|
|
181
|
+
} else {
|
|
182
|
+
loadingState.setLoading(id, false);
|
|
175
183
|
}
|
|
176
184
|
|
|
177
185
|
chitRenderInstance.resetDirty();
|
|
@@ -180,6 +188,7 @@ export default function Viewer({
|
|
|
180
188
|
}
|
|
181
189
|
} else {
|
|
182
190
|
timeState.setAnimationState(id, false);
|
|
191
|
+
loadingState.setLoading(id, false);
|
|
183
192
|
}
|
|
184
193
|
} catch (e) {
|
|
185
194
|
console.error(e);
|
|
@@ -192,7 +201,18 @@ export default function Viewer({
|
|
|
192
201
|
timeState.setAnimationState(id, false);
|
|
193
202
|
cancelled = true;
|
|
194
203
|
};
|
|
195
|
-
}, [
|
|
204
|
+
}, [
|
|
205
|
+
id,
|
|
206
|
+
timeState,
|
|
207
|
+
hardPaused,
|
|
208
|
+
rendererWrapper,
|
|
209
|
+
chitRenderInstance,
|
|
210
|
+
paused,
|
|
211
|
+
actualRef,
|
|
212
|
+
myRefContainer,
|
|
213
|
+
theme,
|
|
214
|
+
loadingState,
|
|
215
|
+
]);
|
|
196
216
|
|
|
197
217
|
useEffect(() => {
|
|
198
218
|
if (chitRenderInstance) {
|
|
@@ -241,6 +261,7 @@ export default function Viewer({
|
|
|
241
261
|
let pinchEndedRecently = false;
|
|
242
262
|
let pinchScale = 1;
|
|
243
263
|
let pinchCancelled = false;
|
|
264
|
+
let dragHandler: DragHandler | undefined;
|
|
244
265
|
|
|
245
266
|
const handlers: ViewerGestureHandlers = {
|
|
246
267
|
onSingleTap: (x, y, isMouse) => {
|
|
@@ -257,18 +278,28 @@ export default function Viewer({
|
|
|
257
278
|
onLongTap: (x, y, isMouse) => {
|
|
258
279
|
chitRenderInstance.handleLongClick(x, y, isMouse ? 3 : 6, isMouse ? 1.5 : 3);
|
|
259
280
|
},
|
|
260
|
-
onPanStart: () => {
|
|
281
|
+
onPanStart: (x, y, isMouse) => {
|
|
261
282
|
if (pinchEndedRecently) {
|
|
262
283
|
cancelled = true;
|
|
263
284
|
return;
|
|
264
285
|
}
|
|
265
286
|
cancelled = false;
|
|
287
|
+
|
|
288
|
+
const draggingChit = chitRenderInstance.handleBeginDrag(x, y, isMouse ? 3 : 6, isMouse ? 1.5 : 3);
|
|
289
|
+
if (draggingChit) {
|
|
290
|
+
dragHandler = draggingChit.renderInstance!.executeDrag(x, y);
|
|
291
|
+
}
|
|
266
292
|
},
|
|
267
293
|
onPan: (dx, dy, ev) => {
|
|
268
294
|
if (cancelled) {
|
|
269
295
|
return;
|
|
270
296
|
}
|
|
271
297
|
|
|
298
|
+
if (dragHandler) {
|
|
299
|
+
dragHandler.duringDrag(dx, dy);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
272
303
|
if (panCallback) {
|
|
273
304
|
const isMouse = ev.pointerType === "mouse";
|
|
274
305
|
const neededVelocity = chitRenderInstance.cameraZoom <= 1.1 ? 0.3 : isMouse ? 7.5 : 2.5;
|
|
@@ -279,21 +310,30 @@ export default function Viewer({
|
|
|
279
310
|
return;
|
|
280
311
|
}
|
|
281
312
|
}
|
|
282
|
-
if (zoomCallback) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
313
|
+
// if (zoomCallback) {
|
|
314
|
+
// const isMouse = ev.pointerType === "mouse";
|
|
315
|
+
// const neededVelocity = chitRenderInstance.cameraZoom <= 1.1 ? 0.3 : isMouse ? 7.5 : 2.5;
|
|
316
|
+
// if (Math.abs(ev.velocityY) > neededVelocity && ev.distance > 20 && Math.abs(ev.velocityX) < 0.2) {
|
|
317
|
+
// const prev = chitRenderInstance.cameraZoom;
|
|
318
|
+
// chitRenderInstance.handleZoom(0, 0, chitRenderInstance.cameraZoom <= 1 ? 0.0001 : -20, !!zoomCallback);
|
|
319
|
+
// zoomCallback(chitRenderInstance.cameraZoom, prev);
|
|
320
|
+
// setTimeout(() => chitRenderInstance.handleZoom(0, 0, 0, false), 100);
|
|
321
|
+
// cancelled = true;
|
|
322
|
+
// return;
|
|
323
|
+
// }
|
|
324
|
+
// }
|
|
294
325
|
|
|
295
326
|
chitRenderInstance.handlePan(dx, dy);
|
|
296
327
|
},
|
|
328
|
+
onPanEnd: () => {
|
|
329
|
+
if (cancelled) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (dragHandler) {
|
|
333
|
+
dragHandler.finishDrag();
|
|
334
|
+
dragHandler = undefined;
|
|
335
|
+
}
|
|
336
|
+
},
|
|
297
337
|
onPinchStart: () => {
|
|
298
338
|
pinchScale = chitRenderInstance.cameraZoom;
|
|
299
339
|
pinchCancelled = false;
|
package/src/library/game/Chit.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ChitRenderInstance } from "../rendering/ChitRenderInstance";
|
|
2
2
|
import { ChitRenderSpec } from "../rendering/ChitRenderSpec";
|
|
3
|
-
import { Turn } from "./Turn";
|
|
3
|
+
import type { Turn } from "./Turn";
|
|
4
4
|
import { FixChildOutlets, NonEditable, Ordered } from "../utilities/Annotations";
|
|
5
5
|
import { ObjectWithProps } from "../utilities/ObjectWithProps";
|
|
6
|
-
import { ChitPick } from "./Pick";
|
|
6
|
+
import { ChitPick, DragPick, DragTarget } from "./Pick";
|
|
7
7
|
import { Vector2 } from "three";
|
|
8
8
|
import { OrderedOutlet } from "./OrderedOutlet";
|
|
9
9
|
import { SparkChit } from "./SparkChit";
|
|
@@ -14,7 +14,18 @@ import { ImageSpec } from "../utilities/CanvasStack/CanvasOperations";
|
|
|
14
14
|
|
|
15
15
|
export const ORDERED_CHILDREN = "orderedChildren";
|
|
16
16
|
|
|
17
|
+
const EXTRA_SERIALIZATION_PROPS_ARRAY = [
|
|
18
|
+
"id",
|
|
19
|
+
"_parent",
|
|
20
|
+
"_parentOutlet",
|
|
21
|
+
"_parentOutletIndex",
|
|
22
|
+
"_parentFallback",
|
|
23
|
+
"__hiddenProps",
|
|
24
|
+
];
|
|
25
|
+
const EXTRA_SERIALIZATION_PROPS_SET = new Set(EXTRA_SERIALIZATION_PROPS_ARRAY);
|
|
26
|
+
|
|
17
27
|
export type ChitClick = () => void;
|
|
28
|
+
export type ChitDrag = (dropOn: Chit) => void;
|
|
18
29
|
|
|
19
30
|
export type HiddenPropertySerializationRule = {
|
|
20
31
|
fields: "all" | string[];
|
|
@@ -186,11 +197,32 @@ export class Chit extends ObjectWithProps {
|
|
|
186
197
|
this.notifyChange("onClick");
|
|
187
198
|
}
|
|
188
199
|
|
|
200
|
+
@NonEditable
|
|
201
|
+
private _onDrag?: ChitDrag;
|
|
202
|
+
|
|
203
|
+
/** @internal */
|
|
204
|
+
@NonEditable
|
|
205
|
+
public dropTargets?: Chit[];
|
|
206
|
+
|
|
207
|
+
@NonEditable
|
|
208
|
+
public isDropTarget = false;
|
|
209
|
+
|
|
210
|
+
/** @internal */
|
|
211
|
+
public set onDrag(newValue: undefined | ChitDrag) {
|
|
212
|
+
this._onDrag = newValue;
|
|
213
|
+
this.notifyChange("onClick");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** @internal */
|
|
217
|
+
public get onDrag(): undefined | ChitDrag {
|
|
218
|
+
return this._onDrag;
|
|
219
|
+
}
|
|
220
|
+
|
|
189
221
|
/**
|
|
190
222
|
* Returns true if the chit is currently clickable
|
|
191
223
|
*/
|
|
192
224
|
public get isClickable(): boolean {
|
|
193
|
-
return !!this.onClick;
|
|
225
|
+
return !!this.onClick || !!this.onDrag;
|
|
194
226
|
}
|
|
195
227
|
|
|
196
228
|
@NonEditable private _lockedBy?: Turn<any, any, any>;
|
|
@@ -378,7 +410,7 @@ export class Chit extends ObjectWithProps {
|
|
|
378
410
|
}
|
|
379
411
|
|
|
380
412
|
private get serializationProps() {
|
|
381
|
-
return [...this.props,
|
|
413
|
+
return [...this.props, ...EXTRA_SERIALIZATION_PROPS_ARRAY];
|
|
382
414
|
}
|
|
383
415
|
|
|
384
416
|
/** @internal */
|
|
@@ -437,9 +469,13 @@ export class Chit extends ObjectWithProps {
|
|
|
437
469
|
}
|
|
438
470
|
};
|
|
439
471
|
|
|
440
|
-
|
|
441
|
-
|
|
472
|
+
// expanded props will introduce undefined for things that used to be there but aren't
|
|
473
|
+
this.expandedPropsFromJson(j).forEach((key) => {
|
|
474
|
+
if (EXTRA_SERIALIZATION_PROPS_SET.has(key)) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
442
477
|
|
|
478
|
+
const value = (j as any)[key];
|
|
443
479
|
if (value?.___orderedOutlet) {
|
|
444
480
|
(this as any)[key].deserialize(value.___orderedOutlet.map(inflateValue));
|
|
445
481
|
} else {
|
|
@@ -566,6 +602,17 @@ export class Chit extends ObjectWithProps {
|
|
|
566
602
|
return result;
|
|
567
603
|
}
|
|
568
604
|
|
|
605
|
+
public static dragPick<T extends Chit>(
|
|
606
|
+
chit: T | (T | undefined | null | false)[] | OrderedOutlet<T>,
|
|
607
|
+
targets: DragTarget<any, T>[],
|
|
608
|
+
) {
|
|
609
|
+
const result = new DragPick<T>();
|
|
610
|
+
result.chits =
|
|
611
|
+
chit instanceof OrderedOutlet ? chit.copy() : Array.isArray(chit) ? (chit.filter((c) => c) as T[]) : [chit];
|
|
612
|
+
result.dropTargets = targets;
|
|
613
|
+
return result;
|
|
614
|
+
}
|
|
615
|
+
|
|
569
616
|
/** @internal */
|
|
570
617
|
public static deletedIfSerialized(): string {
|
|
571
618
|
return JSON.stringify({
|
|
@@ -33,10 +33,14 @@ export class ClientTimeState {
|
|
|
33
33
|
public goLive(clock: number) {
|
|
34
34
|
this.live.value = true;
|
|
35
35
|
this.targetClock.value = clock;
|
|
36
|
+
this.killAnimations();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public killAnimations() {
|
|
36
40
|
clearTimeout(this._animationOverrideTimeout);
|
|
37
41
|
this.animationSpeedOverrideMultiplier.value = 0.075;
|
|
38
42
|
this._animationOverrideTimeout = setTimeout(() => {
|
|
39
43
|
this.animationSpeedOverrideMultiplier.value = undefined;
|
|
40
|
-
},
|
|
44
|
+
}, 400);
|
|
41
45
|
}
|
|
42
46
|
}
|
|
@@ -5,6 +5,8 @@ import { Chit } from "./Chit";
|
|
|
5
5
|
export class GalleryItemChitChildrenSource implements GalleryItemSource {
|
|
6
6
|
private unSub: () => void;
|
|
7
7
|
|
|
8
|
+
public inlineGallerySize?: number | undefined = undefined;
|
|
9
|
+
|
|
8
10
|
constructor(public backingObject: Chit) {
|
|
9
11
|
this.unSub = backingObject.onChange("deserialized", () => {
|
|
10
12
|
this.cbs.forEach((cb) => cb());
|
|
@@ -3,6 +3,8 @@ import { GalleryItem, GalleryItemSource } from "../components/GalleryViewer";
|
|
|
3
3
|
export class GalleryItemRawSource implements GalleryItemSource {
|
|
4
4
|
constructor(private galleryItems: GalleryItem[]) {}
|
|
5
5
|
|
|
6
|
+
public inlineGallerySize?: number | undefined = undefined;
|
|
7
|
+
|
|
6
8
|
get items() {
|
|
7
9
|
return this.galleryItems;
|
|
8
10
|
}
|
package/src/library/game/Game.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { PlayerChit } from "./PlayerChit";
|
|
|
7
7
|
import { RootChit } from "./RootChit";
|
|
8
8
|
import { ChitRenderSpec } from "../rendering/ChitRenderSpec";
|
|
9
9
|
import { TokenDefinition } from "../components/TokenizedMessage";
|
|
10
|
+
import { GameMetaData } from "./GameMetaData";
|
|
10
11
|
|
|
11
12
|
export interface IChitLibrary<P extends PlayerChit, R extends RootChit<P>> {
|
|
12
13
|
[key: string]: new () => Chit;
|
|
@@ -39,10 +40,11 @@ export type GameResult<P extends PlayerChit> = {
|
|
|
39
40
|
*/
|
|
40
41
|
export interface Game<P extends PlayerChit, R extends RootChit<P>> {
|
|
41
42
|
get theme(): GameTheme;
|
|
42
|
-
get name(): string;
|
|
43
43
|
get chitLibrary(): IChitLibrary<P, R>;
|
|
44
44
|
get canvasLibrary(): ICanvasLibrary;
|
|
45
45
|
get buttonLibrary(): IButtonLibrary;
|
|
46
|
+
get metadata(): GameMetaData;
|
|
47
|
+
|
|
46
48
|
tokenMap?: { [key: string]: TokenDefinition };
|
|
47
49
|
|
|
48
50
|
run(setup: Turn<GameResult<P>, P, R>, rootChit: R): Promise<GameResult<P>>;
|
|
@@ -52,6 +52,8 @@ export class GameButton {
|
|
|
52
52
|
export class ToggleGalleryButton extends GameButton {
|
|
53
53
|
autoShow = true;
|
|
54
54
|
|
|
55
|
+
toggleSmallSize?: number = 125;
|
|
56
|
+
|
|
55
57
|
/** @internal */
|
|
56
58
|
parentChit?: Chit;
|
|
57
59
|
|
|
@@ -86,6 +88,7 @@ export class ToggleGalleryButton extends GameButton {
|
|
|
86
88
|
} else {
|
|
87
89
|
this.galleryItemSource = new GalleryItemRawSource(chitsToGalleryItems(chitPick.chits));
|
|
88
90
|
}
|
|
91
|
+
this.galleryItemSource.inlineGallerySize = this.toggleSmallSize;
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
|
|
@@ -16,6 +16,12 @@ export type Stage<T> = {
|
|
|
16
16
|
export class GameDeckChit<T extends Chit> extends Chit {
|
|
17
17
|
@NonEditable type = "deck";
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* If true, the contents of chits are shuffled as they are drawn. This should only be used if
|
|
21
|
+
* all chits are of the same class type
|
|
22
|
+
*/
|
|
23
|
+
public protectSecrets = true;
|
|
24
|
+
|
|
19
25
|
public chitGenerator?: () => T;
|
|
20
26
|
public stages: Stage<T>[] = [];
|
|
21
27
|
|
|
@@ -33,11 +39,32 @@ export class GameDeckChit<T extends Chit> extends Chit {
|
|
|
33
39
|
if (stage) {
|
|
34
40
|
switch (stage.type) {
|
|
35
41
|
case "draw": {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
if (this.protectSecrets) {
|
|
43
|
+
const rngs = await this.currentTurn.takeRng(2, message);
|
|
44
|
+
const resultIndex = Math.floor(stage.chits.length * rngs());
|
|
45
|
+
const swapIndex = Math.floor(stage.chits.length * rngs());
|
|
46
|
+
const selected = stage.chits[resultIndex];
|
|
47
|
+
const swap = stage.chits[swapIndex];
|
|
48
|
+
|
|
49
|
+
if (selected.id) {
|
|
50
|
+
const selectedSerialized = selected.serialize();
|
|
51
|
+
const swapSerialized = swap.serialize();
|
|
52
|
+
|
|
53
|
+
selected.deserialize(swapSerialized, this.currentTurn.findChit);
|
|
54
|
+
swap.deserialize(selectedSerialized, this.currentTurn.findChit);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
stage.chits.splice(resultIndex, 1);
|
|
58
|
+
selected.setParent();
|
|
59
|
+
return selected;
|
|
60
|
+
} else {
|
|
61
|
+
const rng = await this.currentTurn.rng();
|
|
62
|
+
const resultIndex = Math.floor(stage.chits.length * rng);
|
|
63
|
+
const selected = stage.chits[resultIndex];
|
|
64
|
+
stage.chits.splice(resultIndex, 1);
|
|
65
|
+
selected.setParent();
|
|
66
|
+
return selected;
|
|
67
|
+
}
|
|
41
68
|
}
|
|
42
69
|
case "discard": {
|
|
43
70
|
stage.type = "draw";
|
|
@@ -51,6 +78,10 @@ export class GameDeckChit<T extends Chit> extends Chit {
|
|
|
51
78
|
}
|
|
52
79
|
}
|
|
53
80
|
|
|
81
|
+
public shuffle() {
|
|
82
|
+
this.stages = [{ type: "draw", chits: this.stages.map((stage) => stage.chits).flat() }];
|
|
83
|
+
}
|
|
84
|
+
|
|
54
85
|
private isEmpty(stage?: Stage<T>) {
|
|
55
86
|
return stage?.chits.length === 0;
|
|
56
87
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type GameMetaData = {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
licenseInformation?: string;
|
|
5
|
+
implementationNotes?: string;
|
|
6
|
+
publisher?: string;
|
|
7
|
+
designer?: string;
|
|
8
|
+
artist?: string;
|
|
9
|
+
|
|
10
|
+
tutorialVideoUrl?: string;
|
|
11
|
+
rulesPdfUrl?: string;
|
|
12
|
+
purchaseUrl?: string;
|
|
13
|
+
publisherUrl?: string;
|
|
14
|
+
repositoryUrl?: string;
|
|
15
|
+
bugReportUrl?: string;
|
|
16
|
+
|
|
17
|
+
boxArt: string;
|
|
18
|
+
screenshot: string;
|
|
19
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Color from "color";
|
|
2
2
|
|
|
3
|
+
export const DEFAULT_FONT_FAMILY = "Quicksand, sans-serif";
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Controls color scheme and layout options for all things in a pretty-chitty game. Much of
|
|
5
7
|
* this can be overridden per chit, but some cannot. For example, the background color of the game
|
|
@@ -11,6 +13,17 @@ import Color from "color";
|
|
|
11
13
|
* @group Core Game Elements
|
|
12
14
|
*/
|
|
13
15
|
export class GameTheme {
|
|
16
|
+
public static defaultFontFamily = DEFAULT_FONT_FAMILY;
|
|
17
|
+
|
|
18
|
+
private _fontFamily = DEFAULT_FONT_FAMILY;
|
|
19
|
+
public get fontFamily() {
|
|
20
|
+
return this._fontFamily;
|
|
21
|
+
}
|
|
22
|
+
public set fontFamily(value: string) {
|
|
23
|
+
this._fontFamily = value;
|
|
24
|
+
GameTheme.defaultFontFamily = value;
|
|
25
|
+
}
|
|
26
|
+
|
|
14
27
|
public backgroundColor = "#0f0119";
|
|
15
28
|
|
|
16
29
|
public spacing = 8;
|
|
@@ -28,13 +41,14 @@ export class GameTheme {
|
|
|
28
41
|
public actionBarContextColor = "#3a1957";
|
|
29
42
|
public actionBarContextAnimationDuration = 0.3;
|
|
30
43
|
public actionBarContextShadow = "rgba(0,0,0,0.2)";
|
|
44
|
+
public actionBarToggleSelectedColor = "rgba(255,255,255,0.6)";
|
|
31
45
|
|
|
32
46
|
public barTextColor = "rgba(255,255,255,0.6)";
|
|
33
47
|
public barTextHighlightColor = "rgba(255,255,255,0.6)";
|
|
34
48
|
public barBreak = "rgba(255,255,255,0.3)";
|
|
35
49
|
public barActiveTextColor = "rgba(255,255,255,0.9)";
|
|
36
50
|
public barHighlightTextColor = "#66d5c1";
|
|
37
|
-
public barDisabledTextColor = "rgba(255,255,255,0.
|
|
51
|
+
public barDisabledTextColor = "rgba(255,255,255,0.3)";
|
|
38
52
|
public panelSlotColor = "#858b99";
|
|
39
53
|
public panelSlotSelectedColor = "#66d5c1";
|
|
40
54
|
public fullResetColor = "#66d5c1";
|
|
@@ -69,6 +83,8 @@ export class GameTheme {
|
|
|
69
83
|
public galleryItemWidth = 150;
|
|
70
84
|
public galleryItemHeight: number | undefined;
|
|
71
85
|
public galleryItemSpacing = 20;
|
|
86
|
+
public galleryItemMinimumWidth = 75;
|
|
87
|
+
public galleryItemMinimumHeight = 50;
|
|
72
88
|
|
|
73
89
|
public gallerySummaryBackgroundColor = "#000000";
|
|
74
90
|
public gallerySummaryBackgroundOpacity = 0.7;
|
|
@@ -79,6 +95,9 @@ export class GameTheme {
|
|
|
79
95
|
public actionLogTextColor = "#ffffff";
|
|
80
96
|
public actionBarWidth = 600;
|
|
81
97
|
public actionBarLinesToShow = 2;
|
|
98
|
+
public inlineGalleryBackgroundColor = "rgba(255,255,255,0.1)";
|
|
99
|
+
public inlineGalleryButtonBackgroundColor = "#000000";
|
|
100
|
+
public inlineGalleryButtonForegroundColor = "rgba(255,255,255,0.5)";
|
|
82
101
|
|
|
83
102
|
/** Reference to .png or .jpg file to show as box art in advertising the game */
|
|
84
103
|
public boxArt = "";
|
|
@@ -96,6 +115,9 @@ export class GameTheme {
|
|
|
96
115
|
result.barHighlightTextColor = highlight;
|
|
97
116
|
result.barTopDropdownColor = Color(primaryColor).mix(Color(highlight), 0.1).alpha(0.9).hexa();
|
|
98
117
|
result.barTextHighlightColor = highlight;
|
|
118
|
+
result.actionBarToggleSelectedColor = primaryColor;
|
|
119
|
+
|
|
120
|
+
result.inlineGalleryButtonBackgroundColor = primaryColor;
|
|
99
121
|
|
|
100
122
|
result.endGameBackgroundColor = result.barTopDropdownColor;
|
|
101
123
|
|
|
@@ -106,10 +128,6 @@ export class GameTheme {
|
|
|
106
128
|
result.barTopLineColor = Color(textColor).alpha(0.1).hexa();
|
|
107
129
|
result.endGameTextColor = Color(textColor).alpha(1).hexa();
|
|
108
130
|
|
|
109
|
-
result.barDisabledTextColor = Color(result.barColor).isLight()
|
|
110
|
-
? Color(result.barColor).darken(0.75).hexa()
|
|
111
|
-
: Color(result.barColor).lighten(0.75).hexa();
|
|
112
|
-
|
|
113
131
|
result.actionLogTextColor = result.barActiveTextColor;
|
|
114
132
|
result.actionLogDialogBackgroundColor = result.backgroundColor;
|
|
115
133
|
|