[PR #7195] [MERGED] Native screen hooks: the title's own screens (API 154) #7403

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7195
Author: @JustKarkat
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: feat/native-screen-hooks


📝 Commits (6)

  • 141ae46 Put the title's own screens on the native screen hooks
  • e341593 Merge remote-tracking branch 'origin/main' into feat/native-screen-hooks
  • aea8448 Merge remote-tracking branch 'hr/main' into fix7195
  • 85aba02 Native screen hooks: API fragment, title text routing
  • 98dff42 native_instance_dir fragment: end with a newline
  • fb3d0b8 Hook fragment for the title's screens: stampable

📊 Changes

11 files changed (+275 additions, -45 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+26 -2)
📝 crates/horizon-client/src/game/control.rs (+22 -0)
📝 crates/horizon-client/src/game/mod_api_host_generated.rs (+3 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+58 -24)
📝 crates/horizon-client/src/mod_api.rs (+4 -1)
📝 crates/horizon-client/src/mod_api/generated.rs (+22 -18)
📝 crates/horizon-client/src/mod_api/generated_host.rs (+9 -0)
📝 crates/horizon-client/src/multiplayer.rs (+18 -0)
📝 crates/horizon-client/src/title.rs (+29 -0)
📝 crates/horizon-client/src/title/tests.rs (+73 -0)
➕ tools/native-hook-fragments/native_instance_dir.json (+11 -0)

📄 Description

🤖 Opened by JustKarkat's AI agent (ZCode, on behalf of JustKarkat).

Fixes #6315.

A pack browser (Resourcify and the like) needs to put a button on Create New World and take its clicks. The screen hooks (native_screen_render_post, the mouse/wheel/key _pre hooks) only covered the screens over gameplay: the title state machine had no id and fired nothing there. This puts the title's own screens on them.

What a mod sees (API 154)

  • NativeScreenView.id gains one id per title state — title, world_select, world_create, world_create_flat, world_create_buffet, world_edit, world_backup, world_backup_confirm, world_optimize_confirm, world_optimize, low_disk_space, world_delete, world_recover, world_recovered, error, multiplayer, add_server, edit_server, direct_connect, server_delete, friends_join, disconnected, multiplayer_warning, onboarding, ban_notice — with no menu, no menu title and no slots, and the whole window as rect.
  • screen_render_post fires after the title draws its screen and before its toasts, so a mod draws its button or its whole browser over the screen it was opened from.
  • The _pre input hooks (mouse button press/release, drag, wheel, key press/release, character typed) fire on those screens and cancel as on any other: a cancelled press never reaches the title's own button.
  • A dialog, a prompt, or a server's pack prompt over the title keeps them away; a connect or a world load too.
  • Typing is untouched: the key's text stays on the key for the title's own boxes (the world name, the seed, a server's address), as it does for Options. The control socket's type now types into them as well, which it could not before.
  • native_instance_dir() is the instance folder (options.txt, saves/, resourcepacks/, shaderpacks/, horizon-mods/); a world's datapacks/ is in that world's folder.

native_mod_screen_open still opens a mod's own screen over the world only (its documented contract). Over the title a mod keeps its own screen state and draws it in screen_render_post — same drawing helpers, same click and key hooks — so nothing here needs Screen::Mod to work on the title. Lifting that restriction is a separate change (Escape and the title's own keys would need routing).

Verification

  • cargo test -p horizon-client --lib 673 passed, cargo test -p horizon-client-lib --lib 1382 passed; cargo clippy clean; cargo run -p xtask -- mod-api --check in sync; rustfmt --check clean.
  • New tests: the title states and the multiplayer screens each report their own id (reached by clicking through the real title machine).
  • Live: a throwaway trait mod (not committed) that draws a button in screen_render_post and cancels clicks in screen_mouse_button_pressed_pre, run offscreen with horizon-ctl on this branch:
    • the button draws over the title and over Create New World (screen.id = world_create), and the click hook logs the right id and pointer position;
    • with the hook returning Flow::Cancel on world_create, clicking Create New World does nothing (the game stays on the screen) — the press never reached the title's own button.

API

Adds API 154 (NATIVE_HOOKS_API, native-hooks.json helper entry, generated Host/Hooks and docs regenerated with xtask mod-api).


🔄 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/7195 **Author:** [@JustKarkat](https://github.com/JustKarkat) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/native-screen-hooks` --- ### 📝 Commits (6) - [`141ae46`](https://github.com/horizon-rust/horizon/commit/141ae4662451147a5fc8d90ead497b4aa96b3487) Put the title's own screens on the native screen hooks - [`e341593`](https://github.com/horizon-rust/horizon/commit/e341593fdf000869956fdfd21e956954c32b4cc6) Merge remote-tracking branch 'origin/main' into feat/native-screen-hooks - [`aea8448`](https://github.com/horizon-rust/horizon/commit/aea84488b30357170a8a8667f378eefc9385b3cc) Merge remote-tracking branch 'hr/main' into fix7195 - [`85aba02`](https://github.com/horizon-rust/horizon/commit/85aba02560c222ace095698999871bad132b880c) Native screen hooks: API fragment, title text routing - [`98dff42`](https://github.com/horizon-rust/horizon/commit/98dff424cfb04ace7c726129037dcaace408b76c) native_instance_dir fragment: end with a newline - [`fb3d0b8`](https://github.com/horizon-rust/horizon/commit/fb3d0b8f6f335f6ff0e7837f05d6222011cdc32c) Hook fragment for the title's screens: stampable ### 📊 Changes **11 files changed** (+275 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+26 -2) 📝 `crates/horizon-client/src/game/control.rs` (+22 -0) 📝 `crates/horizon-client/src/game/mod_api_host_generated.rs` (+3 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+58 -24) 📝 `crates/horizon-client/src/mod_api.rs` (+4 -1) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+22 -18) 📝 `crates/horizon-client/src/mod_api/generated_host.rs` (+9 -0) 📝 `crates/horizon-client/src/multiplayer.rs` (+18 -0) 📝 `crates/horizon-client/src/title.rs` (+29 -0) 📝 `crates/horizon-client/src/title/tests.rs` (+73 -0) ➕ `tools/native-hook-fragments/native_instance_dir.json` (+11 -0) </details> ### 📄 Description > 🤖 Opened by JustKarkat's AI agent (ZCode, on behalf of JustKarkat). Fixes #6315. A pack browser (Resourcify and the like) needs to put a button on **Create New World** and take its clicks. The screen hooks (`native_screen_render_post`, the mouse/wheel/key `_pre` hooks) only covered the screens over gameplay: the title state machine had no id and fired nothing there. This puts the title's own screens on them. ### What a mod sees (API 154) * `NativeScreenView.id` gains one id per title state — `title`, `world_select`, `world_create`, `world_create_flat`, `world_create_buffet`, `world_edit`, `world_backup`, `world_backup_confirm`, `world_optimize_confirm`, `world_optimize`, `low_disk_space`, `world_delete`, `world_recover`, `world_recovered`, `error`, `multiplayer`, `add_server`, `edit_server`, `direct_connect`, `server_delete`, `friends_join`, `disconnected`, `multiplayer_warning`, `onboarding`, `ban_notice` — with no `menu`, no menu `title` and no `slots`, and the whole window as `rect`. * `screen_render_post` fires after the title draws its screen and before its toasts, so a mod draws its button or its whole browser over the screen it was opened from. * The `_pre` input hooks (mouse button press/release, drag, wheel, key press/release, character typed) fire on those screens and **cancel** as on any other: a cancelled press never reaches the title's own button. * A dialog, a prompt, or a server's pack prompt over the title keeps them away; a connect or a world load too. * Typing is untouched: the key's text stays on the key for the title's own boxes (the world name, the seed, a server's address), as it does for Options. The control socket's `type` now types into them as well, which it could not before. * `native_instance_dir()` is the instance folder (`options.txt`, `saves/`, `resourcepacks/`, `shaderpacks/`, `horizon-mods/`); a world's `datapacks/` is in that world's folder. `native_mod_screen_open` still opens a mod's own screen over the world only (its documented contract). Over the title a mod keeps its own screen state and draws it in `screen_render_post` — same drawing helpers, same click and key hooks — so nothing here needs `Screen::Mod` to work on the title. Lifting that restriction is a separate change (Escape and the title's own keys would need routing). ### Verification * `cargo test -p horizon-client --lib` 673 passed, `cargo test -p horizon-client-lib --lib` 1382 passed; `cargo clippy` clean; `cargo run -p xtask -- mod-api --check` in sync; `rustfmt --check` clean. * New tests: the title states and the multiplayer screens each report their own id (reached by clicking through the real title machine). * Live: a throwaway trait mod (not committed) that draws a button in `screen_render_post` and cancels clicks in `screen_mouse_button_pressed_pre`, run offscreen with `horizon-ctl` on this branch: * the button draws over the title and over Create New World (`screen.id` = `world_create`), and the click hook logs the right id and pointer position; * with the hook returning `Flow::Cancel` on `world_create`, clicking **Create New World** does nothing (the game stays on the screen) — the press never reached the title's own button. ### API Adds API 154 (`NATIVE_HOOKS_API`, `native-hooks.json` helper entry, generated `Host`/`Hooks` and docs regenerated with `xtask mod-api`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:39:02 +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#7403
No description provided.