[PR #1982] [MERGED] Official mods: FPS Counter and Keystrokes, the first extras as mods #3911

Closed
opened 2026-11-03 04:13:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1982
Author: @ludovic111
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: feat/official-hud-mods


📝 Commits (3)

  • fbd6bee Official mods: FPS Counter and Keystrokes, the first extras as mods
  • 980c619 Merge feat/mod-api-extras (with main) into feat/official-hud-mods
  • 0cb1d46 Merge main into feat/official-hud-mods

📊 Changes

9 files changed (+404 additions, -1 deletions)

View changed files

📝 Cargo.lock (+14 -0)
📝 Cargo.toml (+1 -1)
📝 docs/mods.md (+16 -0)
➕ mods/official/fps-overlay/Cargo.toml (+16 -0)
➕ mods/official/fps-overlay/horizon-mod.toml (+9 -0)
➕ mods/official/fps-overlay/src/lib.rs (+131 -0)
➕ mods/official/keystrokes/Cargo.toml (+16 -0)
➕ mods/official/keystrokes/horizon-mod.toml (+9 -0)
➕ mods/official/keystrokes/src/lib.rs (+192 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Stacked on #1963 (the extras API), itself on #1944, #1929 and #1864. Review only the last commit. Until those merge, the diff also shows their commits.

The first two Horizon extras rewritten as official mods, in mods/official/. They use only the public mod API, like any community mod. The built-in extras stay for now. They go away in the removal PR, which installs these mods, with their settings, for the players who had the extras on.

What's in it

Mod Id Replaces Settings page
FPS Counter fps_overlay Extras > FPS counter Corner (Top left by default); Minimum and 1% low (OFF)
Keystrokes keystrokes Extras > Keystrokes Corner (Top left); Clicks per second (ON)
  • They have the same options and defaults as the extras, and their settings sit in the mod's storage (corner, lows, cps). The migration will write a player's extras settings there.
  • FPS Counter redraws once a tick, only when its text changes.
  • Keystrokes uses the frame hook, so a key lights up on the frame it goes down, as with the extra. It redraws only when a key, label or CPS value changes.
  • Both are workspace members, like coords-hud, so clippy and pr_ready cover them. docs/mods.md gains "Horizon's official mods": where they live, how a maintainer publishes them, and their settings keys.

Same look

Both setups ran in the same world (seed 42, server thread, fresh data folders, offscreen 1280×720) with the built-in extras on, then with the two mods on:

  • Defaults, idle: the keystrokes block is pixel-identical (largest channel difference 1 of 255, the same as untouched parts of the world). The FPS box is identical apart from the live number.
  • W and space held, then 4 clicks: the same boxes, the same lit keys, and "4 CPS" in the same place.
  • Other options (FPS top right with min and 1% low; keystrokes bottom left without CPS): the same placement and text as the extras.
  • Settings pages, in game: Options > Mods > Settings shows the two buttons; each click cycles the option, saves it and moves or changes the overlay at once.

Cost

  • Frame-time A/B: uncapped (maxFps:260, no vsync), the same view, 3 rounds × 20 s each, built-in versus mod. The mean CPU frame times overlap:

    round 1 round 2 round 3 mean
    neither 0.632 ms 0.602 ms 0.576 ms 0.603 ms
    built-in extras 0.620 ms 0.603 ms 0.564 ms 0.596 ms
    the two mods 0.569 ms 0.624 ms 0.597 ms 0.597 ms

    The spread between rounds (about 0.03 ms) is larger than any difference between the setups.

  • In the sandbox (release, 1,000,000 frames with a tick every 20): both mods together cost 1.1 µs per frame, counting the snapshot refresh, the frame call and draining the output. FPS Counter alone costs 0.03 µs per frame; its work is a tick that usually finds the text unchanged.

Publishing

  • Build: cd mods/official/<name> && cargo horizon-mod build on main with rustc 1.99.0.
    • The .wasm holds no local paths (only /rustc/<hash>/ from the toolchain), so the same toolchain and Cargo.lock give the same file.
    • The files built from this branch: fps_overlay 15,124 bytes, SHA-256 58a4f5d00e2f7391a861c6a70d2411bf3c38468f9a8767f9a93db3db74e79ab5; keystrokes 17,096 bytes, SHA-256 5eb2e786108587692c0b314b756eafdae609599082dfd729f0f80fc3e3cd19bf.
  • Registry checks: cargo horizon-mod check passes on both. Each trial run did 40 ticks and 120 frames.
  • Entries: the registry entries (mods/<id>.toml, owners ludovic111) go to horizon-mods once this merges.

How tested

  • cargo clippy -p fps-overlay -p keystrokes --target wasm32-unknown-unknown -- -D warnings, rustfmt.
  • In game: the comparison and the settings pages above, with no panic and no stopped mod in the logs.

Self-check (against #1963's head):

pr_ready (tools/pr_ready.py --quick --base c28bea8e9 on ludovics-mac-mini, against c28bea8e9 at c28bea8e9, 24 min 43 s)

Check Result
Scope ✅ 9 files, +404 −1
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (8 s)
clippy ✅ (3 min 1 s)
tests: workspace ✅ 2083 passed (18 min 47 s)
doc tests ✅ 1 passed (2 min 47 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 331 listed only because the root Cargo.toml changed (two new members). The mods are separate wasm crates that the game doesn't link, so no harness input changes; CI runs them

Label skip-release: nothing changes for players until the mods are published and the removal PR lands.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1982 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/official-hud-mods` --- ### 📝 Commits (3) - [`fbd6bee`](https://github.com/horizon-rust/horizon/commit/fbd6bee3e3adc4f2d64b2e5e3520899fdc0f5239) Official mods: FPS Counter and Keystrokes, the first extras as mods - [`980c619`](https://github.com/horizon-rust/horizon/commit/980c619b81f8833a9c7249050cfd6f54578a2e25) Merge feat/mod-api-extras (with main) into feat/official-hud-mods - [`0cb1d46`](https://github.com/horizon-rust/horizon/commit/0cb1d4639360f6736bd8c25c83f495d3d98b90e2) Merge main into feat/official-hud-mods ### 📊 Changes **9 files changed** (+404 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+14 -0) 📝 `Cargo.toml` (+1 -1) 📝 `docs/mods.md` (+16 -0) ➕ `mods/official/fps-overlay/Cargo.toml` (+16 -0) ➕ `mods/official/fps-overlay/horizon-mod.toml` (+9 -0) ➕ `mods/official/fps-overlay/src/lib.rs` (+131 -0) ➕ `mods/official/keystrokes/Cargo.toml` (+16 -0) ➕ `mods/official/keystrokes/horizon-mod.toml` (+9 -0) ➕ `mods/official/keystrokes/src/lib.rs` (+192 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. **Stacked on #1963** (the extras API), itself on #1944, #1929 and #1864. Review only the last commit. Until those merge, the diff also shows their commits. The first two Horizon extras rewritten as official mods, in `mods/official/`. They use only the public mod API, like any community mod. The built-in extras stay for now. They go away in the removal PR, which installs these mods, with their settings, for the players who had the extras on. ## What's in it | Mod | Id | Replaces | Settings page | |---|---|---|---| | FPS Counter | `fps_overlay` | Extras > FPS counter | Corner (Top left by default); Minimum and 1% low (OFF) | | Keystrokes | `keystrokes` | Extras > Keystrokes | Corner (Top left); Clicks per second (ON) | - They have the same options and defaults as the extras, and their settings sit in the mod's storage (`corner`, `lows`, `cps`). The migration will write a player's extras settings there. - **FPS Counter** redraws once a tick, only when its text changes. - **Keystrokes** uses the frame hook, so a key lights up on the frame it goes down, as with the extra. It redraws only when a key, label or CPS value changes. - Both are workspace members, like coords-hud, so clippy and pr_ready cover them. `docs/mods.md` gains "Horizon's official mods": where they live, how a maintainer publishes them, and their settings keys. ## Same look Both setups ran in the same world (seed 42, server thread, fresh data folders, offscreen 1280×720) with the built-in extras on, then with the two mods on: - **Defaults, idle:** the keystrokes block is pixel-identical (largest channel difference 1 of 255, the same as untouched parts of the world). The FPS box is identical apart from the live number. - **W and space held, then 4 clicks:** the same boxes, the same lit keys, and "4 CPS" in the same place. - **Other options** (FPS top right with min and 1% low; keystrokes bottom left without CPS): the same placement and text as the extras. - **Settings pages, in game:** Options > Mods > Settings shows the two buttons; each click cycles the option, saves it and moves or changes the overlay at once. ## Cost - **Frame-time A/B:** uncapped (`maxFps:260`, no vsync), the same view, 3 rounds × 20 s each, built-in versus mod. The mean CPU frame times overlap: | | round 1 | round 2 | round 3 | mean | |---|---|---|---|---| | neither | 0.632 ms | 0.602 ms | 0.576 ms | 0.603 ms | | built-in extras | 0.620 ms | 0.603 ms | 0.564 ms | 0.596 ms | | the two mods | 0.569 ms | 0.624 ms | 0.597 ms | 0.597 ms | The spread between rounds (about 0.03 ms) is larger than any difference between the setups. - **In the sandbox** (release, 1,000,000 frames with a tick every 20): both mods together cost **1.1 µs per frame**, counting the snapshot refresh, the frame call and draining the output. FPS Counter alone costs 0.03 µs per frame; its work is a tick that usually finds the text unchanged. ## Publishing - **Build:** `cd mods/official/<name> && cargo horizon-mod build` on `main` with rustc 1.99.0. - The `.wasm` holds no local paths (only `/rustc/<hash>/` from the toolchain), so the same toolchain and `Cargo.lock` give the same file. - The files built from this branch: `fps_overlay` 15,124 bytes, SHA-256 `58a4f5d00e2f7391a861c6a70d2411bf3c38468f9a8767f9a93db3db74e79ab5`; `keystrokes` 17,096 bytes, SHA-256 `5eb2e786108587692c0b314b756eafdae609599082dfd729f0f80fc3e3cd19bf`. - **Registry checks:** `cargo horizon-mod check` passes on both. Each trial run did 40 ticks and 120 frames. - **Entries:** the registry entries (`mods/<id>.toml`, owners `ludovic111`) go to horizon-mods once this merges. ## How tested - `cargo clippy -p fps-overlay -p keystrokes --target wasm32-unknown-unknown -- -D warnings`, rustfmt. - In game: the comparison and the settings pages above, with no panic and no stopped mod in the logs. **Self-check** (against #1963's head): **pr_ready** (`tools/pr_ready.py --quick --base c28bea8e9` on ludovics-mac-mini, against c28bea8e9 at c28bea8e9, 24 min 43 s) | Check | Result | | --- | --- | | Scope | ✅ 9 files, +404 −1 | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (8 s) | | clippy | ✅ (3 min 1 s) | | tests: workspace | ✅ 2083 passed (18 min 47 s) | | doc tests | ✅ 1 passed (2 min 47 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 331 listed only because the root `Cargo.toml` changed (two new members). The mods are separate wasm crates that the game doesn't link, so no harness input changes; CI runs them | Label `skip-release`: nothing changes for players until the mods are published and the removal PR lands. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:13:12 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3911
No description provided.