Skip to content

Commit 8da8c33

Browse files
committed
feat(scoreboard): always visible when match mode active
Signed-off-by: Dhruv Arora <dhruv.arora1@autodesk.com>
1 parent b502681 commit 8da8c33

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

fission/src/test/ui/ScoreboardVisibility.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ test("only auto depends on gameplay", () => {
1111
expect(isScoreboardVisible("off", true)).toBe(false)
1212
})
1313

14+
test("a running match shows the scoreboard in every mode", () => {
15+
for (const mode of SCOREBOARD_MODES) {
16+
expect(isScoreboardVisible(mode, true, true)).toBe(true)
17+
}
18+
})
19+
1420
test("cycling visits every mode and returns to the start", () => {
1521
let mode: ScoreboardMode = SCOREBOARD_MODES[0]
1622
const visited = SCOREBOARD_MODES.map(() => (mode = nextScoreboardMode(mode)))

fission/src/ui/components/topbar/GameplayControls.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ const SCOREBOARD_TOOLTIPS: Record<ScoreboardMode, string> = {
1717
off: "Scoreboard: always off",
1818
}
1919

20+
const MATCH_OVERRIDE_TOOLTIP = "Scoreboard: shown while a match is running"
21+
2022
const ScoreboardModeButton: React.FC = () => {
21-
const { mode, visible, setMode } = useScoreboard()
23+
const { mode, visible, overriddenByMatch, setMode } = useScoreboard()
2224

2325
const ScoreboardGlyph = visible ? SynthesisIcons.SCOREBOARD : SynthesisIcons.SCOREBOARD_HIDDEN
2426
const nextMode = nextScoreboardMode(mode)
2527
const cycleMode = useCallback(() => setMode(nextMode), [setMode, nextMode])
2628

2729
return (
2830
<TopBarButton
29-
label={SCOREBOARD_TOOLTIPS[mode]}
31+
label={overriddenByMatch ? MATCH_OVERRIDE_TOOLTIP : SCOREBOARD_TOOLTIPS[mode]}
3032
icon={
31-
<Box sx={SCOREBOARD_GLYPH_SX[mode]}>
33+
<Box sx={overriddenByMatch ? SCOREBOARD_GLYPH_SX.on : SCOREBOARD_GLYPH_SX[mode]}>
3234
<ScoreboardGlyph />
3335
</Box>
3436
}

fission/src/ui/helpers/ScoreboardVisibility.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export const SCOREBOARD_GLYPH_SX: Record<ScoreboardMode, SxProps<Theme>> = {
2323
off: { ...TOP_BAR_GLYPH_SX, opacity: MUTED_GLYPH_OPACITY },
2424
}
2525

26-
export function isScoreboardVisible(mode: ScoreboardMode, gameplayActive: boolean): boolean {
27-
return mode === "on" || (mode === "auto" && gameplayActive)
26+
export function isScoreboardVisible(mode: ScoreboardMode, gameplayActive: boolean, matchActive = false): boolean {
27+
return matchActive || mode === "on" || (mode === "auto" && gameplayActive)
2828
}
2929

3030
export function nextScoreboardMode(mode: ScoreboardMode): ScoreboardMode {
@@ -34,6 +34,7 @@ export function nextScoreboardMode(mode: ScoreboardMode): ScoreboardMode {
3434
export interface Scoreboard {
3535
mode: ScoreboardMode
3636
visible: boolean
37+
overriddenByMatch: boolean // the scoreboard is visible when a match is active
3738
setMode: (mode: ScoreboardMode) => void
3839
}
3940

@@ -67,5 +68,10 @@ export function useScoreboard(): Scoreboard {
6768
[inMatchMode]
6869
)
6970

70-
return { mode, visible: isScoreboardVisible(mode, gameplayActive), setMode }
71+
return {
72+
mode,
73+
visible: isScoreboardVisible(mode, gameplayActive, inMatchMode),
74+
overriddenByMatch: inMatchMode && !isScoreboardVisible(mode, gameplayActive),
75+
setMode,
76+
}
7177
}

0 commit comments

Comments
 (0)