1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
use df_ls_core::ReferenceTo;
use df_ls_lexical_analysis::test_utils::LexerTestBuilder;
use df_ls_structure::*;
use df_ls_syntax_analysis::test_utils::SyntaxTestBuilder;
use indexmap::indexmap;
#[test]
fn test_graphics() {
SyntaxTestBuilder::from_lexer_test_builder(
LexerTestBuilder::test_source(
"graphics_example
[OBJECT:GRAPHICS]
[TILE_PAGE:DWARVES]
[FILE:example/dwarves.bmp]
[TILE_DIM:16:16]
[PAGE_DIM:4:1]
[CREATURE_GRAPHICS:DWARF]
[DEFAULT:DWARVES:0:0:ADD_COLOR]
[MINER:DWARVES:1:0:AS_IS:DEFAULT]
Custom position example:
[MANAGER:DWARVES:2:0:AS_IS:DEFAULT]
[CREATURE_GRAPHICS:HORSE]
[DEFAULT:DWARVES:3:0:AS_IS:DEFAULT]
[CHILD:DWARVES:3:1:AS_IS:DEFAULT]
[CHILD:DWARVES:3:1:AS_IS:ANIMATED]
",
)
.add_test_lexer_diagnostics_codes(vec![])
.add_test_lexer_diagnostics_ranges(vec![]),
)
.add_test_structure(DFRaw {
header: "graphics_example".to_owned(),
token_structure: vec![ObjectToken {
graphics_tokens: vec![
GraphicsToken::TilePage(TilePageToken {
reference: Some(ReferenceTo::new("DWARVES".to_owned())),
file: Some("example/dwarves.bmp".to_owned()),
tile_dimensions: Some((16, 16)),
page_dimensions: Some((4, 1)),
}),
GraphicsToken::CreatureGraphics(CreatureGraphicsToken {
reference: Some(ReferenceTo::new("DWARF".to_owned())),
main_texture_tokens: indexmap! {
"DEFAULT".to_owned() => vec![(
ReferenceTo::new(
"DWARVES".to_owned(),
),
0,
0,
ColorTypeEnum::AddColor,
None,
)],
},
other_graphics_tokens: indexmap! {
"MINER".to_owned() => vec![(
ReferenceTo::new(
"DWARVES".to_owned(),
),
1,
0,
ColorTypeEnum::AsIs,
TextureTypeEnum::Default,
)],
"MANAGER".to_owned() => vec![(
ReferenceTo::new(
"DWARVES".to_owned(),
),
2,
0,
ColorTypeEnum::AsIs,
TextureTypeEnum::Default,
)],
},
}),
GraphicsToken::CreatureGraphics(CreatureGraphicsToken {
reference: Some(ReferenceTo::new("HORSE".to_owned())),
main_texture_tokens: indexmap! {
"DEFAULT".to_owned() => vec![(
ReferenceTo::new(
"DWARVES".to_owned(),
),
3,
0,
ColorTypeEnum::AsIs,
Some(TextureTypeEnum::Default),
)],
},
other_graphics_tokens: indexmap! {
"CHILD".to_owned() => vec![(
ReferenceTo::new(
"DWARVES".to_owned(),
),
3,
1,
ColorTypeEnum::AsIs,
TextureTypeEnum::Default,
),(
ReferenceTo::new(
"DWARVES".to_owned(),
),
3,
1,
ColorTypeEnum::AsIs,
TextureTypeEnum::Animated,
)],
},
}),
],
..Default::default()
}],
})
.add_test_syntax_diagnostics_codes(vec![])
.add_test_syntax_diagnostics_ranges(vec![])
.run_test();
}