Merge pull request #2896 from ludovic111/feat/launcher-owner-screen
🤖 Agent: Merged by Ludovic's AI agent (orchestrator). Proven by the real run with Ludovic's own sign-in on the Mac mini (download from Mojang, prepare, play, sign-out refused, keychain clean; see #2892).
This commit is contained in:
@@ -77,6 +77,11 @@ possible; the launcher just doesn't offer it on its own.
|
||||
again for each account, the selected one first, until one owns the game: the token renewal
|
||||
(below) if due, then entitlements and profile. Without an owner the game doesn't start and Play
|
||||
says "Sign in with a Microsoft account that owns Minecraft: Java Edition to play", with Sign in.
|
||||
- **The window says it once.** A player without an owner (one who played offline until now) sees
|
||||
the gate's screen once when the launcher opens: why Horizon needs the account ("like other
|
||||
launchers"), that worlds, offline names and settings stay where they are, and Sign in, which shows
|
||||
the device code on the same screen. It comes back whenever Play is refused; Not now closes it,
|
||||
and Home keeps a Sign in row (`launcher/src/owner_page.rs`).
|
||||
- **The answer lives with the tokens.** Each account's keychain item keeps the last answer
|
||||
(`owns`), so no plain file can say yes. With no network (or a sign-in that can't be renewed) the
|
||||
last answer stands: being offline never blocks a player who passed before, and the game starts
|
||||
|
||||
@@ -167,5 +167,9 @@
|
||||
"Sign in with a Microsoft account that owns Minecraft: Java Edition to play": "Connectez-vous avec un compte Microsoft qui possède Minecraft: Java Edition pour jouer",
|
||||
"Horizon needs a Microsoft account that owns Minecraft: Java Edition, like other launchers. It also plays online servers with your name and skin.": "Horizon a besoin d'un compte Microsoft qui possède Minecraft: Java Edition, comme les autres launchers. Il permet aussi de jouer sur les serveurs en ligne avec votre nom et votre skin.",
|
||||
"Sign in": "Se connecter",
|
||||
"Sign in with Microsoft": "Se connecter avec Microsoft"
|
||||
"Sign in with Microsoft": "Se connecter avec Microsoft",
|
||||
"Not now": "Pas maintenant",
|
||||
"Horizon needs a Microsoft account that owns Minecraft: Java Edition, like other launchers.": "Horizon a besoin d'un compte Microsoft qui possède Minecraft: Java Edition, comme les autres launchers.",
|
||||
"Your worlds, offline names and settings stay where they are.": "Vos mondes, vos noms hors ligne et vos réglages restent où ils sont.",
|
||||
"Open {link} in your browser and enter this code:": "Ouvrez {link} dans votre navigateur et entrez ce code :"
|
||||
}
|
||||
|
||||
@@ -167,5 +167,9 @@
|
||||
"Sign in with a Microsoft account that owns Minecraft: Java Edition to play": "Чтобы играть, войдите в аккаунт Microsoft, у которого есть Minecraft: Java Edition",
|
||||
"Horizon needs a Microsoft account that owns Minecraft: Java Edition, like other launchers. It also plays online servers with your name and skin.": "Как и другим лаунчерам, Horizon нужен аккаунт Microsoft, у которого есть Minecraft: Java Edition. С ним вы также играете на онлайн-серверах под своим именем и со своим скином.",
|
||||
"Sign in": "Войти",
|
||||
"Sign in with Microsoft": "Войти через Microsoft"
|
||||
"Sign in with Microsoft": "Войти через Microsoft",
|
||||
"Not now": "Не сейчас",
|
||||
"Horizon needs a Microsoft account that owns Minecraft: Java Edition, like other launchers.": "Как и другим лаунчерам, Horizon нужен аккаунт Microsoft, у которого есть Minecraft: Java Edition.",
|
||||
"Your worlds, offline names and settings stay where they are.": "Ваши миры, офлайн-имена и настройки остаются на месте.",
|
||||
"Open {link} in your browser and enter this code:": "Откройте {link} в браузере и введите этот код:"
|
||||
}
|
||||
|
||||
@@ -2625,6 +2625,10 @@ 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,
|
||||
/// The player without an account that owns the game has read, once, why the launcher needs
|
||||
/// one now (the owner gate's screen).
|
||||
#[serde(default)]
|
||||
pub owner_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)]
|
||||
|
||||
+18
-6
@@ -27,6 +27,7 @@ mod modpacks_page;
|
||||
mod mods_page;
|
||||
mod mods_project;
|
||||
mod multiplayer_page;
|
||||
mod owner_page;
|
||||
mod packs_page;
|
||||
mod partner;
|
||||
mod perf;
|
||||
@@ -210,6 +211,8 @@ struct Launcher {
|
||||
/// Whether an account here owns the game, by the keychain's last answers (the owner gate);
|
||||
/// none until the keychain has been read.
|
||||
owner: Option<bool>,
|
||||
/// Play was refused (or Home's Sign in pressed): the owner gate's screen is open.
|
||||
owner_screen_open: bool,
|
||||
/// The game is waiting for its session (a token renewal) before it starts.
|
||||
starting_client: Option<String>,
|
||||
/// Join a friend: the code typed on the Play page, and the one the game
|
||||
@@ -415,6 +418,7 @@ impl Launcher {
|
||||
sign_in_state: None,
|
||||
keychain: true,
|
||||
owner: None,
|
||||
owner_screen_open: false,
|
||||
starting_client: None,
|
||||
friend_code: String::new(),
|
||||
friend_focused: false,
|
||||
@@ -648,6 +652,7 @@ impl Launcher {
|
||||
Ok(pass) => pass,
|
||||
Err(account::NoOwner) => {
|
||||
self.owner = Some(false);
|
||||
self.owner_screen_open = true;
|
||||
self.client_error = Some(format!("{}.", tr(account::NEEDS_OWNER)));
|
||||
self.starting_pack = None;
|
||||
self.joining = None;
|
||||
@@ -917,7 +922,12 @@ impl Launcher {
|
||||
self.accounts = Accounts::load();
|
||||
// Sign-in refuses accounts that don't own the game.
|
||||
self.owner = Some(true);
|
||||
self.owner_screen_open = false;
|
||||
self.client_error = None;
|
||||
if !self.settings.owner_notice_seen {
|
||||
self.settings.owner_notice_seen = true;
|
||||
self.settings.save();
|
||||
}
|
||||
}
|
||||
self.sign_in_state = Some(state);
|
||||
changed = true;
|
||||
@@ -1088,7 +1098,7 @@ impl Launcher {
|
||||
});
|
||||
}
|
||||
|
||||
/// Starts the Microsoft sign-in; Settings shows its code.
|
||||
/// Starts the Microsoft sign-in; Settings and the owner gate's screen show its code.
|
||||
fn start_sign_in(&mut self) {
|
||||
if let Some(old) = self.sign_in.replace(SignIn::start()) {
|
||||
old.cancel();
|
||||
@@ -2301,8 +2311,7 @@ impl Launcher {
|
||||
Some(
|
||||
button("gate-sign-in", "Sign in", Kind::Primary, &t)
|
||||
.on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
|
||||
this.start_sign_in();
|
||||
this.go(Page::Settings);
|
||||
this.sign_in_to_play();
|
||||
cx.notify();
|
||||
}))
|
||||
.into_any_element(),
|
||||
@@ -3201,9 +3210,9 @@ impl Launcher {
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(6.))
|
||||
.child(format!(
|
||||
"Open {} in your browser and enter this code:",
|
||||
code.verification_uri
|
||||
.child(trf(
|
||||
"Open {link} in your browser and enter this code:",
|
||||
&[("link", &code.verification_uri)],
|
||||
))
|
||||
.child(
|
||||
text(theme::HEADING)
|
||||
@@ -3907,6 +3916,9 @@ impl Render for Launcher {
|
||||
if self.asking_consent() {
|
||||
root = root.child(self.consent_screen(cx));
|
||||
}
|
||||
if self.asking_owner() {
|
||||
root = root.child(self.owner_screen(cx));
|
||||
}
|
||||
if let Some(opening) = &self.opening {
|
||||
// The wordmark arrives letter by letter, then gives way to the launcher; a click or
|
||||
// a key skips ahead.
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
//! The owner gate in the window (`horizon_launcher::account::launch`): the screen that asks for a
|
||||
//! Microsoft account that owns Minecraft: Java Edition. It covers the launcher once for players
|
||||
//! without one (those who played offline before the gate), and again whenever Play is refused.
|
||||
//! The sign-in runs on it, code and all.
|
||||
use super::*;
|
||||
|
||||
impl Launcher {
|
||||
/// Whether the screen covers the window: no owner, and either Play was refused or the player
|
||||
/// hasn't read it yet. The data question comes first.
|
||||
pub(crate) fn asking_owner(&self) -> bool {
|
||||
self.owner == Some(false)
|
||||
&& (self.owner_screen_open || !self.settings.owner_notice_seen)
|
||||
&& !self.asking_consent()
|
||||
&& self.opening.is_none()
|
||||
}
|
||||
|
||||
/// Opens the screen and starts the sign-in on it.
|
||||
pub(crate) fn sign_in_to_play(&mut self) {
|
||||
self.owner_screen_open = true;
|
||||
self.start_sign_in();
|
||||
}
|
||||
|
||||
/// Closes it; it comes back with the next refused Play.
|
||||
fn close_owner_screen(&mut self) {
|
||||
if let Some(s) = self.sign_in.take() {
|
||||
s.cancel();
|
||||
}
|
||||
self.sign_in_state = None;
|
||||
self.owner_screen_open = false;
|
||||
if !self.settings.owner_notice_seen {
|
||||
self.settings.owner_notice_seen = true;
|
||||
self.settings.save();
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn owner_screen(&mut self, cx: &mut Context<Self>) -> Stateful<Div> {
|
||||
let t = self.theme;
|
||||
let configured = account::client_id().is_some();
|
||||
let mut body = div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(12.))
|
||||
.p(px(28.))
|
||||
.child(caps(tr("Microsoft account")).text_color(t.muted))
|
||||
.child(
|
||||
text(theme::HEADING)
|
||||
.text_color(t.ink)
|
||||
.child(format!("{}.", tr(account::NEEDS_OWNER))),
|
||||
)
|
||||
.child(text(theme::UI).text_color(t.muted).child(tr(
|
||||
"Horizon needs a Microsoft account that owns Minecraft: Java Edition, like other launchers.",
|
||||
)))
|
||||
.child(text(theme::UI).text_color(t.muted).child(tr(
|
||||
"Your worlds, offline names and settings stay where they are.",
|
||||
)));
|
||||
let status = match &self.sign_in_state {
|
||||
_ if !configured => Some(div().child(tr(account::NOT_CONFIGURED))),
|
||||
Some(SignInState::Starting) => Some(div().child(tr("Asking Microsoft…"))),
|
||||
Some(SignInState::Code(code)) => Some(
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(6.))
|
||||
.child(trf(
|
||||
"Open {link} in your browser and enter this code:",
|
||||
&[("link", &code.verification_uri)],
|
||||
))
|
||||
.child(
|
||||
text(theme::HEADING)
|
||||
.font_family(theme::MONO)
|
||||
.text_color(t.ink)
|
||||
.child(code.user_code.clone()),
|
||||
),
|
||||
),
|
||||
Some(SignInState::Done(Err(e))) => Some(div().text_color(t.danger).child(e.clone())),
|
||||
Some(SignInState::Done(Ok(_))) | None => None,
|
||||
};
|
||||
body = body.children(status.map(|s| {
|
||||
plate(&t)
|
||||
.p(px(16.))
|
||||
.text_size(px(theme::UI.px))
|
||||
.text_color(t.ink_soft)
|
||||
.child(s)
|
||||
}));
|
||||
let mut answers = div()
|
||||
.flex()
|
||||
.justify_end()
|
||||
.gap(px(12.))
|
||||
.px(px(28.))
|
||||
.pb(px(28.))
|
||||
.child(
|
||||
button("owner-later", "Not now", Kind::Secondary, &t).on_click(cx.listener(
|
||||
|this, _: &ClickEvent, _, cx| {
|
||||
this.close_owner_screen();
|
||||
cx.notify();
|
||||
},
|
||||
)),
|
||||
);
|
||||
answers = match &self.sign_in_state {
|
||||
Some(SignInState::Code(code)) => {
|
||||
let (uri, user_code) = (code.verification_uri.clone(), code.user_code.clone());
|
||||
answers
|
||||
.child(
|
||||
button("owner-copy", "Copy code", Kind::Secondary, &t).on_click(
|
||||
move |_, _, cx| {
|
||||
copy_to_clipboard(
|
||||
cx,
|
||||
gpui::ClipboardItem::new_string(user_code.clone()),
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
.child(
|
||||
button("owner-open", "Open link", Kind::Primary, &t)
|
||||
.on_click(move |_, _, cx| cx.open_url(&uri)),
|
||||
)
|
||||
}
|
||||
Some(SignInState::Starting) => answers,
|
||||
_ if !configured => answers,
|
||||
_ => answers.child(
|
||||
button("owner-sign-in", "Sign in", Kind::Primary, &t).on_click(cx.listener(
|
||||
|this, _: &ClickEvent, _, cx| {
|
||||
this.sign_in_to_play();
|
||||
cx.notify();
|
||||
},
|
||||
)),
|
||||
),
|
||||
};
|
||||
let card = plate(&t)
|
||||
.flex()
|
||||
.flex_col()
|
||||
// A set width: text measured at it wraps where it is drawn.
|
||||
.w(px(560.))
|
||||
.max_w_full()
|
||||
.bg(t.page)
|
||||
.border_1()
|
||||
.border_color(t.rule)
|
||||
.child(body)
|
||||
.child(answers);
|
||||
div()
|
||||
.id("owner-gate")
|
||||
.absolute()
|
||||
.top_0()
|
||||
.left_0()
|
||||
.size_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.px(px(32.))
|
||||
.py(px(24.))
|
||||
.bg(t.page.opacity(0.92))
|
||||
.on_scroll_wheel(|_, _, cx| cx.stop_propagation())
|
||||
.occlude()
|
||||
.child(card)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user