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 排除本地工具目录
This commit is contained in:
1 parent
ed5c6e752c
commit
9528307820
78 files changed
+5066
-438
No files matched your search
@@ -3,6 +3,73 @@ Hello! What you've stumbled upon is a personal practice web development project
|
||||
|
||||
I've probably written 98% of all the CSS I've ever written in my life in this project alone. While I'm not exactly a master (yet) I feel entirely capable of taking design directions from a designer and building the CSS that is needed to create it in the real world.
|
||||
|
||||
# 独立转播输出(给 OBS 用)
|
||||
可以把广播画面推到**一个独立的透明输出页**上,通过一个 WebSocket 中继转发,这样 OBS
|
||||
(或任何其它渲染器)可以直接把图形叠到画面上,而控制端继续在普通浏览器标签里操作。
|
||||
|
||||
## 运行
|
||||
```bash
|
||||
# 1. 启动前端(控制页和输出页都由它提供)
|
||||
npm start
|
||||
# 2. 另开一个终端,启动 WebSocket 中继(默认端口 8181)
|
||||
npm run relay
|
||||
```
|
||||
|
||||
然后打开:
|
||||
|
||||
* **控制端**:http://localhost:3000/broadcast (任何 UI 页面都可以)
|
||||
* **输出端**:http://localhost:3000/output —— 透明、只有图形
|
||||
|
||||
## 在 OBS 里使用
|
||||
添加一个 **浏览器(Browser)** 源:
|
||||
|
||||
* URL:`http://localhost:3000/output`
|
||||
* 宽度 `1920`、高度 `1080`
|
||||
* 透明度是自动的(这一页不画任何背景)。按需勾选「源不可见时关闭」
|
||||
* 建议勾选「场景激活时刷新浏览器」,源重连后中继会把最后一次状态重放给它
|
||||
|
||||
## URL 参数
|
||||
| 页面 | 参数 | 作用 |
|
||||
| --- | --- | --- |
|
||||
| `/output` | `?debug=1` | 画出 1920x1080 安全框和连接状态角标 |
|
||||
| `/output` | `?ws=ws://host:port` | 指定中继地址(例如局域网另一台机器:`?ws=ws://192.168.1.20:8181`) |
|
||||
| 控制端页面 | `?bridge=0` | 这个标签页不向中继发布状态 |
|
||||
|
||||
中继可以用 `RELAY_PORT` / `RELAY_HOST` 配置(默认 `8181` / `0.0.0.0`),
|
||||
控制端也可以用 `REACT_APP_RELAY_URL` 指向别处。
|
||||
|
||||
> **同时只开一个控制端标签页。** 中继允许任意多个 controller 连接,但每个标签页都会发布自己的
|
||||
> store,两个控制端会互相覆盖状态(输出页就会闪来闪去)。多余的标签页请关掉,或者加上
|
||||
> `?bridge=0` 让它只当观众。
|
||||
>
|
||||
> 输出页显示不正常时,先看 `http://localhost:8181/health`:`controllers` 应该是 1、
|
||||
> `hasState` 应该是 `true`;输出页加 `?debug=1` 会画出连接状态和「最后一次收到数据」的时间。
|
||||
|
||||
## 实现
|
||||
* `src/components/Output/OutputRoute.tsx` —— 无外壳的输出页:只渲染计时榜、字幕和 logo,
|
||||
按窗口等比缩放,背景透明。
|
||||
* `src/components/Output/BroadcastBridge.tsx` —— 挂在外壳里;节流(约 20Hz)把广播相关的
|
||||
Redux 切片推给中继。
|
||||
* `src/features/outputChannel/` —— 自动重连的 WebSocket 客户端,以及用来把远端状态镜像进
|
||||
本地 store 的 snapshot action。
|
||||
* `server/relayServer.js` —— 极简 `ws` 中继:缓存最后一份状态、广播给所有输出端、
|
||||
忽略输出端发来的状态。健康检查:`GET /health`。
|
||||
|
||||
## 快速开始(中文)
|
||||
控制界面是中文的;上屏的转播图形保持英文,因为它们是在还原 F1 世界转播信号本身的样子。
|
||||
|
||||
**Windows 一键启动**:双击项目根目录里的 **`启动开发服务器.cmd`**。
|
||||
|
||||
**命令行启动**:
|
||||
|
||||
```bash
|
||||
npm install # 第一次才需要
|
||||
npm start
|
||||
```
|
||||
|
||||
然后打开 [localhost:3000](http://localhost:3000)。日常操作都在 **转播控制台**(`/broadcast`)页,
|
||||
进去以后按 <kbd>?</kbd> 就能看到全部快捷键。
|
||||
|
||||
# Demos
|
||||
*Please note that animated images on this page are in WEBP format and may have performance issues (a lowered framerate) depending on your device. Animations are buttery smooth in practice! View the videos below if they're slow for you!*
|
||||
|
||||
@@ -170,6 +237,119 @@ I've learned a little bit about, say, using OBS to overlay websites as a transpa
|
||||
|
||||
If you somehow have the interest AND the skills to do such a thing I fully welcome you to reach out to me and tell me about it. If someone (or a group of people) could continue my work I'd not only give my permission but some of my support as well.
|
||||
|
||||
# Directing a broadcast
|
||||
The broadcast can be driven without ever touching the mouse.
|
||||
|
||||
*The control interface is in Chinese. The on-air graphics are deliberately left
|
||||
in English - they replicate the F1 world feed, so `LAP 1/44`, `Leader` and
|
||||
`OUT` stay exactly as a viewer would see them. All interface text lives in the
|
||||
components plus the shared label maps in `src/i18n/labels.ts`.*
|
||||
|
||||
## Keyboard control
|
||||
Press `?` at any time (or click the keyboard button next to the chyron buttons)
|
||||
to bring up the list inside the app itself.
|
||||
|
||||
| Keys | Action |
|
||||
| --- | --- |
|
||||
| `E` | Show / hide the driver roster editor |
|
||||
| `?` | Show / hide the shortcut list |
|
||||
| `Esc` | Close a panel, otherwise close the chyron |
|
||||
| `↑` `↓` | Move the cursor along the running order |
|
||||
| `Home` `End` | Jump the cursor to the leader or the last car |
|
||||
| `Space` | Add or remove the cursor car from the selection |
|
||||
| `1` … `9` `0` | Select the car running in P1 … P10 |
|
||||
| `Shift` + `1` … `0` | Add that car as the second chyron driver |
|
||||
| `X` | Clear the selection |
|
||||
| `Enter` | Show a chyron for the selection, or the cursor car |
|
||||
| `Shift` + `Enter` | Play the next step of the chyron animation |
|
||||
| `Backspace` | Close the chyron |
|
||||
| `[` `]` | Cycle the chyron mode |
|
||||
| `,` `.` | Cycle the chyron sub mode |
|
||||
| `F` | Cycle the flag: country, team, none |
|
||||
| `P` | Toggle the position flag |
|
||||
| `N` | Toggle the driver number |
|
||||
| `O` | Toggle the portrait |
|
||||
| `S` | Start / stop the event |
|
||||
| `R` | Recalculate the running order |
|
||||
| `Shift` + `P` | Send the selected car 200 m up the road |
|
||||
| `Shift` + `O` | Send every car 100 m up the road |
|
||||
| `Shift` + `F` | Award the fastest lap to the selected car |
|
||||
| `D` | Retire / un-retire the selected car |
|
||||
| `T` | Cycle the timing tower display mode |
|
||||
| `I` | Switch between leader and interval splits |
|
||||
| `+` `=` | Push the LAP counter one lap further on |
|
||||
| `-` | Take the LAP counter one lap back |
|
||||
| `C` | Start / pause the show clock beside LAP |
|
||||
| `Shift` + `C` | Back to zero and replay the position script |
|
||||
| `J` | Show / hide the JSON position script |
|
||||
|
||||
Shortcuts never fire while you are typing in a field, and every press answers
|
||||
with a short toast at the bottom of the screen so you can tell what landed
|
||||
without looking away from the video.
|
||||
|
||||
The whole list lives in `src/features/keyboard/shortcuts.ts`. The handler beside
|
||||
it implements that same table and the help overlay renders it, so the on-screen
|
||||
documentation cannot drift away from the real bindings.
|
||||
|
||||
## Driver roster editor
|
||||
Press `E`, or use the roster button next to the chyron buttons.
|
||||
|
||||
* First name, last name, three letter code, car number, nationality, team,
|
||||
performance and yellow T-Cam are editable, per car.
|
||||
* The portrait can be pointed at any portrait bundled in
|
||||
`src/public/images/drivers/front`.
|
||||
* Edits are written straight into the event state, so the chyrons and the timing
|
||||
tower redraw as you type - there is no apply step.
|
||||
* `▲` / `▼` move a driver up or down the starting grid, `↺` restores a single
|
||||
driver and `Reset all` restores the shipped 2021 lineup.
|
||||
* The roster is kept in `localStorage` as you edit, and `Export JSON` /
|
||||
`Import JSON` move a lineup between machines.
|
||||
|
||||
A driver whose fields are never touched behaves exactly as before: the portrait
|
||||
still defaults to the driver's own id, so none of the stock data changed.
|
||||
|
||||
## The show clock and the LAP counter
|
||||
The status indicator in the top left corner carries two extra readouts:
|
||||
|
||||
* **LAP** can be nudged by hand with `+` and `-`. The offset is remembered
|
||||
separately from the lap the simulation derives from the leader's distance, so
|
||||
the two never fight each other.
|
||||
* **The show clock** sits beside it and counts `mm:ss.mmm` from the moment the
|
||||
timing graphics appeared. `C` pauses it, `Shift` + `C` puts it back to zero.
|
||||
|
||||
## Position script
|
||||
Press `J` (or the code button beside the chyron buttons) for a JSON schedule of
|
||||
running order changes. Its zero *is* the show clock, so the same file replays
|
||||
identically on every run.
|
||||
|
||||
```json
|
||||
{
|
||||
"autoStart": true,
|
||||
"order": ["VER", "HAM", "BOT", "PER", "SAI", "NOR", "LEC", "RIC", "GAS", "ALO",
|
||||
"OCO", "VET", "STR", "TSU", "RUS", "RAI", "LAT", "GIO", "MSC", "MAZ"],
|
||||
"events": [
|
||||
{ "at": "00:05.000", "action": "swap", "drivers": ["HAM", "VER"] },
|
||||
{ "at": "00:12.000", "action": "move", "driver": "LEC", "to": 3 },
|
||||
{ "at": "00:18.500", "action": "lap", "value": 1 },
|
||||
{ "at": "00:24.000", "action": "retire", "driver": "MAZ" },
|
||||
{ "at": "00:31.000", "action": "restore", "driver": "MAZ" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
* `at` is milliseconds or `"mm:ss.mmm"` after zero.
|
||||
* `action` is `swap`, `move`, `retire`, `restore` or `lap`.
|
||||
* A driver may be named by id (`verstappen`), code (`VER`), surname
|
||||
(`Verstappen`) or car number (`33`).
|
||||
* `order` is optional and is put back on the track every time the clock resets,
|
||||
which is what makes "Reset & replay" reproduce the same show.
|
||||
* Editing is live: a valid schedule takes effect immediately, an invalid one
|
||||
reports itself and keeps the previous schedule running.
|
||||
|
||||
Reshuffling gives each car the track position of the rank it moves into, so the
|
||||
gaps - and the interval column - survive untouched, and the timing tower plays
|
||||
its position change animation exactly as it does during a real race.
|
||||
|
||||
# How to download and run
|
||||
Here I'll do my best to guide you to try this project on your own
|
||||
|
||||
|
||||
Reference in new issue
Block a user