diff --git a/launcher/src/backend.rs b/launcher/src/backend.rs index 85818a67c..55a78193a 100644 --- a/launcher/src/backend.rs +++ b/launcher/src/backend.rs @@ -2545,6 +2545,13 @@ pub struct Settings { /// first-run question, or on the Play page once if they answered that before it existed. #[serde(default)] pub ping_notice_seen: bool, + /// Seconds the sidebar's partner banner has been on screen, over every start, up to + /// `partner::SEEN_BEFORE_HIDE`: only then can the player hide it. + #[serde(default)] + pub partner_seen_secs: u64, + /// The player hid the sidebar's partner banner. The Servers page keeps its own. + #[serde(default)] + pub partner_hidden: bool, } impl Settings { diff --git a/launcher/src/main.rs b/launcher/src/main.rs index 50e62756d..7cc6d0ccd 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -248,6 +248,32 @@ impl Launcher { } }) .detach(); + // Counts the time the sidebar's partner banner is on screen, until it may be hidden. + cx.spawn(async move |this, cx| loop { + cx.background_executor() + .timer(Duration::from_secs(10)) + .await; + let counting = this.update(cx, |this, cx| { + let s = &mut this.settings; + if s.partner_hidden || s.partner_seen_secs >= partner::SEEN_BEFORE_HIDE { + return false; + } + if this.page != Page::Servers { + s.partner_seen_secs += 10; + if s.partner_seen_secs % 60 == 0 + || s.partner_seen_secs >= partner::SEEN_BEFORE_HIDE + { + s.save(); + cx.notify(); + } + } + true + }); + if !matches!(counting, Ok(true)) { + break; + } + }) + .detach(); let mut settings = Settings::load(); if settings.minecraft_dir.is_none() { settings.minecraft_dir = backend::default_minecraft_dir(); @@ -1749,6 +1775,36 @@ impl Launcher { } _ => {} } + // Sculk's banner, small, above the links: seen without scrolling, on every page but Servers, which + // shows it large. After a while on screen a "Hide" beside its label puts it away for good. + if self.page != Page::Servers && !self.settings.partner_hidden { + let mut side = div().relative().mb(px(8.)).child(partner::banner( + "partner-side", + theme::SIDEBAR - 20., + &t, + )); + if self.settings.partner_seen_secs >= partner::SEEN_BEFORE_HIDE { + let hide = div() + .id("partner-hide") + .absolute() + .top(px(0.)) + .right(px(0.)) + .cursor_pointer() + .child( + text(theme::MICRO) + .text_color(t.muted) + .hover(move |s| s.text_color(t.ink)) + .child("HIDE"), + ) + .on_click(cx.listener(|this, _: &ClickEvent, _, cx| { + this.settings.partner_hidden = true; + this.settings.save(); + cx.notify(); + })); + side = side.child(keyboard(hide, &t)); + } + foot = foot.child(side); + } if !self.links.discord.is_empty() { foot = foot.child(link( "discord", @@ -2131,8 +2187,7 @@ impl Launcher { if let Some(crash) = self.crash.clone() { page = page.child(self.crash_notice(crash, cx)); } - // Below everything the player needs to start, so it never moves Play. - page.child(partner::banner("partner-home", 560., &t)) + page } /// "Horizon crashed": the report and the logs, and where to report it. diff --git a/launcher/src/partner.rs b/launcher/src/partner.rs index eea1a3524..c4feac7b8 100644 --- a/launcher/src/partner.rs +++ b/launcher/src/partner.rs @@ -1,5 +1,5 @@ -//! 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 +//! Sculk's banner: a server host that sponsors Horizon (Ludovic, 2026-10-26), large on the Servers page +//! and small at the foot of the sidebar on the other pages, where it shows without scrolling. 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}; @@ -7,6 +7,10 @@ use std::sync::{Arc, LazyLock}; pub const URL: &str = "https://my.sculkhosting.com/ref/horizon"; +/// How long the sidebar's banner stays on screen, counted over every start, before a "Hide" shows +/// beside its label: long enough to be seen, then the player may put it away for good. +pub const SEEN_BEFORE_HIDE: u64 = 180; + /// 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.; @@ -19,7 +23,7 @@ static BANNER: LazyLock> = LazyLock::new(|| { }); /// 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. +/// label to ink. The narrowest window (960) leaves the page 648 pixels, so the Servers one always fits. pub fn banner(id: &'static str, width: f32, t: &Theme) -> Stateful
{ let t = *t; let el = div()