feat(match): 添加画面上下镜像、跳过准备和装甲板整局复位

This commit is contained in:
sloray committed 2026-10-31 09:27:26 +08:00
1 parent 235fb1c73b
commit 338efa5c2e
39 files changed
+1094 -54

No files matched your search

+16 -2
View File
@@ -84,6 +84,7 @@ export function RefereeMatchControl({ snapshot, onError }: { snapshot: Snapshot;
const [approved, setApproved] = useState(false);
const [seconds, setSeconds] = useState(5);
const [busy, setBusy] = useState(false);
const canReset = clock.phase === "finished" || snapshot.health.some(health => health.outcome != null);
const active = ["preparation", "ready", "countdown", "running"].includes(clock.phase);
const run = async (action: MatchAction, close?: () => void) => {
if (busy) return;
@@ -97,8 +98,21 @@ export function RefereeMatchControl({ snapshot, onError }: { snapshot: Snapshot;
<div className="match-control__identity"><span className="label">MATCH CONTROL</span><span>{snapshot.demo ? "本机演示 · 合成计时" : "裁判计时 / 局域网同步"}</span>{!snapshot.demo && <small className={snapshot.matchClock.syncError ? "is-error" : ""}>{snapshot.matchClock.syncError ?? "仅对局进行中扣血;准备与暂停时只闪灯"}</small>}</div>
<Readout clock={clock} names={snapshot.config.teamNames} />
<div className="match-control__actions">
{clock.phase === "idle" || clock.phase === "finished" ? <button className="btn btn--primary" disabled={busy} onClick={() => void run({ type: "prepare" })}><Icon name="timer" />开始 3 分钟准备</button> : clock.phase === "ready" ? <div className="match-control__start"><label>开赛倒计时 <input aria-label="开赛倒计时秒数" type="number" min="1" max="60" step="1" value={seconds} onChange={e => setSeconds(Number(e.target.value))} /> 秒</label><button className="btn btn--primary" disabled={busy || !Number.isInteger(seconds) || seconds < 1 || seconds > 60} onClick={() => void run({ type: "countdown", seconds })}><Icon name="play" />确认开赛</button></div> : clock.phase === "paused" ? <button className="btn btn--primary" disabled={busy} onClick={() => void run({ type: "resume" })}><Icon name="play" />恢复{clock.resumePhase === "preparation" ? "准备" : clock.resumePhase === "ready" ? "待开赛阶段" : clock.resumePhase === "countdown" ? "倒计时" : "对局"}</button> : <span className="match-control__hint">{clock.phase === "preparation" ? "准备结束后等待裁判确认开赛" : clock.phase === "countdown" ? "请选手就位" : "计时到零结束本局"}</span>}
<div className="match-control__buttons"><button className="btn" disabled={busy || !active} onClick={() => openPause("player")}><Icon name="pause" />选手暂停</button><button className="btn" disabled={busy || !active} onClick={() => openPause("official")}><Icon name="pause" />官方暂停</button>{active || clock.phase === "paused" ? <button className="btn btn--quiet" disabled={busy} onClick={() => setDialog("end")}><Icon name="stop" />结束本局</button> : clock.phase === "finished" && <button className="btn btn--quiet" disabled={busy} onClick={() => void run({ type: "reset" })}><Icon name="reset" />清除计时</button>}</div>
{canReset ? <>
<span className="match-control__hint">{busy ? "等待装甲板回执与满血上报" : "重置后恢复满血,保留设备槽位和设置"}</span>
<button className="btn btn--primary" disabled={busy} title="恢复装甲板满血,清除本局计时和结果,保留设备槽位与设置" onClick={() => void run({ type: "reset" })}><Icon name="reset" />{busy ? "正在重置本局…" : "重置到未开始"}</button>
</> : <>
{clock.phase === "idle" ? <button className="btn btn--primary" disabled={busy} onClick={() => void run({ type: "prepare" })}><Icon name="timer" />开始 3 分钟准备</button>
: clock.phase === "preparation" ? <button className="btn" disabled={busy} title="结束准备,进入等待裁判确认开赛" onClick={() => void run({ type: "skipPreparation" })}><Icon name="play" />跳过准备倒计时</button>
: clock.phase === "ready" ? <div className="match-control__start"><label>开赛倒计时 <input aria-label="开赛倒计时秒数" type="number" min="1" max="60" step="1" value={seconds} onChange={e => setSeconds(Number(e.target.value))} /> 秒</label><button className="btn btn--primary" disabled={busy || !Number.isInteger(seconds) || seconds < 1 || seconds > 60} onClick={() => void run({ type: "countdown", seconds })}><Icon name="play" />确认开赛</button></div>
: clock.phase === "paused" ? <button className="btn btn--primary" disabled={busy} onClick={() => void run({ type: "resume" })}><Icon name="play" />恢复{clock.resumePhase === "preparation" ? "准备" : clock.resumePhase === "ready" ? "待开赛阶段" : clock.resumePhase === "countdown" ? "倒计时" : "对局"}</button>
: <span className="match-control__hint">{clock.phase === "countdown" ? "请选手就位" : "计时到零结束本局"}</span>}
<div className="match-control__buttons">
<button className="btn" disabled={busy || !active} onClick={() => openPause("player")}><Icon name="pause" />选手暂停</button>
<button className="btn" disabled={busy || !active} onClick={() => openPause("official")}><Icon name="pause" />官方暂停</button>
{(active || clock.phase === "paused") && <button className="btn btn--quiet" disabled={busy} onClick={() => setDialog("end")}><Icon name="stop" />结束本局</button>}
</div>
</>}
</div>
{dialog && <Dialog title={dialog === "end" ? "结束本局计时" : dialog === "player" ? "选手技术暂停" : "官方技术暂停"} closeDisabled={busy} onClose={() => setDialog(null)} className="match-dialog">
{close => <div className="match-dialog__body">{dialog === "end" ? <><p>结束当前计时并同步到选手端,同时停止装甲板扣血。比赛结果由裁判判定。</p><button className="btn btn--primary" disabled={busy} onClick={() => void run({ type: "end" }, close)}><Icon name="stop" />确认结束本局</button></> : <>