1 // Copyright 2020-2021 Ian Jackson and contributors to Otter
2 // SPDX-License-Identifier: AGPL-3.0-or-later
3 // There is NO WARRANTY.
5 pub use crate::prelude::*;
7 #[doc(hidden)] pub type LLE = shapelib::LibraryLoadError;
9 // At the implementation level, each loaded item contains an
10 // `Arc<GroupDetails>`, which is simply stored directly. The
11 // `GroupDefn` is processed.
12 #[derive(Debug,Deserialize)]
13 pub struct GroupDefn {
15 #[serde(default)] pub item_prefix: String,
16 #[serde(default)] pub item_suffix: String,
17 #[serde(default)] pub sort: String,
18 #[serde(flatten)] pub d: GroupDetails,
21 #[derive(Debug,Deserialize)]
22 pub struct GroupDetails {
23 #[cfg(doc)]inherit: String, // handled specially
24 pub size: Vec<f64>, // scaled when put into GroupData
25 #[serde(default)] pub orig_size: Vec<f64>,
26 #[serde(default)] pub centre: Option<[f64; 2]>,
27 #[serde(default)] pub flip: bool,
28 #[serde(default)] pub back: Option<Box <dyn PieceSpec>>,
29 #[serde(default="num_traits::identities::One::one")] pub scale: f64,
30 #[serde(default)] pub colours: HashMap<String, RecolourData>,
31 pub desc_template: Option<String>,
32 pub occulted: Option<OccultationMethod>,
34 /// One of `"Circle"` or `"Rect"`, to define the outline shape.
35 /// The size is taken from `size`.
37 /// This value is a string, not some weird Rust type, despite
38 /// what you see here.
39 #[serde(flatten)] pub outline: Box<dyn shapelib::OutlineDefn>,
42 #[derive(Deserialize,Clone,Debug)]
43 #[serde(tag="method")]
44 pub enum OccultationMethod {
53 #[derive(Debug,Deserialize)]
54 pub struct RecolourData {
56 #[cfg(doc)] pub map: HashMap<String, String>,
60 #[derive(Deserialize,Debug)]
61 #[serde(try_from="String")]
62 pub struct FileList(pub Vec<FileData>);
64 #[derive(Deserialize,Debug)]
66 pub item_spec: String,
67 pub src_file_spec: String,
68 pub extra_fields: HashMap<String, String>,
73 /// `scraper`, specifying where and how to get updated piece SVGs.
75 /// Determines which scraper is run and the rest of the table
76 /// [`scraper`](LibraryTomlFile::scraper) is interpreted.
78 /// There are two methods available:
80 /// * `"none"`: Do not scrape anything. The SVGs in the Otter
81 /// source tree are hand-edited. The 2nd field in each
82 /// [`files`](GroupDefn::files) line
83 /// ([`r_file_spec`](FileData::r_file_spec)) is ignored.
85 /// * `"wikimedia"`: Scrape a site that uses Mediawiki the way that
86 /// Wikimedia does. In this case
87 /// [`scraper`](LibraryTomlFile::scraper) is a table containing the
88 /// fields of [`WikimediaScraper`], not just `method`.
90 /// * `"cards-oxymoron`": Special for that subdirectory.
95 /// Settings to go alongside `scraper = "wikimedia"`
97 /// TODO: Most fields here yet to be documented!
98 pub struct WikimediaScraper {
99 /// See [`method` in `Scraper`](Scraper::method). `"wikimedia"`