From 5d5580b7ea69aa0d3cbb87578c28cc7e9c9d80d8 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 11 Apr 2022 10:50:03 +0100 Subject: [PATCH] Implement InertPieceTrait for SimpleShape Right now, this allows simple circles and rectangles to be used as backs (for occultation). It will also allow them to be used for dice, when we have those. It is not convenient to provide a test for this because occultation methods must be provided in libraries, and we don't have a test library. Signed-off-by: Ian Jackson --- src/pieces.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pieces.rs b/src/pieces.rs index a1563be1..c65294bb 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -150,6 +150,21 @@ impl PieceTrait for SimpleShape { fn itemname(&self) -> &str { self.itemname() } } +#[typetag::serde] +impl InertPieceTrait for SimpleShape { + fn nfaces(&self) -> RawFaceId { PieceTrait::nfaces(self) } + + #[throws(IE)] + fn svg(&self, f: &mut Html, _vpid: VisiblePieceId, face: FaceId) { + self.svg_piece_raw(f, face, &mut |_|Ok(()))?; + } + + #[throws(IE)] + fn describe_html(&self) -> Html { + hformat!("a {}", self.desc) + } +} + #[derive(Debug,Clone,Serialize,Deserialize)] pub struct PieceLabelLoaded { #[serde(default)] pub place: piece_specs::PieceLabelPlace, -- 2.30.2