From: Ian Jackson Date: Tue, 23 Mar 2021 23:12:39 +0000 (+0000) Subject: hand: wip text X-Git-Tag: otter-0.5.0~488 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=cd20167651421570fa7c597bc8912d8028634a07;p=otter.git hand: wip text Signed-off-by: Ian Jackson --- 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)]