2026-10-18 01:54:06 +03:00
|
|
|
//! Move list: main line as a two-column table (Lichess style), comments and variations
|
|
|
|
|
//! as full-width blocks between rows; nested variations inline in parentheses.
|
|
|
|
|
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
2026-10-18 01:54:06 +03:00
|
|
|
use crate::i18n::tr;
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
use crate::review::{Mark, judgement_color, judgement_name, judgement_symbol};
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
use crate::translate_ui::Mark as Translated;
|
2026-10-18 11:45:13 +03:00
|
|
|
use chess_core::shakmaty::{Color, Position};
|
2026-10-18 01:54:06 +03:00
|
|
|
use chess_core::{CommentPart, Game, Nag, NodeId, parse_comment};
|
|
|
|
|
use egui::{Align2, Color32, FontId, RichText, Sense, Stroke, Ui, vec2};
|
|
|
|
|
|
|
|
|
|
pub struct Notation<'a> {
|
|
|
|
|
pub game: &'a Game,
|
|
|
|
|
pub cursor: NodeId,
|
|
|
|
|
pub scroll_to_cursor: bool,
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
/// Engine assessments of main-line moves (whole-game analysis), shown apart from NAGs.
|
|
|
|
|
pub marks: Option<&'a HashMap<NodeId, Mark>>,
|
2026-10-18 11:45:13 +03:00
|
|
|
/// Engine line shown on the board: (start node, SAN moves, moves played so far).
|
|
|
|
|
pub preview: Option<(NodeId, &'a [String], usize)>,
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
/// Translated comments by their original text (none: the original is shown).
|
|
|
|
|
pub translations: Option<&'a HashMap<String, Translated>>,
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Result of a frame of the notation panel.
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
pub struct NotationResponse {
|
|
|
|
|
pub clicked: Option<NodeId>,
|
|
|
|
|
pub context: Option<(NodeId, NotationCommand)>,
|
2026-10-18 11:45:13 +03:00
|
|
|
/// A move of the better line of this marked move was clicked: (marked node, moves to show).
|
|
|
|
|
pub best: Option<(NodeId, usize)>,
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug)]
|
|
|
|
|
pub enum NotationCommand {
|
|
|
|
|
Promote,
|
|
|
|
|
Delete,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ROW_H: f32 = 26.0;
|
|
|
|
|
const NUM_W: f32 = 38.0;
|
2026-10-18 12:10:40 +03:00
|
|
|
/// Moves of an engine's better line shown under a marked move.
|
|
|
|
|
const MARK_LINE_MOVES: usize = 6;
|
2026-10-18 01:54:06 +03:00
|
|
|
|
|
|
|
|
impl Notation<'_> {
|
|
|
|
|
pub fn show(self, ui: &mut Ui) -> NotationResponse {
|
|
|
|
|
let mut out = NotationResponse::default();
|
|
|
|
|
let game = self.game;
|
|
|
|
|
let root_comments = comment_text(
|
|
|
|
|
game.node(NodeId::ROOT)
|
|
|
|
|
.map(|n| n.comments_after())
|
|
|
|
|
.unwrap_or(&[]),
|
|
|
|
|
);
|
|
|
|
|
if !root_comments.is_empty() {
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
comment_block(ui, &self, &root_comments);
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let mut row = Row::default();
|
|
|
|
|
let mut node = NodeId::ROOT;
|
|
|
|
|
while let Some(child) = game.main_child(node) {
|
|
|
|
|
let Some(n) = game.node(child) else { break };
|
|
|
|
|
let before = comment_text(n.comments_before());
|
|
|
|
|
if !before.is_empty() {
|
|
|
|
|
row.flush(ui, &self, &mut out);
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
comment_block(ui, &self, &before);
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
let (num, color) = game.move_number(child).unwrap_or((0, Color::White));
|
|
|
|
|
if color == Color::White {
|
|
|
|
|
row.flush(ui, &self, &mut out);
|
|
|
|
|
row.num = num;
|
|
|
|
|
row.white = Some(child);
|
|
|
|
|
} else {
|
|
|
|
|
if row.white.is_none() {
|
|
|
|
|
row.num = num;
|
|
|
|
|
}
|
|
|
|
|
row.black = Some(child);
|
|
|
|
|
}
|
|
|
|
|
let after = comment_text(n.comments_after());
|
|
|
|
|
let vars = game.variations(node);
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
let mark = self.marks.and_then(|m| m.get(&child));
|
|
|
|
|
let interrupted =
|
|
|
|
|
!after.is_empty() || !vars.is_empty() || !n.unparsed().is_empty() || mark.is_some();
|
2026-10-18 01:54:06 +03:00
|
|
|
if interrupted || color == Color::Black {
|
|
|
|
|
row.flush(ui, &self, &mut out);
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
if let Some(mark) = mark {
|
2026-10-18 11:45:13 +03:00
|
|
|
mark_block(ui, &self, child, mark, &mut out);
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
if !after.is_empty() {
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
comment_block(ui, &self, &after);
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
for u in n.unparsed() {
|
|
|
|
|
unparsed_block(ui, u);
|
|
|
|
|
}
|
|
|
|
|
for &v in vars {
|
|
|
|
|
variation_block(ui, &self, v, &mut out);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
node = child;
|
|
|
|
|
}
|
|
|
|
|
row.flush(ui, &self, &mut out);
|
|
|
|
|
|
|
|
|
|
let result = game.result().as_str();
|
|
|
|
|
if result != "*" {
|
|
|
|
|
ui.add_space(6.0);
|
|
|
|
|
ui.vertical_centered(|ui| ui.label(RichText::new(result).strong().size(16.0)));
|
|
|
|
|
}
|
|
|
|
|
out
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
|
struct Row {
|
|
|
|
|
num: u32,
|
|
|
|
|
white: Option<NodeId>,
|
|
|
|
|
black: Option<NodeId>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Row {
|
|
|
|
|
fn flush(&mut self, ui: &mut Ui, n: &Notation, out: &mut NotationResponse) {
|
|
|
|
|
if self.white.is_none() && self.black.is_none() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let width = ui.available_width();
|
|
|
|
|
let (rect, _) = ui.allocate_exact_size(vec2(width, ROW_H), Sense::hover());
|
|
|
|
|
let painter = ui.painter();
|
|
|
|
|
let visuals = ui.visuals();
|
|
|
|
|
painter.rect_filled(
|
|
|
|
|
egui::Rect::from_min_size(rect.min, vec2(NUM_W, ROW_H)),
|
|
|
|
|
0.0,
|
|
|
|
|
visuals.faint_bg_color,
|
|
|
|
|
);
|
|
|
|
|
painter.text(
|
|
|
|
|
rect.left_center() + vec2(NUM_W - 8.0, 0.0),
|
|
|
|
|
Align2::RIGHT_CENTER,
|
|
|
|
|
self.num.to_string(),
|
|
|
|
|
FontId::proportional(14.0),
|
|
|
|
|
visuals.weak_text_color(),
|
|
|
|
|
);
|
|
|
|
|
let cell_w = (width - NUM_W) / 2.0;
|
|
|
|
|
let cells = [(self.white, 0.0), (self.black, cell_w)];
|
|
|
|
|
for (id, off) in cells {
|
|
|
|
|
let cell =
|
|
|
|
|
egui::Rect::from_min_size(rect.min + vec2(NUM_W + off, 0.0), vec2(cell_w, ROW_H));
|
|
|
|
|
match id {
|
|
|
|
|
Some(id) => {
|
|
|
|
|
let resp = ui.interact(cell, ui.id().with(("mv", id.index())), Sense::click());
|
|
|
|
|
paint_move_cell(ui, cell, n.game, id, id == n.cursor, resp.hovered());
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
if let Some(mark) = n.marks.and_then(|m| m.get(&id)) {
|
|
|
|
|
paint_badge(ui, cell, mark);
|
|
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
handle_move_response(ui, &resp, n, id, out);
|
|
|
|
|
}
|
|
|
|
|
None => {
|
|
|
|
|
ui.painter().text(
|
|
|
|
|
cell.left_center() + vec2(10.0, 0.0),
|
|
|
|
|
Align2::LEFT_CENTER,
|
|
|
|
|
"…",
|
|
|
|
|
FontId::proportional(15.0),
|
|
|
|
|
ui.visuals().weak_text_color(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*self = Row::default();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn handle_move_response(
|
|
|
|
|
ui: &Ui,
|
|
|
|
|
resp: &egui::Response,
|
|
|
|
|
n: &Notation,
|
|
|
|
|
id: NodeId,
|
|
|
|
|
out: &mut NotationResponse,
|
|
|
|
|
) {
|
|
|
|
|
if resp.clicked() {
|
|
|
|
|
out.clicked = Some(id);
|
|
|
|
|
}
|
|
|
|
|
if n.scroll_to_cursor && id == n.cursor {
|
|
|
|
|
resp.scroll_to_me(Some(egui::Align::Center));
|
|
|
|
|
}
|
|
|
|
|
let is_variation = n.game.child_index(id).is_some_and(|i| i > 0) || !n.game.is_mainline(id);
|
|
|
|
|
resp.context_menu(|ui| {
|
|
|
|
|
if is_variation && ui.button(tr("Make main line")).clicked() {
|
|
|
|
|
out.context = Some((id, NotationCommand::Promote));
|
|
|
|
|
ui.close();
|
|
|
|
|
}
|
|
|
|
|
if ui.button(tr("Delete move and continuation")).clicked() {
|
|
|
|
|
out.context = Some((id, NotationCommand::Delete));
|
|
|
|
|
ui.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
let _ = ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn paint_move_cell(
|
|
|
|
|
ui: &Ui,
|
|
|
|
|
cell: egui::Rect,
|
|
|
|
|
game: &Game,
|
|
|
|
|
id: NodeId,
|
|
|
|
|
current: bool,
|
|
|
|
|
hovered: bool,
|
|
|
|
|
) {
|
|
|
|
|
let visuals = ui.visuals();
|
|
|
|
|
if current {
|
|
|
|
|
ui.painter()
|
|
|
|
|
.rect_filled(cell, 2.0, visuals.selection.bg_fill);
|
|
|
|
|
} else if hovered {
|
|
|
|
|
ui.painter()
|
|
|
|
|
.rect_filled(cell, 2.0, visuals.widgets.hovered.weak_bg_fill);
|
|
|
|
|
}
|
|
|
|
|
let node = game.node(id);
|
|
|
|
|
let san = game.game_move(id).map(|m| m.san.as_str()).unwrap_or("?");
|
Move notation: Latin letters, figurines or the interface language's letters
Settings › Board & pieces: Nf3, ♘f3 as on Lichess, or Кр Ф Л С К (German
K D T L S, French R D T F C, Spanish and Italian R D T A C; in English the
Latin letters), with a sample per option and a line of a game. Only the shown
label changes (san::show): the game, PGN, copied games, the analysis written
into a game, the reference cache and every comparison stay Latin SAN. Applied
in the move list, engine lines, the reference tab, board search and the
analysis report. The figurines are egui's chess glyphs cut out to a 4.7 KB
font, a little smaller and on the baseline. Latin remains the default.
Reviewed by the designer and the tester agents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:18:53 +03:00
|
|
|
let san = crate::san::show(san);
|
2026-10-18 01:54:06 +03:00
|
|
|
let (sym, color) = node
|
|
|
|
|
.map(|n| move_glyph(n.nags()))
|
|
|
|
|
.unwrap_or((String::new(), None));
|
|
|
|
|
let text_color = if current {
|
|
|
|
|
visuals.selection.stroke.color
|
|
|
|
|
} else {
|
|
|
|
|
color.unwrap_or(visuals.text_color())
|
|
|
|
|
};
|
|
|
|
|
ui.painter().text(
|
|
|
|
|
cell.left_center() + vec2(10.0, 0.0),
|
|
|
|
|
Align2::LEFT_CENTER,
|
|
|
|
|
format!("{san}{sym}"),
|
|
|
|
|
FontId::proportional(16.0),
|
|
|
|
|
text_color,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
/// Engine verdict at the right edge of a move cell: a filled pill, unlike the author's NAGs.
|
|
|
|
|
fn paint_badge(ui: &Ui, cell: egui::Rect, mark: &Mark) {
|
|
|
|
|
let color = judgement_color(mark.judgement);
|
|
|
|
|
let font = FontId::proportional(12.0);
|
|
|
|
|
let galley = ui.painter().layout_no_wrap(
|
|
|
|
|
judgement_symbol(mark.judgement).to_string(),
|
|
|
|
|
font,
|
|
|
|
|
Color32::WHITE,
|
|
|
|
|
);
|
|
|
|
|
let size = vec2(galley.size().x + 10.0, 16.0);
|
|
|
|
|
let rect = egui::Rect::from_min_size(
|
|
|
|
|
egui::pos2(cell.right() - size.x - 6.0, cell.center().y - size.y / 2.0),
|
|
|
|
|
size,
|
|
|
|
|
);
|
|
|
|
|
ui.painter().rect_filled(rect, 8.0, color);
|
|
|
|
|
ui.painter()
|
|
|
|
|
.galley(rect.center() - galley.size() / 2.0, galley, Color32::WHITE);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 11:45:13 +03:00
|
|
|
/// "Mistake. Best: 23…Nf6 24.Nd5 …" under a marked main-line move. Each move opens the line
|
|
|
|
|
/// on the board up to it; the move shown on the board is highlighted like the game cursor.
|
|
|
|
|
fn mark_block(ui: &mut Ui, n: &Notation, id: NodeId, mark: &Mark, out: &mut NotationResponse) {
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
let color = judgement_color(mark.judgement);
|
2026-10-18 11:45:13 +03:00
|
|
|
let start = n
|
|
|
|
|
.game
|
|
|
|
|
.position(mark.base)
|
|
|
|
|
.map(|p| (p.fullmoves().get(), p.turn()));
|
|
|
|
|
let shown = n
|
|
|
|
|
.preview
|
|
|
|
|
.filter(|(base, san, _)| *base == mark.base && *san == mark.best_san.as_slice())
|
|
|
|
|
.map(|(_, _, shown)| shown);
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
egui::Frame::new()
|
|
|
|
|
.fill(ui.visuals().extreme_bg_color)
|
|
|
|
|
.inner_margin(egui::Margin {
|
|
|
|
|
left: 10,
|
|
|
|
|
right: 10,
|
|
|
|
|
top: 3,
|
|
|
|
|
bottom: 3,
|
|
|
|
|
})
|
|
|
|
|
.stroke(Stroke::new(1.0, color.gamma_multiply(0.6)))
|
|
|
|
|
.show(ui, |ui| {
|
|
|
|
|
ui.set_width(ui.available_width());
|
|
|
|
|
ui.horizontal_wrapped(|ui| {
|
2026-10-18 11:45:13 +03:00
|
|
|
ui.spacing_mut().item_spacing = vec2(3.0, 2.0);
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
ui.label(
|
|
|
|
|
RichText::new(format!("{}.", judgement_name(mark.judgement)))
|
|
|
|
|
.color(color)
|
|
|
|
|
.strong(),
|
|
|
|
|
);
|
2026-10-18 11:45:13 +03:00
|
|
|
if mark.best_san.is_empty() {
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
return;
|
|
|
|
|
}
|
2026-10-18 11:45:13 +03:00
|
|
|
ui.label(RichText::new(tr("Best:")).weak());
|
2026-10-18 12:10:40 +03:00
|
|
|
// Short by default; grows while the line is stepped through on the board.
|
|
|
|
|
let visible = MARK_LINE_MOVES.max(shown.unwrap_or(0));
|
|
|
|
|
for (i, san) in mark.best_san.iter().enumerate().take(visible) {
|
2026-10-18 11:45:13 +03:00
|
|
|
let label = match start {
|
|
|
|
|
Some((num, turn)) => {
|
|
|
|
|
let ply = i as u32 + u32::from(turn == Color::Black);
|
|
|
|
|
let num = num + ply / 2;
|
|
|
|
|
if ply.is_multiple_of(2) {
|
|
|
|
|
format!("{num}.{san}")
|
|
|
|
|
} else if i == 0 {
|
|
|
|
|
format!("{num}…{san}")
|
|
|
|
|
} else {
|
|
|
|
|
san.clone()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
None => san.clone(),
|
|
|
|
|
};
|
Move notation: Latin letters, figurines or the interface language's letters
Settings › Board & pieces: Nf3, ♘f3 as on Lichess, or Кр Ф Л С К (German
K D T L S, French R D T F C, Spanish and Italian R D T A C; in English the
Latin letters), with a sample per option and a line of a game. Only the shown
label changes (san::show): the game, PGN, copied games, the analysis written
into a game, the reference cache and every comparison stay Latin SAN. Applied
in the move list, engine lines, the reference tab, board search and the
analysis report. The figurines are egui's chess glyphs cut out to a 4.7 KB
font, a little smaller and on the baseline. Latin remains the default.
Reviewed by the designer and the tester agents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:18:53 +03:00
|
|
|
let label = crate::san::show(&label).into_owned();
|
2026-10-18 11:45:13 +03:00
|
|
|
let text = RichText::new(label).size(14.5);
|
|
|
|
|
let current = shown == Some(i + 1);
|
|
|
|
|
let button = if current {
|
|
|
|
|
let sel = ui.visuals().selection;
|
|
|
|
|
egui::Button::new(text.color(sel.stroke.color).strong())
|
|
|
|
|
.fill(sel.bg_fill)
|
|
|
|
|
.stroke(Stroke::new(1.0, sel.stroke.color))
|
|
|
|
|
} else {
|
|
|
|
|
egui::Button::new(text).frame_when_inactive(false)
|
|
|
|
|
};
|
|
|
|
|
let resp = ui
|
|
|
|
|
.add(button)
|
|
|
|
|
.on_hover_text(tr("Show this line on the board"));
|
|
|
|
|
if current && n.scroll_to_cursor {
|
|
|
|
|
resp.scroll_to_me(Some(egui::Align::Center));
|
|
|
|
|
}
|
|
|
|
|
if resp.clicked() {
|
|
|
|
|
out.best = Some((id, i + 1));
|
|
|
|
|
}
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
}
|
2026-10-18 12:10:40 +03:00
|
|
|
if mark.best_san.len() > visible {
|
|
|
|
|
ui.label(RichText::new("…").weak());
|
|
|
|
|
}
|
Game analysis: whole-game engine review with graph, report and notation marks
- Separate background engine job over the main line (go nodes N), live engine
paused meanwhile; header button with progress/cancel, Shift+A.
- Lichess-method metrics: win %, move/game accuracy, inaccuracy/mistake/blunder,
ACPL, accuracy per game phase.
- Evaluation graph under the board, Report tab, engine badges and better lines
in the notation (preview on click), launch dialog with quality/threads/memory
and time estimate.
- Results cached in ~/.cache/chesspenguin/analysis; [%eval] read from PGN.
- Write analysis to the game as one undo step (chess-core: Game::annotate,
Game::edit_group).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 11:03:23 +03:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 14:00:19 +03:00
|
|
|
/// Colour of a move-assessment NAG ($1-$6), the Lichess palette.
|
|
|
|
|
pub fn assessment_color(nag: Nag) -> Option<Color32> {
|
|
|
|
|
Some(match nag.0 {
|
|
|
|
|
1 => Color32::from_rgb(0x62, 0x9c, 0x2e),
|
|
|
|
|
2 => Color32::from_rgb(0xe6, 0x8f, 0x00),
|
|
|
|
|
3 => Color32::from_rgb(0x22, 0xac, 0x9a),
|
|
|
|
|
4 => Color32::from_rgb(0xdf, 0x53, 0x53),
|
|
|
|
|
5 => Color32::from_rgb(0xea, 0x45, 0xd8),
|
|
|
|
|
6 => Color32::from_rgb(0x56, 0xb4, 0xe9),
|
|
|
|
|
_ => return None,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 01:54:06 +03:00
|
|
|
/// Move-assessment glyph (`!`, `?`, …) with its color, plus position assessments.
|
|
|
|
|
fn move_glyph(nags: &[Nag]) -> (String, Option<Color32>) {
|
|
|
|
|
let mut s = String::new();
|
|
|
|
|
let mut color = None;
|
|
|
|
|
for nag in nags {
|
|
|
|
|
let Some(sym) = nag.symbol() else {
|
|
|
|
|
s.push_str(&format!(" ${}", nag.0));
|
|
|
|
|
continue;
|
|
|
|
|
};
|
|
|
|
|
if nag.is_move_assessment() {
|
2026-10-18 14:00:19 +03:00
|
|
|
let Some(c) = assessment_color(*nag) else {
|
|
|
|
|
continue;
|
|
|
|
|
};
|
|
|
|
|
color = Some(c);
|
2026-10-18 01:54:06 +03:00
|
|
|
s.push_str(sym);
|
|
|
|
|
} else {
|
|
|
|
|
s.push(' ');
|
|
|
|
|
s.push_str(sym);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
(s, color)
|
|
|
|
|
}
|
|
|
|
|
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
pub fn comment_text(comments: &[String]) -> String {
|
2026-10-18 01:54:06 +03:00
|
|
|
let mut out = String::new();
|
|
|
|
|
for c in comments {
|
|
|
|
|
for part in parse_comment(c) {
|
|
|
|
|
if let CommentPart::Text(t) = part {
|
Open ChessBase databases (.cbh, .cbv) and zip/7z archives
New crate chess-import converts non-PGN sources to PGN in memory and returns
a PgnDatabase, so the library, notation and analysis work unchanged:
- .cbv archives (container rewritten after uncbv), .cbh with companion files
(layout after the public Morphy format description): games, variations,
comments with per-database code page detection, NAGs, squares/arrows, set-up
positions, time spent, book chapters (guiding texts) as move-less records;
- ChessBase figurines become piece letters, diagram/object markers handled,
Western names in Cyrillic databases read correctly;
- .zip/.7z with PGN (own encoding each), .cbh and .cbv; duplicates skipped;
- .cbz/encrypted archives and 2CBH rejected with clear messages.
Library: '+ Add database', format shown, import notes; comments keep
paragraph breaks. Tests on the user's sample books (skipped when absent).
Also: AUR PKGBUILD for 0.2.0 with the bundled Stockfish.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 13:18:27 +03:00
|
|
|
// Single line breaks are formatting, not content: reflow to the panel width.
|
|
|
|
|
// A blank line starts a new paragraph (book chapters imported from ChessBase).
|
|
|
|
|
let mut blank = false;
|
|
|
|
|
for line in t.lines() {
|
|
|
|
|
if line.trim().is_empty() {
|
|
|
|
|
blank = true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if blank && !out.is_empty() {
|
|
|
|
|
out.push_str("\n\n");
|
|
|
|
|
}
|
|
|
|
|
blank = false;
|
|
|
|
|
for word in line.split_whitespace() {
|
|
|
|
|
if !out.is_empty() && !out.ends_with('\n') {
|
|
|
|
|
out.push(' ');
|
|
|
|
|
}
|
|
|
|
|
out.push_str(word);
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
out
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn block_frame(ui: &Ui) -> egui::Frame {
|
|
|
|
|
egui::Frame::new()
|
|
|
|
|
.fill(ui.visuals().extreme_bg_color)
|
|
|
|
|
.inner_margin(egui::Margin::symmetric(10, 6))
|
|
|
|
|
.stroke(Stroke::new(
|
|
|
|
|
1.0,
|
|
|
|
|
ui.visuals().widgets.noninteractive.bg_stroke.color,
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
/// The text to show for a comment and its translation mark.
|
|
|
|
|
fn translated<'a>(n: &'a Notation, text: &'a str) -> (&'a str, Option<&'a Translated>) {
|
|
|
|
|
match n.translations.and_then(|t| t.get(text)) {
|
|
|
|
|
Some(m @ Translated::Translated(t)) => (t.as_str(), Some(m)),
|
|
|
|
|
m => (text, m),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// "⇄" (machine translation, the original in the tooltip), "⋯" (on its way), "⚠" (failed).
|
|
|
|
|
fn translation_mark(ui: &mut Ui, mark: &Translated, original: &str) {
|
|
|
|
|
let (sym, color, tip, name) = match mark {
|
|
|
|
|
Translated::Translated(_) => {
|
|
|
|
|
let mut o: String = original.chars().take(1000).collect();
|
|
|
|
|
if original.chars().count() > 1000 {
|
|
|
|
|
o.push('…');
|
|
|
|
|
}
|
|
|
|
|
(
|
|
|
|
|
"⇄",
|
|
|
|
|
ui.visuals().weak_text_color(),
|
|
|
|
|
format!("{}\n{o}", tr("Machine translation. Original:")),
|
|
|
|
|
tr("Machine translation"),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
Translated::Pending => (
|
|
|
|
|
"⋯",
|
|
|
|
|
ui.visuals().weak_text_color(),
|
|
|
|
|
tr("Translating…").to_owned(),
|
|
|
|
|
tr("Translating…"),
|
|
|
|
|
),
|
|
|
|
|
Translated::Bad => (
|
|
|
|
|
"⚠",
|
|
|
|
|
ui.visuals().warn_fg_color,
|
|
|
|
|
tr("This comment could not be translated — the original is shown. Press “Retry” in the line above the notation.").to_owned(),
|
|
|
|
|
tr("Not translated"),
|
|
|
|
|
),
|
|
|
|
|
};
|
|
|
|
|
let r =
|
|
|
|
|
ui.add(egui::Label::new(RichText::new(sym).size(13.0).color(color)).sense(Sense::hover()));
|
|
|
|
|
r.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, name));
|
|
|
|
|
r.on_hover_ui(|ui| {
|
|
|
|
|
ui.set_max_width(360.0);
|
|
|
|
|
ui.label(tip);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn comment_block(ui: &mut Ui, n: &Notation, text: &str) {
|
|
|
|
|
let (shown, mark) = translated(n, text);
|
2026-10-18 01:54:06 +03:00
|
|
|
block_frame(ui).show(ui, |ui| {
|
|
|
|
|
ui.set_width(ui.available_width());
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
match mark {
|
|
|
|
|
Some(m) => {
|
|
|
|
|
ui.horizontal_top(|ui| {
|
|
|
|
|
// A slot of its own for the mark: ⚠ is wider than ⇄.
|
|
|
|
|
let w = ui.available_width() - 16.0 - ui.spacing().item_spacing.x;
|
|
|
|
|
ui.allocate_ui_with_layout(
|
|
|
|
|
vec2(w, 0.0),
|
|
|
|
|
egui::Layout::top_down(egui::Align::Min),
|
|
|
|
|
|ui| {
|
|
|
|
|
ui.set_width(w);
|
|
|
|
|
ui.label(RichText::new(shown).color(comment_color(ui)).size(14.5));
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
ui.allocate_ui_with_layout(
|
|
|
|
|
vec2(16.0, 18.0),
|
|
|
|
|
egui::Layout::top_down(egui::Align::Center),
|
|
|
|
|
|ui| translation_mark(ui, m, text),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
None => {
|
|
|
|
|
ui.label(RichText::new(shown).color(comment_color(ui)).size(14.5));
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn unparsed_block(ui: &mut Ui, text: &str) {
|
|
|
|
|
block_frame(ui).show(ui, |ui| {
|
|
|
|
|
ui.set_width(ui.available_width());
|
|
|
|
|
ui.label(
|
|
|
|
|
RichText::new(text)
|
|
|
|
|
.monospace()
|
|
|
|
|
.color(ui.visuals().warn_fg_color),
|
|
|
|
|
)
|
|
|
|
|
.on_hover_text(tr("PGN fragment that could not be parsed; kept as is"));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn comment_color(ui: &Ui) -> Color32 {
|
|
|
|
|
if ui.visuals().dark_mode {
|
|
|
|
|
Color32::from_rgb(0x9e, 0xc4, 0xe0)
|
|
|
|
|
} else {
|
|
|
|
|
Color32::from_rgb(0x2a, 0x5b, 0x8a)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn variation_block(ui: &mut Ui, n: &Notation, start: NodeId, out: &mut NotationResponse) {
|
|
|
|
|
block_frame(ui).show(ui, |ui| {
|
|
|
|
|
ui.set_width(ui.available_width());
|
|
|
|
|
ui.horizontal_wrapped(|ui| {
|
|
|
|
|
ui.spacing_mut().item_spacing = vec2(3.0, 2.0);
|
|
|
|
|
inline_line(ui, n, start, out);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Renders a line starting at `first` (a variation move) as flowing text.
|
|
|
|
|
fn inline_line(ui: &mut Ui, n: &Notation, first: NodeId, out: &mut NotationResponse) {
|
|
|
|
|
let game = n.game;
|
|
|
|
|
let mut node = first;
|
|
|
|
|
let mut need_number = true;
|
|
|
|
|
loop {
|
|
|
|
|
let Some(nd) = game.node(node) else { return };
|
|
|
|
|
let before = comment_text(nd.comments_before());
|
|
|
|
|
if !before.is_empty() {
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
let (shown, mark) = translated(n, &before);
|
|
|
|
|
ui.label(RichText::new(shown).color(comment_color(ui)));
|
|
|
|
|
if let Some(m) = mark {
|
|
|
|
|
translation_mark(ui, m, &before);
|
|
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
need_number = true;
|
|
|
|
|
}
|
|
|
|
|
let (num, color) = game.move_number(node).unwrap_or((0, Color::White));
|
|
|
|
|
let san = game.game_move(node).map(|m| m.san.as_str()).unwrap_or("?");
|
Move notation: Latin letters, figurines or the interface language's letters
Settings › Board & pieces: Nf3, ♘f3 as on Lichess, or Кр Ф Л С К (German
K D T L S, French R D T F C, Spanish and Italian R D T A C; in English the
Latin letters), with a sample per option and a line of a game. Only the shown
label changes (san::show): the game, PGN, copied games, the analysis written
into a game, the reference cache and every comparison stay Latin SAN. Applied
in the move list, engine lines, the reference tab, board search and the
analysis report. The figurines are egui's chess glyphs cut out to a 4.7 KB
font, a little smaller and on the baseline. Latin remains the default.
Reviewed by the designer and the tester agents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:18:53 +03:00
|
|
|
let san = crate::san::show(san);
|
2026-10-18 01:54:06 +03:00
|
|
|
let (sym, sym_color) = move_glyph(nd.nags());
|
|
|
|
|
let label = match (color, need_number) {
|
|
|
|
|
(Color::White, _) => format!("{num}.{san}{sym}"),
|
|
|
|
|
(Color::Black, true) => format!("{num}…{san}{sym}"),
|
|
|
|
|
(Color::Black, false) => format!("{san}{sym}"),
|
|
|
|
|
};
|
|
|
|
|
need_number = false;
|
|
|
|
|
let current = node == n.cursor;
|
|
|
|
|
let mut text = RichText::new(label).size(15.0);
|
|
|
|
|
if let Some(c) = sym_color
|
|
|
|
|
&& !current
|
|
|
|
|
{
|
|
|
|
|
text = text.color(c);
|
|
|
|
|
}
|
|
|
|
|
// Same strong highlight as the main-line table, so the current move is visible inside text.
|
|
|
|
|
let button = if current {
|
|
|
|
|
let sel = ui.visuals().selection;
|
|
|
|
|
egui::Button::new(text.color(sel.stroke.color).strong())
|
|
|
|
|
.fill(sel.bg_fill)
|
|
|
|
|
.stroke(egui::Stroke::new(1.0, sel.stroke.color))
|
|
|
|
|
} else {
|
|
|
|
|
egui::Button::new(text).frame_when_inactive(false)
|
|
|
|
|
};
|
|
|
|
|
let resp = ui.add(button);
|
|
|
|
|
handle_move_response(ui, &resp, n, node, out);
|
|
|
|
|
|
|
|
|
|
let after = comment_text(nd.comments_after());
|
|
|
|
|
if !after.is_empty() {
|
Translation of game comments
When a game's comments are in another language, ChessPenguin offers to translate
them into the reader's: with the ChatGPT Plus/Pro subscription (Sign in with
ChatGPT: OAuth with PKCE in the browser, a loopback callback, tokens refreshed
one at a time), or an OpenAI-compatible API key (DeepSeek, OpenAI, Gemini, a
model on this computer with Ollama or LM Studio, another address). After the
first consent, games in other languages are translated as they are opened;
[Original | Translation] (Ctrl+Shift+T) switches back.
Only comment text is sent; the model gets strict instructions and a glossary,
and every answer must keep the moves and squares of the original, or the
comment stays in the original with a mark. Translations are never written to
the PGN; a cache keeps them per language. Keys and tokens live in a 0600 file
apart from the settings. Settings › Translation holds the target language,
when to translate, the connection, permissions and the cache.
Also: the monospace font and three glyphs of Noto Sans Math are text fallbacks,
so arrows and the evaluation signs ⩲ ⩱ ⌓ no longer show as boxes.
Reviewed by the designer and the tester agents (two rounds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 21:03:03 +03:00
|
|
|
let (shown, mark) = translated(n, &after);
|
|
|
|
|
ui.label(RichText::new(shown).color(comment_color(ui)));
|
|
|
|
|
if let Some(m) = mark {
|
|
|
|
|
translation_mark(ui, m, &after);
|
|
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
need_number = true;
|
|
|
|
|
}
|
|
|
|
|
for u in nd.unparsed() {
|
|
|
|
|
ui.label(
|
|
|
|
|
RichText::new(u)
|
|
|
|
|
.monospace()
|
|
|
|
|
.color(ui.visuals().warn_fg_color),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
// Alternatives to this move are printed right after it (PGN order),
|
|
|
|
|
// except for the line's own first move whose siblings belong to the outer level.
|
|
|
|
|
if node != first
|
|
|
|
|
&& let Some(parent) = game.parent(node)
|
|
|
|
|
{
|
|
|
|
|
for &v in game.variations(parent) {
|
|
|
|
|
ui.label(RichText::new("(").weak());
|
|
|
|
|
inline_line(ui, n, v, out);
|
|
|
|
|
ui.label(RichText::new(")").weak());
|
|
|
|
|
need_number = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
match game.main_child(node) {
|
|
|
|
|
Some(next) => node = next,
|
|
|
|
|
None => return,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|