From cd20167651421570fa7c597bc8912d8028634a07 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 23 Mar 2021 23:12:39 +0000 Subject: [PATCH] hand: wip text Signed-off-by: Ian Jackson --- src/hand.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/hand.rs b/src/hand.rs index 0808a505..71c79fda 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -87,7 +87,8 @@ impl Hand { impl PieceTrait for Hand { fn nfaces(&self) -> RawFaceId { 1 } #[throws(IE)] - fn svg_piece(&self, f: &mut Html, gpc: &GPiece, _gs: &GameState, _vpid: VisiblePieceId) { + fn svg_piece(&self, f: &mut Html, gpc: &GPiece, + gs: &GameState, _vpid: VisiblePieceId) { let owned = if_chain!{ if let Some(xdata) = gpc.xdata.get::()?; if let Some(owned) = &xdata.owner; @@ -100,6 +101,26 @@ impl PieceTrait for Hand { } Ok(()) })?; + if_chain! { + if let Some(owned) = owned; + if let Some(gpl) = gs.players.get(owned.player); + if let Some(colour) = self.shape.edges.get(0); + let signum = if false { -1. } else { 1. }; + let fontsz = 4.; + let PosC([x,y]) = { + let mut pos = (self.shape.outline.xy * -0.5)?; + pos.0[1] -= 0.5 * fontsz; + pos.0[1] *= signum; + pos.0[1] += 0.5 * fontsz; + pos + }; + then { + write!(f.0, + r##"{}"##, + x, y, fontsz, &colour.0, + htmlescape::encode_minimal(&gpl.nick))?; + } + } } #[throws(IE)] -- 2.30.2