aoe2_probe/prebuilt/ver1_46/
bitmap_info.rs1use std::sync::Arc;
2
3use crate::{parse::Token, utils::map::*};
4
5pub struct BitmapInfo;
6
7impl BitmapInfo {
8 pub fn template() -> Token {
9 let mut root = PatchedMap::with_capacity(13);
10 root.push_back("size", 0_i32);
11 root.push_back("width", 0_u32);
12 root.push_back("height", 0_u32);
13 root.push_back("planes", 0_i16);
14 root.push_back("bit_count", 0_i16);
15 root.push_back("compression", 0_u32);
16 root.push_back("image_size", 0_u32);
17 root.push_back("x_pels", 0_u32);
18 root.push_back("y_pels", 0_u32);
19 root.push_back("number_of_colors_used", 0_u32);
20 root.push_back("important_colors", 0_u32);
21
22 root.push_back("colors_used", vec![0_u32.into()]);
23
24 root.patches.insert(
25 "colors_used".to_string(),
26 Arc::new(|map: &mut PatchedMap, template: &mut Token| {
27 if map.contains("number_of_colors_used") {
28 let count = *map["number_of_colors_used"].try_u32();
29 let unit = template.try_vec()[0].clone();
30 let vec = template.try_mut_vec();
31 vec.clear();
32
33 for _ in 0..count {
34 vec.push(unit.clone());
35 }
36 }
37 }),
38 );
39
40 root.push_back("image", vec![0_u8.into()]);
41 root.patches.insert(
42 "image".to_string(),
43 Arc::new(|map: &mut PatchedMap, template: &mut Token| {
44 if map.contains("width") && map.contains("height") {
45 let count = *map["width"].try_u32() * *map["height"].try_u32();
46 let unit = template.try_vec()[0].clone();
47 let vec = template.try_mut_vec();
48 vec.clear();
49
50 for _ in 0..count {
51 vec.push(unit.clone());
52 }
53 }
54 }),
55 );
56
57 root.into()
58 }
59}