2019-06-17 04:23:31 +00:00
|
|
|
//! The data structures used in an Adobe SWF file.
|
|
|
|
//!
|
2020-09-19 14:27:24 +00:00
|
|
|
//! These structures are documented in the Adobe SWF File Format Specification
|
2019-06-17 04:23:31 +00:00
|
|
|
//! version 19 (henceforth SWF19):
|
|
|
|
//! https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf
|
2019-12-01 19:05:25 +00:00
|
|
|
use enumset::{EnumSet, EnumSetType};
|
2016-09-09 04:19:51 +00:00
|
|
|
use std::collections::HashSet;
|
|
|
|
|
2020-05-19 16:50:37 +00:00
|
|
|
mod matrix;
|
|
|
|
|
|
|
|
pub use matrix::Matrix;
|
|
|
|
|
2019-06-17 04:23:31 +00:00
|
|
|
/// A complete header and tags in the SWF file.
|
|
|
|
/// This is returned by the `swf::read_swf` convenience method.
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct Swf {
|
2019-06-17 04:23:31 +00:00
|
|
|
pub header: Header,
|
|
|
|
pub tags: Vec<Tag>,
|
|
|
|
}
|
|
|
|
|
2019-10-10 20:07:07 +00:00
|
|
|
/// Returned by `read::read_swf_header`. Includes the decompress
|
|
|
|
/// stream as well as the uncompressed data length.
|
|
|
|
pub struct SwfStream<'a> {
|
|
|
|
pub header: Header,
|
2020-10-23 14:06:16 +00:00
|
|
|
pub uncompressed_length: usize,
|
2019-10-10 20:07:07 +00:00
|
|
|
pub reader: crate::read::Reader<Box<dyn std::io::Read + 'a>>,
|
|
|
|
}
|
|
|
|
|
2019-06-17 04:23:31 +00:00
|
|
|
/// The header of an SWF file.
|
|
|
|
///
|
|
|
|
/// Notably contains the compression format used by the rest of the SWF data.
|
|
|
|
///
|
|
|
|
/// [SWF19 p.27](https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf#page=27)
|
2019-11-12 20:05:18 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2019-06-17 04:23:31 +00:00
|
|
|
pub struct Header {
|
2020-10-23 10:04:28 +00:00
|
|
|
pub version: u8,
|
2020-10-23 14:06:16 +00:00
|
|
|
pub compression: Compression,
|
2016-08-29 07:51:32 +00:00
|
|
|
pub stage_size: Rectangle,
|
|
|
|
pub frame_rate: f32,
|
|
|
|
pub num_frames: u16,
|
|
|
|
}
|
|
|
|
|
2020-09-19 14:27:24 +00:00
|
|
|
/// The compression format used internally by the SWF file.
|
2019-06-17 04:23:31 +00:00
|
|
|
///
|
|
|
|
/// The vast majority of SWFs will use zlib compression.
|
|
|
|
/// [SWF19 p.27](https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf#page=27)
|
2019-11-12 20:05:18 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum Compression {
|
|
|
|
None,
|
|
|
|
Zlib,
|
|
|
|
Lzma,
|
|
|
|
}
|
|
|
|
|
2019-06-17 04:23:31 +00:00
|
|
|
/// Most coordinates in an SWF file are represented in "twips".
|
|
|
|
/// A twip is 1/20th of a pixel.
|
|
|
|
///
|
|
|
|
/// `Twips` is a type-safe wrapper type documenting where Twips are used
|
|
|
|
/// in the SWF format.
|
|
|
|
///
|
|
|
|
/// Use `Twips::from_pixels` and `Twips::to_pixels` to convert to and from
|
|
|
|
/// pixel values.
|
2019-05-17 04:32:18 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, PartialOrd, Ord)]
|
|
|
|
pub struct Twips(i32);
|
|
|
|
|
|
|
|
impl Twips {
|
2019-06-17 04:23:31 +00:00
|
|
|
/// There are 20 twips in a pixel.
|
2019-05-17 04:32:18 +00:00
|
|
|
pub const TWIPS_PER_PIXEL: f64 = 20.0;
|
|
|
|
|
2019-06-17 04:23:31 +00:00
|
|
|
/// Creates a new `Twips` object. Note that the `twips` value is in twips,
|
|
|
|
/// not pixels. Use `from_pixels` to convert from pixel units.
|
2019-05-17 04:32:18 +00:00
|
|
|
pub fn new<T: Into<i32>>(twips: T) -> Self {
|
|
|
|
Self(twips.into())
|
|
|
|
}
|
|
|
|
|
2020-05-21 14:45:22 +00:00
|
|
|
/// Creates a new `Twips` object set to the value of 0.
|
|
|
|
pub fn zero() -> Self {
|
|
|
|
Self(0)
|
|
|
|
}
|
|
|
|
|
2019-06-17 04:23:31 +00:00
|
|
|
/// Returns the number of twips.
|
2019-05-17 04:32:18 +00:00
|
|
|
pub fn get(self) -> i32 {
|
|
|
|
self.0
|
|
|
|
}
|
|
|
|
|
2019-06-17 04:23:31 +00:00
|
|
|
/// Converts the number of pixels into twips.
|
|
|
|
///
|
|
|
|
/// This may be a lossy conversion; any precision less than a twip (1/20 pixels) is truncated.
|
2019-05-17 04:32:18 +00:00
|
|
|
pub fn from_pixels(pixels: f64) -> Self {
|
|
|
|
Self((pixels * Self::TWIPS_PER_PIXEL) as i32)
|
|
|
|
}
|
|
|
|
|
2019-06-17 04:23:31 +00:00
|
|
|
/// Converts this twips value into pixel units.
|
|
|
|
///
|
|
|
|
/// This is a lossless operation.
|
2019-05-17 04:32:18 +00:00
|
|
|
pub fn to_pixels(self) -> f64 {
|
|
|
|
f64::from(self.0) / Self::TWIPS_PER_PIXEL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::ops::Add for Twips {
|
|
|
|
type Output = Self;
|
|
|
|
fn add(self, other: Self) -> Self {
|
|
|
|
Self(self.0 + other.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::ops::AddAssign for Twips {
|
|
|
|
fn add_assign(&mut self, other: Self) {
|
|
|
|
self.0 += other.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::ops::Sub for Twips {
|
|
|
|
type Output = Self;
|
|
|
|
fn sub(self, other: Self) -> Self {
|
|
|
|
Self(self.0 - other.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::ops::SubAssign for Twips {
|
|
|
|
fn sub_assign(&mut self, other: Self) {
|
|
|
|
self.0 -= other.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::ops::Mul<i32> for Twips {
|
|
|
|
type Output = Self;
|
|
|
|
fn mul(self, other: i32) -> Self {
|
|
|
|
Self(self.0 * other)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::ops::MulAssign<i32> for Twips {
|
|
|
|
fn mul_assign(&mut self, other: i32) {
|
|
|
|
self.0 *= other
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::ops::Div<i32> for Twips {
|
|
|
|
type Output = Self;
|
|
|
|
fn div(self, other: i32) -> Self {
|
|
|
|
Self(self.0 / other)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::ops::DivAssign<i32> for Twips {
|
|
|
|
fn div_assign(&mut self, other: i32) {
|
|
|
|
self.0 /= other
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for Twips {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
|
|
write!(f, "{}", self.to_pixels())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Clone, Default)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct Rectangle {
|
2019-05-17 04:32:18 +00:00
|
|
|
pub x_min: Twips,
|
|
|
|
pub x_max: Twips,
|
|
|
|
pub y_min: Twips,
|
|
|
|
pub y_max: Twips,
|
2016-08-29 07:51:32 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct Color {
|
|
|
|
pub r: u8,
|
|
|
|
pub g: u8,
|
|
|
|
pub b: u8,
|
|
|
|
pub a: u8,
|
|
|
|
}
|
|
|
|
|
2020-04-17 08:56:11 +00:00
|
|
|
impl Color {
|
|
|
|
pub fn from_rgb(rgb: u32, alpha: u8) -> Self {
|
|
|
|
Self {
|
|
|
|
r: ((rgb & 0xFF_0000) >> 16) as u8,
|
|
|
|
g: ((rgb & 0x00_FF00) >> 8) as u8,
|
|
|
|
b: (rgb & 0x00_00FF) as u8,
|
|
|
|
a: alpha,
|
|
|
|
}
|
|
|
|
}
|
2020-12-07 19:15:58 +00:00
|
|
|
pub fn to_rgb(&self) -> u32 {
|
|
|
|
((self.r as u32) << 16) | ((self.g as u32) << 8) | (self.b as u32)
|
|
|
|
}
|
2020-04-17 08:56:11 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct ColorTransform {
|
2016-09-08 02:59:59 +00:00
|
|
|
pub r_multiply: f32,
|
|
|
|
pub g_multiply: f32,
|
|
|
|
pub b_multiply: f32,
|
|
|
|
pub a_multiply: f32,
|
2016-08-29 07:51:32 +00:00
|
|
|
pub r_add: i16,
|
|
|
|
pub g_add: i16,
|
|
|
|
pub b_add: i16,
|
|
|
|
pub a_add: i16,
|
|
|
|
}
|
|
|
|
|
2016-09-14 01:55:13 +00:00
|
|
|
impl ColorTransform {
|
|
|
|
pub fn new() -> ColorTransform {
|
|
|
|
ColorTransform {
|
|
|
|
r_multiply: 1f32,
|
|
|
|
g_multiply: 1f32,
|
|
|
|
b_multiply: 1f32,
|
|
|
|
a_multiply: 1f32,
|
|
|
|
r_add: 0,
|
|
|
|
g_add: 0,
|
|
|
|
b_add: 0,
|
|
|
|
a_add: 0,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-24 22:03:40 +00:00
|
|
|
impl Default for ColorTransform {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-17 04:15:35 +00:00
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
|
|
|
pub enum Language {
|
|
|
|
Unknown,
|
|
|
|
Latin,
|
|
|
|
Japanese,
|
|
|
|
Korean,
|
|
|
|
SimplifiedChinese,
|
|
|
|
TraditionalChinese,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct FileAttributes {
|
|
|
|
pub use_direct_blit: bool,
|
|
|
|
pub use_gpu: bool,
|
|
|
|
pub has_metadata: bool,
|
|
|
|
pub is_action_script_3: bool,
|
|
|
|
pub use_network_sandbox: bool,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct FrameLabel {
|
2019-08-15 23:39:24 +00:00
|
|
|
pub label: String,
|
|
|
|
pub is_anchor: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct DefineSceneAndFrameLabelData {
|
|
|
|
pub scenes: Vec<FrameLabelData>,
|
|
|
|
pub frame_labels: Vec<FrameLabelData>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct FrameLabelData {
|
2016-08-29 07:51:32 +00:00
|
|
|
pub frame_num: u32,
|
|
|
|
pub label: String,
|
|
|
|
}
|
|
|
|
|
2019-12-17 06:47:22 +00:00
|
|
|
pub type Depth = u16;
|
2016-08-29 07:51:32 +00:00
|
|
|
pub type CharacterId = u16;
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct PlaceObject {
|
2016-09-06 18:50:36 +00:00
|
|
|
pub version: u8,
|
|
|
|
pub action: PlaceObjectAction,
|
2016-08-29 07:51:32 +00:00
|
|
|
pub depth: Depth,
|
|
|
|
pub matrix: Option<Matrix>,
|
2016-09-08 02:59:59 +00:00
|
|
|
pub color_transform: Option<ColorTransform>,
|
2016-09-06 18:50:36 +00:00
|
|
|
pub ratio: Option<u16>,
|
2016-08-29 07:51:32 +00:00
|
|
|
pub name: Option<String>,
|
2016-09-06 18:50:36 +00:00
|
|
|
pub clip_depth: Option<Depth>,
|
2016-09-08 02:59:59 +00:00
|
|
|
pub class_name: Option<String>,
|
2020-09-04 00:41:58 +00:00
|
|
|
pub filters: Option<Vec<Filter>>,
|
2016-09-08 02:59:59 +00:00
|
|
|
pub background_color: Option<Color>,
|
2020-09-04 00:41:58 +00:00
|
|
|
pub blend_mode: Option<BlendMode>,
|
|
|
|
pub clip_actions: Option<Vec<ClipAction>>,
|
2016-09-09 06:02:43 +00:00
|
|
|
pub is_image: bool,
|
2020-09-04 00:41:58 +00:00
|
|
|
pub is_bitmap_cached: Option<bool>,
|
|
|
|
pub is_visible: Option<bool>,
|
2017-02-25 04:11:28 +00:00
|
|
|
pub amf_data: Option<Vec<u8>>,
|
2016-09-06 18:50:36 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
2016-09-06 18:50:36 +00:00
|
|
|
pub enum PlaceObjectAction {
|
2016-09-08 02:59:59 +00:00
|
|
|
Place(CharacterId),
|
2016-09-06 18:50:36 +00:00
|
|
|
Modify,
|
|
|
|
Replace(CharacterId),
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-06 18:50:36 +00:00
|
|
|
pub enum Filter {
|
2016-09-09 06:29:12 +00:00
|
|
|
DropShadowFilter(Box<DropShadowFilter>),
|
|
|
|
BlurFilter(Box<BlurFilter>),
|
|
|
|
GlowFilter(Box<GlowFilter>),
|
2016-09-09 07:05:07 +00:00
|
|
|
BevelFilter(Box<BevelFilter>),
|
2016-09-09 06:29:12 +00:00
|
|
|
GradientGlowFilter(Box<GradientGlowFilter>),
|
|
|
|
ConvolutionFilter(Box<ConvolutionFilter>),
|
|
|
|
ColorMatrixFilter(Box<ColorMatrixFilter>),
|
|
|
|
GradientBevelFilter(Box<GradientBevelFilter>),
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-09 06:29:12 +00:00
|
|
|
pub struct DropShadowFilter {
|
|
|
|
pub color: Color,
|
|
|
|
pub blur_x: f64,
|
|
|
|
pub blur_y: f64,
|
|
|
|
pub angle: f64,
|
|
|
|
pub distance: f64,
|
|
|
|
pub strength: f32,
|
|
|
|
pub is_inner: bool,
|
2016-09-09 07:05:07 +00:00
|
|
|
pub is_knockout: bool,
|
2016-09-09 06:29:12 +00:00
|
|
|
pub num_passes: u8,
|
2016-09-06 18:50:36 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-09 06:29:12 +00:00
|
|
|
pub struct BlurFilter {
|
|
|
|
pub blur_x: f64,
|
|
|
|
pub blur_y: f64,
|
2016-09-09 07:05:07 +00:00
|
|
|
pub num_passes: u8,
|
2016-09-09 06:29:12 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-09 06:29:12 +00:00
|
|
|
pub struct GlowFilter {
|
|
|
|
pub color: Color,
|
|
|
|
pub blur_x: f64,
|
|
|
|
pub blur_y: f64,
|
|
|
|
pub strength: f32,
|
|
|
|
pub is_inner: bool,
|
2016-09-09 07:05:07 +00:00
|
|
|
pub is_knockout: bool,
|
2016-09-09 06:29:12 +00:00
|
|
|
pub num_passes: u8,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-09 06:29:12 +00:00
|
|
|
pub struct BevelFilter {
|
|
|
|
pub shadow_color: Color,
|
|
|
|
pub highlight_color: Color,
|
|
|
|
pub blur_x: f64,
|
|
|
|
pub blur_y: f64,
|
|
|
|
pub angle: f64,
|
|
|
|
pub distance: f64,
|
|
|
|
pub strength: f32,
|
|
|
|
pub is_inner: bool,
|
2016-09-09 07:05:07 +00:00
|
|
|
pub is_knockout: bool,
|
2016-09-09 06:29:12 +00:00
|
|
|
pub is_on_top: bool,
|
|
|
|
pub num_passes: u8,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-09 06:29:12 +00:00
|
|
|
pub struct GradientGlowFilter {
|
|
|
|
pub colors: Vec<GradientRecord>,
|
|
|
|
pub blur_x: f64,
|
|
|
|
pub blur_y: f64,
|
|
|
|
pub angle: f64,
|
|
|
|
pub distance: f64,
|
|
|
|
pub strength: f32,
|
|
|
|
pub is_inner: bool,
|
2016-09-09 07:05:07 +00:00
|
|
|
pub is_knockout: bool,
|
2016-09-10 06:49:57 +00:00
|
|
|
pub is_on_top: bool,
|
2016-09-09 06:29:12 +00:00
|
|
|
pub num_passes: u8,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-09 06:29:12 +00:00
|
|
|
pub struct ConvolutionFilter {
|
|
|
|
pub num_matrix_rows: u8,
|
|
|
|
pub num_matrix_cols: u8,
|
2016-09-09 07:05:07 +00:00
|
|
|
pub matrix: Vec<f64>,
|
|
|
|
pub divisor: f64,
|
|
|
|
pub bias: f64,
|
2016-09-09 06:29:12 +00:00
|
|
|
pub default_color: Color,
|
|
|
|
pub is_clamped: bool,
|
|
|
|
pub is_preserve_alpha: bool,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-09 06:29:12 +00:00
|
|
|
pub struct ColorMatrixFilter {
|
2016-09-09 07:05:07 +00:00
|
|
|
pub matrix: [f64; 20],
|
2016-09-09 06:29:12 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-09 06:29:12 +00:00
|
|
|
pub struct GradientBevelFilter {
|
2016-09-09 07:05:07 +00:00
|
|
|
pub colors: Vec<GradientRecord>,
|
|
|
|
pub blur_x: f64,
|
|
|
|
pub blur_y: f64,
|
|
|
|
pub angle: f64,
|
|
|
|
pub distance: f64,
|
|
|
|
pub strength: f32,
|
|
|
|
pub is_inner: bool,
|
|
|
|
pub is_knockout: bool,
|
|
|
|
pub is_on_top: bool,
|
|
|
|
pub num_passes: u8,
|
2016-09-09 06:29:12 +00:00
|
|
|
}
|
2016-09-06 18:50:36 +00:00
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
2016-09-06 18:50:36 +00:00
|
|
|
pub enum BlendMode {
|
|
|
|
Normal,
|
|
|
|
Layer,
|
|
|
|
Multiply,
|
|
|
|
Screen,
|
|
|
|
Lighten,
|
|
|
|
Darken,
|
|
|
|
Difference,
|
|
|
|
Add,
|
|
|
|
Subtract,
|
|
|
|
Invert,
|
|
|
|
Alpha,
|
|
|
|
Erase,
|
|
|
|
Overlay,
|
|
|
|
HardLight,
|
2017-06-24 19:56:49 +00:00
|
|
|
}
|
2016-09-06 18:50:36 +00:00
|
|
|
|
2019-12-01 19:05:25 +00:00
|
|
|
/// An clip action (a.k.a. clip event) placed on a movieclip instance.
|
|
|
|
/// Created in the Flash IDE using `onClipEvent` or `on` blocks.
|
|
|
|
///
|
|
|
|
/// [SWF19 pp.37-38 ClipActionRecord](https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf#page=37)
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
2016-09-06 18:50:36 +00:00
|
|
|
pub struct ClipAction {
|
2019-12-01 19:05:25 +00:00
|
|
|
pub events: EnumSet<ClipEventFlag>,
|
|
|
|
pub key_code: Option<KeyCode>,
|
2016-09-09 01:17:14 +00:00
|
|
|
pub action_data: Vec<u8>,
|
2016-09-06 18:50:36 +00:00
|
|
|
}
|
|
|
|
|
2019-12-01 19:05:25 +00:00
|
|
|
/// An event that can be attached to a movieclip instance using
|
|
|
|
/// an `onClipEvent` or `on` block.
|
|
|
|
///
|
|
|
|
/// [SWF19 pp.48-50 ClipEvent](https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf#page=38)
|
|
|
|
#[derive(Debug, EnumSetType)]
|
|
|
|
pub enum ClipEventFlag {
|
|
|
|
Construct,
|
|
|
|
Data,
|
|
|
|
DragOut,
|
|
|
|
DragOver,
|
|
|
|
EnterFrame,
|
|
|
|
Initialize,
|
2016-09-06 18:50:36 +00:00
|
|
|
KeyUp,
|
|
|
|
KeyDown,
|
2019-12-01 19:05:25 +00:00
|
|
|
KeyPress,
|
|
|
|
Load,
|
2016-09-06 18:50:36 +00:00
|
|
|
MouseUp,
|
|
|
|
MouseDown,
|
|
|
|
MouseMove,
|
2019-12-01 19:05:25 +00:00
|
|
|
Press,
|
2016-09-06 18:50:36 +00:00
|
|
|
RollOut,
|
|
|
|
RollOver,
|
|
|
|
Release,
|
2019-12-01 19:05:25 +00:00
|
|
|
ReleaseOutside,
|
|
|
|
Unload,
|
2016-08-29 07:51:32 +00:00
|
|
|
}
|
|
|
|
|
2019-12-01 19:05:25 +00:00
|
|
|
/// A key code used in `ButtonAction` and `ClipAction` key press events.
|
|
|
|
pub type KeyCode = u8;
|
2016-09-09 04:19:51 +00:00
|
|
|
|
2019-06-17 04:23:31 +00:00
|
|
|
/// Represents a tag in an SWF file.
|
|
|
|
///
|
|
|
|
/// The SWF format is made up of a stream of tags. Each tag either
|
|
|
|
/// defines a character (graphic, sound, movieclip), or places/modifies
|
|
|
|
/// an instance of these characters on the display list.
|
|
|
|
///
|
|
|
|
// [SWF19 p.29](https://www.adobe.com/content/dam/acom/en/devnet/pdf/swf-file-format-spec.pdf#page=29)
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum Tag {
|
2019-12-16 19:23:31 +00:00
|
|
|
ExportAssets(ExportAssets),
|
2017-06-24 19:56:49 +00:00
|
|
|
ScriptLimits {
|
|
|
|
max_recursion_depth: u16,
|
|
|
|
timeout_in_seconds: u16,
|
|
|
|
},
|
2016-08-29 07:51:32 +00:00
|
|
|
ShowFrame,
|
|
|
|
|
2016-09-10 08:57:23 +00:00
|
|
|
Protect(Option<String>),
|
2017-02-21 04:23:12 +00:00
|
|
|
CsmTextSettings(CsmTextSettings),
|
2019-08-16 16:56:49 +00:00
|
|
|
DebugId(DebugId),
|
2019-04-23 07:31:12 +00:00
|
|
|
DefineBinaryData {
|
|
|
|
id: CharacterId,
|
|
|
|
data: Vec<u8>,
|
|
|
|
},
|
|
|
|
DefineBits {
|
|
|
|
id: CharacterId,
|
|
|
|
jpeg_data: Vec<u8>,
|
|
|
|
},
|
|
|
|
DefineBitsJpeg2 {
|
|
|
|
id: CharacterId,
|
|
|
|
jpeg_data: Vec<u8>,
|
|
|
|
},
|
2017-02-25 03:32:35 +00:00
|
|
|
DefineBitsJpeg3(DefineBitsJpeg3),
|
|
|
|
DefineBitsLossless(DefineBitsLossless),
|
2016-09-14 01:55:13 +00:00
|
|
|
DefineButton(Box<Button>),
|
2016-09-17 19:40:50 +00:00
|
|
|
DefineButton2(Box<Button>),
|
2019-12-20 20:26:18 +00:00
|
|
|
DefineButtonColorTransform(ButtonColorTransform),
|
2016-09-14 03:36:15 +00:00
|
|
|
DefineButtonSound(Box<ButtonSounds>),
|
2017-02-16 21:42:19 +00:00
|
|
|
DefineEditText(Box<EditText>),
|
2017-02-21 00:40:53 +00:00
|
|
|
DefineFont(Box<FontV1>),
|
|
|
|
DefineFont2(Box<Font>),
|
2017-02-21 23:22:59 +00:00
|
|
|
DefineFont4(Font4),
|
2017-06-24 19:56:49 +00:00
|
|
|
DefineFontAlignZones {
|
|
|
|
id: CharacterId,
|
|
|
|
thickness: FontThickness,
|
|
|
|
zones: Vec<FontAlignZone>,
|
|
|
|
},
|
2017-02-13 04:22:22 +00:00
|
|
|
DefineFontInfo(Box<FontInfo>),
|
2017-06-24 19:56:49 +00:00
|
|
|
DefineFontName {
|
|
|
|
id: CharacterId,
|
|
|
|
name: String,
|
|
|
|
copyright_info: String,
|
|
|
|
},
|
2017-02-23 02:48:12 +00:00
|
|
|
DefineMorphShape(Box<DefineMorphShape>),
|
2017-06-24 19:56:49 +00:00
|
|
|
DefineScalingGrid {
|
|
|
|
id: CharacterId,
|
|
|
|
splitter_rect: Rectangle,
|
|
|
|
},
|
2016-08-29 07:51:32 +00:00
|
|
|
DefineShape(Shape),
|
2016-09-11 19:56:08 +00:00
|
|
|
DefineSound(Box<Sound>),
|
2016-09-08 05:08:24 +00:00
|
|
|
DefineSprite(Sprite),
|
2017-02-16 03:07:08 +00:00
|
|
|
DefineText(Box<Text>),
|
2017-02-23 03:53:56 +00:00
|
|
|
DefineVideoStream(DefineVideoStream),
|
2017-08-26 08:18:51 +00:00
|
|
|
DoAbc(DoAbc),
|
2019-07-23 01:29:39 +00:00
|
|
|
DoAction(DoAction),
|
2017-06-24 19:56:49 +00:00
|
|
|
DoInitAction {
|
|
|
|
id: CharacterId,
|
|
|
|
action_data: Vec<u8>,
|
|
|
|
},
|
2016-09-10 23:11:22 +00:00
|
|
|
EnableDebugger(String),
|
2019-04-23 07:31:12 +00:00
|
|
|
EnableTelemetry {
|
|
|
|
password_hash: Vec<u8>,
|
|
|
|
},
|
2019-06-17 10:23:29 +00:00
|
|
|
End,
|
2016-09-11 00:02:10 +00:00
|
|
|
Metadata(String),
|
2017-06-24 19:56:49 +00:00
|
|
|
ImportAssets {
|
|
|
|
url: String,
|
|
|
|
imports: Vec<ExportedAsset>,
|
|
|
|
},
|
2019-07-23 01:29:39 +00:00
|
|
|
JpegTables(JpegTables),
|
|
|
|
SetBackgroundColor(SetBackgroundColor),
|
2019-04-23 07:31:12 +00:00
|
|
|
SetTabIndex {
|
|
|
|
depth: Depth,
|
|
|
|
tab_index: u16,
|
|
|
|
},
|
2019-07-23 01:29:39 +00:00
|
|
|
SoundStreamBlock(SoundStreamBlock),
|
|
|
|
SoundStreamHead(Box<SoundStreamHead>),
|
|
|
|
SoundStreamHead2(Box<SoundStreamHead>),
|
|
|
|
StartSound(StartSound),
|
2017-06-24 19:56:49 +00:00
|
|
|
StartSound2 {
|
|
|
|
class_name: String,
|
|
|
|
sound_info: Box<SoundInfo>,
|
|
|
|
},
|
2016-09-10 23:55:09 +00:00
|
|
|
SymbolClass(Vec<SymbolClassLink>),
|
2016-09-08 02:59:59 +00:00
|
|
|
PlaceObject(Box<PlaceObject>),
|
2019-07-23 01:29:39 +00:00
|
|
|
RemoveObject(RemoveObject),
|
2017-02-23 03:53:56 +00:00
|
|
|
VideoFrame(VideoFrame),
|
2016-08-29 07:51:32 +00:00
|
|
|
FileAttributes(FileAttributes),
|
|
|
|
|
2019-08-15 23:39:24 +00:00
|
|
|
FrameLabel(FrameLabel),
|
|
|
|
DefineSceneAndFrameLabelData(DefineSceneAndFrameLabelData),
|
2016-08-29 07:51:32 +00:00
|
|
|
|
2019-08-16 16:50:54 +00:00
|
|
|
ProductInfo(ProductInfo),
|
2016-08-29 07:51:32 +00:00
|
|
|
|
2019-04-23 07:31:12 +00:00
|
|
|
Unknown {
|
|
|
|
tag_code: u16,
|
|
|
|
data: Vec<u8>,
|
|
|
|
},
|
2016-08-29 07:51:32 +00:00
|
|
|
}
|
|
|
|
|
2019-12-16 19:23:31 +00:00
|
|
|
pub type ExportAssets = Vec<ExportedAsset>;
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-10 21:48:02 +00:00
|
|
|
pub struct ExportedAsset {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub name: String,
|
|
|
|
}
|
|
|
|
|
2019-07-23 01:29:39 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
|
|
|
pub struct RemoveObject {
|
|
|
|
pub depth: Depth,
|
|
|
|
pub character_id: Option<CharacterId>,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type SetBackgroundColor = Color;
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-10 23:55:09 +00:00
|
|
|
pub struct SymbolClassLink {
|
|
|
|
pub id: CharacterId,
|
2017-06-24 19:56:49 +00:00
|
|
|
pub class_name: String,
|
2016-09-10 23:55:09 +00:00
|
|
|
}
|
|
|
|
|
2020-08-21 06:25:31 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct Shape {
|
|
|
|
pub version: u8,
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub shape_bounds: Rectangle,
|
|
|
|
pub edge_bounds: Rectangle,
|
2016-09-11 02:37:34 +00:00
|
|
|
pub has_fill_winding_rule: bool,
|
|
|
|
pub has_non_scaling_strokes: bool,
|
|
|
|
pub has_scaling_strokes: bool,
|
2016-08-29 07:51:32 +00:00
|
|
|
pub styles: ShapeStyles,
|
|
|
|
pub shape: Vec<ShapeRecord>,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-11 19:56:08 +00:00
|
|
|
pub struct Sound {
|
|
|
|
pub id: CharacterId,
|
2016-09-14 00:29:59 +00:00
|
|
|
pub format: SoundFormat,
|
2016-09-11 19:56:08 +00:00
|
|
|
pub num_samples: u32,
|
|
|
|
pub data: Vec<u8>,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-12 00:03:55 +00:00
|
|
|
pub struct SoundInfo {
|
|
|
|
pub event: SoundEvent,
|
|
|
|
pub in_sample: Option<u32>,
|
|
|
|
pub out_sample: Option<u32>,
|
|
|
|
pub num_loops: u16,
|
|
|
|
pub envelope: Option<SoundEnvelope>,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
2016-09-12 00:03:55 +00:00
|
|
|
pub enum SoundEvent {
|
|
|
|
Event,
|
|
|
|
Start,
|
|
|
|
Stop,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type SoundEnvelope = Vec<SoundEnvelopePoint>;
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-12 00:03:55 +00:00
|
|
|
pub struct SoundEnvelopePoint {
|
|
|
|
pub sample: u32,
|
|
|
|
pub left_volume: f32,
|
|
|
|
pub right_volume: f32,
|
|
|
|
}
|
|
|
|
|
2019-07-23 01:29:39 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct StartSound {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub sound_info: Box<SoundInfo>,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq)]
|
2016-09-08 05:08:24 +00:00
|
|
|
pub struct Sprite {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub num_frames: u16,
|
|
|
|
pub tags: Vec<Tag>,
|
|
|
|
}
|
|
|
|
|
2017-02-17 04:15:35 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct ShapeStyles {
|
|
|
|
pub fill_styles: Vec<FillStyle>,
|
|
|
|
pub line_styles: Vec<LineStyle>,
|
|
|
|
}
|
|
|
|
|
2017-02-17 04:15:35 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum ShapeRecord {
|
|
|
|
StyleChange(StyleChangeData),
|
2019-04-23 07:31:12 +00:00
|
|
|
StraightEdge {
|
2019-05-17 04:32:18 +00:00
|
|
|
delta_x: Twips,
|
|
|
|
delta_y: Twips,
|
2019-04-23 07:31:12 +00:00
|
|
|
},
|
2016-08-29 20:32:56 +00:00
|
|
|
CurvedEdge {
|
2019-05-17 04:32:18 +00:00
|
|
|
control_delta_x: Twips,
|
|
|
|
control_delta_y: Twips,
|
|
|
|
anchor_delta_x: Twips,
|
|
|
|
anchor_delta_y: Twips,
|
2016-08-29 20:32:56 +00:00
|
|
|
},
|
2016-08-29 07:51:32 +00:00
|
|
|
}
|
|
|
|
|
2017-02-17 04:15:35 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct StyleChangeData {
|
2019-05-17 04:32:18 +00:00
|
|
|
pub move_to: Option<(Twips, Twips)>,
|
2016-08-29 07:51:32 +00:00
|
|
|
pub fill_style_0: Option<u32>,
|
|
|
|
pub fill_style_1: Option<u32>,
|
|
|
|
pub line_style: Option<u32>,
|
|
|
|
pub new_styles: Option<ShapeStyles>,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum FillStyle {
|
|
|
|
Color(Color),
|
|
|
|
LinearGradient(Gradient),
|
|
|
|
RadialGradient(Gradient),
|
2016-08-29 20:32:56 +00:00
|
|
|
FocalGradient {
|
|
|
|
gradient: Gradient,
|
|
|
|
focal_point: f32,
|
|
|
|
},
|
|
|
|
Bitmap {
|
|
|
|
id: CharacterId,
|
|
|
|
matrix: Matrix,
|
|
|
|
is_smoothed: bool,
|
|
|
|
is_repeating: bool,
|
|
|
|
},
|
2016-08-29 07:51:32 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct Gradient {
|
2016-09-11 02:37:34 +00:00
|
|
|
pub matrix: Matrix,
|
2016-08-29 07:51:32 +00:00
|
|
|
pub spread: GradientSpread,
|
|
|
|
pub interpolation: GradientInterpolation,
|
|
|
|
pub records: Vec<GradientRecord>,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum GradientSpread {
|
|
|
|
Pad,
|
|
|
|
Reflect,
|
|
|
|
Repeat,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum GradientInterpolation {
|
|
|
|
RGB,
|
|
|
|
LinearRGB,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct GradientRecord {
|
|
|
|
pub ratio: u8,
|
|
|
|
pub color: Color,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct LineStyle {
|
2019-05-17 04:32:18 +00:00
|
|
|
pub width: Twips,
|
2016-08-29 07:51:32 +00:00
|
|
|
pub color: Color,
|
2016-09-11 02:37:34 +00:00
|
|
|
pub start_cap: LineCapStyle,
|
|
|
|
pub end_cap: LineCapStyle,
|
|
|
|
pub join_style: LineJoinStyle,
|
|
|
|
pub fill_style: Option<FillStyle>,
|
|
|
|
pub allow_scale_x: bool,
|
|
|
|
pub allow_scale_y: bool,
|
|
|
|
pub is_pixel_hinted: bool,
|
|
|
|
pub allow_close: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl LineStyle {
|
2019-05-17 04:32:18 +00:00
|
|
|
pub fn new_v1(width: Twips, color: Color) -> LineStyle {
|
2016-09-11 02:37:34 +00:00
|
|
|
LineStyle {
|
2019-04-23 07:24:33 +00:00
|
|
|
width,
|
|
|
|
color,
|
2016-09-11 02:37:34 +00:00
|
|
|
start_cap: LineCapStyle::Round,
|
|
|
|
end_cap: LineCapStyle::Round,
|
|
|
|
join_style: LineJoinStyle::Round,
|
|
|
|
fill_style: None,
|
|
|
|
allow_scale_x: false,
|
|
|
|
allow_scale_y: false,
|
|
|
|
is_pixel_hinted: false,
|
|
|
|
allow_close: true,
|
|
|
|
}
|
|
|
|
}
|
2016-08-29 07:51:32 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum LineCapStyle {
|
|
|
|
Round,
|
|
|
|
None,
|
|
|
|
Square,
|
|
|
|
}
|
2016-09-11 19:56:08 +00:00
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum LineJoinStyle {
|
|
|
|
Round,
|
|
|
|
Bevel,
|
|
|
|
Miter(f32),
|
2016-09-11 19:56:08 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
2016-09-11 19:56:08 +00:00
|
|
|
pub enum AudioCompression {
|
|
|
|
UncompressedUnknownEndian,
|
|
|
|
Adpcm,
|
|
|
|
Mp3,
|
|
|
|
Uncompressed,
|
|
|
|
Nellymoser16Khz,
|
|
|
|
Nellymoser8Khz,
|
|
|
|
Nellymoser,
|
|
|
|
Speex,
|
2016-09-14 00:29:59 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-14 00:29:59 +00:00
|
|
|
pub struct SoundFormat {
|
|
|
|
pub compression: AudioCompression,
|
|
|
|
pub sample_rate: u16,
|
|
|
|
pub is_stereo: bool,
|
|
|
|
pub is_16_bit: bool,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2019-07-23 01:29:39 +00:00
|
|
|
pub struct SoundStreamHead {
|
2016-09-14 00:29:59 +00:00
|
|
|
pub stream_format: SoundFormat,
|
|
|
|
pub playback_format: SoundFormat,
|
|
|
|
pub num_samples_per_block: u16,
|
|
|
|
pub latency_seek: i16,
|
2016-09-14 01:55:13 +00:00
|
|
|
}
|
|
|
|
|
2019-07-23 01:29:39 +00:00
|
|
|
pub type SoundStreamBlock = Vec<u8>;
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-14 01:55:13 +00:00
|
|
|
pub struct Button {
|
|
|
|
pub id: CharacterId,
|
2016-09-17 19:40:50 +00:00
|
|
|
pub is_track_as_menu: bool,
|
2016-09-14 01:55:13 +00:00
|
|
|
pub records: Vec<ButtonRecord>,
|
2016-09-17 19:40:50 +00:00
|
|
|
pub actions: Vec<ButtonAction>,
|
2016-09-14 01:55:13 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-14 01:55:13 +00:00
|
|
|
pub struct ButtonRecord {
|
|
|
|
pub states: HashSet<ButtonState>,
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub depth: Depth,
|
|
|
|
pub matrix: Matrix,
|
|
|
|
pub color_transform: ColorTransform,
|
|
|
|
pub filters: Vec<Filter>,
|
|
|
|
pub blend_mode: BlendMode,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
|
2016-09-14 01:55:13 +00:00
|
|
|
pub enum ButtonState {
|
|
|
|
Up,
|
|
|
|
Over,
|
|
|
|
Down,
|
|
|
|
HitTest,
|
2016-09-14 03:36:15 +00:00
|
|
|
}
|
|
|
|
|
2019-12-20 20:26:18 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
|
|
|
pub struct ButtonColorTransform {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub color_transforms: Vec<ColorTransform>,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-14 03:36:15 +00:00
|
|
|
pub struct ButtonSounds {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub over_to_up_sound: Option<ButtonSound>,
|
|
|
|
pub up_to_over_sound: Option<ButtonSound>,
|
|
|
|
pub over_to_down_sound: Option<ButtonSound>,
|
|
|
|
pub down_to_over_sound: Option<ButtonSound>,
|
|
|
|
}
|
|
|
|
|
2016-09-17 19:40:50 +00:00
|
|
|
pub type ButtonSound = (CharacterId, SoundInfo);
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Clone)]
|
2016-09-17 19:40:50 +00:00
|
|
|
pub struct ButtonAction {
|
|
|
|
pub conditions: HashSet<ButtonActionCondition>,
|
|
|
|
pub key_code: Option<u8>,
|
|
|
|
pub action_data: Vec<u8>,
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:56:49 +00:00
|
|
|
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
|
2016-09-17 19:40:50 +00:00
|
|
|
pub enum ButtonActionCondition {
|
|
|
|
IdleToOverDown,
|
|
|
|
OutDownToIdle,
|
|
|
|
OutDownToOverDown,
|
|
|
|
OverDownToOutDown,
|
|
|
|
OverDownToOverUp,
|
|
|
|
OverUpToOverDown,
|
|
|
|
OverUpToIdle,
|
|
|
|
IdleToOverUp,
|
|
|
|
OverDownToIdle,
|
2017-06-24 19:56:49 +00:00
|
|
|
KeyPress,
|
2017-02-11 01:57:25 +00:00
|
|
|
}
|
|
|
|
|
2017-02-23 02:48:12 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct DefineMorphShape {
|
|
|
|
pub version: u8,
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub has_non_scaling_strokes: bool,
|
|
|
|
pub has_scaling_strokes: bool,
|
|
|
|
pub start: MorphShape,
|
|
|
|
pub end: MorphShape,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct MorphShape {
|
|
|
|
pub shape_bounds: Rectangle,
|
|
|
|
pub edge_bounds: Rectangle,
|
|
|
|
pub fill_styles: Vec<FillStyle>,
|
|
|
|
pub line_styles: Vec<LineStyle>,
|
|
|
|
pub shape: Vec<ShapeRecord>,
|
|
|
|
}
|
|
|
|
|
2017-02-21 00:40:53 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct FontV1 {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub glyphs: Vec<Vec<ShapeRecord>>,
|
|
|
|
}
|
|
|
|
|
2017-02-17 04:15:35 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2017-02-11 01:57:25 +00:00
|
|
|
pub struct Font {
|
2017-02-21 00:40:53 +00:00
|
|
|
pub version: u8,
|
2017-02-11 01:57:25 +00:00
|
|
|
pub id: CharacterId,
|
2017-02-21 00:40:53 +00:00
|
|
|
pub name: String,
|
|
|
|
pub language: Language,
|
|
|
|
pub layout: Option<FontLayout>,
|
2017-02-11 01:57:25 +00:00
|
|
|
pub glyphs: Vec<Glyph>,
|
2017-02-21 00:40:53 +00:00
|
|
|
pub is_small_text: bool,
|
|
|
|
pub is_shift_jis: bool, // TODO(Herschel): Use enum for Shift-JIS/ANSI/UCS-2
|
|
|
|
pub is_ansi: bool,
|
|
|
|
pub is_bold: bool,
|
|
|
|
pub is_italic: bool,
|
|
|
|
}
|
|
|
|
|
2017-02-21 23:22:59 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct Font4 {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub is_italic: bool,
|
|
|
|
pub is_bold: bool,
|
|
|
|
pub name: String,
|
|
|
|
pub data: Option<Vec<u8>>,
|
|
|
|
}
|
|
|
|
|
2017-02-21 00:40:53 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct Glyph {
|
|
|
|
pub shape_records: Vec<ShapeRecord>,
|
|
|
|
pub code: u16,
|
|
|
|
pub advance: Option<i16>,
|
|
|
|
pub bounds: Option<Rectangle>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
|
|
pub struct FontLayout {
|
|
|
|
pub ascent: u16,
|
|
|
|
pub descent: u16,
|
|
|
|
pub leading: i16,
|
|
|
|
pub kerning: Vec<KerningRecord>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
|
|
pub struct KerningRecord {
|
|
|
|
pub left_code: u16,
|
|
|
|
pub right_code: u16,
|
2019-05-17 04:32:18 +00:00
|
|
|
pub adjustment: Twips,
|
2017-02-11 01:57:25 +00:00
|
|
|
}
|
|
|
|
|
2017-02-13 04:22:22 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct FontInfo {
|
|
|
|
pub id: CharacterId,
|
2017-02-17 04:15:35 +00:00
|
|
|
pub version: u8,
|
2017-02-13 04:22:22 +00:00
|
|
|
pub name: String,
|
|
|
|
pub is_small_text: bool,
|
|
|
|
pub is_shift_jis: bool,
|
|
|
|
pub is_ansi: bool,
|
|
|
|
pub is_bold: bool,
|
|
|
|
pub is_italic: bool,
|
2017-02-17 04:15:35 +00:00
|
|
|
pub language: Language,
|
2017-02-13 04:22:22 +00:00
|
|
|
pub code_table: Vec<u16>,
|
|
|
|
}
|
|
|
|
|
2017-02-16 03:07:08 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct Text {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub bounds: Rectangle,
|
|
|
|
pub matrix: Matrix,
|
|
|
|
pub records: Vec<TextRecord>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct TextRecord {
|
|
|
|
pub font_id: Option<CharacterId>,
|
|
|
|
pub color: Option<Color>,
|
2019-05-17 04:32:18 +00:00
|
|
|
pub x_offset: Option<Twips>,
|
|
|
|
pub y_offset: Option<Twips>,
|
2020-01-20 02:31:22 +00:00
|
|
|
pub height: Option<Twips>,
|
2017-02-16 03:07:08 +00:00
|
|
|
pub glyphs: Vec<GlyphEntry>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct GlyphEntry {
|
|
|
|
pub index: u32,
|
|
|
|
pub advance: i32,
|
|
|
|
}
|
2017-02-16 05:16:47 +00:00
|
|
|
|
2017-02-16 21:42:19 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct EditText {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub bounds: Rectangle,
|
|
|
|
pub font_id: Option<CharacterId>, // TODO(Herschel): Combine with height
|
|
|
|
pub font_class_name: Option<String>,
|
2020-01-20 01:52:59 +00:00
|
|
|
pub height: Option<Twips>,
|
2017-02-16 21:42:19 +00:00
|
|
|
pub color: Option<Color>,
|
|
|
|
pub max_length: Option<u16>,
|
|
|
|
pub layout: Option<TextLayout>,
|
|
|
|
pub variable_name: String,
|
|
|
|
pub initial_text: Option<String>,
|
|
|
|
pub is_word_wrap: bool,
|
|
|
|
pub is_multiline: bool,
|
|
|
|
pub is_password: bool,
|
|
|
|
pub is_read_only: bool,
|
|
|
|
pub is_auto_size: bool,
|
|
|
|
pub is_selectable: bool,
|
|
|
|
pub has_border: bool,
|
|
|
|
pub was_static: bool,
|
|
|
|
pub is_html: bool,
|
|
|
|
pub is_device_font: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct TextLayout {
|
|
|
|
pub align: TextAlign,
|
2019-05-17 04:32:18 +00:00
|
|
|
pub left_margin: Twips,
|
|
|
|
pub right_margin: Twips,
|
|
|
|
pub indent: Twips,
|
|
|
|
pub leading: Twips,
|
2017-02-16 21:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum TextAlign {
|
|
|
|
Left,
|
|
|
|
Center,
|
|
|
|
Right,
|
|
|
|
Justify,
|
|
|
|
}
|
|
|
|
|
2017-02-21 04:23:12 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct FontAlignZone {
|
|
|
|
// TODO(Herschel): Read these as f16s.
|
|
|
|
pub left: i16,
|
|
|
|
pub width: i16,
|
|
|
|
pub bottom: i16,
|
|
|
|
pub height: i16,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum FontThickness {
|
|
|
|
Thin,
|
|
|
|
Medium,
|
2017-06-24 19:56:49 +00:00
|
|
|
Thick,
|
2017-02-21 04:23:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct CsmTextSettings {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub use_advanced_rendering: bool,
|
|
|
|
pub grid_fit: TextGridFit,
|
|
|
|
pub thickness: f32, // TODO(Herschel): 0.0 is default. Should be Option?
|
|
|
|
pub sharpness: f32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum TextGridFit {
|
|
|
|
None,
|
|
|
|
Pixel,
|
|
|
|
SubPixel,
|
|
|
|
}
|
|
|
|
|
2017-02-16 05:16:47 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct DefineBitsLossless {
|
2017-02-25 03:32:35 +00:00
|
|
|
pub version: u8,
|
2017-02-16 05:16:47 +00:00
|
|
|
pub id: CharacterId,
|
|
|
|
pub format: BitmapFormat,
|
|
|
|
pub width: u16,
|
|
|
|
pub height: u16,
|
|
|
|
pub num_colors: u8,
|
|
|
|
pub data: Vec<u8>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum BitmapFormat {
|
|
|
|
ColorMap8,
|
|
|
|
Rgb15,
|
2017-02-25 03:32:35 +00:00
|
|
|
Rgb32,
|
2017-02-16 05:16:47 +00:00
|
|
|
}
|
2017-02-23 03:53:56 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct DefineVideoStream {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub num_frames: u16,
|
|
|
|
pub width: u16,
|
|
|
|
pub height: u16,
|
|
|
|
pub is_smoothed: bool,
|
|
|
|
pub deblocking: VideoDeblocking,
|
|
|
|
pub codec: VideoCodec,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum VideoDeblocking {
|
|
|
|
UseVideoPacketValue,
|
|
|
|
None,
|
|
|
|
Level1,
|
|
|
|
Level2,
|
|
|
|
Level3,
|
|
|
|
Level4,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
pub enum VideoCodec {
|
|
|
|
H263,
|
|
|
|
ScreenVideo,
|
|
|
|
VP6,
|
|
|
|
VP6WithAlpha,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct VideoFrame {
|
|
|
|
pub stream_id: CharacterId,
|
|
|
|
pub frame_num: u16,
|
|
|
|
pub data: Vec<u8>,
|
|
|
|
}
|
2017-02-25 03:32:35 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct DefineBitsJpeg3 {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub version: u8,
|
|
|
|
pub deblocking: f32,
|
|
|
|
pub data: Vec<u8>,
|
|
|
|
pub alpha_data: Vec<u8>,
|
|
|
|
}
|
2017-08-26 08:18:51 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
|
|
pub struct DoAbc {
|
|
|
|
pub name: String,
|
|
|
|
pub is_lazy_initialize: bool,
|
|
|
|
pub data: Vec<u8>,
|
|
|
|
}
|
2019-07-23 01:29:39 +00:00
|
|
|
|
|
|
|
pub type DoAction = Vec<u8>;
|
|
|
|
|
|
|
|
pub type JpegTables = Vec<u8>;
|
2019-08-16 16:50:54 +00:00
|
|
|
|
|
|
|
/// `ProductInfo` contains information about the software used to generate the SWF.
|
2019-08-16 16:56:49 +00:00
|
|
|
/// Not documented in the SWF19 reference. Emitted by mxmlc.
|
2019-08-16 16:50:54 +00:00
|
|
|
/// See http://wahlers.com.br/claus/blog/undocumented-swf-tags-written-by-mxmlc/
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
pub struct ProductInfo {
|
|
|
|
pub product_id: u32,
|
|
|
|
pub edition: u32,
|
|
|
|
pub major_version: u8,
|
|
|
|
pub minor_version: u8,
|
|
|
|
pub build_number: u64,
|
|
|
|
pub compilation_date: u64,
|
|
|
|
}
|
2019-08-16 16:56:49 +00:00
|
|
|
|
|
|
|
/// `DebugId` is a UUID written to debug SWFs and used by the Flash Debugger.
|
|
|
|
pub type DebugId = [u8; 16];
|