image: image.into()
};
+ let special = PieceSpecialProperties {
+ rendering: Some(SpecialClientRendering::Die{}),
+ ..default()
+ };
SpecLoaded {
p: Box::new(die) as _,
occultable,
- special: default(),
+ special,
}
}
}
fn nfaces(&self) -> RawFaceId { self.nfaces }
fn itemname(&self) -> &str { &self.itemname }
-
- #[throws(IE)]
- fn special(&self) -> Option<SpecialClientRendering> {
- Some(SpecialClientRendering::Die{})
- }
}
#[typetag::serde(name="Die")]
fn nfaces(&self) -> RawFaceId;
fn itemname(&self) -> &str;
-
- // Don't add an xdata argument to this. Implementors must not make
- // this depend on the piece state, because the piece state might change
- // between svg() (which sets up information in the DOM) and special()
- // (which arranges to use that information).
- fn special(&self) -> Result<Option<SpecialClientRendering>,IE> { Ok(None) }
}
#[typetag::serde] // usual variable: p
/// so they are mostly "can/do we do this thing".
#[derive(Debug,Clone,Default,Serialize,Deserialize)]
pub struct PieceSpecialProperties {
+ pub rendering: Option<SpecialClientRendering>,
}
#[typetag::serde(tag="type")]
const DEFKEY_FLIP: UoKey = 'f';
-#[derive(Serialize,Debug)]
+#[derive(Deserialize,Serialize,Clone,Debug)]
#[serde(tag="kind")]
pub enum SpecialClientRendering {
Die { },
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),
hwrite!(&mut defs,
r##"<g id="piece{}" transform="{}" data-dragraise="{}""##,
pri.vpid, &transform.0, dragraise)?;
- if let Some(special) = &special {
+ if let Some(special) = &ipc.special.rendering {
let special = serde_json::to_string(&special).map_err(IE::JSONEncode)?;
hwrite!(&mut defs,
r##" data-special="{}""##,