[PR #3423] [MERGED] GUI: screens keep vanilla's int layout at any window size #4972

Closed
opened 2026-11-03 05:09:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3423
Author: @d3grando
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3362


📝 Commits (2)

  • e889633 GUI: screens keep vanilla's int layout at any window size
  • 765cdb6 Merge main into fix-3362: keep both new multiplayer tests

📊 Changes

3 files changed (+109 additions, -36 deletions)

View changed files

📝 crates/horizon-client/src/game/screens.rs (+15 -8)
📝 crates/horizon-client/src/game/sign_edit.rs (+22 -3)
📝 crates/horizon-client/src/multiplayer.rs (+72 -25)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Fixes #3362.

Direct Connection, Add/Edit Server, Join a Friend, Connection Lost, the death screen and the sign editor's Done button computed their widget positions as w / 2.0 - 100.0 and h / 4.0 + N in floats. In vanilla, Screen.width and Screen.height are ints, so this.height / 4 drops the remainder. Horizon kept it, so these widgets landed on half or quarter GUI pixels whenever the GUI height wasn't a multiple of 4 or the GUI width was odd. That covers most maximized windows and windows resized by height. At GUI scale 3, half a GUI pixel is 1.5 device pixels: the quads get rasterized off the pixel grid, so a button's border comes out 2 pixels on one side and 3 on the other, and glyph rows come out uneven. That matches the report: "stroke being smaller and font being off".

A 960x1000 window (GUI scale 3, 320x334 GUI pixels) on Direct Connection:

horizon-ctl screen: Join Server Cancel button border, top / bottom
before (60, 191.5) (60, 215.5) 3 px / 2 px
after (60, 191) (60, 215) 3 px / 3 px

The change:

  • multiplayer.rs: half and quarter do vanilla's int division of the screen size. They're used for every button of the Edit, Direct, Friend and Disconnected screens, for the Friend/Edit field hit test and for Connection Lost's text. Centred titles follow GuiGraphicsExtractor.centeredText: width / 2 - font.width / 2.
  • game/screens.rs (death_buttons) and game/sign_edit.rs (done_button, used by both the draw and the click): the same int width / 2 - 100 and height / 4 + N. The Done label is centred as an int too.

Screens that already floored (title, pause, options lists, multiplayer list, confirm) are unchanged. The GUI scale itself was already right: HudBatch::new matches Window.calculateScale, and the surface is reconfigured on every Resized.

Not in this PR: a few other places use the same float pattern. Books' Done/Sign buttons use w / 2.0 ± … (odd widths only), as do the options screen's resource-error Done button and the flat-world presets' Select/Cancel. They follow screens with different layouts, so they're better as a separate change.

Vanilla reference

Read with javap -c -p against the 26.3 client jar:

  • DirectJoinServerScreen.init / extractRenderState: the box at width / 2 - 100, 116; buttons at height / 4 + 96 + 12 and + 120 + 12; the title through centeredText(width / 2, 20).
  • ManageServerScreen.init: width / 2 - 100, height / 4 + 72, + 96 + 18, + 120 + 18 (idiv).
  • DeathScreen.init: width / 2 - 100, height / 4 + 72 and + 96.
  • AbstractSignEditScreen.init: Done at width / 2 - 100, height / 4 + 144.
  • GuiGraphicsExtractor.centeredText(Font, Component, int, int, int): x - font.width(text) / 2.

No harness covers screen layout. The new unit tests pin the int positions: multiplayer::tests::screens_lay_out_on_whole_gui_pixels_at_any_window_size, game::screens::tests::death_buttons_sit_on_whole_gui_pixels and game::sign_edit::tests::done_button_sits_on_whole_gui_pixels. All three fail without the fix (for example left: [(113.5, 191.5), (113.5, 215.5)], right: [(113.0, 191.0), (113.0, 215.0)]) and pass with it.

Self-check

pr_ready (tools/pr_ready.py --quick on DESKTOP-J80C959, against origin/main at f3d8535fc, 33 min 36 s)

Check Result
Scope ✅ 3 files, +106 −34 (+109 −36 with the test update)
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 408 run, FAILED (failures=1, skipped=2) (52 s)
rustfmt ✅ (7 s)
clippy ✅ (54 s)
tests: horizon-client ❌ failed (30 min 41 s)
doc tests ✅ 0 passed (59 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 ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

About the two ❌ (Windows):

  • Python: test_port_publish.test_body_has_names_and_signatures_only fails on Windows on main too.
  • tests: horizon-client: this run turned up multiplayer::tests::edit_cycles_and_saves_the_server_resource_pack_setting, which hard-coded the old half-pixel x (113.5) for the Edit Server cycle button. It now expects vanilla's 427 / 2 - 100 = 113. After that update, cargo test -p horizon-client --features mods --lib --bins gives lib 1109 passed with 1 failed (save::tests::session_lock_is_exclusive, a Windows-only file-lock failure that also fails on main) and bin 141 passed. (In pr_ready's run, the lib test binary also stalled for about 30 minutes before I stopped it; run directly it finishes in under 15 s.) cargo clippy -p horizon-client --features mods --all-targets -- -D warnings and cargo fmt --check are clean on the final commit.

Screenshots

Direct Connection, 960x1000 window (GUI scale 3), zoomed 2x. Before (0.2.94 release; current main is the same), the Join Server and Cancel borders are thinner at the bottom. After, every border is 3 px:

before after
before after

🤖 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/3423 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3362` --- ### 📝 Commits (2) - [`e889633`](https://github.com/horizon-rust/horizon/commit/e8896336da140ee40b5bc2f228c96b56d0e2b9b4) GUI: screens keep vanilla's int layout at any window size - [`765cdb6`](https://github.com/horizon-rust/horizon/commit/765cdb6bb09fe019cb506df78e1b6e804e4a2c44) Merge main into fix-3362: keep both new multiplayer tests ### 📊 Changes **3 files changed** (+109 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/screens.rs` (+15 -8) 📝 `crates/horizon-client/src/game/sign_edit.rs` (+22 -3) 📝 `crates/horizon-client/src/multiplayer.rs` (+72 -25) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3362. Direct Connection, Add/Edit Server, Join a Friend, Connection Lost, the death screen and the sign editor's Done button computed their widget positions as `w / 2.0 - 100.0` and `h / 4.0 + N` in floats. In vanilla, `Screen.width` and `Screen.height` are ints, so `this.height / 4` drops the remainder. Horizon kept it, so these widgets landed on half or quarter GUI pixels whenever the GUI height wasn't a multiple of 4 or the GUI width was odd. That covers most maximized windows and windows resized by height. At GUI scale 3, half a GUI pixel is 1.5 device pixels: the quads get rasterized off the pixel grid, so a button's border comes out 2 pixels on one side and 3 on the other, and glyph rows come out uneven. That matches the report: "stroke being smaller and font being off". A 960x1000 window (GUI scale 3, 320x334 GUI pixels) on Direct Connection: | | `horizon-ctl screen`: Join Server | Cancel | button border, top / bottom | |---|---|---|---| | before | (60, **191.5**) | (60, **215.5**) | 3 px / **2 px** | | after | (60, 191) | (60, 215) | 3 px / 3 px | The change: - `multiplayer.rs`: `half` and `quarter` do vanilla's int division of the screen size. They're used for every button of the Edit, Direct, Friend and Disconnected screens, for the Friend/Edit field hit test and for Connection Lost's text. Centred titles follow `GuiGraphicsExtractor.centeredText`: `width / 2 - font.width / 2`. - `game/screens.rs` (`death_buttons`) and `game/sign_edit.rs` (`done_button`, used by both the draw and the click): the same int `width / 2 - 100` and `height / 4 + N`. The Done label is centred as an int too. Screens that already floored (title, pause, options lists, multiplayer list, confirm) are unchanged. The GUI scale itself was already right: `HudBatch::new` matches `Window.calculateScale`, and the surface is reconfigured on every `Resized`. Not in this PR: a few other places use the same float pattern. Books' Done/Sign buttons use `w / 2.0 ± …` (odd widths only), as do the options screen's resource-error Done button and the flat-world presets' Select/Cancel. They follow screens with different layouts, so they're better as a separate change. ## Vanilla reference Read with `javap -c -p` against the 26.3 client jar: - `DirectJoinServerScreen.init` / `extractRenderState`: the box at `width / 2 - 100, 116`; buttons at `height / 4 + 96 + 12` and `+ 120 + 12`; the title through `centeredText(width / 2, 20)`. - `ManageServerScreen.init`: `width / 2 - 100`, `height / 4 + 72`, `+ 96 + 18`, `+ 120 + 18` (`idiv`). - `DeathScreen.init`: `width / 2 - 100`, `height / 4 + 72` and `+ 96`. - `AbstractSignEditScreen.init`: Done at `width / 2 - 100, height / 4 + 144`. - `GuiGraphicsExtractor.centeredText(Font, Component, int, int, int)`: `x - font.width(text) / 2`. No harness covers screen layout. The new unit tests pin the int positions: `multiplayer::tests::screens_lay_out_on_whole_gui_pixels_at_any_window_size`, `game::screens::tests::death_buttons_sit_on_whole_gui_pixels` and `game::sign_edit::tests::done_button_sits_on_whole_gui_pixels`. All three fail without the fix (for example `left: [(113.5, 191.5), (113.5, 215.5)]`, `right: [(113.0, 191.0), (113.0, 215.0)]`) and pass with it. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-J80C959, against origin/main at f3d8535fc, 33 min 36 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +106 −34 (+109 −36 with the test update) | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 408 run, FAILED (failures=1, skipped=2) (52 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (54 s) | | tests: horizon-client | ❌ failed (30 min 41 s) | | doc tests | ✅ 0 passed (59 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 | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | About the two ❌ (Windows): - Python: `test_port_publish.test_body_has_names_and_signatures_only` fails on Windows on main too. - tests: horizon-client: this run turned up `multiplayer::tests::edit_cycles_and_saves_the_server_resource_pack_setting`, which hard-coded the old half-pixel x (`113.5`) for the Edit Server cycle button. It now expects vanilla's `427 / 2 - 100 = 113`. After that update, `cargo test -p horizon-client --features mods --lib --bins` gives lib 1109 passed with 1 failed (`save::tests::session_lock_is_exclusive`, a Windows-only file-lock failure that also fails on main) and bin 141 passed. (In pr_ready's run, the lib test binary also stalled for about 30 minutes before I stopped it; run directly it finishes in under 15 s.) `cargo clippy -p horizon-client --features mods --all-targets -- -D warnings` and `cargo fmt --check` are clean on the final commit. ## Screenshots Direct Connection, 960x1000 window (GUI scale 3), zoomed 2x. Before (0.2.94 release; current main is the same), the Join Server and Cancel borders are thinner at the bottom. After, every border is 3 px: | before | after | |---|---| | ![before](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/gui-whole-pixels-before.png) | ![after](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/gui-whole-pixels-after.png) | 🤖 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 05:09:17 +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#4972
No description provided.