[PR #6795] [CLOSED] Title screen: show and edit the offline player name (#2055) #7098

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6795
Author: @MSedgeMC
Created: 11/2/2026
Status: ❌ Closed

Base: main ← Head: fix/2055-player-name


📝 Commits (1)

  • f7d4eec Title screen: show and edit the offline player name

📊 Changes

6 files changed (+324 additions, -5 deletions)

View changed files

📝 crates/horizon-client/assets/horizon/lang/en_us.json (+5 -0)
📝 crates/horizon-client/src/game.rs (+25 -1)
📝 crates/horizon-client/src/game/agent.rs (+3 -0)
📝 crates/horizon-client/src/game/startup_menu.rs (+9 -1)
📝 crates/horizon-client/src/offline_name.rs (+30 -0)
📝 crates/horizon-client/src/title.rs (+252 -3)

📄 Description

Vanilla takes the name a client joins with from the account the launcher started it with (Main's --username), so the player chooses it before the game runs; Horizon has no account and generated an offline name into horizon-player.txt that was invisible and uneditable in game.

What Horizon got wrong. Nothing on any screen showed or changed the offline name: a player who wanted a different name for a world or a server had to find and edit horizon-player.txt by hand, and there was no way to tell what name the game would use.

What this does. The title screen draws Player: <name> above its version line as a PlainTextButton, the same way the "Not affiliated with Mojang or Microsoft" notice at the other end of the footer already works. A press opens a screen with the name in an editable box, Done and Cancel:

  • the box takes the 16 characters a profile name takes (StringUtil.isValidPlayerName);
  • Done checks the name with offline_name::is_valid; a refused name stays on the screen and says why, leaving the name the game has alone;
  • Done writes it with offline_name::store, which writes what load_or_create reads back, so the next launch joins with it too;
  • Done returns Action::PlayerName(name), which Options::set_player_name turns into the name every later connection joins with (it also replaces an earlier --name for this run, since the player just chose one).

The screen is Horizon's own (not a vanilla one), so it narrates itself as player-name and the control socket reports {"mode": "player-name", "name", "error"}.

Proven (on the build box, ~/pushrun.py ~/horizon-worktrees/player-name):

  • cargo test -q -p horizon-client-lib --lib player_name -> 1 passed (the_player_name_line_opens_the_name_screen: a press in the drawn rect opens the screen with the current name; a press outside does nothing)
  • cargo test -q -p horizon-client-lib --lib a_chosen_name_is_stored -> 1 passed (a_chosen_name_is_stored_and_read_back: stored names come back through load_or_create, 16 characters allowed, ""/space/17 characters/é refused and the last good name kept)
  • cargo test -q -p horizon-client-lib --lib a_name_the_game -> 2 passed (Done returns Action::PlayerName("Alex_2") and returns to the title; a name with a space sets the error, returns no action and keeps the old name; Cancel leaves both alone)
  • cargo test -q -p horizon-client-lib --lib the_name_field_takes -> 1 passed (typing, backspace, and the box stopping at 16)
  • cargo test -q -p horizon-client-lib --lib title:: -> 78 passed, 0 failed
  • cargo clippy -q -p horizon-client --lib and cargo clippy -q -p horizon-client-lib --lib -> no warnings
  • rustfmt --edition 2024 --check on the five changed files -> clean

Not proven. I did not run the game: the box has no GPU, so nobody has looked at the drawn line, pressed it with a mouse or typed into the box in a real window — the tests drive the layout rects, the click, the typing and the file only. Single player is unchanged: a world's player keeps the LAN host's profile name, so this applies to server connections (and the credits screen), not to what a single-player world calls the player.

Closes #2055. verify may be red only on the pre-existing stale mod API output (xtask mod_api::tests::generated_output_is_current), which #6724 fixes.


🔄 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/6795 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/2055-player-name` --- ### 📝 Commits (1) - [`f7d4eec`](https://github.com/horizon-rust/horizon/commit/f7d4eecb47d920e48e1e99679f46ea12c0786e9b) Title screen: show and edit the offline player name ### 📊 Changes **6 files changed** (+324 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/assets/horizon/lang/en_us.json` (+5 -0) 📝 `crates/horizon-client/src/game.rs` (+25 -1) 📝 `crates/horizon-client/src/game/agent.rs` (+3 -0) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+9 -1) 📝 `crates/horizon-client/src/offline_name.rs` (+30 -0) 📝 `crates/horizon-client/src/title.rs` (+252 -3) </details> ### 📄 Description Vanilla takes the name a client joins with from the account the launcher started it with (`Main`'s `--username`), so the player chooses it before the game runs; Horizon has no account and generated an offline name into `horizon-player.txt` that was invisible and uneditable in game. **What Horizon got wrong.** Nothing on any screen showed or changed the offline name: a player who wanted a different name for a world or a server had to find and edit `horizon-player.txt` by hand, and there was no way to tell what name the game would use. **What this does.** The title screen draws `Player: <name>` above its version line as a `PlainTextButton`, the same way the "Not affiliated with Mojang or Microsoft" notice at the other end of the footer already works. A press opens a screen with the name in an editable box, Done and Cancel: - the box takes the 16 characters a profile name takes (`StringUtil.isValidPlayerName`); - Done checks the name with `offline_name::is_valid`; a refused name stays on the screen and says why, leaving the name the game has alone; - Done writes it with `offline_name::store`, which writes what `load_or_create` reads back, so the next launch joins with it too; - Done returns `Action::PlayerName(name)`, which `Options::set_player_name` turns into the name every later connection joins with (it also replaces an earlier `--name` for this run, since the player just chose one). The screen is Horizon's own (not a vanilla one), so it narrates itself as `player-name` and the control socket reports `{"mode": "player-name", "name", "error"}`. **Proven** (on the build box, `~/pushrun.py ~/horizon-worktrees/player-name`): - `cargo test -q -p horizon-client-lib --lib player_name` -> 1 passed (`the_player_name_line_opens_the_name_screen`: a press in the drawn rect opens the screen with the current name; a press outside does nothing) - `cargo test -q -p horizon-client-lib --lib a_chosen_name_is_stored` -> 1 passed (`a_chosen_name_is_stored_and_read_back`: stored names come back through `load_or_create`, 16 characters allowed, `""`/space/17 characters/`é` refused and the last good name kept) - `cargo test -q -p horizon-client-lib --lib a_name_the_game` -> 2 passed (Done returns `Action::PlayerName("Alex_2")` and returns to the title; a name with a space sets the error, returns no action and keeps the old name; Cancel leaves both alone) - `cargo test -q -p horizon-client-lib --lib the_name_field_takes` -> 1 passed (typing, backspace, and the box stopping at 16) - `cargo test -q -p horizon-client-lib --lib title::` -> 78 passed, 0 failed - `cargo clippy -q -p horizon-client --lib` and `cargo clippy -q -p horizon-client-lib --lib` -> no warnings - `rustfmt --edition 2024 --check` on the five changed files -> clean **Not proven.** I did not run the game: the box has no GPU, so nobody has looked at the drawn line, pressed it with a mouse or typed into the box in a real window — the tests drive the layout rects, the click, the typing and the file only. Single player is unchanged: a world's player keeps the LAN host's profile name, so this applies to server connections (and the credits screen), not to what a single-player world calls the player. Closes #2055. `verify` may be red only on the pre-existing stale mod API output (`xtask` `mod_api::tests::generated_output_is_current`), which #6724 fixes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:33:45 +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#7098
No description provided.