[PR #6293] [MERGED] Buttons scroll a label wider than they are, as vanilla does, instead of panicking (Resource Packs screen in 8 languages) #6775

Closed
opened 2026-11-03 06:26:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6293
Author: @mariuslozo-boop
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/pack-screen-long-label


📝 Commits (4)

  • 7a9207e Buttons scroll a label wider than they are, instead of panicking in clamp (#6129)
  • 3ef7e2e Pack screen harness: scrolling button labels in 8 languages at a fixed clock (#6129)
  • bee5c7d Buttons reach the label through vanilla's scrolling chain; drop the unreproducible offset hash (#6129)
  • 76e2ffd Port ledger: ClickableStyleFinder.acceptScrolling's note no longer says there is no scrolling text (#6129)

📊 Changes

8 files changed (+515 additions, -37 deletions)

View changed files

📝 crates/horizon-client-render/src/options_ui.rs (+1 -1)
📝 crates/horizon-client-render/src/pack_screen.rs (+155 -13)
📝 crates/horizon-client-render/src/screen_draw.rs (+283 -7)
📝 crates/horizon-client/examples/probe/pack_screen_fixture.rs (+16 -5)
📝 crates/horizon-client/src/game/chat.rs (+1 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaPackScreenOracle.java (+39 -2)
📝 tools/port_map/client2-009.tsv (+4 -4)
📝 tools/test_pack_screen_parity.py (+16 -5)

📄 Description

🤖 Opened by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally.

What and why

Fixes #6129. Opening Options > Resource Packs panicked in 8 languages (af_za, ca_es, io_en, isv, mk_mk, oc_fr, tl_ph, vp_vl): screen_draw::button centred every label with ((left + right) / 2).clamp(left + lw / 2, right - lw / 2), and a label wider than the button gives min > max.

Vanilla never clamps a label that is too wide. ActiveTextCollector.defaultScrollingHelper (ActiveTextCollector.java:62-90) has two branches: a label that fits is centred with that clamp (where min <= max always holds), and a label wider than right - left is drawn left-aligned, scissored to the button, and slides back and forth with the clock. Horizon had ported only the first branch. This ports the second, and the chain that reaches it:

  • screen_draw::scroll_offset and screen_draw::scrolling_text: defaultScrollingHelper's scroll branch, with its constants (PERIOD_PER_SCROLLED_PIXEL, MIN_SCROLL_PERIOD), the sine easing, Mth.lerp, the (int) cast and the scissor box.
  • scrolling_with_default_center and scrolling_string_over_contents: AbstractWidget.acceptScrollingWithDefaultCenter and extractScrollingStringOverContents (2 px margin, AbstractWidget.java:92-98), which button now goes through like AbstractButton.extractDefaultLabel (AbstractButton.java:39-40).
  • The clock is passed in (now_ms): the game passes hud_overlays::now_ms() (monotonic milliseconds, like Util.getMillis), tests and the parity fixture pass a fixed value. PackScreen::draw takes it, and the footer is drawn by draw_footer(.., labels) so a test can use any language's strings without touching the global language.
  • All three callers of screen_draw::button get it: the pack screen footer, the pack confirm screen's Yes/No, and the chat's Leave Bed button.
  • Port ledger (tools/port_map/client2-009.tsv): defaultScrollingHelper, acceptScrolling and RenderingTextCollector.acceptScrolling go from missing to port; map-check reports no problems.

Not changed here: Horizon's other buttons and sliders (ui::button, ui::slider, the title-screen buttons) clip or spill a too-long label instead of scrolling it. That is #6229, a follow-up on top of this.

Known limit, documented on scrolling_text: paint replaces a scissor rather than intersecting it, and NoScissor clears rather than restores. None of the three callers is drawn inside another scissor today.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

ActiveTextCollector.defaultScrollingHelper (ActiveTextCollector.java:62-90), AbstractWidget.extractScrollingStringOverContents / acceptScrollingWithDefaultCenter (AbstractWidget.java:92-98), AbstractButton.extractDefaultLabel (AbstractButton.java:39-40), PackSelectionScreen (PackSelectionScreen.java:118, Button.DEFAULT_WIDTH 150), Mth.lerp (Mth.java:578).

Harness: tools/test_pack_screen_parity.py. 20% of its cases now run in one of the 8 crashing languages (or fr_fr/de_de) at a fixed clock; the Java oracle sets the language, pins Util's time source and records the label's scissor. On Windows: 3000/3000 match, 427 of them scrolling labels (offsets 0 to -25 px). With the old clamp put back, the fixture panics with min > max, so the harness now catches #6129. Its outputs are read as UTF-8 (the Windows default encoding crashed on the mk_mk labels).

Other projects' code

none

Self-check

New tests, each run with the old clamp put back (they panic with min > max) and with the fix (they pass):

  • screen_draw::button_label_tests: a label wider than its button scrolls inside its box; the scroll starts one pixel past the room; empty labels and tiny buttons (1 px, widths -5, 0 and 2 to 5) don't panic. a_label_that_fits_is_centred and the_offset_follows_the_vanilla_period_and_easing pass either way (they pin the unchanged fitting case and the new formula's spot values).
  • pack_screen::footer_label_tests::a_footer_label_wider_than_its_button_scrolls.
  • the_footer_draws_in_every_language_file (#[ignore], needs HORIZON_TEST_RESOURCES): all 143 lang files with the real font, each with a local Language (the global one is left alone). 10 languages scroll: the 8 from the issue plus ro_ro and sl_si (one pixel over).

Real client (offscreen, isolated home, lang:af_za): Options > Resource Packs opens, and the footer label slides between "Maak die Hulpbronbak-gids oc…" and "aak die Hulpbronbak-gids oop", clipped at both button edges, over six screenshots about 6 s apart. Switching to isv (170 px label) with the screen open doesn't crash. A sweep of all 143 languages with the Resource Packs screen open: 143/143 without a crash (8 crashed before).

pr_ready (tools/pr_ready.py --base upstream/main on PCDKBLENDER, against upstream/main at 3adcfcbb3, 15 min 13 s)

Check Result
Scope ✅ 8 files, +514 −36
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 585 passed (1 min 35 s)
rustfmt ✅ (14 s)
clippy ✅ (30 s)
tests: horizon-client, horizon-client-render ❌ 1188 passed, 1 failed (12 min 43 s)
doc tests ✅ 0 passed (7 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ❌ 382 affected, (2 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • The one failure is entities::armor_stand_motion_tests::a_tick_keeps_the_previous_position_for_interpolation. It fails the same on a clean 3adcfcbb3 (it needs .local, so CI skips it), and is #6235 / #6236. cargo stops at the first failing binary, so the remaining binaries were run separately: horizon-client-render 912 + 7 passed; horizon-client's 11 integration test binaries pass; the game binary 541 passed, 2 failed (game::tnt::tests::a_soul_sand_bubble_column_lifts_primed_tnt, primed_tnt_follows_water_currents_after_moving), both also failing on clean main and also in #6235 / #6236.
  • Parity: run on Windows, where the runner needs fcntl and can't start. The pack-screen harness was run on its own (above).
  • RUST_TEST_THREADS=2 was set: on this machine the GPU render tests hang with more threads (#5238).

Not tested:

  • In the real client, only the Resource Packs screen, at 1280x720 and GUI scale 2 (the clamp's inputs are in GUI pixels, so the window size doesn't change the result). The confirm screen's Yes/No and Leave Bed are covered by unit tests only.
  • After switching to isv with the screen open, the screen title and pack names stayed Afrikaans in one screenshot. Not looked into; it looks separate from this.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RodDbPWCByh96WKcbiEQpB


🔄 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/6293 **Author:** [@mariuslozo-boop](https://github.com/mariuslozo-boop) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/pack-screen-long-label` --- ### 📝 Commits (4) - [`7a9207e`](https://github.com/horizon-rust/horizon/commit/7a9207e1e214adc136b55ac5ec6c9e0f5788505e) Buttons scroll a label wider than they are, instead of panicking in clamp (#6129) - [`3ef7e2e`](https://github.com/horizon-rust/horizon/commit/3ef7e2e8f712515be1776214da6ae9e532ee8f56) Pack screen harness: scrolling button labels in 8 languages at a fixed clock (#6129) - [`bee5c7d`](https://github.com/horizon-rust/horizon/commit/bee5c7da72c358cea0f17869d8a10c7cb354e26a) Buttons reach the label through vanilla's scrolling chain; drop the unreproducible offset hash (#6129) - [`76e2ffd`](https://github.com/horizon-rust/horizon/commit/76e2ffdb8705fe37076959786bb1bfcbb7086c94) Port ledger: ClickableStyleFinder.acceptScrolling's note no longer says there is no scrolling text (#6129) ### 📊 Changes **8 files changed** (+515 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/options_ui.rs` (+1 -1) 📝 `crates/horizon-client-render/src/pack_screen.rs` (+155 -13) 📝 `crates/horizon-client-render/src/screen_draw.rs` (+283 -7) 📝 `crates/horizon-client/examples/probe/pack_screen_fixture.rs` (+16 -5) 📝 `crates/horizon-client/src/game/chat.rs` (+1 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaPackScreenOracle.java` (+39 -2) 📝 `tools/port_map/client2-009.tsv` (+4 -4) 📝 `tools/test_pack_screen_parity.py` (+16 -5) </details> ### 📄 Description > 🤖 Opened by mariuslozo-boop's AI agent (Claude Code, Claude Sonnet 5.5 + Claude Opus 5.5 review), not by mariuslozo-boop personally. ## What and why Fixes #6129. Opening Options > Resource Packs panicked in 8 languages (af_za, ca_es, io_en, isv, mk_mk, oc_fr, tl_ph, vp_vl): `screen_draw::button` centred every label with `((left + right) / 2).clamp(left + lw / 2, right - lw / 2)`, and a label wider than the button gives min > max. Vanilla never clamps a label that is too wide. `ActiveTextCollector.defaultScrollingHelper` (`ActiveTextCollector.java:62-90`) has two branches: a label that fits is centred with that clamp (where min <= max always holds), and a label wider than `right - left` is drawn left-aligned, scissored to the button, and slides back and forth with the clock. Horizon had ported only the first branch. This ports the second, and the chain that reaches it: - `screen_draw::scroll_offset` and `screen_draw::scrolling_text`: `defaultScrollingHelper`'s scroll branch, with its constants (`PERIOD_PER_SCROLLED_PIXEL`, `MIN_SCROLL_PERIOD`), the sine easing, `Mth.lerp`, the `(int)` cast and the scissor box. - `scrolling_with_default_center` and `scrolling_string_over_contents`: `AbstractWidget.acceptScrollingWithDefaultCenter` and `extractScrollingStringOverContents` (2 px margin, `AbstractWidget.java:92-98`), which `button` now goes through like `AbstractButton.extractDefaultLabel` (`AbstractButton.java:39-40`). - The clock is passed in (`now_ms`): the game passes `hud_overlays::now_ms()` (monotonic milliseconds, like `Util.getMillis`), tests and the parity fixture pass a fixed value. `PackScreen::draw` takes it, and the footer is drawn by `draw_footer(.., labels)` so a test can use any language's strings without touching the global language. - All three callers of `screen_draw::button` get it: the pack screen footer, the pack confirm screen's Yes/No, and the chat's Leave Bed button. - Port ledger (`tools/port_map/client2-009.tsv`): `defaultScrollingHelper`, `acceptScrolling` and `RenderingTextCollector.acceptScrolling` go from missing to port; `map-check` reports no problems. Not changed here: Horizon's other buttons and sliders (`ui::button`, `ui::slider`, the title-screen buttons) clip or spill a too-long label instead of scrolling it. That is #6229, a follow-up on top of this. Known limit, documented on `scrolling_text`: `paint` replaces a scissor rather than intersecting it, and `NoScissor` clears rather than restores. None of the three callers is drawn inside another scissor today. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [x] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `ActiveTextCollector.defaultScrollingHelper` (`ActiveTextCollector.java:62-90`), `AbstractWidget.extractScrollingStringOverContents` / `acceptScrollingWithDefaultCenter` (`AbstractWidget.java:92-98`), `AbstractButton.extractDefaultLabel` (`AbstractButton.java:39-40`), `PackSelectionScreen` (`PackSelectionScreen.java:118`, `Button.DEFAULT_WIDTH` 150), `Mth.lerp` (`Mth.java:578`). Harness: `tools/test_pack_screen_parity.py`. 20% of its cases now run in one of the 8 crashing languages (or fr_fr/de_de) at a fixed clock; the Java oracle sets the language, pins `Util`'s time source and records the label's scissor. On Windows: **3000/3000 match, 427 of them scrolling labels** (offsets 0 to -25 px). With the old clamp put back, the fixture panics with `min > max`, so the harness now catches #6129. Its outputs are read as UTF-8 (the Windows default encoding crashed on the mk_mk labels). ## Other projects' code none ## Self-check New tests, each run with the old clamp put back (they panic with `min > max`) and with the fix (they pass): - `screen_draw::button_label_tests`: a label wider than its button scrolls inside its box; the scroll starts one pixel past the room; empty labels and tiny buttons (1 px, widths -5, 0 and 2 to 5) don't panic. `a_label_that_fits_is_centred` and `the_offset_follows_the_vanilla_period_and_easing` pass either way (they pin the unchanged fitting case and the new formula's spot values). - `pack_screen::footer_label_tests::a_footer_label_wider_than_its_button_scrolls`. - `the_footer_draws_in_every_language_file` (`#[ignore]`, needs `HORIZON_TEST_RESOURCES`): all 143 lang files with the real font, each with a local `Language` (the global one is left alone). 10 languages scroll: the 8 from the issue plus ro_ro and sl_si (one pixel over). Real client (offscreen, isolated home, `lang:af_za`): Options > Resource Packs opens, and the footer label slides between "Maak die Hulpbronbak-gids oc…" and "aak die Hulpbronbak-gids oop", clipped at both button edges, over six screenshots about 6 s apart. Switching to isv (170 px label) with the screen open doesn't crash. A sweep of all 143 languages with the Resource Packs screen open: 143/143 without a crash (8 crashed before). **pr_ready** (`tools/pr_ready.py --base upstream/main` on PCDKBLENDER, against upstream/main at 3adcfcbb3, 15 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +514 −36 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 585 passed (1 min 35 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (30 s) | | tests: horizon-client, horizon-client-render | ❌ 1188 passed, 1 failed (12 min 43 s) | | doc tests | ✅ 0 passed (7 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ❌ 382 affected, (2 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - The one failure is `entities::armor_stand_motion_tests::a_tick_keeps_the_previous_position_for_interpolation`. It fails the same on a clean `3adcfcbb3` (it needs `.local`, so CI skips it), and is #6235 / #6236. cargo stops at the first failing binary, so the remaining binaries were run separately: horizon-client-render 912 + 7 passed; horizon-client's 11 integration test binaries pass; the game binary 541 passed, 2 failed (`game::tnt::tests::a_soul_sand_bubble_column_lifts_primed_tnt`, `primed_tnt_follows_water_currents_after_moving`), both also failing on clean main and also in #6235 / #6236. - Parity: run on Windows, where the runner needs `fcntl` and can't start. The pack-screen harness was run on its own (above). - `RUST_TEST_THREADS=2` was set: on this machine the GPU render tests hang with more threads (#5238). Not tested: - In the real client, only the Resource Packs screen, at 1280x720 and GUI scale 2 (the clamp's inputs are in GUI pixels, so the window size doesn't change the result). The confirm screen's Yes/No and Leave Bed are covered by unit tests only. - After switching to isv with the screen open, the screen title and pack names stayed Afrikaans in one screenshot. Not looked into; it looks separate from this. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RodDbPWCByh96WKcbiEQpB --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:26:25 +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#6775
No description provided.