Web version: what the browser lacks is not offered, files dropped on the window, checks, docs
The interface hides what the platform does not have (platform::CAPS): play, new databases, adding to a database, preparation, translation, their shortcuts and the Translation tab. Files dropped on the window open like chosen ones (in a browser; the desktop program takes no drops, as before), with «Release to open» while they are dragged over it. /app/: ?phone=android and ?phone=ios show those variants of the device page. apps/web/check: device.test.mjs (14 devices: computer, iPhone, iPad as a Mac, Android phone and tablet, desktop-site modes, Chromebook, touch laptop) and app.mjs (headless Firefox: the device page in three languages without the program, the program, a PGN opened by Ctrl+O and the file chooser, a dropped PGN, a game of the classics, moves, «Download PGN», e2-e4 on the board, the settings after a reload). All pass. docs/dev/web.md: the architecture, the platform layer, what is not built for a browser, the build and the checks, what comes next; docs/dev/uci.md and desktop.md updated, web/README.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3e69a5d57c
commit
30eac472ff
13 changed files with 501 additions and 32 deletions
|
|
@ -2730,6 +2730,35 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
/// Files dropped on the window open as databases, like chosen ones; while files are
|
||||
/// dragged over it, the window says so.
|
||||
fn dropped_files(&mut self, ctx: &egui::Context) {
|
||||
let (tx, waker) = (self.tx.clone(), ctx.clone());
|
||||
crate::platform::files::take_dropped(ctx, move |paths| {
|
||||
if !paths.is_empty() {
|
||||
let _ = tx.send(Async::DatabasesPicked(paths));
|
||||
}
|
||||
waker.request_repaint();
|
||||
});
|
||||
if crate::platform::files::dragging(ctx) {
|
||||
let rect = ctx.content_rect();
|
||||
let painter = ctx.layer_painter(egui::LayerId::new(
|
||||
egui::Order::Foreground,
|
||||
egui::Id::new("dropping files"),
|
||||
));
|
||||
let visuals = ctx.global_style().visuals.clone();
|
||||
let accent = visuals.selection.bg_fill;
|
||||
painter.rect_filled(rect, 0.0, accent.gamma_multiply(0.12));
|
||||
painter.text(
|
||||
rect.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
tr("Release to open"),
|
||||
egui::FontId::proportional(22.0),
|
||||
visuals.strong_text_color(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The open game's PGN, downloaded as a file named after the game.
|
||||
#[cfg(web)]
|
||||
fn download_pgn(&mut self, ctx: &egui::Context) {
|
||||
|
|
@ -3065,6 +3094,7 @@ impl eframe::App for App {
|
|||
ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose);
|
||||
self.confirm_close = Some(CloseIntent::QuitApp);
|
||||
}
|
||||
self.dropped_files(&ctx);
|
||||
self.handle_async(&ctx);
|
||||
// Dev hook (screenshots): the engine offer as on pressing L without an engine.
|
||||
if std::env::var("CP_ENGINE_OFFER").is_ok() && !self.offer_hook_done {
|
||||
|
|
@ -3091,13 +3121,17 @@ impl eframe::App for App {
|
|||
Key::N,
|
||||
))
|
||||
}) && self.game.is_none()
|
||||
&& crate::platform::CAPS.own_databases
|
||||
{
|
||||
self.own.then_close = None;
|
||||
self.new_base_dialog(own_db::AfterCreate::Shelf);
|
||||
}
|
||||
// In the library a game from the start; on a game's screen the game plays on
|
||||
// from its position (the game view takes Ctrl+G there).
|
||||
if self.game.is_none() && ctx.input_mut(|i| i.consume_shortcut(&ctrl(Key::G))) {
|
||||
if self.game.is_none()
|
||||
&& crate::platform::CAPS.play
|
||||
&& ctx.input_mut(|i| i.consume_shortcut(&ctrl(Key::G)))
|
||||
{
|
||||
self.play_new(&ctx, PlayNext::Dialog(None));
|
||||
}
|
||||
if ctx.input_mut(|i| i.consume_shortcut(&ctrl(Key::N))) && self.game.is_none() {
|
||||
|
|
|
|||
|
|
@ -1959,7 +1959,9 @@ impl GameView {
|
|||
actions.push(GameAction::Save);
|
||||
ui.close();
|
||||
}
|
||||
if ui.button(tr("Add to database… (Ctrl+Shift+S)")).clicked() {
|
||||
if crate::platform::CAPS.own_databases
|
||||
&& ui.button(tr("Add to database… (Ctrl+Shift+S)")).clicked()
|
||||
{
|
||||
actions.push(GameAction::AddToDatabase);
|
||||
ui.close();
|
||||
}
|
||||
|
|
@ -1987,7 +1989,7 @@ impl GameView {
|
|||
self.paste_clipboard(ui.ctx());
|
||||
ui.close();
|
||||
}
|
||||
if self.play.is_none() {
|
||||
if self.play.is_none() && crate::platform::CAPS.play {
|
||||
ui.separator();
|
||||
if ui.button(tr("Play on from here… (Ctrl+G)")).clicked() {
|
||||
let at = self.cursor;
|
||||
|
|
@ -2017,7 +2019,9 @@ impl GameView {
|
|||
ui.close();
|
||||
}
|
||||
ui.separator();
|
||||
if self.translation.can_translate() && ui.button(tr("Translate comments")).clicked()
|
||||
if crate::platform::CAPS.translation
|
||||
&& self.translation.can_translate()
|
||||
&& ui.button(tr("Translate comments")).clicked()
|
||||
{
|
||||
self.translate_now = true;
|
||||
self.side_tab = SideTab::Notation;
|
||||
|
|
@ -4832,11 +4836,13 @@ impl GameView {
|
|||
}
|
||||
"copy" => actions.push(self.copy_pgn()),
|
||||
"save" => actions.push(GameAction::Save),
|
||||
"play_from" => {
|
||||
"play_from" if crate::platform::CAPS.play => {
|
||||
let at = self.cursor;
|
||||
self.play_from(at, actions);
|
||||
}
|
||||
"add_to_db" => actions.push(GameAction::AddToDatabase),
|
||||
"add_to_db" if crate::platform::CAPS.own_databases => {
|
||||
actions.push(GameAction::AddToDatabase)
|
||||
}
|
||||
"game_data" => actions.push(GameAction::EditGameData),
|
||||
"back" => actions.push(GameAction::BackKey),
|
||||
"find" if self.search_line().is_some() => {
|
||||
|
|
@ -4864,7 +4870,7 @@ impl GameView {
|
|||
self.goto(end);
|
||||
}
|
||||
"flip" => self.flipped = !self.flipped,
|
||||
"translate" => {
|
||||
"translate" if crate::platform::CAPS.translation => {
|
||||
if self.translation.has_translation() {
|
||||
self.translation.toggle();
|
||||
} else if self.translation.can_translate() {
|
||||
|
|
|
|||
|
|
@ -217,6 +217,17 @@ pub fn trf(key: &'static str, args: &[(&str, &dyn Display)]) -> String {
|
|||
// Uzbek o‘ and g‘ are written with ‘ (U+2018): the interface font has no U+02BB.
|
||||
const ROWS: &[[&str; 9]] = &[
|
||||
// --- the web version ---
|
||||
[
|
||||
"Release to open",
|
||||
"Отпустите, чтобы открыть",
|
||||
"Relâchez pour ouvrir",
|
||||
"Zum Öffnen loslassen",
|
||||
"Suelta para abrir",
|
||||
"Rilascia per aprire",
|
||||
"Solte para abrir",
|
||||
"Ochish uchun qo‘yib yuboring",
|
||||
"Ашу үшін жіберіңіз",
|
||||
],
|
||||
[
|
||||
"⇩ Download PGN",
|
||||
"⇩ Скачать PGN",
|
||||
|
|
|
|||
|
|
@ -136,9 +136,14 @@ fn shelf_buttons_w(ui: &Ui, update: Option<&str>, icons: bool) -> f32 {
|
|||
tr("♞ Play"),
|
||||
]
|
||||
};
|
||||
texts.iter().map(|t| button_w(ui, t)).sum::<f32>()
|
||||
let play = crate::platform::CAPS.play;
|
||||
let groups = if play { 2.0 } else { 1.0 };
|
||||
texts[..if play { 4 } else { 3 }]
|
||||
.iter()
|
||||
.map(|t| button_w(ui, t))
|
||||
.sum::<f32>()
|
||||
+ update.map_or(0.0, |v| button_w(ui, v))
|
||||
+ 2.0 * GROUP_GAP
|
||||
+ groups * GROUP_GAP
|
||||
}
|
||||
|
||||
/// A shelf button's tooltip: with icons only, its name first.
|
||||
|
|
@ -636,6 +641,7 @@ impl Library {
|
|||
if let Some(path) = self.selected_db.clone()
|
||||
&& let Some(view) = self.large.get_mut(&path)
|
||||
&& let Some(entry) = view.prepare.take()
|
||||
&& crate::platform::CAPS.prep
|
||||
{
|
||||
actions.push(LibraryAction::PrepareAgainst { path, entry });
|
||||
}
|
||||
|
|
@ -771,8 +777,10 @@ impl Library {
|
|||
self.shelf_actions(ui, folded, actions);
|
||||
ui.separator();
|
||||
self.game_buttons(ui, icons, actions);
|
||||
ui.separator();
|
||||
self.play_button(ui, icons, actions);
|
||||
if crate::platform::CAPS.play {
|
||||
ui.separator();
|
||||
self.play_button(ui, icons, actions);
|
||||
}
|
||||
}
|
||||
|
||||
/// "♞ Play": a game against Maia, a group of its own.
|
||||
|
|
@ -933,10 +941,11 @@ impl Library {
|
|||
actions.push(LibraryAction::AddDatabases);
|
||||
ui.close();
|
||||
}
|
||||
if ui
|
||||
.button(tr("New database…"))
|
||||
.on_hover_text(new_hint)
|
||||
.clicked()
|
||||
if crate::platform::CAPS.own_databases
|
||||
&& ui
|
||||
.button(tr("New database…"))
|
||||
.on_hover_text(new_hint)
|
||||
.clicked()
|
||||
{
|
||||
actions.push(LibraryAction::NewDatabase);
|
||||
ui.close();
|
||||
|
|
@ -950,10 +959,11 @@ impl Library {
|
|||
{
|
||||
actions.push(LibraryAction::AddDatabases);
|
||||
}
|
||||
if ui
|
||||
.button(tr("✚ New database"))
|
||||
.on_hover_text(new_hint)
|
||||
.clicked()
|
||||
if crate::platform::CAPS.own_databases
|
||||
&& ui
|
||||
.button(tr("✚ New database"))
|
||||
.on_hover_text(new_hint)
|
||||
.clicked()
|
||||
{
|
||||
actions.push(LibraryAction::NewDatabase);
|
||||
}
|
||||
|
|
@ -1027,9 +1037,10 @@ impl Library {
|
|||
{
|
||||
actions.push(LibraryAction::AddDatabases);
|
||||
}
|
||||
if card(ui, new_w, tr("✚ New database"), None)
|
||||
.on_hover_text(tr("An empty PGN file for your own games (Ctrl+Shift+N)"))
|
||||
.clicked()
|
||||
if crate::platform::CAPS.own_databases
|
||||
&& card(ui, new_w, tr("✚ New database"), None)
|
||||
.on_hover_text(tr("An empty PGN file for your own games (Ctrl+Shift+N)"))
|
||||
.clicked()
|
||||
{
|
||||
actions.push(LibraryAction::NewDatabase);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -445,6 +445,10 @@ fn handle_move_response(
|
|||
out.context = Some((id, NotationCommand::Delete));
|
||||
ui.close();
|
||||
}
|
||||
// Games against the computer and the trainer: not in every version.
|
||||
if !crate::platform::CAPS.play {
|
||||
return;
|
||||
}
|
||||
ui.separator();
|
||||
// A finished position has nothing to play.
|
||||
let over = n.game.position(id).and_then(|p| {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,9 @@ impl SettingsWindow {
|
|||
ui.selectable_value(&mut self.tab, Tab::Board, tr("Board & pieces"));
|
||||
ui.selectable_value(&mut self.tab, Tab::Sound, tr("Sound"));
|
||||
ui.selectable_value(&mut self.tab, Tab::Interface, tr("Interface"));
|
||||
ui.selectable_value(&mut self.tab, Tab::Translation, tr("Translation"));
|
||||
if crate::platform::CAPS.translation {
|
||||
ui.selectable_value(&mut self.tab, Tab::Translation, tr("Translation"));
|
||||
}
|
||||
ui.selectable_value(&mut self.tab, Tab::About, tr("About"));
|
||||
});
|
||||
ui.separator();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue