@pretty-chitty/core 2.3.6 → 2.3.7

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.
Files changed (142) hide show
  1. package/dist/1ea77c9e193d437b9bfa.woff +0 -0
  2. package/dist/2282b9ff81c2cd7cf5b4.mp3 +0 -0
  3. package/dist/22a445dd65cce94defdd.woff2 +0 -0
  4. package/dist/2b94f846c05846d73536.mp3 +0 -0
  5. package/dist/32d6296b80e676d66bda.woff +0 -0
  6. package/dist/36e7e033bfef7b32bf3c.mp3 +0 -0
  7. package/dist/37f3b2ddcbe588b2aaa5.jpg +0 -0
  8. package/dist/3f0fb9058a03e14ad2fa.jpg +0 -0
  9. package/dist/412050b824afb24fef88.mp3 +0 -0
  10. package/dist/468cf705a21091e5f755.mp3 +0 -0
  11. package/dist/47a823ae095f5f4cfd82.woff +0 -0
  12. package/dist/5062c95fb3c68af2ee2e.woff2 +0 -0
  13. package/dist/5aecd40f51b84ffb6efa.woff2 +0 -0
  14. package/dist/5d184fc5808150d51726.mp3 +0 -0
  15. package/dist/60b937eec087d648c831.woff2 +0 -0
  16. package/dist/63da6d06ce0ff84b8b2c.mp3 +0 -0
  17. package/dist/63f3d4f28784375801ac.woff +0 -0
  18. package/dist/669804475e1d5e52a4f5.mp3 +0 -0
  19. package/dist/6a6d042ba2a9290aba9c.woff2 +0 -0
  20. package/dist/72e60d1c7f7c603f31d6.woff +0 -0
  21. package/dist/788c3dfe27f9734edff5.mp3 +0 -0
  22. package/dist/7e339dfbea59fe54f2e3.png +0 -0
  23. package/dist/7ecd698217d211cad841.mp3 +0 -0
  24. package/dist/8c8f3dcefaec6a40d787.mp3 +0 -0
  25. package/dist/8d29c92c7f9ca79d8a5c.mp3 +0 -0
  26. package/dist/8ea5f16c95238d2ff902.mp3 +0 -0
  27. package/dist/97e19a7d82ab67080019.mp3 +0 -0
  28. package/dist/98373f88bbc3b8237b09.mp3 +0 -0
  29. package/dist/98c71bee993adc81d5be.mp3 +0 -0
  30. package/dist/a09db3cc936e581f320a.mp3 +0 -0
  31. package/dist/a51c64560480e6fdae0d.mp3 +0 -0
  32. package/dist/ad2392bc6cdf9bb1b5fd.mp3 +0 -0
  33. package/dist/b3708bfbeff0d340bdef.mp3 +0 -0
  34. package/dist/b81893c113e684d9eec4.woff +0 -0
  35. package/dist/bc6bc3d7802469910f83.mp3 +0 -0
  36. package/dist/bde37bf538e175149c3b.mp3 +0 -0
  37. package/dist/d6b5a560b17d31cd3c7c.mp3 +0 -0
  38. package/dist/dd3231a4b15c4f8f2b94.mp3 +0 -0
  39. package/dist/f63358bf5b9e4f8d7f79.mp3 +0 -0
  40. package/dist/fc02be176de567378fa4.woff2 +0 -0
  41. package/dist/fe1535c25dc5d879c085.mp3 +0 -0
  42. package/dist/index.html +12 -0
  43. package/dist/main.034dfcc6b83fdd218994.hot-update.js +265 -0
  44. package/dist/main.034dfcc6b83fdd218994.hot-update.js.map +1 -0
  45. package/dist/main.034dfcc6b83fdd218994.hot-update.json +1 -0
  46. package/dist/main.0c0a98b3b3e1e004beb2.hot-update.js +265 -0
  47. package/dist/main.0c0a98b3b3e1e004beb2.hot-update.js.map +1 -0
  48. package/dist/main.0c0a98b3b3e1e004beb2.hot-update.json +1 -0
  49. package/dist/main.13daf8cac0f0a3231f6a.hot-update.js +190 -0
  50. package/dist/main.13daf8cac0f0a3231f6a.hot-update.js.map +1 -0
  51. package/dist/main.13daf8cac0f0a3231f6a.hot-update.json +1 -0
  52. package/dist/main.14e055541f09be93a122.hot-update.js +321 -0
  53. package/dist/main.14e055541f09be93a122.hot-update.js.map +1 -0
  54. package/dist/main.14e055541f09be93a122.hot-update.json +1 -0
  55. package/dist/main.26499c88c63113e7a3f8.hot-update.js +190 -0
  56. package/dist/main.26499c88c63113e7a3f8.hot-update.js.map +1 -0
  57. package/dist/main.26499c88c63113e7a3f8.hot-update.json +1 -0
  58. package/dist/main.2c3a3f1928ea25c4b79a.hot-update.js +11 -0
  59. package/dist/main.2c3a3f1928ea25c4b79a.hot-update.js.map +1 -0
  60. package/dist/main.2c3a3f1928ea25c4b79a.hot-update.json +1 -0
  61. package/dist/main.324b63996b3b36daf5af.hot-update.js +603 -0
  62. package/dist/main.324b63996b3b36daf5af.hot-update.js.map +1 -0
  63. package/dist/main.324b63996b3b36daf5af.hot-update.json +1 -0
  64. package/dist/main.4b0f7799388b5de9908d.hot-update.js +265 -0
  65. package/dist/main.4b0f7799388b5de9908d.hot-update.js.map +1 -0
  66. package/dist/main.4b0f7799388b5de9908d.hot-update.json +1 -0
  67. package/dist/main.6424291443afea7eb7ac.hot-update.js +187 -0
  68. package/dist/main.6424291443afea7eb7ac.hot-update.js.map +1 -0
  69. package/dist/main.6424291443afea7eb7ac.hot-update.json +1 -0
  70. package/dist/main.69127e32a0c76b421f15.hot-update.js +392 -0
  71. package/dist/main.69127e32a0c76b421f15.hot-update.js.map +1 -0
  72. package/dist/main.69127e32a0c76b421f15.hot-update.json +1 -0
  73. package/dist/main.755d91e1a6c7e6bd6702.hot-update.js +265 -0
  74. package/dist/main.755d91e1a6c7e6bd6702.hot-update.js.map +1 -0
  75. package/dist/main.755d91e1a6c7e6bd6702.hot-update.json +1 -0
  76. package/dist/main.75a666c9d30baa58c5ec.hot-update.js +265 -0
  77. package/dist/main.75a666c9d30baa58c5ec.hot-update.js.map +1 -0
  78. package/dist/main.75a666c9d30baa58c5ec.hot-update.json +1 -0
  79. package/dist/main.828f4c348446c6c3640d.hot-update.js +11 -0
  80. package/dist/main.828f4c348446c6c3640d.hot-update.js.map +1 -0
  81. package/dist/main.828f4c348446c6c3640d.hot-update.json +1 -0
  82. package/dist/main.8459249b2915a8823bd3.hot-update.js +321 -0
  83. package/dist/main.8459249b2915a8823bd3.hot-update.js.map +1 -0
  84. package/dist/main.8459249b2915a8823bd3.hot-update.json +1 -0
  85. package/dist/main.87f757c2602cac7001cb.hot-update.js +382 -0
  86. package/dist/main.87f757c2602cac7001cb.hot-update.js.map +1 -0
  87. package/dist/main.87f757c2602cac7001cb.hot-update.json +1 -0
  88. package/dist/main.8aa248086ab27072c348.hot-update.js +265 -0
  89. package/dist/main.8aa248086ab27072c348.hot-update.js.map +1 -0
  90. package/dist/main.8aa248086ab27072c348.hot-update.json +1 -0
  91. package/dist/main.8ce461bf769f3943b7ed.hot-update.js +265 -0
  92. package/dist/main.8ce461bf769f3943b7ed.hot-update.js.map +1 -0
  93. package/dist/main.8ce461bf769f3943b7ed.hot-update.json +1 -0
  94. package/dist/main.9fdbde5beb7c70940250.hot-update.js +392 -0
  95. package/dist/main.9fdbde5beb7c70940250.hot-update.js.map +1 -0
  96. package/dist/main.9fdbde5beb7c70940250.hot-update.json +1 -0
  97. package/dist/main.af59faaae348c919e033.hot-update.js +11 -0
  98. package/dist/main.af59faaae348c919e033.hot-update.js.map +1 -0
  99. package/dist/main.af59faaae348c919e033.hot-update.json +1 -0
  100. package/dist/main.b11900976593b0e609ee.hot-update.js +187 -0
  101. package/dist/main.b11900976593b0e609ee.hot-update.js.map +1 -0
  102. package/dist/main.b11900976593b0e609ee.hot-update.json +1 -0
  103. package/dist/main.b57518d376449c846971.hot-update.js +265 -0
  104. package/dist/main.b57518d376449c846971.hot-update.js.map +1 -0
  105. package/dist/main.b57518d376449c846971.hot-update.json +1 -0
  106. package/dist/main.b5fa8b91f66c4a67740b.hot-update.js +265 -0
  107. package/dist/main.b5fa8b91f66c4a67740b.hot-update.js.map +1 -0
  108. package/dist/main.b5fa8b91f66c4a67740b.hot-update.json +1 -0
  109. package/dist/main.bdb9e6ab1d13cf4250e8.hot-update.js +265 -0
  110. package/dist/main.bdb9e6ab1d13cf4250e8.hot-update.js.map +1 -0
  111. package/dist/main.bdb9e6ab1d13cf4250e8.hot-update.json +1 -0
  112. package/dist/main.c9b051fce9f983306d51.hot-update.js +265 -0
  113. package/dist/main.c9b051fce9f983306d51.hot-update.js.map +1 -0
  114. package/dist/main.c9b051fce9f983306d51.hot-update.json +1 -0
  115. package/dist/main.d03d8e0bfcbd86932c58.hot-update.js +638 -0
  116. package/dist/main.d03d8e0bfcbd86932c58.hot-update.js.map +1 -0
  117. package/dist/main.d03d8e0bfcbd86932c58.hot-update.json +1 -0
  118. package/dist/main.d3b74a9a35325f35373d.hot-update.js +265 -0
  119. package/dist/main.d3b74a9a35325f35373d.hot-update.js.map +1 -0
  120. package/dist/main.d3b74a9a35325f35373d.hot-update.json +1 -0
  121. package/dist/main.d61b231278a9c69df2f8.hot-update.js +265 -0
  122. package/dist/main.d61b231278a9c69df2f8.hot-update.js.map +1 -0
  123. package/dist/main.d61b231278a9c69df2f8.hot-update.json +1 -0
  124. package/dist/pretty-chitty.js +243813 -0
  125. package/dist/pretty-chitty.js.map +1 -0
  126. package/package.json +1 -1
  127. package/src/library/components/ActionLogDisplay.tsx +1 -1
  128. package/src/library/components/ActionLogSidebar.tsx +1 -1
  129. package/src/library/components/BottomBar.tsx +2 -0
  130. package/src/library/components/BottomBarButton.tsx +3 -3
  131. package/src/library/components/MatchViewer.tsx +23 -9
  132. package/src/library/components/Panel/MultiPanel.tsx +7 -6
  133. package/src/library/components/Panel/PanelContents.tsx +4 -2
  134. package/src/library/components/Panel/SinglePanel.tsx +7 -6
  135. package/src/library/components/SettingsDisplay.tsx +152 -90
  136. package/src/library/components/TopBar.tsx +2 -0
  137. package/src/library/components/TopBarPlayers.tsx +4 -2
  138. package/src/library/game/DisplaySettings.test.ts +80 -0
  139. package/src/library/game/DisplaySettings.ts +153 -0
  140. package/src/library/game/GameTheme.ts +10 -0
  141. package/src/library/hooks/useDisplaySettings.tsx +58 -0
  142. package/src/library/hooks/usePanelScale.tsx +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pretty-chitty/core",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "description": "A TypeScript framework for building high-quality async or realtime 3D strategy board games",
