Library: New game and Paste PGN beside the database actions; one «+ Game» in an empty base; the folder button under the path
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1518fc5f70
commit
863c957947
5 changed files with 65 additions and 45 deletions
|
|
@ -1633,20 +1633,12 @@ impl LargeView {
|
|||
// A database with no games yet (own-databases.md §2.3): how to put one in.
|
||||
if total == 0 && writable {
|
||||
let name = crate::own_db::base_name(path);
|
||||
// The header as for any database; nothing to search, so no field and no switch.
|
||||
// The header as for any database; nothing to search, so no field and no switch,
|
||||
// and «+ Game» once: the main button in the middle.
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(RichText::new(&name).strong());
|
||||
ui.label(RichText::new(format!("· {}", header.format)).weak());
|
||||
ui.label(format!("· {}", crate::i18n::games(0)));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if ui
|
||||
.button(tr("+ Game"))
|
||||
.on_hover_text(new_game_hint(&name))
|
||||
.clicked()
|
||||
{
|
||||
actions.push(LibraryAction::NewGameIn(path.to_path_buf()));
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.add_space(60.0);
|
||||
|
|
|
|||
|
|
@ -112,16 +112,35 @@ fn legacy_pgn(path: &Path) -> bool {
|
|||
guess.encoding != chess_core::TextEncoding::Utf8 && !guess.ascii_only
|
||||
}
|
||||
|
||||
/// The width of the shelf's buttons on the right (`Library::shelf_buttons`).
|
||||
/// The width of the game buttons and of the program's ones (`Library::game_buttons`,
|
||||
/// `Library::app_buttons`), with the gap that sets the game ones apart from the
|
||||
/// database actions.
|
||||
fn shelf_buttons_w(ui: &Ui, update: Option<&str>, icons: bool) -> f32 {
|
||||
let texts: [&str; 3] = if icons {
|
||||
["⚙", "📋", "♟"]
|
||||
} else {
|
||||
[tr("⚙ Settings"), tr("📋 Paste PGN"), tr("♟ New game")]
|
||||
};
|
||||
texts.iter().map(|t| button_w(ui, t)).sum::<f32>() + update.map_or(0.0, |v| button_w(ui, v))
|
||||
texts.iter().map(|t| button_w(ui, t)).sum::<f32>()
|
||||
+ update.map_or(0.0, |v| button_w(ui, v))
|
||||
+ GROUP_GAP
|
||||
}
|
||||
|
||||
/// A shelf button's tooltip: with icons only, its name first.
|
||||
fn shelf_hint(icons: bool, full: &str, hint: &str) -> String {
|
||||
if icons {
|
||||
format!(
|
||||
"{}\n{hint}",
|
||||
full.trim_start_matches(|c: char| !c.is_alphabetic())
|
||||
)
|
||||
} else {
|
||||
hint.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
/// Between the database actions and the game ones in the title row.
|
||||
const GROUP_GAP: f32 = 16.0;
|
||||
|
||||
/// The shelf's "+ Add database", "✚ New database" and "Online games" cards: 150 wide,
|
||||
/// wider when their label needs it (some languages say it longer).
|
||||
fn side_card_widths(ui: &Ui) -> (f32, f32, f32) {
|
||||
|
|
@ -646,29 +665,21 @@ impl Library {
|
|||
self.select_db(&p, ui.ctx());
|
||||
}
|
||||
self.shelf_actions(ui, true, actions);
|
||||
ui.add_space(GROUP_GAP - ui.spacing().item_spacing.x);
|
||||
self.game_buttons(ui, icons, actions);
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
self.shelf_buttons(ui, icons, actions);
|
||||
self.app_buttons(ui, icons, actions);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// "♟ New game · 📋 Paste PGN · ⚙ Settings" (right to left), or their icons with
|
||||
/// the names in the tooltips.
|
||||
fn shelf_buttons(&self, ui: &mut Ui, icons: bool, actions: &mut Vec<LibraryAction>) {
|
||||
/// "⚙ Settings" and the newer version (right to left): the program's corner, the
|
||||
/// same as on the game screen. Icons only, with the names in the tooltips.
|
||||
fn app_buttons(&self, ui: &mut Ui, icons: bool, actions: &mut Vec<LibraryAction>) {
|
||||
let label = |full: &'static str, icon: &'static str| if icons { icon } else { full };
|
||||
let hint = |full: &str, hint: &str| {
|
||||
if icons {
|
||||
format!(
|
||||
"{}\n{hint}",
|
||||
full.trim_start_matches(|c: char| !c.is_alphabetic())
|
||||
)
|
||||
} else {
|
||||
hint.to_owned()
|
||||
}
|
||||
};
|
||||
if ui
|
||||
.button(label(tr("⚙ Settings"), "⚙"))
|
||||
.on_hover_text(hint(tr("⚙ Settings"), "Ctrl+,"))
|
||||
.on_hover_text(shelf_hint(icons, tr("⚙ Settings"), "Ctrl+,"))
|
||||
.clicked()
|
||||
{
|
||||
actions.push(LibraryAction::OpenSettings);
|
||||
|
|
@ -678,6 +689,22 @@ impl Library {
|
|||
{
|
||||
actions.push(LibraryAction::OpenUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
/// "♟ New game · 📋 Paste PGN" after the database actions: what to put in, together.
|
||||
fn game_buttons(&self, ui: &mut Ui, icons: bool, actions: &mut Vec<LibraryAction>) {
|
||||
let label = |full: &'static str, icon: &'static str| if icons { icon } else { full };
|
||||
let hint = |full: &str, hint: &str| shelf_hint(icons, full, hint);
|
||||
if ui
|
||||
.button(label(tr("♟ New game"), "♟"))
|
||||
.on_hover_text(hint(
|
||||
tr("♟ New game"),
|
||||
tr("Empty board in the starting position (Ctrl+N)"),
|
||||
))
|
||||
.clicked()
|
||||
{
|
||||
actions.push(LibraryAction::NewGame);
|
||||
}
|
||||
if ui
|
||||
.button(label(tr("📋 Paste PGN"), "📋"))
|
||||
.on_hover_text(hint(
|
||||
|
|
@ -688,24 +715,14 @@ impl Library {
|
|||
{
|
||||
actions.push(LibraryAction::PastePgn);
|
||||
}
|
||||
if ui
|
||||
.button(label(tr("♟ New game"), "♟"))
|
||||
.on_hover_text(hint(
|
||||
tr("♟ New game"),
|
||||
tr("Empty board in the starting position (Ctrl+N)"),
|
||||
))
|
||||
.clicked()
|
||||
{
|
||||
actions.push(LibraryAction::NewGame);
|
||||
}
|
||||
}
|
||||
|
||||
fn shelf(&mut self, ui: &mut Ui, databases: &[PathBuf], actions: &mut Vec<LibraryAction>) {
|
||||
ui.add_space(8.0);
|
||||
// The title row (library-layout.md §1.4): «Databases», the actions with databases
|
||||
// on the left, the game and program ones on the right. Narrowing: the left group
|
||||
// folds to «+ ▾ 🌐» first (databases are added seldom), then the right one shows
|
||||
// icons, then the title goes.
|
||||
// The title row (library-layout.md §1.4): «Databases», then what to put in — the
|
||||
// database actions and, apart, the game ones; the program's on the right.
|
||||
// Narrowing: the database actions fold to «+ ▾ 🌐» first (databases are added
|
||||
// seldom), then the other buttons show icons, then the title goes.
|
||||
let avail = ui.available_width();
|
||||
let heading = text_w(ui, tr("Databases"), egui::TextStyle::Heading) + 16.0;
|
||||
let between = 24.0;
|
||||
|
|
@ -728,8 +745,10 @@ impl Library {
|
|||
ui.add_space(16.0 - ui.spacing().item_spacing.x);
|
||||
}
|
||||
self.shelf_actions(ui, folded, actions);
|
||||
ui.add_space(GROUP_GAP - ui.spacing().item_spacing.x);
|
||||
self.game_buttons(ui, icons, actions);
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
self.shelf_buttons(ui, icons, actions);
|
||||
self.app_buttons(ui, icons, actions);
|
||||
});
|
||||
});
|
||||
if !databases.is_empty() {
|
||||
|
|
|
|||
|
|
@ -169,10 +169,11 @@ impl NewBaseDialog {
|
|||
self.path().display().to_string()
|
||||
};
|
||||
ui.label(RichText::new(shown).weak());
|
||||
if ui.small_button(tr("Change folder…")).clicked() {
|
||||
out = Some(NewBaseOutcome::PickFolder);
|
||||
}
|
||||
});
|
||||
// On a line of its own: typing the name does not move it.
|
||||
if ui.small_button(tr("Change folder…")).clicked() {
|
||||
out = Some(NewBaseOutcome::PickFolder);
|
||||
}
|
||||
match &check {
|
||||
Err(e) if !e.is_empty() => {
|
||||
ui.label(RichText::new(e).color(ui.visuals().error_fg_color));
|
||||
|
|
|
|||
|
|
@ -391,3 +391,4 @@
|
|||
## Изменения
|
||||
|
||||
- 2026-10-25: первая версия.
|
||||
- 2026-10-25: по решению владельца «♟ Новая партия» и «📋 Вставить PGN» стоят слева, после действий с базами (через промежуток 16): слева всё, чем наполняют библиотеку; справа — только программа: «⚙ Настройки» и кнопка обновления. В пустой базе «+ Партия» одна — главная кнопка посередине (в шапке её нет). В «Новой базе» «Изменить папку…» — отдельной строкой под «Файл:».
|
||||
|
|
|
|||
|
|
@ -90,6 +90,13 @@
|
|||
- **Суть:** при вводе партии (новая партия, своя база) нужно писать текстовые комментарии к ходам прямо в программе — сейчас комментарии только читаются (и приходят из анализа).
|
||||
- **Мысли:** поле комментария под нотацией или по двойному клику/клавише у хода; запись через `Game::annotate` (уже есть, с Undo); комментарии до хода и после; NAG-символы (!, ?, ±…) той же панелью; сохранение в свою базу — Ctrl+S (задача «свои базы»).
|
||||
|
||||
### 10. Две запущенные копии программы затирают полку друг друга
|
||||
- **Статус:** новая (баг, 2026-10-25).
|
||||
- **Как нашли:** владелец создал базы «MyBase» и «mуBase2» в новой сборке, а в это время работала установленная 1.0.3. Файлы на месте (`~/Documents/ChessPenguin/`), но с полки пропали.
|
||||
- **Причина:** `Settings::save` (`apps/desktop/src/settings.rs`) пишет файл настроек целиком из памяти своей копии. Копия, загруженная раньше, при сохранении (выбор базы, выход) возвращает старый список баз и всё остальное.
|
||||
- **Варианты:** (а) одна копия программы: второй запуск поднимает окно первой (замок + сигнал; на трёх системах по-разному); (б) сохранять только изменённое: при записи перечитать файл и взять с диска поля, которые эта копия не меняла (трёхстороннее слияние по ключам JSON), а полку объединять; (в) обе копии следят за файлом и перечитывают его.
|
||||
- **Рекомендация:** (а) — проще для пользователя и убирает весь класс ошибок (ещё и общие файлы просмотренных партий, онлайн-загрузки); обсудить.
|
||||
|
||||
## Сделано
|
||||
|
||||
(пусто)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue