Desktop play: the time control in the header, the set's kings, a low-time tick, which game is left
During a game against the computer the header's chip shows its control («5+3», «∞») where the result comes after it. The players' cards show the king of the board's piece set instead of ♔/♚, the state line under the name. The player's clock turning red is heard once a game: a double tick made of Kenney's tick_004 (CC0), every sound set; a game put aside with the time already low goes on without it. «The game is on» says which game: «Maia 1550 · you play white · 5+3 · move 5», as the card of a game put aside. Reviewed by the designer and the tester. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b29cc5ebca
commit
5b585b0dee
9 changed files with 111 additions and 26 deletions
|
|
@ -59,6 +59,9 @@ other sets, re-encoded as Ogg Vorbis.
|
|||
|
||||
`apps/desktop/assets/sounds/common/Wrong.ogg` (a wrong move while learning an opening, every
|
||||
set) is Kenney's `error_003` of "Interface Sounds" (CC0), made the same way.
|
||||
`apps/desktop/assets/sounds/common/LowTime.ogg` (the player's clock getting low, every set) is
|
||||
two of Kenney's `tick_004` of "Interface Sounds" (CC0) 180 ms apart, 4 dB quieter, re-encoded
|
||||
as Ogg Vorbis.
|
||||
|
||||
The Defeat and Success sounds of the Lichess sets (`Defeat.ogg` and `Victory.ogg` of
|
||||
`public/sound/sfx`, `piano`, `futuristic`, `nes`, by Enigmahack, AGPLv3+) were downloaded
|
||||
|
|
|
|||
BIN
apps/desktop/assets/sounds/common/LowTime.ogg
Normal file
BIN
apps/desktop/assets/sounds/common/LowTime.ogg
Normal file
Binary file not shown.
|
|
@ -562,6 +562,8 @@ pub enum Sound {
|
|||
Wrong,
|
||||
/// The line done (learning an opening).
|
||||
Success,
|
||||
/// The player's clock got low (once a game).
|
||||
LowTime,
|
||||
}
|
||||
|
||||
pub fn sound_bytes(set: SoundSet, sound: Sound) -> &'static [u8] {
|
||||
|
|
@ -605,6 +607,8 @@ pub fn sound_bytes(set: SoundSet, sound: Sound) -> &'static [u8] {
|
|||
(SoundSet::Clicks, Sound::Defeat) => s!("clicks", "Defeat"),
|
||||
// One short falling tone for every set (Kenney, CC0).
|
||||
(_, Sound::Wrong) => s!("common", "Wrong"),
|
||||
// A double tick for every set (Kenney, CC0).
|
||||
(_, Sound::LowTime) => s!("common", "LowTime"),
|
||||
(SoundSet::Sfx, Sound::Success) => s!("sfx", "Success"),
|
||||
(SoundSet::Piano, Sound::Success) => s!("piano", "Success"),
|
||||
(SoundSet::Futuristic, Sound::Success) => s!("futuristic", "Success"),
|
||||
|
|
@ -629,6 +633,7 @@ mod tests {
|
|||
Sound::Check,
|
||||
Sound::Checkmate,
|
||||
Sound::Defeat,
|
||||
Sound::LowTime,
|
||||
] {
|
||||
let b = sound_bytes(set, s);
|
||||
assert!(b.starts_with(b"OggS") && b.len() > 1000, "{set:?} {s:?}");
|
||||
|
|
|
|||
|
|
@ -967,8 +967,19 @@ impl GameView {
|
|||
)
|
||||
+ notes.as_ref().map_or(0.0, |n| button(ui, n.text()))
|
||||
};
|
||||
let result = result_label(self.game.result());
|
||||
let result_w = result.map_or(0.0, |r| {
|
||||
// The result, or during a game against the computer its time control («5+3», «∞»)
|
||||
// in the same place.
|
||||
let (result, result_hint) = match result_label(self.game.result()) {
|
||||
Some(r) => (Some(r.to_owned()), result_hint(self.game.result())),
|
||||
None => match &self.play {
|
||||
Some(s) => match &s.clock {
|
||||
Some(c) => (Some(c.control.label()), tr("Time control")),
|
||||
None => (Some("∞".to_owned()), tr("Unlimited")),
|
||||
},
|
||||
None => (None, ""),
|
||||
},
|
||||
};
|
||||
let result_w = result.as_ref().map_or(0.0, |r| {
|
||||
ui.painter()
|
||||
.layout_no_wrap(
|
||||
format!(" {r} "),
|
||||
|
|
@ -1042,14 +1053,14 @@ impl GameView {
|
|||
actions.push(GameAction::EditGameData);
|
||||
}
|
||||
});
|
||||
if let Some(result) = result {
|
||||
if let Some(result) = &result {
|
||||
ui.label(
|
||||
RichText::new(format!(" {result} "))
|
||||
.strong()
|
||||
.size(15.0)
|
||||
.background_color(ui.visuals().widgets.inactive.weak_bg_fill),
|
||||
)
|
||||
.on_hover_text(result_hint(self.game.result()));
|
||||
.on_hover_text(result_hint);
|
||||
}
|
||||
});
|
||||
let sub: Vec<String> = self
|
||||
|
|
@ -2278,6 +2289,11 @@ impl GameView {
|
|||
self.flipped = start.user == Color::Black;
|
||||
self.play_end = None;
|
||||
self.recorded = None;
|
||||
// A game put aside with the player's time already low goes on without the tick:
|
||||
// it was heard before.
|
||||
let low_time_heard = clock
|
||||
.as_ref()
|
||||
.is_some_and(|c| c.left(start.user, std::time::Instant::now()) <= c.low());
|
||||
self.play = Some(Session {
|
||||
journal,
|
||||
user: start.user,
|
||||
|
|
@ -2293,6 +2309,7 @@ impl GameView {
|
|||
}
|
||||
},
|
||||
resign_asked: false,
|
||||
low_time_heard,
|
||||
judge: judge.map(|p| {
|
||||
let ctx = ctx.clone();
|
||||
crate::play::Judge::start(
|
||||
|
|
@ -2640,6 +2657,12 @@ impl GameView {
|
|||
self.finish_play(crate::play::Ending::Time { loser: side, draw }, actions);
|
||||
return;
|
||||
}
|
||||
// The player's time getting low is heard once, as on Lichess (the clock turns
|
||||
// red at the same moment).
|
||||
if side == s.user && left <= c.low() && !s.low_time_heard {
|
||||
s.low_time_heard = true;
|
||||
actions.push(GameAction::Sound(Sound::LowTime));
|
||||
}
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(100));
|
||||
}
|
||||
}
|
||||
|
|
@ -3073,10 +3096,37 @@ impl GameView {
|
|||
let Some((intent, since)) = self.play_leave else {
|
||||
return;
|
||||
};
|
||||
// Which game: «Rodent IV 2800 · Tal · you play white · 5+3 · move 10», as on the
|
||||
// card of a game put aside.
|
||||
let context = self.play.as_ref().map(|s| {
|
||||
let mut parts = vec![s.rival_label()];
|
||||
parts.extend(s.rival_style().map(str::to_owned));
|
||||
parts.push(
|
||||
if s.user == Color::White {
|
||||
tr("you play white")
|
||||
} else {
|
||||
tr("you play black")
|
||||
}
|
||||
.to_owned(),
|
||||
);
|
||||
parts.push(
|
||||
s.clock
|
||||
.as_ref()
|
||||
.map_or_else(|| tr("no clock").to_owned(), |c| c.control.label()),
|
||||
);
|
||||
if let Some(pos) = self.game.position(self.play_end_node()) {
|
||||
parts.push(trf("move {n}", &[("n", &pos.fullmoves().get())]));
|
||||
}
|
||||
parts.join(" · ")
|
||||
});
|
||||
let mut choice = None;
|
||||
egui::Modal::new(egui::Id::new("play_leave")).show(ctx, |ui| {
|
||||
ui.set_width(460.0);
|
||||
ui.heading(tr("The game is on"));
|
||||
if let Some(context) = &context {
|
||||
ui.label(RichText::new(context).weak());
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
// A game written by itself needs no «add»: where it goes is said instead.
|
||||
let target = self
|
||||
.play
|
||||
|
|
@ -3170,7 +3220,7 @@ impl GameView {
|
|||
hub: &mut crate::translate_ui::Hub,
|
||||
actions: &mut Vec<GameAction>,
|
||||
) {
|
||||
let _ = (settings, analysis, reference, hub);
|
||||
let _ = (analysis, reference, hub);
|
||||
let Some(s) = &self.play else { return };
|
||||
let user = s.user;
|
||||
// The side whose pieces are at the top of the board is at the top.
|
||||
|
|
@ -3182,10 +3232,10 @@ impl GameView {
|
|||
egui::Panel::bottom("play_toolbar").show(ui, |ui| self.play_toolbar(ui, actions));
|
||||
egui::Panel::bottom("play_card_bottom")
|
||||
.show_separator_line(false)
|
||||
.show(ui, |ui| self.clock_card(ui, !top, user));
|
||||
.show(ui, |ui| self.clock_card(ui, !top, user, settings.piece_set));
|
||||
egui::Panel::top("play_card_top")
|
||||
.show_separator_line(false)
|
||||
.show(ui, |ui| self.clock_card(ui, top, user));
|
||||
.show(ui, |ui| self.clock_card(ui, top, user, settings.piece_set));
|
||||
if self.play.as_ref().is_some_and(|s| s.resign_offer.is_some()) {
|
||||
egui::Panel::bottom("play_resign_offer")
|
||||
.show_separator_line(false)
|
||||
|
|
@ -3240,7 +3290,7 @@ impl GameView {
|
|||
}
|
||||
|
||||
/// A player's card: name, rating, the clock and what is going on.
|
||||
fn clock_card(&self, ui: &mut Ui, side: Color, user: Color) {
|
||||
fn clock_card(&self, ui: &mut Ui, side: Color, user: Color, pieces: crate::assets::PieceSet) {
|
||||
let Some(s) = &self.play else { return };
|
||||
// While «The game is on» is open, the clocks stand at the moment it opened.
|
||||
let now = self
|
||||
|
|
@ -3283,10 +3333,11 @@ impl GameView {
|
|||
.size()
|
||||
.x
|
||||
};
|
||||
let rival_w = width(
|
||||
format!("♚ {}", s.rival_label()),
|
||||
egui::FontId::proportional(15.0),
|
||||
);
|
||||
// The king of the board's piece set before the name.
|
||||
let king_size = 22.0;
|
||||
let rival_w = king_size
|
||||
+ ui.spacing().item_spacing.x
|
||||
+ width(s.rival_label(), egui::FontId::proportional(15.0));
|
||||
let clock_size = left.map_or(28.0, |l| {
|
||||
let at_28 = width(crate::play::clock_text(l), egui::FontId::monospace(28.0));
|
||||
let room = ui.available_width() - rival_w - 16.0;
|
||||
|
|
@ -3301,19 +3352,27 @@ impl GameView {
|
|||
ui.horizontal(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_max_width(ui.available_width() - clock_w);
|
||||
let king = if side == Color::White { "♔" } else { "♚" };
|
||||
let name = if side == user {
|
||||
match s.user_elo {
|
||||
Some(r) => format!("{king} {} · {r}", tr("You")),
|
||||
None => format!("{king} {}", tr("You")),
|
||||
Some(r) => format!("{} · {r}", tr("You")),
|
||||
None => tr("You").to_owned(),
|
||||
}
|
||||
} else {
|
||||
format!("{king} {}", s.rival_label())
|
||||
s.rival_label()
|
||||
};
|
||||
// One line however narrow the panel: a long style is cut, not wrapped
|
||||
// under the clock (the whole name on hover).
|
||||
ui.add(egui::Label::new(RichText::new(&name).size(15.0)).truncate())
|
||||
.on_hover_text(&name);
|
||||
ui.horizontal(|ui| {
|
||||
let (rect, _) =
|
||||
ui.allocate_exact_size(vec2(king_size, king_size), Sense::hover());
|
||||
let king = chess_core::shakmaty::Piece {
|
||||
color: side,
|
||||
role: chess_core::shakmaty::Role::King,
|
||||
};
|
||||
pieces.paint(ui, king, rect);
|
||||
// One line however narrow the panel: a long style is cut, not
|
||||
// wrapped under the clock (the whole name on hover).
|
||||
ui.add(egui::Label::new(RichText::new(&name).size(15.0)).truncate())
|
||||
.on_hover_text(&name);
|
||||
});
|
||||
let state = if side != user && s.resign_offer.is_some() {
|
||||
tr("resigns")
|
||||
} else if side != user && s.opponent.thinking {
|
||||
|
|
@ -3331,7 +3390,11 @@ impl GameView {
|
|||
Some(st) => format!("{st} · {state}"),
|
||||
None => state.to_owned(),
|
||||
};
|
||||
ui.add(egui::Label::new(RichText::new(state).weak().size(13.0)).truncate());
|
||||
// Under the name, not under the king.
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(king_size + ui.spacing().item_spacing.x);
|
||||
ui.add(egui::Label::new(RichText::new(state).weak().size(13.0)).truncate());
|
||||
});
|
||||
});
|
||||
if let Some(left) = left {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
|
|
|
|||
|
|
@ -10847,6 +10847,17 @@ const ROWS: &[[&str; 9]] = &[
|
|||
"Raqib — Maia {elo}",
|
||||
"Қарсылас — Maia {elo}",
|
||||
],
|
||||
[
|
||||
"Time control",
|
||||
"Контроль времени",
|
||||
"Cadence",
|
||||
"Bedenkzeit",
|
||||
"Ritmo de juego",
|
||||
"Cadenza",
|
||||
"Ritmo de jogo",
|
||||
"Vaqt nazorati",
|
||||
"Уақыт бақылауы",
|
||||
],
|
||||
[
|
||||
"Unlimited",
|
||||
"Бессрочно",
|
||||
|
|
|
|||
|
|
@ -841,6 +841,8 @@ pub struct Session {
|
|||
pub opponent: Opponent,
|
||||
/// «Resign?» waits for the second click.
|
||||
pub resign_asked: bool,
|
||||
/// The player's clock got low and was heard (once a game).
|
||||
pub low_time_heard: bool,
|
||||
/// The engine judging the game for Maia's resignation (none without an engine).
|
||||
pub judge: Option<Judge>,
|
||||
/// Maia's turns in a row with her position hopeless.
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@
|
|||
|
||||
```
|
||||
┌─ Партия идёт ──────────────────────────────────────────────────┐
|
||||
│ Вы — Maia 1550 · 5+3 · 5-й ход │ слабым
|
||||
│ Maia 1550 · вы белыми · 5+3 · 5-й ход │ слабым
|
||||
│ Отложите партию — часы остановятся, а продолжить её можно │
|
||||
│ с карточки в библиотеке. Если сдаться, партия закончится │
|
||||
│ и запишется в «Роман — партии с компьютером». │
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@
|
|||
| Maia загружается | «загружается…» (`loading…`) | выделение, часы не идут |
|
||||
| без часов | как выше, но без времени | время не рисуется, имя на всю ширину |
|
||||
|
||||
- Звук при входе в «мало времени»: в наборах звуков программы его нет (`assets/sounds/*`: Move, Capture, Check, Checkmate). В v1 — только вид; звук — когда будет проверенный источник с лицензией (`AGENTS.md`). Звуки ходов, взятий, шаха — как в обычной партии; конец партии — `Checkmate`, если он есть в наборе.
|
||||
- Звук при входе в «мало времени» (с 2026-10-27): один раз за партию, когда **часы пользователя** становятся красными, — двойной тик `Sound::LowTime` (`assets/sounds/common/LowTime.ogg`, из Kenney «Interface Sounds», CC0; один для всех наборов, как `Wrong`). Часы соперника не звучат. Выключенный звук в настройках выключает и его. Звуки ходов, взятий, шаха — как в обычной партии; конец партии — `Checkmate`, если он есть в наборе.
|
||||
- Maia **не проигрывает по времени** (R15), поэтому красной её карточка практически не бывает; правило одно для обеих.
|
||||
|
||||
### 3.4. Шапка
|
||||
|
|
@ -225,7 +225,7 @@
|
|||
```
|
||||
|
||||
- Название — белые — чёрные, как всегда, но пользователь назван «Вы»: «Вы — Maia 1500» белыми, «Maia 1500 — Вы» чёрными (`You`). Не кликается (нет «Данных партии» в игре).
|
||||
- **Чип контроля** «5+3» — на месте чипа результата, тем же видом; «Без часов» — чип «∞» с подсказкой «Без часов» (`No clock`). После конца на этом месте — результат «1-0»: чип не прыгает.
|
||||
- **Чип контроля** «5+3» — на месте чипа результата, тем же видом; «Без часов» — чип «∞» с подсказкой «Бессрочно» (`Unlimited`, как в окне «Играть»); у чипа контроля подсказка «Контроль времени» (`Time control`). После конца на этом месте — результат «1-0»: чип не прыгает.
|
||||
- Подзаголовок: «Партия с компьютером · {категория}» (`Game vs computer · {category}`), без часов — «Партия с компьютером».
|
||||
- Слева — «⬅ Библиотека» (ведёт к вопросу §6). Справа — только «⚙ Настройки» (вид доски и звук можно менять, часы при этом идут). **Скрыты:** «🔍 Найти в базе», «⏷», «⚠/ℹ заметки», «•» несохранённой партии, «⬅ К партии …».
|
||||
|
||||
|
|
@ -356,13 +356,14 @@
|
|||
|
||||
```
|
||||
┌─ Партия идёт ──────────────────────────────────────────────┐
|
||||
│ Вы — Maia 1500 · 5+3 · 24-й ход │ ← слабым
|
||||
│ Maia 1500 · вы белыми · 5+3 · 24-й ход │ ← слабым
|
||||
│ Если выйти, партия закончится вашей сдачей. │
|
||||
│ │
|
||||
│ [Сдаться и добавить в базу…] [Сдаться и выйти] [Продолжить игру] │
|
||||
└────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
- Под заголовком слабым — какая это партия (с 2026-10-27): соперник (у Rodent — и стиль), цвет пользователя, контроль («без часов»), номер хода — те же слова, что на карточке отложенной партии.
|
||||
- Заголовок «Партия идёт» (`The game is on`); текст «Если выйти, партия закончится вашей сдачей.» (`If you leave, the game ends with your resignation.`). Modal 460, `confirm_dialog` по образцу §3.4.
|
||||
- «Сдаться и добавить в базу…» (`Resign and add to a database…`) — результат «сдача», затем поток «Добавить в базу» (§5.2); после записи уход продолжается (`close_after_save`); «Отмена» в нём — партия уже закончена, экран остаётся на сыгранной партии с полосой результата (уход не продолжается, ничего не потеряно).
|
||||
- «Сдаться и выйти» (`Resign and leave`) — результат пишется, партия не сохраняется, уход (или закрытие программы).
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@
|
|||
- **Рекомендация:** (а) — проще для пользователя и убирает весь класс ошибок (ещё и общие файлы просмотренных партий, онлайн-загрузки); обсудить.
|
||||
|
||||
### 11. Игра с Maia: доделки после ревью дизайнера
|
||||
- **Статус:** частично (2026-10-25). Диалог переделан в 1.3.0 (порядок блоков, «Соперник — Maia N», слайдер с 600/2600, подсветка «Как я», плитки с рамкой, «Бессрочно»). Осталось ниже.
|
||||
- **Статус:** частично (2026-10-27: сделаны чип контроля в шапке, короли набора на карточках, звук малого времени, строка контекста в «Партия идёт»; «Партия идёт» уже с кнопками справа). Осталось «Потом» ниже, кроме сделанного. Диалог переделан в 1.3.0 (порядок блоков, «Соперник — Maia N», слайдер с 600/2600, подсветка «Как я», плитки с рамкой, «Бессрочно»). Осталось ниже.
|
||||
- **Шапка во время партии:** фишка контроля «5+3» (или «∞») на месте результата.
|
||||
- **«Партия идёт»:** кнопки справа, одной высоты; строка контекста «Maia 1500 — Вы · 5+3 · 10-й ход».
|
||||
- **Узкое окно (640×900):** часы — одна строка из двух половинных карточек над нотацией; нотация прокручивается к последнему ходу.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue