Merge pull request #1271 from ludovic111/feat/vanilla-menus

🤖 Agent: merged after verify passed. Local proof on the merged head bf274d92: fmt, clippy -D warnings, client and launcher tests, parity --changed origin/main, and test_friends.py --server-thread. CI parity passed on the earlier head. Every Horizon setting is reachable from vanilla-style screens (list in the PR body).
This commit is contained in:
Ludovic Marie
2026-10-23 00:56:15 +02:00
committed by GitHub
73 changed files with 800 additions and 5184 deletions
-3
View File
@@ -188,9 +188,6 @@ jobs:
retry "$launcher" install latest
"$launcher" versions --installed
"$launcher" links --json
"$launcher" menu-style classic
grep -qx 'menuStyle:classic' "$HORIZON_HOME/horizon.txt"
"$launcher" menu-style horizon
clients=("$HORIZON_LAUNCHER_HOME"/versions/v*/horizon-client*)
client="${clients[0]}"
echo "installed client: $client"
+3 -3
View File
@@ -46,7 +46,7 @@ The [documentation](https://playhorizon.dev/docs/) covers each of these.
- **The game:** singleplayer with vanilla's world generation, mobs, villagers, raids, redstone, every command, the HUD and the recipe book, on saves in vanilla's format. Worlds from 1.8 to 26.2 are upgraded as vanilla does. [Status table](#project-status).
- **Horizon's own extras:** new menus (vanilla's are one setting away), graphics presets, distant terrain up to 1024 chunks, controller support, optional zoom, minimap and more, all off by default where they would change the vanilla look. See [Settings](https://playhorizon.dev/docs/settings).
- **Resource packs, shader packs and data packs:** resource packs work, Java shader packs run their full-screen effects (experimental), and data packs load functions, predicates and item modifiers.
- **Playing with others:** invite friends from the pause menu with a code, Open to LAN, and joining offline-mode servers. Horizon cannot sign in to a Microsoft account yet, so it cannot join servers that check accounts. See [Multiplayer](https://playhorizon.dev/docs/multiplayer).
- **Playing with others:** invite friends from the pause menu's Friends button with a code, Open to LAN, and joining offline-mode servers. Horizon cannot sign in to a Microsoft account yet, so it cannot join servers that check accounts. See [Multiplayer](https://playhorizon.dev/docs/multiplayer).
- **Mods:** Horizon has its own mod system (Rust compiled to WebAssembly). Java mod jars do not run. See [Mods and data packs](https://playhorizon.dev/docs/mods).
Screenshots, captured in the Rust client itself with vanilla assets and no mods or shaders:
@@ -56,8 +56,8 @@ Screenshots, captured in the Rust client itself with vanilla assets and no mods
<td colspan="2"><img src="docs/media/sunset.webp" alt="Sunset over a savanna river valley and a plains village"></td>
</tr>
<tr>
<td width="50%"><img src="docs/media/menu-title.webp" alt="Horizon's title screen over a veiled snowy landscape"></td>
<td width="50%"><img src="docs/media/settings.webp" alt="The Video settings in their Simple view: a preset, render distance, field of view, framerate, VSync and GUI scale, each with what it costs"></td>
<td width="50%"><img src="docs/media/survival.webp" alt="Survival at dusk: a zombie walks up, with the hotbar, health, hunger and experience"></td>
<td width="50%"><img src="docs/media/settings.webp" alt="Vanilla's Video Settings screen with Horizon's own buttons at the top: Horizon Graphics, Advanced Graphics and Shader Packs"></td>
</tr>
<tr>
<td width="50%"><img src="docs/media/village.webp" alt="A plains village among savanna hills, with farms, villagers and an iron golem"></td>
+303
View File
@@ -0,0 +1,303 @@
//! Play with Friends: Horizon's own sharing of the open world behind an
//! invite code (`game/friends.rs`). The pause menu's Friends button, the icon
//! vanilla's PauseScreen already has, opens it. It is drawn the way a mod adds
//! a screen to vanilla: the menu background, a centred title and text,
//! vanilla's buttons and Done in the footer.
use crate::{
hud::{HudAtlas, HudBatch, rgba},
multiplayer::wrap,
text::Text,
ui,
};
pub const TITLE: &str = "Play with Friends";
/// What the screen shows (game/friends.rs fills it).
#[derive(Clone, Debug, Default)]
pub struct FriendsView {
/// A singleplayer world (not a server): sharing is offered.
pub shown: bool,
pub sharing: bool,
pub code: Option<String>,
/// Who can join and what to do when friends on the internet can't (or,
/// before the code, what the game is doing).
pub status: String,
/// Friends on the internet can reach the host.
pub reachable: bool,
/// Where the troubleshooting is, when they can't.
pub help: Option<String>,
/// The players in the world besides the host.
pub guests: Vec<String>,
pub notice: Option<String>,
/// The code was just copied.
pub copied: bool,
}
/// A button's action.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Action {
Share,
Copy,
Stop,
/// Open the troubleshooting page.
Help,
Done,
}
fn grey() -> u32 {
rgba(160, 160, 160, 255)
}
const WHITE: u32 = u32::MAX;
const HINT: &str = "Friends paste the code after the title screen's Friends button, in Direct Connection, or on the launcher's Play page.";
struct Button {
x: f32,
y: f32,
w: f32,
label: &'static str,
action: Action,
active: bool,
}
/// The centred lines (text, colour, y) and the buttons.
fn layout(
atlas: &HudAtlas,
(w, h): (f32, f32),
view: &FriendsView,
) -> (Vec<(String, u32, f32)>, Vec<Button>) {
let width = (w - 40.0).min(310.0);
let cx = (w / 2.0).floor();
let mut lines = Vec::new();
let mut y = 40.0;
let add = |lines: &mut Vec<(String, u32, f32)>, text: &str, color: u32, y: &mut f32| {
for line in wrap(text, width, atlas) {
lines.push((line, color, *y));
*y += 10.0;
}
};
let mut buttons = Vec::new();
if view.sharing {
lines.push(("Invite Code".to_owned(), grey(), y));
y += 12.0;
match &view.code {
Some(code) => {
for line in code_lines(atlas, code, width) {
lines.push((line, WHITE, y));
y += 10.0;
}
}
None => add(&mut lines, &view.status, WHITE, &mut y),
}
y += 6.0;
buttons.push(Button {
x: cx - 154.0,
y,
w: 150.0,
label: if view.copied { "Copied" } else { "Copy Code" },
action: Action::Copy,
active: view.code.is_some(),
});
buttons.push(Button {
x: cx + 4.0,
y,
w: 150.0,
label: "Stop Sharing",
action: Action::Stop,
active: true,
});
y += 30.0;
if view.code.is_some() {
// Who can join: grey when friends anywhere can, white (it asks
// for something) when only the LAN and VPNs can.
let tint = if view.reachable { grey() } else { WHITE };
add(&mut lines, &view.status, tint, &mut y);
y += 4.0;
}
let here = if view.guests.is_empty() {
"No friends here yet.".to_owned()
} else {
format!("Here now: {}", view.guests.join(", "))
};
add(&mut lines, &here, grey(), &mut y);
if let Some(notice) = &view.notice {
add(&mut lines, notice, WHITE, &mut y);
}
// Where friends paste the code, while it fits above the footer.
if y + 10.0 * wrap(HINT, width, atlas).len() as f32 <= h - 33.0 {
add(&mut lines, HINT, grey(), &mut y);
}
} else {
add(
&mut lines,
"Share this world behind an invite code: it opens to LAN, and friends on the internet join with the code. No server of ours is involved.",
WHITE,
&mut y,
);
y += 4.0;
add(&mut lines, HINT, grey(), &mut y);
buttons.push(Button {
x: cx - 100.0,
y: y + 8.0,
w: 200.0,
label: "Start Sharing",
action: Action::Share,
active: view.shown,
});
}
// HeaderAndFooterLayout's footer: Done, beside Troubleshooting when
// friends on the internet can't reach the host.
if view.sharing && view.help.is_some() {
buttons.push(Button {
x: cx - 154.0,
y: h - 27.0,
w: 150.0,
label: "Troubleshooting...",
action: Action::Help,
active: true,
});
buttons.push(Button {
x: cx + 4.0,
y: h - 27.0,
w: 150.0,
label: "gui.done",
action: Action::Done,
active: true,
});
} else {
buttons.push(Button {
x: cx - 100.0,
y: h - 27.0,
w: 200.0,
label: "gui.done",
action: Action::Done,
active: true,
});
}
(lines, buttons)
}
/// The code's groups packed into lines of at most `width`.
fn code_lines(atlas: &HudAtlas, code: &str, width: f32) -> Vec<String> {
let mut lines: Vec<String> = Vec::new();
for group in code.split('-') {
match lines.last_mut() {
Some(l) if HudBatch::text_width(atlas, &format!("{l}-{group}")) <= width => {
l.push('-');
l.push_str(group);
}
_ => lines.push(group.to_owned()),
}
}
lines
}
fn label(key: &str) -> Text {
if key.starts_with("gui.") {
Text::translate(key, &[])
} else {
Text::literal(key)
}
}
pub fn draw(
batch: &mut HudBatch,
atlas: &HudAtlas,
cursor: (f32, f32),
view: &FriendsView,
in_world: bool,
) {
let (w, h) = (batch.width, batch.height);
ui::menu_background(batch, atlas, 0.0, 0.0, w, h, in_world);
let title = Text::literal(TITLE);
let tw = atlas.font.width_text(&title);
batch.text_styled(atlas, &title, ((w - tw) / 2.0).floor(), 15.0, WHITE, true);
let (lines, buttons) = layout(atlas, (w, h), view);
for (line, color, y) in lines {
let lw = HudBatch::text_width(atlas, &line);
batch.text(atlas, &line, ((w - lw) / 2.0).floor(), y, color, true);
}
for b in buttons {
let hover = b.active && ui::hovered(cursor, b.x, b.y, b.w, 20.0);
ui::button(
batch,
atlas,
b.x,
b.y,
b.w,
20.0,
&label(b.label),
b.active,
hover,
);
}
}
/// The button under a click, if it is active.
pub fn click(
atlas: &HudAtlas,
size: (f32, f32),
cursor: (f32, f32),
view: &FriendsView,
) -> Option<Action> {
layout(atlas, size, view)
.1
.into_iter()
.find(|b| b.active && ui::hovered(cursor, b.x, b.y, b.w, 20.0))
.map(|b| b.action)
}
#[cfg(test)]
mod tests {
use super::*;
fn atlas() -> HudAtlas {
HudAtlas::build(std::path::Path::new("/nonexistent/horizon-test-assets")).unwrap()
}
#[test]
fn share_then_copy_and_stop() {
let atlas = atlas();
let size = (427.0, 240.0);
let idle = FriendsView {
shown: true,
..FriendsView::default()
};
let (_, buttons) = layout(&atlas, size, &idle);
let share = buttons.iter().find(|b| b.action == Action::Share).unwrap();
assert_eq!(
click(&atlas, size, (share.x + 1.0, share.y + 1.0), &idle),
Some(Action::Share)
);
let sharing = FriendsView {
shown: true,
sharing: true,
status: "Finding how friends can reach you…".into(),
..FriendsView::default()
};
let (_, buttons) = layout(&atlas, size, &sharing);
let copy = buttons.iter().find(|b| b.action == Action::Copy).unwrap();
assert!(!copy.active, "nothing to copy before the code");
let with_code = FriendsView {
code: Some("0B33K-Q405Q-1Z5CV-X6NHY-R12N0-VK8T1-60N00-RA134-952PE-1HA08-910P0-K5M01-ST1NB-JDTB6-K4W1P-0".into()),
status: "Friends on your network or VPN can join. For friends on the internet: turn on UPnP on your router, or forward TCP port 25580 to 10.0.0.2, or use a relay, or a VPN such as Tailscale or ZeroTier (the code already holds your VPN address).".into(),
help: Some("https://example.invalid/help".into()),
..sharing
};
let (lines, buttons) = layout(&atlas, size, &with_code);
assert!(
lines.iter().all(|(_, _, y)| y + 9.0 <= size.1 - 27.0),
"the text stays above the footer"
);
for action in [Action::Copy, Action::Stop, Action::Help, Action::Done] {
let b = buttons.iter().find(|b| b.action == action).unwrap();
assert_eq!(
click(&atlas, size, (b.x + 1.0, b.y + 1.0), &with_code),
Some(action)
);
}
}
#[test]
fn a_server_offers_no_sharing() {
let atlas = atlas();
let view = FriendsView::default();
let (_, buttons) = layout(&atlas, (427.0, 240.0), &view);
let share = buttons.iter().find(|b| b.action == Action::Share).unwrap();
assert!(!share.active);
}
}
File diff suppressed because it is too large Load Diff
+46 -125
View File
@@ -5,7 +5,6 @@ mod advancements_screen;
mod agent;
mod allays;
mod armor_stands;
mod backdrop;
mod banners;
mod beacon;
mod beehives;
@@ -457,6 +456,9 @@ enum Screen {
Advancements,
/// WorldOptionsScreen (game/lan_screen.rs).
WorldOptions,
/// Play with Friends, from the pause menu's Friends button
/// (`friends_screen`, game/friends.rs).
Friends,
/// CommandBlockEditScreen (game/command_blocks.rs).
CommandBlock,
}
@@ -1317,10 +1319,6 @@ struct Game<'a> {
settings: Settings,
/// Where the options screen returns: true = title, false = pause menu.
options_from_title: bool,
/// The live title backdrop (game/backdrop.rs).
backdrop: backdrop::Backdrop,
/// When the pause menu opened (Horizon style's entrance).
pause_since: Option<Instant>,
dragging: bool,
/// `ClientAvatarState`: walked distance and view bob.
avatar: horizon_client::camera::AvatarBob,
@@ -4457,6 +4455,7 @@ impl Game<'_> {
| Screen::Stats
| Screen::Advancements
| Screen::WorldOptions
| Screen::Friends
| Screen::CommandBlock
) || self.book.is_some())
}
@@ -4684,20 +4683,12 @@ impl Game<'_> {
}
}
if let Some(title) = &self.title {
if horizon_client::ui_theme::horizon() {
let fade = self.backdrop_fade();
let mut ui =
horizon_client::ui_theme::Ui::new(&self.gui.atlas, &mut batch, self.cursor);
title.draw_horizon(&mut ui, fade);
ui.finish();
} else {
title.draw(
&self.gui.atlas,
&mut batch,
self.cursor,
self.settings.file.bool("hideSplashTexts"),
);
}
title.draw(
&self.gui.atlas,
&mut batch,
self.cursor,
self.settings.file.bool("hideSplashTexts"),
);
return batch;
}
let atlas_ptr: *const HudAtlas = &self.gui.atlas;
@@ -4714,9 +4705,7 @@ impl Game<'_> {
// the sleep overlay, debug screen and open screens still draw.
let spectator = self.spectator();
let (wi, hi) = (w as i32, h as i32);
// Horizon's pause menu sits over the blurred world alone.
let horizon_pause = self.horizon_pause();
let show_hud = !self.ui.hide_gui && !horizon_pause;
let show_hud = !self.ui.hide_gui;
if show_hud {
self.draw_spyglass(&mut batch);
// Hud.extractCrosshair / extractItemHotbar / extractPlayerHealth /
@@ -4850,10 +4839,8 @@ impl Game<'_> {
let tw = HudBatch::text_width(atlas, text);
batch.text(atlas, text, (w - tw) / 2.0, h - 59.0, u32::MAX, true);
}
if !horizon_pause {
self.draw_chat(&mut batch);
self.draw_tab_list(&mut batch);
}
self.draw_chat(&mut batch);
self.draw_tab_list(&mut batch);
// Screen.extractBlurredBackground blurs the world and HUD, while the
// screen's background, widgets, toasts and debug overlay stay sharp.
batch.blur_at = batch.vertices.len() as u32;
@@ -4877,6 +4864,7 @@ impl Game<'_> {
Screen::Stats => self.draw_stats(&mut batch),
Screen::Advancements => self.draw_advancements(&mut batch),
Screen::WorldOptions => self.draw_world_options(&mut batch),
Screen::Friends => self.draw_friends_screen(&mut batch),
Screen::CommandBlock => self.draw_command_block(&mut batch),
Screen::Inventory => {
self.draw_inventory(&mut batch);
@@ -9600,12 +9588,7 @@ impl Game<'_> {
// Camera.getCameraEntityPartialTicks: the view, the hand and the
// player's own model stay smooth while the level is frozen.
let camera_alpha = self.clock.camera_fraction();
let live = self.backdrop_live();
let view = if live {
self.backdrop_view()
} else {
self.camera_view(camera_alpha as f32)
};
let view = self.camera_view(camera_alpha as f32);
let (camera, underwater, view_yaw, view_pitch) = match view {
Some((c, yaw, pitch)) => {
let s =
@@ -9753,9 +9736,7 @@ impl Game<'_> {
// LevelLoadingScreen (Reason.OTHER) draws the title's panorama.
let title = self.title.is_some()
|| self.loading_reason() == Some(horizon_client::level_loading::Reason::Other);
let (yaw, pitch) = if live {
(view_yaw, view_pitch)
} else if title {
let (yaw, pitch) = if title {
// PanoramaRenderer: the title cube spins at 0.1 degrees per tick, pitched 10 degrees.
(
self.panorama_rotation.update(
@@ -9767,9 +9748,7 @@ impl Game<'_> {
} else {
(view_yaw, view_pitch)
};
let fov_degrees = if live {
72.0
} else if title {
let fov_degrees = if title {
85.0
} else {
self.fov_degrees(camera_alpha as f32, camera.to_array())
@@ -9820,7 +9799,7 @@ impl Game<'_> {
}
.to_owned()
};
let (celestial, stars) = if title && !live {
let (celestial, stars) = if title {
(Vec::new(), None)
} else if self.dim == Dim::Overworld
&& self.potions.effects.get("darkness").is_none()
@@ -9846,12 +9825,11 @@ impl Game<'_> {
if !title {
self.end_geometry(camera, &mut entities);
}
let weather =
if (!title || live) && self.dim == Dim::Overworld && self.settings.horizon.weather {
horizon_client::spans::time("weather", || self.weather_geometry(camera, alpha))
} else {
Vec::new()
};
let weather = if !title && self.dim == Dim::Overworld && self.settings.horizon.weather {
horizon_client::spans::time("weather", || self.weather_geometry(camera, alpha))
} else {
Vec::new()
};
let border = (!title)
.then(|| self.border_draw(camera.to_array(), alpha as f32))
.flatten();
@@ -9876,7 +9854,7 @@ impl Game<'_> {
detail_distance: (self.streaming.radius * 16) as f32,
depth_far,
underwater,
title: title && !live,
title,
skybox: self.dim == Dim::Overworld && self.settings.horizon.sky,
end_sky: self.dim == Dim::End && self.settings.horizon.sky,
end_sky_sprite: self
@@ -9910,7 +9888,7 @@ impl Game<'_> {
debug_lines_on_top: &debug_lines_on_top,
debug_crosshair: &debug_crosshair,
hud: &hud,
clouds: ((!title || live)
clouds: (!title
&& self.dim == Dim::Overworld
&& horizon_client::clouds::visible(&clouds_mode, sky.cloud_color[3]))
.then(|| self.gui.atlas.sprites.get("horizon/white"))
@@ -9965,13 +9943,6 @@ impl Game<'_> {
darkness: self.darkness_lighting(alpha as f32),
night_vision: self.night_vision_intensity(),
block_flicker: self.fog.block_light_flicker,
post: if live {
Some(horizon_client::post::PostGrade::FROST)
} else if self.horizon_pause() {
Some(horizon_client::post::PostGrade::PAUSE)
} else {
None
},
menu_blur: self.menu_blur(),
};
let result = match self.renderer.as_mut() {
@@ -10043,15 +10014,14 @@ impl Game<'_> {
/// HUD, when `menuBackgroundBlurriness` is at least 1.
fn menu_blur(&self) -> Option<f32> {
let loading = self.loading_reason() == Some(horizon_client::level_loading::Reason::Other);
let blurred = !horizon_client::ui_theme::horizon()
&& (loading
|| self.title.as_ref().is_some_and(|t| {
self.screen == Screen::Options
|| !matches!(t.mode, horizon_client::title::Mode::Main)
})
|| (self.title.is_none()
&& self.player.is_some()
&& self.screen.blurs_background(self.pause_menu)));
let blurred = loading
|| self.title.as_ref().is_some_and(|t| {
self.screen == Screen::Options
|| !matches!(t.mode, horizon_client::title::Mode::Main)
})
|| (self.title.is_none()
&& self.player.is_some()
&& self.screen.blurs_background(self.pause_menu));
let radius = self.settings.menu_blur as f32;
(blurred && radius >= 1.0).then_some(radius)
}
@@ -10130,7 +10100,7 @@ impl Game<'_> {
}
Screen::GameModeSwitcher => self.close_gamemode_switcher(false),
Screen::Dead => {}
Screen::Stats => self.screen = Screen::Paused,
Screen::Stats | Screen::Friends => self.screen = Screen::Paused,
Screen::Advancements => self.close_advancements(),
Screen::WorldOptions => self.world_options_escape(),
Screen::CommandBlock => self.close_command_block(),
@@ -10604,15 +10574,6 @@ impl ApplicationHandler for Game<'_> {
) {
self.last_input = Instant::now();
}
if let WindowEvent::MouseInput {
state,
button: MouseButton::Left,
..
} = &event
{
// The press state of Horizon-style buttons.
horizon_client::ui_theme::set_pressed(*state == ElementState::Pressed);
}
if (self.pending_entry.is_some() || self.world_loader.is_some())
&& matches!(&event, WindowEvent::KeyboardInput { event, .. }
if event.state == ElementState::Pressed
@@ -10712,9 +10673,7 @@ impl ApplicationHandler for Game<'_> {
if matches!(self.screen, Screen::Inventory | Screen::Creative) {
self.inventory_drag_move();
}
if let Some(title) = &mut self.title
&& !horizon_client::ui_theme::horizon()
{
if let Some(title) = &mut self.title {
title.drag(self.cursor, (b.width, b.height));
title.drag_field(&self.gui.atlas, self.cursor.0);
}
@@ -10740,9 +10699,7 @@ impl ApplicationHandler for Game<'_> {
}) * wheel_sensitivity
};
let d = scaled(raw_y) as f32;
if let Some(title) = &mut self.title
&& !horizon_client::ui_theme::horizon()
{
if let Some(title) = &mut self.title {
let size = self
.window
.as_ref()
@@ -10830,21 +10787,13 @@ impl ApplicationHandler for Game<'_> {
.as_ref()
.map(|r| [r.config.width, r.config.height])
.unwrap_or([1, 1]);
let mut b = HudBatch::new(size);
let b = HudBatch::new(size);
let atlas = &self.gui.atlas;
let shift = self.has_shift_down();
let (action, sound) = self.title.as_mut().map_or((Action::None, false), |t| {
if horizon_client::ui_theme::horizon() {
(
t.click_horizon(atlas, &mut b, self.cursor.0, self.cursor.1),
false,
)
} else {
let clicked =
t.click(self.cursor.0, self.cursor.1, (b.width, b.height));
t.press_field(atlas, self.cursor, (b.width, b.height), shift);
clicked
}
let clicked = t.click(self.cursor.0, self.cursor.1, (b.width, b.height));
t.press_field(atlas, self.cursor, (b.width, b.height), shift);
clicked
});
self.save_title_options();
if sound {
@@ -10980,6 +10929,9 @@ impl ApplicationHandler for Game<'_> {
Screen::WorldOptions if pressed && button == MouseButton::Left => {
self.world_options_click()
}
Screen::Friends if pressed && button == MouseButton::Left => {
self.friends_screen_click()
}
Screen::CommandBlock if pressed && button == MouseButton::Left => {
self.command_block_click()
}
@@ -11079,9 +11031,7 @@ impl ApplicationHandler for Game<'_> {
}
}
WindowEvent::KeyboardInput { event, .. } if self.title.is_some() => {
if event.state == ElementState::Pressed
&& self.title.as_ref().is_some_and(|t| !t.skip_opening())
{
if event.state == ElementState::Pressed {
if let Some(shortcut) = self.edit_shortcut(&event) {
self.title_shortcut(shortcut);
return Ok(());
@@ -11174,11 +11124,6 @@ impl ApplicationHandler for Game<'_> {
+ (turn(KeyCode::ArrowDown) - turn(KeyCode::ArrowUp)) * 90.0 * secs)
.clamp(-90.0, 90.0);
}
self.update_backdrop()?;
horizon_client::ui_theme::set_backdrop(self.backdrop_fade());
if self.screen != Screen::Paused {
self.pause_since = None;
}
if self.title.is_none() {
horizon_client::spans::time("update_world", || self.update_world());
horizon_client::spans::time("spawn_player", || self.spawn_player())?;
@@ -11200,8 +11145,6 @@ impl ApplicationHandler for Game<'_> {
}
self.tick_ambience();
self.tick_fov();
} else if self.title.is_some() {
self.tick_backdrop();
}
self.tick_music();
self.tick_sound_engine();
@@ -11612,8 +11555,6 @@ impl<'a> Game<'a> {
hand_strength: Default::default(),
settings,
options_from_title: false,
backdrop: Default::default(),
pause_since: None,
dragging: false,
avatar: Default::default(),
flash: 0,
@@ -11986,13 +11927,11 @@ impl Progress {
/// Harness and dedicated runs keep the fully-synchronous startup so their
/// output stays byte-identical; only an ordinary launch shows the window first.
fn synchronous_startup(options: &Options) -> bool {
let classic = std::env::var("HORIZON_MENU_STYLE").ok().as_deref() == Some("classic");
options.frames.is_some()
|| options.world_frames.is_some()
|| options.benchmark.is_some()
|| options.control.is_some()
|| options.dedicated.is_some()
|| classic
|| std::env::var_os("HORIZON_DISPENSE_FIXTURE").is_some()
|| std::env::var_os("HORIZON_SCULK_FIXTURE").is_some()
|| std::env::var_os("HORIZON_COMMAND_SCRIPT").is_some()
@@ -12013,7 +11952,7 @@ fn load_resources(
let requested_root = root.clone();
let threads = settings.horizon.worker_threads();
// Stage A: the menu bundle (atlas and panorama). With a loading screen it is
// published at once so the title backdrop can appear while the world bundle
// published at once so the title screen can appear while the world bundle
// loads; the synchronous launch instead carries it in `Loaded`.
let mut loaded_gui = None;
let mut ui_ready = false;
@@ -12434,7 +12373,6 @@ fn loading_frame(hud: &HudBatch) -> Frame<'_> {
darkness: (0.0, 0.0),
night_vision: 0.0,
block_flicker: 0.0,
post: None,
menu_blur: None,
shader: Default::default(),
}
@@ -12461,18 +12399,8 @@ fn start_game<'a>(
let handoff = prepared.is_some();
let mut settings = match settings {
Some(settings) => settings,
None => {
horizon_client::ui_theme::load_preferences(&std::env::current_dir()?);
Settings::load(&std::env::current_dir()?.join("options.txt"))
}
None => Settings::load(&std::env::current_dir()?.join("options.txt")),
};
// Scripted and frame-limited runs (the parity harnesses) see vanilla's
// screens unless HORIZON_MENU_STYLE asks otherwise.
if (options.frames.is_some() || options.control.is_some())
&& std::env::var_os("HORIZON_MENU_STYLE").is_none()
{
horizon_client::ui_theme::set_style(horizon_client::ui_theme::MenuStyle::Classic);
}
if let Some(d) = options.distance_override {
settings.render_distance = d;
}
@@ -12578,12 +12506,6 @@ fn start_game<'a>(
&game.options.resources,
);
title.last_server = game.settings.file.string("lastServer");
// The launcher's opening, once per session and only in Horizon's style.
if horizon_client::ui_theme::horizon() && game.options.frames.is_none() {
title
.opening
.set(Some(horizon_client::front::Opening::new()));
}
game.title = Some(title);
}
}
@@ -12941,7 +12863,6 @@ fn run_loading(
pack_error: Option<String>,
started: Instant,
) -> Result<()> {
horizon_client::ui_theme::load_preferences(&std::env::current_dir()?);
let progress = Progress::new();
let (receiver, loader) =
startup_menu::spawn_loader(&options, &settings, &vanilla_root, started, &progress)?;
+1
View File
@@ -403,6 +403,7 @@ impl Game<'_> {
Screen::Stats => "stats",
Screen::Advancements => "advancements",
Screen::WorldOptions => "world-options",
Screen::Friends => "friends",
Screen::CommandBlock => "command-block",
}
}
-303
View File
@@ -1,303 +0,0 @@
//! The live title backdrop (Menu style: Horizon): a frozen landscape that
//! Horizon generates and renders itself behind the title screens, seen
//! through a slow orbiting camera, falling snow, an overcast sky and the cold
//! blur and grade of `gfx::PostGrade`. Nothing is bundled: the chunks come
//! from the vanilla generator for a fixed seed and are cached in
//! `saves/.horizon-title/backdrop` (no level.dat, so no world list entry).
//! The ice-spikes spot is found once with `/locate biome`'s search and kept
//! in `spot.txt` there. The generator is built and the spot found on a
//! worker, so the title keeps drawing its panorama until both are ready.
use super::Game;
use horizon_client::{
Result,
save::{Persistent, SaveDir},
streaming::Streaming,
vanillagen::VanillaTerrain,
world::{Weather, World},
};
use horizon_core::biome::{BiomeZoom, obfuscate_seed};
use std::{
sync::{Arc, Mutex},
time::Instant,
};
/// The world the backdrop is cut from (HORIZON_BACKDROP_SEED overrides it).
const SEED: i64 = 2_026_031_337;
/// The biome the camera looks for.
const BIOME: &str = "minecraft:ice_spikes";
/// Late morning: the snow reads clearly; the grade (`PostGrade::FROST`) makes it cold.
const DAY_TIME: i64 = 4_000;
/// The worker's result: the generator for [`SEED`], or why it failed.
type Built = std::result::Result<Arc<VanillaTerrain>, String>;
#[derive(Default)]
pub(super) struct Backdrop {
pub active: bool,
/// The generator, once the worker has built it; taken when it is installed.
terrain: Arc<Mutex<Option<Built>>>,
/// The generator streams the backdrop's chunks.
installed: bool,
/// The search for the spot, then the spot (block x, z).
spot: Arc<Mutex<Option<Option<(i32, i32)>>>>,
centred: bool,
/// Camera position once the ground under it has loaded.
pub camera: Option<glam::DVec3>,
pub ready: Option<Instant>,
pub started: Option<Instant>,
}
fn seed() -> i64 {
std::env::var("HORIZON_BACKDROP_SEED")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(SEED)
}
impl Game<'_> {
/// How visible the live backdrop is (0 until its first chunks are drawn).
pub(super) fn backdrop_fade(&self) -> f32 {
let Some(at) = self.backdrop.ready else {
return 0.0;
};
let x = (at.elapsed().as_secs_f32() / 1.6).clamp(0.0, 1.0);
x * x * (3.0 - 2.0 * x)
}
/// Whether the frame should draw the backdrop world instead of the panorama.
pub(super) fn backdrop_live(&self) -> bool {
self.title.is_some() && self.backdrop.active && self.backdrop.camera.is_some()
}
/// The orbiting camera: position, yaw and pitch.
pub(super) fn backdrop_view(&self) -> Option<(glam::DVec3, f32, f32)> {
let c = self.backdrop.camera?;
let t = self
.backdrop
.started
.map_or(0.0, |s| s.elapsed().as_secs_f32());
// A full turn in about six minutes.
let yaw = (200.0 + t * 1.0) % 360.0;
let pitch = 6.0 + (t * 0.05).sin() * 2.0;
Some((c, yaw, pitch))
}
/// Called every frame while the title is up.
pub(super) fn update_backdrop(&mut self) -> Result<()> {
let wanted = self.pending_entry.is_none()
&& self.title.is_some()
&& horizon_client::ui_theme::horizon()
&& self.world_renderer_ready
&& self.renderer.is_some()
&& self.options.frames.is_none();
if !wanted {
if self.backdrop.active && self.title.is_some() {
self.stop_backdrop();
}
if self.title.is_none() && self.backdrop.active {
// open_world / connect_server replaced the world and streaming.
self.backdrop = Backdrop::default();
}
return Ok(());
}
if !self.backdrop.active {
self.start_backdrop()?;
}
if !self.backdrop.installed {
let built = self
.backdrop
.terrain
.lock()
.unwrap_or_else(|e| e.into_inner())
.take();
match built {
// Still building: the panorama stays up.
None => return Ok(()),
Some(Ok(terrain)) => self.install_backdrop(terrain)?,
Some(Err(e)) => {
// The panorama stays up for good.
log::warn!("Horizon: title backdrop: {e}");
self.backdrop.installed = true;
return Ok(());
}
}
}
let found = *self.backdrop.spot.lock().unwrap_or_else(|e| e.into_inner());
let Some(Some((x, z))) = found else {
return Ok(());
};
if !self.backdrop.centred {
self.backdrop.centred = true;
self.streaming.center = (x >> 4, z >> 4);
self.streaming.paused = false;
}
self.update_world();
if self.backdrop.camera.is_none()
&& (-2..=2)
.all(|dz| (-2..=2).all(|dx| self.streaming.is_lit((x >> 4) + dx, (z >> 4) + dz)))
{
// Above the tallest block nearby, so no spike pokes through the lens.
let mut top = 64;
for dz in (-12..=12).step_by(3) {
for dx in (-12..=12).step_by(3) {
if let Some(y) = self.surface_y(x + dx, z + dz) {
top = top.max(y);
}
}
}
let ground = self.surface_y(x, z).unwrap_or(top);
let y = (ground + 22).max(top + 4);
self.backdrop.camera = Some(glam::DVec3::new(
f64::from(x) + 0.5,
f64::from(y),
f64::from(z) + 0.5,
));
}
if self.backdrop.camera.is_some()
&& self.backdrop.ready.is_none()
&& self
.renderer
.as_ref()
.is_some_and(|r| r.section_count() > 40)
{
self.backdrop.ready = Some(Instant::now());
log::info!(
"Horizon: title backdrop ready; world rest ready: {}",
self.res.rest.get().is_some()
);
}
Ok(())
}
/// The world tick of the backdrop: time passes for clouds and snow only.
pub(super) fn tick_backdrop(&mut self) {
if self.backdrop.active {
self.world.game_time += 1;
// The snow's fall follows the client tick counter.
self.ticks += 1;
}
}
fn surface_y(&self, x: i32, z: i32) -> Option<i32> {
let air = self.res.facts().air;
(-60..320).rev().find(|&y| self.world.block(x, y, z) != air)
}
/// Start building the generator and finding the spot on a worker
/// (`VanillaTerrain::new` takes seconds on a cold cache).
fn start_backdrop(&mut self) -> Result<()> {
log::info!(
"Horizon: starting title backdrop after {} ms",
self.started.elapsed().as_millis()
);
let seed = seed();
let dir = self.backdrop_root()?.join(format!("{seed}"));
std::fs::create_dir_all(&dir)?;
// The streaming is replaced once the generator is built.
self.streaming.paused = true;
let mut world = World::new(self.res.facts().air, seed);
world.day_time = DAY_TIME;
world.game_time = 6000;
// Light snow: the weather renders as snow in frozen biomes.
world.weather = Weather {
clear_time: 0,
rain_time: i32::MAX / 2,
thunder_time: i32::MAX / 2,
raining: true,
thundering: false,
rain_level: (0.35, 0.35),
thunder_level: (0.0, 0.0),
};
self.world = world;
self.dim = super::Dim::Overworld;
if let Some(r) = self.renderer.as_mut() {
r.clear_sections();
}
self.backdrop = Backdrop {
active: true,
started: Some(Instant::now()),
..Default::default()
};
let (terrain, spot) = (self.backdrop.terrain.clone(), self.backdrop.spot.clone());
let worldgen = self.options.resources.join("worldgen");
let registry = self.pack.assets.registry;
let biomes = self.res.biomes().clone();
let cache = dir.join("spot.txt");
std::thread::Builder::new()
.name("horizon-backdrop".into())
.spawn(move || {
let built = Instant::now();
let inner = match VanillaTerrain::new(&worldgen, registry, &biomes, seed) {
Ok(t) => Arc::new(t),
Err(e) => {
*terrain.lock().unwrap_or_else(|e| e.into_inner()) =
Some(Err(e.to_string()));
return;
}
};
log::info!(
"Horizon: title backdrop generator built in {} ms",
built.elapsed().as_millis()
);
*terrain.lock().unwrap_or_else(|e| e.into_inner()) = Some(Ok(inner.clone()));
// Find (or recall) the spot.
let known = std::fs::read_to_string(&cache).ok().and_then(|t| {
let mut it = t.split_whitespace().map(|v| v.parse::<i32>().ok());
Some((it.next()??, it.next()??))
});
let found = known.or_else(|| {
let allowed = |name: &str| name == BIOME;
let search = horizon_world::worldgen::generator::BiomeSearch {
allowed: &allowed,
origin: [0, 64, 0],
radius: 6400,
horizontal: 32,
vertical: 64,
min_y: -64,
max_y: 320,
};
let found = inner.find_closest_biome(&search);
log::info!("Horizon: title backdrop: {BIOME} at {found:?}");
let (_, p) = found?;
let _ = std::fs::write(&cache, format!("{} {}\n", p[0], p[2]));
Some((p[0], p[2]))
});
*spot.lock().unwrap_or_else(|e| e.into_inner()) =
Some(Some(found.unwrap_or((0, 0))));
})?;
Ok(())
}
fn backdrop_root(&self) -> Result<std::path::PathBuf> {
Ok(std::env::current_dir()?
.join("saves")
.join(".horizon-title")
.join("backdrop"))
}
/// The built generator streams the backdrop's chunks.
fn install_backdrop(&mut self, inner: Arc<VanillaTerrain>) -> Result<()> {
let seed = seed();
let save = Arc::new(SaveDir::new(self.backdrop_root()?.join(format!("{seed}"))));
let (res, pack) = (&*self.res, &self.pack);
let mut streaming = Streaming::new(
Arc::new(Persistent {
inner,
save: save.clone(),
registry: pack.assets.clone(),
biomes: res.biomes().clone(),
}),
pack.context.clone(),
res.threads().min(6),
);
streaming.radius = self.settings.render_distance.clamp(4, 10);
streaming.biome_blend = self.settings.biome_blend;
streaming.smooth_lighting = self.settings.smooth_lighting;
streaming.cutout_leaves = self.settings.cutout_leaves;
streaming.cull_leaves = self.settings.horizon.cull_leaves;
streaming.biome_zoom = BiomeZoom::new(obfuscate_seed(seed));
streaming.paused = true;
self.streaming = streaming;
self.save = save;
self.backdrop.installed = true;
Ok(())
}
fn stop_backdrop(&mut self) {
self.streaming.paused = true;
self.world = World::new(self.res.facts().air, 0);
if let Some(r) = self.renderer.as_mut() {
r.clear_sections();
}
self.backdrop = Backdrop::default();
}
}
@@ -564,6 +564,8 @@ impl Game<'_> {
"graphics" => Page::Graphics,
"graphics-advanced" => Page::GraphicsAdvanced,
"extras" => Page::Extras,
"horizon" => Page::Horizon,
"shader-packs" => Page::ShaderPacks,
other => return Err(format!("unknown options page {other}").into()),
};
if self.screen == Screen::Playing && self.title.is_none() {
@@ -736,6 +738,7 @@ impl Game<'_> {
Screen::Stats => "stats",
Screen::Advancements => "advancements",
Screen::WorldOptions => "world-options",
Screen::Friends => "friends",
Screen::CommandBlock => "command-block",
}
}
+43 -4
View File
@@ -1,4 +1,5 @@
//! Play with friends, host side: "Invite friends" opens the world to LAN if
//! Play with friends, host side: "Start Sharing" on the Play with Friends
//! screen (`friends_screen`, the pause menu's Friends button) opens the world to LAN if
//! it isn't (with Open to LAN's defaults) and shares that port behind an
//! invite code (horizon-friends). The code holds this computer's addresses
//! and the key, so friends join with no server of ours; a relay the player
@@ -6,7 +7,12 @@
//! LAN one, unchanged: tunnelled guests are LAN guests that connect from the
//! loopback address.
use super::{Game, lan::LanSettings};
use horizon_client::{Result, front::FriendsView, text::Text};
use horizon_client::{
Result,
friends_screen::{self, Action, FriendsView},
hud::HudBatch,
text::Text,
};
use horizon_friends::{Host, HostConfig, HostEvent, PathMode, host::DEFAULT_PORT, reach, stun};
use horizon_protocol::{GAME_VERSION, PROTOCOL_VERSION};
use std::time::{Duration, Instant};
@@ -155,7 +161,7 @@ impl Game<'_> {
}
if announce {
self.system_message(Text::literal(
"Your invite code is ready in the pause menu: copy it and send it to your friends.",
"Your invite code is ready: Game Menu, Play with Friends. Copy it and send it to your friends.",
));
}
}
@@ -171,7 +177,40 @@ impl Game<'_> {
}
}
/// What the pause menu shows.
/// Play with Friends. The world is paused under it in singleplayer, so
/// new codes and sessions are read while it is drawn.
pub(super) fn draw_friends_screen(&mut self, batch: &mut HudBatch) {
self.tick_friends();
let view = self.friends_view();
friends_screen::draw(batch, &self.gui.atlas, self.cursor, &view, true);
}
pub(super) fn friends_screen_click(&mut self) {
let view = self.friends_view();
let Some(action) =
friends_screen::click(&self.gui.atlas, self.gui_size(), self.cursor, &view)
else {
return;
};
self.audio.play_button_click();
match action {
Action::Share => {
if let Err(e) = self.friends_start() {
self.system_message(Text::literal(format!("Couldn't share the world: {e}")));
}
}
Action::Copy => self.friends_copy(),
Action::Stop => self.friends_stop(),
// The system browser, as the Shader Packs page opens its folder.
Action::Help => {
if let Some(url) = &view.help {
super::packs::open_folder(std::path::Path::new(url));
}
}
Action::Done => self.screen = super::Screen::Paused,
}
}
/// What Play with Friends shows.
pub(super) fn friends_view(&self) -> FriendsView {
let guests = match &self.lan {
Some(h) => h.hub.guests.iter().map(|g| g.name.clone()).collect(),
+7 -39
View File
@@ -113,7 +113,7 @@ impl Game<'_> {
}
/// Where focus can land: buttons drawn last frame, every registered
/// target (sliders, fields, rows, Horizon-style widgets), and the slots
/// target (sliders, fields, rows, keyboard keys), and the slots
/// and tabs of inventories (GUI pixels), on screen.
fn pad_targets(&self) -> Vec<Target> {
let mut targets = self.pad_all_targets();
@@ -137,7 +137,7 @@ impl Game<'_> {
})
.collect();
for t in widgets::last_targets() {
// A Horizon button is both a labelled button and a target.
// A button can be both a labelled button and a target.
if let Some(same) = targets.iter_mut().find(|o| o.rect == t.rect) {
same.kind = t.kind;
} else {
@@ -1026,45 +1026,13 @@ impl Game<'_> {
}
}
/// The focus highlight. Classic screens look as vanilla's keyboard focus
/// does: buttons, sliders and slots already draw their highlighted
/// sprite under the (hidden) pointer, and list rows and fields get
/// vanilla's white one-pixel outline (`AbstractSelectionList`'s focused
/// selection, `EditBox`'s highlighted border). Horizon-style screens get
/// the design system's focus colour: a two-dp accent ring.
/// The focus highlight, as vanilla's keyboard focus looks: buttons,
/// sliders and slots already draw their highlighted sprite under the
/// (hidden) pointer, and list rows and fields get vanilla's white
/// one-pixel outline (`AbstractSelectionList`'s focused selection,
/// `EditBox`'s highlighted border).
fn draw_pad_focus(&self, batch: &mut HudBatch, focus: Target) {
let [x, y, w, h] = focus.rect;
// The options' sub-pages keep the classic layout under either style.
let horizon = horizon_client::ui_theme::horizon()
&& if self.screen == Screen::Options {
self.ui.options.page() == Page::Main
} else {
self.title.is_some() || self.screen == Screen::Paused
};
if horizon {
use horizon_client::ui_theme::{self as theme, Ui, color};
let mut ui = Ui::new(&self.gui.atlas, batch, self.cursor);
let k = ui.batch.scale / ui.density;
let (x, y, w, h) = (x * k, y * k, w * k, h * k);
let radius = match focus.kind {
Kind::Button | Kind::Tab(_) | Kind::Slider { .. } => (h + 6.0) / 2.0,
Kind::Field => theme::RADIUS + 3.0,
_ => theme::RADIUS_PLATE + 3.0,
};
for inset in [0.0, 1.0] {
let o = 3.0 - inset;
ui.border(
x - o,
y - o,
w + 2.0 * o,
h + 2.0 * o,
radius - inset,
color::ACCENT,
);
}
ui.finish();
return;
}
if matches!(focus.kind, Kind::Row | Kind::Field) {
let atlas = &self.gui.atlas;
let white = rgba(255, 255, 255, 255);
+52 -68
View File
@@ -13,7 +13,11 @@ impl Screen {
pub(super) fn blurs_background(self, pause_menu: bool) -> bool {
match self {
Self::Paused => pause_menu,
Self::Options | Self::Stats | Self::Advancements | Self::WorldOptions => true,
Self::Options
| Self::Stats
| Self::Advancements
| Self::WorldOptions
| Self::Friends => true,
Self::Playing
| Self::GameModeSwitcher
| Self::Chat
@@ -61,6 +65,9 @@ fn pause_buttons(w: f32, h: f32, remote: bool) -> Vec<(f32, f32, f32, &'static s
}
/// The icon row: report bugs, feedback, friends, player reporting.
/// `FRIENDS_ICON` (vanilla's `CommonButtons.friends`) opens Horizon's
/// Play with Friends; the others stay inactive.
const FRIENDS_ICON: usize = 2;
fn pause_icons(w: f32, h: f32) -> [(f32, f32, &'static str); 4] {
let x0 = ((w - 212.0) * 0.5).floor() + 60.0;
let y = ((h - 166.0) * 0.25).floor() + 98.0;
@@ -87,41 +94,8 @@ impl Game<'_> {
pub(super) fn external_server(&self) -> bool {
self.remote.is_some() && self.integrated.is_none()
}
/// Whether the pause menu is drawn in Horizon's style (over a blurred world).
pub(super) fn horizon_pause(&self) -> bool {
self.screen == Screen::Paused
&& self.pause_menu
&& self.title.is_none()
&& horizon_client::ui_theme::horizon()
}
fn pause_labels(&self) -> (String, &'static str) {
if let Some(server) = &self.integrated {
return (server.world_name.clone(), "Save and quit");
}
if self.external_server() {
("Multiplayer".to_owned(), "Disconnect")
} else {
(self.level.name.clone(), "Save and quit")
}
}
pub(super) fn draw_pause_menu(&mut self, batch: &mut HudBatch) {
if horizon_client::ui_theme::horizon() {
let opened = *self.pause_since.get_or_insert_with(std::time::Instant::now);
let (world, quit) = self.pause_labels();
self.tick_friends();
let friends = self.friends_view();
let mut ui = horizon_client::ui_theme::Ui::new(&self.gui.atlas, batch, self.cursor);
horizon_client::front::pause::draw(
&mut ui,
&world,
quit,
opened,
&friends,
self.external_server(),
);
ui.finish();
return;
}
let friends = self.friends_view().shown;
let atlas = &self.gui.atlas;
let (w, h) = (batch.width, batch.height);
ui::menu_background(batch, atlas, 0.0, 0.0, w, h, true);
@@ -149,12 +123,41 @@ impl Game<'_> {
hover,
);
}
for (x, y, sprite) in pause_icons(w, h) {
ui::button(batch, atlas, x, y, 20.0, 20.0, &Text::empty(), false, false);
let mut tooltip = None;
for (i, (x, y, sprite)) in pause_icons(w, h).into_iter().enumerate() {
let active = i == FRIENDS_ICON && friends;
let hover = ui::hovered(self.cursor, x, y, 20.0, 20.0);
// The icon has no label: name it for controller focus and the
// control socket's widget tree.
if i == FRIENDS_ICON {
horizon_client::widgets::record(
horizon_client::friends_screen::TITLE,
[x, y, 20.0, 20.0],
active,
);
}
ui::button(
batch,
atlas,
x,
y,
20.0,
20.0,
&Text::empty(),
active,
active && hover,
);
// SpriteIconButton.CenteredIcon: the 15x15 sprite at
// x + width / 2 - 15 / 2 in integer pixels, untinted even
// when the button is inactive.
batch.sprite_scaled(atlas, sprite, x + 3.0, y + 3.0, 15.0, 15.0, u32::MAX);
if i == FRIENDS_ICON && hover {
tooltip = Some(Text::literal(horizon_client::friends_screen::TITLE));
}
}
// SpriteIconButton.withTootip: the label as a tooltip.
if let Some(tip) = tooltip {
ui::tooltip(batch, atlas, &[tip], self.cursor);
}
}
pub(super) fn pause_click(&mut self) -> Result<()> {
@@ -166,29 +169,16 @@ impl Game<'_> {
let b = HudBatch::new(size);
(b.width, b.height)
};
let hit = if horizon_client::ui_theme::horizon() {
let size = self
.renderer
.as_ref()
.map_or([1, 1], |r| [r.config.width, r.config.height]);
let mut b = HudBatch::new(size);
let (world, quit) = self.pause_labels();
horizon_client::front::pause::click(
&self.gui.atlas,
&mut b,
self.cursor.0,
self.cursor.1,
&world,
quit,
&self.friends_view(),
self.external_server(),
)
} else {
pause_buttons(w, h, self.external_server())
.into_iter()
.find(|b| b.5 && ui::hovered(self.cursor, b.0, b.1, b.2, 20.0))
.map(|b| b.4)
};
let friends = pause_icons(w, h)[FRIENDS_ICON];
let hit = pause_buttons(w, h, self.external_server())
.into_iter()
.find(|b| b.5 && ui::hovered(self.cursor, b.0, b.1, b.2, 20.0))
.map(|b| b.4)
.or_else(|| {
(self.friends_view().shown
&& ui::hovered(self.cursor, friends.0, friends.1, 20.0, 20.0))
.then_some(10)
});
match hit {
Some(0) => {
self.screen = Screen::Playing;
@@ -198,17 +188,11 @@ impl Game<'_> {
Some(3) => self.open_stats(),
Some(4) => self.open_advancements(true),
Some(9) => self.open_world_options(),
Some(10) => {
if let Err(e) = self.friends_start() {
self.system_message(Text::literal(format!("Couldn't share the world: {e}")));
}
}
Some(11) => self.friends_copy(),
Some(12) => self.friends_stop(),
Some(10) => self.screen = Screen::Friends,
Some(2) => self.close_world()?,
_ => {}
}
if hit.is_some() && !horizon_client::ui_theme::horizon() {
if hit.is_some() {
self.audio.play_button_click();
}
Ok(())
+18 -60
View File
@@ -73,11 +73,6 @@ impl StartupMenu {
&self.root,
);
title.last_server = settings.file.string("lastServer");
if horizon_client::ui_theme::horizon() {
title
.opening
.set(Some(horizon_client::front::Opening::new()));
}
self.title = Some(title);
}
}
@@ -152,9 +147,6 @@ impl StartupMenu {
fn title_key(&mut self, event: &KeyEvent) {
let shortcut = self.shortcut(event);
let Some(title) = &mut self.title else { return };
if title.skip_opening() {
return;
}
if let Some(shortcut) = shortcut {
if title.has_caret_field() {
title.field_shortcut(shortcut, &mut self.clipboard);
@@ -422,14 +414,6 @@ impl Loading {
event_loop: &ActiveEventLoop,
event: WindowEvent,
) -> Result<()> {
if let WindowEvent::MouseInput {
state,
button: MouseButton::Left,
..
} = &event
{
horizon_client::ui_theme::set_pressed(*state == ElementState::Pressed);
}
if let WindowEvent::KeyboardInput { event, .. } = &event
&& let PhysicalKey::Code(key) = event.physical_key
{
@@ -455,7 +439,6 @@ impl Loading {
WindowEvent::Focused(false) => {
self.menu.modifiers = ModifiersState::empty();
self.menu.physical_keys.clear();
horizon_client::ui_theme::set_pressed(false);
self.menu.dragging = false;
if let Some(title) = &mut self.menu.title {
title.release();
@@ -508,41 +491,23 @@ impl Loading {
button: MouseButton::Left,
..
} => {
let mut batch = HudBatch::new(self.menu_size());
let batch = HudBatch::new(self.menu_size());
if let (Some(title), Some(gui)) = (&mut self.menu.title, &self.gui) {
if state == ElementState::Released {
title.release();
title.release_field();
} else {
let action = if horizon_client::ui_theme::horizon() {
let action = title.click_horizon(
&gui.atlas,
&mut batch,
self.menu.cursor.0,
self.menu.cursor.1,
);
// Horizon's deeper world-management pages use classic fields.
title.press_field(
&gui.atlas,
self.menu.cursor,
(batch.width, batch.height),
self.menu.modifiers.shift_key(),
);
action
} else {
let (action, _) = title.click(
self.menu.cursor.0,
self.menu.cursor.1,
(batch.width, batch.height),
);
title.press_field(
&gui.atlas,
self.menu.cursor,
(batch.width, batch.height),
self.menu.modifiers.shift_key(),
);
action
};
let (action, _) = title.click(
self.menu.cursor.0,
self.menu.cursor.1,
(batch.width, batch.height),
);
title.press_field(
&gui.atlas,
self.menu.cursor,
(batch.width, batch.height),
self.menu.modifiers.shift_key(),
);
self.menu_action(event_loop, action);
}
}
@@ -617,18 +582,12 @@ impl Loading {
} else if let Some(title) = &mut self.menu.title {
title.poll_backup();
let _ = title.update_toast(self.settings.notification_display_time);
if horizon_client::ui_theme::horizon() {
let mut ui = horizon_client::ui_theme::Ui::new(&gui.atlas, batch, self.menu.cursor);
title.draw_horizon(&mut ui, 0.0);
ui.finish();
} else {
title.draw(
&gui.atlas,
batch,
self.menu.cursor,
self.settings.file.bool("hideSplashTexts"),
);
}
title.draw(
&gui.atlas,
batch,
self.menu.cursor,
self.settings.file.bool("hideSplashTexts"),
);
}
}
@@ -730,7 +689,6 @@ mod tests {
// Navigate and enter a world name without a registry, biomes, pack
// tables or a Game. Replacing fallback artwork preserves this state.
let title = loading.menu.title.as_mut().unwrap();
title.opening.set(None);
title.mode = horizon_client::title::Mode::Create {
name: String::new(),
seed: "42".into(),
-22
View File
@@ -239,8 +239,6 @@ pub struct Frame<'a> {
pub night_vision: f32,
/// Torch flicker added to the block light factor of 1.4.
pub block_flicker: f32,
/// Blur and grade the frame under a Horizon-style menu (`post`).
pub post: Option<crate::post::PostGrade>,
/// `Screen.extractBlurredBackground`: blur the frame by this radius
/// (`menuBackgroundBlurriness`) before the screen is drawn over it.
pub menu_blur: Option<f32>,
@@ -450,8 +448,6 @@ pub struct Renderer {
/// The selected shader pack's stages (Horizon setting; none by default).
pack: Option<Pack>,
pub hud: HudRenderer,
/// The menus' backdrop blur, made on first use.
post: Option<crate::post::Post>,
/// Vanilla's menu background blur, made on first use.
menu_blur: Option<crate::menu_blur::MenuBlur>,
pub info: wgpu::AdapterInfo,
@@ -2223,7 +2219,6 @@ impl Renderer {
world_post,
pack: None,
hud,
post: None,
menu_blur: None,
info,
suspended: size.width == 0 || size.height == 0,
@@ -3947,23 +3942,6 @@ impl Renderer {
radius,
);
}
if let Some(grade) = &frame.post
&& self.config.usage.contains(wgpu::TextureUsages::COPY_SRC)
{
let format = self.config.format;
let device = &self.device;
self.post
.get_or_insert_with(|| crate::post::Post::new(device, format))
.apply(
&self.device,
&self.queue,
&mut encoder,
&target_texture,
&view_target,
[self.config.width, self.config.height],
grade,
);
}
self.hud.draw_range(
&mut encoder,
&view_target,
+3 -7
View File
@@ -204,8 +204,6 @@ pub struct Graphics {
pub resolution_scale: u32,
/// FXAA over the world.
pub fxaa: bool,
/// The settings level last shown: Advanced, or Simple.
pub advanced: bool,
/// Battery mode: at most 60 frames per second in a world and 30 in menus
/// or behind other windows, and half the worker threads. Off by default;
/// it changes when frames are drawn, never what they show or the ticks.
@@ -236,7 +234,6 @@ impl Default for Graphics {
overlay: Overlay::Off,
resolution_scale: 100,
fxaa: false,
advanced: false,
battery: false,
shader_pack: String::new(),
api: GraphicsApi::Auto,
@@ -288,7 +285,6 @@ impl Graphics {
"workers" => g.workers = number(g.workers).min(64),
"resolutionScale" => g.resolution_scale = number(g.resolution_scale).clamp(50, 200),
"fxaa" => g.fxaa = flag(g.fxaa),
"level" => g.advanced = value == "advanced",
"batteryMode" => g.battery = flag(g.battery),
"shaderPack" => g.shader_pack = value.to_string(),
"graphicsApi" => g.api = GraphicsApi::from_name(value).unwrap_or_default(),
@@ -306,7 +302,7 @@ impl Graphics {
}
pub fn serialize(&self) -> String {
format!(
"preset:{}\nlodDistance:{}\ncaveCulling:{}\ncullLeaves:{}\nentityCulling:{}\nchunkUpdates:{}\nuploadBudgetKiB:{}\nsky:{}\nfog:{}\nweather:{}\nanimatedTextures:{}\npresentMode:{}\nframePacing:{}\nworkers:{}\noverlay:{}\nresolutionScale:{}\nfxaa:{}\nlevel:{}\nbatteryMode:{}\nshaderPack:{}\ngraphicsApi:{}\n",
"preset:{}\nlodDistance:{}\ncaveCulling:{}\ncullLeaves:{}\nentityCulling:{}\nchunkUpdates:{}\nuploadBudgetKiB:{}\nsky:{}\nfog:{}\nweather:{}\nanimatedTextures:{}\npresentMode:{}\nframePacing:{}\nworkers:{}\noverlay:{}\nresolutionScale:{}\nfxaa:{}\nbatteryMode:{}\nshaderPack:{}\ngraphicsApi:{}\n",
self.preset.name(),
self.lod_distance,
bool_text(self.cave_culling),
@@ -331,7 +327,6 @@ impl Graphics {
},
self.resolution_scale,
bool_text(self.fxaa),
if self.advanced { "advanced" } else { "simple" },
bool_text(self.battery),
self.shader_pack,
self.api.name(),
@@ -425,13 +420,14 @@ mod tests {
overlay: Overlay::Graph,
resolution_scale: 75,
fxaa: true,
advanced: true,
battery: true,
shader_pack: "horizon-sample".into(),
api: GraphicsApi::Dx12,
};
assert_eq!(Graphics::parse(&g.serialize()), g);
assert_eq!(Graphics::parse(""), Graphics::default());
// The old menus' Simple / Advanced choice is ignored.
assert_eq!(Graphics::parse("level:advanced\n"), Graphics::default());
assert_eq!(
Graphics::parse("workers:abc\nsky:maybe\ncullLeaves:maybe\nentityCulling:maybe\n"),
Graphics::default()
+2 -2
View File
@@ -285,7 +285,7 @@ pub fn rows(level: Level) -> Vec<Row> {
const UPLOAD_STEPS: [u32; 8] = [0, 256, 512, 1024, 2048, 4096, 8192, 16384];
/// Classic's submenus supplement the vanilla options on their parent screens.
/// Horizon's graphics screens supplement the vanilla options on Video Settings.
fn extra_rows(level: Level) -> Vec<Row> {
let mut rows = rows(level);
rows.retain(|row| !matches!(row, Row::Setting(s) if matches!(s.item, Item::Vanilla(_))));
@@ -444,7 +444,7 @@ fn max_workers() -> u32 {
}
impl Item {
/// On/off settings, drawn as switches by the Horizon menus.
/// On/off settings and their value.
pub fn switch(self, s: &Settings) -> Option<bool> {
let g = &s.horizon;
Some(match self {
+2 -2
View File
@@ -160,7 +160,7 @@ impl HudAtlas {
)
}
/// Empty slots written at run time: map textures (game/maps.rs), the
/// minimap, downloaded skins, world icons and the Horizon menu text.
/// minimap, downloaded skins, world icons and the on-screen keyboard's text.
fn slots(images: &mut Vec<PackedImage>) {
for i in 0..MAP_SLOTS {
images.push((format!("horizon/map{i}"), 128, 128, vec![0; 128 * 128 * 4]));
@@ -184,7 +184,7 @@ impl HudAtlas {
vec![0; 64 * 64 * 4],
));
}
// Horizon-style menu text and corner masks (ui_theme), rasterized at run time.
// The on-screen keyboard's text and corner masks (ui_theme), rasterized at run time.
images.push((
"horizon/ui-text".into(),
2048,
+1 -3
View File
@@ -69,7 +69,7 @@ pub mod first_person;
pub mod flatgen;
pub mod fog;
pub mod font;
pub mod front;
pub mod friends_screen;
pub mod game_mode_switcher;
pub mod gamepad;
pub mod gamerules;
@@ -127,7 +127,6 @@ pub mod nether_portal;
pub mod offline_name;
pub mod options_file;
pub mod options_fixes;
pub mod options_horizon;
pub mod options_ui;
pub mod osk;
pub mod overlay;
@@ -141,7 +140,6 @@ pub mod player_sync;
pub mod poi_sections;
pub mod portal_sections;
pub mod pose;
pub mod post;
pub mod projectiles;
pub mod raid;
pub mod random_sequences;
+34 -10
View File
@@ -78,8 +78,8 @@ pub enum Screen {
name: String,
lines: std::cell::Cell<usize>,
},
/// Join a friend's world with its invite code (Horizon's own, reached
/// from Horizon's multiplayer page).
/// Join a friend's world with its invite code (Horizon's own, behind the
/// title screen's Friends button).
Friend {
code: String,
/// The relay for short codes (optional; saved on Join).
@@ -373,13 +373,6 @@ impl Screen {
}
}
/// The address of list row `row` (saved servers, then LAN games).
pub fn address_of(&self, row: usize) -> Option<String> {
match self {
Self::List { servers, lan, .. } => entry_address(servers, lan, row),
_ => None,
}
}
pub fn list(saves: &Path) -> Self {
let servers = servers::load(&servers_file(saves));
let pings: Pings = Arc::default();
@@ -1162,7 +1155,7 @@ impl Screen {
) => *self = Self::list(saves),
(Self::Disconnected { retry, .. }, Some(55)) => *retry = None,
(Self::Direct { address }, Some(52)) => {
return Outcome::Connect(address.trim().to_owned());
return Outcome::Connect(direct_address(address));
}
(Self::Friend { code, relay, .. }, Some(56)) => {
if horizon_friends::invite::parse(code).is_some() {
@@ -1326,6 +1319,19 @@ impl Screen {
}
}
/// Direct Connection's address; a full invite code pasted there joins the
/// friend (a short relay code could be a host name, so it needs Join a Friend).
fn direct_address(address: &str) -> String {
let code: String = address.chars().filter(|c| !c.is_whitespace()).collect();
if matches!(
horizon_friends::invite::parse(&code),
Some(horizon_friends::invite::Parsed::Long(_))
) {
format!("{}{code}", crate::net::FRIEND)
} else {
address.trim().to_owned()
}
}
/// Greedy word wrap to a pixel width.
pub fn wrap(text: &str, width: f32, atlas: &HudAtlas) -> Vec<String> {
let mut lines = Vec::new();
@@ -1353,6 +1359,24 @@ pub fn wrap(text: &str, width: f32, atlas: &HudAtlas) -> Vec<String> {
mod tests {
use super::*;
#[test]
fn direct_connection_joins_a_pasted_invite_and_keeps_host_names() {
let invite = horizon_friends::invite::Invite {
secret: *b"0123456789",
port: 25580,
endpoints: vec!["192.168.1.20:25580".parse().unwrap()],
relay: None,
}
.encode();
assert_eq!(
direct_address(&format!(" {invite} ")),
format!("{}{invite}", crate::net::FRIEND)
);
for host in ["localhost", "example.org:25566", "abcdefgh", "[::1]:25568"] {
assert_eq!(direct_address(host), host);
}
}
#[test]
fn ping_tooltip_follows_only_visible_status_bars_and_current_ping() {
let servers: Vec<_> = (0..6)
File diff suppressed because it is too large Load Diff
+128 -113
View File
@@ -130,7 +130,7 @@ pub(crate) enum Kind {
Slider(f32),
Cycle,
}
/// Options shared by the Classic page and Horizon's Accessibility section.
/// The Accessibility Settings page:
/// `AccessibilityOptionsScreen.options`, with the Controls link inserted separately.
pub(crate) const ACCESSIBILITY_OPTIONS: &[Opt] = &[
Opt::Narrator,
@@ -871,6 +871,9 @@ pub enum Page {
Controller,
PadBinds,
Extras,
/// Horizon Settings: every page Horizon adds, as a mod's settings
/// screen hangs off vanilla's Options.
Horizon,
}
#[derive(Clone, Debug, PartialEq)]
enum Act {
@@ -886,8 +889,6 @@ enum Act {
PadKey(&'static str),
ResetPadKey(&'static str),
ResetPadKeys,
/// Back to Horizon's own menus (Horizon only, see `list_rows`).
HorizonMenus,
ToggleMod(usize),
OpenModFolder,
/// Pick shader pack `i` of `OptionsUi::shader_packs` (again: off).
@@ -968,15 +969,8 @@ pub struct OptionsUi {
/// when it last moved: the handle follows the pointer while the option
/// keeps its stepped value, then snaps to it (`resetValue`).
slider_value: Option<(Opt, f32, Instant)>,
/// The pointer's last y while a Classic or Horizon scrollbar is held.
/// The pointer's last y while a scrollbar is held.
pub(crate) scrollbar_drag_y: Option<f32>,
/// Horizon style: the selected sidebar section, the one last drawn and
/// the rows' scroll in dp (`options_horizon`).
pub section: usize,
pub(crate) section_shown: Option<usize>,
pub(crate) hscroll: f32,
/// The slider being dragged on the Horizon options shell.
pub(crate) hdragging: Option<crate::graphics_ui::Item>,
/// Key Binds: the mapping waiting for a key.
pub selected_key: Option<&'static str>,
/// Controller Binds: the action waiting for a pad button.
@@ -1017,10 +1011,6 @@ impl Default for OptionsUi {
dragging: None,
slider_value: None,
scrollbar_drag_y: None,
section: 0,
section_shown: None,
hscroll: 0.0,
hdragging: None,
selected_key: None,
selected_pad_action: None,
pad_style: GlyphStyle::Xbox,
@@ -1081,6 +1071,27 @@ fn option_widget(s: &Settings, opt: Opt, x: f32, y: f32, w: f32) -> Widget {
Kind::Cycle => button(x, y, w, opt.label(s), Act::Cycle(opt)),
}
}
/// What a button opening one of Horizon's pages says on hover.
fn horizon_page_tooltip(page: Page) -> Option<&'static str> {
Some(match page {
Page::Horizon => {
"Horizon's own settings: graphics, shader packs, controllers, extras and mods."
}
Page::Graphics => "Graphics, simply: each setting says what it costs.",
Page::GraphicsAdvanced => {
"Every graphics setting, Horizon's included, with what each costs."
}
Page::ShaderPacks => "Packs that redraw the world. Off is the vanilla look.",
Page::Controller => "Controllers: their buttons, sticks, vibration and menu navigation.",
Page::Extras => {
"Optional additions, all off by default: the game stays vanilla until you turn one on."
}
Page::Mods => {
"Mods made for Horizon, from the horizon-mods folder. Each runs in a sandbox and stays off until you turn it on."
}
_ => return None,
})
}
/// Rows of an OptionsList: (big?, options) or a header.
enum Row {
Big(Opt),
@@ -1098,10 +1109,7 @@ fn pairs(opts: &[Opt]) -> Vec<Row> {
impl OptionsUi {
fn settings_search_active(&self) -> bool {
self.settings_search.focused
&& (matches!(self.page(), Page::Video | Page::Controls | Page::KeyBinds)
|| (crate::ui_theme::horizon()
&& self.page() == Page::Main
&& crate::options_horizon::searchable_section(self.section)))
&& matches!(self.page(), Page::Video | Page::Controls | Page::KeyBinds)
}
pub fn page(&self) -> Page {
*self.stack.last().unwrap_or(&Page::Main)
@@ -1122,10 +1130,6 @@ impl OptionsUi {
self.in_world = in_world;
self.selected_key = None;
}
/// Open one of vanilla's pages over the current one.
pub(crate) fn open_page(&mut self, page: Page) {
self.push(page);
}
fn push(&mut self, page: Page) {
self.stack.push(page);
self.scroll = 0.0;
@@ -1164,14 +1168,9 @@ impl OptionsUi {
.as_ref()
.is_some_and(|(e, _)| e == id)
}
/// Whether the Shader Packs page (or the Horizon menus' section) shows.
/// Whether the Shader Packs page shows.
fn shader_packs_shown(&self) -> bool {
self.page() == Page::ShaderPacks
|| crate::ui_theme::horizon()
&& self.page() == Page::Main
&& crate::options_horizon::SECTIONS
.get(self.section)
.is_some_and(|s| s.name == crate::options_horizon::SHADER_PACKS)
}
/// The graphics screen level of `page`, if it is one.
fn graphics_level(page: Page) -> Option<crate::graphics_ui::Level> {
@@ -1200,6 +1199,7 @@ impl OptionsUi {
Page::Controller => "Controller Settings",
Page::PadBinds => "Controller Binds",
Page::Extras => "Horizon Extras",
Page::Horizon => "Horizon Settings",
}
}
fn scrollbar_x(&self, width: f32) -> f32 {
@@ -1263,7 +1263,17 @@ impl OptionsUi {
} else {
Text::literal(value)
};
button(0.0, 0.0, 150.0, label, Act::Extra(item))
let widget = button(0.0, 0.0, 150.0, label, Act::Extra(item));
// A setting of a switch that is off does nothing: inactive,
// as vanilla greys out an option that can't apply.
if item
.parent()
.is_some_and(|parent| parent.switch(&s.extras) == Some(false))
{
inactive(widget)
} else {
widget
}
};
let mut rows = Vec::new();
let mut section = Vec::new();
@@ -1287,6 +1297,27 @@ impl OptionsUi {
flush(&mut rows, &mut section);
rows
}
Page::Horizon => {
// Two to a row, as vanilla's OptionsList.addSmall lays out
// buttons; each opens a page built from vanilla's widgets.
let open = |label: &str, page: Page| {
button(0.0, 0.0, 150.0, Text::literal(label), Act::Push(page))
};
vec![
Row::Buttons(
open("Graphics...", Page::Graphics),
Some(open("Advanced Graphics...", Page::GraphicsAdvanced)),
),
Row::Buttons(
open("Shader Packs...", Page::ShaderPacks),
Some(open("Controller Settings...", Page::Controller)),
),
Row::Buttons(
open("Extras...", Page::Extras),
Some(open("Mods...", Page::Mods)),
),
]
}
Page::Video => {
// Horizon's graphics screens, Simple and Advanced.
let mut rows = vec![Row::Buttons(
@@ -1315,22 +1346,6 @@ impl OptionsUi {
),
None,
));
// The way back from Classic menus. Horizon-only like the row
// above, here rather than on the main Options screen so that
// one keeps vanilla's exact layout; vanilla's interface
// settings (GUI Scale) are on this page too.
if !crate::ui_theme::horizon() {
rows.push(Row::Buttons(
button(
0.0,
0.0,
310.0,
Text::literal("Menu Style: Classic"),
Act::HorizonMenus,
),
None,
));
}
rows.push(Row::Header("options.video.display.header"));
rows.extend(pairs(&[
Opt::MaxFps,
@@ -1578,8 +1593,10 @@ impl OptionsUi {
("options.chat", Some(Page::Chat)),
("options.resourcepack", Some(Page::Packs)),
("options.accessibility", Some(Page::Accessibility)),
// Vanilla's Telemetry Data and Credits slots: Horizon's
// settings and its mods, as a mod adds its button here.
("Horizon Settings...", Some(Page::Horizon)),
("Mods...", Some(Page::Mods)),
("Horizon Extras...", Some(Page::Extras)),
];
let gy = (61.0 + 30.0f32).min(h - 33.0 - 120.0);
for (i, (key, page)) in entries.iter().enumerate() {
@@ -2052,10 +2069,6 @@ impl OptionsUi {
);
return;
}
if crate::ui_theme::horizon() && self.page() == Page::Main {
self.draw_horizon(s, batch, atlas, cursor);
return;
}
if let Some(level) = Self::graphics_level(self.page()) {
self.graphics
.draw(level, s, batch, atlas, cursor, self.in_world);
@@ -2094,6 +2107,14 @@ impl OptionsUi {
{
tooltip = Some(atlas.font.split(&Text::literal(item.description()), 170.0));
}
if let WKind::Button {
act: Act::Push(page),
..
} = &wd.kind
&& let Some(text) = horizon_page_tooltip(*page)
{
tooltip = Some(atlas.font.split(&Text::literal(text), 170.0));
}
let key = match &wd.kind {
WKind::Button {
act: Act::Cycle(opt),
@@ -2300,9 +2321,6 @@ impl OptionsUi {
}
return Vec::new();
}
if crate::ui_theme::horizon() && self.page() == Page::Main {
return self.click_horizon(s, atlas, x, y, framebuffer, drag, right);
}
if let Some(level) = Self::graphics_level(self.page()) {
use crate::graphics_ui::Action;
let mut events = Vec::new();
@@ -2471,12 +2489,6 @@ impl OptionsUi {
s.controller.reset_bindings();
events.push(Event::Changed);
}
Act::HorizonMenus => {
self.horizon_menus();
if let Ok(dir) = std::env::current_dir() {
crate::ui_theme::save_preferences(&dir);
}
}
Act::ToggleMod(i) => {
s.mods.toggle(i);
events.push(Event::Changed);
@@ -2510,20 +2522,6 @@ impl OptionsUi {
}
events
}
/// Switch to Horizon's menus and show where the choice lives there
/// (Options, Interface, Menu style).
fn horizon_menus(&mut self) {
crate::ui_theme::set_style(crate::ui_theme::MenuStyle::Horizon);
self.stack.truncate(1);
self.scroll = 0.0;
self.scrollbar_drag_y = None;
self.section = crate::options_horizon::SECTIONS
.iter()
.position(|section| section.name == "Interface")
.unwrap_or(0);
self.section_shown = None;
self.hscroll = 0.0;
}
/// Where a slider's handle sits: its own position while held (or until
/// a delayed one applies), else the option's stepped value.
fn slider_shown(&self, opt: Opt, value: f32) -> f32 {
@@ -2540,7 +2538,6 @@ impl OptionsUi {
// AbstractSliderButton suppresses the press sound and plays once on
// release, even if the pointer has left the widget or its value stayed.
let slider = self.dragging.take().is_some();
self.hdragging = None;
let graphics_slider = self.graphics.release();
if slider || graphics_slider {
vec![Event::ButtonClick]
@@ -2558,10 +2555,6 @@ impl OptionsUi {
if self.resource_error.is_some() {
return;
}
if crate::ui_theme::horizon() && self.page() == Page::Main {
self.scroll_horizon(amount);
return;
}
if let Some(level) = Self::graphics_level(self.page()) {
self.graphics.scroll(level, size.1, amount);
return;
@@ -2783,7 +2776,6 @@ impl OptionsUi {
#[cfg(test)]
mod tests {
use super::*;
use crate::ui_theme::{MenuStyle, set_style, style};
#[test]
fn accessibility_sliders_and_toggles_survive_options_round_trip() {
@@ -3337,9 +3329,7 @@ mod tests {
}
#[test]
fn classic_extras_entry_edits_shared_settings_and_returns_without_changing_style() {
let previous_style = style();
set_style(MenuStyle::Classic);
fn extras_from_horizon_settings_edit_shared_settings_and_return() {
let atlas = atlas();
let mut s = Settings::default();
let mut ui = OptionsUi::default();
@@ -3363,11 +3353,13 @@ mod tests {
false,
)
};
assert_eq!(
click(&mut ui, &mut s, Act::Push(Page::Extras)),
vec![Event::ButtonClick]
);
assert_eq!(ui.page(), Page::Extras);
for page in [Page::Horizon, Page::Extras] {
assert_eq!(
click(&mut ui, &mut s, Act::Push(page)),
vec![Event::ButtonClick]
);
assert_eq!(ui.page(), page);
}
let (widgets, _, _, _) = ui.layout(&s, size.0, size.1);
assert_eq!(
widgets
@@ -3408,9 +3400,7 @@ mod tests {
ui.key(&mut s, &atlas, winit::keyboard::KeyCode::Escape, None),
vec![Event::Changed]
);
assert_eq!(ui.page(), Page::Main);
assert_eq!(style(), MenuStyle::Classic);
set_style(previous_style);
assert_eq!(ui.page(), Page::Horizon);
}
#[test]
@@ -3994,15 +3984,25 @@ mod tests {
let atlas = atlas();
let mut s = Settings::default();
let mut ui = OptionsUi::default();
ui.show(Page::Extras);
for (right, expected) in [(false, "key.mouse.left"), (true, "key.mouse.right")] {
ui.selected_key = Some(crate::extras::SORT_KEY);
assert_eq!(
ui.click_horizon(&mut s, &atlas, 2.0, 2.0, [960, 480], false, right),
ui.click(
&mut s,
&atlas,
2.0,
2.0,
(480.0, 240.0),
[960, 480],
false,
right
),
vec![Event::Changed]
);
assert_eq!(s.extras.sort_key, expected);
assert_eq!(ui.selected_key, None);
assert_eq!(ui.section, 0);
assert_eq!(ui.page(), Page::Extras);
}
}
@@ -4116,30 +4116,45 @@ mod tests {
}
#[test]
fn classic_video_settings_lead_back_to_horizon_menus() {
let previous_style = style();
set_style(MenuStyle::Horizon);
fn horizon_settings_hang_off_options_and_reach_every_horizon_page() {
let s = Settings::default();
let mut ui = OptionsUi::default();
ui.push(Page::Video);
let way_back = |ui: &OptionsUi| {
ui.list_rows(&s).iter().any(|row| {
matches!(row, Row::Buttons(w, _)
if matches!(&w.kind, WKind::Button { act: Act::HorizonMenus, .. }))
})
let pushes = |ui: &mut OptionsUi| -> Vec<Page> {
let (widgets, _, _, _) = ui.layout(&s, 427.0, 240.0);
widgets
.iter()
.filter_map(|w| match &w.kind {
WKind::Button {
act: Act::Push(page),
active: true,
..
} => Some(*page),
_ => None,
})
.collect()
};
// Horizon's own menus have the choice on their Interface page.
assert!(!way_back(&ui));
set_style(MenuStyle::Classic);
let classic = way_back(&ui);
ui.horizon_menus();
assert!(classic, "Classic Video Settings offer Menu Style");
assert_eq!(style(), MenuStyle::Horizon);
assert_eq!(ui.stack, vec![Page::Main]);
// Vanilla's ten Options buttons, the last two Horizon's.
let main = pushes(&mut ui);
assert_eq!(&main[main.len() - 2..], [Page::Horizon, Page::Mods]);
ui.push(Page::Horizon);
assert_eq!(
crate::options_horizon::SECTIONS[ui.section].name,
"Interface"
pushes(&mut ui),
[
Page::Graphics,
Page::GraphicsAdvanced,
Page::ShaderPacks,
Page::Controller,
Page::Extras,
Page::Mods,
]
);
set_style(previous_style);
// Vanilla's own pages keep the Horizon pages they had.
ui.stack = vec![Page::Main, Page::Video];
let video = pushes(&mut ui);
for page in [Page::Graphics, Page::GraphicsAdvanced, Page::ShaderPacks] {
assert!(video.contains(&page), "{page:?}");
}
ui.stack = vec![Page::Main, Page::Controls];
assert!(pushes(&mut ui).contains(&Page::Controller));
}
}
-273
View File
@@ -1,273 +0,0 @@
//! The menus' backdrop treatment (`ui_theme`'s Horizon style): the finished
//! world frame is blurred (dual Kawase: three halvings down, back up) and
//! colour graded before the HUD is drawn over it. Needs a swapchain that can
//! be copied from; without one the frame is left as it is.
/// How the frame under a Horizon-style menu is treated.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct PostGrade {
/// Colour multiplier and lift (`c * tint + lift`).
pub tint: [f32; 3],
pub lift: [f32; 3],
/// Toward grey, 0..1.
pub desaturate: f32,
/// Darkening toward the corners, 0..1.
pub vignette: f32,
}
impl PostGrade {
/// The title backdrop: icy, slightly lifted shadows.
pub const FROST: Self = Self {
tint: [0.62, 0.78, 1.0],
lift: [0.0, 0.01, 0.035],
desaturate: 0.45,
vignette: 0.5,
};
/// Behind the pause menu: the world stays recognisable.
pub const PAUSE: Self = Self {
tint: [0.8, 0.86, 0.98],
lift: [0.0, 0.004, 0.012],
desaturate: 0.25,
vignette: 0.3,
};
}
#[repr(C)]
#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
struct Uniform {
texel: [f32; 4],
tint: [f32; 4],
lift: [f32; 4],
params: [f32; 4],
}
const LEVELS: usize = 3;
pub struct Post {
layout: wgpu::BindGroupLayout,
down: wgpu::RenderPipeline,
up: wgpu::RenderPipeline,
finish: wgpu::RenderPipeline,
sampler: wgpu::Sampler,
/// The copied frame, then the halvings.
levels: Vec<(wgpu::Texture, wgpu::TextureView, [u32; 2])>,
uniforms: Vec<wgpu::Buffer>,
size: [u32; 2],
format: wgpu::TextureFormat,
}
impl Post {
pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat) -> Self {
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("Menu backdrop"),
source: wgpu::ShaderSource::Wgsl(include_str!("post.wgsl").into()),
});
let layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("Menu backdrop bindings"),
entries: &[
wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Texture {
sample_type: wgpu::TextureSampleType::Float { filterable: true },
view_dimension: wgpu::TextureViewDimension::D2,
multisampled: false,
},
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
wgpu::BindGroupLayoutEntry {
binding: 2,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform,
has_dynamic_offset: false,
min_binding_size: None,
},
count: None,
},
],
});
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("Menu backdrop"),
bind_group_layouts: &[Some(&layout)],
..Default::default()
});
let pipeline = |entry: &str| {
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Menu backdrop pass"),
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: Some("vs_main"),
buffers: &[],
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: &shader,
entry_point: Some(entry),
targets: &[Some(wgpu::ColorTargetState {
format,
blend: None,
write_mask: wgpu::ColorWrites::ALL,
})],
compilation_options: Default::default(),
}),
primitive: Default::default(),
depth_stencil: None,
multisample: Default::default(),
multiview_mask: None,
cache: None,
})
};
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
label: Some("Menu backdrop"),
mag_filter: wgpu::FilterMode::Linear,
min_filter: wgpu::FilterMode::Linear,
address_mode_u: wgpu::AddressMode::ClampToEdge,
address_mode_v: wgpu::AddressMode::ClampToEdge,
..Default::default()
});
let uniforms = (0..LEVELS * 2 + 1)
.map(|_| {
device.create_buffer(&wgpu::BufferDescriptor {
label: Some("Menu backdrop pass"),
size: std::mem::size_of::<Uniform>() as u64,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
})
})
.collect();
Self {
down: pipeline("fs_down"),
up: pipeline("fs_up"),
finish: pipeline("fs_final"),
layout,
sampler,
levels: Vec::new(),
uniforms,
size: [0, 0],
format,
}
}
fn ensure(&mut self, device: &wgpu::Device, size: [u32; 2]) {
if self.size == size && !self.levels.is_empty() {
return;
}
self.size = size;
self.levels = (0..=LEVELS)
.map(|i| {
let s = [(size[0] >> i).max(1), (size[1] >> i).max(1)];
let texture = device.create_texture(&wgpu::TextureDescriptor {
label: Some("Menu backdrop level"),
size: wgpu::Extent3d {
width: s[0],
height: s[1],
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: self.format,
usage: wgpu::TextureUsages::TEXTURE_BINDING
| wgpu::TextureUsages::RENDER_ATTACHMENT
| wgpu::TextureUsages::COPY_DST,
view_formats: &[],
});
let view = texture.create_view(&Default::default());
(texture, view, s)
})
.collect();
}
fn pass(
&self,
device: &wgpu::Device,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
pipeline: &wgpu::RenderPipeline,
(from, uniform): (usize, usize),
target: &wgpu::TextureView,
data: Uniform,
) {
let (_, view, s) = &self.levels[from];
let mut data = data;
data.texel = [0.5 / s[0] as f32, 0.5 / s[1] as f32, 0.0, 0.0];
queue.write_buffer(&self.uniforms[uniform], 0, bytemuck::bytes_of(&data));
let group = device.create_bind_group(&wgpu::BindGroupDescriptor {
label: Some("Menu backdrop pass"),
layout: &self.layout,
entries: &[
wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::TextureView(view),
},
wgpu::BindGroupEntry {
binding: 1,
resource: wgpu::BindingResource::Sampler(&self.sampler),
},
wgpu::BindGroupEntry {
binding: 2,
resource: self.uniforms[uniform].as_entire_binding(),
},
],
});
let attachments = [Some(wgpu::RenderPassColorAttachment {
view: target,
resolve_target: None,
depth_slice: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: wgpu::StoreOp::Store,
},
})];
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("Menu backdrop pass"),
color_attachments: &attachments,
..Default::default()
});
pass.set_pipeline(pipeline);
pass.set_bind_group(0, &group, &[]);
pass.draw(0..3, 0..1);
}
/// Blur and grade `frame` (the swapchain texture) into `target`.
#[allow(clippy::too_many_arguments)]
pub fn apply(
&mut self,
device: &wgpu::Device,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
frame: &wgpu::Texture,
target: &wgpu::TextureView,
size: [u32; 2],
grade: &PostGrade,
) {
self.ensure(device, size);
encoder.copy_texture_to_texture(
frame.as_image_copy(),
self.levels[0].0.as_image_copy(),
wgpu::Extent3d {
width: size[0],
height: size[1],
depth_or_array_layers: 1,
},
);
let data = Uniform {
texel: [0.0; 4],
tint: [grade.tint[0], grade.tint[1], grade.tint[2], 1.0],
lift: [grade.lift[0], grade.lift[1], grade.lift[2], 0.0],
params: [grade.desaturate, grade.vignette, 0.0, 0.0],
};
let mut u = 0;
for i in 1..=LEVELS {
let target = &self.levels[i].1;
self.pass(device, queue, encoder, &self.down, (i - 1, u), target, data);
u += 1;
}
for i in (1..LEVELS).rev() {
let target = &self.levels[i].1;
self.pass(device, queue, encoder, &self.up, (i + 1, u), target, data);
u += 1;
}
self.pass(device, queue, encoder, &self.finish, (1, u), target, data);
}
}
-51
View File
@@ -1,51 +0,0 @@
// Menu backdrop: dual-Kawase blur (down and up passes) and a cold colour grade.
struct Post {
// Half a source texel (u, v), unused, unused.
texel: vec4<f32>,
// Multiplier and lift of the grade.
tint: vec4<f32>,
lift: vec4<f32>,
// Desaturation, vignette, unused, unused.
params: vec4<f32>,
}
@group(0) @binding(0) var src: texture_2d<f32>;
@group(0) @binding(1) var samp: sampler;
@group(0) @binding(2) var<uniform> post: Post;
struct Out {
@builtin(position) clip: vec4<f32>,
@location(0) uv: vec2<f32>,
}
@vertex fn vs_main(@builtin(vertex_index) i: u32) -> Out {
let p = vec2<f32>(f32((i << 1u) & 2u), f32(i & 2u));
var out: Out;
out.clip = vec4(p * 2.0 - 1.0, 0.0, 1.0);
out.uv = vec2(p.x, 1.0 - p.y);
return out;
}
fn s(uv: vec2<f32>) -> vec3<f32> {
return textureSampleLevel(src, samp, uv, 0.0).rgb;
}
@fragment fn fs_down(in: Out) -> @location(0) vec4<f32> {
let h = post.texel.xy;
let c = s(in.uv) * 4.0 + s(in.uv - h) + s(in.uv + h) + s(in.uv + vec2(h.x, -h.y)) + s(in.uv - vec2(h.x, -h.y));
return vec4(c / 8.0, 1.0);
}
fn up(uv: vec2<f32>) -> vec3<f32> {
let h = post.texel.xy;
var c = s(uv + vec2(-h.x * 2.0, 0.0)) + s(uv + vec2(h.x * 2.0, 0.0));
c += s(uv + vec2(0.0, -h.y * 2.0)) + s(uv + vec2(0.0, h.y * 2.0));
c += (s(uv + vec2(-h.x, h.y)) + s(uv + vec2(h.x, h.y)) + s(uv + vec2(-h.x, -h.y)) + s(uv + vec2(h.x, -h.y))) * 2.0;
return c / 12.0;
}
@fragment fn fs_up(in: Out) -> @location(0) vec4<f32> {
return vec4(up(in.uv), 1.0);
}
@fragment fn fs_final(in: Out) -> @location(0) vec4<f32> {
var c = up(in.uv);
let l = dot(c, vec3(0.2126, 0.7152, 0.0722));
c = mix(c, vec3(l), post.params.x);
c = c * post.tint.rgb + post.lift.rgb;
let d = length((in.uv - 0.5) * vec2(1.25, 1.0));
c *= 1.0 - post.params.y * smoothstep(0.35, 0.95, d);
return vec4(clamp(c, vec3(0.0), vec3(1.0)), 1.0);
}
+1 -1
View File
@@ -33,7 +33,7 @@ pub fn mark_start() {
STARTED.get_or_init(Instant::now);
}
/// The menu bundle is ready: the title backdrop can draw. The first writer wins.
/// The menu bundle is ready: the title screen can draw. The first writer wins.
pub fn mark_ui_ready() {
if let Some(started) = STARTED.get() {
let ms = started.elapsed().as_millis() as u32;
+16 -20
View File
@@ -142,10 +142,6 @@ pub struct Title {
toast: Option<(crate::toasts::Slide, BackupToast)>,
icons: RefCell<std::collections::HashMap<PathBuf, (std::time::SystemTime, Option<Vec<u8>>)>>,
splash: Option<String>,
/// The mode last drawn and when it appeared (Horizon's screen fades).
shown: std::cell::Cell<(std::mem::Discriminant<Mode>, std::time::Instant)>,
/// The launcher-style opening (Horizon style, first title of the session).
pub opening: std::cell::Cell<Option<crate::front::Opening>>,
/// The saves listed for Home, re-read every couple of seconds.
recent: std::cell::RefCell<Option<(std::time::Instant, Vec<WorldEntry>)>>,
}
@@ -232,7 +228,6 @@ impl Title {
let mode = Mode::Main;
let now = std::time::Instant::now();
Self {
shown: std::cell::Cell::new((std::mem::discriminant(&mode), now)),
mode,
last_server: String::new(),
saves,
@@ -256,7 +251,6 @@ impl Title {
.subsec_nanos() as usize,
(today.month(), today.day()),
),
opening: std::cell::Cell::new(None),
recent: std::cell::RefCell::new(None),
}
}
@@ -517,17 +511,6 @@ impl Title {
}
}
}
/// When the current mode first appeared.
pub fn entered(&self) -> std::time::Instant {
let now = std::mem::discriminant(&self.mode);
let (mode, at) = self.shown.get();
if mode == now {
return at;
}
let at = std::time::Instant::now();
self.shown.set((now, at));
at
}
/// Create New World: the folder name and options (FileUtil.findAvailableName).
pub fn create_action(&self) -> Action {
let Mode::Create {
@@ -597,7 +580,9 @@ impl Title {
b(cx + 2.0, y + 96.0, 98.0, "Quit Game", true, 2),
];
for (i, (label, enabled, id, icon, size)) in [
("Friends", false, 5, "friends/friends", 15.0),
// Horizon's Join a Friend (an invite code) behind
// vanilla's Friends button.
("Friends", true, 5, "friends/friends", 15.0),
("Language", true, 6, "icon/language", 15.0),
(
"Accessibility Settings",
@@ -1207,6 +1192,10 @@ impl Title {
crate::multiplayer::Outcome::Connect(address) => Action::Connect { address },
crate::multiplayer::Outcome::None => Action::None,
},
(Mode::Main, Some(5)) => {
self.mode = Mode::Multiplayer(crate::multiplayer::Screen::friend());
Action::None
}
(Mode::Main, Some(3)) => Action::Options,
(Mode::Main, Some(7)) => Action::Accessibility,
(Mode::Main, Some(6)) => Action::Language,
@@ -1669,7 +1658,7 @@ mod classic_tests {
let cx = (w / 2.0).floor();
let y = (h / 4.0).floor() + 48.0;
for (id, x, enabled, icon) in [
(5, cx - 34.0, false, "friends/friends"),
(5, cx - 34.0, true, "friends/friends"),
(6, cx - 10.0, true, "icon/language"),
(7, cx + 14.0, true, "icon/accessibility"),
] {
@@ -1683,9 +1672,16 @@ mod classic_tests {
match id {
6 => (Action::Language, true),
7 => (Action::Accessibility, true),
_ => (Action::None, false),
_ => (Action::None, true),
}
);
if id == 5 {
assert!(matches!(
title.mode,
Mode::Multiplayer(crate::multiplayer::Screen::Friend { .. })
));
title.mode = Mode::Main;
}
}
for id in [2, 3] {
assert_eq!(buttons.iter().find(|b| b.id == id).unwrap().y, y + 96.0);
@@ -38,7 +38,7 @@ pub(super) fn reset_icon(saves: &Path, folder: &str) -> crate::Result<()> {
Ok(())
}
/// `LevelStorageAccess.deleteLevel`, shared by both menu styles. The world's
/// `LevelStorageAccess.deleteLevel`. The world's
/// session lock is taken first, so a world open in this or another instance is
/// refused rather than pulled from under it; everything but the lock goes,
/// then the lock is released and removed with the folder. A failed pass (a
File diff suppressed because it is too large Load Diff
+4 -5
View File
@@ -1,7 +1,7 @@
//! The labelled widgets and focus targets drawn in the last frame, for the
//! control socket: a script clicks a button by its label (`horizon-ctl
//! click-button Respawn`) or any widget by its id in [`tree`] (`horizon-ctl
//! click done`), whatever screen or menu style drew it.
//! click done`), whatever screen drew it.
use std::cell::RefCell;
/// A labelled widget in GUI pixels (the coordinates screens take input in).
@@ -21,7 +21,7 @@ pub struct Widget {
/// navigation").
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Kind {
/// Clicked with A (buttons, switches, segments, sidebar items).
/// Clicked with A (buttons, icon buttons, keys).
Button,
/// Left and right move the value instead of focus; A does nothing (a
/// click would jump the handle to the middle). `value` is 0..1 as drawn;
@@ -53,9 +53,8 @@ impl Target {
thread_local! {
/// Buttons drawn since the last `end_frame`, and the last frame's.
static WIDGETS: RefCell<(Vec<Widget>, Vec<Widget>, u64)> = const { RefCell::new((Vec::new(), Vec::new(), 0)) };
/// Every interactive rectangle (Horizon-style menus' sidebar items,
/// switches, sliders, segments; classic sliders, fields and list rows),
/// labelled or not: where a controller can move focus. Drawn since
/// Every interactive rectangle (sliders, fields, list rows, the
/// on-screen keyboard's keys), labelled or not: where a controller can move focus. Drawn since
/// `end_frame`, the last frame's, and how many frames rotated.
static TARGETS: RefCell<(Vec<Target>, Vec<Target>, u64)> = const { RefCell::new((Vec::new(), Vec::new(), 0)) };
}
+1 -1
View File
@@ -1,5 +1,5 @@
//! Horizon's design tokens, the one source of truth for the launcher (`launcher/src/theme.rs`),
//! the game's own menus (`horizon-client`'s `ui_theme`) and the website (`website/src/tokens.css`,
//! the game's on-screen keyboard (`horizon-client`'s `ui_theme`) and the website (`website/src/tokens.css`,
//! generated from [`css`] by `cargo run -p xtask -- tokens`). Change a value here and all three
//! follow. The system is described in `docs/design-system.md`.
//!
+1 -1
View File
@@ -20,7 +20,7 @@ To play, use [the launcher](../launcher/README.md); the project site is [playhor
- [Resource packs](resource-packs.md): everything a 26.3 resource pack can change, whether Horizon honours it, and the proof.
- [Opt-in data collection](telemetry.md): the consent, exactly what is sent, how it is stored and sent.
- [Benchmark report format](benchmark-report.md): the versioned JSON every benchmark writes (game, launcher, `tools/perf_bench.py`), the local log and, with consent, the upload.
- Menus: the title, world list, create world, multiplayer, options and pause screens share the launcher's design tokens and fonts (`crates/horizon-theme`), drawn by `ui_theme` over a live frozen backdrop (`game/backdrop.rs`, blurred and graded by `post.rs`). Options → Interface → Menu style switches to vanilla's screens (Classic, kept in `horizon.txt`; `HORIZON_MENU_STYLE=horizon|classic` overrides it, and scripted runs default to Classic). [Title](media/menu-title.png) ([webm](media/menu-title.webm)), [worlds](media/menu-worlds.png), [options](media/menu-options.png), [pause](media/menu-pause.png).
- Menus: every screen is vanilla's (title, world list, create world, multiplayer, options, pause). Horizon's own settings hang off vanilla's Options the way mods add theirs: **Horizon Settings...** and **Mods...** in the last two slots of the Options grid (Horizon Settings opens Graphics, Advanced Graphics, Shader Packs, Controller Settings, Extras and Mods, each a vanilla options list), with Horizon Graphics, Advanced Graphics and Shader Packs also at the top of Video Settings and Controller Settings at the bottom of Controls. The title screen's and pause menu's Friends buttons open Join a Friend and Play with Friends ([play-with-friends.md](play-with-friends.md)).
## Parity
+3 -5
View File
@@ -29,7 +29,6 @@ Legend: **yes** complete, **part** partial (see note), **no** missing, **—** n
| Dedicated server: start, console, log, stop | yes | yes | yes | |
| Accounts (no secrets) | yes | yes | yes | names and UUIDs only; sign-in is a device code the player enters |
| Launcher settings (game folder, auto-install, opening animation, desktop entry) | yes | part | no | CLI has `desktop-entry`; the rest only in the window |
| Game menu style | yes | yes | yes | |
| Logs, crash report | yes | yes | yes | |
| Updates (Horizon and launcher) | yes | yes | yes | MCP only checks |
| Patch notes, links | yes | yes | yes | |
@@ -76,7 +75,7 @@ Legend: **yes** complete, **part** partial (see note), **no** missing, **—** n
| Capability | Before | After |
| --- | --- | --- |
| Screens: widgets | labelled buttons only | every widget of every screen (`ui`): id, kind, label, bounds, slider value, tab selected, slots with stacks; both menu styles |
| Screens: widgets | labelled buttons only | every widget of every screen (`ui`): id, kind, label, bounds, slider value, tab selected, slots with stacks |
| Screens: act on a widget | `click-button LABEL`, `click-at X Y` | `click ID [right\|middle] [shift]`, `set ID VALUE` (sliders), `click` focuses fields |
| Options | open a page; `render-distance` only | `options-get` all 193 `options.txt` options typed with ranges/choices; `options-set` validates, applies, saves |
| Waits | `wait TICKS`, `wait-ready` | `wait-for screen\|widget\|loaded\|chat\|event` with timeout errors |
@@ -111,7 +110,7 @@ Legend: **yes** complete, **part** partial (see note), **no** missing, **—** n
### Structured UI: the widget tree
`ui` returns every interactive element the last frame drew, on every screen (title menus,
pause, options pages, inventories and stations, chat, death, Horizon-style menus):
pause, options pages, inventories and stations, chat, death, Play with Friends):
```json
{"screen": "options", "gui_size": [427, 240], "frame": 3061,
@@ -126,8 +125,7 @@ pause, options pages, inventories and stations, chat, death, Horizon-style menus
`Video Settings...` → `video-settings`); a repeated slug gets `-2`, `-3` in draw order;
unlabelled elements are `<kind>-<n>` in draw order. The id of a slider does not change
when its value (and so its label) does. World, server and language rows carry their
names; Horizon-style switches, sliders and segments carry their settings row's caption
(`vsync`, `menu-style-horizon`); inventory, creative and menu slots are `slot-<ID>` with
names; inventory, creative and menu slots are `slot-<ID>` with
their stack (an item tab's display slots are `slot-900` up).
- **Kinds**: `button`, `slider` (`value` 0..1 as drawn), `field` (text box), `row` (list
entry: world, server, pack, language), `tab` (`selected`), `slot`.
+15 -19
View File
@@ -97,9 +97,8 @@ real mouse hands control back at once.
Every interactive rectangle a screen draws registers itself as a focus
target with its kind (`widgets::target_as`): classic buttons, sliders, edit
boxes and list rows (worlds, servers, languages), every Horizon-style widget
(`ui_theme::Ui::interact`: sidebar items, switches, segments, sliders,
fields, buttons), inventory and container slots, creative and recipe-book
boxes and list rows (worlds, servers, languages), icon buttons (the title's
and pause menu's Friends button), inventory and container slots, creative and recipe-book
tabs, and the stations' own buttons (trades, loom patterns, beacon effects,
enchantments, stonecutter recipes, the recipe book's recipes, pages and
filter). A screen that registers nothing falls back to the pointer.
@@ -137,16 +136,11 @@ the crafting result, armour to the player's grid.
- **Where focus lands** when a screen opens: the held hotbar slot in an
inventory, else the first button.
How it looks follows the menu style:
- **Classic screens** look as vanilla's own keyboard focus does: buttons,
sliders and slots show their highlighted sprite (`isHoveredOrFocused`,
drawn because the hidden pointer is over them), and list rows and text
fields get vanilla's white one-pixel outline (`AbstractSelectionList`'s
focused selection, `EditBox`'s highlighted border).
- **Horizon-style screens** get the design system's focus colour: a two-dp
ring in the accent colour around the focused widget, pill-shaped on
buttons, tabs and sliders.
It looks as vanilla's own keyboard focus does: buttons, sliders and slots
show their highlighted sprite (`isHoveredOrFocused`, drawn because the hidden
pointer is over them), and list rows and text fields get vanilla's white
one-pixel outline (`AbstractSelectionList`'s focused selection, `EditBox`'s
highlighted border).
### Pointer
@@ -183,8 +177,8 @@ Steam + X opens it at any time. "On-Screen Keyboard: Auto / Horizon / Steam"
Both modes reach every screen through the pointer events. Focus mode
registers targets on: the title menus (main, world list and its search, create
and edit world, delete, multiplayer list and its edit screens), every options
page (classic pages and the Horizon-style sections, key and controller binds,
language list), pause, death, chat, signs and books (their buttons), the
page (vanilla's and Horizon Settings with the pages it opens, key and
controller binds, language list), pause and Play with Friends, death, chat, signs and books (their buttons), the
survival and creative inventories, every container and station (chests,
furnaces, brewing, crafter, crafting table with its recipe book, anvil,
grindstone, smithing, stonecutter, loom, cartography, enchanting, beacon,
@@ -212,8 +206,10 @@ hints, "Press X to dismount") only while the pad is the last-used input.
## Options and remapping
Controller settings are Horizon's own and live in `horizon-controller.txt`
next to `options.txt`, like `horizon-graphics.txt`: `options.txt` stays
Controller settings are Horizon's own: **Options → Controls → Controller
Settings...** (or **Options → Horizon Settings... → Controller Settings...**),
a vanilla options list with **Controller Binds...** at the top. They live in
`horizon-controller.txt` next to `options.txt`, like `horizon-graphics.txt`: `options.txt` stays
exactly vanilla's, so a vanilla client can share the game folder.
```
@@ -490,8 +486,8 @@ The first round (input layer, menus, glyphs and options, rumble) shipped in
PRs #120, #129, #145 and #149. The second round, each shippable alone:
1. **Focus navigation** (this section above): the menu navigation option,
focus targets and vanilla's arrow-key step, the focus highlight in both
menu styles, the on-screen keyboard.
focus targets and vanilla's arrow-key step, vanilla's focus highlight,
the on-screen keyboard.
2. **Button prompts**: contextual hints with the pad's glyphs in menus and
optionally in game, and rebinding from them.
3. **DualSense output** (above): the HID output layer and rumble through it
+6 -7
View File
@@ -1,8 +1,9 @@
# Horizon's design system
One design language for the launcher, the website and the game's own menus (what "Menu style:
Horizon" draws). Vanilla's classic screens and the HUD are not part of it: they stay exactly
vanilla, because parity is the point of the game.
One design language for the launcher, the website and the few overlays the game draws that
vanilla has no screen for (the on-screen keyboard a controller types with). Every game screen
and the HUD are not part of it: they are vanilla's, because parity is the point of the game, and
Horizon's own settings are pages built from vanilla's widgets, the way mods add theirs.
The tokens live in one place, `crates/horizon-theme`. The launcher (`launcher/src/theme.rs`)
and the game (`crates/horizon-client/src/ui_theme.rs`) read them as Rust constants, and the
@@ -145,10 +146,8 @@ Geist (400, 500, 600) and Geist Mono (400), bundled under the SIL Open Font Lice
12, no frame). Light and dark follow the system, with a toggle. A giant faint wordmark sits
above the footer. No hero photograph: the first screen is the headline, one paragraph, the
download button and the parity score as an index row.
- **Game menus** (Horizon style): the title backdrop under a page-colour veil; text sidebar;
index lists for worlds and servers; options pages as index lists of rows (label left, value
in mono, the control right). The pause menu is a centred column of plain rows over a darker
veil.
- **Game**: vanilla's screens. The on-screen keyboard is a rounded plate of keys in the page
colour, the focused key in the accent.
## The mark
+5 -4
View File
@@ -19,11 +19,12 @@ again restores vanilla's behaviour completely.
| Game glue (input hooks, per-frame update) | `crates/horizon-client/src/game/extras.rs` |
| Mouse Tweaks-style controls, sort buttons | `crates/horizon-client/src/game/tweaks.rs` |
| Sort order and its clicks | `crates/horizon-client/src/inv_sort.rs` (pure, unit tested) |
| The settings page | `options_horizon.rs`: the **Extras** section of Horizon's Options |
| The settings page | `options_ui.rs` (`Page::Extras`): **Options → Horizon Settings... → Extras...** |
The settings are grouped by extra. On Horizon's page an extra's own settings
(its key, corner, size...) show under its switch while it is on (`Item::parent`);
Classic's Horizon Extras screen lists them all, two buttons to a row.
The settings are grouped by extra, under a header each, two buttons to a row as
vanilla's options lists are, and each says what it does in its tooltip. An
extra's own settings (its key, corner, size...) are greyed out while its switch
is off (`Item::parent`).
`game.rs` only gets one-line hooks (key, wheel, mouse, frame, HUD), so the
extras stay out of the way of other input and options work.
+7 -7
View File
@@ -2,17 +2,17 @@
## Settings
In the Horizon menu style, the Options screen's **Video** section holds the graphics settings, with a Simple / Advanced switch at the top (remembered between sessions):
Horizon's graphics settings are two screens built from vanilla's widgets, opened from the top of **Video Settings** (**Horizon Graphics...** and **Advanced Graphics...**, beside **Shader Packs...**, where Sodium and Iris put theirs) or from **Options → Horizon Settings...**:
- **Simple**: a preset (Performance, Balanced, Quality, Ultra or Custom), render distance, LOD distance, FOV, max framerate, VSync and GUI scale.
- **Advanced**: every setting, grouped under Rendering, Quality, Display, Preferences, Performance and Overlay.
- **Graphics** (Simple): a preset (Performance, Balanced, Quality, Ultra or Custom) and LOD distance.
- **Advanced Graphics**: every Horizon setting, grouped under Rendering, Quality, Display, Preferences, Performance and Overlay.
In the Classic style, Video Settings starts with two buttons opening the same settings as vanilla-looking screens.
Vanilla's own settings (render distance, FOV, framerate, VSync, GUI scale, smooth lighting...) stay where vanilla has them, in Video Settings; both screens leave them out.
Every row has a one-line description and its cost in frame time (none, low, medium, high, or saves time for culling that makes frames faster), and applies at once, except worker threads, which apply at the next start. A preset sets the quality settings together; changing one of them turns it into Custom. Display preferences (FOV, framerate, VSync, GUI scale, fullscreen, present mode, pacing) leave the preset as it is.
![Simple](media/settings-simple.png)
![Advanced](media/settings-advanced.png)
![Video Settings, with Horizon's buttons at the top](media/settings-simple.png)
![Advanced Graphics](media/settings-advanced.png)
| Group | Setting | Stored in |
| --- | --- | --- |
@@ -29,7 +29,7 @@ Every row has a one-line description and its cost in frame time (none, low, medi
**Battery mode** (Performance, off by default) is for laptops and handhelds: at most 60 frames per second in a world, 30 in menus without a world or while another window has focus, and half the automatic worker threads (chunks load slower). It changes only when frames are drawn: what they show and the game's 20 ticks per second stay as they are.
Which settings each level shows, their descriptions and costs are in `crates/horizon-client/src/graphics_ui.rs` (`rows`); the Horizon shell draws them in `options_horizon.rs` with `ui_theme::described_row`, and the Classic screens use `graphics_style.rs`.
Which settings each screen shows, their descriptions and costs are in `crates/horizon-client/src/graphics_ui.rs` (`rows`); `graphics_style.rs` draws them.
## Distant terrain
Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 569 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 569 KiB

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 76 KiB

+1 -1
View File
@@ -110,7 +110,7 @@ loading. Ordered by what the first native ports need ([research](research/java-m
| `target` | the crosshair's block or entity, with its state and NBT summary | Jade/WTHIT-style tooltips |
| `inventory-read` | the player's inventory, held item, open container | AppleSkin, recipe viewers |
| `recipes` | the recipe registry and lookups | JEI/EMI-style viewers |
| `ui` | widgets: text, item icons, lists, a screen the mod owns, a settings page in Options > Mods | built on `ui_theme` so it matches the menus |
| `ui` | widgets: text, item icons, lists, a screen the mod owns, a settings page in Options > Mods | built from vanilla's widgets (`ui`) so it matches the menus |
| `world-read` | blocks and biomes around the player, within the render distance | minimaps, schematics |
| `render` | world-space lines, boxes and ghost blocks in a per-frame budget | Litematica-style placement, waypoints |
| `registries` | new blocks, items, entities and recipes, mostly data: JSON models, textures, loot and recipes in the `.hmod`'s `assets/` and `data/` | server side; see [Multiplayer](#multiplayer) |
+2 -2
View File
@@ -119,7 +119,7 @@ game accepts, test hooks included.
`place X Y Z [--item ITEM]`, `interact X Y Z` (doors, chests, crafting
tables), `use-item [--hold S]` (eat, drink, throw), `select SLOT|ITEM`, `drop`.
- **Widgets:** `ui` lists every widget of the open screen (title menus, pause,
options pages in both menu styles, inventories and menus): an id, its kind
options pages, inventories and menus): an id, its kind
(`button`, `slider` with its 0..1 `value`, `field`, `row`, `tab` with
`selected`, `slot` with its stack), the label and its bounds. Ids come from
labels (`FOV: 70` is `fov`, `Video Settings...` is `video-settings`, a
@@ -144,7 +144,7 @@ game accepts, test hooks included.
- **Screens:** `open-inventory`, `click-slot SLOT [right] [shift]` (0-8 hotbar,
9-35 inventory, 100+ crafting grid, 200 result, 300+ containers, 500-503
armor, 504 offhand, 600+ stations), `close`, `click-button LABEL` (any
button of any screen or title menu, classic or Horizon style, by its label),
button of any screen or title menu, by its label),
`click-at X Y`, `type TEXT` (on the create-world screen `--field name|seed
--replace`), `chat`, `command`, `respawn`, `pause`, `resume`.
- **World:** `tp`, `give`, `time`, `setblock`, `summon`, `wait TICKS`, and the
+6 -3
View File
@@ -1,7 +1,8 @@
# Play with friends
A player opens their single-player world to friends with one click and gets an **invite code**.
Friends paste the code (on the multiplayer screen in game, or on the launcher's Play page) and join.
Friends paste the code (in game: the title screen's Friends button opens Join a Friend, and Direct
Connection takes a full code too; or on the launcher's Play page) and join.
There is no Horizon server in the middle and no account: the code itself says where the host is and
holds the key that encrypts the game between them.
@@ -22,7 +23,8 @@ bytes vanilla's protocol would send, between a loopback port on each side.
## How it works
**Hosting.** "Invite friends" (in Horizon's pause menu) opens the world to LAN if it isn't (Open to
**Hosting.** The pause menu's Friends button (vanilla's icon, beside Player Reporting) opens **Play
with Friends** (`friends_screen.rs`); its **Start Sharing** opens the world to LAN if it isn't (Open to
LAN's defaults), then the host's game, on its own:
1. listens on its **direct port**, TCP 25580 by default (the same port every time, so a port forwarded
@@ -59,7 +61,8 @@ port closes, the router mapping is deleted). Sharing again makes a new secret.
## When friends can't reach the host
The host's panel says what to expect, from what the game found:
Play with Friends says what to expect, from what the game found; when friends on the internet can't
reach the host, its **Troubleshooting...** button (beside Done) opens this section in the browser:
| What the game found | What the host reads |
| --- | --- |
+3 -4
View File
@@ -44,8 +44,7 @@ Everything is in `crates/horizon-client/src/gfx.rs`, `Renderer::render`, one com
4. **Screen effects** (`screen_effects.rs`): pumpkin blur, portal, powder snow, vignette, nausea, as
full-screen quads.
5. **Menu blur** (`menu_blur.rs`, `menu_blur.wgsl`): vanilla's `menuBackgroundBlurriness` behind screens.
6. **Menu grade** (`post.rs`, `post.wgsl`): the Horizon menus' frosted backdrop.
7. **HUD** (`hud.rs`, `hud.wgsl`): GUI, text, items in slots.
6. **HUD** (`hud.rs`, `hud.wgsl`): GUI, text, items in slots.
All world shaders share one uniform block, `Globals` in `gfx.rs` (`struct Globals` in `terrain.wgsl`):
view-projection, inverse view, fog colour and distances, sky colour, sun direction, sunrise colour, game time.
@@ -60,8 +59,8 @@ The lightmap, fog and sky colours are computed on the CPU (`environment.rs`, `fo
`~/Library/Application Support/horizon` on macOS, `~/.local/share/horizon` on Linux), not the launcher's version
folder. A pack with a `pack.toml` at its root is a Horizon pack; a folder with `shaders/`, or a `.zip`, is a Java
pack.
- The **Shader Packs** page lists them: a sidebar section in the Horizon menus, **Video Settings → Shader Packs...**
in the Classic ones, and the Shader Pack row of the graphics settings leads to it. It shows the folder's full path
- The **Shader Packs** page lists them: **Video Settings → Shader Packs...** (where Iris puts its button), **Options →
Horizon Settings... → Shader Packs...**, and the Shader Pack row of the graphics settings lead to it. It shows the folder's full path
and an *Open Folder* button (the folder is made if it is missing), then one switch per pack: turning one on picks
it, turning it off is the vanilla picture. With no pack, it says so under the path. The list is read again every
second while the page is open, so a pack dropped into the folder shows up.
+6 -12
View File
@@ -79,9 +79,8 @@ page `servers.json` (the list), `servers/<name>/` (the servers created there) an
- **Settings**: install new Horizon versions automatically (on unless you turn it off; the
selected version only moves to the new one if you were on the newest), which ones (Updates,
below), the opening animation,
the game's menu style, the game's extra command-line arguments, and the launcher's own version
and update state.
below), the opening animation, the game's extra command-line arguments, and the launcher's own
version and update state.
- **Updates**: **Stable** (the default) installs a tested build about once a day, the betas that
`promote.yml` makes stable; **Alpha** installs every release as soon as it is built, several
times a day, and can break (docs/release-flow.md, "Channels"). While it is open, the launcher
@@ -94,10 +93,6 @@ page `servers.json` (the list), `servers/<name>/` (the servers created there) an
launcher's own arguments, kept as `game_args` in `settings.json`, and apply the next time the
game starts. `horizon-launcher game-args "<line>"` sets them too, and `play --arg <ARG>` passes
one for a single run.
- **Menu style**: Horizon's own menus or Classic (vanilla's screens). Classic has no way back
inside the game, so the launcher is where you return to Horizon's. It is the `menuStyle:` line
of `horizon.txt` in the game's home folder (`HORIZON_HOME`, else `horizon` in the data
directory), which the game reads when it starts.
- **Links**: the Discord invite, the Sponsors page and the website come from `launcher/links.json` on main
(`{"discord": "...", "sponsor": "...", "website": "..."}`), so they change without a launcher release. Offline,
the launcher uses the same values built in; an empty address hides its button.
@@ -139,7 +134,6 @@ The same binary is a command-line tool; without a subcommand it opens the window
horizon-launcher server [--dir <dir>] [--version <tag>] [--accept-eula]
horizon-launcher notes [<tag>] patch notes as plain text
horizon-launcher links the Discord, sponsor and website links
horizon-launcher menu-style [horizon|classic] show or set the game's menu style
horizon-launcher update-channel [stable|alpha] show or set which releases install by themselves
horizon-launcher game-args [<line>] show or set the extra arguments the game starts with
horizon-launcher update [--check] Horizon and the launcher
@@ -174,7 +168,7 @@ The same binary is a command-line tool; without a subcommand it opens the window
horizon-launcher data benchmark <report.json> upload a benchmark report, printed first
`--json` prints JSON where there is something to report (`versions`, `install`, `notes`,
`next`, `links`, `menu-style`, `update-channel`, `game-args`, `update --check`, `logs`, `account`, `benchmark`, `data`, `modpack`). Errors go to stderr with exit code 1. `server` runs in the terminal,
`next`, `links`, `update-channel`, `game-args`, `update --check`, `logs`, `account`, `benchmark`, `data`, `modpack`). Errors go to stderr with exit code 1. `server` runs in the terminal,
so lines you type reach its console. `HORIZON_LAUNCHER_HOME` replaces the data folder (for
scripts and tests).
@@ -186,7 +180,7 @@ scripts and tests).
(with the full path to the binary if it is not on your `PATH`). Its tools: `list_versions`,
`install_version`, `remove_version`, `prepare_resources`, `launch_client`, `start_server`,
`server_command`, `server_log`, `stop_server`, `patch_notes`, `links`, `menu_style`, `update_channel`, `logs`,
`server_command`, `server_log`, `stop_server`, `patch_notes`, `links`, `update_channel`, `logs`,
`check_updates`, `accounts`, `sign_in` (returns the link and code for the player; the sign-in
finishes in the background), `sign_out`, `select_account`, and for data collection
`data_collection`, `set_data_collection`, `data_preview`, `delete_my_data` and `report_bug`
@@ -265,9 +259,9 @@ workflow builds all three platforms on every push to the `launcher` branch (or a
client starts (`--help`) and that the binaries import only system libraries (Windows).
cargo test --lib # tag separation, version order, update selection, notes as text,
# the auto-install default, the links fallback, the menu style file
# the auto-install default, the links fallback
Geist and Geist Mono (SIL Open Font License, `crates/horizon-theme/fonts/OFL-*.txt`, shared with the game's menus) are
Geist and Geist Mono (SIL Open Font License, `crates/horizon-theme/fonts/OFL-*.txt`, shared with the game's on-screen keyboard) are
bundled so the type is the same on every platform.
-83
View File
@@ -1410,65 +1410,6 @@ pub fn read_logs(lines: usize, crash: bool) -> Result<(PathBuf, String), String>
Ok((path, text))
}
/// Which drawing the game's menus use. Classic is vanilla's own screens, which have no way to
/// switch back, so the launcher is where the player returns to Horizon's.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MenuStyle {
Horizon,
Classic,
}
impl MenuStyle {
pub fn name(self) -> &'static str {
match self {
MenuStyle::Horizon => "horizon",
MenuStyle::Classic => "classic",
}
}
pub fn parse(name: &str) -> Option<Self> {
match name {
"horizon" => Some(MenuStyle::Horizon),
"classic" => Some(MenuStyle::Classic),
_ => None,
}
}
/// The style `horizon.txt` holds: Horizon unless it has the line `menuStyle:classic`, as the
/// game reads it (crates/horizon-client/src/ui_theme.rs).
fn from_file(text: &str) -> Self {
if text.lines().any(|l| l.trim() == "menuStyle:classic") {
MenuStyle::Classic
} else {
MenuStyle::Horizon
}
}
/// `text` with its `menuStyle:` line set to this style and every other line kept.
fn into_file(self, text: &str) -> String {
let mut out: Vec<String> = text
.lines()
.filter(|l| !l.trim().starts_with("menuStyle:"))
.map(String::from)
.collect();
out.insert(0, format!("menuStyle:{}", self.name()));
out.join("\n") + "\n"
}
}
/// The menu style saved in the game home's `horizon.txt` (Horizon when there is none).
pub fn menu_style() -> MenuStyle {
MenuStyle::from_file(&fs::read_to_string(game_home().join("horizon.txt")).unwrap_or_default())
}
pub fn set_menu_style(style: MenuStyle) -> Result<(), String> {
let home = game_home();
fs::create_dir_all(&home).map_err(|e| e.to_string())?;
let file = home.join("horizon.txt");
let text = style.into_file(&fs::read_to_string(&file).unwrap_or_default());
fs::write(file, text).map_err(|e| e.to_string())
}
/// Splits the player's extra game arguments (Settings' one line) into words, the way a shell
/// would: spaces separate them, single or double quotes group a word with spaces in it, and a
/// backslash escapes the next character (outside quotes, or inside double quotes).
@@ -2919,30 +2860,6 @@ mod tests {
assert_eq!(Links::parse(r#"{"mastodon": "https://x.y/z"}"#), defaults);
}
#[test]
fn menu_style_file_matches_the_games() {
assert_eq!(MenuStyle::from_file(""), MenuStyle::Horizon);
assert_eq!(
MenuStyle::from_file("menuStyle:horizon\n"),
MenuStyle::Horizon
);
assert_eq!(
MenuStyle::from_file("menuStyle:classic\n"),
MenuStyle::Classic
);
assert_eq!(
MenuStyle::from_file("other:1\nmenuStyle:classic\n"),
MenuStyle::Classic
);
assert_eq!(MenuStyle::Classic.into_file(""), "menuStyle:classic\n");
assert_eq!(
MenuStyle::Horizon.into_file("menuStyle:classic\nother:1\n"),
"menuStyle:horizon\nother:1\n"
);
assert_eq!(MenuStyle::parse("classic"), Some(MenuStyle::Classic));
assert_eq!(MenuStyle::parse("vanilla"), None);
}
#[test]
fn a_new_version_reuses_resources_prepared_by_a_compatible_one() {
let versions =
-17
View File
@@ -271,12 +271,6 @@ enum Cmd {
#[command(subcommand)]
action: Option<AccountCmd>,
},
/// Show or set the game's menu style (classic is vanilla's own screens)
MenuStyle {
/// Omit to show the current style
#[arg(value_parser = ["horizon", "classic"])]
style: Option<String>,
},
/// Show or set which Horizon releases install by themselves: stable (a tested build about once
/// a day) or alpha (every release as soon as it is built; can break)
UpdateChannel {
@@ -548,17 +542,6 @@ fn execute(command: Cmd, as_json: bool) -> Result<(), String> {
}
}
}
Cmd::MenuStyle { style } => {
if let Some(style) = style.as_deref().and_then(backend::MenuStyle::parse) {
backend::set_menu_style(style)?;
}
let style = backend::menu_style().name();
if as_json {
json(serde_json::json!({ "menu_style": style }));
} else {
println!("Menu style: {style}");
}
}
Cmd::UpdateChannel { channel } => {
let mut settings = backend::Settings::load();
if let Some(channel) = channel.as_deref().and_then(backend::UpdateChannel::parse) {
+7 -36
View File
@@ -124,7 +124,6 @@ struct Launcher {
settings: Settings,
/// The Discord, sponsor and website links: built in until links.json on main has been read.
links: backend::Links,
menu_style: backend::MenuStyle,
preparing: bool,
prepare_log: VecDeque<String>,
prepare_error: Option<String>,
@@ -257,7 +256,6 @@ impl Launcher {
args_focus: cx.focus_handle(),
settings,
links: backend::Links::default(),
menu_style: backend::menu_style(),
preparing: false,
prepare_log: VecDeque::new(),
prepare_error: None,
@@ -1870,24 +1868,6 @@ impl Launcher {
cx.notify();
}),
);
let this = cx.entity().downgrade();
let menus = segments(
"menu-style",
&[
(backend::MenuStyle::Horizon, "Horizon"),
(backend::MenuStyle::Classic, "Classic"),
],
self.menu_style,
&t,
move |style, _, cx| {
let _ = this.update(cx, |this, cx| {
if backend::set_menu_style(style).is_ok() {
this.menu_style = style;
}
cx.notify();
});
},
);
let horizon = match (&self.updates.horizon, &self.update_error) {
(Some(r), _) => format!("{} available", r.tag),
(None, Some(e)) => e.clone(),
@@ -1983,7 +1963,7 @@ impl Launcher {
.gap(px(32.))
.child(page_header(
"Settings",
"Accounts, updates, menus, and the launcher itself.",
"Accounts, updates, and the launcher itself.",
&t,
))
.child(
@@ -2025,33 +2005,24 @@ impl Launcher {
Some(opening.into_any_element()),
&t,
))
.child(self.game_args_row(n + 4, cx))
.child(index_row(n + 5, "Horizon", Some(plain(&horizon)), horizon_action, &t))
.child(index_row(
n + 4,
"Game menus",
Some(plain(
"Classic is vanilla's own screens, with no way back inside the game: switch back here. Applies the next time the game starts.",
)),
Some(menus.into_any_element()),
&t,
))
.child(self.game_args_row(n + 5, cx))
.child(index_row(n + 6, "Horizon", Some(plain(&horizon)), horizon_action, &t))
.child(index_row(
n + 7,
n + 6,
"Launcher",
Some(plain(&launcher)),
launcher_action,
&t,
))
.child(index_row(
n + 8,
n + 7,
"Data folder",
Some(mono(short(&backend::data_dir()))),
None,
&t,
))
.child(index_row(
n + 9,
n + 8,
"Logs",
Some(mono(format!(
"{} · crash reports beside it",
@@ -2070,7 +2041,7 @@ impl Launcher {
))
.when(cfg!(target_os = "linux"), |d| {
d.child(index_row(
n + 10,
n + 9,
"Applications menu",
Some(plain(if self.settings.desktop_entry() {
"Horizon and its icon are in your desktop's menu."
-10
View File
@@ -49,8 +49,6 @@ fn tools() -> Value {
{ "name": "patch_notes", "description": "A release's patch notes as markdown.",
"inputSchema": { "type": "object", "properties": { "tag": { "type": "string", "description": "Default: the newest release." } } } },
{ "name": "links", "description": "The Horizon links: the Discord invite, the GitHub Sponsors page and the website (an empty one is not offered).", "inputSchema": none },
{ "name": "menu_style", "description": "Show or set the game's menu style. \"horizon\" is Horizon's own menus, \"classic\" is vanilla's screens, which have no way back inside the game. The game reads it when it starts.",
"inputSchema": { "type": "object", "properties": { "style": { "type": "string", "enum": ["horizon", "classic"], "description": "Omit to show the current style." } } } },
{ "name": "update_channel", "description": "Show or set which Horizon releases install by themselves. \"stable\" (the default) is a tested build about once a day; \"alpha\" is every release as soon as it is built, several times a day, and can break. Only when the player asks to change it.",
"inputSchema": { "type": "object", "properties": { "channel": { "type": "string", "enum": ["stable", "alpha"], "description": "Omit to show the current channel." } } } },
{ "name": "logs", "description": "Read the game's log: the last lines of logs/latest.log in the game folder, or with crash the newest crash report (what the game wrote when it last crashed). Read-only.",
@@ -279,14 +277,6 @@ impl Session {
let (path, text) = backend::read_logs(lines.clamp(1, 5000) as usize, crash)?;
Ok(format!("{}\n\n{text}", path.display()))
}
"menu_style" => {
if let Some(name) = arg_str(args, "style") {
let style = backend::MenuStyle::parse(name)
.ok_or("style is \"horizon\" or \"classic\"")?;
backend::set_menu_style(style)?;
}
Ok(format!("Menu style: {}", backend::menu_style().name()))
}
"update_channel" => {
let mut settings = backend::Settings::load();
if let Some(name) = arg_str(args, "channel") {
+1 -1
View File
@@ -113,7 +113,7 @@ def start_client(client, resources, home, endpoint, log, *extra):
str(client), '--resources', str(resources), '--render-distance', '2',
'--test-terrain', '--control-socket', str(endpoint), '--timeout-seconds', '180', *extra,
], cwd=home, env=dict(os.environ, HORIZON_HOME=str(home), HORIZON_NO_AUDIO='1',
HORIZON_MENU_STYLE='classic', HORIZON_PLAYER_NAME=''),
HORIZON_PLAYER_NAME=''),
stdout=log, stderr=subprocess.STDOUT)
+2 -6
View File
@@ -44,17 +44,13 @@ the repository, so the launcher's screenshots no longer show it.
All captured in Horizon's Rust client, with vanilla resources prepared from the maintainer's
own copy of Minecraft: Java Edition 26.3, at the default graphics settings and with no mods or shaders
(the game and menus last captured on 2026-10-17). Converted to WebP at 1600 and 800 pixels wide
(the game last captured on 2026-10-17, the menus on 2026-10-22). Converted to WebP at 1600 and 800 pixels wide
by `scripts/assets.mjs`.
| Files in `public/media/` | Source | What it shows |
| --- | --- | --- |
| `menu-title*.webp` | `docs/media/menu-title.png` | Horizon's own title screen (no Minecraft logo or splash text) |
| `menu-worlds*.webp` | `docs/media/menu-worlds.png` | Horizon's own world list |
| `menu-options*.webp` | `docs/media/menu-options.png` | Horizon's own options screen |
| `menu-pause*.webp` | `docs/media/menu-pause.png` | Horizon's own pause screen |
| `launcher*.webp` | `docs/media/launcher-play.png` | The Horizon launcher's Play page (no background image) |
| `settings*.webp` | `docs/media/settings-simple.png` | Horizon's own Video settings, Simple view |
| `settings*.webp` | `docs/media/settings-simple.png` | Video Settings, with Horizon's graphics and shader pack buttons at the top |
| `sunset*.webp`, `village*.webp`, `survival*.webp`, `nether*.webp`, `night*.webp`, `underwater*.webp` | `docs/media/<name>.jpg` | In-game views of one fixed-seed world; none shows a Mojang logo or splash text |
Horizon's interface in these images is Horizon's original work (MIT). The block, mob and
+1 -1
View File
@@ -7,7 +7,7 @@ Horizon is Minecraft: Java Edition 26.3 rewritten in Rust. You install it with a
- **A new game program, not a mod.** Horizon is written from scratch in Rust. It reads the same worlds, plays by the same rules and generates the same terrain as the Java game.
- **Checked against vanilla.** {{HARNESSES}} automated tests ("harnesses") feed the same inputs to Horizon and to the real game, then compare the results. Today every subsystem matches in every harness that compares it. That is {{PERCENT}} of what the harnesses compare, which is not proof that nothing else differs. The [status table](/#parity) lists what is covered.
- **Light and fast.** It starts quickly, uses little memory and draws efficiently. See [Performance](/docs/performance) for what is measured and what is not.
- **A few things vanilla doesn't have.** Its own menus (vanilla's are one setting away), graphics presets, distant terrain, controller support, optional extras such as zoom, a minimap and dynamic lights (dynamic lights are in Alpha builds for now), an invite code to play your world with friends, and a server you can run without Java.
- **A few things vanilla doesn't have.** Its own settings, added to vanilla's menus the way mods add theirs, graphics presets, distant terrain, controller support, optional extras such as zoom, a minimap and dynamic lights (dynamic lights are in Alpha builds for now), an invite code to play your world with friends, and a server you can run without Java.
## What Horizon is not
+1 -1
View File
@@ -24,7 +24,7 @@ Every release also carries `SHA256SUMS` and a signature, `SHA256SUMS.sig`, if yo
2. Back on **Play**, the launcher says "Not prepared. Horizon needs the files of your own Minecraft 26.3." Choose **Prepare**. It finds your Minecraft folder by itself in the usual places. If it cannot, it lists where it looked, and **Choose…** next to the Minecraft folder lets you point it at yours.
3. Wait a few minutes. When it says "Prepared for Minecraft 26.3", choose **Play**.
The game opens on Horizon's own title screen. Your worlds, options and logs live in the game folder, which is not inside a version's folder, so updating or removing a version never touches them:
The game opens on vanilla's title screen. Your worlds, options and logs live in the game folder, which is not inside a version's folder, so updating or removing a version never touches them:
- Linux: `~/.local/share/horizon`
- macOS: `~/Library/Application Support/horizon`
+1 -1
View File
@@ -11,7 +11,7 @@ Horizon mods are written in Rust, compiled to WebAssembly and run in a sandbox.
**Playing with mods**
1. Put the mod's `.hmod` file in the `horizon-mods` folder of the game folder (see [Install](/docs/install#first-launch) for where that is), or use the **Open Mod Folder** button on the Mods screen.
2. Open **Options, Mods**. Each mod is listed with what it may do ("May see your position, health and the time, draw text on your screen…") and a switch. Mods start off. Turn on the ones you trust.
2. Open **Options, Mods...**. Each mod is listed with what it may do ("May see your position, health and the time, draw text on your screen…") and a switch. Mods start off. Turn on the ones you trust.
3. A mod that failed to load shows why, in red, on its row.
**What a mod can do today**
+3 -3
View File
@@ -6,13 +6,13 @@ You can play with friends from your own world, on your local network, or on a se
This needs no server and no account.
1. In your world, open the pause menu and choose **Invite friends**. Horizon opens the world to your network and shows an **invite code**.
1. In your world, open the pause menu and choose the **Friends** button (the icon with two people), then **Start Sharing**. Horizon opens the world to your network and shows an **invite code** with **Copy Code**.
2. Send the code to your friends.
3. On their side, your friends choose **Join a friend** (on the game's Multiplayer page, or on the launcher's **Play** page), paste the code and choose **Join**.
3. On their side, your friends choose the **Friends** button on the title screen (or **Join a friend** on the launcher's **Play** page), paste the code and choose **Join**. Pasting the code in **Direct Connection** works too.
There is no Horizon server in the middle. The code holds the host's addresses and a secret key, and the game between you is encrypted with it. A code works for as long as you keep sharing: closing the world or quitting ends it.
**Can your friends reach you?** The pause menu says what the game found:
**Can your friends reach you?** The Play with Friends screen says what the game found:
- On the same network, or over a VPN such as Tailscale or ZeroTier, it just works.
- Over the internet, it asks your router to open the port by itself (UPnP). If the router does not allow it, forward TCP port 25580 to your computer.
+11 -13
View File
@@ -2,20 +2,18 @@
Horizon plays like vanilla out of the box. This page covers the settings that are different or new: graphics, distant terrain, shader packs, resource packs, controllers and a few optional extras.
All of them are in the game's **Options** screen. Horizon's own menus group them in sections: Video, Audio, Controls, Accessibility, Language, Chat, Interface, Extras and Mods.
The game's menus are vanilla's. Horizon adds its own settings to vanilla's **Options** screen the way mods do: **Horizon Settings...** and **Mods...** take the last two buttons of the grid. **Horizon Settings** opens Graphics, Advanced Graphics, Shader Packs, Controller Settings, Extras and Mods, each a screen of vanilla's buttons and sliders. The graphics and shader pack buttons are also at the top of **Video Settings**, and Controller Settings at the bottom of **Controls**.
## Menu style
Horizon draws its own menus: the title screen, the world list, the options and the pause menu, over a live view of the world. If you prefer vanilla's screens, go to **Options, Interface, Menu style** and choose **Classic**. Classic has no way back inside the game, so to return to Horizon's menus use the launcher's **Settings** page, which has the same switch.
![Horizon's Video settings in their Simple view](/media/settings-800.webp)
![Video Settings, with Horizon's graphics buttons at the top](/media/settings-800.webp)
## Graphics: presets, Simple and Advanced
**Options, Video** has a **Simple / Advanced** switch at the top, and the game remembers your choice.
**Options, Video Settings** starts with **Horizon Graphics...** and **Advanced Graphics...** (also in **Options, Horizon Settings**).
- **Simple** has a preset (Performance, Balanced, Quality, Ultra or Custom), render distance, LOD distance, field of view, maximum frame rate, VSync and GUI scale.
- **Advanced** has every setting, in groups: Rendering, Quality, Display, Preferences, Performance and Overlay.
- **Horizon Graphics** has a preset (Performance, Balanced, Quality, Ultra or Custom) and LOD distance.
- **Advanced Graphics** has every Horizon setting, in groups: Rendering, Quality, Display, Preferences, Performance and Overlay.
Vanilla's own settings (render distance, field of view, frame rate, VSync, GUI scale and the rest) stay on Video Settings, where vanilla has them.
Every row has a one-line description and its cost in frame time: none, low, medium or high. Changes apply at once, except worker threads, which apply at the next start. A preset sets the quality settings together, and changing one of them turns the preset into **Custom**.
@@ -35,7 +33,7 @@ Not available: anisotropic filtering, MSAA (FXAA is there instead) and exclusive
## Graphics API on Windows
Linux always uses Vulkan and macOS always uses Metal. On Windows there is a choice, in **Options, Video, Advanced, Performance, Graphics API**:
Linux always uses Vulkan and macOS always uses Metal. On Windows there is a choice, in **Options, Video Settings, Advanced Graphics, Performance, Graphics API**:
- **Auto** (the default) uses Vulkan, and DirectX 12 when Vulkan has no graphics card or driver that works.
- **Vulkan** and **DirectX 12** force one of the two.
@@ -44,7 +42,7 @@ The change applies at the next start. If Vulkan gives you trouble, try DirectX 1
## Shader packs
Shader packs are **experimental**. Put a pack's folder in the `shaderpacks` folder of the game folder (see [Install](/docs/install#first-launch) for where that is), then choose it in **Options, Video, Shader Packs**. With no pack selected the game draws exactly what vanilla draws. A pack that fails to load shows why in red and leaves the normal picture on.
Shader packs are **experimental**. Put a pack's folder in the `shaderpacks` folder of the game folder (see [Install](/docs/install#first-launch) for where that is), then choose it in **Options, Video Settings, Shader Packs** (or **Options, Horizon Settings, Shader Packs**). With no pack selected the game draws exactly what vanilla draws. A pack that fails to load shows why in red and leaves the normal picture on.
Horizon can run the full-screen effects of Java shader packs (OptiFine and Iris packs: colour grading, bloom, sky and fog effects). It does not run their geometry and shadow passes yet, so packs do not look as they do in Iris. Horizon also has its own shader pack format, in WGSL, with a `pack.toml` manifest, options and hot reload. It has full-screen passes too; stages that draw the world's terrain and shadows are planned. The details are in the [shader pack notes](https://github.com/ludovic111/horizon/blob/main/docs/shader-packs.md).
@@ -62,14 +60,14 @@ The launcher's **Mods** page can download them from Modrinth (see [Mods and data
Horizon plays with PlayStation (DualShock 4 and DualSense), Xbox (360, One and Series) and Nintendo Switch Pro controllers, and with the Steam Deck's built-in controls. Vanilla has no controller support at all, so this is Horizon's own. With no controller connected, nothing changes.
- Settings are in **Options, Controls, Controller**: on or off, vibration, look sensitivity, inverting the axes, deadzones, button glyphs and remapping.
- Settings are in **Options, Controls, Controller Settings** (or **Options, Horizon Settings, Controller Settings**): on or off, vibration, look sensitivity, inverting the axes, deadzones, button glyphs and remapping.
- Menus, the inventory and chat work with a controller, with an on-screen keyboard for text.
- On a DualSense you can also set adaptive triggers and the lightbar.
- On the Steam Deck, Steam's default layout works with no setup.
## Extras
**Options, Extras** holds small, optional conveniences. Every one is off by default, so a fresh install behaves like vanilla: fullbright, zoom, a minimap, an FPS counter, a keystroke display, auto-reconnect, Mouse Tweaks-style inventory controls and inventory sorting. In Alpha builds there is one more, **dynamic lights**: a torch, lantern or other light source that you hold, that lies dropped as an item, or a burning mob, lights the blocks around it. It is client-side only, so other players do not see it.
**Options, Horizon Settings, Extras** holds small, optional conveniences. Every one is off by default, so a fresh install behaves like vanilla: fullbright, zoom, a minimap, an FPS counter, a keystroke display, auto-reconnect, Mouse Tweaks-style inventory controls and inventory sorting. In Alpha builds there is one more, **dynamic lights**: a torch, lantern or other light source that you hold, that lies dropped as an item, or a burning mob, lights the blocks around it. It is client-side only, so other players do not see it.
## Where your settings are stored
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 67 KiB

-4
View File
@@ -26,10 +26,6 @@ export const images = [
["docs/media/nether.jpg", "nether"],
["docs/media/night.jpg", "night"],
["docs/media/underwater.jpg", "underwater"],
["docs/media/menu-title.png", "menu-title"],
["docs/media/menu-worlds.png", "menu-worlds"],
["docs/media/menu-options.png", "menu-options"],
["docs/media/menu-pause.png", "menu-pause"],
["docs/media/settings-simple.png", "settings"],
["docs/media/launcher-play.png", "launcher"],
];
+4 -10
View File
@@ -166,7 +166,7 @@
<li class="row reveal"><span class="row-index" aria-hidden="true">01</span><h3>One-click install</h3><p>Pick a release and it installs the build for your platform into its own folder, then prepares the resources from your Java Edition 26.3 install.</p></li>
<li class="row reveal"><span class="row-index" aria-hidden="true">02</span><h3>Updates on its own</h3><p>It looks for a new Horizon release when it starts and every four hours, and updates itself from the launcher's own releases.</p></li>
<li class="row reveal"><span class="row-index" aria-hidden="true">03</span><h3>Client or server</h3><p>Start the client, or host a server from the Servers page: create it, start it, watch players and the console, change its settings and keep backups.</p></li>
<li class="row reveal"><span class="row-index" aria-hidden="true">04</span><h3>Your choice of menus</h3><p>Play with Horizon's own menus, shown here, or vanilla's classic screens.</p></li>
<li class="row reveal"><span class="row-index" aria-hidden="true">04</span><h3>Logs and crash reports</h3><p>The Settings page shows where the game's logs and crash reports are, and <code>horizon-launcher logs</code> prints them.</p></li>
<li class="row reveal"><span class="row-index" aria-hidden="true">05</span><h3>Modpacks and packs</h3><p>The Modpacks page reads a Modrinth or CurseForge pack and carries over the mods Horizon can run. The Mods page installs resource packs, shader packs and modpacks from Modrinth.</p></li>
</ul>
<div class="launcher-actions reveal">
@@ -176,22 +176,16 @@
</div>
<div class="screens reveal-media">
<div class="tabs" role="tablist" aria-label="Horizon's menus">
<div class="tabs" role="tablist" aria-label="The launcher and Horizon's settings">
<span class="tab-pill" aria-hidden="true"></span>
<button type="button" role="tab" id="tab-launcher" aria-controls="screen-launcher" aria-selected="true">Launcher</button>
<button type="button" role="tab" id="tab-title" aria-controls="screen-title" aria-selected="false" tabindex="-1">Title</button>
<button type="button" role="tab" id="tab-worlds" aria-controls="screen-worlds" aria-selected="false" tabindex="-1">Worlds</button>
<button type="button" role="tab" id="tab-settings" aria-controls="screen-settings" aria-selected="false" tabindex="-1">Settings</button>
<button type="button" role="tab" id="tab-pause" aria-controls="screen-pause" aria-selected="false" tabindex="-1">Pause</button>
</div>
<div class="screen">
<div class="screen-panel is-active" role="tabpanel" id="screen-launcher" aria-labelledby="tab-launcher"><img loading="lazy" decoding="async" src="/media/launcher-800.webp" srcset="/media/launcher-800.webp 800w, /media/launcher.webp 1280w" sizes="(min-width: 1000px) 720px, 92vw" width="1280" height="800" alt="The launcher's Play page: the version, Client and Server, the version picker and Play, the prepared resources and the Minecraft folder as a numbered list"></div>
<div class="screen-panel" role="tabpanel" id="screen-title" aria-labelledby="tab-title"><img loading="lazy" decoding="async" src="/media/menu-title-800.webp" srcset="/media/menu-title-800.webp 800w, /media/menu-title.webp 1280w" sizes="(min-width: 1000px) 720px, 92vw" width="1280" height="800" alt="Horizon's title screen: the mark and the pages on the left, the Horizon title, Singleplayer and Multiplayer, the last world played and the faint wordmark, over a veiled snowy landscape"></div>
<div class="screen-panel" role="tabpanel" id="screen-worlds" aria-labelledby="tab-worlds"><img loading="lazy" decoding="async" src="/media/menu-worlds-800.webp" srcset="/media/menu-worlds-800.webp 800w, /media/menu-worlds.webp 1280w" sizes="(min-width: 1000px) 720px, 92vw" width="1280" height="800" alt="The Singleplayer page: the worlds as a numbered list with their dates and game modes, and Create world and Play"></div>
<div class="screen-panel" role="tabpanel" id="screen-settings" aria-labelledby="tab-settings"><img loading="lazy" decoding="async" src="/media/settings-800.webp" srcset="/media/settings-800.webp 800w, /media/settings.webp 1280w" sizes="(min-width: 1000px) 720px, 92vw" width="1280" height="800" alt="The Video settings in their Simple view: a preset, render distance, field of view, framerate, VSync and GUI scale, each with what it costs"></div>
<div class="screen-panel" role="tabpanel" id="screen-pause" aria-labelledby="tab-pause"><img loading="lazy" decoding="async" src="/media/menu-pause-800.webp" srcset="/media/menu-pause-800.webp 800w, /media/menu-pause.webp 1280w" sizes="(min-width: 1000px) 720px, 92vw" width="1280" height="800" alt="The pause screen of a world, with Back to game, Open to LAN and Save and quit"></div>
<div class="screen-panel" role="tabpanel" id="screen-settings" aria-labelledby="tab-settings"><img loading="lazy" decoding="async" src="/media/settings-800.webp" srcset="/media/settings-800.webp 800w, /media/settings.webp 1280w" sizes="(min-width: 1000px) 720px, 92vw" width="1280" height="720" alt="Vanilla's Video Settings screen with Horizon's own buttons at the top: Horizon Graphics, Advanced Graphics and Shader Packs"></div>
</div>
<p class="screen-caption">The launcher, and Horizon's own menus in the game. The launcher opens them, or vanilla's.</p>
<p class="screen-caption">The launcher, and Horizon's graphics settings in the game: vanilla's menus, with Horizon's pages added the way mods add theirs.</p>
</div>
</div>
</section>