From: Ian Jackson Date: Mon, 11 Apr 2022 09:50:03 +0000 (+0100) Subject: Implement InertPieceTrait for SimpleShape X-Git-Tag: otter-1.1.0~616 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=5d5580b7ea69aa0d3cbb87578c28cc7e9c9d80d8;p=otter.git 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 --- 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,