swf: Add NameCharacter tag
This commit is contained in:
parent
e40f7b3474
commit
56c260fa74
|
@ -587,6 +587,7 @@ impl<'a> Reader<'a> {
|
|||
|
||||
TagCode::VideoFrame => tag_reader.read_video_frame()?,
|
||||
TagCode::ProductInfo => Tag::ProductInfo(tag_reader.read_product_info()?),
|
||||
TagCode::NameCharacter => Tag::NameCharacter(tag_reader.read_name_character()?),
|
||||
};
|
||||
|
||||
if !tag_reader.input.is_empty() {
|
||||
|
@ -2595,6 +2596,16 @@ impl<'a> Reader<'a> {
|
|||
self.get_mut().read_exact(&mut debug_id)?;
|
||||
Ok(debug_id)
|
||||
}
|
||||
|
||||
pub fn read_name_character(&mut self) -> Result<NameCharacter<'a>> {
|
||||
// Not documented in SWF19 reference, and seems to be ignored by the official Flash Player.
|
||||
// Not generated by any version of the Flash IDE, but some 3rd party tools contain it.
|
||||
// See https://www.m2osw.com/swf_tag_namecharacter
|
||||
Ok(NameCharacter {
|
||||
id: self.read_character_id()?,
|
||||
name: self.read_str()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_compression_type<R: Read>(mut input: R) -> Result<Compression> {
|
||||
|
|
|
@ -41,7 +41,7 @@ pub enum TagCode {
|
|||
DefineEditText = 37,
|
||||
|
||||
DefineSprite = 39,
|
||||
|
||||
NameCharacter = 40,
|
||||
ProductInfo = 41,
|
||||
|
||||
FrameLabel = 43,
|
||||
|
|
|
@ -836,6 +836,7 @@ pub enum Tag<'a> {
|
|||
imports: Vec<ExportedAsset<'a>>,
|
||||
},
|
||||
JpegTables(JpegTables<'a>),
|
||||
NameCharacter(NameCharacter<'a>),
|
||||
SetBackgroundColor(SetBackgroundColor),
|
||||
SetTabIndex {
|
||||
depth: Depth,
|
||||
|
@ -1506,3 +1507,12 @@ pub struct ProductInfo {
|
|||
|
||||
/// `DebugId` is a UUID written to debug SWFs and used by the Flash Debugger.
|
||||
pub type DebugId = [u8; 16];
|
||||
|
||||
/// An undocumented and unused tag to set the instance name of a character.
|
||||
/// This seems to have no effect in the official Flash Player.
|
||||
/// Superseded by the PlaceObject2 tag.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct NameCharacter<'a> {
|
||||
pub id: CharacterId,
|
||||
pub name: &'a SwfStr,
|
||||
}
|
||||
|
|
|
@ -979,7 +979,7 @@ impl<W: Write> Writer<W> {
|
|||
}
|
||||
Tag::ProductInfo(ref product_info) => self.write_product_info(product_info)?,
|
||||
Tag::DebugId(ref debug_id) => self.write_debug_id(debug_id)?,
|
||||
|
||||
Tag::NameCharacter(ref name_character) => self.write_name_character(name_character)?,
|
||||
Tag::Unknown { tag_code, data } => {
|
||||
self.write_tag_code_and_length(tag_code, data.len() as u32)?;
|
||||
self.output.write_all(data)?;
|
||||
|
@ -2470,6 +2470,13 @@ impl<W: Write> Writer<W> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn write_name_character(&mut self, name_character: &NameCharacter) -> Result<()> {
|
||||
self.write_tag_header(TagCode::NameCharacter, 3 + name_character.name.len() as u32)?;
|
||||
self.write_character_id(name_character.id)?;
|
||||
self.write_string(name_character.name)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_tag_header(&mut self, tag_code: TagCode, length: u32) -> Result<()> {
|
||||
self.write_tag_code_and_length(tag_code as u16, length)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue