From: Ian Jackson Date: Fri, 15 Apr 2022 10:40:56 +0000 (+0100) Subject: Pass face to InertPieceTrait::describe_html X-Git-Tag: otter-1.1.0~603 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=950dee6ab04b84410390b8bb460513c6895edb34;p=otter.git Pass face to InertPieceTrait::describe_html This ought to have been part of Extend InertPieceTrait to support multiple faces Signed-off-by: Ian Jackson --- diff --git a/src/gamestate.rs b/src/gamestate.rs index 9dc9d8ff..6887274b 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -244,7 +244,7 @@ pub trait InertPieceTrait: PieceBaseTrait { /// face used is always default, regardless of nfaces. fn svg(&self, f: &mut Html, id: VisiblePieceId, face: FaceId, xdata: &PieceXDataState /* use with care! */) -> Result<(),IE>; - fn describe_html(&self) -> Result; + fn describe_html(&self, face: FaceId) -> Result; } #[derive(Debug)] diff --git a/src/pcrender.rs b/src/pcrender.rs index 6dbcb80a..f5e81a36 100644 --- a/src/pcrender.rs +++ b/src/pcrender.rs @@ -76,7 +76,7 @@ impl PriOccultedGeneral { gpc: &GPiece, ipc: &IPiece) -> Html { match self.instead(ioccults, ipc)? { Left(y) => ipc.show(y).describe_html(gpc, goccults)?, - Right(i) => i.describe_html()?, + Right(i) => i.describe_html(default())?, } } } diff --git a/src/pieces.rs b/src/pieces.rs index 14194eeb..f6e5f867 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -160,7 +160,7 @@ impl InertPieceTrait for SimpleShape { } #[throws(IE)] - fn describe_html(&self) -> Html { + fn describe_html(&self, _: FaceId) -> Html { hformat!("a {}", self.desc) } } diff --git a/src/shapelib.rs b/src/shapelib.rs index a4242278..7a85c1f4 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -239,7 +239,7 @@ impl InertPieceTrait for ItemInertForOcculted { self.xform.write_svgd(f, &self.svgd)?; } #[throws(IE)] - fn describe_html(&self) -> Html { self.desc.clone() } + fn describe_html(&self, _: FaceId) -> Html { self.desc.clone() } } #[derive(Debug,Clone,Serialize,Deserialize,Eq,PartialEq,Ord,PartialOrd)] @@ -361,7 +361,7 @@ impl Item { if let Some(face) = self.faces.get(face) { face.desc } else if let Some(back) = &self.back { - return back.describe_html()?; + return back.describe_html(default())?; } else { self.faces[0].desc } @@ -402,7 +402,7 @@ impl InertPieceTrait for Item { self.svg_face(f, face, id, xdata)?; } #[throws(IE)] - fn describe_html(&self) -> Html { + fn describe_html(&self, _: FaceId) -> Html { self.describe_face(default())? } } diff --git a/src/updates.rs b/src/updates.rs index a9d87f3b..1587cd73 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -301,7 +301,7 @@ pub fn log_did_to_piece_whoby(ioccults: &IOccults, goccults: &GameOccults, let desc = (||{ Ok::<_,IE>(match ipc.show_or_instead(ioccults, y)? { Left(y) => ipc.show(y).describe_html(gpc, goccults)?, - Right(instead) => instead.describe_html()?, + Right(instead) => instead.describe_html(default())?, }) })().unwrap_or_else(|e|{ error!("failed to format during logging: {:?}", e);