task 43 review: hint stays dimmed during an engine line, plain text, help under «Board», ring 10×10, reopened game keeps the hint

This commit is contained in:
vrubelroman 2026-11-27 14:24:02 +03:00
parent 112fee89a5
commit b384f7b792
5 changed files with 55 additions and 32 deletions

View file

@ -735,9 +735,15 @@ impl GameView {
show && fresh
}
/// The hint's strip: the translation strip's look, closed for good by its ×.
/// The hint's strip: the translation strip's look, closed for good by its ×; dimmed
/// (its height kept) while the board shows an engine line and takes no drawing.
/// Returns whether the hint's settings changed.
fn shapes_hint_strip(&mut self, ui: &mut Ui, hint: &mut crate::settings::Hint) -> bool {
fn shapes_hint_strip(
&mut self,
ui: &mut Ui,
hint: &mut crate::settings::Hint,
dim: bool,
) -> bool {
let mut closed = false;
egui::Frame::new()
.fill(ui.visuals().faint_bg_color)
@ -752,15 +758,17 @@ impl GameView {
egui::Layout::left_to_right(egui::Align::Center).with_main_wrap(true),
|ui| {
ui.set_min_height(row_h);
ui.add(
egui::Label::new(RichText::new(tr(
"Arrows and circles: drag or click with the right mouse button on the board. They are saved in the game.",
)).weak())
.wrap(),
)
.on_hover_text(tr(
"No key — green, Shift — red, Alt — blue, Shift+Alt — yellow. Draw the same one again to remove it. Ctrl+Z undoes.",
));
ui.add_enabled_ui(!dim, |ui| {
ui.add(
egui::Label::new(tr(
"Arrows and circles: drag or click with the right mouse button on the board. They are saved in the game.",
))
.wrap(),
)
.on_hover_text(tr(
"No key — green, Shift — red, Alt — blue, Shift+Alt — yellow. Draw the same one again to remove it. Ctrl+Z undoes.",
));
});
},
);
ui.allocate_ui_with_layout(
@ -1693,8 +1701,9 @@ impl GameView {
let mut hints_changed =
self.decide_shapes_hint(&mut settings.hints.board_shapes, &mut seen, translating);
ui.data_mut(|d| d.insert_temp(seen_id, seen));
if self.shapes_hint == Some(true) && !translating && self.preview.is_none() {
hints_changed |= self.shapes_hint_strip(ui, &mut settings.hints.board_shapes);
if self.shapes_hint == Some(true) && !translating {
let dim = self.preview.is_some();
hints_changed |= self.shapes_hint_strip(ui, &mut settings.hints.board_shapes, dim);
}
if hints_changed {
actions.push(GameAction::HintsChanged);
@ -5693,6 +5702,10 @@ mod tests {
let mut b = open(1);
b.decide_shapes_hint(&mut hint, &mut seen, false);
assert_eq!(hint.shown, 3);
// The third counted game opened again keeps the hint, uncounted.
let mut b_again = open(1);
assert!(!b_again.decide_shapes_hint(&mut hint, &mut seen, false));
assert_eq!((b_again.shapes_hint, hint.shown), (Some(true), 3));
// The fourth game: gone by itself.
let mut c = open(2);
assert!(!c.decide_shapes_hint(&mut hint, &mut seen, false));

View file

@ -104,7 +104,8 @@ fn paint_shapes_sign(
Stroke::NONE,
));
} else {
painter.circle_stroke(center, SIGN / 2.0 - 0.5, stroke);
// The ring's outer edge within the sign's box, as the arrow's.
painter.circle_stroke(center, SIGN / 2.0 - 1.0, stroke);
}
}
@ -1340,8 +1341,9 @@ fn move_chip(
.painter()
.layout_no_wrap(label.to_owned(), font, text_color);
let pad = vec2(4.0, 2.0);
// The sign and the chip's own right padding after it.
let sign = if shapes.is_some() {
SIGN_GAP + SIGN
SIGN_GAP + SIGN + 2.0
} else {
0.0
};

View file

@ -202,14 +202,19 @@ impl Hint {
pub const SHOWS: u32 = 3;
/// A game opens where the hint can stand: whether it is shown there. A show counts
/// once per game (`fresh`: the game was not opened before in this session).
/// once per game (`fresh`: the game was not shown the hint before in this session);
/// such a game keeps it, the last counted one too.
pub fn offer(&mut self, fresh: bool) -> bool {
if self.done || self.shown >= Self::SHOWS {
if self.done {
return false;
}
if fresh {
self.shown += 1;
if !fresh {
return true;
}
if self.shown >= Self::SHOWS {
return false;
}
self.shown += 1;
true
}
}
@ -404,8 +409,9 @@ mod tests {
assert!(hint.offer(true));
assert!(hint.offer(true));
assert_eq!(hint.shown, 3);
// A fourth game: gone; a game already shown in the session keeps it.
assert!(!hint.offer(true));
assert!(!hint.offer(false));
assert!(hint.offer(false));
assert_eq!(hint.shown, 3);
}

View file

@ -519,6 +519,13 @@ fn board_tab(ui: &mut Ui, s: &mut Settings, changed: &mut bool) {
notation_section(ui, s, changed);
ui.add_space(8.0);
ui.label(RichText::new(tr("Board")).strong());
// The hint above the notation goes away; what it told stays here, in sight.
ui.label(
RichText::new(tr(
"Arrows and circles: right mouse button on the board; Shift — red, Alt — blue, Shift+Alt — yellow. Saved in the move's comment ([%cal], [%csl]).",
))
.weak(),
);
ui.horizontal_wrapped(|ui| {
for id in BoardThemeId::ALL {
let t = id.theme();
@ -559,13 +566,6 @@ fn board_tab(ui: &mut Ui, s: &mut Settings, changed: &mut bool) {
}
}
});
// The hint above the notation goes away; what it told stays here.
ui.label(
RichText::new(tr(
"Arrows and circles: right mouse button on the board; Shift — red, Alt — blue, Shift+Alt — yellow. Saved in the move's comment ([%cal], [%csl]).",
))
.weak(),
);
ui.add_space(8.0);
ui.horizontal(|ui| {
ui.label(tr("Piece animation"));