Implement SymbolClass tag
This commit is contained in:
parent
8e88789994
commit
00a0086a96
14
src/read.rs
14
src/read.rs
|
@ -358,7 +358,7 @@ impl<R: Read> Reader<R> {
|
||||||
}
|
}
|
||||||
Tag::ImportAssets { url: url, imports: imports }
|
Tag::ImportAssets { url: url, imports: imports }
|
||||||
},
|
},
|
||||||
|
|
||||||
Some(TagCode::SetBackgroundColor) => {
|
Some(TagCode::SetBackgroundColor) => {
|
||||||
Tag::SetBackgroundColor(try!(tag_reader.read_rgb()))
|
Tag::SetBackgroundColor(try!(tag_reader.read_rgb()))
|
||||||
},
|
},
|
||||||
|
@ -379,6 +379,18 @@ impl<R: Read> Reader<R> {
|
||||||
tab_index: try!(tag_reader.read_u16()),
|
tab_index: try!(tag_reader.read_u16()),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Some(TagCode::SymbolClass) => {
|
||||||
|
let num_symbols = try!(tag_reader.read_u16());
|
||||||
|
let mut symbols = Vec::with_capacity(num_symbols as usize);
|
||||||
|
for _ in 0..num_symbols {
|
||||||
|
symbols.push(SymbolClassLink {
|
||||||
|
id: try!(tag_reader.read_u16()),
|
||||||
|
class_name: try!(tag_reader.read_c_string()),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Tag::SymbolClass(symbols)
|
||||||
|
},
|
||||||
|
|
||||||
Some(TagCode::ExportAssets) => {
|
Some(TagCode::ExportAssets) => {
|
||||||
let num_exports = try!(tag_reader.read_u16());
|
let num_exports = try!(tag_reader.read_u16());
|
||||||
let mut exports = Vec::with_capacity(num_exports as usize);
|
let mut exports = Vec::with_capacity(num_exports as usize);
|
||||||
|
|
|
@ -335,6 +335,15 @@ pub fn tag_tests() -> Vec<TagTestData> { vec![
|
||||||
|
|
||||||
(1, Tag::ShowFrame, vec![0b01_000000, 0]),
|
(1, Tag::ShowFrame, vec![0b01_000000, 0]),
|
||||||
|
|
||||||
|
(
|
||||||
|
9,
|
||||||
|
Tag::SymbolClass(vec![
|
||||||
|
SymbolClassLink { id: 2, class_name: "foo.Test".to_string() },
|
||||||
|
SymbolClassLink { id: 0, class_name: "DocumentTest".to_string() },
|
||||||
|
]),
|
||||||
|
read_tag_bytes_from_file("tests/swfs/symbolclass.swf", TagCode::SymbolClass)
|
||||||
|
),
|
||||||
|
|
||||||
(1, Tag::Unknown { tag_code: 512, data: vec![] }, vec![0b00_000000, 0b10000000]),
|
(1, Tag::Unknown { tag_code: 512, data: vec![] }, vec![0b00_000000, 0b10000000]),
|
||||||
(1, Tag::Unknown { tag_code: 513, data: vec![1, 2] }, vec![0b01_000010, 0b10000000, 1, 2]),
|
(1, Tag::Unknown { tag_code: 513, data: vec![1, 2] }, vec![0b01_000010, 0b10000000, 1, 2]),
|
||||||
(
|
(
|
||||||
|
|
|
@ -284,7 +284,7 @@ pub enum Tag {
|
||||||
ImportAssets { url: String, imports: Vec<ExportedAsset> },
|
ImportAssets { url: String, imports: Vec<ExportedAsset> },
|
||||||
SetBackgroundColor(Color),
|
SetBackgroundColor(Color),
|
||||||
SetTabIndex { depth: Depth, tab_index: u16 },
|
SetTabIndex { depth: Depth, tab_index: u16 },
|
||||||
|
SymbolClass(Vec<SymbolClassLink>),
|
||||||
PlaceObject(Box<PlaceObject>),
|
PlaceObject(Box<PlaceObject>),
|
||||||
RemoveObject { depth: Depth, character_id: Option<CharacterId> },
|
RemoveObject { depth: Depth, character_id: Option<CharacterId> },
|
||||||
|
|
||||||
|
@ -305,6 +305,12 @@ pub struct ExportedAsset {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug,PartialEq,Clone)]
|
||||||
|
pub struct SymbolClassLink {
|
||||||
|
pub id: CharacterId,
|
||||||
|
pub class_name: String
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug,PartialEq)]
|
#[derive(Debug,PartialEq)]
|
||||||
pub struct Shape {
|
pub struct Shape {
|
||||||
pub version: u8,
|
pub version: u8,
|
||||||
|
|
11
src/write.rs
11
src/write.rs
|
@ -405,6 +405,17 @@ impl<W: Write> Writer<W> {
|
||||||
try!(self.write_i16(depth));
|
try!(self.write_i16(depth));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
&Tag::SymbolClass(ref symbols) => {
|
||||||
|
let len = symbols.iter().map(|e| e.class_name.len() as u32 + 3).sum::<u32>()
|
||||||
|
+ 2;
|
||||||
|
try!(self.write_tag_header(TagCode::SymbolClass, len));
|
||||||
|
try!(self.write_u16(symbols.len() as u16));
|
||||||
|
for &SymbolClassLink {id, ref class_name} in symbols {
|
||||||
|
try!(self.write_u16(id));
|
||||||
|
try!(self.write_c_string(class_name));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
&Tag::FileAttributes(ref attributes) => {
|
&Tag::FileAttributes(ref attributes) => {
|
||||||
try!(self.write_tag_header(TagCode::FileAttributes, 4));
|
try!(self.write_tag_header(TagCode::FileAttributes, 4));
|
||||||
let mut flags = 0u32;
|
let mut flags = 0u32;
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue