From: Ian Jackson Date: Sun, 12 Jul 2020 15:00:06 +0000 (+0100) Subject: abolish faffsome svg handling X-Git-Tag: otter-0.2.0~1354 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=8400ddf4712088bc3598ffd0ad75ac8980456ac9;p=otter.git abolish faffsome svg handling --- diff --git a/src/gamestate.rs b/src/gamestate.rs index e51876db..a1c39e6e 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -71,7 +71,6 @@ pub trait Piece : Send + Debug { fn svg_piece(&self, f: &mut String, pri: &PieceRenderInstructions) -> SR; fn outline_path(&self, pri : &PieceRenderInstructions) -> String; fn surround_path(&self, pri : &PieceRenderInstructions) -> String; - fn svg_x_ids(&self) -> VisiblePieceIdSvgIds; fn svg_x_defs(&self, pri : &PieceRenderInstructions) -> String; fn thresh_dragraise(&self, pri : &PieceRenderInstructions) -> Option; @@ -84,15 +83,6 @@ pub struct PieceRenderInstructions { pub face : FaceId, } -pub type VisiblePieceIdSvgIds = &'static [&'static str]; - -impl PieceRenderInstructions { - pub fn id_use(&self) -> String { format!("use{}", self.id) } - pub fn id_piece(&self) -> String { format!("piece{}", self.id) } - pub fn id_select(&self) -> String { format!("select{}", self.id) } - pub fn id_x(&self, w : &str) -> String { format!("def.{}.{}", self.id, w) } -} - // ========== implementations ========== // ---------- simple data types ---------- @@ -141,14 +131,14 @@ impl PieceState { Some(n) => n, None => -1, }; - write!(defs, r##""##, - pri.id_piece(), - dragraise)?; + write!(defs, + r##""##, + pri.id, dragraise)?; pr.p.svg_piece(&mut defs, &pri)?; write!(defs, r##""##)?; - write!(defs, r##""##, - pri.id_select(), - pr.p.surround_path(&pri))?; + write!(defs, + r##""##, + pri.id, pr.p.surround_path(&pri))?; write!(defs, "{}", pr.p.svg_x_defs(&pri))?; defs } diff --git a/src/pieces.rs b/src/pieces.rs index c6170e80..339c9560 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -93,18 +93,10 @@ impl Piece for SimpleShape { fn surround_path(&self, _pri : &PieceRenderInstructions) -> String { self.scaled_path.clone() } - /* - fn svg_select(&self, pri : &PieceRenderInstructions) -> String { - format!(r##""##, - SELECT_SCALE, - pri.id_x("base")) - } -*/ fn thresh_dragraise(&self, _pri : &PieceRenderInstructions) -> Option { Some(self.approx_dia / 2) } - fn svg_x_ids(&self) -> VisiblePieceIdSvgIds { &["base"] } fn svg_x_defs(&self, _pri : &PieceRenderInstructions) -> String { "".to_owned() } diff --git a/templates/script.ts b/templates/script.ts index cfc1c1aa..10633b6d 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -33,7 +33,7 @@ // generated by server, referenced by JS in pelem for selection // // #def.{}.stuff -// generated by server +// generated by server, reserved for Piece trait impl type PieceId = string; type PlayerId = string;