Move marks in the owner's palette on the desktop and Android
!! #26C2A3, ! #81B64C, ?! #F7C631, ? #FFA459, ?? #FA412D (from the owner's reference); darker variants for text in the light theme; the judgement colors now come from the NAG colors, and the accuracy follows them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4ffe45363d
commit
df6ad23b45
4 changed files with 71 additions and 57 deletions
|
|
@ -15,6 +15,10 @@ All notable changes are listed here. Versions follow [Semantic Versioning](https
|
|||
author's own sign, when there is one, stands instead.
|
||||
- Desktop, a game against the computer: the draw offer is «½–½» on its button («Offer a
|
||||
draw» in its tooltip), so that the game's buttons fit in a narrow panel.
|
||||
- Move marks in the owner's palette (as on chess.com): !! #26C2A3, ! #81B64C, ?! yellow
|
||||
#F7C631, ? #FFA459, ?? #FA412D, on the board, in the notation, the report and the graph,
|
||||
on the desktop and Android; as text in the light theme darkened to stay readable. The
|
||||
accuracy numbers follow the same colors.
|
||||
- Android: the board shows the move's mark in the corner of its square, as on the desktop:
|
||||
the review's ?!, ?, ??, !, !! or the author's own sign.
|
||||
|
||||
|
|
|
|||
|
|
@ -54,26 +54,26 @@ val DarkChess = LightChess.copy(
|
|||
comment = Color(0xFF9EC4E0),
|
||||
)
|
||||
|
||||
/// Move assessments in the colors of Lichess (as on the desktop). On a light background
|
||||
/// they are darkened to stay readable (contrast at least 4.5:1).
|
||||
/// Move assessments in the owner's palette (chess.com's), as on the desktop. On a light
|
||||
/// background they are darkened to stay readable (contrast at least 4.5:1).
|
||||
fun nagColor(nag: Int, dark: Boolean): Color? = if (dark) {
|
||||
when (nag) {
|
||||
1 -> Color(0xFF629C2E) // !
|
||||
2 -> Color(0xFFE68F00) // ?
|
||||
3 -> Color(0xFF22AC9A) // !!
|
||||
4 -> Color(0xFFDF5353) // ??
|
||||
1 -> Color(0xFF81B64C) // !
|
||||
2 -> Color(0xFFFFA459) // ?
|
||||
3 -> Color(0xFF26C2A3) // !!
|
||||
4 -> Color(0xFFFA412D) // ??
|
||||
5 -> Color(0xFFEA45D8) // !?
|
||||
6 -> Color(0xFF56B4E9) // ?!
|
||||
6 -> Color(0xFFF7C631) // ?!
|
||||
else -> null
|
||||
}
|
||||
} else {
|
||||
when (nag) {
|
||||
1 -> Color(0xFF4E7F22)
|
||||
2 -> Color(0xFFA35F00)
|
||||
3 -> Color(0xFF12806F)
|
||||
4 -> Color(0xFFC23B3B)
|
||||
1 -> Color(0xFF5B8135)
|
||||
2 -> Color(0xFFC25700)
|
||||
3 -> Color(0xFF1A846F)
|
||||
4 -> Color(0xFFD2301C)
|
||||
5 -> Color(0xFFB0259F)
|
||||
6 -> Color(0xFF1F72A8)
|
||||
6 -> Color(0xFF937006)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ fn symbol_row_sized(
|
|||
let mut text = RichText::new(*sym).size(if w < SYMBOL_W { 14.0 } else { 15.0 });
|
||||
if pressed {
|
||||
text = text.strong().color(ui.visuals().selection.stroke.color);
|
||||
} else if moves && let Some(c) = assessment_color(*nag) {
|
||||
} else if moves && let Some(c) = assessment_text_color(*nag, ui.visuals().dark_mode) {
|
||||
text = text.color(c);
|
||||
}
|
||||
let r = ui
|
||||
|
|
@ -579,7 +579,7 @@ fn paint_move_cell(
|
|||
let san = game.game_move(id).map(|m| m.san.as_str()).unwrap_or("?");
|
||||
let san = crate::san::show(san);
|
||||
let (mut sym, mut color) = node
|
||||
.map(|n| move_glyph(n.nags()))
|
||||
.map(|n| move_glyph(n.nags(), visuals.dark_mode))
|
||||
.unwrap_or((String::new(), None));
|
||||
// The engine's verdict right after the move, the move in its color (as on Lichess);
|
||||
// the author's own sign stands instead when there is one.
|
||||
|
|
@ -689,21 +689,39 @@ fn mark_block(ui: &mut Ui, n: &Notation, id: NodeId, mark: &Mark, out: &mut Nota
|
|||
});
|
||||
}
|
||||
|
||||
/// Colour of a move-assessment NAG ($1-$6), the Lichess palette.
|
||||
/// Colour of a move-assessment NAG ($1-$6): the owner's palette (chess.com's), bright,
|
||||
/// for badges and dark backgrounds.
|
||||
pub fn assessment_color(nag: Nag) -> Option<Color32> {
|
||||
Some(match nag.0 {
|
||||
1 => Color32::from_rgb(0x62, 0x9c, 0x2e),
|
||||
2 => Color32::from_rgb(0xe6, 0x8f, 0x00),
|
||||
3 => Color32::from_rgb(0x22, 0xac, 0x9a),
|
||||
4 => Color32::from_rgb(0xdf, 0x53, 0x53),
|
||||
1 => Color32::from_rgb(0x81, 0xb6, 0x4c),
|
||||
2 => Color32::from_rgb(0xff, 0xa4, 0x59),
|
||||
3 => Color32::from_rgb(0x26, 0xc2, 0xa3),
|
||||
4 => Color32::from_rgb(0xfa, 0x41, 0x2d),
|
||||
5 => Color32::from_rgb(0xea, 0x45, 0xd8),
|
||||
6 => Color32::from_rgb(0x56, 0xb4, 0xe9),
|
||||
6 => Color32::from_rgb(0xf7, 0xc6, 0x31),
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// The same as text: on a light background darkened to stay readable (contrast at least
|
||||
/// 4.5:1), as on Android.
|
||||
pub fn assessment_text_color(nag: Nag, dark: bool) -> Option<Color32> {
|
||||
if dark {
|
||||
return assessment_color(nag);
|
||||
}
|
||||
Some(match nag.0 {
|
||||
1 => Color32::from_rgb(0x5b, 0x81, 0x35),
|
||||
2 => Color32::from_rgb(0xc2, 0x57, 0x00),
|
||||
3 => Color32::from_rgb(0x1a, 0x84, 0x6f),
|
||||
4 => Color32::from_rgb(0xd2, 0x30, 0x1c),
|
||||
5 => Color32::from_rgb(0xb0, 0x25, 0x9f),
|
||||
6 => Color32::from_rgb(0x93, 0x70, 0x06),
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Move-assessment glyph (`!`, `?`, …) with its color, plus position assessments.
|
||||
fn move_glyph(nags: &[Nag]) -> (String, Option<Color32>) {
|
||||
fn move_glyph(nags: &[Nag], dark: bool) -> (String, Option<Color32>) {
|
||||
let mut s = String::new();
|
||||
let mut color = None;
|
||||
for nag in nags {
|
||||
|
|
@ -712,7 +730,7 @@ fn move_glyph(nags: &[Nag]) -> (String, Option<Color32>) {
|
|||
continue;
|
||||
};
|
||||
if nag.is_move_assessment() {
|
||||
let Some(c) = assessment_color(*nag) else {
|
||||
let Some(c) = assessment_text_color(*nag, dark) else {
|
||||
continue;
|
||||
};
|
||||
color = Some(c);
|
||||
|
|
@ -1153,7 +1171,7 @@ fn variation_block(
|
|||
out: &mut NotationResponse,
|
||||
) {
|
||||
let mut tokens = Vec::new();
|
||||
line_tokens(n, start, &mut tokens);
|
||||
line_tokens(n, start, ui.visuals().dark_mode, &mut tokens);
|
||||
let editing = editor.as_ref().map(|e| e.slot);
|
||||
// The flow is cut where the editor stands: after the move for «after», before it
|
||||
// for «before»; a comment being edited is replaced by the editor.
|
||||
|
|
@ -1280,7 +1298,7 @@ fn flow(
|
|||
}
|
||||
|
||||
/// The tokens of a line starting at `first` (a variation move), nested lines inside.
|
||||
fn line_tokens(n: &Notation, first: NodeId, tokens: &mut Vec<Token>) {
|
||||
fn line_tokens(n: &Notation, first: NodeId, dark: bool, tokens: &mut Vec<Token>) {
|
||||
let game = n.game;
|
||||
let mut node = first;
|
||||
let mut need_number = true;
|
||||
|
|
@ -1297,7 +1315,7 @@ fn line_tokens(n: &Notation, first: NodeId, tokens: &mut Vec<Token>) {
|
|||
let (num, color) = game.move_number(node).unwrap_or((0, Color::White));
|
||||
let san = game.game_move(node).map(|m| m.san.as_str()).unwrap_or("?");
|
||||
let san = crate::san::show(san);
|
||||
let (sym, sym_color) = move_glyph(nd.nags());
|
||||
let (sym, sym_color) = move_glyph(nd.nags(), dark);
|
||||
let label = match (color, need_number) {
|
||||
(Color::White, _) => format!("{num}.{san}{sym}"),
|
||||
(Color::Black, true) => format!("{num}…{san}{sym}"),
|
||||
|
|
@ -1332,7 +1350,7 @@ fn line_tokens(n: &Notation, first: NodeId, tokens: &mut Vec<Token>) {
|
|||
{
|
||||
for &v in game.variations(parent) {
|
||||
tokens.push(Token::Open);
|
||||
line_tokens(n, v, tokens);
|
||||
line_tokens(n, v, dark, tokens);
|
||||
tokens.push(Token::Close);
|
||||
need_number = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -275,13 +275,7 @@ impl Review {
|
|||
}
|
||||
errors += 1;
|
||||
if !authored {
|
||||
nags.push(match mark.judgement {
|
||||
Judgement::Inaccuracy => Nag::DUBIOUS_MOVE,
|
||||
Judgement::Mistake => Nag::MISTAKE,
|
||||
Judgement::Blunder => Nag::BLUNDER,
|
||||
Judgement::Great => Nag::GOOD_MOVE,
|
||||
Judgement::Brilliant => Nag::BRILLIANT_MOVE,
|
||||
});
|
||||
nags.push(judgement_nag(mark.judgement));
|
||||
}
|
||||
let name = judgement_name(mark.judgement);
|
||||
let text = match &mark.best_label {
|
||||
|
|
@ -686,7 +680,7 @@ impl Review {
|
|||
.enumerate()
|
||||
{
|
||||
if let Some(a) = s.phase_accuracy[i] {
|
||||
value_row(ui, percent(a), label, Some(accuracy_color(a)));
|
||||
value_row(ui, percent(a), label, Some(accuracy_color(a, ui.visuals().dark_mode)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -859,29 +853,25 @@ fn strip_eval(c: &str) -> String {
|
|||
out.trim().to_string()
|
||||
}
|
||||
|
||||
/// A judgement's color: the same as its sign's NAG (`notation::assessment_color`).
|
||||
pub fn judgement_color(j: Judgement) -> Color32 {
|
||||
match j {
|
||||
Judgement::Inaccuracy => Color32::from_rgb(0x56, 0xb4, 0xe9),
|
||||
Judgement::Mistake => Color32::from_rgb(0xe6, 0x8f, 0x00),
|
||||
Judgement::Blunder => Color32::from_rgb(0xdf, 0x53, 0x53),
|
||||
// The colors of the signs ! and !! in the notation.
|
||||
Judgement::Great => Color32::from_rgb(0x62, 0x9c, 0x2e),
|
||||
Judgement::Brilliant => Color32::from_rgb(0x22, 0xac, 0x9a),
|
||||
}
|
||||
crate::notation::assessment_color(judgement_nag(j)).unwrap_or(Color32::GRAY)
|
||||
}
|
||||
|
||||
/// The color of a judgement as text: on a light background darker than the bright one
|
||||
/// of the badges, as on Android.
|
||||
pub fn judgement_text_color(j: Judgement, dark: bool) -> Color32 {
|
||||
if dark {
|
||||
return judgement_color(j);
|
||||
}
|
||||
crate::notation::assessment_text_color(judgement_nag(j), dark).unwrap_or(Color32::GRAY)
|
||||
}
|
||||
|
||||
/// The NAG of the same sign.
|
||||
pub fn judgement_nag(j: Judgement) -> Nag {
|
||||
match j {
|
||||
Judgement::Inaccuracy => Color32::from_rgb(0x1f, 0x72, 0xa8),
|
||||
Judgement::Mistake => Color32::from_rgb(0xa3, 0x5f, 0x00),
|
||||
Judgement::Blunder => Color32::from_rgb(0xc2, 0x3b, 0x3b),
|
||||
Judgement::Great => Color32::from_rgb(0x4e, 0x7f, 0x22),
|
||||
Judgement::Brilliant => Color32::from_rgb(0x12, 0x80, 0x6f),
|
||||
Judgement::Inaccuracy => Nag::DUBIOUS_MOVE,
|
||||
Judgement::Mistake => Nag::MISTAKE,
|
||||
Judgement::Blunder => Nag::BLUNDER,
|
||||
Judgement::Great => Nag::GOOD_MOVE,
|
||||
Judgement::Brilliant => Nag::BRILLIANT_MOVE,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -915,16 +905,18 @@ fn judgement_plural(j: Judgement) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
fn accuracy_color(a: f64) -> Color32 {
|
||||
if a >= 85.0 {
|
||||
Color32::from_rgb(0x62, 0x9c, 0x2e)
|
||||
/// Accuracy in the colors of the move marks: green, yellow, orange, red.
|
||||
fn accuracy_color(a: f64, dark: bool) -> Color32 {
|
||||
let j = if a >= 85.0 {
|
||||
Judgement::Great
|
||||
} else if a >= 70.0 {
|
||||
Color32::from_rgb(0x56, 0xb4, 0xe9)
|
||||
Judgement::Inaccuracy
|
||||
} else if a >= 50.0 {
|
||||
Color32::from_rgb(0xe6, 0x8f, 0x00)
|
||||
Judgement::Mistake
|
||||
} else {
|
||||
Color32::from_rgb(0xdf, 0x53, 0x53)
|
||||
}
|
||||
Judgement::Blunder
|
||||
};
|
||||
judgement_text_color(j, dark)
|
||||
}
|
||||
|
||||
fn percent(a: f64) -> String {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue