2016-10-15 04:22:02 +00:00
|
|
|
use avm1;
|
2016-09-09 04:19:51 +00:00
|
|
|
use std::collections::HashSet;
|
|
|
|
|
2016-08-29 07:51:32 +00:00
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
pub struct Swf {
|
|
|
|
pub version: u8,
|
|
|
|
pub compression: Compression,
|
|
|
|
pub stage_size: Rectangle,
|
|
|
|
pub frame_rate: f32,
|
|
|
|
pub num_frames: u16,
|
|
|
|
pub tags: Vec<Tag>,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Defines the compression type used in an SWF.
|
|
|
|
#[derive(Debug,PartialEq,Eq)]
|
|
|
|
pub enum Compression {
|
|
|
|
None,
|
|
|
|
Zlib,
|
|
|
|
Lzma,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
pub struct Rectangle {
|
|
|
|
pub x_min: f32,
|
|
|
|
pub x_max: f32,
|
|
|
|
pub y_min: f32,
|
|
|
|
pub y_max: f32,
|
|
|
|
}
|
|
|
|
|
2016-09-09 06:29:12 +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,
|
|
|
|
}
|
|
|
|
|
2016-09-14 01:55:13 +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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct Matrix {
|
|
|
|
pub translate_x: f32,
|
|
|
|
pub translate_y: f32,
|
|
|
|
pub scale_x: f32,
|
|
|
|
pub scale_y: f32,
|
|
|
|
pub rotate_skew_0: f32,
|
|
|
|
pub rotate_skew_1: f32,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Matrix {
|
|
|
|
pub fn new() -> Matrix {
|
2016-08-29 20:32:56 +00:00
|
|
|
Matrix {
|
|
|
|
translate_x: 0f32,
|
|
|
|
translate_y: 0f32,
|
|
|
|
scale_x: 1f32,
|
|
|
|
scale_y: 1f32,
|
2016-08-30 00:00:43 +00:00
|
|
|
rotate_skew_0: 0f32,
|
|
|
|
rotate_skew_1: 0f32,
|
2016-08-29 20:32:56 +00:00
|
|
|
}
|
2016-08-29 07:51:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
pub struct FrameLabel {
|
|
|
|
pub frame_num: u32,
|
|
|
|
pub label: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type Depth = i16;
|
|
|
|
pub type CharacterId = u16;
|
|
|
|
pub type Twips = i32;
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
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>,
|
2016-09-06 18:50:36 +00:00
|
|
|
pub filters: Vec<Filter>,
|
2016-09-08 02:59:59 +00:00
|
|
|
pub background_color: Option<Color>,
|
|
|
|
pub blend_mode: BlendMode,
|
|
|
|
pub clip_actions: Vec<ClipAction>,
|
2016-09-09 06:02:43 +00:00
|
|
|
pub is_image: bool,
|
2016-09-06 18:50:36 +00:00
|
|
|
pub is_bitmap_cached: bool,
|
|
|
|
pub is_visible: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone,Copy)]
|
|
|
|
pub enum PlaceObjectAction {
|
2016-09-08 02:59:59 +00:00
|
|
|
Place(CharacterId),
|
2016-09-06 18:50:36 +00:00
|
|
|
Modify,
|
|
|
|
Replace(CharacterId),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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>),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-09-09 06:29:12 +00:00
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
pub struct ColorMatrixFilter {
|
2016-09-09 07:05:07 +00:00
|
|
|
pub matrix: [f64; 20],
|
2016-09-09 06:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Eq,Clone,Copy)]
|
|
|
|
pub enum BlendMode {
|
|
|
|
Normal,
|
|
|
|
Layer,
|
|
|
|
Multiply,
|
|
|
|
Screen,
|
|
|
|
Lighten,
|
|
|
|
Darken,
|
|
|
|
Difference,
|
|
|
|
Add,
|
|
|
|
Subtract,
|
|
|
|
Invert,
|
|
|
|
Alpha,
|
|
|
|
Erase,
|
|
|
|
Overlay,
|
|
|
|
HardLight,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Eq,Clone)]
|
|
|
|
pub struct ClipAction {
|
2016-09-09 04:19:51 +00:00
|
|
|
pub events: HashSet<ClipEvent>,
|
2016-09-06 18:50:36 +00:00
|
|
|
pub key_code: Option<u8>,
|
2016-09-09 01:17:14 +00:00
|
|
|
pub action_data: Vec<u8>,
|
2016-09-06 18:50:36 +00:00
|
|
|
}
|
|
|
|
|
2016-09-09 04:19:51 +00:00
|
|
|
#[derive(Debug,PartialEq,Eq,Clone,Copy,Hash)]
|
2016-09-06 18:50:36 +00:00
|
|
|
pub enum ClipEvent {
|
|
|
|
KeyUp,
|
|
|
|
KeyDown,
|
|
|
|
MouseUp,
|
|
|
|
MouseDown,
|
|
|
|
MouseMove,
|
|
|
|
Unload,
|
|
|
|
EnterFrame,
|
|
|
|
Load,
|
|
|
|
DragOver,
|
|
|
|
RollOut,
|
|
|
|
RollOver,
|
|
|
|
ReleaseOutside,
|
|
|
|
Release,
|
|
|
|
Press,
|
|
|
|
Initialize,
|
2016-09-09 01:17:14 +00:00
|
|
|
Data,
|
2016-09-06 18:50:36 +00:00
|
|
|
Construct,
|
2016-09-09 01:17:14 +00:00
|
|
|
KeyPress,
|
|
|
|
DragOut,
|
2016-08-29 07:51:32 +00:00
|
|
|
}
|
|
|
|
|
2016-09-09 04:19:51 +00:00
|
|
|
pub type ClipEventFlags = HashSet<ClipEvent>;
|
|
|
|
|
2016-08-29 07:51:32 +00:00
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
pub enum Tag {
|
2016-09-10 21:48:02 +00:00
|
|
|
ExportAssets(Vec<ExportedAsset>),
|
2016-09-10 23:18:19 +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>),
|
2016-09-11 03:12:27 +00:00
|
|
|
DefineBinaryData { id: CharacterId, data: Vec<u8> },
|
2016-12-16 23:57:29 +00:00
|
|
|
DefineBits { id: CharacterId, jpeg_data: Vec<u8> },
|
2016-12-17 00:52:03 +00:00
|
|
|
DefineBitsJpeg2 { id: CharacterId, jpeg_data: Vec<u8> },
|
2016-09-14 01:55:13 +00:00
|
|
|
DefineButton(Box<Button>),
|
2016-09-17 19:40:50 +00:00
|
|
|
DefineButton2(Box<Button>),
|
2016-09-14 03:36:15 +00:00
|
|
|
DefineButtonColorTransform { id: CharacterId, color_transforms: Vec<ColorTransform> },
|
|
|
|
DefineButtonSound(Box<ButtonSounds>),
|
2016-09-11 00:22:57 +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),
|
2016-09-11 00:44:37 +00:00
|
|
|
DoAbc(Vec<u8>),
|
2016-10-15 04:22:02 +00:00
|
|
|
DoAction(Vec<avm1::types::Action>),
|
2016-09-11 00:44:37 +00:00
|
|
|
DoInitAction { id: CharacterId, action_data: Vec<u8> },
|
2016-09-10 23:11:22 +00:00
|
|
|
EnableDebugger(String),
|
2016-09-11 20:20:31 +00:00
|
|
|
EnableTelemetry { password_hash: Vec<u8> },
|
2016-09-11 00:02:10 +00:00
|
|
|
Metadata(String),
|
2016-09-10 22:10:40 +00:00
|
|
|
ImportAssets { url: String, imports: Vec<ExportedAsset> },
|
2016-12-16 23:57:29 +00:00
|
|
|
JpegTables(Vec<u8>),
|
2016-08-29 07:51:32 +00:00
|
|
|
SetBackgroundColor(Color),
|
2016-09-10 23:34:04 +00:00
|
|
|
SetTabIndex { depth: Depth, tab_index: u16 },
|
2016-09-14 00:38:51 +00:00
|
|
|
SoundStreamBlock(Vec<u8>),
|
2016-09-14 00:29:59 +00:00
|
|
|
SoundStreamHead(Box<SoundStreamInfo>),
|
|
|
|
SoundStreamHead2(Box<SoundStreamInfo>),
|
2016-09-12 00:03:55 +00:00
|
|
|
StartSound { id: CharacterId, sound_info: Box<SoundInfo> },
|
2016-09-13 06:50:36 +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>),
|
2016-09-08 05:48:20 +00:00
|
|
|
RemoveObject { depth: Depth, character_id: Option<CharacterId> },
|
2016-08-29 07:51:32 +00:00
|
|
|
|
|
|
|
FileAttributes(FileAttributes),
|
|
|
|
|
2016-09-10 07:26:46 +00:00
|
|
|
FrameLabel { label: String, is_anchor: bool },
|
2016-08-29 20:32:56 +00:00
|
|
|
DefineSceneAndFrameLabelData {
|
|
|
|
scenes: Vec<FrameLabel>,
|
|
|
|
frame_labels: Vec<FrameLabel>,
|
|
|
|
},
|
2016-08-29 07:51:32 +00:00
|
|
|
|
|
|
|
Unknown { tag_code: u16, data: Vec<u8> },
|
|
|
|
}
|
|
|
|
|
2016-09-10 21:48:02 +00:00
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
pub struct ExportedAsset {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub name: String,
|
|
|
|
}
|
|
|
|
|
2016-09-10 23:55:09 +00:00
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
pub struct SymbolClassLink {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub class_name: String
|
|
|
|
}
|
|
|
|
|
2016-08-29 07:51:32 +00:00
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
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>,
|
|
|
|
}
|
|
|
|
|
2016-09-11 19:56:08 +00:00
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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>,
|
|
|
|
}
|
|
|
|
|
2016-09-12 00:03:55 +00:00
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
pub struct SoundInfo {
|
|
|
|
pub event: SoundEvent,
|
|
|
|
pub in_sample: Option<u32>,
|
|
|
|
pub out_sample: Option<u32>,
|
|
|
|
pub num_loops: u16,
|
|
|
|
pub envelope: Option<SoundEnvelope>,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone,Copy)]
|
|
|
|
pub enum SoundEvent {
|
|
|
|
Event,
|
|
|
|
Start,
|
|
|
|
Stop,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type SoundEnvelope = Vec<SoundEnvelopePoint>;
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
pub struct SoundEnvelopePoint {
|
|
|
|
pub sample: u32,
|
|
|
|
pub left_volume: f32,
|
|
|
|
pub right_volume: f32,
|
|
|
|
}
|
|
|
|
|
2016-09-08 05:08:24 +00:00
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
pub struct Sprite {
|
|
|
|
pub id: CharacterId,
|
|
|
|
pub num_frames: u16,
|
|
|
|
pub tags: Vec<Tag>,
|
|
|
|
}
|
|
|
|
|
2016-08-29 07:51:32 +00:00
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
pub struct ShapeStyles {
|
|
|
|
pub fill_styles: Vec<FillStyle>,
|
|
|
|
pub line_styles: Vec<LineStyle>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
pub enum ShapeRecord {
|
|
|
|
// TODO: Twips
|
|
|
|
StyleChange(StyleChangeData),
|
|
|
|
StraightEdge { delta_x: f32, delta_y: f32 },
|
2016-08-29 20:32:56 +00:00
|
|
|
CurvedEdge {
|
|
|
|
control_delta_x: f32,
|
|
|
|
control_delta_y: f32,
|
|
|
|
anchor_delta_x: f32,
|
|
|
|
anchor_delta_y: f32,
|
|
|
|
},
|
2016-08-29 07:51:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq)]
|
|
|
|
pub struct StyleChangeData {
|
2016-09-25 18:16:22 +00:00
|
|
|
pub move_to: Option<(f32, f32)>,
|
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>,
|
|
|
|
}
|
|
|
|
|
2016-09-22 07:52:56 +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
|
|
|
}
|
|
|
|
|
2016-09-22 07:52:56 +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>,
|
|
|
|
}
|
|
|
|
|
2016-09-22 07:52:56 +00:00
|
|
|
#[derive(Debug,PartialEq,Clone,Copy)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum GradientSpread {
|
|
|
|
Pad,
|
|
|
|
Reflect,
|
|
|
|
Repeat,
|
|
|
|
}
|
|
|
|
|
2016-09-22 07:52:56 +00:00
|
|
|
#[derive(Debug,PartialEq,Clone,Copy)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub enum GradientInterpolation {
|
|
|
|
RGB,
|
|
|
|
LinearRGB,
|
|
|
|
}
|
|
|
|
|
2016-09-09 06:29:12 +00:00
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct GradientRecord {
|
|
|
|
pub ratio: u8,
|
|
|
|
pub color: Color,
|
|
|
|
}
|
|
|
|
|
2016-09-22 07:52:56 +00:00
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
2016-08-29 07:51:32 +00:00
|
|
|
pub struct LineStyle {
|
|
|
|
pub width: u16, // Twips
|
|
|
|
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 {
|
|
|
|
pub fn new_v1(width: u16, color: Color) -> LineStyle {
|
|
|
|
LineStyle {
|
|
|
|
width: width,
|
|
|
|
color: color,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-09-11 19:56:08 +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
|
|
|
|
|
|
|
#[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
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone,Copy)]
|
|
|
|
pub enum AudioCompression {
|
|
|
|
UncompressedUnknownEndian,
|
|
|
|
Adpcm,
|
|
|
|
Mp3,
|
|
|
|
Uncompressed,
|
|
|
|
Nellymoser16Khz,
|
|
|
|
Nellymoser8Khz,
|
|
|
|
Nellymoser,
|
|
|
|
Speex,
|
2016-09-14 00:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
pub struct SoundFormat {
|
|
|
|
pub compression: AudioCompression,
|
|
|
|
pub sample_rate: u16,
|
|
|
|
pub is_stereo: bool,
|
|
|
|
pub is_16_bit: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
pub struct SoundStreamInfo {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Eq,Clone,Copy,Hash)]
|
|
|
|
pub enum ButtonState {
|
|
|
|
Up,
|
|
|
|
Over,
|
|
|
|
Down,
|
|
|
|
HitTest,
|
2016-09-14 03:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
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);
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Clone)]
|
|
|
|
pub struct ButtonAction {
|
|
|
|
pub conditions: HashSet<ButtonActionCondition>,
|
|
|
|
pub key_code: Option<u8>,
|
|
|
|
pub action_data: Vec<u8>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug,PartialEq,Eq,Clone,Copy,Hash)]
|
|
|
|
pub enum ButtonActionCondition {
|
|
|
|
IdleToOverDown,
|
|
|
|
OutDownToIdle,
|
|
|
|
OutDownToOverDown,
|
|
|
|
OverDownToOutDown,
|
|
|
|
OverDownToOverUp,
|
|
|
|
OverUpToOverDown,
|
|
|
|
OverUpToIdle,
|
|
|
|
IdleToOverUp,
|
|
|
|
OverDownToIdle,
|
|
|
|
KeyPress
|
|
|
|
}
|