opening trainer: no «0 left» on the summary; «Learned X of Y · learning Z»; S0 shows the repertoire's start; «Switch colour to …» in the menu
This commit is contained in:
parent
f717644b6d
commit
358e1bf08e
5 changed files with 50 additions and 51 deletions
|
|
@ -1119,26 +1119,26 @@ const ROWS: &[[&str; 9]] = &[
|
||||||
"Бұл репертуарды оқу мүмкін болмады",
|
"Бұл репертуарды оқу мүмкін болмады",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Play as Black",
|
"Switch colour to Black",
|
||||||
"Играть чёрными",
|
"Сменить цвет на чёрные",
|
||||||
"Jouer les Noirs",
|
"Passer aux Noirs",
|
||||||
"Mit Schwarz spielen",
|
"Farbe auf Schwarz wechseln",
|
||||||
"Jugar con negras",
|
"Cambiar a negras",
|
||||||
"Gioca con il Nero",
|
"Passa al Nero",
|
||||||
"Jogar de pretas",
|
"Mudar para pretas",
|
||||||
"Qora bilan o‘ynash",
|
"Rangni qoraga almashtirish",
|
||||||
"Қарамен ойнау",
|
"Түсті қараға ауыстыру",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Play as White",
|
"Switch colour to White",
|
||||||
"Играть белыми",
|
"Сменить цвет на белые",
|
||||||
"Jouer les Blancs",
|
"Passer aux Blancs",
|
||||||
"Mit Weiß spielen",
|
"Farbe auf Weiß wechseln",
|
||||||
"Jugar con blancas",
|
"Cambiar a blancas",
|
||||||
"Gioca con il Bianco",
|
"Passa al Bianco",
|
||||||
"Jogar de brancas",
|
"Mudar para brancas",
|
||||||
"Oq bilan o‘ynash",
|
"Rangni oqqa almashtirish",
|
||||||
"Ақпен ойнау",
|
"Түсті аққа ауыстыру",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Lines…",
|
"Lines…",
|
||||||
|
|
@ -1482,15 +1482,15 @@ const ROWS: &[[&str; 9]] = &[
|
||||||
"{y} жүрістің {x} үйренілді",
|
"{y} жүрістің {x} үйренілді",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"{k} in progress",
|
"learning {k}",
|
||||||
"учится: {k}",
|
"учится {k}",
|
||||||
"{k} en cours",
|
"en cours {k}",
|
||||||
"{k} in Arbeit",
|
"in Arbeit {k}",
|
||||||
"{k} en curso",
|
"en curso {k}",
|
||||||
"{k} in corso",
|
"in corso {k}",
|
||||||
"{k} em andamento",
|
"em andamento {k}",
|
||||||
"o‘rganilmoqda: {k}",
|
"o‘rganilmoqda {k}",
|
||||||
"үйренілуде: {k}",
|
"үйренілуде {k}",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Add PGN to “{name}”",
|
"Add PGN to “{name}”",
|
||||||
|
|
|
||||||
|
|
@ -1766,12 +1766,11 @@ impl OpeningSessionUi {
|
||||||
fn counter(&self, state: &State) -> (String, &'static str) {
|
fn counter(&self, state: &State) -> (String, &'static str) {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
SessionKind::Daily => {
|
SessionKind::Daily => {
|
||||||
let left = if matches!(state, State::Summary) && !self.stopped {
|
// A finished session has nothing left: no «0 left» on its summary.
|
||||||
0
|
if matches!(state, State::Summary) && !self.stopped {
|
||||||
} else {
|
return (String::new(), "");
|
||||||
self.session.remaining()
|
}
|
||||||
};
|
(self.session.remaining().to_string(), tr("left"))
|
||||||
(left.to_string(), tr("left"))
|
|
||||||
}
|
}
|
||||||
SessionKind::ReviewAll | SessionKind::Branch { .. } => {
|
SessionKind::ReviewAll | SessionKind::Branch { .. } => {
|
||||||
let k = if self.is_finished() {
|
let k = if self.is_finished() {
|
||||||
|
|
|
||||||
|
|
@ -1423,11 +1423,11 @@ fn a_daily_session_brings_mistakes_and_hints_back_and_its_numbers_agree() {
|
||||||
// e4 wrong, e4 right, Nf3 right, Bb5 right.
|
// e4 wrong, e4 right, Nf3 right, Bb5 right.
|
||||||
assert_eq!(independent, 4);
|
assert_eq!(independent, 4);
|
||||||
f.ui.compute_summary();
|
f.ui.compute_summary();
|
||||||
f.ui.compute_summary();
|
|
||||||
let summary = f.ui.summary.as_ref().unwrap();
|
let summary = f.ui.summary.as_ref().unwrap();
|
||||||
assert_eq!(summary.more_new, 0);
|
assert_eq!(summary.more_new, 0);
|
||||||
assert!(!summary.next_review.is_empty());
|
assert!(!summary.next_review.is_empty());
|
||||||
assert_eq!(f.ui.counter(&State::Summary).0, "0");
|
// A finished session shows no «0 left».
|
||||||
|
assert_eq!(f.ui.counter(&State::Summary).0, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,8 @@ static NEXT_JOB: AtomicU64 = AtomicU64::new(1);
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct RowIndex {
|
struct RowIndex {
|
||||||
start: Chess,
|
start: Chess,
|
||||||
|
/// The position a session starts from (S0 shows it, not the library's preview).
|
||||||
|
initial: Chess,
|
||||||
last_move: Option<(Square, Square)>,
|
last_move: Option<(Square, Square)>,
|
||||||
has_moves: bool,
|
has_moves: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -452,6 +454,7 @@ impl RepertoireUi {
|
||||||
r.id.clone(),
|
r.id.clone(),
|
||||||
RowIndex {
|
RowIndex {
|
||||||
start: layout::position_of(&game, start),
|
start: layout::position_of(&game, start),
|
||||||
|
initial: layout::position_of(&game, NodeId::ROOT),
|
||||||
last_move: layout::last_move(&game, start),
|
last_move: layout::last_move(&game, start),
|
||||||
has_moves: !game.children(NodeId::ROOT).is_empty(),
|
has_moves: !game.children(NodeId::ROOT).is_empty(),
|
||||||
},
|
},
|
||||||
|
|
@ -1103,7 +1106,7 @@ impl RepertoireUi {
|
||||||
{
|
{
|
||||||
let side = layout::side_of(settings, &preparing.id);
|
let side = layout::side_of(settings, &preparing.id);
|
||||||
let index = self.index.get(&preparing.id);
|
let index = self.index.get(&preparing.id);
|
||||||
let start = index.map(|row| row.start.clone()).unwrap_or_default();
|
let start = index.map(|row| row.initial.clone()).unwrap_or_default();
|
||||||
let subtitle = preparing.kind.subtitle(side);
|
let subtitle = preparing.kind.subtitle(side);
|
||||||
let view = PreparingView {
|
let view = PreparingView {
|
||||||
name: &preparing.name,
|
name: &preparing.name,
|
||||||
|
|
@ -1115,7 +1118,7 @@ impl RepertoireUi {
|
||||||
},
|
},
|
||||||
position: &start,
|
position: &start,
|
||||||
orientation: layout::orientation(side),
|
orientation: layout::orientation(side),
|
||||||
last_move: index.and_then(|row| row.last_move),
|
last_move: None,
|
||||||
lines: preparing.kind != SessionKind::Daily,
|
lines: preparing.kind != SessionKind::Daily,
|
||||||
};
|
};
|
||||||
for action in show_preparing(ui, settings, &mut self.board, &view) {
|
for action in show_preparing(ui, settings, &mut self.board, &view) {
|
||||||
|
|
@ -2433,8 +2436,8 @@ fn main_button(state: &CardState, side: LearningSide) -> (String, bool, Option<M
|
||||||
CardState::Empty => (tr("Add PGN…").to_owned(), true, Some(MenuItem::AddPgn)),
|
CardState::Empty => (tr("Add PGN…").to_owned(), true, Some(MenuItem::AddPgn)),
|
||||||
CardState::OtherColor => (
|
CardState::OtherColor => (
|
||||||
match side {
|
match side {
|
||||||
LearningSide::White => tr("Play as Black"),
|
LearningSide::White => tr("Switch colour to Black"),
|
||||||
LearningSide::Black => tr("Play as White"),
|
LearningSide::Black => tr("Switch colour to White"),
|
||||||
}
|
}
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
true,
|
true,
|
||||||
|
|
@ -2474,15 +2477,12 @@ fn progress(ui: &mut Ui, stats: Option<&RowStats>) {
|
||||||
(stats.learnt, stats.total, stats.learning)
|
(stats.learnt, stats.total, stats.learning)
|
||||||
});
|
});
|
||||||
if stats.is_some() {
|
if stats.is_some() {
|
||||||
layout::line(
|
let mut text = trf("Learned {x} of {y} moves", &[("x", &learnt), ("y", &total)]);
|
||||||
ui,
|
// The bar's second segment, named where the bar is read.
|
||||||
trf("Learned {x} of {y} moves", &[("x", &learnt), ("y", &total)]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if learning > 0 {
|
if learning > 0 {
|
||||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
text = format!("{text} · {}", trf("learning {k}", &[("k", &learning)]));
|
||||||
ui.label(RichText::new(trf("{k} in progress", &[("k", &learning)])).weak());
|
}
|
||||||
});
|
layout::line(ui, text);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -2509,8 +2509,8 @@ fn menu_items(
|
||||||
ui,
|
ui,
|
||||||
true,
|
true,
|
||||||
match side {
|
match side {
|
||||||
LearningSide::White => tr("Play as Black"),
|
LearningSide::White => tr("Switch colour to Black"),
|
||||||
LearningSide::Black => tr("Play as White"),
|
LearningSide::Black => tr("Switch colour to White"),
|
||||||
},
|
},
|
||||||
MenuItem::SwitchColor,
|
MenuItem::SwitchColor,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ fn the_card_says_what_to_do_in_every_state() {
|
||||||
assert!(!main_button(&CardState::Counting, LearningSide::White).1);
|
assert!(!main_button(&CardState::Counting, LearningSide::White).1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
main_button(&CardState::OtherColor, LearningSide::White).0,
|
main_button(&CardState::OtherColor, LearningSide::White).0,
|
||||||
tr("Play as Black")
|
tr("Switch colour to Black")
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
card_texts(&CardState::Review { due: 3, new: 10 }, LearningSide::White),
|
card_texts(&CardState::Review { due: 3, new: 10 }, LearningSide::White),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue