Files
test/src/components/BroadcastGraphics/Common/AngledFlag/AngledFlag.tsx
T
DeepSeek Harness 9528307820 feat: 中文界面、键盘控制、车手名单、名次脚本与 OBS 输出
- 键盘控制:数字按名次选车、方向键移动光标、出/收字幕、圈数 +/-、计时器、
  名次脚本、快捷键总表;在输入框里打字时不触发,每次按键都有 Toast 反馈
- 车手名单编辑器(E):姓名/缩写/车号/国籍/车队/性能/黄T摄/头像均可改,
  支持调整发车顺位、单条重置、全部重置、JSON 导入导出,localStorage 持久化
- LAP 可手动 +/-,LAP 旁新增 mm:ss.mmm 计时器(零点=计时榜出现的瞬间)
- 名次脚本(J):JSON 预设,以计时器为零点,支持 swap/move/retire/restore/lap 与 order
  * 改脚本即时生效并从零重播,修掉"改完之后过期事件被一次性爆发"的问题
  * order 立即铺回赛道;写错会在状态条里报出具体原因,不再静默失败
  * localStorage 持久化,刷新不再丢失
- 合并 feature/standalone-output:OBS 透明输出页 /output 与 WebSocket 中继 server/relayServer.js
  * 修复中继晚连接的输出页只能收到最后一片补丁(缓存改为合并累加)
- 修复 react-spring 缺少 deps 导致进场动画被每次渲染重启
  (chyron、百叶窗、wipe、计时塔名次描边)
- 界面中文化(上屏的转播图形保持英文),F1 字体栈补 CJK 回退
- 新增「启动开发服务器.cmd」一键启动,.gitignore 排除本地工具目录
2026-10-20 21:26:50 +08:00

128 lines
3.5 KiB
TypeScript

import { ReactNode } from "react";
import { TeamId } from "../../../../types/state";
import { Px } from "../../../../types/style";
import { getTeamFlagStyle } from "../../../../utils/dataLookup";
import { resolveCountryFlag, resolveTeamLogo } from "../../../../domain/data/assets";
import {
Container,
Slant,
Sheen,
FlagEdge,
CountryFlagDiv,
FlagContainer,
TeamFlagDiv,
} from "./styles";
const FLAG_WIDTH_TEAM = 2.4;
const FLAG_WIDTH_COUNTRY = 2;
/**
* To look right, country flags need to be 2:1. Additional editing will be
* necessary for some flags to not cut off prominent elements. Ex: China's flag
* would have its stars mostly cut out without edits to place them closer to the
* center.
*/
type AngledFlagProps = {
flagHeight: Px,
flagProps: {
flagMode: "country",
flag: string,
} | {
flagMode: "team",
flag: TeamId,
},
};
export function AngledFlag(props: AngledFlagProps) {
const { flagProps, flagHeight } = props;
let topFlag: ReactNode = null;
let bottomFlag: ReactNode = null;
if (flagProps.flagMode === "country") {
// The roster editor only offers bundled flags, but an imported roster can
// name anything - fall through to an empty flag instead of crashing.
const flagSrc = resolveCountryFlag(flagProps.flag);
if (flagSrc != null) {
topFlag = (
<CountryFlagDiv
src={flagSrc}
height={flagHeight}
width={flagHeight * FLAG_WIDTH_COUNTRY}
>
<FlagEdge
x={flagHeight / 2}
height={flagHeight}
girth={flagHeight * 0.07}
/>
</CountryFlagDiv>
);
bottomFlag = (
<CountryFlagDiv
src={flagSrc}
height={flagHeight}
width={flagHeight * FLAG_WIDTH_COUNTRY}
xOffset={-flagHeight * 0.005}
/>
);
}
} else if (flagProps.flagMode === "team") {
const logoSrc = resolveTeamLogo(flagProps.flag);
if (logoSrc != null) {
topFlag = (
<TeamFlagDiv
src={logoSrc}
height={flagHeight}
width={flagHeight * FLAG_WIDTH_TEAM}
style={getTeamFlagStyle(flagProps.flag)}
>
<FlagEdge
x={flagHeight / 2}
height={flagHeight}
girth={flagHeight * 0.04}
/>
</TeamFlagDiv>
);
bottomFlag = (
<TeamFlagDiv
src={logoSrc}
height={flagHeight}
width={flagHeight * FLAG_WIDTH_TEAM}
style={getTeamFlagStyle(flagProps.flag)}
bottomFlag
/>
);
}
}
const flagModeWidth = flagProps.flagMode === "team" ? FLAG_WIDTH_TEAM : FLAG_WIDTH_COUNTRY;
return (
<Container width={flagHeight * 6} height={flagHeight * 3}>
<Slant x={0} height={flagHeight * 3} girth={flagHeight * 2.4} />
<FlagContainer
height={flagHeight}
width={flagHeight * flagModeWidth} // Dynamic width...
collapsedWidth={flagHeight * flagModeWidth}
masked
teamFlag={flagProps.flagMode === "team"}
>
<FlagContainer
height={flagHeight}
width={flagHeight * flagModeWidth}
collapsedWidth={flagHeight * flagModeWidth}
topFlag
teamFlag={flagProps.flagMode === "team"}
>
{topFlag}
</FlagContainer>
{bottomFlag}
</FlagContainer>
<Sheen
x={-flagHeight / 6.4}
height={flagHeight * 3}
girth={flagHeight * 1.1}
/>
</Container>
);
}