From: Ian Jackson Date: Mon, 22 Mar 2021 00:57:01 +0000 (+0000) Subject: shapelib: Implement load_occult for ItemSpec X-Git-Tag: otter-0.5.0~529 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f9c04640609b01755675d5ea306d1b1da98e059d;p=otter.git shapelib: Implement load_occult for ItemSpec Nothing calls this yet, but we will soon, ourselves. Signed-off-by: Ian Jackson --- diff --git a/src/gamestate.rs b/src/gamestate.rs index 782f440c..24d61865 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -199,6 +199,9 @@ pub trait PieceSpec: Debug + Sync + Send + 'static { fn count(&self) -> usize { 1 } fn load(&self, i: usize, gpc: &mut GPiece, ir: &InstanceRef) -> Result; + fn load_occult(&self) -> Result, SpecError> { + throw!(SpE::ComplexPieceWhereSimpleRequired) + } } // ========== implementations ========== diff --git a/src/shapelib.rs b/src/shapelib.rs index 448c293c..1fc971a5 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -271,6 +271,18 @@ impl PieceTrait for Item { fn itemname(&self) -> &str { &self.itemname } } +#[typetag::serde(name="LibItem")] +impl OccultedPieceTrait for Item { + #[throws(IE)] + fn svg(&self, f: &mut Html, _id: VisiblePieceId) { + self.svg_face(f, default())?; + } + #[throws(IE)] + fn describe_html(&self) -> Html { + self.describe_face(default())? + } +} + static SHAPELIBS: RwLock> = const_rwlock(None); pub fn libs_list() -> Vec { @@ -418,6 +430,10 @@ impl PieceSpec for ItemSpec { -> PieceSpecLoaded { self.find_load()?.into() } + #[throws(SpecError)] + fn load_occult(&self) -> Box { + self.find_load()?.0 as Box + } } #[typetag::serde(name="LibList")]