Mercurial > touhou
comparison formats/src/th06/anm0.rs @ 766:8a3b8e2ffa24
formats: Expose color_key on Anm0
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 30 Aug 2022 17:06:38 +0200 |
parents | 2a5279168d5a |
children |
comparison
equal
deleted
inserted
replaced
765:2a5279168d5a | 766:8a3b8e2ffa24 |
---|---|
53 pub struct Anm0 { | 53 pub struct Anm0 { |
54 /// Resolution of the image used by this ANM. | 54 /// Resolution of the image used by this ANM. |
55 pub size: (u32, u32), | 55 pub size: (u32, u32), |
56 | 56 |
57 /// Format of this ANM. | 57 /// Format of this ANM. |
58 // TODO: use an enum for that. | |
58 pub format: u32, | 59 pub format: u32, |
60 | |
61 /// Color key, probably used for transparency. | |
62 pub color_key: u32, | |
59 | 63 |
60 /// File name of the main image. | 64 /// File name of the main image. |
61 pub png_filename: String, | 65 pub png_filename: String, |
62 | 66 |
63 /// File name of an alpha channel image. | 67 /// File name of an alpha channel image. |
166 30 => fn ScaleIn(sx: f32, sy: f32, duration: u32), | 170 30 => fn ScaleIn(sx: f32, sy: f32, duration: u32), |
167 31 => fn Todo(todo: u32), | 171 31 => fn Todo(todo: u32), |
168 } | 172 } |
169 | 173 |
170 fn parse_anm0(input: &[u8]) -> IResult<&[u8], Anm0> { | 174 fn parse_anm0(input: &[u8]) -> IResult<&[u8], Anm0> { |
171 let (i, (num_sprites, num_scripts, _, width, height, format, _unknown1, | 175 let (i, (num_sprites, num_scripts, _, width, height, format, color_key, |
172 first_name_offset, _unused, second_name_offset, version, _unknown2, | 176 first_name_offset, _, second_name_offset, version, _, |
173 _texture_offset, has_data, _next_offset, unknown3)) = | 177 _texture_offset, has_data, _next_offset, _)) = |
174 tuple((le_u32, le_u32, tag(b"\0\0\0\0"), le_u32, le_u32, le_u32, le_u32, le_u32, | 178 tuple((le_u32, le_u32, tag(b"\0\0\0\0"), le_u32, le_u32, le_u32, le_u32, le_u32, |
175 le_u32, le_u32, le_u32, le_u32, le_u32, le_u32, le_u32, le_u32))(input)?; | 179 tag(b"\0\0\0\0"), le_u32, le_u32, tag(b"\0\0\0\0"), le_u32, le_u32, le_u32, |
180 tag(b"\0\0\0\0")))(input)?; | |
176 | 181 |
177 assert_eq!(version, 0); | 182 assert_eq!(version, 0); |
178 assert_eq!(unknown3, 0); | |
179 assert_eq!(has_data, 0); | 183 assert_eq!(has_data, 0); |
180 let num_sprites = num_sprites as usize; | 184 let num_sprites = num_sprites as usize; |
181 let num_scripts = num_scripts as usize; | 185 let num_scripts = num_scripts as usize; |
182 | 186 |
183 let (i, sprite_offsets) = many_m_n(num_sprites, num_sprites, le_u32)(i)?; | 187 let (i, sprite_offsets) = many_m_n(num_sprites, num_sprites, le_u32)(i)?; |
266 } | 270 } |
267 | 271 |
268 let anm0 = Anm0 { | 272 let anm0 = Anm0 { |
269 size: (width, height), | 273 size: (width, height), |
270 format, | 274 format, |
275 color_key, | |
271 png_filename, | 276 png_filename, |
272 alpha_filename, | 277 alpha_filename, |
273 sprites, | 278 sprites, |
274 scripts, | 279 scripts, |
275 }; | 280 }; |