diff --git a/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfStreamReader.cs b/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfStreamReader.cs index 8575caf..72fdb95 100644 --- a/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfStreamReader.cs +++ b/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfStreamReader.cs @@ -93,6 +93,14 @@ namespace FlashTools.Internal.SwfTools { return _binaryReader.ReadUInt32(); } + public float ReadFloat32() { + return _binaryReader.ReadSingle(); + } + + public double ReadDouble64() { + return _binaryReader.ReadDouble(); + } + public int ReadSignedBits(uint count) { if ( count == 0 ) { return 0; diff --git a/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfTags/PlaceObject3Tag.cs b/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfTags/PlaceObject3Tag.cs index 39be08f..4957933 100644 --- a/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfTags/PlaceObject3Tag.cs +++ b/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfTags/PlaceObject3Tag.cs @@ -63,8 +63,20 @@ namespace FlashTools.Internal.SwfTools.SwfTags { if ( HasClipDepth ) { sb.AppendFormat(", ClipDepth: {0}", ClipDepth); } + if ( HasFilterList ) { + sb.AppendFormat(", SurfaceFilters: {0}", SurfaceFilters); + } + if ( HasBlendMode ) { + sb.AppendFormat(", BlendMode: {0}", BlendMode); + } + if ( HasCacheAsBitmap ) { + sb.AppendFormat(", BitmapCache: {0}", BitmapCache); + } + if ( HasVisible ) { + sb.AppendFormat(", Visible: {0}", Visible); + } if ( HasClipActions ) { - sb.AppendFormat(", ClipActions: {0}", HasClipActions); + sb.AppendFormat(", ClipActions: {0}", ClipActions); } return sb.ToString(); } diff --git a/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfTypes/SwfSurfaceFilters.cs b/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfTypes/SwfSurfaceFilters.cs index f95a7f6..c9464c6 100644 --- a/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfTypes/SwfSurfaceFilters.cs +++ b/Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfTypes/SwfSurfaceFilters.cs @@ -1,20 +1,169 @@ using UnityEngine; +using System.Collections.Generic; namespace FlashTools.Internal.SwfTools.SwfTypes { public struct SwfSurfaceFilters { + public enum FilterType { + DropShadow, + Blur, + Glow, + Bevel, + GradientGlow, + Convolution, + ColorMatrix, + GradientBevel + } + + public abstract class Filter { + public abstract FilterType Type { get; } + } + + public class DropShadowFilter : Filter { + public override FilterType Type { + get { return FilterType.DropShadow; } + } + } + + public class BlurFilter : Filter { + public override FilterType Type { + get { return FilterType.Blur; } + } + } + + public class GlowFilter : Filter { + public override FilterType Type { + get { return FilterType.Glow; } + } + } + + public class BevelFilter : Filter { + public override FilterType Type { + get { return FilterType.Bevel; } + } + } + + public class GradientGlowFilter : Filter { + public override FilterType Type { + get { return FilterType.GradientGlow; } + } + } + + public class ConvolutionFilter : Filter { + public override FilterType Type { + get { return FilterType.Convolution; } + } + } + + public class ColorMatrixFilter : Filter { + public override FilterType Type { + get { return FilterType.ColorMatrix; } + } + } + + public class GradientBevelFilter : Filter { + public override FilterType Type { + get { return FilterType.GradientBevel; } + } + } + + public List Filters; + public static SwfSurfaceFilters identity { get { - return new SwfSurfaceFilters(); + return new SwfSurfaceFilters{ + Filters = new List() + }; } } public static SwfSurfaceFilters Read(SwfStreamReader reader) { - //TODO: IMPLME - throw new UnityException("Surface filters is unsupported"); + var surface_filters = SwfSurfaceFilters.identity; + byte count = reader.ReadByte(); + for ( var i = 0; i < count; ++i ) { + surface_filters.Filters.Add(ReadFilter(reader)); + } + return surface_filters; } public override string ToString() { - return "SwfSurfaceFilters."; + return string.Format( + "SwfSurfaceFilters. Filters: {0}", + Filters.Count); + } + + // ------------------------------------------------------------------------ + // + // ReadFilters + // + // ------------------------------------------------------------------------ + + static Filter ReadFilter(SwfStreamReader reader) { + var type_id = reader.ReadByte(); + return CreateFilterFromTypeId(type_id, reader); + } + + static Filter CreateFilterFromTypeId(byte type_id, SwfStreamReader reader) { + switch ( type_id ) { + case 0: return ReadConcreteFilter(new DropShadowFilter (), reader); + case 1: return ReadConcreteFilter(new BlurFilter (), reader); + case 2: return ReadConcreteFilter(new GlowFilter (), reader); + case 3: return ReadConcreteFilter(new BevelFilter (), reader); + case 4: return ReadConcreteFilter(new GradientGlowFilter (), reader); + case 5: return ReadConcreteFilter(new ConvolutionFilter (), reader); + case 6: return ReadConcreteFilter(new ColorMatrixFilter (), reader); + case 7: return ReadConcreteFilter(new GradientBevelFilter(), reader); + default: + throw new UnityException(string.Format( + "Incorrect surface filter type id: {0}", type_id)); + } + } + + static Filter ReadConcreteFilter(DropShadowFilter filter, SwfStreamReader reader) { + //TODO: IMPLME + throw new UnityException(string.Format( + "Unsupported surface filter type: {0}", filter.Type)); + } + + static Filter ReadConcreteFilter(BlurFilter filter, SwfStreamReader reader) { + //TODO: IMPLME + throw new UnityException(string.Format( + "Unsupported surface filter type: {0}", filter.Type)); + } + + static Filter ReadConcreteFilter(GlowFilter filter, SwfStreamReader reader) { + //TODO: IMPLME + throw new UnityException(string.Format( + "Unsupported surface filter type: {0}", filter.Type)); + } + + static Filter ReadConcreteFilter(BevelFilter filter, SwfStreamReader reader) { + //TODO: IMPLME + throw new UnityException(string.Format( + "Unsupported surface filter type: {0}", filter.Type)); + } + + static Filter ReadConcreteFilter(GradientGlowFilter filter, SwfStreamReader reader) { + //TODO: IMPLME + throw new UnityException(string.Format( + "Unsupported surface filter type: {0}", filter.Type)); + } + + static Filter ReadConcreteFilter(ConvolutionFilter filter, SwfStreamReader reader) { + //TODO: IMPLME + throw new UnityException(string.Format( + "Unsupported surface filter type: {0}", filter.Type)); + } + + static Filter ReadConcreteFilter(ColorMatrixFilter filter, SwfStreamReader reader) { + //TODO: IMPLME + throw new UnityException(string.Format( + "Unsupported surface filter type: {0}", filter.Type)); + } + + static Filter ReadConcreteFilter(GradientBevelFilter filter, SwfStreamReader reader) { + //TODO: IMPLME + throw new UnityException(string.Format( + "Unsupported surface filter type: {0}", filter.Type)); } } } \ No newline at end of file