Always list the Anvil champions A to Z; sort selector moves to Autres champions (#119)
The client lists the Anvil champions alphabetically: the row now keeps the statistics' own order whatever sort was chosen. The selector, which only applies to the other cards, sits beside the search of Autres champions. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit was merged in pull request #120.
This commit is contained in:
1 parent
5f309d35e7
commit
986c090d78
7 files changed
+48
-46
No files matched your search
@@ -54,8 +54,8 @@ impl Page {
|
||||
self.next_home = None;
|
||||
}
|
||||
|
||||
/// The home statistics' rows in the cards' order: the single iteration the home grid, the
|
||||
/// Anvil champions and « Autres champions » all follow.
|
||||
/// The home statistics' rows in the cards' order: the single iteration the home grid and
|
||||
/// « Autres champions » follow (the Anvil champions are always A to Z).
|
||||
pub(in crate::page) fn ordered_rows(&self) -> impl Iterator<Item = &ChampionRow> {
|
||||
let rows = self
|
||||
.home_statistics()
|
||||
|
||||
@@ -61,16 +61,16 @@ impl Page {
|
||||
/// The cards of the Anvil champions row (`stats_notice` says why there are none when the
|
||||
/// statistics are missing). For when the champ select, the statistics or the status change.
|
||||
pub(in crate::page) fn prepare_champ_select(&mut self, cx: &mut Context<Self>) {
|
||||
// The same rows in the same order as the home grid (`ordered_rows`): the
|
||||
// cards keep their place whatever the champ select does. An id the rows do not know is
|
||||
// skipped.
|
||||
// The statistics' own order, A to Z, whatever sort the player chose: it is the client's
|
||||
// order of the Anvil champions. An id the rows do not know is skipped.
|
||||
let champ_select = self.live_champ_select();
|
||||
let anvil = champ_select.and_then(|pick| pick.anvil_champions.as_deref());
|
||||
let ids = anvil.unwrap_or_default();
|
||||
let cards = self.champ_select_cards(
|
||||
self.ordered_rows()
|
||||
.filter(|row| ids.contains(&row.champion.id)),
|
||||
);
|
||||
let rows = self
|
||||
.home_statistics()
|
||||
.map_or(&[][..], |s| s.rows.as_slice());
|
||||
let cards =
|
||||
self.champ_select_cards(rows.iter().filter(|row| ids.contains(&row.champion.id)));
|
||||
// A list the client did not send dims no tick: the ring would look empty.
|
||||
self.ring.update(cx, |ring, cx| ring.set_anvil(anvil, cx));
|
||||
if champ_select.is_some() {
|
||||
|
||||
@@ -42,27 +42,16 @@ impl Page {
|
||||
div()
|
||||
.v_flex()
|
||||
.gap_3()
|
||||
// The scrollbar's lane: the sort selector does not go under it.
|
||||
.pr(Scrollbar::width())
|
||||
.child(
|
||||
div()
|
||||
.h_flex()
|
||||
.flex_wrap()
|
||||
.items_center()
|
||||
.justify_between()
|
||||
.gap_x_3()
|
||||
.gap_y_2()
|
||||
.child(
|
||||
div()
|
||||
.h_flex()
|
||||
.items_center()
|
||||
.gap(px(6.))
|
||||
.child(heading(cx).text_xl().child("Champions de l'Enclume"))
|
||||
.when(row.is_none(), |heading| {
|
||||
heading.child(count_badge(self.anvil_count.clone(), muted, border))
|
||||
}),
|
||||
)
|
||||
.child(self.sort_selector(cx)),
|
||||
.gap(px(6.))
|
||||
.child(heading(cx).text_xl().child("Champions de l'Enclume"))
|
||||
.when(row.is_none(), |heading| {
|
||||
heading.child(count_badge(self.anvil_count.clone(), muted, border))
|
||||
}),
|
||||
)
|
||||
.children(match row {
|
||||
// The header already says there is no Season, and a banner the statistics' error:
|
||||
@@ -155,12 +144,20 @@ impl Page {
|
||||
.when(open, |section| {
|
||||
section
|
||||
.child(
|
||||
div().h_flex().child(
|
||||
Input::new(&self.others_search_input)
|
||||
.cleanable(true)
|
||||
.w(px(260.))
|
||||
.min_w(px(150.)),
|
||||
),
|
||||
div()
|
||||
.h_flex()
|
||||
.flex_wrap()
|
||||
.items_center()
|
||||
.justify_between()
|
||||
.gap_x_3()
|
||||
.gap_y_2()
|
||||
.child(
|
||||
Input::new(&self.others_search_input)
|
||||
.cleanable(true)
|
||||
.w(px(260.))
|
||||
.min_w(px(150.)),
|
||||
)
|
||||
.child(self.sort_selector(cx)),
|
||||
)
|
||||
.child(self.others_cards(window_width, cx))
|
||||
.children(self.lift_layer(&self.others_grid, cx))
|
||||
|
||||
@@ -215,8 +215,8 @@ impl Page {
|
||||
vec![column.id("home").overflow_y_scroll().into_any_element()]
|
||||
}
|
||||
|
||||
/// The sort selector: a sort icon and the choice, « Maîtrise » or « A–Z ». It stays on the
|
||||
/// home and during a champ select, and applies to every section of cards.
|
||||
/// The sort selector: a sort icon and the choice, « Maîtrise » or « A–Z ». It is on the
|
||||
/// home and in « Autres champions »; the Anvil champions are always A to Z.
|
||||
pub(in crate::page) fn sort_selector(&self, cx: &App) -> impl IntoElement {
|
||||
let muted = cx.theme().muted_foreground;
|
||||
div()
|
||||
|
||||
@@ -103,9 +103,7 @@ pub(super) const MASTERY: [(u32, u64); 7] = [
|
||||
(103, 100),
|
||||
];
|
||||
|
||||
/// The Anvil champions of the capture by Mastery Points, then those without an anvil.
|
||||
pub(super) const ANVIL_BY_MASTERY: [u32; 5] = [64, 16, 233, 68, 5];
|
||||
|
||||
/// The champions without an anvil of the capture by Mastery Points.
|
||||
pub(super) const OTHERS_BY_MASTERY: [u32; 4] = [50, 12, 103, 25];
|
||||
|
||||
pub(super) const ALL_A_TO_Z: [&str; 9] = [
|
||||
|
||||
@@ -4,8 +4,8 @@ use super::champ_select_fixtures::{
|
||||
send, start_leaving, with_bans_and_ally,
|
||||
};
|
||||
use super::page_fixtures::{
|
||||
animations, assert_at_rest, draw, focus_sort, frame_after, hover, open_page_with_tracker,
|
||||
press, rise, settle, shown_tab, switch_tab, veil,
|
||||
animations, assert_at_rest, draw, frame_after, hover, open_page_with_tracker, press, rise,
|
||||
settle, shown_tab, switch_tab, veil,
|
||||
};
|
||||
use crate::card::Reason;
|
||||
use crate::page::Tab;
|
||||
@@ -150,8 +150,14 @@ async fn the_pointer_moving_cancels_the_card_the_keyboard_waits_for(cx: &mut Tes
|
||||
|
||||
// 400 ms: Briar, the first card, is on its way.
|
||||
frame_after(cx, 400);
|
||||
focus_sort(&page, cx);
|
||||
press(cx, "tab");
|
||||
// Nothing precedes the Anvil row in the tab order: shift-tab from « Autres champions »
|
||||
// lands on its last card.
|
||||
let others = page.read_with(cx, |p, _| p.others_focus.clone());
|
||||
cx.update(|window, cx| {
|
||||
window.activate_window();
|
||||
window.focus(&others, cx)
|
||||
});
|
||||
press(cx, "shift-tab");
|
||||
assert!(page.read_with(cx, |p, _| p.hover_waiting.is_some()));
|
||||
cx.simulate_mouse_move(point(px(5.), px(5.)), None, Modifiers::none());
|
||||
draw(cx);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::champ_select_fixtures::{
|
||||
ALL_A_TO_Z, ANVIL_A_TO_Z, ANVIL_BY_MASTERY, OTHERS_A_TO_Z, OTHERS_BY_MASTERY, anvil_cards,
|
||||
click_others, frames, ids, joueur_tracker_with, leave, others_cards, reasons, send,
|
||||
ALL_A_TO_Z, ANVIL_A_TO_Z, OTHERS_A_TO_Z, OTHERS_BY_MASTERY, anvil_cards, click_others, frames,
|
||||
ids, joueur_tracker_with, leave, others_cards, reasons, send,
|
||||
};
|
||||
use super::page_fixtures::{
|
||||
center, draw, grid_names, open_page_in_season, open_page_with_sort, open_page_with_tracker,
|
||||
@@ -199,21 +199,22 @@ async fn alias_filters_sort_and_the_champ_select_all_follow_one_order(cx: &mut T
|
||||
[103, 12, 233, 25, 50, 5]
|
||||
);
|
||||
|
||||
// Entering a champ select: the Anvil row follows the sort, so does « Autres champions »,
|
||||
// and the selector stays.
|
||||
// Entering a champ select: the Anvil row is A to Z whatever the sort, « Autres champions »
|
||||
// follows it, and the selector is in the latter, beside its search, once it is open.
|
||||
send(&page, &mut window, &frames()[0]);
|
||||
cx.condition(&page, |p, _| {
|
||||
p.stats.as_ref().is_some_and(|s| s.rows.len() == 9)
|
||||
})
|
||||
.await;
|
||||
draw(&mut window);
|
||||
assert!(window.debug_bounds("sort").is_some());
|
||||
assert!(window.debug_bounds("sort").is_none());
|
||||
assert_eq!(ids(&anvil_cards(&page, &mut window)), ANVIL_A_TO_Z);
|
||||
click_others(&mut window);
|
||||
assert!(window.debug_bounds("sort").is_some());
|
||||
assert_eq!(ids(&others_cards(&page, &mut window)), OTHERS_A_TO_Z);
|
||||
|
||||
pick_sort(&page, &mut window, "Maîtrise");
|
||||
assert_eq!(ids(&anvil_cards(&page, &mut window)), ANVIL_BY_MASTERY);
|
||||
assert_eq!(ids(&anvil_cards(&page, &mut window)), ANVIL_A_TO_Z);
|
||||
assert_eq!(ids(&others_cards(&page, &mut window)), OTHERS_BY_MASTERY);
|
||||
// Reasons still go with their cards.
|
||||
assert_eq!(
|
||||
|
||||
Reference in new issue
Block a user