mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2026-01-06 08:26:52 +07:00
tags to separate files
This commit is contained in:
@@ -50,8 +50,29 @@
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\FlashAnimEditor.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\FlashAnimFtaPostprocessor.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\FlashAnimSwfPostprocessor.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\FlashAnimSwfTags.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\FlashAnimSwfUtils.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\DefineBitsLossless2Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\DefineBitsLosslessTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\DefineScalingGridTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\DefineSceneAndFrameLabelDataTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\DefineShape2Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\DefineShape3Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\DefineShape4Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\DefineShapeTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\DefineSpriteTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\EndTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\FileAttributesTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\FrameLabelTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\PlaceObject2Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\PlaceObject3Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\PlaceObjectTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\RemoveObject2Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\RemoveObjectTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\SetBackgroundColorTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\SetTabIndexTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\ShowFrameTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\SwfTagBase.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTags\UnknownTag.cs" />
|
||||
<None Include="Assets\FlashTools\Shaders\FlashAnim.shader" />
|
||||
<Reference Include="UnityEditor.Advertisements">
|
||||
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/Advertisements/Editor/UnityEditor.Advertisements.dll</HintPath>
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ionic.Zlib;
|
||||
using FlashTools.Internal.SwfTags;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
public class FlashAnimSwfPostprocessor : AssetPostprocessor {
|
||||
@@ -22,14 +23,86 @@ namespace FlashTools.Internal {
|
||||
|
||||
static void SwfAssetProcess(string swf_asset) {
|
||||
Debug.LogFormat("SwfAssetProcess: {0}", swf_asset);
|
||||
var reader = new SwfStreamReader(swf_asset);
|
||||
var header = SwfHeader.Read(reader);
|
||||
var raw_reader = new SwfStreamReader(swf_asset);
|
||||
var header = SwfHeader.Read(raw_reader);
|
||||
Debug.LogFormat("Header: {0}", header);
|
||||
while ( !reader.IsEOF ) {
|
||||
var tag_data = SwfTagData.Read(reader);
|
||||
var tag = SwfTagBase.Create(tag_data);
|
||||
Debug.LogFormat("Tag: {0} - {1}", tag.TagType.ToString(), tag.ToString());
|
||||
SwfStreamReader swf_reader;
|
||||
switch ( header.Format ) {
|
||||
case "FWS":
|
||||
swf_reader = raw_reader;
|
||||
SwfRect.Read(swf_reader);
|
||||
swf_reader.ReadFixedPoint8();
|
||||
swf_reader.Reader.ReadUInt16();
|
||||
break;
|
||||
case "CWS":
|
||||
var mem = new MemoryStream();
|
||||
Decompress(new MemoryStream(raw_reader.ReadRest()), mem);
|
||||
swf_reader = new SwfStreamReader(mem);
|
||||
SwfRect.Read(swf_reader);
|
||||
swf_reader.ReadFixedPoint8();
|
||||
swf_reader.Reader.ReadUInt16();
|
||||
|
||||
//var swf_rest = raw_reader.ReadRest();
|
||||
//var raw_rest = Decompress(swf_rest);
|
||||
//swf_reader = new SwfStreamReader(new MemoryStream(raw_rest));
|
||||
break;
|
||||
default:
|
||||
throw new UnityException(string.Format(
|
||||
"Unsupported swf format: {0}", header.Format));
|
||||
}
|
||||
while ( !swf_reader.IsEOF ) {
|
||||
var tag_data = SwfTagData.Read(swf_reader);
|
||||
var tag = SwfTagBase.Create(tag_data);
|
||||
if ( tag.TagType == SwfTagType.Unknown ) {
|
||||
Debug.LogWarningFormat("Tag: {0}", tag.ToString());
|
||||
} else {
|
||||
Debug.LogFormat("Tag: {0}", tag.ToString());
|
||||
}
|
||||
}
|
||||
//SwfBitmapsToAtlas(swf_asset, tags);
|
||||
}
|
||||
|
||||
/*
|
||||
static void SwfBitmapsToAtlas(string swf_asset, List<SwfTagBase> tags) {
|
||||
var defines = tags
|
||||
.Where(p => p.TagType == SwfTagType.DefineBitsLossless2)
|
||||
.Select(p => p as DefineBitsLossless2Tag)
|
||||
.Where(p => p.BitmapFormat == 5);
|
||||
var textures = new List<Texture2D>();
|
||||
foreach ( var define in defines ) {
|
||||
var data = Decompress(define.ZlibBitmapData);
|
||||
var texture = new Texture2D(
|
||||
define.BitmapWidth, define.BitmapHeight,
|
||||
TextureFormat.ARGB32, false);
|
||||
texture.LoadRawTextureData(data);
|
||||
textures.Add(texture);
|
||||
}
|
||||
var atlas = new Texture2D(0, 0);
|
||||
var atlas_path = Path.ChangeExtension(swf_asset, ".png");
|
||||
atlas.PackTextures(textures.ToArray(), 1, 1024);
|
||||
File.WriteAllBytes(atlas_path, atlas.EncodeToPNG());
|
||||
GameObject.DestroyImmediate(atlas, true);
|
||||
AssetDatabase.ImportAsset(
|
||||
atlas_path,
|
||||
ImportAssetOptions.ForceUncompressedImport);
|
||||
}*/
|
||||
|
||||
static void Decompress(Stream compressed, Stream target) {
|
||||
var zip = new ZlibStream(target, CompressionMode.Decompress);
|
||||
int readBytes;
|
||||
var buffer = new byte[512];
|
||||
do {
|
||||
readBytes = compressed.Read(buffer, 0, buffer.Length);
|
||||
zip.Write(buffer, 0, readBytes);
|
||||
} while (readBytes > 0);
|
||||
zip.Flush();
|
||||
target.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
static byte[] Decompress(byte[] compressed) {
|
||||
var mem = new MemoryStream();
|
||||
Decompress(new MemoryStream(compressed), mem);
|
||||
return mem.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,795 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Ionic.Zlib;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
enum SwfTagType : ushort {
|
||||
//
|
||||
// Display list
|
||||
//
|
||||
PlaceObject = 4,
|
||||
PlaceObject2 = 26,
|
||||
PlaceObject3 = 70,
|
||||
RemoveObject = 5,
|
||||
RemoveObject2 = 28,
|
||||
ShowFrame = 1,
|
||||
|
||||
//
|
||||
// Control
|
||||
//
|
||||
SetBackgroundColor = 9,
|
||||
FrameLabel = 43,
|
||||
//Protect = 24,
|
||||
End = 0,
|
||||
//ExportAssets = 56,
|
||||
//ImportAssets = 57,
|
||||
//EnableDebugger = 58,
|
||||
//EnableDebugger2 = 64,
|
||||
//ScriptLimits = 65,
|
||||
SetTabIndex = 66,
|
||||
//ImportAssets2 = 71,
|
||||
//SymbolClass = 76,
|
||||
//Metadata = 77,
|
||||
DefineScalingGrid = 78,
|
||||
DefineSceneAndFrameLabelData = 86,
|
||||
|
||||
//
|
||||
// Actions
|
||||
//
|
||||
//DoAction = 12,
|
||||
//DoInitAction = 59,
|
||||
//DoABC = 82,
|
||||
|
||||
//
|
||||
// Shape
|
||||
//
|
||||
DefineShape = 2,
|
||||
DefineShape2 = 22,
|
||||
DefineShape3 = 32,
|
||||
DefineShape4 = 83,
|
||||
|
||||
//
|
||||
// Bitmaps
|
||||
//
|
||||
DefineBits = 6,
|
||||
JPEGTables = 8,
|
||||
DefineBitsJPEG2 = 21,
|
||||
DefineBitsJPEG3 = 35,
|
||||
DefineBitsLossless = 20,
|
||||
DefineBitsLossless2 = 36,
|
||||
DefineBitsJPEG4 = 90,
|
||||
|
||||
//
|
||||
// Shape Morphing
|
||||
//
|
||||
//DefineMorphShape = 46,
|
||||
//DefineMorphShape2 = 84,
|
||||
|
||||
//
|
||||
// Fonts and Text
|
||||
//
|
||||
//DefineFont = 10,
|
||||
//DefineFontInfo = 13,
|
||||
//DefineFontInfo2 = 62,
|
||||
//DefineFont2 = 48,
|
||||
//DefineFont3 = 75,
|
||||
//DefineFontAlignZones = 73,
|
||||
//DefineFontName = 88,
|
||||
//DefineText = 11,
|
||||
//DefineText2 = 33,
|
||||
//DefineEditText = 37,
|
||||
//CSMTextSettings = 74,
|
||||
//DefineFont4 = 91,
|
||||
|
||||
//
|
||||
// Sounds
|
||||
//
|
||||
//DefineSound = 14,
|
||||
//StartSound = 15,
|
||||
//StartSound2 = 89,
|
||||
//SoundStreamHead = 18,
|
||||
//SoundStreamHead2 = 45,
|
||||
//SoundStreamBlock = 19,
|
||||
|
||||
//
|
||||
// Buttons
|
||||
//
|
||||
//DefineButton = 7,
|
||||
//DefineButton2 = 34,
|
||||
//DefineButtonCxform = 23,
|
||||
//DefineButtonSound = 17,
|
||||
|
||||
//
|
||||
// Sprites and Movie Clips
|
||||
//
|
||||
DefineSprite = 39,
|
||||
|
||||
//
|
||||
// Video
|
||||
//
|
||||
//DefineVideoStream = 60,
|
||||
//VideoFrame = 61,
|
||||
|
||||
//
|
||||
// Metadata
|
||||
//
|
||||
FileAttributes = 69,
|
||||
//EnableTelemetry = 93,
|
||||
//DefineBinaryData = 87,
|
||||
}
|
||||
|
||||
struct SwfTagData {
|
||||
public SwfTagType Type;
|
||||
public byte[] Data;
|
||||
|
||||
public static SwfTagData Read(SwfStreamReader reader) {
|
||||
var type_and_size = reader.Reader.ReadUInt16();
|
||||
var type = (SwfTagType)(type_and_size >> 6);
|
||||
var short_size = type_and_size & 0x3f;
|
||||
var size = short_size < 0x3f ? short_size : reader.Reader.ReadInt32();
|
||||
var tag_data = reader.Reader.ReadBytes(size);
|
||||
return new SwfTagData{Type = type, Data = tag_data};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SwfTagBase {
|
||||
public abstract SwfTagType TagType { get; }
|
||||
public static SwfTagBase Create(SwfTagData tag_data) {
|
||||
var stream = new MemoryStream(tag_data.Data);
|
||||
var reader = new SwfStreamReader(stream);
|
||||
switch ( tag_data.Type ) {
|
||||
case SwfTagType.PlaceObject: return PlaceObjectTag.Create(reader);
|
||||
case SwfTagType.PlaceObject2: return PlaceObject2Tag.Create(reader);
|
||||
case SwfTagType.PlaceObject3: return PlaceObject3Tag.Create(reader);
|
||||
case SwfTagType.RemoveObject: return RemoveObjectTag.Create(reader);
|
||||
case SwfTagType.RemoveObject2: return RemoveObject2Tag.Create(reader);
|
||||
case SwfTagType.ShowFrame: return ShowFrameTag.Create(reader);
|
||||
case SwfTagType.SetBackgroundColor: return SetBackgroundColorTag.Create(reader);
|
||||
case SwfTagType.FrameLabel: return FrameLabelTag.Create(reader);
|
||||
case SwfTagType.End: return EndTag.Create(reader);
|
||||
case SwfTagType.SetTabIndex: return SetTabIndexTag.Create(reader);
|
||||
case SwfTagType.DefineScalingGrid: return DefineScalingGridTag.Create(reader);
|
||||
case SwfTagType.DefineSceneAndFrameLabelData: return DefineSceneAndFrameLabelDataTag.Create(reader);
|
||||
case SwfTagType.DefineShape: return DefineShapeTag.Create(reader);
|
||||
case SwfTagType.DefineShape2: return DefineShape2Tag.Create(reader);
|
||||
case SwfTagType.DefineShape3: return DefineShape3Tag.Create(reader);
|
||||
case SwfTagType.DefineShape4: return DefineShape4Tag.Create(reader);
|
||||
//case DefineBits:
|
||||
//case JPEGTables:
|
||||
//case DefineBitsJPEG2:
|
||||
//case DefineBitsJPEG3:
|
||||
case SwfTagType.DefineBitsLossless: return DefineBitsLosslessTag.Create(reader);
|
||||
case SwfTagType.DefineBitsLossless2: return DefineBitsLossless2Tag.Create(reader);
|
||||
//case DefineBitsJPEG4:
|
||||
case SwfTagType.DefineSprite: return DefineSpriteTag.Create(reader);
|
||||
case SwfTagType.FileAttributes: return FileAttributesTag.Create(reader);
|
||||
default: return UnknownTag.Create(tag_data.Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlaceObjectTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public ushort Depth;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransformRGB ColorTransform;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"CharacterId: {0}, Depth: {1}, Matrix: {2}, ColorTransform: {3}",
|
||||
CharacterId, Depth, Matrix, ColorTransform);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.PlaceObject; }
|
||||
}
|
||||
|
||||
public static PlaceObjectTag Create(SwfStreamReader reader) {
|
||||
var tag = new PlaceObjectTag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
tag.Matrix = SwfMatrix.Read(reader);
|
||||
if ( !reader.IsEOF ) {
|
||||
tag.ColorTransform = SwfColorTransformRGB.Read(reader);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class PlaceObject2Tag : SwfTagBase {
|
||||
public bool HasClipActions;
|
||||
public bool HasClipDepth;
|
||||
public bool HasName;
|
||||
public bool HasRatio;
|
||||
public bool HasColorTransform;
|
||||
public bool HasMatrix;
|
||||
public bool HasCharacter;
|
||||
public bool Move;
|
||||
public ushort Depth;
|
||||
public ushort CharacterId;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransformRGBA ColorTransform;
|
||||
public ushort Ratio;
|
||||
public string Name;
|
||||
public ushort ClipDepth;
|
||||
public SwfClipActions ClipActions;
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder(1024);
|
||||
sb.AppendFormat("Move: {0} Depth: {1}", Move, Depth);
|
||||
if ( HasCharacter ) {
|
||||
sb.AppendFormat(" CharacterId: {0}", CharacterId);
|
||||
}
|
||||
if ( HasMatrix ) {
|
||||
sb.AppendFormat(" Matrix: {0}", Matrix);
|
||||
}
|
||||
if ( HasColorTransform ) {
|
||||
sb.AppendFormat(" ColorTransform: {0}", ColorTransform);
|
||||
}
|
||||
if ( HasRatio ) {
|
||||
sb.AppendFormat(" Ratio: {0}", Ratio);
|
||||
}
|
||||
if ( HasName ) {
|
||||
sb.AppendFormat(" Name: {0}", Name);
|
||||
}
|
||||
if ( HasClipDepth ) {
|
||||
sb.AppendFormat(" ClipDepth: {0}", ClipDepth);
|
||||
}
|
||||
if ( HasClipActions ) {
|
||||
sb.AppendFormat(" ClipActions: {0}", HasClipActions);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.PlaceObject2; }
|
||||
}
|
||||
|
||||
public static PlaceObject2Tag Create(SwfStreamReader reader) {
|
||||
var tag = new PlaceObject2Tag();
|
||||
tag.HasClipActions = reader.ReadBit();
|
||||
tag.HasClipDepth = reader.ReadBit();
|
||||
tag.HasName = reader.ReadBit();
|
||||
tag.HasRatio = reader.ReadBit();
|
||||
tag.HasColorTransform = reader.ReadBit();
|
||||
tag.HasMatrix = reader.ReadBit();
|
||||
tag.HasCharacter = reader.ReadBit();
|
||||
tag.Move = reader.ReadBit();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
if ( tag.HasCharacter ) {
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasMatrix ) {
|
||||
tag.Matrix = SwfMatrix.Read(reader);
|
||||
}
|
||||
if ( tag.HasColorTransform ) {
|
||||
tag.ColorTransform = SwfColorTransformRGBA.Read(reader);
|
||||
}
|
||||
if ( tag.HasRatio ) {
|
||||
tag.Ratio = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasName ) {
|
||||
tag.Name = reader.ReadString();
|
||||
}
|
||||
if ( tag.HasClipDepth ) {
|
||||
tag.ClipDepth = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasClipActions ) {
|
||||
tag.ClipActions = SwfClipActions.Read(reader);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class PlaceObject3Tag : SwfTagBase {
|
||||
public bool HasClipActions;
|
||||
public bool HasClipDepth;
|
||||
public bool HasName;
|
||||
public bool HasRatio;
|
||||
public bool HasColorTransform;
|
||||
public bool HasMatrix;
|
||||
public bool HasCharacter;
|
||||
public bool Move;
|
||||
public bool OpaqueBackground;
|
||||
public bool HasVisible;
|
||||
public bool HasImage;
|
||||
public bool HasClassName;
|
||||
public bool HasCacheAsBitmap;
|
||||
public bool HasBlendMode;
|
||||
public bool HasFilterList;
|
||||
public ushort Depth;
|
||||
public string ClassName;
|
||||
public ushort CharacterId;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransformRGBA ColorTransform;
|
||||
public ushort Ratio;
|
||||
public string Name;
|
||||
public ushort ClipDepth;
|
||||
public SwfSurfaceFilters SurfaceFilters;
|
||||
public SwfBlendMode BlendMode;
|
||||
public byte BitmapCache;
|
||||
public byte Visible;
|
||||
public SwfRGBA BackgroundColor;
|
||||
public SwfClipActions ClipActions;
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder(1024);
|
||||
sb.AppendFormat("Move: {0} Depth: {1}", Move, Depth);
|
||||
if ( HasCharacter ) {
|
||||
sb.AppendFormat(" CharacterId: {0}", CharacterId);
|
||||
}
|
||||
if ( HasMatrix ) {
|
||||
sb.AppendFormat(" Matrix: {0}", Matrix);
|
||||
}
|
||||
if ( HasColorTransform ) {
|
||||
sb.AppendFormat(" ColorTransform: {0}", ColorTransform);
|
||||
}
|
||||
if ( HasRatio ) {
|
||||
sb.AppendFormat(" Ratio: {0}", Ratio);
|
||||
}
|
||||
if ( HasName ) {
|
||||
sb.AppendFormat(" Name: {0}", Name);
|
||||
}
|
||||
if ( HasClipDepth ) {
|
||||
sb.AppendFormat(" ClipDepth: {0}", ClipDepth);
|
||||
}
|
||||
if ( HasClipActions ) {
|
||||
sb.AppendFormat(" ClipActions: {0}", HasClipActions);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.PlaceObject3; }
|
||||
}
|
||||
|
||||
public static PlaceObject3Tag Create(SwfStreamReader reader) {
|
||||
var tag = new PlaceObject3Tag();
|
||||
tag.HasClipActions = reader.ReadBit();
|
||||
tag.HasClipDepth = reader.ReadBit();
|
||||
tag.HasName = reader.ReadBit();
|
||||
tag.HasRatio = reader.ReadBit();
|
||||
tag.HasColorTransform = reader.ReadBit();
|
||||
tag.HasMatrix = reader.ReadBit();
|
||||
tag.HasCharacter = reader.ReadBit();
|
||||
tag.Move = reader.ReadBit();
|
||||
reader.ReadBit(); // reserved
|
||||
tag.OpaqueBackground = reader.ReadBit();
|
||||
tag.HasVisible = reader.ReadBit();
|
||||
tag.HasImage = reader.ReadBit();
|
||||
tag.HasClassName = reader.ReadBit();
|
||||
tag.HasCacheAsBitmap = reader.ReadBit();
|
||||
tag.HasBlendMode = reader.ReadBit();
|
||||
tag.HasFilterList = reader.ReadBit();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
if ( tag.HasCharacter || (tag.HasImage && tag.HasCharacter) ) {
|
||||
tag.ClassName = reader.ReadString();
|
||||
}
|
||||
if ( tag.HasCharacter ) {
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasMatrix ) {
|
||||
tag.Matrix = SwfMatrix.Read(reader);
|
||||
}
|
||||
if ( tag.HasColorTransform ) {
|
||||
tag.ColorTransform = SwfColorTransformRGBA.Read(reader);
|
||||
}
|
||||
if ( tag.HasRatio ) {
|
||||
tag.Ratio = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasName ) {
|
||||
tag.Name = reader.ReadString();
|
||||
}
|
||||
if ( tag.HasClipDepth ) {
|
||||
tag.ClipDepth = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasFilterList ) {
|
||||
tag.SurfaceFilters = SwfSurfaceFilters.Read(reader);
|
||||
}
|
||||
if ( tag.HasBlendMode ) {
|
||||
tag.BlendMode = (SwfBlendMode)reader.Reader.ReadByte();
|
||||
}
|
||||
if ( tag.HasCacheAsBitmap ) {
|
||||
tag.BitmapCache = reader.Reader.ReadByte();
|
||||
}
|
||||
if ( tag.HasVisible ) {
|
||||
tag.Visible = reader.Reader.ReadByte();
|
||||
tag.BackgroundColor = SwfRGBA.Read(reader);
|
||||
}
|
||||
if ( tag.HasClipActions ) {
|
||||
tag.ClipActions = SwfClipActions.Read(reader);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class RemoveObjectTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public ushort Depth;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("CharacterId: {0}, Depth: {1}", CharacterId, Depth);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.RemoveObject; }
|
||||
}
|
||||
|
||||
public static RemoveObjectTag Create(SwfStreamReader reader) {
|
||||
var tag = new RemoveObjectTag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class RemoveObject2Tag : SwfTagBase {
|
||||
public ushort Depth;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("Depth: {0}", Depth);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.RemoveObject2; }
|
||||
}
|
||||
|
||||
public static RemoveObject2Tag Create(SwfStreamReader reader) {
|
||||
var tag = new RemoveObject2Tag();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class ShowFrameTag : SwfTagBase {
|
||||
public override string ToString() {
|
||||
return "ShowFrameTag";
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.ShowFrame; }
|
||||
}
|
||||
|
||||
public static ShowFrameTag Create(SwfStreamReader reader) {
|
||||
return new ShowFrameTag();
|
||||
}
|
||||
}
|
||||
|
||||
class SetBackgroundColorTag : SwfTagBase {
|
||||
public SwfRGB BackgroundColor;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("BackgroundColor: {0}", BackgroundColor);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.SetBackgroundColor; }
|
||||
}
|
||||
|
||||
public static SetBackgroundColorTag Create(SwfStreamReader reader) {
|
||||
var tag = new SetBackgroundColorTag();
|
||||
tag.BackgroundColor = SwfRGB.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class FrameLabelTag : SwfTagBase {
|
||||
public string Name;
|
||||
public byte AnchorFlag;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("Name: {0}, AnchorFlag: {1}", Name, AnchorFlag);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.FrameLabel; }
|
||||
}
|
||||
|
||||
public static FrameLabelTag Create(SwfStreamReader reader) {
|
||||
var tag = new FrameLabelTag();
|
||||
tag.Name = reader.ReadString();
|
||||
if ( !reader.IsEOF ) {
|
||||
tag.AnchorFlag = reader.Reader.ReadByte();
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class EndTag : SwfTagBase {
|
||||
public override string ToString() {
|
||||
return "EndTag";
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.End; }
|
||||
}
|
||||
|
||||
public static EndTag Create(SwfStreamReader reader) {
|
||||
return new EndTag();
|
||||
}
|
||||
}
|
||||
|
||||
class SetTabIndexTag : SwfTagBase {
|
||||
public ushort Depth;
|
||||
public ushort TabIndex;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("Depth: {0}, TabIndex: {1}", Depth, TabIndex);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.SetTabIndex; }
|
||||
}
|
||||
|
||||
public static SetTabIndexTag Create(SwfStreamReader reader) {
|
||||
var tag = new SetTabIndexTag();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
tag.TabIndex = reader.Reader.ReadUInt16();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class DefineScalingGridTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public SwfRect Splitter;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("CharacterId: {0}, Splitter: {1}", CharacterId, Splitter);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineScalingGrid; }
|
||||
}
|
||||
|
||||
public static DefineScalingGridTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineScalingGridTag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.Splitter = SwfRect.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class DefineSceneAndFrameLabelDataTag : SwfTagBase {
|
||||
public List<SceneOffsetData> Scenes = new List<SceneOffsetData>();
|
||||
public List<FrameLabelData> Frames = new List<FrameLabelData>();
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("Scenes: {0}, Frames: {1}", Scenes.Count, Frames.Count);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineSceneAndFrameLabelData; }
|
||||
}
|
||||
|
||||
public static DefineSceneAndFrameLabelDataTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineSceneAndFrameLabelDataTag();
|
||||
var scenes = reader.ReadEncodedU32();
|
||||
for ( var i = 0; i < scenes; ++i ) {
|
||||
tag.Scenes.Add(SceneOffsetData.Read(reader));
|
||||
}
|
||||
var frames = reader.ReadEncodedU32();
|
||||
for ( var i = 0; i < frames; ++i ) {
|
||||
tag.Frames.Add(FrameLabelData.Read(reader));
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class DefineShapeTag : SwfTagBase {
|
||||
public ushort ShapeID;
|
||||
public SwfRect ShapeBounds;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("ShapeID: {0}, ShapeBounds: {1}", ShapeID, ShapeBounds);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineShape; }
|
||||
}
|
||||
|
||||
public static DefineShapeTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineShapeTag();
|
||||
tag.ShapeID = reader.Reader.ReadUInt16();
|
||||
tag.ShapeBounds = SwfRect.Read(reader);
|
||||
//tag.Shapes = SwfShapes.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class DefineShape2Tag : SwfTagBase {
|
||||
public ushort ShapeID;
|
||||
public SwfRect ShapeBounds;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("ShapeID: {0}, ShapeBounds: {1}", ShapeID, ShapeBounds);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineShape2; }
|
||||
}
|
||||
|
||||
public static DefineShape2Tag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineShape2Tag();
|
||||
tag.ShapeID = reader.Reader.ReadUInt16();
|
||||
tag.ShapeBounds = SwfRect.Read(reader);
|
||||
//tag.Shapes = SwfShapes.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class DefineShape3Tag : SwfTagBase {
|
||||
public ushort ShapeID;
|
||||
public SwfRect ShapeBounds;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("ShapeID: {0}, ShapeBounds: {1}", ShapeID, ShapeBounds);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineShape3; }
|
||||
}
|
||||
|
||||
public static DefineShape3Tag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineShape3Tag();
|
||||
tag.ShapeID = reader.Reader.ReadUInt16();
|
||||
tag.ShapeBounds = SwfRect.Read(reader);
|
||||
//tag.Shapes = SwfShapes.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class DefineShape4Tag : SwfTagBase {
|
||||
public ushort ShapeID;
|
||||
public SwfRect ShapeBounds;
|
||||
public SwfRect EdgeBounds;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"ShapeID: {0}, ShapeBounds: {1}, EdgeBounds: {2}",
|
||||
ShapeID, ShapeBounds, EdgeBounds);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineShape4; }
|
||||
}
|
||||
|
||||
public static DefineShape4Tag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineShape4Tag();
|
||||
tag.ShapeID = reader.Reader.ReadUInt16();
|
||||
tag.ShapeBounds = SwfRect.Read(reader);
|
||||
tag.EdgeBounds = SwfRect.Read(reader);
|
||||
//tag.Flags = reader.Reader.ReadByte();
|
||||
//tag.Shapes = SwfShapes.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class DefineBitsLosslessTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public byte BitmapFormat;
|
||||
public ushort BitmapWidth;
|
||||
public ushort BitmapHeight;
|
||||
public byte BitmapColorTableSize;
|
||||
public byte[] ZlibBitmapData;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineBitsLossless; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"CharacterId: {0}, BitmapFormat: {1}, Width: {2}, Height: {3}",
|
||||
CharacterId, BitmapFormat, BitmapWidth, BitmapHeight);
|
||||
}
|
||||
|
||||
public static DefineBitsLosslessTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineBitsLosslessTag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.BitmapFormat = reader.Reader.ReadByte();
|
||||
tag.BitmapWidth = reader.Reader.ReadUInt16();
|
||||
tag.BitmapHeight = reader.Reader.ReadUInt16();
|
||||
if ( tag.BitmapFormat == 3 ) {
|
||||
tag.BitmapColorTableSize = reader.Reader.ReadByte();
|
||||
}
|
||||
tag.ZlibBitmapData = reader.ReadRest();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class DefineBitsLossless2Tag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public byte BitmapFormat;
|
||||
public ushort BitmapWidth;
|
||||
public ushort BitmapHeight;
|
||||
public byte BitmapColorTableSize;
|
||||
public byte[] ZlibBitmapData;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineBitsLossless2; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"CharacterId: {0}, BitmapFormat: {1}, Width: {2}, Height: {3}",
|
||||
CharacterId, BitmapFormat, BitmapWidth, BitmapHeight);
|
||||
}
|
||||
|
||||
public static DefineBitsLossless2Tag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineBitsLossless2Tag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.BitmapFormat = reader.Reader.ReadByte();
|
||||
tag.BitmapWidth = reader.Reader.ReadUInt16();
|
||||
tag.BitmapHeight = reader.Reader.ReadUInt16();
|
||||
if ( tag.BitmapFormat == 3 ) {
|
||||
tag.BitmapColorTableSize = reader.Reader.ReadByte();
|
||||
}
|
||||
tag.ZlibBitmapData = reader.ReadRest();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class DefineSpriteTag : SwfTagBase {
|
||||
public ushort SpriteId;
|
||||
public ushort FrameCount;
|
||||
public List<SwfTagBase> ControlTags;
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SpriteId: {0}, FrameCount: {1}, ControlTags: {2}",
|
||||
SpriteId, FrameCount, ControlTags.Count);
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineSprite; }
|
||||
}
|
||||
|
||||
public static DefineSpriteTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineSpriteTag();
|
||||
tag.SpriteId = reader.Reader.ReadUInt16();
|
||||
tag.FrameCount = reader.Reader.ReadUInt16();
|
||||
tag.ControlTags = new List<SwfTagBase>();
|
||||
SwfTagBase sub_tag;
|
||||
do {
|
||||
var sub_tag_data = SwfTagData.Read(reader);
|
||||
sub_tag = SwfTagBase.Create(sub_tag_data);
|
||||
if ( sub_tag != null ) {
|
||||
tag.ControlTags.Add(sub_tag);
|
||||
}
|
||||
} while ( sub_tag != null && sub_tag.TagType != SwfTagType.End );
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
class FileAttributesTag : SwfTagBase {
|
||||
public override string ToString() {
|
||||
return "FileAttributesTag";
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.FileAttributes; }
|
||||
}
|
||||
|
||||
public static FileAttributesTag Create(SwfStreamReader reader) {
|
||||
return new FileAttributesTag();
|
||||
}
|
||||
}
|
||||
|
||||
class UnknownTag : SwfTagBase {
|
||||
SwfTagType Type;
|
||||
|
||||
public override string ToString() {
|
||||
return "UnknownTag";
|
||||
}
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return Type; }
|
||||
}
|
||||
|
||||
public static UnknownTag Create(SwfTagType type) {
|
||||
var tag = new UnknownTag();
|
||||
tag.Type = type;
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using FlashTools.Internal.SwfTags;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
class SwfStreamReader {
|
||||
@@ -27,6 +29,10 @@ namespace FlashTools.Internal {
|
||||
_reader = new BinaryReader(File.OpenRead(path));
|
||||
}
|
||||
|
||||
public SwfStreamReader(byte[] data) {
|
||||
_reader = new BinaryReader(new MemoryStream(data));
|
||||
}
|
||||
|
||||
public SwfStreamReader(Stream stream) {
|
||||
_reader = new BinaryReader(stream);
|
||||
}
|
||||
@@ -160,9 +166,9 @@ namespace FlashTools.Internal {
|
||||
header.Format = new string(reader.Reader.ReadChars(3));
|
||||
header.Version = reader.Reader.ReadByte();
|
||||
header.FileLength = reader.Reader.ReadUInt32();
|
||||
header.FrameSize = SwfRect.Read(reader);
|
||||
header.FrameRate = reader.ReadFixedPoint8();
|
||||
header.FrameCount = reader.Reader.ReadUInt16();
|
||||
//header.FrameSize = SwfRect.Read(reader);
|
||||
//header.FrameRate = reader.ReadFixedPoint8();
|
||||
//header.FrameCount = reader.Reader.ReadUInt16();
|
||||
return header;
|
||||
}
|
||||
|
||||
@@ -173,30 +179,6 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
}
|
||||
|
||||
struct SceneOffsetData {
|
||||
public uint Offset;
|
||||
public string Name;
|
||||
|
||||
public static SceneOffsetData Read(SwfStreamReader reader) {
|
||||
var data = new SceneOffsetData();
|
||||
data.Offset = reader.ReadEncodedU32();
|
||||
data.Name = reader.ReadString();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
struct FrameLabelData {
|
||||
public uint Number;
|
||||
public string Label;
|
||||
|
||||
public static FrameLabelData Read(SwfStreamReader reader) {
|
||||
var data = new FrameLabelData();
|
||||
data.Number = reader.ReadEncodedU32();
|
||||
data.Label = reader.ReadString();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
struct SwfRGB {
|
||||
public byte Red;
|
||||
public byte Green;
|
||||
@@ -239,6 +221,16 @@ namespace FlashTools.Internal {
|
||||
}
|
||||
}
|
||||
|
||||
struct SwfShapesWithStyle {
|
||||
public static SwfShapesWithStyle Read(SwfStreamReader reader) {
|
||||
return new SwfShapesWithStyle();
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
struct SwfRect {
|
||||
public float XMin;
|
||||
public float XMax;
|
||||
@@ -432,4 +424,21 @@ namespace FlashTools.Internal {
|
||||
throw new UnityException("implme!");
|
||||
}
|
||||
}
|
||||
|
||||
struct SwfControlTags {
|
||||
public List<SwfTagBase> Tags;
|
||||
public static SwfControlTags Read(SwfStreamReader reader) {
|
||||
var control_tags = new SwfControlTags();
|
||||
control_tags.Tags = new List<SwfTagBase>();
|
||||
while ( true ) {
|
||||
var tag_data = SwfTagData.Read(reader);
|
||||
var tag = SwfTagBase.Create(tag_data);
|
||||
control_tags.Tags.Add(tag);
|
||||
if ( tag.TagType == SwfTagType.End ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return control_tags;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/FlashTools/Scripts/Internal/Editor/SwfTags.meta
Normal file
9
Assets/FlashTools/Scripts/Internal/Editor/SwfTags.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15db74a10abbb4b35ab17143a18753a5
|
||||
folderAsset: yes
|
||||
timeCreated: 1457805943
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class DefineBitsLossless2Tag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public byte BitmapFormat;
|
||||
public ushort BitmapWidth;
|
||||
public ushort BitmapHeight;
|
||||
public byte BitmapColorTableSize;
|
||||
public byte[] ZlibBitmapData;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineBitsLossless2; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineBitsLossless2Tag. " +
|
||||
"CharacterId: {0}, BitmapFormat: {1}, Width: {2}, Height: {3}",
|
||||
CharacterId, BitmapFormat, BitmapWidth, BitmapHeight);
|
||||
}
|
||||
|
||||
public static DefineBitsLossless2Tag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineBitsLossless2Tag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.BitmapFormat = reader.Reader.ReadByte();
|
||||
tag.BitmapWidth = reader.Reader.ReadUInt16();
|
||||
tag.BitmapHeight = reader.Reader.ReadUInt16();
|
||||
if ( tag.BitmapFormat == 3 ) {
|
||||
tag.BitmapColorTableSize = reader.Reader.ReadByte();
|
||||
}
|
||||
tag.ZlibBitmapData = reader.ReadRest();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6fd42db76e554f85abc15861c15e758
|
||||
timeCreated: 1457387815
|
||||
guid: 9a86e93cfb4a14b91bca7f9669b7ee7e
|
||||
timeCreated: 1457806192
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class DefineBitsLosslessTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public byte BitmapFormat;
|
||||
public ushort BitmapWidth;
|
||||
public ushort BitmapHeight;
|
||||
public byte BitmapColorTableSize;
|
||||
public byte[] ZlibBitmapData;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineBitsLossless; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineBitsLosslessTag. " +
|
||||
"CharacterId: {0}, BitmapFormat: {1}, Width: {2}, Height: {3}",
|
||||
CharacterId, BitmapFormat, BitmapWidth, BitmapHeight);
|
||||
}
|
||||
|
||||
public static DefineBitsLosslessTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineBitsLosslessTag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.BitmapFormat = reader.Reader.ReadByte();
|
||||
tag.BitmapWidth = reader.Reader.ReadUInt16();
|
||||
tag.BitmapHeight = reader.Reader.ReadUInt16();
|
||||
if ( tag.BitmapFormat == 3 ) {
|
||||
tag.BitmapColorTableSize = reader.Reader.ReadByte();
|
||||
}
|
||||
tag.ZlibBitmapData = reader.ReadRest();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93930c1f11b8b4299b5b252c8d1e44cc
|
||||
timeCreated: 1457806180
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class DefineScalingGridTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public SwfRect Splitter;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineScalingGrid; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineScalingGridTag. " +
|
||||
"CharacterId: {0}, Splitter: {1}",
|
||||
CharacterId, Splitter);
|
||||
}
|
||||
|
||||
public static DefineScalingGridTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineScalingGridTag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.Splitter = SwfRect.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03bab2d6ff7054cac9a8d14d9ba20731
|
||||
timeCreated: 1457806116
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class DefineSceneAndFrameLabelDataTag : SwfTagBase {
|
||||
public struct SceneOffsetData {
|
||||
public uint Offset;
|
||||
public string Name;
|
||||
}
|
||||
|
||||
public struct FrameLabelData {
|
||||
public uint Number;
|
||||
public string Label;
|
||||
}
|
||||
|
||||
public List<SceneOffsetData> Scenes = new List<SceneOffsetData>();
|
||||
public List<FrameLabelData> Frames = new List<FrameLabelData>();
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineSceneAndFrameLabelData; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineSceneAndFrameLabelDataTag. " +
|
||||
"Scenes: {0}, Frames: {1}",
|
||||
Scenes.Count, Frames.Count);
|
||||
}
|
||||
|
||||
public static DefineSceneAndFrameLabelDataTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineSceneAndFrameLabelDataTag();
|
||||
var scenes = reader.ReadEncodedU32();
|
||||
for ( var i = 0; i < scenes; ++i ) {
|
||||
tag.Scenes.Add(new SceneOffsetData{
|
||||
Offset = reader.ReadEncodedU32(),
|
||||
Name = reader.ReadString()
|
||||
});
|
||||
}
|
||||
var frames = reader.ReadEncodedU32();
|
||||
for ( var i = 0; i < frames; ++i ) {
|
||||
tag.Frames.Add(new FrameLabelData{
|
||||
Number = reader.ReadEncodedU32(),
|
||||
Label = reader.ReadString()
|
||||
});
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8861b3a830cd64ddb8e2b3373a6952dc
|
||||
timeCreated: 1457806126
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class DefineShape2Tag : SwfTagBase {
|
||||
public ushort ShapeId;
|
||||
public SwfRect ShapeBounds;
|
||||
public SwfShapesWithStyle Shapes;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineShape2; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineShape2Tag. " +
|
||||
"ShapeId: {0}, ShapeBounds: {1}, Shapes: {2}",
|
||||
ShapeId, ShapeBounds, Shapes);
|
||||
}
|
||||
|
||||
public static DefineShape2Tag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineShape2Tag();
|
||||
tag.ShapeId = reader.Reader.ReadUInt16();
|
||||
tag.ShapeBounds = SwfRect.Read(reader);
|
||||
tag.Shapes = SwfShapesWithStyle.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c14bd04574d2540f5b4c834e394ff09b
|
||||
timeCreated: 1457806145
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class DefineShape3Tag : SwfTagBase {
|
||||
public ushort ShapeId;
|
||||
public SwfRect ShapeBounds;
|
||||
public SwfShapesWithStyle Shapes;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineShape3; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineShape3Tag. " +
|
||||
"ShapeId: {0}, ShapeBounds: {1}, Shapes: {2}",
|
||||
ShapeId, ShapeBounds, Shapes);
|
||||
}
|
||||
|
||||
public static DefineShape3Tag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineShape3Tag();
|
||||
tag.ShapeId = reader.Reader.ReadUInt16();
|
||||
tag.ShapeBounds = SwfRect.Read(reader);
|
||||
tag.Shapes = SwfShapesWithStyle.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17f96f9e9841246658fdc871e73cc2cc
|
||||
timeCreated: 1457806154
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class DefineShape4Tag : SwfTagBase {
|
||||
public ushort ShapeId;
|
||||
public SwfRect ShapeBounds;
|
||||
public SwfRect EdgeBounds;
|
||||
public SwfShapesWithStyle Shapes;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineShape4; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineShape4Tag. " +
|
||||
"ShapeId: {0}, ShapeBounds: {1}, EdgeBounds: {2}, Shapes: {3}",
|
||||
ShapeId, ShapeBounds, EdgeBounds, Shapes);
|
||||
}
|
||||
|
||||
public static DefineShape4Tag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineShape4Tag();
|
||||
tag.ShapeId = reader.Reader.ReadUInt16();
|
||||
tag.ShapeBounds = SwfRect.Read(reader);
|
||||
tag.EdgeBounds = SwfRect.Read(reader);
|
||||
reader.Reader.ReadByte(); // Skip flags
|
||||
tag.Shapes = SwfShapesWithStyle.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8588b2fc4ef4a49cfb422ae16057b33b
|
||||
timeCreated: 1457806164
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class DefineShapeTag : SwfTagBase {
|
||||
public ushort ShapeId;
|
||||
public SwfRect ShapeBounds;
|
||||
public SwfShapesWithStyle Shapes;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineShape; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineShapeTag. " +
|
||||
"ShapeId: {0}, ShapeBounds: {1}, Shapes: {2}",
|
||||
ShapeId, ShapeBounds, Shapes);
|
||||
}
|
||||
|
||||
public static DefineShapeTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineShapeTag();
|
||||
tag.ShapeId = reader.Reader.ReadUInt16();
|
||||
tag.ShapeBounds = SwfRect.Read(reader);
|
||||
tag.Shapes = SwfShapesWithStyle.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c4031f2278a949ea8f13253950a43d6
|
||||
timeCreated: 1457806135
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class DefineSpriteTag : SwfTagBase {
|
||||
public ushort SpriteId;
|
||||
public ushort FrameCount;
|
||||
public SwfControlTags ControlTags;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.DefineSprite; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineSpriteTag. " +
|
||||
"SpriteId: {0}, FrameCount: {1}, ControlTags: {2}",
|
||||
SpriteId, FrameCount, ControlTags.Tags.Count);
|
||||
}
|
||||
|
||||
public static DefineSpriteTag Create(SwfStreamReader reader) {
|
||||
var tag = new DefineSpriteTag();
|
||||
tag.SpriteId = reader.Reader.ReadUInt16();
|
||||
tag.FrameCount = reader.Reader.ReadUInt16();
|
||||
tag.ControlTags = SwfControlTags.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3c659fdccfff42f9a79049ed13aab4f
|
||||
timeCreated: 1457806204
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/FlashTools/Scripts/Internal/Editor/SwfTags/EndTag.cs
Normal file
15
Assets/FlashTools/Scripts/Internal/Editor/SwfTags/EndTag.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class EndTag : SwfTagBase {
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.End; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "EndTag.";
|
||||
}
|
||||
|
||||
public static EndTag Create(SwfStreamReader reader) {
|
||||
return new EndTag();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfab3868fff1148f3ada0a0bb74b660b
|
||||
timeCreated: 1457806094
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class FileAttributesTag : SwfTagBase {
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.FileAttributes; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "FileAttributesTag.";
|
||||
}
|
||||
|
||||
public static FileAttributesTag Create(SwfStreamReader reader) {
|
||||
return new FileAttributesTag();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7799f56fc5f01418f99c69da8d177010
|
||||
timeCreated: 1457806214
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class FrameLabelTag : SwfTagBase {
|
||||
public string Name;
|
||||
public byte AnchorFlag;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.FrameLabel; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"FrameLabelTag. " +
|
||||
"Name: {0}, AnchorFlag: {1}",
|
||||
Name, AnchorFlag);
|
||||
}
|
||||
|
||||
public static FrameLabelTag Create(SwfStreamReader reader) {
|
||||
var tag = new FrameLabelTag();
|
||||
tag.Name = reader.ReadString();
|
||||
if ( !reader.IsEOF ) {
|
||||
tag.AnchorFlag = reader.Reader.ReadByte();
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6324f9cc87fb24045bbc089ff54e7969
|
||||
timeCreated: 1457806085
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
using System.Text;
|
||||
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class PlaceObject2Tag : SwfTagBase {
|
||||
public bool HasClipActions;
|
||||
public bool HasClipDepth;
|
||||
public bool HasName;
|
||||
public bool HasRatio;
|
||||
public bool HasColorTransform;
|
||||
public bool HasMatrix;
|
||||
public bool HasCharacter;
|
||||
public bool Move;
|
||||
public ushort Depth;
|
||||
public ushort CharacterId;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransformRGBA ColorTransform;
|
||||
public ushort Ratio;
|
||||
public string Name;
|
||||
public ushort ClipDepth;
|
||||
public SwfClipActions ClipActions;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.PlaceObject2; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder(1024);
|
||||
sb.Append("PlaceObject2Tag. ");
|
||||
sb.AppendFormat("Move: {0} Depth: {1}", Move, Depth);
|
||||
if ( HasCharacter ) {
|
||||
sb.AppendFormat(" CharacterId: {0}", CharacterId);
|
||||
}
|
||||
if ( HasMatrix ) {
|
||||
sb.AppendFormat(" Matrix: {0}", Matrix);
|
||||
}
|
||||
if ( HasColorTransform ) {
|
||||
sb.AppendFormat(" ColorTransform: {0}", ColorTransform);
|
||||
}
|
||||
if ( HasRatio ) {
|
||||
sb.AppendFormat(" Ratio: {0}", Ratio);
|
||||
}
|
||||
if ( HasName ) {
|
||||
sb.AppendFormat(" Name: {0}", Name);
|
||||
}
|
||||
if ( HasClipDepth ) {
|
||||
sb.AppendFormat(" ClipDepth: {0}", ClipDepth);
|
||||
}
|
||||
if ( HasClipActions ) {
|
||||
sb.AppendFormat(" ClipActions: {0}", HasClipActions);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static PlaceObject2Tag Create(SwfStreamReader reader) {
|
||||
var tag = new PlaceObject2Tag();
|
||||
tag.HasClipActions = reader.ReadBit();
|
||||
tag.HasClipDepth = reader.ReadBit();
|
||||
tag.HasName = reader.ReadBit();
|
||||
tag.HasRatio = reader.ReadBit();
|
||||
tag.HasColorTransform = reader.ReadBit();
|
||||
tag.HasMatrix = reader.ReadBit();
|
||||
tag.HasCharacter = reader.ReadBit();
|
||||
tag.Move = reader.ReadBit();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
if ( tag.HasCharacter ) {
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasMatrix ) {
|
||||
tag.Matrix = SwfMatrix.Read(reader);
|
||||
}
|
||||
if ( tag.HasColorTransform ) {
|
||||
tag.ColorTransform = SwfColorTransformRGBA.Read(reader);
|
||||
}
|
||||
if ( tag.HasRatio ) {
|
||||
tag.Ratio = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasName ) {
|
||||
tag.Name = reader.ReadString();
|
||||
}
|
||||
if ( tag.HasClipDepth ) {
|
||||
tag.ClipDepth = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasClipActions ) {
|
||||
tag.ClipActions = SwfClipActions.Read(reader);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1fd75a14bb004dcbaf692b2cf9b7498
|
||||
timeCreated: 1457806017
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,126 @@
|
||||
using System.Text;
|
||||
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class PlaceObject3Tag : SwfTagBase {
|
||||
public bool HasClipActions;
|
||||
public bool HasClipDepth;
|
||||
public bool HasName;
|
||||
public bool HasRatio;
|
||||
public bool HasColorTransform;
|
||||
public bool HasMatrix;
|
||||
public bool HasCharacter;
|
||||
public bool Move;
|
||||
public bool OpaqueBackground;
|
||||
public bool HasVisible;
|
||||
public bool HasImage;
|
||||
public bool HasClassName;
|
||||
public bool HasCacheAsBitmap;
|
||||
public bool HasBlendMode;
|
||||
public bool HasFilterList;
|
||||
public ushort Depth;
|
||||
public string ClassName;
|
||||
public ushort CharacterId;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransformRGBA ColorTransform;
|
||||
public ushort Ratio;
|
||||
public string Name;
|
||||
public ushort ClipDepth;
|
||||
public SwfSurfaceFilters SurfaceFilters;
|
||||
public SwfBlendMode BlendMode;
|
||||
public byte BitmapCache;
|
||||
public byte Visible;
|
||||
public SwfRGBA BackgroundColor;
|
||||
public SwfClipActions ClipActions;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.PlaceObject3; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder(1024);
|
||||
sb.Append("PlaceObject3Tag. ");
|
||||
sb.AppendFormat("Move: {0} Depth: {1}", Move, Depth);
|
||||
if ( HasCharacter ) {
|
||||
sb.AppendFormat(" CharacterId: {0}", CharacterId);
|
||||
}
|
||||
if ( HasMatrix ) {
|
||||
sb.AppendFormat(" Matrix: {0}", Matrix);
|
||||
}
|
||||
if ( HasColorTransform ) {
|
||||
sb.AppendFormat(" ColorTransform: {0}", ColorTransform);
|
||||
}
|
||||
if ( HasRatio ) {
|
||||
sb.AppendFormat(" Ratio: {0}", Ratio);
|
||||
}
|
||||
if ( HasName ) {
|
||||
sb.AppendFormat(" Name: {0}", Name);
|
||||
}
|
||||
if ( HasClipDepth ) {
|
||||
sb.AppendFormat(" ClipDepth: {0}", ClipDepth);
|
||||
}
|
||||
if ( HasClipActions ) {
|
||||
sb.AppendFormat(" ClipActions: {0}", HasClipActions);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static PlaceObject3Tag Create(SwfStreamReader reader) {
|
||||
var tag = new PlaceObject3Tag();
|
||||
tag.HasClipActions = reader.ReadBit();
|
||||
tag.HasClipDepth = reader.ReadBit();
|
||||
tag.HasName = reader.ReadBit();
|
||||
tag.HasRatio = reader.ReadBit();
|
||||
tag.HasColorTransform = reader.ReadBit();
|
||||
tag.HasMatrix = reader.ReadBit();
|
||||
tag.HasCharacter = reader.ReadBit();
|
||||
tag.Move = reader.ReadBit();
|
||||
reader.ReadBit(); // reserved
|
||||
tag.OpaqueBackground = reader.ReadBit();
|
||||
tag.HasVisible = reader.ReadBit();
|
||||
tag.HasImage = reader.ReadBit();
|
||||
tag.HasClassName = reader.ReadBit();
|
||||
tag.HasCacheAsBitmap = reader.ReadBit();
|
||||
tag.HasBlendMode = reader.ReadBit();
|
||||
tag.HasFilterList = reader.ReadBit();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
if ( tag.HasCharacter || (tag.HasImage && tag.HasCharacter) ) {
|
||||
tag.ClassName = reader.ReadString();
|
||||
}
|
||||
if ( tag.HasCharacter ) {
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasMatrix ) {
|
||||
tag.Matrix = SwfMatrix.Read(reader);
|
||||
}
|
||||
if ( tag.HasColorTransform ) {
|
||||
tag.ColorTransform = SwfColorTransformRGBA.Read(reader);
|
||||
}
|
||||
if ( tag.HasRatio ) {
|
||||
tag.Ratio = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasName ) {
|
||||
tag.Name = reader.ReadString();
|
||||
}
|
||||
if ( tag.HasClipDepth ) {
|
||||
tag.ClipDepth = reader.Reader.ReadUInt16();
|
||||
}
|
||||
if ( tag.HasFilterList ) {
|
||||
tag.SurfaceFilters = SwfSurfaceFilters.Read(reader);
|
||||
}
|
||||
if ( tag.HasBlendMode ) {
|
||||
tag.BlendMode = (SwfBlendMode)reader.Reader.ReadByte();
|
||||
}
|
||||
if ( tag.HasCacheAsBitmap ) {
|
||||
tag.BitmapCache = reader.Reader.ReadByte();
|
||||
}
|
||||
if ( tag.HasVisible ) {
|
||||
tag.Visible = reader.Reader.ReadByte();
|
||||
tag.BackgroundColor = SwfRGBA.Read(reader);
|
||||
}
|
||||
if ( tag.HasClipActions ) {
|
||||
tag.ClipActions = SwfClipActions.Read(reader);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0b85321c9e164303a2fb2a6106f6699
|
||||
timeCreated: 1457806030
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class PlaceObjectTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public ushort Depth;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransformRGB ColorTransform;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.PlaceObject; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"PlaceObjectTag. " +
|
||||
"CharacterId: {0}, Depth: {1}, Matrix: {2}, ColorTransform: {3}",
|
||||
CharacterId, Depth, Matrix, ColorTransform);
|
||||
}
|
||||
|
||||
public static PlaceObjectTag Create(SwfStreamReader reader) {
|
||||
var tag = new PlaceObjectTag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
tag.Matrix = SwfMatrix.Read(reader);
|
||||
if ( !reader.IsEOF ) {
|
||||
tag.ColorTransform = SwfColorTransformRGB.Read(reader);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba536e4ee6b3848948e7208a1cefefdf
|
||||
timeCreated: 1457806006
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class RemoveObject2Tag : SwfTagBase {
|
||||
public ushort Depth;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.RemoveObject2; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"RemoveObject2Tag. " +
|
||||
"Depth: {0}",
|
||||
Depth);
|
||||
}
|
||||
|
||||
public static RemoveObject2Tag Create(SwfStreamReader reader) {
|
||||
var tag = new RemoveObject2Tag();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50a3f4c3646154192b0c4dcb40b315b3
|
||||
timeCreated: 1457806055
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class RemoveObjectTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public ushort Depth;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.RemoveObject; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"RemoveObjectTag. " +
|
||||
"CharacterId: {0}, Depth: {1}",
|
||||
CharacterId, Depth);
|
||||
}
|
||||
|
||||
public static RemoveObjectTag Create(SwfStreamReader reader) {
|
||||
var tag = new RemoveObjectTag();
|
||||
tag.CharacterId = reader.Reader.ReadUInt16();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a66815e233fed447f8319dd343167b2e
|
||||
timeCreated: 1457806046
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class SetBackgroundColorTag : SwfTagBase {
|
||||
public SwfRGB BackgroundColor;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.SetBackgroundColor; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SetBackgroundColorTag. " +
|
||||
"BackgroundColor: {0}",
|
||||
BackgroundColor);
|
||||
}
|
||||
|
||||
public static SetBackgroundColorTag Create(SwfStreamReader reader) {
|
||||
var tag = new SetBackgroundColorTag();
|
||||
tag.BackgroundColor = SwfRGB.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ba6ee247270a4e2582be095c59f59bf
|
||||
timeCreated: 1457806076
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class SetTabIndexTag : SwfTagBase {
|
||||
public ushort Depth;
|
||||
public ushort TabIndex;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.SetTabIndex; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SetTabIndexTag. " +
|
||||
"Depth: {0}, TabIndex: {1}",
|
||||
Depth, TabIndex);
|
||||
}
|
||||
|
||||
public static SetTabIndexTag Create(SwfStreamReader reader) {
|
||||
var tag = new SetTabIndexTag();
|
||||
tag.Depth = reader.Reader.ReadUInt16();
|
||||
tag.TabIndex = reader.Reader.ReadUInt16();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3941fb765685542b5b22249c0820b023
|
||||
timeCreated: 1457806104
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class ShowFrameTag : SwfTagBase {
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.ShowFrame; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "ShowFrameTag.";
|
||||
}
|
||||
|
||||
public static ShowFrameTag Create(SwfStreamReader reader) {
|
||||
return new ShowFrameTag();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06e82bd9e78964590b8b35dbe6ca47c0
|
||||
timeCreated: 1457806067
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
180
Assets/FlashTools/Scripts/Internal/Editor/SwfTags/SwfTagBase.cs
Normal file
180
Assets/FlashTools/Scripts/Internal/Editor/SwfTags/SwfTagBase.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
using System.IO;
|
||||
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
enum SwfTagType {
|
||||
// -----------------------------
|
||||
// Display list
|
||||
// -----------------------------
|
||||
|
||||
PlaceObject = 4,
|
||||
PlaceObject2 = 26,
|
||||
PlaceObject3 = 70,
|
||||
RemoveObject = 5,
|
||||
RemoveObject2 = 28,
|
||||
ShowFrame = 1,
|
||||
|
||||
// -----------------------------
|
||||
// Control
|
||||
// -----------------------------
|
||||
|
||||
SetBackgroundColor = 9,
|
||||
FrameLabel = 43,
|
||||
//Protect = 24,
|
||||
End = 0,
|
||||
//ExportAssets = 56,
|
||||
//ImportAssets = 57,
|
||||
//EnableDebugger = 58,
|
||||
//EnableDebugger2 = 64,
|
||||
//ScriptLimits = 65,
|
||||
SetTabIndex = 66,
|
||||
//ImportAssets2 = 71,
|
||||
//SymbolClass = 76,
|
||||
//Metadata = 77,
|
||||
DefineScalingGrid = 78,
|
||||
DefineSceneAndFrameLabelData = 86,
|
||||
|
||||
// -----------------------------
|
||||
// Actions
|
||||
// -----------------------------
|
||||
|
||||
//DoAction = 12,
|
||||
//DoInitAction = 59,
|
||||
//DoABC = 82,
|
||||
|
||||
// -----------------------------
|
||||
// Shape
|
||||
// -----------------------------
|
||||
|
||||
DefineShape = 2,
|
||||
DefineShape2 = 22,
|
||||
DefineShape3 = 32,
|
||||
DefineShape4 = 83,
|
||||
|
||||
// -----------------------------
|
||||
// Bitmaps
|
||||
// -----------------------------
|
||||
|
||||
//DefineBits = 6,
|
||||
//JPEGTables = 8,
|
||||
//DefineBitsJPEG2 = 21,
|
||||
//DefineBitsJPEG3 = 35,
|
||||
DefineBitsLossless = 20,
|
||||
DefineBitsLossless2 = 36,
|
||||
//DefineBitsJPEG4 = 90,
|
||||
|
||||
// -----------------------------
|
||||
// Shape Morphing
|
||||
// -----------------------------
|
||||
|
||||
//DefineMorphShape = 46,
|
||||
//DefineMorphShape2 = 84,
|
||||
|
||||
// -----------------------------
|
||||
// Fonts and Text
|
||||
// -----------------------------
|
||||
|
||||
//DefineFont = 10,
|
||||
//DefineFontInfo = 13,
|
||||
//DefineFontInfo2 = 62,
|
||||
//DefineFont2 = 48,
|
||||
//DefineFont3 = 75,
|
||||
//DefineFontAlignZones = 73,
|
||||
//DefineFontName = 88,
|
||||
//DefineText = 11,
|
||||
//DefineText2 = 33,
|
||||
//DefineEditText = 37,
|
||||
//CSMTextSettings = 74,
|
||||
//DefineFont4 = 91,
|
||||
|
||||
// -----------------------------
|
||||
// Sounds
|
||||
// -----------------------------
|
||||
|
||||
//DefineSound = 14,
|
||||
//StartSound = 15,
|
||||
//StartSound2 = 89,
|
||||
//SoundStreamHead = 18,
|
||||
//SoundStreamHead2 = 45,
|
||||
//SoundStreamBlock = 19,
|
||||
|
||||
// -----------------------------
|
||||
// Buttons
|
||||
// -----------------------------
|
||||
|
||||
//DefineButton = 7,
|
||||
//DefineButton2 = 34,
|
||||
//DefineButtonCxform = 23,
|
||||
//DefineButtonSound = 17,
|
||||
|
||||
// -----------------------------
|
||||
// Sprites and Movie Clips
|
||||
// -----------------------------
|
||||
|
||||
DefineSprite = 39,
|
||||
|
||||
// -----------------------------
|
||||
// Video
|
||||
// -----------------------------
|
||||
|
||||
//DefineVideoStream = 60,
|
||||
//VideoFrame = 61,
|
||||
|
||||
// -----------------------------
|
||||
// Metadata
|
||||
// -----------------------------
|
||||
|
||||
FileAttributes = 69,
|
||||
//EnableTelemetry = 93,
|
||||
//DefineBinaryData = 87,
|
||||
|
||||
// -----------------------------
|
||||
// Unknown
|
||||
// -----------------------------
|
||||
|
||||
Unknown
|
||||
}
|
||||
|
||||
struct SwfTagData {
|
||||
public int TagId;
|
||||
public byte[] TagData;
|
||||
|
||||
public static SwfTagData Read(SwfStreamReader reader) {
|
||||
var type_and_size = reader.Reader.ReadUInt16();
|
||||
var tag_id = type_and_size >> 6;
|
||||
var short_size = type_and_size & 0x3f;
|
||||
var size = short_size < 0x3f ? short_size : reader.Reader.ReadInt32();
|
||||
var tag_data = reader.Reader.ReadBytes(size);
|
||||
return new SwfTagData{TagId = tag_id, TagData = tag_data};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SwfTagBase {
|
||||
public abstract SwfTagType TagType { get; }
|
||||
public static SwfTagBase Create(SwfTagData tag_data) {
|
||||
var reader = new SwfStreamReader(tag_data.TagData);
|
||||
switch ( tag_data.TagId ) {
|
||||
case (int)SwfTagType.PlaceObject: return PlaceObjectTag.Create(reader);
|
||||
case (int)SwfTagType.PlaceObject2: return PlaceObject2Tag.Create(reader);
|
||||
case (int)SwfTagType.PlaceObject3: return PlaceObject3Tag.Create(reader);
|
||||
case (int)SwfTagType.RemoveObject: return RemoveObjectTag.Create(reader);
|
||||
case (int)SwfTagType.RemoveObject2: return RemoveObject2Tag.Create(reader);
|
||||
case (int)SwfTagType.ShowFrame: return ShowFrameTag.Create(reader);
|
||||
case (int)SwfTagType.SetBackgroundColor: return SetBackgroundColorTag.Create(reader);
|
||||
case (int)SwfTagType.FrameLabel: return FrameLabelTag.Create(reader);
|
||||
case (int)SwfTagType.End: return EndTag.Create(reader);
|
||||
case (int)SwfTagType.SetTabIndex: return SetTabIndexTag.Create(reader);
|
||||
case (int)SwfTagType.DefineScalingGrid: return DefineScalingGridTag.Create(reader);
|
||||
case (int)SwfTagType.DefineSceneAndFrameLabelData: return DefineSceneAndFrameLabelDataTag.Create(reader);
|
||||
case (int)SwfTagType.DefineShape: return DefineShapeTag.Create(reader);
|
||||
case (int)SwfTagType.DefineShape2: return DefineShape2Tag.Create(reader);
|
||||
case (int)SwfTagType.DefineShape3: return DefineShape3Tag.Create(reader);
|
||||
case (int)SwfTagType.DefineShape4: return DefineShape4Tag.Create(reader);
|
||||
case (int)SwfTagType.DefineBitsLossless: return DefineBitsLosslessTag.Create(reader);
|
||||
case (int)SwfTagType.DefineBitsLossless2: return DefineBitsLossless2Tag.Create(reader);
|
||||
case (int)SwfTagType.DefineSprite: return DefineSpriteTag.Create(reader);
|
||||
case (int)SwfTagType.FileAttributes: return FileAttributesTag.Create(reader);
|
||||
default: return UnknownTag.Create(tag_data.TagId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc12052cbac15441bb21840c82f5ebbc
|
||||
timeCreated: 1457805979
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace FlashTools.Internal.SwfTags {
|
||||
class UnknownTag : SwfTagBase {
|
||||
public int TagId;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.Unknown; }
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"TagId: {0}", TagId);
|
||||
}
|
||||
|
||||
public static UnknownTag Create(int tag_id) {
|
||||
var tag = new UnknownTag();
|
||||
tag.TagId = tag_id;
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15edc6d79a7fc4bbcb127dd779a0bc13
|
||||
timeCreated: 1457806224
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -161,7 +161,7 @@
|
||||
ftd.prepare_bitmaps = function (document) {
|
||||
ft.type_assert(document, Document);
|
||||
ft.array_foreach(document.library.items, function(item) {
|
||||
ft.trace_fmt("-Item: {0}", item.name);
|
||||
//ft.trace_fmt("-Item: {0}", item.name);
|
||||
if ( item.itemType == "bitmap" ) {
|
||||
item.compressionType = "lossless";
|
||||
}
|
||||
@@ -204,7 +204,7 @@
|
||||
(function () {
|
||||
ft.clear_output();
|
||||
ft.array_foreach(fl.documents, function (document) {
|
||||
ft.trace_fmt("Doc: {0}", document.name);
|
||||
//ft.trace_fmt("Doc: {0}", document.name);
|
||||
ftd.prepare_folders(document);
|
||||
ftd.prepare_bitmaps(document);
|
||||
ftd.export_swf(document);
|
||||
|
||||
Reference in New Issue
Block a user