diff --git a/docs/design-system.md b/docs/design-system.md index e1417f749..66767c0b7 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -168,6 +168,11 @@ of the main action. The game's menus keep `LIGHT` and `DARK`. ships no third-party pictures. The Horizon instance shows a grass block drawn from the player's own prepared Minecraft textures. Sources are named in text ("from Modrinth"): Modrinth's logo is all rights reserved, so it is not shown. +- **Partner banner**: the one exception to shipping no third-party pictures. Sculk, a server host, + sponsors Horizon: its banner (`launcher/assets/sculk-banner.webp`, `launcher/src/partner.rs`) sits + under a muted mono "Partner" label at the end of the Servers page and of Home, below Play, and opens + Sculk's page in the browser. The website shows the same banner the same way on Home and the hosting + docs, as a `rel="sponsored"` link. - **Pixel art drawn in code.** The stone behind the pages is close shades of the page colour (`TILE_SHADES`), never Minecraft's stone; the landscape is a banded sky, a sun cut in slices like the mark, hills and square trees (a sunset in dark, a dawn in light). The launcher bakes them in diff --git a/launcher/assets/sculk-banner.webp b/launcher/assets/sculk-banner.webp new file mode 100644 index 000000000..3ed947276 Binary files /dev/null and b/launcher/assets/sculk-banner.webp differ diff --git a/launcher/src/main.rs b/launcher/src/main.rs index 2599b47a5..50e62756d 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -18,6 +18,7 @@ mod mcp; mod modpacks_page; mod mods_page; mod mods_project; +mod partner; mod perf; mod scrollbar; mod servers_page; @@ -2130,7 +2131,8 @@ impl Launcher { if let Some(crash) = self.crash.clone() { page = page.child(self.crash_notice(crash, cx)); } - page + // Below everything the player needs to start, so it never moves Play. + page.child(partner::banner("partner-home", 560., &t)) } /// "Horizon crashed": the report and the logs, and where to report it. diff --git a/launcher/src/partner.rs b/launcher/src/partner.rs new file mode 100644 index 000000000..eea1a3524 --- /dev/null +++ b/launcher/src/partner.rs @@ -0,0 +1,64 @@ +//! Sculk's banner: a server host that sponsors Horizon (Ludovic, 2026-10-26), on the Servers page +//! and under Home's rows. The picture is in the binary, never fetched; a click opens Sculk's page in +//! the browser. A "Partner" label above it says it is an ad. +use crate::theme::Theme; +use gpui::{div, img, prelude::*, px, ClickEvent, Div, Image, ImageFormat, Stateful}; +use std::sync::{Arc, LazyLock}; + +pub const URL: &str = "https://my.sculkhosting.com/ref/horizon"; + +/// 1200×441: twice the widest it is shown at, for Retina screens. Its transparent edges let the +/// characters stand out of the card. +const WIDTH: f32 = 1200.; +const HEIGHT: f32 = 441.; +static BANNER: LazyLock> = LazyLock::new(|| { + Arc::new(Image::from_bytes( + ImageFormat::Webp, + include_bytes!("../assets/sculk-banner.webp").to_vec(), + )) +}); + +/// The banner `width` logical pixels wide, under its label. Hovering lifts it a little and turns the +/// label to ink. The narrowest window (960) leaves the page 648 pixels, so it always fits. +pub fn banner(id: &'static str, width: f32, t: &Theme) -> Stateful
{ + let t = *t; + let el = div() + .id(id) + .group(id) + .flex() + .flex_col() + .gap(px(8.)) + .w(px(width)) + .cursor_pointer() + .child( + crate::text(crate::theme::MICRO) + .text_color(t.muted) + .group_hover(id, move |s| s.text_color(t.ink)) + .child("PARTNER"), + ) + .child( + div().relative().group_hover(id, |s| s.top(px(-2.))).child( + img(BANNER.clone()) + .w(px(width)) + .h(px(width * HEIGHT / WIDTH)), + ), + ) + .on_click(|_: &ClickEvent, _, cx| cx.open_url(URL)); + crate::keyboard(el, &t) +} + +#[cfg(test)] +mod tests { + use super::{HEIGHT, WIDTH}; + + #[test] + fn the_bundled_banner_decodes() { + let bytes = include_bytes!("../assets/sculk-banner.webp"); + let banner = image::load_from_memory_with_format(bytes, image::ImageFormat::WebP) + .expect("the banner is a WebP"); + assert_eq!( + (banner.width(), banner.height()), + (WIDTH as u32, HEIGHT as u32) + ); + } +} diff --git a/launcher/src/servers_page.rs b/launcher/src/servers_page.rs index b1e7eb775..0a5618768 100644 --- a/launcher/src/servers_page.rs +++ b/launcher/src/servers_page.rs @@ -1167,12 +1167,15 @@ impl Launcher { { page = page.child(self.problem_notice(p, cx)); } + let partner = super::partner::banner("partner-servers", 600., &t); if self.servers.list.is_empty() { - return page.child(centered( - "No server yet. Create one: it takes a few seconds, and with the defaults (tick \ - the EULA, press Create) you get a friends-only survival world.", - &t, - )); + return page + .child(centered( + "No server yet. Create one: it takes a few seconds, and with the defaults \ + (tick the EULA, press Create) you get a friends-only survival world.", + &t, + )) + .child(partner); } let mut list = div().flex().flex_col().border_t_1().border_color(t.rule); for (i, e) in self.servers.list.clone().into_iter().enumerate() { @@ -1213,7 +1216,7 @@ impl Launcher { &t, )); } - page.child(list) + page.child(list).child(partner) } fn add_server_folder(&mut self, cx: &mut Context) {