From: Ian Jackson Date: Sat, 13 Feb 2021 11:05:30 +0000 (+0000) Subject: Revert "SimpleShape: Move itemname out of common" X-Git-Tag: otter-0.4.0~522 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2408c2d7c9825f3c684f3689787051bbc8929cab;p=otter.git Revert "SimpleShape: Move itemname out of common" Actually we need to reuse Disc and Square as they are, so we must do this by hand somehow. This reverts commit 878aeb46778ef76feea9bc51d0691f37074fcabb. --- diff --git a/src/pieces.rs b/src/pieces.rs index 4efae312..c0c02d10 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -171,11 +171,12 @@ impl SimpleShape { #[throws(SpecError)] fn new(desc: Html, path: Html, outline: Box, - itemname: &'_ str, + def_itemname: &'_ str, common: &piece_specs::SimpleCommon) -> SimpleShape { - let itemname = itemname.to_owned(); + let itemname = common.itemname.clone() + .unwrap_or_else(|| def_itemname.to_string()); let cmap = |spec: &FaceColourSpecs| Ok::<_,SpecError>( spec @@ -225,7 +226,7 @@ impl SimplePieceSpec for piece_specs::Disc { Html::lit("disc"), svg_circle_path(self.diam as f64)?, Box::new(outline), - self.itemname.as_deref().unwrap_or("simple-disc"), + "simple-disc", &self.common, )? } @@ -256,7 +257,7 @@ impl SimplePieceSpec for piece_specs::Square { Html::lit("square"), svg_rectangle_path(self.xy()?.promote())?, Box::new(outline), - self.itemname.as_deref().unwrap_or("simple-square"), + "simple-square", &self.common, )? } diff --git a/src/spec.rs b/src/spec.rs index a6725621..879cca40 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -199,6 +199,7 @@ pub mod piece_specs { #[derive(Debug,Serialize,Deserialize)] pub struct SimpleCommon { + pub itemname: Option, pub faces: IndexVec, #[serde(default)] pub edges: IndexVec, pub edge_width: Option, @@ -207,7 +208,6 @@ pub mod piece_specs { #[derive(Debug,Serialize,Deserialize)] pub struct Disc { pub diam: Coord, - pub itemname: Option, #[serde(flatten)] pub common: SimpleCommon, } @@ -215,7 +215,6 @@ pub mod piece_specs { #[derive(Debug,Serialize,Deserialize)] pub struct Square { pub size: Vec, - pub itemname: Option, #[serde(flatten)] pub common: SimpleCommon, }