6
6
  "author": "Pretty Chitty, LLC",
@@ -166,7 +166,7 @@ export function ActionLogDisplay({ toggleSidebarLog }: { toggleSidebarLog: boole
166
166
  p: 1,
167
167
  lineHeight: 1,
168
168
  textAlign: "center",
169
- minHeight: 14 * theme.actionBarLinesToShow * 1.1 + PADDING_SIZE * 2, // 8px for padding?
169
+ minHeight: 14 * theme.fontScalar * theme.actionBarLinesToShow * 1.1 + PADDING_SIZE * 2, // 8px for padding?
170
170
  color: theme.actionLogTextColor,
171
171
  maxWidth: layoutSize !== "mobile" ? `${theme.actionBarWidth - 40}px` : undefined,
172
172
  display: "flex",
@@ -7,7 +7,7 @@ export function ActionLogSidebar() {
7
7
  const theme = useGameTheme();
8
8
  return (
9
9
  <Box
10
- sx={{ position: "relative", height: `100%`, width: "350px", background: theme.actionLogDialogBackgroundColor }}
10
+ sx={{ position: "relative", height: `100%`, width: `${theme.actionLogSidebarWidth}px`, background: theme.actionLogDialogBackgroundColor }}
11
11
  >
12
12
  <Box sx={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }}>
13
13
  <ActionLogHistory visible />
@@ -14,6 +14,8 @@ function BaseBottomBar({ children }: { children: ReactNode | ReactNode[] }) {
14
14
  position: "relative",
15
15
  background: `${theme.barColor} linear-gradient(${theme.barGradientAngle}deg, rgba(255,255,255,${theme.barGradientPercent}) 0%, rgba(0,0,0,${theme.barGradientPercent}) 100%)`,
16
16
  height: theme.bottomBarHeight,
17
+ // A fixed-height bar in the viewer's flex column: never squeezed when the table needs the room
18
+ flexShrink: 0,
17
19
  }}
18
20
  >
19
21
  {children}
@@ -179,9 +179,9 @@ export default function BottomBarButton({
179
179
  <Box
180
180
  sx={{
181
181
  color: iconColor,
182
- fontSize: 30,
183
- lineHeight: "30px",
184
- height: "30px",
182
+ fontSize: theme.bottomBarIconSize,
183
+ lineHeight: `${theme.bottomBarIconSize}px`,
184
+ height: `${theme.bottomBarIconSize}px`,
185
185
  textAlign: "center",
186
186
  }}
187
187
  >
@@ -7,7 +7,7 @@ import { GameThemeProvider, useGameTheme } from "../hooks/useGameTheme";
7
7
  import TopBar from "./TopBar";
8
8
  import { useEventChannelState } from "../hooks/useEventChannelState";
9
9
  import { MatchEndDisplay } from "./MatchEndDisplay";
10
- import { PanelScaleProvider } from "../hooks/usePanelScale";
10
+ import { DisplaySectionTheme, DisplaySettingsProvider } from "../hooks/useDisplaySettings";
11
11
  import { ModalProvider } from "../hooks/useModalState";
12
12
  import { FullScreenGalleryDisplay } from "./FullScreenGalleryDisplay";
13
13
  import { ActionLogDisplay } from "./ActionLogDisplay";
@@ -75,7 +75,9 @@ function InnerMatchViewer({ onBack }: { onBack?: () => void }) {
75
75
  }}
76
76
  >
77
77
  <Stack flex={1} sx={{ maxWidth: "100%" }}>
78
- <TopBar onBack={onBack} />
78
+ <DisplaySectionTheme section="topBar">
79
+ <TopBar onBack={onBack} />
80
+ </DisplaySectionTheme>
79
81
  <Stack
80
82
  direction={"column"}
81
83
  flex={1}
@@ -88,11 +90,15 @@ function InnerMatchViewer({ onBack }: { onBack?: () => void }) {
88
90
  <MatchEndDisplay />
89
91
  <FullScreenGalleryDisplay />
90
92
  <SettingsDisplay />
91
- <ActionLogHistoryDisplay />
93
+ <DisplaySectionTheme section="actionLog">
94
+ <ActionLogHistoryDisplay />
95
+ </DisplaySectionTheme>
92
96
 
93
97
  <Stack direction={"column"} flex={1}>
94
98
  {!errorMessage && rootChit && (
95
- <PanelContents rootChit={rootChit} scaleWidth={width} scaleHeight={height} />
99
+ <DisplaySectionTheme section="panelPadding">
100
+ <PanelContents rootChit={rootChit} scaleWidth={width} scaleHeight={height} />
101
+ </DisplaySectionTheme>
96
102
  )}
97
103
 
98
104
  <InlineGalleryDisplay />
@@ -100,12 +106,20 @@ function InnerMatchViewer({ onBack }: { onBack?: () => void }) {
100
106
  {errorMessage}
101
107
  </Box>
102
108
 
103
- <ActionLogDisplay toggleSidebarLog={largeEnoughToShowLogSidebar} />
109
+ <DisplaySectionTheme section="actionLog">
110
+ <ActionLogDisplay toggleSidebarLog={largeEnoughToShowLogSidebar} />
111
+ </DisplaySectionTheme>
104
112
  </Stack>
105
- <BottomBar />
113
+ <DisplaySectionTheme section="bottomBar">
114
+ <BottomBar />
115
+ </DisplaySectionTheme>
106
116
  </Stack>
107
117
 
108
- {largeEnoughToShowLogSidebar && showLog && <ActionLogSidebar />}
118
+ {largeEnoughToShowLogSidebar && showLog && (
119
+ <DisplaySectionTheme section="actionLog">
120
+ <ActionLogSidebar />
121
+ </DisplaySectionTheme>
122
+ )}
109
123
 
110
124
  <TutorialOverlay />
111
125
  </Stack>
@@ -122,7 +136,7 @@ export function MatchViewer({ onBack, skipReplay = false }: { onBack?: () => voi
122
136
  const muiTheme = useMemo(() => createMuiTheme(game.theme), [game.theme]);
123
137
  return (
124
138
  <TimeControllerProvider skipReplay={skipReplay}>
125
- <PanelScaleProvider>
139
+ <DisplaySettingsProvider>
126
140
  <ModalProvider modalState={modalState}>
127
141
  <GameThemeProvider theme={game.theme}>
128
142
  <ThemeProvider theme={muiTheme}>
@@ -134,7 +148,7 @@ export function MatchViewer({ onBack, skipReplay = false }: { onBack?: () => voi
134
148
  </ThemeProvider>
135
149
  </GameThemeProvider>
136
150
  </ModalProvider>
137
- </PanelScaleProvider>
151
+ </DisplaySettingsProvider>
138
152
  </TimeControllerProvider>
139
153
  );
140
154
  }
@@ -44,6 +44,7 @@ export function MultiPanel({
44
44
  setFocusedPanel: (chit: Chit | undefined) => void;
45
45
  }) {
46
46
  const theme = useGameTheme();
47
+ const panelSpacing = theme.getPanelSpacing();
47
48
  const refContainer = useRef(null);
48
49
  const timeState = useTimeState();
49
50
  const { registerPosition } = usePanelPositioning();
@@ -207,10 +208,10 @@ export function MultiPanel({
207
208
 
208
209
  registerPosition(chitId, {
209
210
  chitId,
210
- x: x + theme.spacing / 4,
211
- y: y + theme.spacing / 4,
212
- w: w - theme.spacing / 2,
213
- h: h - effectiveTabHeight - theme.spacing / 2,
211
+ x: x + panelSpacing / 4,
212
+ y: y + panelSpacing / 4,
213
+ w: w - panelSpacing / 2,
214
+ h: h - effectiveTabHeight - panelSpacing / 2,
214
215
  paused: isPaused,
215
216
  panCallback,
216
217
  visible: true,
@@ -232,7 +233,7 @@ export function MultiPanel({
232
233
  isSliding,
233
234
  focusedPanel,
234
235
  registerPosition,
235
- theme.spacing,
236
+ panelSpacing,
236
237
  refContainer,
237
238
  panCallback,
238
239
  timeMultiplier,
@@ -270,7 +271,7 @@ export function MultiPanel({
270
271
  top: `${y}px`,
271
272
  position: "absolute",
272
273
  zIndex: enabled ? "auto" : -1,
273
- p: `${theme.spacing / 4}px`,
274
+ p: `${panelSpacing / 4}px`,
274
275
  transition: panelTransition(theme, timeMultiplier),
275
276
  }}
276
277
  >
@@ -3,7 +3,7 @@ import { Box } from "@mui/material";
3
3
  import useSize from "@react-hook/size";
4
4
  import { useGameTheme } from "../../hooks/useGameTheme";
5
5
  import { RootChit } from "../../game/RootChit";
6
- import { usePanelScale } from "../../hooks/usePanelScale";
6
+ import { usePanelScale } from "../../hooks/useDisplaySettings";
7
7
  import { usePlayerId } from "../../hooks/usePlayer";
8
8
  import { SinglePanel } from "./SinglePanel";
9
9
  import { MultiPanel } from "./MultiPanel";
@@ -353,7 +353,9 @@ export function PanelContents({
353
353
  sx={{
354
354
  position: "relative",
355
355
  flex: 1,
356
- p: `${theme.spacing * 0.75}px`,
356
+ // Each panel insets itself by panelSpacing / 4 (SinglePanel, MultiPanel), so two neighbours sit
357
+ // panelSpacing / 2 apart; a quarter here gives the screen edge that same gap
358
+ p: `${theme.getPanelSpacing() * 0.25}px`,
357
359
  }}
358
360
  >
359
361
  <Box
@@ -28,6 +28,7 @@ export function SinglePanel({
28
28
  setFocusedPanel: (chit: Chit | undefined) => void;
29
29
  }) {
30
30
  const theme = useGameTheme();
31
+ const panelSpacing = theme.getPanelSpacing();
31
32
  const animationSpeedMultiplier = useAnimationSpeedMultiplier();
32
33
  const { registerPosition } = usePanelPositioning();
33
34
 
@@ -45,16 +46,16 @@ export function SinglePanel({
45
46
  const chitId = chit.id ?? "";
46
47
  registerPosition(chitId, {
47
48
  chitId,
48
- x: x + theme.spacing / 4,
49
- y: y + theme.spacing / 4,
50
- w: w - theme.spacing / 2,
51
- h: h - theme.spacing / 2,
49
+ x: x + panelSpacing / 4,
50
+ y: y + panelSpacing / 4,
51
+ w: w - panelSpacing / 2,
52
+ h: h - panelSpacing / 2,
52
53
  paused: effectivePaused,
53
54
  front: true,
54
55
  visible: true,
55
56
  transition,
56
57
  });
57
- }, [chit, x, y, w, h, transition, effectivePaused, enabled, focusedPanel, registerPosition, theme.spacing]);
58
+ }, [chit, x, y, w, h, transition, effectivePaused, enabled, focusedPanel, registerPosition, panelSpacing]);
58
59
 
59
60
  return (
60
61
  <Box
@@ -65,7 +66,7 @@ export function SinglePanel({
65
66
  left: `${x}px`,
66
67
  top: `${y}px`,
67
68
  position: "absolute",
68
- p: `${theme.spacing / 4}px`,
69
+ p: `${panelSpacing / 4}px`,
69
70
  transition,
70
71
  zIndex: enabled ? "auto" : -1,
71
72
  }}
@@ -1,140 +1,202 @@
1
- import React, { useEffect, useMemo, useState } from "react";
2
- import { Box, Stack, Slider, Typography, Button, Checkbox, FormControlLabel } from "@mui/material";
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import { Box, Stack, Slider, Typography, Button, Checkbox, FormControlLabel, Divider } from "@mui/material";
3
3
  import { GameModalDialog } from "./GameModalDialog";
4
4
  import { useModalState } from "../hooks/useModalState";
5
5
  import { useEventChannelState } from "../hooks/useEventChannelState";
6
6
  import { useGameTheme } from "../hooks/useGameTheme";
7
7
  import { useTimeState } from "../hooks/useTimeController";
8
- import { usePanelScale, usePanelSetScale } from "../hooks/usePanelScale";
8
+ import { useDisplaySettings } from "../hooks/useDisplaySettings";
9
+ import {
10
+ ANIMATION_SPEEDS,
11
+ DISPLAY_SECTIONS,
12
+ DISPLAY_STEP_COUNT,
13
+ DISPLAY_STEP_LABELS,
14
+ NORMAL_STEP,
15
+ allAtStep,
16
+ animationSpeedStep,
17
+ overallStep,
18
+ } from "../game/DisplaySettings";
9
19
 
10
- interface SettingSliderProps {
20
+ /** How long the dialog stays see-through after a size change, so the player can see the result */
21
+ const PREVIEW_MS = 2000;
22
+
23
+ interface StepSliderProps {
11
24
  label: string;
12
- value: number;
13
- onChange: (value: number) => void;
14
- min: number;
15
- max: number;
25
+ valueLabel: string;
26
+ step: number;
27
+ onChange: (step: number) => void;
28
+ lowHint: string;
29
+ highHint: string;
30
+ markLabels?: string[];
31
+ compact?: boolean;
32
+ /** No step is selected (Display Size when the parts are set differently): no handle and no filled track */
33
+ unset?: boolean;
16
34
  }
17
35
 
18
- function SettingSlider({ label, value, onChange, min, max }: SettingSliderProps) {
36
+ function StepSlider({ label, valueLabel, step, onChange, lowHint, highHint, markLabels, compact, unset }: StepSliderProps) {
19
37
  const theme = useGameTheme();
38
+ const marks = Array.from({ length: DISPLAY_STEP_COUNT }, (_, i) => ({ value: i, label: markLabels?.[i] }));
20
39
 
21
40
  return (
22
41
  <Box>
23
- <Stack direction="row" spacing={2} alignItems="center" sx={{ mb: 1 }}>
24
- <Typography sx={{ color: theme.actionLogTextColor, fontWeight: "bold", minWidth: 120 }}>{label}</Typography>
25
- <Typography sx={{ color: theme.actionLogTextColor, minWidth: 40, textAlign: "right" }}>
26
- {value.toFixed(2)}
42
+ <Stack direction="row" justifyContent="space-between" alignItems="baseline">
43
+ <Typography sx={{ color: theme.actionLogTextColor, fontWeight: "bold", fontSize: compact ? 14 : 16 }}>
44
+ {label}
27
45
  </Typography>
28
- <Button
29
- variant="outlined"
30
- size="small"
31
- onClick={() => onChange(1)}
46
+ <Typography sx={{ color: theme.barHighlightTextColor, fontSize: compact ? 13 : 14 }}>{valueLabel}</Typography>
47
+ </Stack>
48
+ <Box sx={{ px: 1 }}>
49
+ <Slider
50
+ value={step}
51
+ onChange={(_, value) => onChange(value as number)}
52
+ min={0}
53
+ max={DISPLAY_STEP_COUNT - 1}
54
+ step={1}
55
+ marks={marks}
56
+ size={compact ? "small" : "medium"}
32
57
  sx={{
33
- color: theme.actionLogTextColor,
34
- borderColor: theme.actionLogTextColor,
35
- "&:hover": {
36
- borderColor: theme.actionLogTextColor,
37
- backgroundColor: "rgba(255,255,255,0.1)",
38
- },
58
+ color: theme.barHighlightTextColor,
59
+ mb: markLabels ? 1 : 0,
60
+ "& .MuiSlider-rail": { backgroundColor: theme.actionLogTextColor, opacity: 0.3 },
61
+ "& .MuiSlider-mark": { backgroundColor: theme.actionLogTextColor, opacity: 0.5, width: 4, height: 4, borderRadius: 2 },
62
+ "& .MuiSlider-markActive": { backgroundColor: theme.actionLogDialogBackgroundColor, opacity: 0.8 },
63
+ "& .MuiSlider-markLabel": { color: theme.actionLogTextColor, opacity: 0.7, fontSize: 12 },
64
+ ...(unset && {
65
+ "& .MuiSlider-thumb, & .MuiSlider-track": { display: "none" },
66
+ "& .MuiSlider-markActive": { backgroundColor: theme.actionLogTextColor, opacity: 0.5 },
67
+ }),
39
68
  }}
40
- >
41
- Reset
42
- </Button>
43
- </Stack>
44
- <Slider
45
- value={value}
46
- onChange={(_, value) => onChange(value as number)}
47
- min={min}
48
- max={max}
49
- step={0.01}
50
- sx={{
51
- color: theme.actionLogTextColor,
52
- "& .MuiSlider-thumb": {
53
- backgroundColor: theme.actionLogTextColor,
54
- },
55
- "& .MuiSlider-track": {
56
- backgroundColor: theme.actionLogTextColor,
57
- },
58
- "& .MuiSlider-rail": {
59
- backgroundColor: "rgba(255,255,255,0.3)",
60
- },
61
- }}
62
- />
69
+ />
70
+ </Box>
71
+ {!markLabels && (
72
+ <Stack direction="row" justifyContent="space-between" sx={{ mt: -0.5 }}>
73
+ <Typography sx={{ color: theme.actionLogTextColor, opacity: 0.5, fontSize: 12 }}>{lowHint}</Typography>
74
+ <Typography sx={{ color: theme.actionLogTextColor, opacity: 0.5, fontSize: 12 }}>{highHint}</Typography>
75
+ </Stack>
76
+ )}
63
77
  </Box>
64
78
  );
65
79
  }
66
80
 
81
+ function ThemedCheckbox({ label, checked, onChange }: { label: string; checked: boolean; onChange: (c: boolean) => void }) {
82
+ const theme = useGameTheme();
83
+ return (
84
+ <FormControlLabel
85
+ control={
86
+ <Checkbox
87
+ checked={checked}
88
+ onChange={(e) => onChange(e.target.checked)}
89
+ sx={{ color: theme.actionLogTextColor, "&.Mui-checked": { color: theme.barHighlightTextColor } }}
90
+ />
91
+ }
92
+ label={<Typography sx={{ color: theme.actionLogTextColor }}>{label}</Typography>}
93
+ />
94
+ );
95
+ }
96
+
97
+ function speedLabel(speed: number) {
98
+ return speed === 0.5 ? "½×" : `${speed}×`;
99
+ }
100
+
67
101
  export function SettingsDisplay() {
68
102
  const modalState = useModalState();
69
103
  const theme = useGameTheme();
70
104
 
71
- const scale = usePanelScale();
72
- const setScale = usePanelSetScale();
73
-
74
- const [adjustingScale, setAdjustingScale] = useState(false);
105
+ const [display, setDisplay] = useDisplaySettings();
106
+ const overall = overallStep(display);
75
107
 
108
+ // See-through for a moment after a size change, so the player can see what it did behind the dialog
109
+ const [previewing, setPreviewing] = useState(false);
110
+ const lastDisplay = useRef(display);
76
111
  useEffect(() => {
77
- setAdjustingScale(true);
78
- const to = setTimeout(() => {
79
- setAdjustingScale(false);
80
- }, 2000);
112
+ if (lastDisplay.current === display) {
113
+ return;
114
+ }
115
+ lastDisplay.current = display;
116
+ setPreviewing(true);
117
+ const to = setTimeout(() => setPreviewing(false), PREVIEW_MS);
81
118
  return () => clearTimeout(to);
82
- }, [scale]);
119
+ }, [display]);
83
120
 
84
121
  const timeState = useTimeState();
85
122
  const [speed, setSpeed] = useEventChannelState(timeState.animationSpeedMultiplier);
86
123
  const [skipReplay, setSkipReplay] = useEventChannelState(timeState.skipReplay);
87
124
  const [showLog, setShowLog] = useEventChannelState(timeState.showLog);
125
+ const speedStep = animationSpeedStep(speed);
88
126
 
89
127
  const [visible, setVisible] = useEventChannelState(modalState.settingsVisible);
90
128
 
129
+ const averageStep = Math.round(
130
+ DISPLAY_SECTIONS.reduce((sum, s) => sum + display[s.key], 0) / DISPLAY_SECTIONS.length,
131
+ );
132
+
91
133
  return (
92
134
  <GameModalDialog
93
135
  visible={visible}
94
- opacity={adjustingScale ? 0.3 : 1}
136
+ opacity={previewing ? 0.3 : 1}
95
137
  onClose={() => setVisible(false)}
96
138
  title="Settings"
97
139
  >
98
140
  <Box sx={{ p: 3, overflowY: "auto" }}>
99
- <Stack spacing={4}>
100
- <SettingSlider label="Scale" value={scale} onChange={setScale} min={0.5} max={3} />
101
- <SettingSlider
141
+ <Stack spacing={3}>
142
+ <Stack>
143
+ <ThemedCheckbox label="Skip Replay" checked={skipReplay} onChange={setSkipReplay} />
144
+ <ThemedCheckbox label="Show Log (on larger screens)" checked={showLog} onChange={setShowLog} />
145
+ </Stack>
146
+
147
+ <Divider sx={{ borderColor: "rgba(128,128,128,0.3)" }} />
148
+
149
+ <StepSlider
102
150
  label="Animation Speed"
103
- value={1 / speed}
104
- onChange={(value) => setSpeed(1 / value)}
105
- min={0.25}
106
- max={8}
107
- />
108
- <FormControlLabel
109
- control={
110
- <Checkbox
111
- checked={skipReplay}
112
- onChange={(e) => setSkipReplay(e.target.checked)}
113
- sx={{
114
- color: theme.actionLogTextColor,
115
- "&.Mui-checked": {
116
- color: theme.actionLogTextColor,
117
- },
118
- }}
119
- />
120
- }
121
- label={<Typography sx={{ color: theme.actionLogTextColor }}>Skip Replay</Typography>}
151
+ valueLabel={speedLabel(ANIMATION_SPEEDS[speedStep])}
152
+ step={speedStep}
153
+ onChange={(step) => setSpeed(1 / ANIMATION_SPEEDS[step])}
154
+ lowHint="Slower"
155
+ highHint="Faster"
156
+ markLabels={ANIMATION_SPEEDS.map(speedLabel)}
122
157
  />
123
- <FormControlLabel
124
- control={
125
- <Checkbox
126
- checked={showLog}
127
- onChange={(e) => setShowLog(e.target.checked)}
158
+
159
+ <Divider sx={{ borderColor: "rgba(128,128,128,0.3)" }} />
160
+
161
+ <Stack spacing={1}>
162
+ <StepSlider
163
+ label="Display Size"
164
+ valueLabel={overall === undefined ? "Custom" : DISPLAY_STEP_LABELS[overall]}
165
+ step={overall ?? averageStep}
166
+ unset={overall === undefined}
167
+ onChange={(step) => setDisplay(allAtStep(step))}
168
+ lowHint="Fit more on screen"
169
+ highHint="Bigger everything"
170
+ />
171
+ <Stack direction="row" justifyContent="flex-end">
172
+ <Button
173
+ size="small"
174
+ disabled={overall === NORMAL_STEP}
175
+ onClick={() => setDisplay(allAtStep(NORMAL_STEP))}
128
176
  sx={{
129
177
  color: theme.actionLogTextColor,
130
- "&.Mui-checked": {
131
- color: theme.actionLogTextColor,
132
- },
178
+ textTransform: "none",
179
+ "&.Mui-disabled": { color: theme.actionLogTextColor, opacity: 0.3 },
133
180
  }}
134
- />
135
- }
136
- label={<Typography sx={{ color: theme.actionLogTextColor }}>Show Log (on larger screens)</Typography>}
137
- />
181
+ >
182
+ Reset
183
+ </Button>
184
+ </Stack>
185
+ <Stack spacing={2} sx={{ pl: 2, pt: 1, borderLeft: "2px solid rgba(128,128,128,0.4)" }}>
186
+ {DISPLAY_SECTIONS.map((section) => (
187
+ <StepSlider
188
+ compact
189
+ key={section.key}
190
+ label={section.label}
191
+ valueLabel={DISPLAY_STEP_LABELS[display[section.key]]}
192
+ step={display[section.key]}
193
+ onChange={(step) => setDisplay({ ...display, [section.key]: step })}
194
+ lowHint={section.smallerHint}
195
+ highHint={section.biggerHint}
196
+ />
197
+ ))}
198
+ </Stack>
199
+ </Stack>
138
200
  </Stack>
139
201
  </Box>
140
202
  </GameModalDialog>
@@ -20,6 +20,8 @@ function BaseTopBar({ children }: { children: ReactNode | ReactNode[] }) {
20
20
  position: "relative",
21
21
  background: theme.barColor,
22
22
  height: theme.topBarHeight,
23
+ // A fixed-height bar in the viewer's flex column: never squeezed when the table needs the room
24
+ flexShrink: 0,
23
25
  }}
24
26
  >
25
27
  {children}
@@ -132,7 +132,8 @@ export default function TopBarPlayers() {
132
132
  return (
133
133
  <TopBarDropdown
134
134
  label={
135
- <Stack direction={"row"} sx={{ pt: 1, pb: 1, maxWidth: "100%" }}>
135
+ // padded by the theme's spacing, which the avatar size allows for, so the strip is exactly the bar's height
136
+ <Stack direction={"row"} sx={{ py: `${theme.spacing}px`, maxWidth: "100%" }}>
136
137
  {/* The avatar cluster is what a tutorial points at with { ui: "players" }, not the whole strip */}
137
138
  <Stack direction={"row"} data-tutorial-target="players" sx={{ pl: 1 }}>
138
139
  {playerChits.map((player) => (
@@ -148,7 +149,8 @@ export default function TopBarPlayers() {
148
149
  <Typography
149
150
  flex={1}
150
151
  sx={{
151
- p: 1,
152
+ px: 1,
153
+ py: `${theme.spacing}px`,
152
154
  lineHeight: `${theme.topBarHeight - theme.spacing * 4}px`,
153
155
  fontSize: 14 * theme.fontScalar,
154
156
  whiteSpace: "nowrap",
@@ -0,0 +1,80 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { GameTheme } from "./GameTheme";
3
+ import {
4
+ DEFAULT_DISPLAY_SETTINGS,
5
+ allAtStep,
6
+ animationSpeedStep,
7
+ loadDisplaySettings,
8
+ overallStep,
9
+ scaledTheme,
10
+ sectionMultiplier,
11
+ } from "./DisplaySettings";
12
+
13
+ function storage(values: Record<string, string>) {
14
+ return { getItem: (key: string) => values[key] ?? null };
15
+ }
16
+
17
+ describe("DisplaySettings", () => {
18
+ it("leaves the theme alone at normal size", () => {
19
+ const theme = new GameTheme();
20
+ for (const section of ["panelPadding", "topBar", "actionLog", "bottomBar"] as const) {
21
+ expect(scaledTheme(theme, section, DEFAULT_DISPLAY_SETTINGS)).toBe(theme);
22
+ }
23
+ });
24
+
25
+ it("scales only the section's own sizes, from the game's theme", () => {
26
+ const theme = GameTheme.withDefaults("#224466", "#ff8800");
27
+ theme.topBarHeight = 50;
28
+ theme.fontFamily = "Serif";
29
+ const bigger = allAtStep(4);
30
+
31
+ const top = scaledTheme(theme, "topBar", bigger);
32
+ expect(top).toBeInstanceOf(GameTheme);
33
+ expect(top.topBarHeight).toBeCloseTo(70);
34
+ expect(top.bottomBarHeight).toBe(theme.bottomBarHeight);
35
+ expect(top.barColor).toBe(theme.barColor);
36
+ expect(top.fontFamily).toBe("Serif");
37
+ expect(theme.topBarHeight).toBe(50);
38
+
39
+ const bottom = scaledTheme(theme, "bottomBar", allAtStep(0));
40
+ expect(bottom.bottomBarHeight).toBeLessThan(theme.bottomBarHeight);
41
+ expect(bottom.bottomBarIconSize).toBeLessThan(theme.bottomBarIconSize);
42
+ });
43
+
44
+ it("scales the panel gap without touching spacing used inside panels", () => {
45
+ const theme = new GameTheme();
46
+ const tight = scaledTheme(theme, "panelPadding", allAtStep(0));
47
+ expect(tight.getPanelSpacing()).toBeLessThan(theme.spacing);
48
+ expect(tight.spacing).toBe(theme.spacing);
49
+ });
50
+
51
+ it("fits fewer panels as the layout gets bigger", () => {
52
+ expect(sectionMultiplier("panelLayout", allAtStep(0))).toBeGreaterThan(1);
53
+ expect(sectionMultiplier("panelLayout", allAtStep(4))).toBeLessThan(1);
54
+ });
55
+
56
+ it("knows when every section is at the same step", () => {
57
+ expect(overallStep(allAtStep(3))).toBe(3);
58
+ expect(overallStep({ ...allAtStep(3), topBar: 1 })).toBeUndefined();
59
+ });
60
+
61
+ it("loads saved settings, clamping bad values", () => {
62
+ const loaded = loadDisplaySettings(storage({ displaySettings: JSON.stringify({ topBar: 9, actionLog: 1 }) }));
63
+ expect(loaded).toEqual({ ...DEFAULT_DISPLAY_SETTINGS, topBar: 4, actionLog: 1 });
64
+ expect(loadDisplaySettings(storage({ displaySettings: "not json" }))).toEqual(DEFAULT_DISPLAY_SETTINGS);
65
+ });
66
+
67
+ it("carries over the old free-form panel scale", () => {
68
+ expect(loadDisplaySettings(storage({ panelScale: "1" })).panelLayout).toBe(2);
69
+ expect(loadDisplaySettings(storage({ panelScale: "3" })).panelLayout).toBe(0);
70
+ expect(loadDisplaySettings(storage({ panelScale: "0.5" })).panelLayout).toBe(4);
71
+ });
72
+
73
+ it("maps animation duration multipliers to the nearest speed", () => {
74
+ expect(animationSpeedStep(1)).toBe(1);
75
+ expect(animationSpeedStep(1 / 8)).toBe(4);
76
+ expect(animationSpeedStep(1 / 4)).toBe(3);
77
+ expect(animationSpeedStep(1 / 2)).toBe(2);
78
+ expect(animationSpeedStep(4)).toBe(0);
79
+ });
80
+ });