Honours ``label``, displaying the number of of pieces in (on) this deck.
+ * ``stack_pos``: When stacking neatly, stack here relative to the
+ deck centre. [two numbers, ``[0,0]``]
+
Example::
[[pieces]]
struct Deck {
shape: GenericSimpleShape<(), RectOutline>,
label: Option<PieceLabelLoaded>,
+ stack_pos: Pos,
}
#[derive(Debug,Clone,Copy,Ord,PartialOrd,Eq,PartialEq)]
gpc.rotateable = false;
let p = Box::new(Deck {
shape,
+ stack_pos: PosC { coords: self.stack_pos },
label: self.label.load()?,
}) as Box<dyn PieceTrait>;
SpecLoaded {
Disabled => None,
Counting => Some(OccKG::Visible),
Enabled => {
- let displace = OccDisplacement::Stack { pos: gpc.pos };
+ let pos = (|| {
+ (gpc.pos + self.stack_pos).ok()?
+ .clamped(gs.table_size).ok()
+ })().ok_or_else(|| Ia::PosOffTable)?;
+ let displace = OccDisplacement::Stack { pos };
let displace = (displace, gpc.zlevel.z.clone());
Some(OccKG::Displaced(displace))
},
pub edge_width: Option<f64>,
pub shape: Outline,
pub label: Option<PieceLabel>,
+ #[serde(default)] pub stack_pos: [Coord; 2],
}
}