Put the Défi's banner on « Parties » and play the end of a Match there (#110)
- « Parties » draws the Défi's banner (Season, counter, ring) on the splash of the Match chosen, whose tick is lit; none chosen, nothing shown nor lit. The dressing moves to home/dress.rs (banner.rs would pass 500 lines). - The playback knows its screen: the end of a Match that opens its recap plays on « Parties » once the new Match is chosen, else on « Défi ». `challenge_visible` becomes `playback_visible`; the list read plays what waits. - « Défi » shows the final state afterwards, without a second play. - « Parties » lays the banner over a column that scrolls in a low window; tests that read a whole recap use a taller window. - Interface spec and user guide updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4392191a22
commit
97cd91e9b9
23 files changed
+683
-173
No files matched your search
@@ -165,13 +165,17 @@ struct WaitingMatch {
|
||||
champion_id: u32,
|
||||
}
|
||||
|
||||
/// The end of a followed Match on « Défi », from the round that stored it to the end of its
|
||||
/// animation; `Page::end_match` drops it all.
|
||||
/// The end of a followed Match on « Défi », or on « Parties » when it opened its recap there
|
||||
/// (#110), from the round that stored it to the end of its animation; `Page::end_match` drops it
|
||||
/// all.
|
||||
#[derive(Default)]
|
||||
struct MatchPlayback {
|
||||
/// The Match to play once the statistics with it are shown and « Défi » is in front: it
|
||||
/// waits there whatever hides « Défi » meanwhile.
|
||||
/// The Match to play once the statistics with it are shown and its screen is in front: it
|
||||
/// waits there whatever hides the screen meanwhile.
|
||||
waiting: Deferred<WaitingMatch>,
|
||||
/// The screen is « Parties », where the end of the Match opened its recap, rather than
|
||||
/// « Défi ».
|
||||
on_matches: bool,
|
||||
/// The statistics shown do not hold the queued Match yet.
|
||||
stats_pending: bool,
|
||||
/// The animation running, fixed when it started.
|
||||
|
||||
@@ -67,23 +67,21 @@ impl Render for Page {
|
||||
// A card lifting or settling asks for the next frame, and none once they are still.
|
||||
let now = cx.background_executor().now();
|
||||
if let Some(animation) = self.playback.animation {
|
||||
if animation.finished(now) || cx.reduce_motion() || !self.challenge_visible(window) {
|
||||
if animation.finished(now) || cx.reduce_motion() || !self.playback_visible(window) {
|
||||
self.end_match(cx);
|
||||
} else {
|
||||
// The comet lands: the splash of the champion just validé settles in, when its
|
||||
// Match is the banner's, the last Match. A Match older than the last (it arrived
|
||||
// late) leaves the banner as a reload shows it.
|
||||
// Match is the banner's (the last Match on « Défi », the one chosen on
|
||||
// « Parties »). A Match older than that (it arrived late) leaves the banner as a
|
||||
// reload shows it.
|
||||
if animation.has_comet()
|
||||
&& animation.since_landing(now) >= 0.
|
||||
&& self.playback.previous_banner.take().is_some()
|
||||
{
|
||||
let last_played = (self.home_statistics())
|
||||
.and_then(|s| s.challenge.as_ref())
|
||||
.and_then(|c| c.last_match)
|
||||
.map(|m| m.champion_id);
|
||||
let splash = self.banner.splash.clone();
|
||||
let splash = self.banner_splash();
|
||||
let own = self.banner_champion() == Some(animation.champion_id);
|
||||
self.banner_art.update(cx, |art, cx| {
|
||||
if last_played == Some(animation.champion_id) {
|
||||
if own {
|
||||
art.reveal(splash, cx);
|
||||
} else {
|
||||
art.set_target(splash, cx);
|
||||
|
||||
@@ -10,6 +10,7 @@ use gpui_kit::*;
|
||||
mod banner;
|
||||
mod content;
|
||||
mod data;
|
||||
mod dress;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) use content::IDENTIFYING;
|
||||
|
||||
@@ -2,31 +2,36 @@ use gpui_kit::component::{ActiveTheme as _, StyledExt as _};
|
||||
use gpui_kit::prelude::FluentBuilder as _;
|
||||
use gpui_kit::*;
|
||||
|
||||
use super::{BannerContent, Line, NO_SEASON, Page};
|
||||
use super::{Line, NO_SEASON, Page};
|
||||
use crate::banner_art::BannerArt;
|
||||
use crate::motion::{COUNTER_ROLL, ease_out};
|
||||
use crate::page::Tab;
|
||||
use crate::ring::{self, Tick};
|
||||
use crate::theme::{banner_band, gold_ink, heading};
|
||||
use std::rc::Rc;
|
||||
|
||||
impl Page {
|
||||
/// The banner, on the home and during a champ select: the ring, then the Season, the
|
||||
/// Challenge's count and its two lines, over the splash of the champion of the last Match. In a
|
||||
/// The banner, on the home, on « Parties » and during a champ select: the ring, then the
|
||||
/// Season, the Challenge's count and its two lines, over the splash of the champion of the
|
||||
/// last Match (of the Match chosen, on « Parties »). In a
|
||||
/// narrow window the ring goes above the text, and the splash covers the whole banner under a
|
||||
/// stronger fade.
|
||||
pub(super) fn banner(&self, window: &mut Window, cx: &mut Context<Page>) -> impl IntoElement {
|
||||
pub(in crate::page) fn banner(
|
||||
&self,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Page>,
|
||||
) -> impl IntoElement {
|
||||
let layout = BannerLayout::of(window.viewport_size().width);
|
||||
let now = cx.background_executor().now();
|
||||
let animation = self.playback.animation;
|
||||
// Seconds since the comet landed, or since the start without one.
|
||||
let landed = animation.map(|a| a.since_landing(now));
|
||||
// The banner says what it said before the Match until the comet lands.
|
||||
// The banner says what it said before the Match until the comet lands, also while the
|
||||
// end of the Match waits on « Parties ».
|
||||
let waiting_here = self.playback.on_matches && self.shown_tab == Tab::Matches;
|
||||
let text = self
|
||||
.playback
|
||||
.previous_banner
|
||||
.as_ref()
|
||||
.filter(|_| landed.is_some_and(|t| t < 0.))
|
||||
.filter(|_| landed.map_or(waiting_here, |t| t < 0.))
|
||||
.unwrap_or(self.shown_banner());
|
||||
// The count of champions validés rolls in once the comet lands: 0 to 1.
|
||||
let roll = animation
|
||||
@@ -384,96 +389,3 @@ impl Render for BannerArt {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Page {
|
||||
/// The banner's text and the ring's ticks, for when the home statistics change. Neither
|
||||
/// follows the Format, the filter, the search nor the sort.
|
||||
pub(in crate::page) fn prepare_banner(&mut self, cx: &mut Context<Self>) {
|
||||
let stats = self.home_statistics();
|
||||
let champ_select = self.in_champ_select();
|
||||
let splashes = stats
|
||||
.filter(|_| champ_select)
|
||||
.into_iter()
|
||||
.flat_map(|s| &s.rows)
|
||||
.filter_map(|row| Some((row.champion.id, Rc::new(row.splash.clone()?))))
|
||||
.collect();
|
||||
let ticks: Rc<[Tick]> = stats
|
||||
.and_then(|s| {
|
||||
Some(ring::ticks(
|
||||
&s.rows,
|
||||
&s.challenge.as_ref()?.completion_order,
|
||||
))
|
||||
})
|
||||
.unwrap_or_default()
|
||||
.into();
|
||||
self.banner = BannerContent::new(self.home_season.as_ref(), stats);
|
||||
self.name_other_account();
|
||||
self.champ_select_splashes = splashes;
|
||||
self.reaim();
|
||||
self.ring.update(cx, |ring, cx| ring.set_ticks(ticks, cx));
|
||||
if self.shown_tab == Tab::InGame {
|
||||
// « En partie » reads the same statistics, prepared only while shown (rule #1).
|
||||
self.prepare_in_game(cx);
|
||||
}
|
||||
self.dress_banner(cx);
|
||||
}
|
||||
|
||||
/// What the banner drawn says: the champ select's on « Sélection », the Live Match's on
|
||||
/// « En partie », else the home's.
|
||||
pub(in crate::page) fn shown_banner(&self) -> &BannerContent {
|
||||
match self.shown_tab {
|
||||
Tab::ChampSelect => &self.champ_select_banner,
|
||||
Tab::InGame => &self.in_game.banner,
|
||||
_ => &self.banner,
|
||||
}
|
||||
}
|
||||
|
||||
/// The ring and the illustration of the banner drawn. The champ select's dims the ticks
|
||||
/// without an anvil and shows the card hovered; the Live Match's lights its champion's tick
|
||||
/// and shows its splash; the home's dims none and shows its own splash, unless the end of a
|
||||
/// Match holds it.
|
||||
pub(in crate::page) fn dress_banner(&mut self, cx: &mut Context<Self>) {
|
||||
let selecting = self.shown_tab == Tab::ChampSelect;
|
||||
let anvil = (self.live_champ_select())
|
||||
.filter(|_| selecting)
|
||||
.and_then(|pick| pick.anvil_champions.as_deref());
|
||||
self.ring.update(cx, |ring, cx| ring.set_anvil(anvil, cx));
|
||||
let playing = self.shown_tab == Tab::InGame;
|
||||
// Elsewhere only a card under the pointer lights a tick.
|
||||
let aimed = (self.ring_hover.aimed.as_ref()).map(|aimed| (aimed.id, aimed.splash.clone()));
|
||||
let lit = if let Some((id, _)) = &aimed {
|
||||
Some(Some(*id))
|
||||
} else if playing {
|
||||
Some(self.in_game.champion)
|
||||
} else {
|
||||
self.lit_by.is_none().then_some(None)
|
||||
};
|
||||
if let Some(lit) = lit {
|
||||
self.ring.update(cx, |ring, cx| ring.set_lit(lit, cx));
|
||||
}
|
||||
if let Some((_, splash)) = aimed {
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(splash, cx));
|
||||
} else if selecting {
|
||||
self.select_art(self.ring.read(cx).lit(), cx);
|
||||
} else if playing {
|
||||
let splash = self.in_game.banner.splash.clone();
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(splash, cx));
|
||||
} else if !self.playback.active() {
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(self.banner.splash.clone(), cx));
|
||||
}
|
||||
}
|
||||
|
||||
/// The illustration of the champ select's banner: the card hovered's, else its own.
|
||||
pub(in crate::page) fn select_art(&self, hovered: Option<u32>, cx: &mut Context<Self>) {
|
||||
let splash = match (&self.ring_hover.aimed, hovered) {
|
||||
(Some(aimed), _) => aimed.splash.as_ref(),
|
||||
(None, Some(id)) => self.champ_select_splashes.get(&id),
|
||||
(None, None) => self.champ_select_banner.splash.as_ref(),
|
||||
};
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(splash.cloned(), cx));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
//! What the banner drawn says and shows at rest: its text, the ring's ticks and the lit one, and
|
||||
//! the illustration of each screen that has a banner.
|
||||
|
||||
use super::BannerContent;
|
||||
use crate::page::{Page, Tab};
|
||||
use crate::ring::{self, Tick};
|
||||
use arena_tracker_core::Splash;
|
||||
use gpui_kit::*;
|
||||
use std::rc::Rc;
|
||||
|
||||
impl Page {
|
||||
/// The banner's text and the ring's ticks, for when the home statistics change. Neither
|
||||
/// follows the Format, the filter, the search nor the sort.
|
||||
pub(in crate::page) fn prepare_banner(&mut self, cx: &mut Context<Self>) {
|
||||
let stats = self.home_statistics();
|
||||
let champ_select = self.in_champ_select();
|
||||
let splashes = stats
|
||||
.filter(|_| champ_select)
|
||||
.into_iter()
|
||||
.flat_map(|s| &s.rows)
|
||||
.filter_map(|row| Some((row.champion.id, Rc::new(row.splash.clone()?))))
|
||||
.collect();
|
||||
let ticks: Rc<[Tick]> = stats
|
||||
.and_then(|s| {
|
||||
Some(ring::ticks(
|
||||
&s.rows,
|
||||
&s.challenge.as_ref()?.completion_order,
|
||||
))
|
||||
})
|
||||
.unwrap_or_default()
|
||||
.into();
|
||||
self.banner = BannerContent::new(self.home_season.as_ref(), stats);
|
||||
self.name_other_account();
|
||||
self.champ_select_splashes = splashes;
|
||||
self.reaim();
|
||||
self.ring.update(cx, |ring, cx| ring.set_ticks(ticks, cx));
|
||||
if self.shown_tab == Tab::InGame {
|
||||
// « En partie » reads the same statistics, prepared only while shown (rule #1).
|
||||
self.prepare_in_game(cx);
|
||||
}
|
||||
self.dress_banner(cx);
|
||||
}
|
||||
|
||||
/// What the banner drawn says: the champ select's on « Sélection », the Live Match's on
|
||||
/// « En partie », else the home's.
|
||||
pub(in crate::page) fn shown_banner(&self) -> &BannerContent {
|
||||
match self.shown_tab {
|
||||
Tab::ChampSelect => &self.champ_select_banner,
|
||||
Tab::InGame => &self.in_game.banner,
|
||||
_ => &self.banner,
|
||||
}
|
||||
}
|
||||
|
||||
/// The ring and the illustration of the banner drawn. The champ select's dims the ticks
|
||||
/// without an anvil and shows the card hovered; the Live Match's lights its champion's tick
|
||||
/// and shows its splash; the home's dims none and shows its own splash; « Parties » lights
|
||||
/// its chosen Match's champion and shows its splash. The end of a Match holds the banner of
|
||||
/// the screen it plays on: its animation draws it.
|
||||
pub(in crate::page) fn dress_banner(&mut self, cx: &mut Context<Self>) {
|
||||
let selecting = self.shown_tab == Tab::ChampSelect;
|
||||
let anvil = (self.live_champ_select())
|
||||
.filter(|_| selecting)
|
||||
.and_then(|pick| pick.anvil_champions.as_deref());
|
||||
self.ring.update(cx, |ring, cx| ring.set_anvil(anvil, cx));
|
||||
let playing = self.shown_tab == Tab::InGame;
|
||||
let browsing = self.shown_tab == Tab::Matches;
|
||||
let held = self.playback.active() && (self.playback.on_matches || !browsing);
|
||||
// Elsewhere only a card under the pointer lights a tick.
|
||||
let aimed = self
|
||||
.ring_hover
|
||||
.aimed
|
||||
.as_ref()
|
||||
.map(|aimed| (aimed.id, aimed.splash.clone()));
|
||||
let lit = if let Some((id, _)) = &aimed {
|
||||
Some(Some(*id))
|
||||
} else if playing {
|
||||
Some(self.in_game.champion)
|
||||
} else if browsing {
|
||||
Some(self.banner_champion().filter(|_| !held))
|
||||
} else {
|
||||
self.lit_by.is_none().then_some(None)
|
||||
};
|
||||
if let Some(lit) = lit {
|
||||
self.ring.update(cx, |ring, cx| ring.set_lit(lit, cx));
|
||||
}
|
||||
if let Some((_, splash)) = aimed {
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(splash, cx));
|
||||
} else if selecting {
|
||||
self.select_art(self.ring.read(cx).lit(), cx);
|
||||
} else if playing {
|
||||
let splash = self.in_game.banner.splash.clone();
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(splash, cx));
|
||||
} else if !held {
|
||||
let splash = self.banner_splash();
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(splash, cx));
|
||||
}
|
||||
}
|
||||
|
||||
/// The champion the banner drawn is about: the last Match's on « Défi », the Match chosen's
|
||||
/// on « Parties », none when no Match is.
|
||||
pub(in crate::page) fn banner_champion(&self) -> Option<u32> {
|
||||
if self.shown_tab == Tab::Matches {
|
||||
return Some(self.chosen_champion().0).filter(|&id| id != 0);
|
||||
}
|
||||
let last = self.home_statistics()?.challenge.as_ref()?.last_match;
|
||||
last.map(|m| m.champion_id)
|
||||
}
|
||||
|
||||
/// The illustration of the banner at rest: the splash of its champion.
|
||||
pub(in crate::page) fn banner_splash(&self) -> Option<Rc<Splash>> {
|
||||
if self.shown_tab != Tab::Matches {
|
||||
return self.banner.splash.clone();
|
||||
}
|
||||
let id = self.banner_champion()?;
|
||||
let rows = &self.home_statistics()?.rows;
|
||||
Some(Rc::new(
|
||||
rows.iter().find(|r| r.champion.id == id)?.splash.clone()?,
|
||||
))
|
||||
}
|
||||
|
||||
/// The illustration of the champ select's banner: the card hovered's, else its own.
|
||||
pub(in crate::page) fn select_art(&self, hovered: Option<u32>, cx: &mut Context<Self>) {
|
||||
let splash = match (&self.ring_hover.aimed, hovered) {
|
||||
(Some(aimed), _) => aimed.splash.as_ref(),
|
||||
(None, Some(id)) => self.champ_select_splashes.get(&id),
|
||||
(None, None) => self.champ_select_banner.splash.as_ref(),
|
||||
};
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(splash.cloned(), cx));
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ pub(in crate::page) struct Matches {
|
||||
/// The Match chosen. Not kept from one opening of the screen to the next.
|
||||
pub(in crate::page) selected: Option<String>,
|
||||
/// The Match whose end opened the screen, chosen once the list holds it (#129).
|
||||
arriving: Option<String>,
|
||||
pub(in crate::page) arriving: Option<String>,
|
||||
pub(in crate::page) recap: Recap,
|
||||
recap_job: RefreshGate,
|
||||
recap_generation: u64,
|
||||
@@ -256,11 +256,16 @@ impl Page {
|
||||
&mut self,
|
||||
generation: u64,
|
||||
result: Result<Vec<MatchEntry>, String>,
|
||||
window: &Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if generation == self.matches.generation {
|
||||
match result {
|
||||
Ok(entries) => self.show_matches(entries, cx),
|
||||
Ok(entries) => {
|
||||
self.show_matches(entries, cx);
|
||||
// The Match the end of a game opened is chosen: its animation may play.
|
||||
self.play_waiting(window, cx);
|
||||
}
|
||||
// The Matches already known stay.
|
||||
Err(error) => self.matches.error = Some(error.into()),
|
||||
}
|
||||
@@ -303,6 +308,7 @@ impl Page {
|
||||
self.matches.selected = Some(match_id);
|
||||
self.request_recap();
|
||||
}
|
||||
self.dress_banner(cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
@@ -414,7 +420,7 @@ impl Page {
|
||||
}
|
||||
|
||||
/// The champion of the Match chosen, from its row.
|
||||
fn chosen_champion(&self) -> (u32, &str) {
|
||||
pub(in crate::page) fn chosen_champion(&self) -> (u32, &str) {
|
||||
let matches = &self.matches;
|
||||
(matches.entries.iter().flatten())
|
||||
.find(|entry| Some(&entry.match_id) == matches.selected.as_ref())
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! The end of a Match opens its recap (#129): when its end-of-game block arrives, « Parties »
|
||||
//! shows the new Match, from any screen, never bringing the window forward nor taking the focus.
|
||||
//! With the preference off, or when the game ended without a block, the Challenge shows instead.
|
||||
//! Each game's end is decided once: nothing brings the player back to either screen afterwards.
|
||||
//! The animation of the end of the Match plays on « Parties » then (#110). Each game's end is
|
||||
//! decided once: nothing brings the player back to either screen afterwards.
|
||||
//! During a Live Match, « En partie » stays until the block or the lobby (#109).
|
||||
|
||||
use crate::page::{ALL_SEASONS, Page, RecapOpened, Tab};
|
||||
@@ -108,6 +109,8 @@ impl Page {
|
||||
if hidden {
|
||||
self.show_every_format_of_the_season(ended.season.clone(), window, cx);
|
||||
}
|
||||
// The animation of the end of a Match waiting plays on this screen, not on « Défi » (#110).
|
||||
self.playback.on_matches = self.playback.waiting.waiting().is_some();
|
||||
let drawn = self.shown_tab == Tab::Matches;
|
||||
// Hidden, minimised or behind « Paramètres », the switch is at once, without the veil.
|
||||
self.set_tab(Tab::Matches, window, cx);
|
||||
|
||||
@@ -161,6 +161,7 @@ impl Page {
|
||||
if choose {
|
||||
self.request_recap();
|
||||
}
|
||||
self.dress_banner(cx);
|
||||
}
|
||||
|
||||
/// A filter of this page changed: the list follows while it shows.
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
//! How « Parties » is laid out: the place of the banner, then the list and the recap side by
|
||||
//! side, or the list behind a button in a narrow window.
|
||||
//! How « Parties » is laid out: the banner, then the list and the recap side by side, or the
|
||||
//! list behind a button in a narrow window.
|
||||
|
||||
use super::filters::no_result;
|
||||
use super::{Recap, recap};
|
||||
use crate::card_images;
|
||||
use crate::page::Page;
|
||||
use crate::page::home::{StatsNotice, notice_line};
|
||||
use crate::page::{Page, shown};
|
||||
use crate::text::stored;
|
||||
use crate::theme::heading;
|
||||
use gpui_kit::base::Button as BaseButton;
|
||||
use gpui_kit::component::{ActiveTheme as _, Icon, IconName, Sizable as _, StyledExt as _};
|
||||
use gpui_kit::prelude::FluentBuilder as _;
|
||||
@@ -16,22 +15,19 @@ use gpui_kit::*;
|
||||
/// Narrower than this, the list hides behind a button and shows over the recap.
|
||||
const NARROW: f32 = 900.;
|
||||
const LIST_WIDTH: f32 = 320.;
|
||||
/// The least height of the list and the recap under the banner.
|
||||
const MIN_BODY: f32 = 240.;
|
||||
|
||||
impl Page {
|
||||
/// Under the status messages: the place of the banner, then the list and the recap side by
|
||||
/// side, the list behind a button in a narrow window.
|
||||
/// Under the status messages: the Défi's banner, then the list and the recap side by side,
|
||||
/// the list behind a button in a narrow window. In a low window the banner leaves them less
|
||||
/// than their least height: the column scrolls then, as the home's does.
|
||||
pub(in crate::page) fn matches_content(
|
||||
&self,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Page>,
|
||||
) -> Vec<AnyElement> {
|
||||
let muted = cx.theme().muted_foreground;
|
||||
// The banner (#110) comes here.
|
||||
let title = div()
|
||||
.h_flex()
|
||||
.items_center()
|
||||
.debug_selector(|| "matches-banner".into())
|
||||
.child(heading(cx).text_3xl().child("Parties"));
|
||||
let matches = &self.matches;
|
||||
let body = match (&matches.puuid, &matches.entries) {
|
||||
(None, _) => notice_line("matches-notice", StatsNotice::NoAccount.label(None), muted),
|
||||
@@ -48,15 +44,23 @@ impl Page {
|
||||
.then_some(matches.error.as_ref())
|
||||
.flatten()
|
||||
.map(|error| self.matches_error(error, cx));
|
||||
let column = div().id("matches").v_flex().flex_1().min_h_0().gap_3();
|
||||
let column = match shown("banner") {
|
||||
true => column.child(self.banner(window, cx)),
|
||||
false => column,
|
||||
};
|
||||
vec![
|
||||
title.into_any_element(),
|
||||
div()
|
||||
.v_flex()
|
||||
.flex_1()
|
||||
.min_h_0()
|
||||
.gap_3()
|
||||
.children(error)
|
||||
.child(body)
|
||||
column
|
||||
.child(
|
||||
div()
|
||||
.v_flex()
|
||||
.flex_1()
|
||||
.min_h(px(MIN_BODY))
|
||||
.gap_3()
|
||||
.children(error)
|
||||
.child(body),
|
||||
)
|
||||
.overflow_y_scroll()
|
||||
.into_any_element(),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ impl Page {
|
||||
// What « En partie » showed after its Live Match goes with it.
|
||||
self.in_game.clear();
|
||||
}
|
||||
// The ring and the illustration are the banner's on « Défi », « Sélection » and
|
||||
// « En partie ».
|
||||
// The ring and the illustration are the banner's on « Défi », « Parties », « Sélection »
|
||||
// and « En partie ».
|
||||
self.dress_banner(cx);
|
||||
self.release_hidden(window, cx);
|
||||
}
|
||||
@@ -159,8 +159,8 @@ impl Page {
|
||||
if shown != Tab::Matches {
|
||||
self.release_matches_images(window, cx);
|
||||
}
|
||||
if matches!(shown, Tab::Statistics | Tab::Matches) {
|
||||
// Neither banner is shown: its illustration goes too.
|
||||
if shown == Tab::Statistics {
|
||||
// No banner is shown: its illustration goes too.
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.release(window, cx));
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ impl Page {
|
||||
}
|
||||
}
|
||||
|
||||
/// The end of a followed Match: it plays once the statistics with it are shown and « Défi »
|
||||
/// is in front. Of several meanwhile, the strongest plays, on its own champion; the most
|
||||
/// The end of a followed Match: it plays once the statistics with it are shown and its screen
|
||||
/// is in front (« Défi », or « Parties » once its end opens its recap there). Of several meanwhile, the strongest plays, on its own champion; the most
|
||||
/// recent of the strongest. With the Windows « Show animations » setting off, the end state
|
||||
/// is all there is.
|
||||
pub(in crate::page) fn queue_match(&mut self, event: &FollowedMatch, cx: &mut Context<Self>) {
|
||||
@@ -48,21 +48,32 @@ impl Page {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether « Défi » is in front of the player. A window merely covered by another cannot
|
||||
/// be told on Windows (GPUI's `WindowVisibility`): visible then means shown and not
|
||||
/// minimised.
|
||||
pub(in crate::page) fn challenge_visible(&self, window: &Window) -> bool {
|
||||
/// Whether the screen the playback plays on is in front of the player: « Défi », or
|
||||
/// « Parties » when the end of the Match opened its recap there (#110). A window merely
|
||||
/// covered by another cannot be told on Windows (GPUI's `WindowVisibility`): visible then
|
||||
/// means shown and not minimised.
|
||||
pub(in crate::page) fn playback_visible(&self, window: &Window) -> bool {
|
||||
let screen = if self.playback.on_matches {
|
||||
Tab::Matches
|
||||
} else {
|
||||
Tab::Challenge
|
||||
};
|
||||
window.is_visible()
|
||||
&& !self.covered
|
||||
&& self.tab == Tab::Challenge
|
||||
&& self.shown_tab == Tab::Challenge
|
||||
&& self.tab == screen
|
||||
&& self.shown_tab == screen
|
||||
&& self.fade.is_none()
|
||||
&& !self.in_champ_select()
|
||||
}
|
||||
|
||||
/// « Défi » may have become visible: the animation waiting, if any, plays.
|
||||
/// The screen of the playback may have become visible: the animation waiting, if any, plays.
|
||||
/// On « Parties » it waits for the Match its end opened to be the one chosen, so that the
|
||||
/// illustration arriving after the comet is its champion's.
|
||||
pub(in crate::page) fn play_waiting(&mut self, window: &Window, cx: &mut Context<Self>) {
|
||||
if self.challenge_visible(window)
|
||||
let chosen = !self.playback.on_matches
|
||||
|| (self.matches.arriving.is_none() && self.matches.selected.is_some());
|
||||
if self.playback_visible(window)
|
||||
&& chosen
|
||||
&& !cx.reduce_motion()
|
||||
&& !self.playback.stats_pending
|
||||
&& let Some(waiting) = self.playback.waiting.shown()
|
||||
@@ -77,15 +88,11 @@ impl Page {
|
||||
// Nothing is aimed at while it plays.
|
||||
self.leave_ring(cx);
|
||||
// Under the comet, the splash of the champion of the Match before.
|
||||
let target = (self.playback.previous_banner.as_ref())
|
||||
.filter(|_| {
|
||||
self.playback
|
||||
.animation
|
||||
.is_some_and(MatchAnimation::has_comet)
|
||||
})
|
||||
.unwrap_or(&self.banner)
|
||||
.splash
|
||||
.clone();
|
||||
let comet = (self.playback.animation).is_some_and(MatchAnimation::has_comet);
|
||||
let target = match &self.playback.previous_banner {
|
||||
Some(previous) if comet => previous.splash.clone(),
|
||||
_ => self.banner_splash(),
|
||||
};
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(target, cx));
|
||||
if self.playback.animation.is_none() {
|
||||
|
||||
@@ -24,9 +24,11 @@ mod match_animation;
|
||||
mod match_end_fixtures;
|
||||
mod matches;
|
||||
mod matches_auto_open;
|
||||
mod matches_banner;
|
||||
mod matches_bubble;
|
||||
mod matches_death_recap;
|
||||
mod matches_details;
|
||||
mod matches_end_animation;
|
||||
mod matches_filters;
|
||||
mod matches_fixtures;
|
||||
mod matches_game_data;
|
||||
|
||||
@@ -252,7 +252,7 @@ fn without_an_account_the_screen_says_so(cx: &mut TestAppContext) {
|
||||
let cx = &mut { cx };
|
||||
switch_tab(&page, cx, Tab::Matches);
|
||||
draw(cx);
|
||||
assert!(cx.debug_bounds("matches-banner").is_some());
|
||||
assert!(cx.debug_bounds("banner").is_some());
|
||||
assert!(cx.debug_bounds("matches-notice").is_some());
|
||||
assert!(cx.debug_bounds("match-list").is_none());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
//! The banner of « Parties » (#110): the Défi's, on the champion of the Match chosen.
|
||||
|
||||
use super::banner_fixtures::{banner_champion, banner_statistics, on, ring_ticks, splash};
|
||||
use super::matches_fixtures::{ALICE, chosen, recap_ready, tracker_in};
|
||||
use super::page_fixtures::{draw, open_page_with_tracker, season, show, switch_tab, tall};
|
||||
use crate::card_images::tests::TestDir;
|
||||
use crate::page::{Page, Tab};
|
||||
use arena_tracker_core::ChampionRow;
|
||||
use gpui_kit::{Entity, Modifiers, TestAppContext, VisualTestContext};
|
||||
|
||||
/// Irelia (39) and Ahri (103), each with a splash, then Garen without one; Alice's Matches are
|
||||
/// Irelia's, Ahri's and Irelia's.
|
||||
pub(super) fn rows(dir: &TestDir) -> Vec<ChampionRow> {
|
||||
let mut rows = vec![
|
||||
banner_champion(39, "Irelia", 2, None, 100),
|
||||
banner_champion(103, "Ahri", 1, Some(on(11, 3)), 5),
|
||||
banner_champion(4, "Garen", 2, None, 900),
|
||||
];
|
||||
rows[0].splash = Some(splash(dir.path(), "Irelia"));
|
||||
rows[1].splash = Some(splash(dir.path(), "Ahri"));
|
||||
rows
|
||||
}
|
||||
|
||||
/// « Parties » on Alice's Matches, in a Season, under statistics whose champions have splashes.
|
||||
pub(super) async fn on_matches(
|
||||
cx: &mut TestAppContext,
|
||||
dir: &TestDir,
|
||||
) -> (Entity<Page>, VisualTestContext) {
|
||||
cx.executor().allow_parking();
|
||||
let (tracker, _) = tracker_in(false, vec![season("Saison", 2020)]);
|
||||
let (page, mut window) = open_page_with_tracker(cx, tracker);
|
||||
tall(&mut window);
|
||||
show(
|
||||
&page,
|
||||
&mut window,
|
||||
banner_statistics(rows(dir), vec![103], None),
|
||||
);
|
||||
switch_tab(&page, &mut window, Tab::Matches);
|
||||
recap_ready(&page, cx).await;
|
||||
draw(&mut window);
|
||||
(page, window)
|
||||
}
|
||||
|
||||
/// The splash the banner aims at, and the tick lit.
|
||||
pub(super) fn dressed(
|
||||
page: &Entity<Page>,
|
||||
cx: &mut VisualTestContext,
|
||||
) -> (Option<String>, Option<u32>) {
|
||||
page.read_with(cx, |p, cx| {
|
||||
let target = p.banner_art.read(cx).target.as_ref();
|
||||
(
|
||||
target.map(|s| s.path.file_name().unwrap().to_string_lossy().into_owned()),
|
||||
p.ring.read(cx).lit(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn the_banner_is_the_challenges_over_the_chosen_matchs_champion(cx: &mut TestAppContext) {
|
||||
let dir = TestDir::new("matches-banner");
|
||||
let (page, mut cx) = on_matches(cx, &dir).await;
|
||||
let cx = &mut cx;
|
||||
// The Défi's text and ring, and its link to « Statistiques ».
|
||||
for id in ["banner", "banner-season", "banner-title", "statistics-link"] {
|
||||
assert!(cx.debug_bounds(id).is_some(), "{id}");
|
||||
}
|
||||
assert_eq!(ring_ticks(&page, cx).len(), 3);
|
||||
assert_eq!(
|
||||
page.read_with(cx, |p, _| p.shown_banner().title.text.clone()),
|
||||
page.read_with(cx, |p, _| p.banner.title.text.clone())
|
||||
);
|
||||
// The list, under the banner, keeps its own place.
|
||||
let (banner, list) = (
|
||||
cx.debug_bounds("banner").unwrap(),
|
||||
cx.debug_bounds("match-list").unwrap(),
|
||||
);
|
||||
assert!(list.top() >= banner.bottom());
|
||||
|
||||
// The most recent Match is Irelia's.
|
||||
assert_eq!(chosen(&page, cx).as_deref(), Some(ALICE[0]));
|
||||
assert_eq!(
|
||||
dressed(&page, cx),
|
||||
(Some("Irelia.50.30.jpg".into()), Some(39))
|
||||
);
|
||||
// Another Match chosen: its champion's illustration and tick.
|
||||
let at = super::page_fixtures::center(cx, "match-row-1");
|
||||
cx.simulate_click(at, Modifiers::none());
|
||||
draw(cx);
|
||||
assert_eq!(chosen(&page, cx).as_deref(), Some(ALICE[1]));
|
||||
assert_eq!(
|
||||
dressed(&page, cx),
|
||||
(Some("Ahri.50.30.jpg".into()), Some(103))
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn without_a_match_chosen_no_illustration_and_no_tick_are_lit(cx: &mut TestAppContext) {
|
||||
let dir = TestDir::new("matches-banner-none");
|
||||
let (page, mut cx) = on_matches(cx, &dir).await;
|
||||
let cx = &mut cx;
|
||||
assert!(dressed(&page, cx).0.is_some());
|
||||
// A search that keeps no Match.
|
||||
let search = page.read_with(cx, |p, _| p.matches.search_input().clone());
|
||||
cx.update(|window, cx| search.update(cx, |input, cx| input.focus(window, cx)));
|
||||
cx.simulate_input("zzz");
|
||||
draw(cx);
|
||||
assert_eq!(chosen(&page, cx), None);
|
||||
assert_eq!(dressed(&page, cx), (None, None));
|
||||
// The banner stays, with the Défi's text.
|
||||
assert!(cx.debug_bounds("banner-season").is_some());
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn the_challenge_keeps_its_own_illustration_and_no_tick(cx: &mut TestAppContext) {
|
||||
let dir = TestDir::new("matches-banner-challenge");
|
||||
let (page, mut cx) = on_matches(cx, &dir).await;
|
||||
let cx = &mut cx;
|
||||
switch_tab(&page, cx, Tab::Challenge);
|
||||
draw(cx);
|
||||
// No Match was played in the statistics: the Défi has no last Match, hence no illustration.
|
||||
assert_eq!(dressed(&page, cx), (None, None));
|
||||
}
|
||||
@@ -146,7 +146,9 @@ async fn only_items_and_augments_inside_the_recap_viewport_register_tooltips(
|
||||
(players.next().unwrap().1, players.last().unwrap())
|
||||
});
|
||||
let (last_player, last) = last;
|
||||
window.simulate_resize(size(px(1280.), px(380.)));
|
||||
// The recap's viewport is 380 px high, under the banner.
|
||||
let banner = window.debug_bounds("banner").unwrap().size.height;
|
||||
window.simulate_resize(size(px(1280.), px(380.) + banner + px(12.)));
|
||||
draw(&mut window);
|
||||
|
||||
// Both rows are laid out, but only the first row installed tooltips.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use super::client_fixtures::FakeClient;
|
||||
use super::matches_fixtures::{TwoAccounts, recap_ready};
|
||||
use super::page_fixtures::{center, draw, open_page_launched, switch_tab};
|
||||
use super::page_fixtures::{center, draw, open_page_launched, switch_tab, tall};
|
||||
use crate::card_images::tests::TestDir;
|
||||
use crate::page::matches::{Death, NONE_SEEN, OTHERS, Recap, ShownDamage, UNAVAILABLE};
|
||||
use crate::page::{Page, Tab};
|
||||
@@ -212,6 +212,7 @@ pub(super) async fn open(
|
||||
window,
|
||||
asked,
|
||||
};
|
||||
tall(&mut opened.window);
|
||||
switch_tab(&opened.page, &mut opened.window, Tab::Matches);
|
||||
if named {
|
||||
cx.condition(&opened.page, |p, _| !p.matches.catalog().is_empty())
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
//! The animation of the end of a Match plays on « Parties » when its end opens the recap there
|
||||
//! (#110), and on « Défi » otherwise.
|
||||
|
||||
use super::banner_fixtures::{banner_champion, banner_statistics, on, ring_ticks};
|
||||
use super::client_fixtures::FakeClient;
|
||||
use super::match_end_fixtures::{played, statistics_arrive, until_landed};
|
||||
use super::matches_auto_open::{before_the_end, its_recap, settle_tabs, tabs};
|
||||
use super::matches_banner::{dressed, rows};
|
||||
use super::matches_fixtures::chosen;
|
||||
use super::matches_provisional::{LEFT_AT_MS, MATCH, block};
|
||||
use super::page_fixtures::{animations, draw, frame_after, show, switch_tab, tall};
|
||||
use crate::card_images::tests::TestDir;
|
||||
use crate::motion::MatchEnd;
|
||||
use crate::page::{Page, Tab};
|
||||
use crate::worker::Msg;
|
||||
use arena_tracker_core::{ChampionState, LastMatch, MatchOutcome, Statistics};
|
||||
use gpui_kit::{Entity, TestAppContext, VisualTestContext, WindowVisibility};
|
||||
|
||||
/// Irelia, whose Match ends, and Ahri validé: before it, and after a top 1 of Irelia's.
|
||||
fn before(dir: &TestDir) -> Statistics {
|
||||
banner_statistics(rows(dir), vec![103], None)
|
||||
}
|
||||
|
||||
fn after(dir: &TestDir) -> Statistics {
|
||||
let mut rows = rows(dir);
|
||||
rows[0] = banner_champion(39, "Irelia", 3, Some(on(11, 25)), 100);
|
||||
rows[0].splash = super::matches_banner::rows(dir)[0].splash.clone();
|
||||
banner_statistics(
|
||||
rows,
|
||||
vec![103, 39],
|
||||
Some(LastMatch {
|
||||
champion_id: 39,
|
||||
placement: 1,
|
||||
outcome: MatchOutcome::Completed(3),
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
/// The page on the Défi before Irelia's game ends, under `before`'s statistics.
|
||||
fn before_the_game(
|
||||
cx: &mut TestAppContext,
|
||||
dir: &TestDir,
|
||||
) -> (Entity<Page>, VisualTestContext, FakeClient) {
|
||||
let (page, mut window, client, _) = before_the_end(cx);
|
||||
tall(&mut window);
|
||||
show(&page, &mut window, before(dir));
|
||||
draw(&mut window);
|
||||
(page, window, client)
|
||||
}
|
||||
|
||||
/// The game ends and the follower's round, which brings the end `end` of the Match, stores it
|
||||
/// and tells the page; the statistics with it arrive.
|
||||
fn the_game_ends(
|
||||
page: &Entity<Page>,
|
||||
client: &FakeClient,
|
||||
end: MatchEnd,
|
||||
stats: Statistics,
|
||||
cx: &mut VisualTestContext,
|
||||
) {
|
||||
*client.block.lock().unwrap() = Some(block());
|
||||
cx.update(|window, cx| {
|
||||
page.update(cx, |page, cx| {
|
||||
let snapshot = page.tracker.client_snapshot();
|
||||
let mut ended = Vec::new();
|
||||
(page.tracker).follow_client_with(LEFT_AT_MS, None, &snapshot, &mut |_| {}, &mut |m| {
|
||||
ended.push(m)
|
||||
});
|
||||
assert_eq!(ended.len(), 1);
|
||||
ended[0].end = end;
|
||||
let status = page.tracker.status();
|
||||
let msg = Msg::Round {
|
||||
status,
|
||||
reload: false,
|
||||
matches: ended,
|
||||
game_end: None,
|
||||
};
|
||||
page.apply(msg, window, cx);
|
||||
})
|
||||
});
|
||||
statistics_arrive(page, cx, Some(stats));
|
||||
}
|
||||
|
||||
fn playing(page: &Entity<Page>, cx: &mut VisualTestContext) -> bool {
|
||||
page.read_with(cx, |p, _| p.playback.animation.is_some())
|
||||
}
|
||||
|
||||
fn idle(page: &Entity<Page>, cx: &mut VisualTestContext) -> bool {
|
||||
page.read_with(cx, |p, _| !p.playback.active() && !p.playback.stats_pending)
|
||||
}
|
||||
|
||||
/// « Défi » as a reload shows it: the ring, the banner and the card of the champion validé.
|
||||
fn assert_final_challenge(page: &Entity<Page>, cx: &mut VisualTestContext, dir: &TestDir) {
|
||||
assert!(ring_ticks(page, cx).contains(&(39, ChampionState::Completed)));
|
||||
page.read_with(cx, |p, cx| {
|
||||
assert_eq!(
|
||||
p.banner,
|
||||
crate::page::home::BannerContent::new(p.home_season.as_ref(), p.home_statistics())
|
||||
);
|
||||
let splash = p
|
||||
.banner_art
|
||||
.read(cx)
|
||||
.target
|
||||
.as_ref()
|
||||
.map(|s| s.path.clone());
|
||||
assert_eq!(splash, Some(dir.path().join("Irelia.50.30.jpg")));
|
||||
assert!(p.home_grid.read(cx).cards().iter().any(|c| c.id == 39));
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn the_end_of_a_top_1_plays_on_parties_and_the_challenge_then_shows_its_end_state(
|
||||
cx: &mut TestAppContext,
|
||||
) {
|
||||
let dir = TestDir::new("end-on-matches");
|
||||
let (page, mut window, client) = before_the_game(cx, &dir);
|
||||
|
||||
the_game_ends(
|
||||
&page,
|
||||
&client,
|
||||
MatchEnd::Completed,
|
||||
after(&dir),
|
||||
&mut window,
|
||||
);
|
||||
// « Parties » is not shown yet, nor does it hold the Match.
|
||||
assert!(played(&page, &mut window).is_empty());
|
||||
settle_tabs(&page, &mut window);
|
||||
its_recap(&page, cx).await;
|
||||
|
||||
// The Match is chosen: the comet flies over the banner of « Parties ».
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::Matches, Tab::Matches));
|
||||
assert_eq!(chosen(&page, &mut window).as_deref(), Some(MATCH));
|
||||
assert_eq!(played(&page, &mut window), [MatchEnd::Completed]);
|
||||
assert!(playing(&page, &mut window));
|
||||
draw(&mut window);
|
||||
// Under the comet, the champion of the Match before (none); then Irelia's settles in.
|
||||
assert_eq!(dressed(&page, &mut window), (None, None));
|
||||
until_landed(&page, &mut window);
|
||||
assert_eq!(
|
||||
dressed(&page, &mut window).0.as_deref(),
|
||||
Some("Irelia.50.30.jpg")
|
||||
);
|
||||
for _ in 0..30 {
|
||||
frame_after(&mut window, 200);
|
||||
}
|
||||
assert!(!playing(&page, &mut window) && idle(&page, &mut window));
|
||||
assert_eq!(
|
||||
dressed(&page, &mut window),
|
||||
(Some("Irelia.50.30.jpg".into()), Some(39))
|
||||
);
|
||||
|
||||
// Back on « Défi »: the end state, not played again.
|
||||
switch_tab(&page, &mut window, Tab::Challenge);
|
||||
draw(&mut window);
|
||||
assert_eq!(played(&page, &mut window), [MatchEnd::Completed]);
|
||||
assert!(idle(&page, &mut window) && !playing(&page, &mut window));
|
||||
assert_final_challenge(&page, &mut window, &dir);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn leaving_parties_during_the_animation_ends_it_without_a_second_play(
|
||||
cx: &mut TestAppContext,
|
||||
) {
|
||||
let dir = TestDir::new("end-on-matches-left");
|
||||
let (page, mut window, client) = before_the_game(cx, &dir);
|
||||
the_game_ends(
|
||||
&page,
|
||||
&client,
|
||||
MatchEnd::Completed,
|
||||
after(&dir),
|
||||
&mut window,
|
||||
);
|
||||
settle_tabs(&page, &mut window);
|
||||
its_recap(&page, cx).await;
|
||||
assert!(playing(&page, &mut window));
|
||||
|
||||
switch_tab(&page, &mut window, Tab::Challenge);
|
||||
draw(&mut window);
|
||||
assert!(!playing(&page, &mut window) && idle(&page, &mut window));
|
||||
assert_eq!(played(&page, &mut window), [MatchEnd::Completed]);
|
||||
assert_final_challenge(&page, &mut window, &dir);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn it_waits_for_parties_to_show_in_a_hidden_window_or_behind_the_settings(
|
||||
cx: &mut TestAppContext,
|
||||
) {
|
||||
let dir = TestDir::new("end-on-matches-hidden");
|
||||
let (page, mut window, client) = before_the_game(cx, &dir);
|
||||
window.update(|window, cx| page.update(cx, |page, cx| page.hidden(window, cx)));
|
||||
window.simulate_visibility_change(WindowVisibility::Hidden);
|
||||
|
||||
the_game_ends(
|
||||
&page,
|
||||
&client,
|
||||
MatchEnd::Completed,
|
||||
after(&dir),
|
||||
&mut window,
|
||||
);
|
||||
its_recap(&page, cx).await;
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::Matches, Tab::Matches));
|
||||
assert_eq!(chosen(&page, &mut window).as_deref(), Some(MATCH));
|
||||
assert!(played(&page, &mut window).is_empty());
|
||||
|
||||
// Shown again, still behind « Paramètres »: nothing yet.
|
||||
window.simulate_visibility_change(WindowVisibility::Visible);
|
||||
assert!(played(&page, &mut window).is_empty());
|
||||
window.update(|window, cx| page.update(cx, |page, cx| page.uncovered(window, cx)));
|
||||
assert_eq!(played(&page, &mut window), [MatchEnd::Completed]);
|
||||
assert!(playing(&page, &mut window));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn with_the_preference_off_it_plays_on_the_challenge_and_not_on_parties(
|
||||
cx: &mut TestAppContext,
|
||||
) {
|
||||
let dir = TestDir::new("end-on-challenge");
|
||||
let (page, mut window, client) = before_the_game(cx, &dir);
|
||||
page.update(&mut window, |page, _| {
|
||||
page.set_open_recap_at_match_end(false)
|
||||
});
|
||||
|
||||
the_game_ends(
|
||||
&page,
|
||||
&client,
|
||||
MatchEnd::Completed,
|
||||
after(&dir),
|
||||
&mut window,
|
||||
);
|
||||
settle_tabs(&page, &mut window);
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::Challenge, Tab::Challenge));
|
||||
assert_eq!(played(&page, &mut window), [MatchEnd::Completed]);
|
||||
assert!(playing(&page, &mut window));
|
||||
|
||||
// « Parties » opened by hand plays nothing more.
|
||||
switch_tab(&page, &mut window, Tab::Matches);
|
||||
draw(&mut window);
|
||||
assert_eq!(played(&page, &mut window), [MatchEnd::Completed]);
|
||||
assert!(idle(&page, &mut window));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn a_champ_select_that_starts_abandons_the_animation_waiting_on_parties(
|
||||
cx: &mut TestAppContext,
|
||||
) {
|
||||
use arena_tracker_core::ChampSelect;
|
||||
let dir = TestDir::new("end-on-matches-champ-select");
|
||||
let (page, mut window, client) = before_the_game(cx, &dir);
|
||||
window.simulate_visibility_change(WindowVisibility::Hidden);
|
||||
the_game_ends(
|
||||
&page,
|
||||
&client,
|
||||
MatchEnd::Completed,
|
||||
after(&dir),
|
||||
&mut window,
|
||||
);
|
||||
its_recap(&page, cx).await;
|
||||
assert!(page.read_with(&window, |p, _| p.playback.active()));
|
||||
|
||||
let champ_select = ChampSelect::new(Some(39), [39].into(), Some(vec![39]));
|
||||
window.update(|window, cx| {
|
||||
page.update(cx, |page, cx| {
|
||||
page.apply(
|
||||
Msg::ChampSelect(Some(("Alice#EUW".into(), champ_select))),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
});
|
||||
assert!(page.read_with(&window, |p, _| !p.playback.active()));
|
||||
cx.condition(&page, |p, _| !p.stats_job.running()).await;
|
||||
window.update(|window, cx| {
|
||||
page.update(cx, |page, cx| {
|
||||
page.apply(Msg::ChampSelect(None), window, cx)
|
||||
})
|
||||
});
|
||||
cx.condition(&page, |p, _| !p.stats_job.running()).await;
|
||||
window.simulate_visibility_change(WindowVisibility::Visible);
|
||||
draw(&mut window);
|
||||
assert!(played(&page, &mut window).is_empty());
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn without_animations_nothing_plays_on_parties(cx: &mut TestAppContext) {
|
||||
let dir = TestDir::new("end-on-matches-still");
|
||||
let (page, mut window, client) = before_the_game(cx, &dir);
|
||||
animations(&mut window, false);
|
||||
|
||||
the_game_ends(
|
||||
&page,
|
||||
&client,
|
||||
MatchEnd::Completed,
|
||||
after(&dir),
|
||||
&mut window,
|
||||
);
|
||||
settle_tabs(&page, &mut window);
|
||||
its_recap(&page, cx).await;
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::Matches, Tab::Matches));
|
||||
assert!(played(&page, &mut window).is_empty());
|
||||
assert!(idle(&page, &mut window));
|
||||
// The banner is at rest on the Match chosen.
|
||||
assert_eq!(
|
||||
dressed(&page, &mut window),
|
||||
(Some("Irelia.50.30.jpg".into()), Some(39))
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::client_fixtures::FakeClient;
|
||||
use super::page_fixtures::{MATCH_1750, draw, open_page_with_tracker, switch_tab};
|
||||
use super::page_fixtures::{MATCH_1750, draw, open_page_with_tracker, switch_tab, tall};
|
||||
use crate::page::matches::{Death, Recap};
|
||||
use crate::page::{Page, Tab};
|
||||
use crate::worker::Msg;
|
||||
@@ -125,6 +125,7 @@ pub(super) fn tracker_in(more: bool, seasons: Vec<Season>) -> (Tracker, Arc<Mute
|
||||
pub(super) async fn open_matches(cx: &mut TestAppContext) -> (Entity<Page>, VisualTestContext) {
|
||||
cx.executor().allow_parking();
|
||||
let (page, mut window) = open_page_with_tracker(cx, tracker().0);
|
||||
tall(&mut window);
|
||||
switch_tab(&page, &mut window, Tab::Matches);
|
||||
recap_ready(&page, cx).await;
|
||||
draw(&mut window);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use super::client_fixtures::FakeClient;
|
||||
use super::matches_fixtures::{TwoAccounts, recap_ready};
|
||||
use super::page_fixtures::{center, draw, open_page_with_tracker, switch_tab};
|
||||
use super::page_fixtures::{center, draw, open_page_with_tracker, switch_tab, tall};
|
||||
use crate::page::matches::{AWAITED, Recap, ShownDamage};
|
||||
use crate::page::{Page, Tab};
|
||||
use crate::worker::Msg;
|
||||
@@ -180,6 +180,7 @@ async fn publication_replaces_the_provisional_match_keeping_the_selection_and_th
|
||||
cx.executor().allow_parking();
|
||||
let (tracker, published) = tracker_with_provisional();
|
||||
let (page, mut window) = open_page_with_tracker(cx, tracker);
|
||||
tall(&mut window);
|
||||
switch_tab(&page, &mut window, Tab::Matches);
|
||||
recap_ready(&page, cx).await;
|
||||
draw(&mut window);
|
||||
|
||||
@@ -241,6 +241,12 @@ pub(super) fn grid_names(grid: &Entity<CardGrid>, cx: &mut VisualTestContext) ->
|
||||
})
|
||||
}
|
||||
|
||||
/// The window as tall as « Parties » needs to show a whole recap under the banner (#110).
|
||||
pub(super) fn tall(cx: &mut VisualTestContext) {
|
||||
cx.simulate_resize(size(px(1280.), px(1500.)));
|
||||
draw(cx);
|
||||
}
|
||||
|
||||
pub(super) fn draw(cx: &mut VisualTestContext) {
|
||||
cx.update(|window, cx| window.draw(cx).clear(cx));
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ impl Page {
|
||||
Msg::Matches {
|
||||
generation,
|
||||
matches,
|
||||
} => self.apply_matches(generation, matches, cx),
|
||||
} => self.apply_matches(generation, matches, window, cx),
|
||||
Msg::Recap {
|
||||
generation,
|
||||
recap,
|
||||
|
||||
Reference in new issue
Block a user