sokoban_elements/io/settings.rs
1use super::FileFormat;
2
3/// Settings for [`FileFormat`] writer.
4#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
5#[cfg_attr(
6 feature = "serde",
7 derive(serde::Serialize, serde::Deserialize),
8 serde(default)
9)]
10pub struct WriterSettings {
11 pub file_format: FileFormat,
12
13 /// Depending on this, printed game boards will use `-` (dash) to represent empty floors. This
14 /// is arguably more visible than default ` ` (space).
15 ///
16 /// This is most helpful for debugging sessions, otherwise really makes no difference.
17 ///
18 /// Textual representation of Hexoban boards is highly sensitive to whitespace. For that reason
19 /// this option is always ignored for Hexoban boards. When writing Hexoban boards, they always
20 /// behave as if this option was `true`.
21 pub print_visible_floor: bool,
22
23 /// Some file formats support RLE compressed game boards and saved games. Where applicable, use
24 /// `true` to produce this kind of output.
25 pub rle_encode: bool,
26
27 pub wrap_savegame_lines_at: u8,
28}
29
30impl Default for WriterSettings {
31 fn default() -> Self {
32 Self {
33 file_format: FileFormat::SokobanYASC,
34 print_visible_floor: false,
35 rle_encode: false,
36 wrap_savegame_lines_at: 70,
37 }
38 }
39}
40
41/// Settings for [`FileFormat`] reader.
42#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
43#[cfg_attr(
44 feature = "serde",
45 derive(serde::Serialize, serde::Deserialize),
46 serde(default)
47)]
48pub struct ReaderSettings {
49 pub file_format: FileFormat,
50
51 /// See [`SokobanPlus::parsed_legacy()`](crate::SokobanPlus::parsed_legacy()) to understand
52 /// this flag.
53 pub legacy_sokoban_plus: bool,
54}
55
56impl Default for ReaderSettings {
57 fn default() -> Self {
58 Self {
59 file_format: FileFormat::SokobanYASC,
60 legacy_sokoban_plus: false,
61 }
62 }
63}