From: Ian Jackson Date: Mon, 11 Apr 2022 19:52:10 +0000 (+0100) Subject: Provide plumbing for special client rendering instructions X-Git-Tag: otter-1.1.0~581 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=768ebb9b09856fe59a497e0f4891592d74083a53;p=otter.git Provide plumbing for special client rendering instructions Signed-off-by: Ian Jackson --- diff --git a/src/gamestate.rs b/src/gamestate.rs index 03947302..e649864b 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -179,6 +179,8 @@ pub trait PieceBaseTrait: OutlineTrait + Send + Debug + 'static { fn nfaces(&self) -> RawFaceId; fn itemname(&self) -> &str; + + fn special(&self) -> Result,IE> { Ok(None) } } #[typetag::serde] // usual variable: p diff --git a/src/pcrender.rs b/src/pcrender.rs index afba77a2..5315d07b 100644 --- a/src/pcrender.rs +++ b/src/pcrender.rs @@ -13,6 +13,10 @@ pub struct VisibleAngleTransform(Html); const DEFKEY_FLIP: UoKey = 'f'; +#[derive(Serialize,Debug)] +pub enum SpecialClientRendering { +} + #[derive(Debug,Clone)] pub struct PieceRenderInstructions { pub vpid: VisiblePieceId, @@ -181,13 +185,14 @@ impl PieceRenderInstructions { let pri = self; let instead = pri.instead(ioccults, ipc)?; - let o: &dyn OutlineTrait = match instead { + let o: &dyn PieceBaseTrait = match instead { Left(y) => Borrow::::borrow(ipc.show(y)).dyn_upcast(), Right(i) => i.dyn_upcast(), }; let angle = pri.angle(gpc); let bbox = o.bbox_approx()?; + let special = o.special()?; let dragraise = match o.thresh_dragraise()? { Some(n) if n < 0 => throw!(SvgE::NegativeDragraise), @@ -201,6 +206,12 @@ impl PieceRenderInstructions { hwrite!(&mut defs, r##""##)?; diff --git a/templates/script.ts b/templates/script.ts index 4c258775..7adf41d4 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -23,6 +23,7 @@ // pelem // #piece{} // .dragraise dragged more than this ? raise to top! +// .special enum RenderSpecial // // currently-displayed version of the piece // to allow addition/removal of selected indication