Skip to content

Commit cc51a88

Browse files
authored
Match Mode Cancel Button [SYNTH-312] (#1473)
* Match Mode Abort UI Option * Abort Match Top Bar Icon * Better Contrast Match Mode Abort Line * feat: add active highlight while match is running --------- Co-authored-by: PepperLola <PepperLola@users.noreply.github.com>
2 parents 45f1054 + 7469d21 commit cc51a88

4 files changed

Lines changed: 95 additions & 5 deletions

File tree

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

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { Box, Stack } from "@mui/material"
22
import type React from "react"
33
import { useEffect, useState } from "react"
4+
import EventSystem from "@/systems/EventSystem.ts"
5+
import MatchMode from "@/systems/match_mode/MatchMode"
46
import PreferencesSystem from "@/systems/preferences/PreferencesSystem"
57
import { useUIContext } from "@/ui/helpers/UIProviderHelpers"
68
import MatchModeConfigPanel from "@/ui/panels/configuring/MatchModeConfigPanel"
9+
import MultiplayerStartModal from "@/ui/modals/multiplayer/MultiplayerStartModal"
10+
import ConfirmModal from "@/ui/modals/common/ConfirmModal"
711
import { SynthesisIcons } from "@/ui/components/StyledComponents"
812
import { TopBarButton } from "@/ui/components/topbar/TopBarButton"
913
import { TOP_BAR_GLYPH_SX } from "@/ui/components/topbar/TopBarConfig"
1014
import { TopBarIcon } from "@/ui/components/topbar/TopBarIcons"
11-
import MultiplayerStartModal from "@/modals/multiplayer/MultiplayerStartModal.tsx"
15+
import { globalAddToast } from "@/ui/components/GlobalUIControls"
1216

1317
export const ScoreboardButton: React.FC = () => {
1418
const [alwaysOn, setAlwaysOn] = useState(() => PreferencesSystem.getUserPreference("AlwaysShowScoreboard"))
@@ -40,16 +44,42 @@ export const ScoreboardButton: React.FC = () => {
4044
const GameplayControls: React.FC = () => {
4145
const { openModal, togglePanel } = useUIContext()
4246

47+
const [isMatchRunning, setIsMatchRunning] = useState(() => MatchMode.getInstance().isMatchEnabled())
48+
49+
useEffect(() => {
50+
return EventSystem.listen("MatchStateChangedEvent", () => {
51+
setIsMatchRunning(MatchMode.getInstance().isMatchEnabled())
52+
})
53+
}, [])
54+
4355
const openMatchMode = () => togglePanel(MatchModeConfigPanel, undefined)
4456

57+
const abortMatchMode = () => {
58+
openModal(
59+
ConfirmModal,
60+
{ message: "Are you sure you want to abort the current match? This cannot be undone." },
61+
undefined,
62+
{
63+
title: "Abort Match",
64+
acceptText: "Abort Match",
65+
cancelText: "Cancel",
66+
onAccept: () => {
67+
MatchMode.getInstance().sandboxModeStart()
68+
globalAddToast("info", "Match Mode Cancelled")
69+
},
70+
}
71+
)
72+
}
73+
4574
const openMultiplayer = () => openModal(MultiplayerStartModal, undefined)
4675

4776
return (
4877
<Stack direction="row" alignItems="center" gap={1.5}>
4978
<TopBarButton
50-
label="Start Match"
51-
icon={<TopBarIcon name="gp-match-mode" size={30} />}
52-
onClick={openMatchMode}
79+
label={isMatchRunning ? "Abort Match" : "Start Match"}
80+
active={isMatchRunning}
81+
icon={<TopBarIcon name={isMatchRunning ? "gp-match-mode-abort" : "gp-match-mode"} size={30} />}
82+
onClick={isMatchRunning ? abortMatchMode : openMatchMode}
5383
/>
5484
<TopBarButton
5585
label="Open Multiplayer"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const TOP_BAR_ICON_NAMES = [
6161
"cfg-camera-positions",
6262
"gp-multiplayer",
6363
"gp-match-mode",
64+
"gp-match-mode-abort",
6465
] as const
6566

6667
export type TopBarIconName = (typeof TOP_BAR_ICON_NAMES)[number]
Lines changed: 59 additions & 0 deletions
Loading

fission/src/ui/panels/configuring/MatchModeConfigPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ const MatchModeConfigPanel: React.FC<PanelImplProps<void, void>> = ({ panel }) =
244244
globalAddToast(
245245
"error",
246246
"Match Mode Already Running",
247-
"You can't modify the match mode ruleset while a match is running"
247+
"You can't start a new match while one is already running"
248248
)
249249
return
250250
}

0 commit comments

Comments
 (0)