2026-10-23 23:39:31 +03:00
|
|
|
//! Library screen: shelf of databases (PGN, ChessBase, archives) and, for the chosen
|
|
|
|
|
//! one, the game table with its filters and position search (`large_db.rs`).
|
2026-10-18 01:54:06 +03:00
|
|
|
|
|
|
|
|
use crate::i18n::{tr, trf};
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
|
use std::sync::atomic::{AtomicBool, Ordering};
|
|
|
|
|
use std::sync::mpsc::{Receiver, channel};
|
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
|
|
2026-10-23 23:39:31 +03:00
|
|
|
use chess_core::ScanProgress;
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
use chess_import::{Database, Format, ImportError, Opened, Unsupported};
|
2026-10-23 23:39:31 +03:00
|
|
|
use egui::{RichText, Sense, Ui, vec2};
|
2026-10-18 14:00:19 +03:00
|
|
|
|
2026-10-23 23:39:31 +03:00
|
|
|
use crate::large_db::{self, Header, LargeView, OnlineButton, Pane};
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
use crate::settings::Settings;
|
2026-10-18 14:00:19 +03:00
|
|
|
use crate::viewed::{self, Viewed};
|
2026-10-18 01:54:06 +03:00
|
|
|
|
|
|
|
|
enum Slot {
|
|
|
|
|
Loading {
|
|
|
|
|
progress: Arc<Mutex<ScanProgress>>,
|
|
|
|
|
cancel: Arc<AtomicBool>,
|
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
|
|
|
rx: Receiver<Result<Opened, ImportError>>,
|
2026-10-18 01:54:06 +03:00
|
|
|
},
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
Ready(Arc<Database>),
|
2026-10-18 01:54:06 +03:00
|
|
|
Failed(String),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub enum LibraryAction {
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
/// Open a game; `at`: show the first position equal to this one.
|
|
|
|
|
OpenGame {
|
|
|
|
|
path: PathBuf,
|
|
|
|
|
index: usize,
|
|
|
|
|
at: Option<shakmaty::Chess>,
|
|
|
|
|
},
|
|
|
|
|
Sound(crate::assets::Sound),
|
|
|
|
|
CopyText(String, &'static str),
|
|
|
|
|
/// Open PGN text as a new game.
|
|
|
|
|
OpenPgn(String),
|
2026-10-18 01:54:06 +03:00
|
|
|
NewGame,
|
|
|
|
|
PastePgn,
|
|
|
|
|
AddDatabases,
|
2026-10-19 21:10:22 +03:00
|
|
|
/// The window for downloading games from Lichess and Chess.com.
|
|
|
|
|
OnlineGames,
|
|
|
|
|
/// Fetch the new games of an online database.
|
|
|
|
|
UpdateOnline(PathBuf),
|
2026-10-20 07:55:59 +03:00
|
|
|
/// The window offering a newer version.
|
|
|
|
|
OpenUpdate,
|
2026-10-18 01:54:06 +03:00
|
|
|
RemoveDatabase(PathBuf),
|
|
|
|
|
OpenSettings,
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
/// How a database was imported, and what is worth knowing about it.
|
|
|
|
|
struct ImportInfo {
|
|
|
|
|
format: Format,
|
|
|
|
|
notes: Vec<String>,
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 01:54:06 +03:00
|
|
|
pub struct Library {
|
|
|
|
|
slots: HashMap<PathBuf, Slot>,
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
/// Games the user has opened (by content).
|
2026-10-18 14:00:19 +03:00
|
|
|
viewed: Viewed,
|
2026-10-23 23:39:31 +03:00
|
|
|
/// Filters, quick search, position and game list of each database (for the session).
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
large: HashMap<PathBuf, LargeView>,
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
/// A position from a game to show once its database is open.
|
|
|
|
|
pending_position: Option<(PathBuf, shakmaty::Chess, Vec<shakmaty::Move>, bool)>,
|
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
|
|
|
info: HashMap<PathBuf, ImportInfo>,
|
|
|
|
|
/// Database whose import notes are shown.
|
|
|
|
|
notes_open: Option<PathBuf>,
|
2026-10-18 01:54:06 +03:00
|
|
|
pub selected_db: Option<PathBuf>,
|
2026-10-19 21:10:22 +03:00
|
|
|
/// Lichess or Chess.com answered at start (the online games are offered).
|
|
|
|
|
pub online: bool,
|
|
|
|
|
/// Online databases being downloaded or updated.
|
|
|
|
|
pub online_busy: Vec<PathBuf>,
|
2026-10-20 08:30:31 +03:00
|
|
|
/// Games downloaded so far while downloads run (shown on the shelf card).
|
|
|
|
|
pub online_running: Option<usize>,
|
2026-10-20 07:55:59 +03:00
|
|
|
/// A newer version to offer (its number), next to Settings.
|
|
|
|
|
pub update: Option<String>,
|
2026-10-19 23:20:37 +03:00
|
|
|
/// File sizes of databases (`file_size`).
|
|
|
|
|
sizes: HashMap<PathBuf, u64>,
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Library {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
slots: HashMap::new(),
|
2026-10-18 14:00:19 +03:00
|
|
|
viewed: Viewed::load(),
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
large: HashMap::new(),
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
pending_position: None,
|
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
|
|
|
info: HashMap::new(),
|
|
|
|
|
notes_open: None,
|
2026-10-18 01:54:06 +03:00
|
|
|
selected_db: None,
|
2026-10-19 21:10:22 +03:00
|
|
|
online: false,
|
|
|
|
|
online_busy: Vec::new(),
|
2026-10-20 08:30:31 +03:00
|
|
|
online_running: None,
|
2026-10-19 23:20:37 +03:00
|
|
|
sizes: HashMap::new(),
|
2026-10-20 07:55:59 +03:00
|
|
|
update: None,
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Starts loading `path` in the background (no-op if already loaded/loading).
|
|
|
|
|
pub fn load(&mut self, path: &Path, ctx: &egui::Context) {
|
|
|
|
|
if matches!(
|
|
|
|
|
self.slots.get(path),
|
|
|
|
|
Some(Slot::Loading { .. } | Slot::Ready(_))
|
|
|
|
|
) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let progress = Arc::new(Mutex::new(ScanProgress {
|
|
|
|
|
bytes_done: 0,
|
|
|
|
|
bytes_total: 0,
|
|
|
|
|
games: 0,
|
|
|
|
|
}));
|
|
|
|
|
let cancel = Arc::new(AtomicBool::new(false));
|
|
|
|
|
let (tx, rx) = channel();
|
|
|
|
|
let (p, c, path_owned, ctx) = (
|
|
|
|
|
progress.clone(),
|
|
|
|
|
cancel.clone(),
|
|
|
|
|
path.to_path_buf(),
|
|
|
|
|
ctx.clone(),
|
|
|
|
|
);
|
|
|
|
|
let spawned = std::thread::Builder::new()
|
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
|
|
|
.name("db-open".into())
|
2026-10-18 01:54:06 +03:00
|
|
|
.spawn(move || {
|
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
|
|
|
let res = chess_import::open(
|
2026-10-18 01:54:06 +03:00
|
|
|
&path_owned,
|
|
|
|
|
&mut |sp| {
|
|
|
|
|
if let Ok(mut g) = p.lock() {
|
|
|
|
|
*g = sp;
|
|
|
|
|
}
|
|
|
|
|
ctx.request_repaint();
|
|
|
|
|
},
|
|
|
|
|
&c,
|
|
|
|
|
);
|
2026-10-23 23:57:11 +03:00
|
|
|
// The filters' index of a PGN is built here, not on the screen's thread
|
|
|
|
|
// (a large download takes a second, §9.7).
|
|
|
|
|
if let Ok(opened) = &res
|
|
|
|
|
&& let Database::Pgn(pgn) = &opened.db
|
|
|
|
|
{
|
|
|
|
|
pgn.catalog();
|
|
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
let _ = tx.send(res);
|
|
|
|
|
ctx.request_repaint();
|
|
|
|
|
});
|
|
|
|
|
let slot = match spawned {
|
|
|
|
|
Ok(_) => Slot::Loading {
|
|
|
|
|
progress,
|
|
|
|
|
cancel,
|
|
|
|
|
rx,
|
|
|
|
|
},
|
|
|
|
|
Err(e) => Slot::Failed(e.to_string()),
|
|
|
|
|
};
|
|
|
|
|
self.slots.insert(path.to_path_buf(), slot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn select_db(&mut self, path: &Path, ctx: &egui::Context) {
|
|
|
|
|
self.load(path, ctx);
|
|
|
|
|
if self.selected_db.as_deref() != Some(path) {
|
|
|
|
|
self.selected_db = Some(path.to_path_buf());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Selects (and scrolls to) a game row, e.g. when returning from a game.
|
|
|
|
|
pub fn reveal(&mut self, path: &Path, index: usize) {
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
if let Some(view) = self.large.get_mut(path) {
|
|
|
|
|
view.reveal(index);
|
|
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
|
2026-10-19 21:10:22 +03:00
|
|
|
/// Reads a database again (its file changed), keeping it selected if it was.
|
|
|
|
|
pub fn reload(&mut self, path: &Path, ctx: &egui::Context) {
|
|
|
|
|
let selected = self.selected_db.as_deref() == Some(path);
|
2026-10-23 23:39:31 +03:00
|
|
|
// The conditions, the position, the sort and the selection stay (§9.7): the view
|
|
|
|
|
// finds its list anew once the file is read.
|
|
|
|
|
let view = self.large.remove(path);
|
2026-10-19 21:10:22 +03:00
|
|
|
self.forget(path);
|
2026-10-23 23:39:31 +03:00
|
|
|
if let Some(v) = view {
|
|
|
|
|
self.large.insert(path.to_path_buf(), v);
|
|
|
|
|
}
|
2026-10-19 21:10:22 +03:00
|
|
|
if selected {
|
|
|
|
|
self.select_db(path, ctx);
|
|
|
|
|
} else {
|
|
|
|
|
self.load(path, ctx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 01:54:06 +03:00
|
|
|
pub fn forget(&mut self, path: &Path) {
|
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
|
|
|
self.info.remove(path);
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
self.large.remove(path);
|
2026-10-18 01:54:06 +03:00
|
|
|
if let Some(Slot::Loading { cancel, .. }) = self.slots.remove(path) {
|
|
|
|
|
cancel.store(true, Ordering::Relaxed);
|
|
|
|
|
}
|
|
|
|
|
if self.selected_db.as_deref() == Some(path) {
|
|
|
|
|
self.selected_db = None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 14:00:19 +03:00
|
|
|
/// Remembers that a game was opened (shown with a check mark in the table).
|
|
|
|
|
pub fn mark_viewed(&mut self, path: &Path, index: usize) {
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
if let Some(db) = self.database(path) {
|
|
|
|
|
self.viewed.set(viewed::key(db.identity(index)), true);
|
2026-10-18 14:00:19 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 23:20:37 +03:00
|
|
|
/// Size of a database's file (cached: asked every frame by the reference tab).
|
|
|
|
|
pub fn file_size(&mut self, path: &Path) -> u64 {
|
|
|
|
|
*self
|
|
|
|
|
.sizes
|
|
|
|
|
.entry(path.to_owned())
|
|
|
|
|
.or_insert_with(|| std::fs::metadata(path).map_or(0, |m| m.len()))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Why the database could not be opened, if it could not.
|
|
|
|
|
pub fn failure(&self, path: &Path) -> Option<&str> {
|
|
|
|
|
match self.slots.get(path) {
|
|
|
|
|
Some(Slot::Failed(e)) => Some(e.as_str()),
|
|
|
|
|
_ => None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
pub fn database(&self, path: &Path) -> Option<Arc<Database>> {
|
2026-10-18 01:54:06 +03:00
|
|
|
match self.slots.get(path) {
|
|
|
|
|
Some(Slot::Ready(db)) => Some(db.clone()),
|
|
|
|
|
_ => None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-19 23:20:37 +03:00
|
|
|
/// Takes the databases that finished opening (also while a game is shown).
|
|
|
|
|
pub fn poll(&mut self) {
|
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
|
|
|
for (path, slot) in self.slots.iter_mut() {
|
2026-10-18 01:54:06 +03:00
|
|
|
if let Slot::Loading { rx, .. } = slot
|
|
|
|
|
&& let Ok(res) = rx.try_recv()
|
|
|
|
|
{
|
|
|
|
|
*slot = match res {
|
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
|
|
|
Ok(o) => {
|
2026-10-23 23:39:31 +03:00
|
|
|
// Every database has the filters and the position search.
|
|
|
|
|
match self.large.get_mut(path) {
|
|
|
|
|
Some(view) => view.reread(&o.db),
|
|
|
|
|
None => {
|
|
|
|
|
let online = crate::online::is_online(path);
|
|
|
|
|
self.large
|
|
|
|
|
.insert(path.clone(), LargeView::for_database(&o.db, online));
|
|
|
|
|
}
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
}
|
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
|
|
|
self.info.insert(
|
|
|
|
|
path.clone(),
|
|
|
|
|
ImportInfo {
|
|
|
|
|
format: o.format,
|
|
|
|
|
notes: o.notes,
|
|
|
|
|
},
|
|
|
|
|
);
|
2026-10-19 18:54:22 +03:00
|
|
|
// Position searches without a usable `.cbb` get our own
|
|
|
|
|
// booster, kept in the cache directory.
|
|
|
|
|
if let Database::ChessBase(b) = &o.db
|
|
|
|
|
&& let Some(dir) = Settings::cache_dir()
|
|
|
|
|
{
|
|
|
|
|
b.set_booster_dir(&dir.join("boosters"));
|
|
|
|
|
}
|
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
|
|
|
Slot::Ready(Arc::new(o.db))
|
|
|
|
|
}
|
|
|
|
|
Err(e) => Slot::Failed(import_error(&e)),
|
2026-10-18 01:54:06 +03:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
self.apply_pending_position();
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
/// Shows the board of the large database `path` with `line` played from `start`
|
|
|
|
|
/// (a position taken from a game). False if the database is not a large one.
|
|
|
|
|
pub fn show_position(
|
|
|
|
|
&mut self,
|
|
|
|
|
path: &Path,
|
|
|
|
|
start: shakmaty::Chess,
|
|
|
|
|
line: Vec<shakmaty::Move>,
|
|
|
|
|
flipped: bool,
|
|
|
|
|
ctx: &egui::Context,
|
|
|
|
|
) -> bool {
|
|
|
|
|
self.select_db(path, ctx);
|
|
|
|
|
self.pending_position = Some((path.to_path_buf(), start, line, flipped));
|
|
|
|
|
self.apply_pending_position();
|
|
|
|
|
true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Shows a requested position once its database is open.
|
|
|
|
|
fn apply_pending_position(&mut self) {
|
|
|
|
|
let Some((path, ..)) = &self.pending_position else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
let Some(Slot::Ready(db)) = self.slots.get(path) else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
let db = db.clone();
|
|
|
|
|
let (path, start, line, flipped) = self.pending_position.take().expect("pending");
|
2026-10-23 23:39:31 +03:00
|
|
|
let online = crate::online::is_online(&path);
|
|
|
|
|
let view = self
|
|
|
|
|
.large
|
|
|
|
|
.entry(path)
|
|
|
|
|
.or_insert_with(|| LargeView::for_database(&db, online));
|
|
|
|
|
view.show_position(start, line, flipped);
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn show(
|
|
|
|
|
&mut self,
|
|
|
|
|
ui: &mut Ui,
|
|
|
|
|
databases: &[PathBuf],
|
|
|
|
|
settings: &Settings,
|
|
|
|
|
) -> Vec<LibraryAction> {
|
2026-10-18 01:54:06 +03:00
|
|
|
self.poll();
|
|
|
|
|
let mut actions = Vec::new();
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
// With the search board open in a low window the shelf folds into one line,
|
|
|
|
|
// leaving the height to the board.
|
2026-10-23 23:39:31 +03:00
|
|
|
let board_open = self
|
|
|
|
|
.selected_db
|
|
|
|
|
.as_ref()
|
|
|
|
|
.is_some_and(|p| self.large.get(p).is_some_and(|v| v.pane() == Pane::Board));
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
let low = ui.ctx().content_rect().height() < 760.0;
|
|
|
|
|
if board_open && low {
|
|
|
|
|
egui::Panel::top("shelf_compact")
|
|
|
|
|
.show(ui, |ui| self.compact_shelf(ui, databases, &mut actions));
|
|
|
|
|
} else {
|
|
|
|
|
egui::Panel::top("shelf").show(ui, |ui| self.shelf(ui, databases, &mut actions));
|
|
|
|
|
}
|
2026-10-23 23:39:31 +03:00
|
|
|
// A database has its filter panel or its search board on the right.
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
if let Some(path) = self.selected_db.clone()
|
|
|
|
|
&& let Some(Slot::Ready(db)) = self.slots.get(&path)
|
|
|
|
|
&& let Some(view) = self.large.get_mut(&path)
|
|
|
|
|
{
|
|
|
|
|
let db = db.clone();
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
match view.pane() {
|
|
|
|
|
Pane::Filters => {
|
2026-10-24 10:12:10 +03:00
|
|
|
let r = egui::Panel::right("filters")
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
.resizable(true)
|
|
|
|
|
.default_size(280.0)
|
|
|
|
|
.size_range(260.0..=380.0)
|
|
|
|
|
.show(ui, |ui| view.panel(ui, &db));
|
2026-10-24 10:12:10 +03:00
|
|
|
crate::widgets::check_panel("filters", &r.response);
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
}
|
|
|
|
|
Pane::Board => {
|
|
|
|
|
let width = ui.available_width();
|
2026-10-24 10:12:10 +03:00
|
|
|
let r = egui::Panel::right("search_board")
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
.resizable(true)
|
|
|
|
|
.default_size((width * 0.5).max(340.0))
|
|
|
|
|
.size_range(340.0..=(width - 420.0).max(340.0))
|
|
|
|
|
.show(ui, |ui| view.board_panel(ui, &db, settings, &mut actions));
|
2026-10-24 10:12:10 +03:00
|
|
|
crate::widgets::check_panel("search_board", &r.response);
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
}
|
|
|
|
|
Pane::Hidden => {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
egui::CentralPanel::default().show(ui, |ui| self.table_area(ui, settings, &mut actions));
|
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
|
|
|
self.notes_window(ui.ctx());
|
2026-10-18 01:54:06 +03:00
|
|
|
actions
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
fn notes_window(&mut self, ctx: &egui::Context) {
|
|
|
|
|
let Some(path) = self.notes_open.clone() else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
let Some(info) = self.info.get(&path) else {
|
|
|
|
|
self.notes_open = None;
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
let mut open = true;
|
|
|
|
|
egui::Window::new(tr("Import notes"))
|
|
|
|
|
.open(&mut open)
|
|
|
|
|
.default_width(560.0)
|
|
|
|
|
.show(ctx, |ui| {
|
|
|
|
|
ui.label(
|
|
|
|
|
RichText::new(tr(
|
|
|
|
|
"Everything else was read. Games listed here are shown as far as they could be decoded.",
|
|
|
|
|
))
|
|
|
|
|
.weak(),
|
|
|
|
|
);
|
|
|
|
|
ui.add_space(4.0);
|
|
|
|
|
egui::ScrollArea::vertical().max_height(420.0).show(ui, |ui| {
|
|
|
|
|
for n in &info.notes {
|
2026-10-19 19:48:14 +03:00
|
|
|
ui.label(format!("• {n}"));
|
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
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
if !open {
|
|
|
|
|
self.notes_open = None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
/// The shelf as one line: a database picker, "+" and the usual buttons.
|
|
|
|
|
fn compact_shelf(
|
|
|
|
|
&mut self,
|
|
|
|
|
ui: &mut Ui,
|
|
|
|
|
databases: &[PathBuf],
|
|
|
|
|
actions: &mut Vec<LibraryAction>,
|
|
|
|
|
) {
|
|
|
|
|
let name = |p: &Path| {
|
|
|
|
|
p.file_stem()
|
|
|
|
|
.map(|s| s.to_string_lossy().into_owned())
|
|
|
|
|
.unwrap_or_default()
|
|
|
|
|
};
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
let current = self.selected_db.as_deref().map(name).unwrap_or_default();
|
|
|
|
|
let mut pick = None;
|
|
|
|
|
egui::ComboBox::from_id_salt("shelf_db")
|
|
|
|
|
.selected_text(format!("🗄 {current}"))
|
|
|
|
|
.width(260.0)
|
|
|
|
|
.show_ui(ui, |ui| {
|
|
|
|
|
for p in databases {
|
|
|
|
|
if ui
|
|
|
|
|
.selectable_label(self.selected_db.as_deref() == Some(p), name(p))
|
|
|
|
|
.clicked()
|
|
|
|
|
{
|
|
|
|
|
pick = Some(p.clone());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if let Some(p) = pick {
|
|
|
|
|
self.select_db(&p, ui.ctx());
|
|
|
|
|
}
|
|
|
|
|
if ui
|
|
|
|
|
.button("+")
|
|
|
|
|
.on_hover_text(tr(
|
|
|
|
|
"Open PGN, ChessBase (.cbh, .cbv) or an archive (.zip, .7z) (Ctrl+O)",
|
|
|
|
|
))
|
|
|
|
|
.clicked()
|
|
|
|
|
{
|
|
|
|
|
actions.push(LibraryAction::AddDatabases);
|
|
|
|
|
}
|
2026-10-19 21:10:22 +03:00
|
|
|
if self.online
|
|
|
|
|
&& ui
|
|
|
|
|
.button("🌐")
|
2026-10-20 08:30:31 +03:00
|
|
|
.on_hover_text(tr("Download any player's games by nickname into a database: yours, a pupil's, an opponent's"))
|
2026-10-19 21:10:22 +03:00
|
|
|
.clicked()
|
|
|
|
|
{
|
|
|
|
|
actions.push(LibraryAction::OnlineGames);
|
|
|
|
|
}
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
|
|
|
|
if ui.button(tr("⚙ Settings")).clicked() {
|
|
|
|
|
actions.push(LibraryAction::OpenSettings);
|
|
|
|
|
}
|
2026-10-20 07:55:59 +03:00
|
|
|
if let Some(v) = &self.update
|
|
|
|
|
&& crate::widgets::update_button(ui, v).clicked()
|
|
|
|
|
{
|
|
|
|
|
actions.push(LibraryAction::OpenUpdate);
|
|
|
|
|
}
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
if ui.button(tr("📋 Paste PGN")).clicked() {
|
|
|
|
|
actions.push(LibraryAction::PastePgn);
|
|
|
|
|
}
|
|
|
|
|
if ui.button(tr("♟ New game")).clicked() {
|
|
|
|
|
actions.push(LibraryAction::NewGame);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 01:54:06 +03:00
|
|
|
fn shelf(&mut self, ui: &mut Ui, databases: &[PathBuf], actions: &mut Vec<LibraryAction>) {
|
|
|
|
|
ui.add_space(8.0);
|
|
|
|
|
ui.horizontal(|ui| {
|
|
|
|
|
ui.heading(tr("Databases"));
|
|
|
|
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
|
|
|
|
if ui.button(tr("⚙ Settings")).clicked() {
|
|
|
|
|
actions.push(LibraryAction::OpenSettings);
|
|
|
|
|
}
|
2026-10-20 07:55:59 +03:00
|
|
|
if let Some(v) = &self.update
|
|
|
|
|
&& crate::widgets::update_button(ui, v).clicked()
|
|
|
|
|
{
|
|
|
|
|
actions.push(LibraryAction::OpenUpdate);
|
|
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
if ui
|
|
|
|
|
.button(tr("📋 Paste PGN"))
|
|
|
|
|
.on_hover_text(tr("Open a game from the clipboard"))
|
|
|
|
|
.clicked()
|
|
|
|
|
{
|
|
|
|
|
actions.push(LibraryAction::PastePgn);
|
|
|
|
|
}
|
|
|
|
|
if ui
|
|
|
|
|
.button(tr("♟ New game"))
|
|
|
|
|
.on_hover_text(tr("Empty board in the starting position (Ctrl+N)"))
|
|
|
|
|
.clicked()
|
|
|
|
|
{
|
|
|
|
|
actions.push(LibraryAction::NewGame);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
ui.add_space(4.0);
|
|
|
|
|
ui.horizontal_wrapped(|ui| {
|
|
|
|
|
ui.spacing_mut().item_spacing = vec2(8.0, 8.0);
|
|
|
|
|
for path in databases {
|
|
|
|
|
self.db_card(ui, path, actions);
|
|
|
|
|
}
|
|
|
|
|
let (rect, resp) = ui.allocate_exact_size(vec2(150.0, 64.0), Sense::click());
|
|
|
|
|
let visuals = ui.style().interact(&resp);
|
|
|
|
|
ui.painter()
|
|
|
|
|
.rect_stroke(rect, 6.0, visuals.fg_stroke, egui::StrokeKind::Inside);
|
|
|
|
|
ui.painter().text(
|
|
|
|
|
rect.center(),
|
|
|
|
|
egui::Align2::CENTER_CENTER,
|
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
|
|
|
tr("+ Add database"),
|
2026-10-18 01:54:06 +03:00
|
|
|
egui::FontId::proportional(15.0),
|
|
|
|
|
visuals.text_color(),
|
|
|
|
|
);
|
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
|
|
|
if resp
|
|
|
|
|
.on_hover_text(tr(
|
|
|
|
|
"Open PGN, ChessBase (.cbh, .cbv) or an archive (.zip, .7z) (Ctrl+O)",
|
|
|
|
|
))
|
|
|
|
|
.clicked()
|
|
|
|
|
{
|
2026-10-18 01:54:06 +03:00
|
|
|
actions.push(LibraryAction::AddDatabases);
|
|
|
|
|
}
|
2026-10-19 21:10:22 +03:00
|
|
|
if self.online {
|
|
|
|
|
let (rect, resp) = ui.allocate_exact_size(vec2(150.0, 64.0), Sense::click());
|
|
|
|
|
let visuals = ui.style().interact(&resp);
|
|
|
|
|
ui.painter()
|
|
|
|
|
.rect_stroke(rect, 6.0, visuals.fg_stroke, egui::StrokeKind::Inside);
|
2026-10-20 08:30:31 +03:00
|
|
|
let below = match self.online_running {
|
2026-10-20 08:50:18 +03:00
|
|
|
Some(n) => trf("downloading… {n}", &[("n", &crate::i18n::games(n))]),
|
2026-10-20 08:30:31 +03:00
|
|
|
None => "Lichess · Chess.com".to_owned(),
|
|
|
|
|
};
|
|
|
|
|
ui.painter().text(
|
|
|
|
|
rect.center() + vec2(0.0, -9.0),
|
|
|
|
|
egui::Align2::CENTER_CENTER,
|
|
|
|
|
format!("🌐 {}", tr("Online games")),
|
|
|
|
|
egui::FontId::proportional(15.0),
|
|
|
|
|
visuals.text_color(),
|
|
|
|
|
);
|
|
|
|
|
ui.painter().text(
|
|
|
|
|
rect.center() + vec2(0.0, 11.0),
|
|
|
|
|
egui::Align2::CENTER_CENTER,
|
|
|
|
|
below,
|
|
|
|
|
egui::FontId::proportional(13.0),
|
|
|
|
|
ui.visuals().weak_text_color(),
|
|
|
|
|
);
|
2026-10-19 21:10:22 +03:00
|
|
|
if resp
|
2026-10-20 08:30:31 +03:00
|
|
|
.on_hover_text(tr("Download any player's games by nickname into a database: yours, a pupil's, an opponent's"))
|
2026-10-19 21:10:22 +03:00
|
|
|
.clicked()
|
|
|
|
|
{
|
|
|
|
|
actions.push(LibraryAction::OnlineGames);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
});
|
|
|
|
|
ui.add_space(8.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn db_card(&mut self, ui: &mut Ui, path: &Path, actions: &mut Vec<LibraryAction>) {
|
|
|
|
|
let selected = self.selected_db.as_deref() == Some(path);
|
|
|
|
|
let name = path
|
|
|
|
|
.file_stem()
|
|
|
|
|
.map(|s| s.to_string_lossy().into_owned())
|
|
|
|
|
.unwrap_or_default();
|
|
|
|
|
let detail = match self.slots.get(path) {
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
Some(Slot::Ready(db)) => match db.as_chessbase() {
|
|
|
|
|
Some(b) => format!(
|
|
|
|
|
"{} · 🔒",
|
|
|
|
|
trf(
|
|
|
|
|
"{n} games",
|
|
|
|
|
&[("n", &large_db::short_count(b.games() + b.texts()))],
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
None => trf("{n} games", &[("n", &db.len())]),
|
|
|
|
|
},
|
2026-10-18 01:54:06 +03:00
|
|
|
Some(Slot::Loading { progress, .. }) => {
|
|
|
|
|
let p = progress.lock().map(|g| *g).unwrap_or(ScanProgress {
|
|
|
|
|
bytes_done: 0,
|
|
|
|
|
bytes_total: 0,
|
|
|
|
|
games: 0,
|
|
|
|
|
});
|
|
|
|
|
trf("loading… {n}", &[("n", &p.games)])
|
|
|
|
|
}
|
|
|
|
|
Some(Slot::Failed(_)) => tr("error").into(),
|
|
|
|
|
None if !path.exists() => tr("file not found").into(),
|
|
|
|
|
None => tr("not loaded").into(),
|
|
|
|
|
};
|
|
|
|
|
let (rect, resp) = ui.allocate_exact_size(vec2(190.0, 64.0), Sense::click());
|
|
|
|
|
let v = ui.visuals();
|
|
|
|
|
let fill = if selected {
|
|
|
|
|
v.selection.bg_fill
|
|
|
|
|
} else if resp.hovered() {
|
|
|
|
|
v.widgets.hovered.weak_bg_fill
|
|
|
|
|
} else {
|
|
|
|
|
v.faint_bg_color
|
|
|
|
|
};
|
|
|
|
|
ui.painter().rect_filled(rect, 6.0, fill);
|
|
|
|
|
let text_color = if selected {
|
|
|
|
|
v.selection.stroke.color
|
|
|
|
|
} else {
|
|
|
|
|
v.text_color()
|
|
|
|
|
};
|
|
|
|
|
ui.painter().text(
|
|
|
|
|
rect.left_top() + vec2(12.0, 10.0),
|
|
|
|
|
egui::Align2::LEFT_TOP,
|
2026-10-20 08:30:31 +03:00
|
|
|
if crate::online::is_online(path) {
|
|
|
|
|
"🌐"
|
|
|
|
|
} else {
|
|
|
|
|
"🗄"
|
|
|
|
|
},
|
2026-10-18 01:54:06 +03:00
|
|
|
egui::FontId::proportional(22.0),
|
|
|
|
|
text_color,
|
|
|
|
|
);
|
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
|
|
|
// Long names (book titles) are cut to two lines so the detail line stays readable.
|
|
|
|
|
let mut job = egui::text::LayoutJob::simple(
|
2026-10-18 01:54:06 +03:00
|
|
|
name,
|
|
|
|
|
egui::FontId::proportional(14.0),
|
|
|
|
|
text_color,
|
|
|
|
|
rect.width() - 52.0,
|
|
|
|
|
);
|
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
|
|
|
job.wrap.max_rows = 2;
|
|
|
|
|
job.wrap.break_anywhere = false;
|
|
|
|
|
job.wrap.overflow_character = Some('…');
|
|
|
|
|
let galley = ui.fonts_mut(|f| f.layout_job(job));
|
2026-10-18 01:54:06 +03:00
|
|
|
ui.painter()
|
|
|
|
|
.galley(rect.left_top() + vec2(44.0, 9.0), galley, text_color);
|
|
|
|
|
ui.painter().text(
|
|
|
|
|
rect.left_bottom() + vec2(44.0, -8.0),
|
|
|
|
|
egui::Align2::LEFT_BOTTOM,
|
|
|
|
|
detail,
|
|
|
|
|
egui::FontId::proportional(12.0),
|
|
|
|
|
v.weak_text_color(),
|
|
|
|
|
);
|
|
|
|
|
let resp = resp.on_hover_text(path.display().to_string());
|
|
|
|
|
if resp.clicked() {
|
|
|
|
|
self.select_db(path, ui.ctx());
|
|
|
|
|
}
|
|
|
|
|
resp.context_menu(|ui| {
|
|
|
|
|
if ui.button(tr("Remove from list")).clicked() {
|
|
|
|
|
actions.push(LibraryAction::RemoveDatabase(path.to_path_buf()));
|
|
|
|
|
ui.close();
|
|
|
|
|
}
|
|
|
|
|
if ui.button(tr("Reload file")).clicked() {
|
|
|
|
|
self.slots.remove(path);
|
|
|
|
|
self.load(path, ui.ctx());
|
|
|
|
|
ui.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
fn table_area(&mut self, ui: &mut Ui, settings: &Settings, actions: &mut Vec<LibraryAction>) {
|
2026-10-18 01:54:06 +03:00
|
|
|
let Some(path) = self.selected_db.clone() else {
|
|
|
|
|
ui.centered_and_justified(|ui| {
|
|
|
|
|
ui.label(
|
|
|
|
|
RichText::new(tr(
|
|
|
|
|
"Choose a database above, add a PGN file or start a new game",
|
|
|
|
|
))
|
|
|
|
|
.weak()
|
|
|
|
|
.size(16.0),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
let db = match self.slots.get(&path) {
|
|
|
|
|
Some(Slot::Ready(db)) => db.clone(),
|
|
|
|
|
Some(Slot::Loading {
|
|
|
|
|
progress, cancel, ..
|
|
|
|
|
}) => {
|
|
|
|
|
let p = progress.lock().map(|g| *g).unwrap_or(ScanProgress {
|
|
|
|
|
bytes_done: 0,
|
|
|
|
|
bytes_total: 0,
|
|
|
|
|
games: 0,
|
|
|
|
|
});
|
|
|
|
|
let frac = if p.bytes_total > 0 {
|
|
|
|
|
p.bytes_done as f32 / p.bytes_total as f32
|
|
|
|
|
} else {
|
|
|
|
|
0.0
|
|
|
|
|
};
|
|
|
|
|
let cancel = cancel.clone();
|
|
|
|
|
ui.vertical_centered(|ui| {
|
|
|
|
|
ui.add_space(40.0);
|
|
|
|
|
ui.label(trf(
|
|
|
|
|
"Reading {path} — games found: {n}",
|
|
|
|
|
&[("path", &path.display()), ("n", &p.games)],
|
|
|
|
|
));
|
|
|
|
|
ui.add(egui::ProgressBar::new(frac).desired_width(400.0));
|
|
|
|
|
if ui.button(tr("Cancel")).clicked() {
|
|
|
|
|
cancel.store(true, Ordering::Relaxed);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Some(Slot::Failed(e)) => {
|
|
|
|
|
let e = e.clone();
|
|
|
|
|
ui.vertical_centered(|ui| {
|
|
|
|
|
ui.add_space(40.0);
|
|
|
|
|
ui.label(
|
|
|
|
|
RichText::new(trf(
|
|
|
|
|
"Could not open {path}: {e}",
|
|
|
|
|
&[("path", &path.display()), ("e", &e)],
|
|
|
|
|
))
|
|
|
|
|
.color(ui.visuals().error_fg_color),
|
|
|
|
|
);
|
|
|
|
|
if ui.button(tr("Retry")).clicked() {
|
|
|
|
|
self.slots.remove(&path);
|
|
|
|
|
self.load(&path, ui.ctx());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
None => {
|
|
|
|
|
self.load(&path, ui.ctx());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-10-23 23:39:31 +03:00
|
|
|
let online = crate::online::is_online(&path);
|
|
|
|
|
let header = self.header(&path, &db, online);
|
|
|
|
|
let view = self
|
|
|
|
|
.large
|
|
|
|
|
.entry(path.clone())
|
|
|
|
|
.or_insert_with(|| LargeView::for_database(&db, online));
|
|
|
|
|
let notes = self.info.get(&path).map_or(0, |i| i.notes.len());
|
|
|
|
|
if view.table(
|
|
|
|
|
ui,
|
|
|
|
|
&path,
|
|
|
|
|
&db,
|
|
|
|
|
&header,
|
|
|
|
|
&mut self.viewed,
|
|
|
|
|
notes,
|
|
|
|
|
settings,
|
|
|
|
|
actions,
|
|
|
|
|
) {
|
|
|
|
|
self.notes_open = Some(path.clone());
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
}
|
2026-10-23 23:39:31 +03:00
|
|
|
}
|
2026-10-18 01:54:06 +03:00
|
|
|
|
2026-10-23 23:39:31 +03:00
|
|
|
/// What the header says about a database: its format, and for one downloaded from
|
|
|
|
|
/// Lichess and Chess.com, its "⟳ New games".
|
|
|
|
|
fn header(&self, path: &Path, db: &Database, online: bool) -> Header {
|
|
|
|
|
let (format, format_hint) = match (db, self.info.get(path)) {
|
|
|
|
|
(Database::ChessBase(_), _) => (
|
|
|
|
|
tr("ChessBase, read-only").to_string(),
|
|
|
|
|
tr("Read in place; the original files are not changed. Save a game to keep your edits.").to_string(),
|
|
|
|
|
),
|
|
|
|
|
(Database::Pgn(_), Some(info)) if info.format != Format::Pgn => (
|
|
|
|
|
trf("{format}, read-only", &[("format", &info.format.label())]),
|
|
|
|
|
tr("Converted to PGN when opened; the original files are not changed. Save a game to keep your edits.").to_string(),
|
|
|
|
|
),
|
|
|
|
|
(Database::Pgn(pgn), _) => (
|
|
|
|
|
trf("PGN, encoding {enc}", &[("enc", &pgn.encoding().label())]),
|
|
|
|
|
String::new(),
|
|
|
|
|
),
|
ChessPenguin 0.5.0: find games by position on a board
The "Board" pane next to the game list (Ctrl+B): moves played on it filter
the list to the games that reach the position by any move order, together
with the filters; the moves played next are listed with games, a results
bar, average rating and last year. Games reached by another order are
marked and "only this order" narrows the list; strongest games first.
A game opens at the found position; "Find in database" (Ctrl+Shift+F)
searches the position of the game on screen.
Large ChessBase databases: a fast main-line walk (moves built from the
board), pruning by material and pawns, the .cbb search booster when valid;
Mega Database: 0.4 s for the starting position, under 0.1 s deeper.
PGN databases and books: positions of all games, variations included,
kept in memory once built.
Also: × to clear filter and search fields; "Open as a new game" opens at
the last move; the "Moves" column is now "Length".
Docs: decision 13, design (docs/design/board-search.md), research
(position-search, position-index), dev notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 08:42:08 +03:00
|
|
|
};
|
2026-10-23 23:39:31 +03:00
|
|
|
let online = online.then(|| {
|
|
|
|
|
let when = crate::online::State::load(path)
|
|
|
|
|
.and_then(|s| s.updated)
|
|
|
|
|
.map(crate::online::ago);
|
|
|
|
|
let hint = if !self.online {
|
|
|
|
|
tr("No connection to Lichess and Chess.com").to_owned()
|
|
|
|
|
} else if let Some(w) = when {
|
|
|
|
|
trf(
|
|
|
|
|
"Fetch the games played since the last download ({when})",
|
|
|
|
|
&[("when", &w)],
|
2026-10-18 01:54:06 +03:00
|
|
|
)
|
|
|
|
|
} else {
|
2026-10-23 23:39:31 +03:00
|
|
|
tr("Fetch the games played since the last download").to_owned()
|
2026-10-18 01:54:06 +03:00
|
|
|
};
|
2026-10-23 23:39:31 +03:00
|
|
|
OnlineButton {
|
|
|
|
|
busy: self.online_busy.contains(&path.to_path_buf()),
|
|
|
|
|
enabled: self.online,
|
|
|
|
|
hint,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Header {
|
|
|
|
|
format,
|
|
|
|
|
format_hint,
|
|
|
|
|
online,
|
2026-10-18 01:54:06 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// "2010.??.??" → "2010", "1997.05.??" → "05.1997", full dates as "dd.mm.yyyy".
|
ChessPenguin 0.4.0: large ChessBase databases with a filter panel
Mega Database (11.7 million games) opens in under a second: a .cbh with
20,000 records or more is read in place, a game is converted to PGN when
opened. Filter panel on the right (player with suggestions, colour,
opponent, tournament, annotator, years, Elo rule, result, ECO, moves,
comments, variations), applied live in the background with cancellation.
Fixes: a ChessBase game unreadable from its first move (Chess960) crashed
the import; databases mixing UTF-8 and single-byte texts were decoded as
Cyrillic.
Docs: decision 12, design (docs/design/large-databases.md), format research
and acceptance criteria, QA report 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 01:02:36 +03:00
|
|
|
pub fn display_date(raw: &str) -> String {
|
2026-10-23 23:39:31 +03:00
|
|
|
let parts: Vec<&str> = raw.split(['.', '-', '/']).collect();
|
2026-10-18 01:54:06 +03:00
|
|
|
let known = |s: &&str| !s.is_empty() && s.chars().all(|c| c.is_ascii_digit());
|
|
|
|
|
match parts.as_slice() {
|
|
|
|
|
[y, m, d] if known(y) && known(m) && known(d) => format!("{d}.{m}.{y}"),
|
|
|
|
|
[y, m, _] if known(y) && known(m) => format!("{m}.{y}"),
|
|
|
|
|
[y, ..] if known(y) => (*y).to_string(),
|
|
|
|
|
_ => String::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
/// User-facing text of an import failure.
|
|
|
|
|
fn import_error(e: &ImportError) -> String {
|
|
|
|
|
match e {
|
|
|
|
|
ImportError::Cancelled => tr("Loading cancelled").into(),
|
|
|
|
|
ImportError::Empty => tr("No PGN or ChessBase database in the archive").into(),
|
|
|
|
|
ImportError::Unsupported(Unsupported::Encrypted) => {
|
|
|
|
|
tr("Password-protected archives (.cbz, encrypted zip/7z) are not supported").into()
|
|
|
|
|
}
|
|
|
|
|
ImportError::Unsupported(Unsupported::ChessBase2) => tr(
|
|
|
|
|
"The ChessBase 2CBH format is not supported: export the database from ChessBase as CBH or PGN",
|
|
|
|
|
)
|
|
|
|
|
.into(),
|
|
|
|
|
e => e.to_string(),
|
|
|
|
|
}
|
|
|
|
|
}
|