No preview strip: «+ Add as variation» at the end of the line being shown
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run
CI / macos-build (push) Waiting to run

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-25 03:22:51 +03:00
parent 6d3d393e25
commit f03a0d2a4b
4 changed files with 60 additions and 60 deletions

View file

@ -1323,6 +1323,9 @@ impl GameView {
Some(EditorOutcome::Cancel) => self.cancel_editor(),
None => {}
}
if resp.insert_preview {
self.insert_preview(actions);
}
if let Some(slot) = resp.edit {
self.open_editor(slot);
}
@ -1504,9 +1507,25 @@ impl GameView {
let base = self.cursor;
let root = self.game.position(base).cloned();
let lines: Vec<PvLine> = analysis.lines.clone();
let mut insert = false;
for line in &lines {
let previewed = self
.preview
.as_ref()
.is_some_and(|p| p.base == base && p.san == line.san);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 3.0;
// The line being stepped through on the board: added from here.
if previewed
&& ui
.small_button(tr("+ Add as variation"))
.on_hover_text(tr(
"Puts the line into the game as a variation (Ctrl+Z to undo)",
))
.clicked()
{
insert = true;
}
ui.label(
RichText::new(analysis::format_eval(&line.score))
.strong()
@ -1561,35 +1580,8 @@ impl GameView {
});
});
}
}
if let Some(p) = &self.preview {
let mut exit = false;
let mut insert = false;
egui::Frame::new()
.fill(ui.visuals().selection.bg_fill.gamma_multiply(0.35))
.inner_margin(6)
.show(ui, |ui| {
ui.horizontal_wrapped(|ui| {
ui.label(RichText::new(tr("Engine line preview")).strong());
ui.label(
RichText::new(trf(
"move {a}/{b}",
&[("a", &p.shown), ("b", &p.moves.len())],
))
.weak(),
);
if ui.button(tr("Add as variation")).clicked() {
insert = true;
}
if ui.button(tr("Exit (Esc)")).clicked() {
exit = true;
}
});
});
if insert {
self.insert_preview(actions);
} else if exit {
self.preview = None;
}
}
ui.add_space(4.0);

View file

@ -7392,28 +7392,6 @@ const ROWS: &[[&str; 9]] = &[
"Dvigatel sozlamalari",
"Қозғалтқыш баптаулары",
],
[
"Engine line preview",
"Предпросмотр линии движка",
"Aperçu de la ligne du moteur",
"Vorschau der Engine-Variante",
"Vista previa de la línea del motor",
"Anteprima della linea del motore",
"Prévia da linha do motor",
"Dvigatel liniyasini ko‘rish",
"Қозғалтқыш вариантын алдын ала көру",
],
[
"move {a}/{b}",
"ход {a}/{b}",
"coup {a}/{b}",
"Zug {a}/{b}",
"jugada {a}/{b}",
"mossa {a}/{b}",
"lance {a}/{b}",
"yurish {a}/{b}",
"жүріс {a}/{b}",
],
[
"Add as variation",
"Добавить как вариант",
@ -7425,17 +7403,6 @@ const ROWS: &[[&str; 9]] = &[
"Variant sifatida qo‘shish",
"Вариант ретінде қосу",
],
[
"Exit (Esc)",
"Выйти (Esc)",
"Quitter (Échap)",
"Beenden (Esc)",
"Salir (Esc)",
"Esci (Esc)",
"Sair (Esc)",
"Chiqish (Esc)",
"Шығу (Esc)",
],
[
"Line added as a variation (Ctrl+Z to undo)",
"Линия добавлена как вариант (Ctrl+Z — отменить)",
@ -10199,6 +10166,28 @@ const ROWS: &[[&str; 9]] = &[
"Qoralar yutmoqda",
"Қаралар ұтып жатыр",
],
[
"+ Add as variation",
"+ Добавить как вариант",
"+ Ajouter comme variante",
"+ Als Variante hinzufügen",
"+ Añadir como variante",
"+ Aggiungi come variante",
"+ Adicionar como variante",
"+ Variant sifatida qo‘shish",
"+ Нұсқа ретінде қосу",
],
[
"Puts the line into the game as a variation (Ctrl+Z to undo)",
"Запишет линию в партию вариантом (Ctrl+Z — отменить)",
"Ajoute la ligne à la partie comme variante (Ctrl+Z pour annuler)",
"Nimmt die Linie als Variante in die Partie auf (Ctrl+Z zum Rückgängigmachen)",
"Añade la línea a la partida como variante (Ctrl+Z para deshacer)",
"Aggiunge la linea alla partita come variante (Ctrl+Z per annullare)",
"Adiciona a linha à partida como variante (Ctrl+Z para desfazer)",
"Liniyani o‘yinga variant sifatida yozadi (Ctrl+Z — bekor qilish)",
"Желіні партияға нұсқа ретінде жазады (Ctrl+Z — болдырмау)",
],
];
#[cfg(test)]

View file

@ -39,6 +39,8 @@ pub struct NotationResponse {
pub nag: Option<(NodeId, Nag)>,
/// The editor's «Done» or «Cancel».
pub editor: Option<EditorOutcome>,
/// The engine line shown on the board goes into the game as a variation.
pub insert_preview: bool,
}
#[derive(Clone, Copy, Debug)]
@ -553,6 +555,18 @@ fn mark_block(ui: &mut Ui, n: &Notation, id: NodeId, mark: &Mark, out: &mut Nota
if mark.best_san.len() > visible {
ui.label(RichText::new("…").weak());
}
// The line being stepped through on the board: added from here (there is
// no separate strip for it).
if shown.is_some()
&& ui
.small_button(tr("+ Add as variation"))
.on_hover_text(tr(
"Puts the line into the game as a variation (Ctrl+Z to undo)",
))
.clicked()
{
out.insert_preview = true;
}
});
});
}