SwfTools to dll

This commit is contained in:
2016-10-02 23:05:08 +07:00
parent 4620eda86c
commit 312379a3f9
103 changed files with 323 additions and 930 deletions

View File

@@ -4,5 +4,6 @@ glob:Library/*
glob:*.sln glob:*.sln
glob:*.csproj glob:*.csproj
glob:*.userprefs
glob:.DS_Store glob:.DS_Store

View File

@@ -5,9 +5,9 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using FlashTools.Internal.SwfTools; using SwfTools;
using FlashTools.Internal.SwfTools.SwfTags; using SwfTools.SwfTags;
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal { namespace FlashTools.Internal {
public class SwfPostprocessor : AssetPostprocessor { public class SwfPostprocessor : AssetPostprocessor {
@@ -289,4 +289,74 @@ namespace FlashTools.Internal {
.ToList(); .ToList();
} }
} }
// ---------------------------------------------------------------------
//
// Extensions
//
// ---------------------------------------------------------------------
static class SwfExtensions {
public static Matrix4x4 ToUMatrix(this SwfMatrix self) {
var mat = Matrix4x4.identity;
mat.m00 = self.ScaleX;
mat.m10 = self.RotateSkew0;
mat.m01 = self.RotateSkew1;
mat.m11 = self.ScaleY;
mat.m03 = self.TranslateX;
mat.m13 = self.TranslateY;
return mat;
}
public static SwfBlendModeData ToBlendModeData(this SwfBlendMode self) {
switch ( self.Value ) {
case SwfBlendMode.Mode.Normal:
return new SwfBlendModeData(SwfBlendModeData.Types.Normal);
case SwfBlendMode.Mode.Layer:
return new SwfBlendModeData(SwfBlendModeData.Types.Layer);
case SwfBlendMode.Mode.Multiply:
return new SwfBlendModeData(SwfBlendModeData.Types.Multiply);
case SwfBlendMode.Mode.Screen:
return new SwfBlendModeData(SwfBlendModeData.Types.Screen);
case SwfBlendMode.Mode.Lighten:
return new SwfBlendModeData(SwfBlendModeData.Types.Lighten);
case SwfBlendMode.Mode.Darken:
return new SwfBlendModeData(SwfBlendModeData.Types.Darken);
case SwfBlendMode.Mode.Difference:
return new SwfBlendModeData(SwfBlendModeData.Types.Difference);
case SwfBlendMode.Mode.Add:
return new SwfBlendModeData(SwfBlendModeData.Types.Add);
case SwfBlendMode.Mode.Subtract:
return new SwfBlendModeData(SwfBlendModeData.Types.Subtract);
case SwfBlendMode.Mode.Invert:
return new SwfBlendModeData(SwfBlendModeData.Types.Invert);
case SwfBlendMode.Mode.Hardlight:
return new SwfBlendModeData(SwfBlendModeData.Types.Hardlight);
default:
Debug.LogWarningFormat(
"<b>[FlashTools]</b> SwfBlendMode. Unsupported blend mode '{0}'",
self.Value);
return new SwfBlendModeData(SwfBlendModeData.Types.Normal);
}
}
public static SwfColorTransData ToColorTransData(this SwfColorTransform self) {
var trans = SwfColorTransData.identity;
if ( self.HasAdd ) {
trans.addColor = new SwfVec4Data(
self.RAdd / 256.0f,
self.GAdd / 256.0f,
self.BAdd / 256.0f,
self.AAdd / 256.0f);
}
if ( self.HasMul ) {
trans.mulColor = new SwfVec4Data(
self.RMul / 256.0f,
self.GMul / 256.0f,
self.BMul / 256.0f,
self.AMul / 256.0f);
}
return trans;
}
}
} }

View File

@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 484a94bbfa1744985a66e8f387d32d00
folderAsset: yes
timeCreated: 1457862313
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 45e892bdc5efe44c0bef4552f2dcb5b0
timeCreated: 1458464395
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 642f43b0b67924926879406770376159
timeCreated: 1458066637
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: ec49e670db02d4006b7722966e96ede6
timeCreated: 1457864588
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: add0a02be3196481daaf1fd9828f0f4e
timeCreated: 1457819513
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 15db74a10abbb4b35ab17143a18753a5
folderAsset: yes
timeCreated: 1457805943
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 6ffeb1c85031245dcbcdb64b486fa91c
timeCreated: 1472925860
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 9a86e93cfb4a14b91bca7f9669b7ee7e
timeCreated: 1457806192
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 93930c1f11b8b4299b5b252c8d1e44cc
timeCreated: 1457806180
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 8861b3a830cd64ddb8e2b3373a6952dc
timeCreated: 1457806126
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: c14bd04574d2540f5b4c834e394ff09b
timeCreated: 1457806145
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 17f96f9e9841246658fdc871e73cc2cc
timeCreated: 1457806154
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 8588b2fc4ef4a49cfb422ae16057b33b
timeCreated: 1457806164
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 4c4031f2278a949ea8f13253950a43d6
timeCreated: 1457806135
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: d3c659fdccfff42f9a79049ed13aab4f
timeCreated: 1457806204
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 1644c7cd661b049a0afab118c09d69a5
timeCreated: 1472819662
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: b616323c0469d4e81ba73869b289b21e
timeCreated: 1472880545
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: e5d4c7d7a464b4c44be8b8653686760e
timeCreated: 1472880531
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 40db138046cd1449a9e0a3d5020d9963
timeCreated: 1472925852
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: cfab3868fff1148f3ada0a0bb74b660b
timeCreated: 1457806094
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 91d525c5510d747daa79a206efa73ee8
timeCreated: 1472655466
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 7799f56fc5f01418f99c69da8d177010
timeCreated: 1457806214
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 6324f9cc87fb24045bbc089ff54e7969
timeCreated: 1457806085
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: cc3acad5d3b2f4f6c85b645acc3ba632
timeCreated: 1472881090
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: b1fd75a14bb004dcbaf692b2cf9b7498
timeCreated: 1457806017
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: f0b85321c9e164303a2fb2a6106f6699
timeCreated: 1457806030
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: ba536e4ee6b3848948e7208a1cefefdf
timeCreated: 1457806006
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 20eb1ce1437f24232afac6c8d35d11ef
timeCreated: 1472880066
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 50a3f4c3646154192b0c4dcb40b315b3
timeCreated: 1457806055
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: a66815e233fed447f8319dd343167b2e
timeCreated: 1457806046
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 2e2d082e1df494a31acef10d5e90be69
timeCreated: 1472880814
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 9ba6ee247270a4e2582be095c59f59bf
timeCreated: 1457806076
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 06e82bd9e78964590b8b35dbe6ca47c0
timeCreated: 1457806067
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: dc12052cbac15441bb21840c82f5ebbc
timeCreated: 1457805979
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: a50cd5b2e4fdc4596a01180777325faa
timeCreated: 1458065417
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: dc9919be0498b49659aa77f6da045eb9
timeCreated: 1472654295
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 15edc6d79a7fc4bbcb127dd779a0bc13
timeCreated: 1457806224
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: fd477bfe9657d4fdfad37644ef25c1c6
timeCreated: 1471528636
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: c6e637f9f090c4acbb2fecefe412c91c
folderAsset: yes
timeCreated: 1457881315
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,97 +0,0 @@
using UnityEngine;
namespace FlashTools.Internal.SwfTools.SwfTypes {
public struct SwfBlendMode {
public enum Mode {
Normal, // +
Layer, // +
Multiply, // +
Screen, // +
Lighten, // +
Darken, // +
Difference, // +
Add, // +
Subtract, // +
Invert, // +
Alpha, // -
Erase, // -
Overlay, // +
Hardlight // +
}
public Mode Value;
public static SwfBlendMode identity {
get {
return new SwfBlendMode{
Value = Mode.Normal};
}
}
public static SwfBlendMode Read(SwfStreamReader reader) {
var mode_id = reader.ReadByte();
return new SwfBlendMode{
Value = ModeFromByte(mode_id)};
}
public override string ToString() {
return string.Format(
"SwfBlendMode. Mode: {0}",
Value);
}
public SwfBlendModeData ToBlendModeData() {
switch ( Value ) {
case Mode.Normal:
return new SwfBlendModeData(SwfBlendModeData.Types.Normal);
case Mode.Layer:
return new SwfBlendModeData(SwfBlendModeData.Types.Layer);
case Mode.Multiply:
return new SwfBlendModeData(SwfBlendModeData.Types.Multiply);
case Mode.Screen:
return new SwfBlendModeData(SwfBlendModeData.Types.Screen);
case Mode.Lighten:
return new SwfBlendModeData(SwfBlendModeData.Types.Lighten);
case Mode.Darken:
return new SwfBlendModeData(SwfBlendModeData.Types.Darken);
case Mode.Difference:
return new SwfBlendModeData(SwfBlendModeData.Types.Difference);
case Mode.Add:
return new SwfBlendModeData(SwfBlendModeData.Types.Add);
case Mode.Subtract:
return new SwfBlendModeData(SwfBlendModeData.Types.Subtract);
case Mode.Invert:
return new SwfBlendModeData(SwfBlendModeData.Types.Invert);
case Mode.Hardlight:
return new SwfBlendModeData(SwfBlendModeData.Types.Hardlight);
default:
Debug.LogWarningFormat(
"<b>[FlashTools]</b> SwfBlendMode. Unsupported blend mode '{0}'",
Value);
return new SwfBlendModeData(SwfBlendModeData.Types.Normal);
}
}
static Mode ModeFromByte(byte mode_id) {
switch ( mode_id ) {
case 0: // Mode.Normal too
case 1: return Mode.Normal;
case 2: return Mode.Layer;
case 3: return Mode.Multiply;
case 4: return Mode.Screen;
case 5: return Mode.Lighten;
case 6: return Mode.Darken;
case 7: return Mode.Difference;
case 8: return Mode.Add;
case 9: return Mode.Subtract;
case 10: return Mode.Invert;
case 11: return Mode.Alpha;
case 12: return Mode.Erase;
case 13: return Mode.Overlay;
case 14: return Mode.Hardlight;
default:
throw new UnityException(string.Format(
"Incorrect blend mode id: {0}", mode_id));
}
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 1f87ec74e6af540748af80d4a1cc1b49
timeCreated: 1457882212
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 1daabaaa9d07a4d9184fe8dd1928803f
timeCreated: 1457881505
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 3bdf80e6c1ea34969a12400fa1a4a03b
timeCreated: 1457881354
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: f85807ea0dc87404983006ba9b04ebb7
timeCreated: 1457881474
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 904b18edf65b7485fb93fdeec65e93d3
timeCreated: 1457881525
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 392129356a8e143989e89d24bb52060e
timeCreated: 1457976003
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: b6ee0fe9207424e20a8f928a9d72df91
timeCreated: 1457881396
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: c0843850979784e0eb2ef2e2f7d3ef8c
timeCreated: 1457881450
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: ce2e00762eae848eeab3f543b6ccd368
timeCreated: 1457881342
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 9ad135e326c424eb2a9bb593525c4192
timeCreated: 1457881438
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,41 +0,0 @@
using UnityEngine;
using System.IO;
namespace FlashTools.Internal.SwfTools.SwfTypes {
public struct SwfShortHeader {
public string Format;
public byte Version;
public uint FileLength;
public static SwfShortHeader Read(SwfStreamReader reader) {
var header = new SwfShortHeader();
header.Format = new string(reader.ReadChars(3));
header.Version = reader.ReadByte();
header.FileLength = reader.ReadUInt32();
return header;
}
public void Write(Stream stream) {
if ( Format == null || Format.Length != 3 ) {
throw new UnityException(string.Format(
"Incorrect SwfShortHeader Format: {0}",
Format));
}
stream.WriteByte((byte)Format[0]);
stream.WriteByte((byte)Format[1]);
stream.WriteByte((byte)Format[2]);
stream.WriteByte(Version);
stream.WriteByte((byte)((FileLength >> 0) & 0xFF));
stream.WriteByte((byte)((FileLength >> 8) & 0xFF));
stream.WriteByte((byte)((FileLength >> 16) & 0xFF));
stream.WriteByte((byte)((FileLength >> 24) & 0xFF));
}
public override string ToString() {
return string.Format(
"SwfShortHeader. " +
"Format: {0}, Version: {1}, FileLength: {2}",
Format, Version, FileLength);
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 669a2dd77726b497aab3e816c280e023
timeCreated: 1457881385
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 9160ac10286e843ccb7fae733e9de5d8
timeCreated: 1457881516
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools { namespace SwfTools {
using LibraryDefines = SortedDictionary<ushort, SwfLibraryDefine>; using LibraryDefines = SortedDictionary<ushort, SwfLibraryDefine>;
using DisplayInstances = SortedDictionary<ushort, SwfDisplayInstance>; using DisplayInstances = SortedDictionary<ushort, SwfDisplayInstance>;

View File

@@ -1,10 +1,10 @@
using UnityEngine; using System.Linq;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using FlashTools.Internal.SwfTools.SwfTags;
using FlashTools.Internal.SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools { using SwfTools.SwfTags;
using SwfTools.SwfTypes;
namespace SwfTools {
public class SwfContextExecuter : SwfTagVisitor<SwfDisplayList, SwfDisplayList> { public class SwfContextExecuter : SwfTagVisitor<SwfDisplayList, SwfDisplayList> {
public SwfLibrary Library = null; public SwfLibrary Library = null;
public int CurrentTag = 0; public int CurrentTag = 0;
@@ -18,7 +18,6 @@ namespace FlashTools.Internal.SwfTools {
dl.FrameName = string.Empty; dl.FrameName = string.Empty;
while ( CurrentTag < tags.Count ) { while ( CurrentTag < tags.Count ) {
var tag = tags[CurrentTag++]; var tag = tags[CurrentTag++];
TagToDebugLog(tag);
tag.AcceptVistor(this, dl); tag.AcceptVistor(this, dl);
if ( tag.TagType == SwfTagType.ShowFrame ) { if ( tag.TagType == SwfTagType.ShowFrame ) {
ChildrenNextFrameLooped(dl); ChildrenNextFrameLooped(dl);
@@ -53,12 +52,8 @@ namespace FlashTools.Internal.SwfTools {
} }
public SwfDisplayList Visit(PlaceObject2Tag tag, SwfDisplayList dl) { public SwfDisplayList Visit(PlaceObject2Tag tag, SwfDisplayList dl) {
var is_shape = tag.HasCharacter var is_shape = tag.HasCharacter && Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
? Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId) var is_sprite = tag.HasCharacter && Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
: false;
var is_sprite = tag.HasCharacter
? Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId)
: false;
if ( tag.HasCharacter ) { if ( tag.HasCharacter ) {
SwfDisplayInstance old_inst = null; SwfDisplayInstance old_inst = null;
if ( tag.Move ) { // replace character if ( tag.Move ) { // replace character
@@ -102,12 +97,8 @@ namespace FlashTools.Internal.SwfTools {
} }
public SwfDisplayList Visit(PlaceObject3Tag tag, SwfDisplayList dl) { public SwfDisplayList Visit(PlaceObject3Tag tag, SwfDisplayList dl) {
var is_shape = tag.HasCharacter var is_shape = tag.HasCharacter && Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId);
? Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId) var is_sprite = tag.HasCharacter && Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId);
: false;
var is_sprite = tag.HasCharacter
? Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId)
: false;
if ( tag.HasCharacter ) { if ( tag.HasCharacter ) {
SwfDisplayInstance old_inst = null; SwfDisplayInstance old_inst = null;
if ( tag.Move ) { // replace character if ( tag.Move ) { // replace character
@@ -373,13 +364,5 @@ namespace FlashTools.Internal.SwfTools {
} }
} }
} }
void TagToDebugLog(SwfTagBase tag) {
if ( tag is UnsupportedTag || tag is UnknownTag ) {
Debug.LogWarningFormat(
"<b>[FlashTools]</b> SwfContextExecuter. {0}",
tag);
}
}
} }
} }

View File

@@ -1,10 +1,10 @@
using UnityEngine; using System.IO;
using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using FlashTools.Internal.SwfTools.SwfTags;
using FlashTools.Internal.SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools { using SwfTools.SwfTags;
using SwfTools.SwfTypes;
namespace SwfTools {
public class SwfDecoder { public class SwfDecoder {
public SwfShortHeader OriginalHeader; public SwfShortHeader OriginalHeader;
public SwfLongHeader UncompressedHeader; public SwfLongHeader UncompressedHeader;
@@ -30,12 +30,12 @@ namespace FlashTools.Internal.SwfTools {
Version = OriginalHeader.Version, Version = OriginalHeader.Version,
FileLength = OriginalHeader.FileLength}; FileLength = OriginalHeader.FileLength};
var uncompressed_stream = new MemoryStream(); var uncompressed_stream = new MemoryStream();
new_short_header.Write(uncompressed_stream); SwfShortHeader.Write(new_short_header, uncompressed_stream);
rest_stream.WriteTo(uncompressed_stream); rest_stream.WriteTo(uncompressed_stream);
uncompressed_stream.Position = 0; uncompressed_stream.Position = 0;
return uncompressed_stream; return uncompressed_stream;
default: default:
throw new UnityException(string.Format( throw new System.Exception(string.Format(
"Unsupported swf format: {0}", OriginalHeader.Format)); "Unsupported swf format: {0}", OriginalHeader.Format));
} }
} }

View File

@@ -1,9 +1,10 @@
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using Ionic.Zlib; using Ionic.Zlib;
namespace FlashTools.Internal.SwfTools { namespace SwfTools {
public class SwfStreamReader { public class SwfStreamReader {
struct BitContext { struct BitContext {
public byte CachedByte; public byte CachedByte;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class DefineBinaryDataTag : SwfTagBase { public class DefineBinaryDataTag : SwfTagBase {
public ushort Tag; public ushort Tag;
public byte[] Data; public byte[] Data;

View File

@@ -1,6 +1,4 @@
using UnityEngine; namespace SwfTools.SwfTags {
namespace FlashTools.Internal.SwfTools.SwfTags {
public class DefineBitsLossless2Tag : SwfTagBase { public class DefineBitsLossless2Tag : SwfTagBase {
public ushort CharacterId; public ushort CharacterId;
public byte BitmapFormat; public byte BitmapFormat;
@@ -51,7 +49,7 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
} }
} else { } else {
//TODO: IMPLME //TODO: IMPLME
throw new UnityException(string.Format( throw new System.Exception(string.Format(
"Unsupported DefineBitsLossless2 Format: {0}", BitmapFormat)); "Unsupported DefineBitsLossless2 Format: {0}", BitmapFormat));
} }
return result; return result;

View File

@@ -1,6 +1,4 @@
using UnityEngine; namespace SwfTools.SwfTags {
namespace FlashTools.Internal.SwfTools.SwfTags {
public class DefineBitsLosslessTag : SwfTagBase { public class DefineBitsLosslessTag : SwfTagBase {
public ushort CharacterId; public ushort CharacterId;
public byte BitmapFormat; public byte BitmapFormat;
@@ -51,7 +49,7 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
} }
} else { } else {
//TODO: IMPLME //TODO: IMPLME
throw new UnityException(string.Format( throw new System.Exception(string.Format(
"Unsupported DefineBitsLossless Format: {0}", BitmapFormat)); "Unsupported DefineBitsLossless Format: {0}", BitmapFormat));
} }
return result; return result;

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class DefineSceneAndFrameLabelDataTag : SwfTagBase { public class DefineSceneAndFrameLabelDataTag : SwfTagBase {
public struct SceneOffsetData { public struct SceneOffsetData {
public uint Offset; public uint Offset;

View File

@@ -1,6 +1,6 @@
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class DefineShape2Tag : SwfTagBase { public class DefineShape2Tag : SwfTagBase {
public ushort ShapeId; public ushort ShapeId;
public SwfRect ShapeBounds; public SwfRect ShapeBounds;

View File

@@ -1,6 +1,6 @@
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class DefineShape3Tag : SwfTagBase { public class DefineShape3Tag : SwfTagBase {
public ushort ShapeId; public ushort ShapeId;
public SwfRect ShapeBounds; public SwfRect ShapeBounds;

View File

@@ -1,6 +1,6 @@
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class DefineShape4Tag : SwfTagBase { public class DefineShape4Tag : SwfTagBase {
public ushort ShapeId; public ushort ShapeId;
public SwfRect ShapeBounds; public SwfRect ShapeBounds;

View File

@@ -1,6 +1,6 @@
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class DefineShapeTag : SwfTagBase { public class DefineShapeTag : SwfTagBase {
public ushort ShapeId; public ushort ShapeId;
public SwfRect ShapeBounds; public SwfRect ShapeBounds;

View File

@@ -1,6 +1,6 @@
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class DefineSpriteTag : SwfTagBase { public class DefineSpriteTag : SwfTagBase {
public ushort SpriteId; public ushort SpriteId;
public ushort FrameCount; public ushort FrameCount;

View File

@@ -1,6 +1,6 @@
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class DoABCTag : SwfTagBase { public class DoABCTag : SwfTagBase {
public bool ExecuteImmediately; public bool ExecuteImmediately;
public string Name; public string Name;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class EnableDebugger2Tag : SwfTagBase { public class EnableDebugger2Tag : SwfTagBase {
public string MD5PasswordHash; public string MD5PasswordHash;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class EnableDebuggerTag : SwfTagBase { public class EnableDebuggerTag : SwfTagBase {
public string MD5PasswordHash; public string MD5PasswordHash;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class EnableTelemetryTag : SwfTagBase { public class EnableTelemetryTag : SwfTagBase {
public byte[] SHA256PasswordHash; public byte[] SHA256PasswordHash;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class EndTag : SwfTagBase { public class EndTag : SwfTagBase {
public override SwfTagType TagType { public override SwfTagType TagType {
get { return SwfTagType.End; } get { return SwfTagType.End; }

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class ExportAssetsTag : SwfTagBase { public class ExportAssetsTag : SwfTagBase {
public struct AssetTagData { public struct AssetTagData {
public ushort Tag; public ushort Tag;
@@ -26,7 +26,7 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
public static ExportAssetsTag Create(SwfStreamReader reader) { public static ExportAssetsTag Create(SwfStreamReader reader) {
var asset_tag_count = reader.ReadUInt16(); var asset_tag_count = reader.ReadUInt16();
var asset_tags = new List<AssetTagData>((int)asset_tag_count); var asset_tags = new List<AssetTagData>(asset_tag_count);
for ( var i = 0; i < asset_tag_count; ++i ) { for ( var i = 0; i < asset_tag_count; ++i ) {
asset_tags.Add(new AssetTagData{ asset_tags.Add(new AssetTagData{
Tag = reader.ReadUInt16(), Tag = reader.ReadUInt16(),

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class FileAttributesTag : SwfTagBase { public class FileAttributesTag : SwfTagBase {
public override SwfTagType TagType { public override SwfTagType TagType {
get { return SwfTagType.FileAttributes; } get { return SwfTagType.FileAttributes; }

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class FrameLabelTag : SwfTagBase { public class FrameLabelTag : SwfTagBase {
public string Name; public string Name;
public byte AnchorFlag; public byte AnchorFlag;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class MetadataTag : SwfTagBase { public class MetadataTag : SwfTagBase {
public string Metadata; public string Metadata;

View File

@@ -1,7 +1,7 @@
using System.Text; using System.Text;
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class PlaceObject2Tag : SwfTagBase { public class PlaceObject2Tag : SwfTagBase {
public bool HasClipActions; public bool HasClipActions;
public bool HasClipDepth; public bool HasClipDepth;

View File

@@ -1,7 +1,7 @@
using System.Text; using System.Text;
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class PlaceObject3Tag : SwfTagBase { public class PlaceObject3Tag : SwfTagBase {
public bool HasClipActions; public bool HasClipActions;
public bool HasClipDepth; public bool HasClipDepth;

View File

@@ -1,6 +1,6 @@
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class PlaceObjectTag : SwfTagBase { public class PlaceObjectTag : SwfTagBase {
public ushort CharacterId; public ushort CharacterId;
public ushort Depth; public ushort Depth;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class ProtectTag : SwfTagBase { public class ProtectTag : SwfTagBase {
public string MD5Password; public string MD5Password;
@@ -12,7 +12,7 @@
public override string ToString() { public override string ToString() {
return string.Format( return string.Format(
"ProtectTag." + "ProtectTag. " +
"MD5Password: {0}", "MD5Password: {0}",
MD5Password); MD5Password);
} }

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class RemoveObject2Tag : SwfTagBase { public class RemoveObject2Tag : SwfTagBase {
public ushort Depth; public ushort Depth;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class RemoveObjectTag : SwfTagBase { public class RemoveObjectTag : SwfTagBase {
public ushort CharacterId; public ushort CharacterId;
public ushort Depth; public ushort Depth;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class ScriptLimitsTag : SwfTagBase { public class ScriptLimitsTag : SwfTagBase {
public ushort MaxRecursionDepth; public ushort MaxRecursionDepth;
public ushort ScriptTimeoutSeconds; public ushort ScriptTimeoutSeconds;

View File

@@ -1,6 +1,6 @@
using FlashTools.Internal.SwfTools.SwfTypes; using SwfTools.SwfTypes;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class SetBackgroundColorTag : SwfTagBase { public class SetBackgroundColorTag : SwfTagBase {
public SwfColor BackgroundColor; public SwfColor BackgroundColor;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class ShowFrameTag : SwfTagBase { public class ShowFrameTag : SwfTagBase {
public override SwfTagType TagType { public override SwfTagType TagType {
get { return SwfTagType.ShowFrame; } get { return SwfTagType.ShowFrame; }

View File

@@ -1,34 +1,34 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public enum SwfTagType { public enum SwfTagType {
// ----------------------------- // -----------------------------
// Display list // Display list
// ----------------------------- // -----------------------------
PlaceObject = 4, PlaceObject = 4,
PlaceObject2 = 26, PlaceObject2 = 26,
PlaceObject3 = 70, PlaceObject3 = 70,
RemoveObject = 5, RemoveObject = 5,
RemoveObject2 = 28, RemoveObject2 = 28,
ShowFrame = 1, ShowFrame = 1,
// ----------------------------- // -----------------------------
// Control // Control
// ----------------------------- // -----------------------------
SetBackgroundColor = 9, SetBackgroundColor = 9,
FrameLabel = 43, FrameLabel = 43,
Protect = 24, Protect = 24,
End = 0, End = 0,
ExportAssets = 56, ExportAssets = 56,
ImportAssets = 57, // Unsupported ImportAssets = 57, // Unsupported
EnableDebugger = 58, EnableDebugger = 58,
EnableDebugger2 = 64, EnableDebugger2 = 64,
ScriptLimits = 65, ScriptLimits = 65,
SetTabIndex = 66, // Unsupported SetTabIndex = 66, // Unsupported
ImportAssets2 = 71, // Unsupported ImportAssets2 = 71, // Unsupported
SymbolClass = 76, SymbolClass = 76,
Metadata = 77, Metadata = 77,
DefineScalingGrid = 78, // Unsupported DefineScalingGrid = 78, // Unsupported
DefineSceneAndFrameLabelData = 86, DefineSceneAndFrameLabelData = 86,
// ----------------------------- // -----------------------------
@@ -121,8 +121,8 @@
// Metadata // Metadata
// ----------------------------- // -----------------------------
FileAttributes = 69, FileAttributes = 69,
EnableTelemetry = 93, EnableTelemetry = 93,
DefineBinaryData = 87, DefineBinaryData = 87,
// ----------------------------- // -----------------------------

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public interface SwfTagVisitor<TArg, TResult> { public interface SwfTagVisitor<TArg, TResult> {
TResult Visit(PlaceObjectTag tag, TArg arg); TResult Visit(PlaceObjectTag tag, TArg arg);
TResult Visit(PlaceObject2Tag tag, TArg arg); TResult Visit(PlaceObject2Tag tag, TArg arg);
@@ -6,6 +6,7 @@
TResult Visit(RemoveObjectTag tag, TArg arg); TResult Visit(RemoveObjectTag tag, TArg arg);
TResult Visit(RemoveObject2Tag tag, TArg arg); TResult Visit(RemoveObject2Tag tag, TArg arg);
TResult Visit(ShowFrameTag tag, TArg arg); TResult Visit(ShowFrameTag tag, TArg arg);
TResult Visit(SetBackgroundColorTag tag, TArg arg); TResult Visit(SetBackgroundColorTag tag, TArg arg);
TResult Visit(FrameLabelTag tag, TArg arg); TResult Visit(FrameLabelTag tag, TArg arg);
TResult Visit(ProtectTag tag, TArg arg); TResult Visit(ProtectTag tag, TArg arg);
@@ -17,17 +18,23 @@
TResult Visit(SymbolClassTag tag, TArg arg); TResult Visit(SymbolClassTag tag, TArg arg);
TResult Visit(MetadataTag tag, TArg arg); TResult Visit(MetadataTag tag, TArg arg);
TResult Visit(DefineSceneAndFrameLabelDataTag tag, TArg arg); TResult Visit(DefineSceneAndFrameLabelDataTag tag, TArg arg);
TResult Visit(DoABCTag tag, TArg arg); TResult Visit(DoABCTag tag, TArg arg);
TResult Visit(DefineShapeTag tag, TArg arg); TResult Visit(DefineShapeTag tag, TArg arg);
TResult Visit(DefineShape2Tag tag, TArg arg); TResult Visit(DefineShape2Tag tag, TArg arg);
TResult Visit(DefineShape3Tag tag, TArg arg); TResult Visit(DefineShape3Tag tag, TArg arg);
TResult Visit(DefineShape4Tag tag, TArg arg); TResult Visit(DefineShape4Tag tag, TArg arg);
TResult Visit(DefineBitsLosslessTag tag, TArg arg); TResult Visit(DefineBitsLosslessTag tag, TArg arg);
TResult Visit(DefineBitsLossless2Tag tag, TArg arg); TResult Visit(DefineBitsLossless2Tag tag, TArg arg);
TResult Visit(DefineSpriteTag tag, TArg arg); TResult Visit(DefineSpriteTag tag, TArg arg);
TResult Visit(FileAttributesTag tag, TArg arg); TResult Visit(FileAttributesTag tag, TArg arg);
TResult Visit(EnableTelemetryTag tag, TArg arg); TResult Visit(EnableTelemetryTag tag, TArg arg);
TResult Visit(DefineBinaryDataTag tag, TArg arg); TResult Visit(DefineBinaryDataTag tag, TArg arg);
TResult Visit(UnknownTag tag, TArg arg); TResult Visit(UnknownTag tag, TArg arg);
TResult Visit(UnsupportedTag tag, TArg arg); TResult Visit(UnsupportedTag tag, TArg arg);
} }

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class SymbolClassTag : SwfTagBase { public class SymbolClassTag : SwfTagBase {
public struct SymbolTagData { public struct SymbolTagData {
public ushort Tag; public ushort Tag;
@@ -26,7 +26,7 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
public static SymbolClassTag Create(SwfStreamReader reader) { public static SymbolClassTag Create(SwfStreamReader reader) {
var symbol_tag_count = reader.ReadUInt16(); var symbol_tag_count = reader.ReadUInt16();
var symbol_tags = new List<SymbolTagData>((int)symbol_tag_count); var symbol_tags = new List<SymbolTagData>(symbol_tag_count);
for ( var i = 0; i < symbol_tag_count; ++i ) { for ( var i = 0; i < symbol_tag_count; ++i ) {
symbol_tags.Add(new SymbolTagData{ symbol_tags.Add(new SymbolTagData{
Tag = reader.ReadUInt16(), Tag = reader.ReadUInt16(),

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class UnknownTag : SwfTagBase { public class UnknownTag : SwfTagBase {
public int _tagId; public int _tagId;

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTags { namespace SwfTools.SwfTags {
public class UnsupportedTag : SwfTagBase { public class UnsupportedTag : SwfTagBase {
SwfTagType _tagType; SwfTagType _tagType;
@@ -12,7 +12,8 @@
public override string ToString() { public override string ToString() {
return string.Format( return string.Format(
"{0}. Unsupported tag!", "UnsupportedTag. " +
"TagType: {0}",
TagType); TagType);
} }

View File

@@ -0,0 +1,65 @@
namespace SwfTools.SwfTypes {
public struct SwfBlendMode {
public enum Mode {
Normal,
Layer,
Multiply,
Screen,
Lighten,
Darken,
Difference,
Add,
Subtract,
Invert,
Alpha,
Erase,
Overlay,
Hardlight
}
public Mode Value;
public static SwfBlendMode identity {
get {
return new SwfBlendMode{
Value = Mode.Normal};
}
}
public static SwfBlendMode Read(SwfStreamReader reader) {
var mode_id = reader.ReadByte();
return new SwfBlendMode{
Value = ModeFromByte(mode_id)};
}
public override string ToString() {
return string.Format(
"SwfBlendMode. " +
"Mode: {0}",
Value);
}
static Mode ModeFromByte(byte mode_id) {
switch ( mode_id ) {
case 0: // Mode.Normal too
case 1: return Mode.Normal;
case 2: return Mode.Layer;
case 3: return Mode.Multiply;
case 4: return Mode.Screen;
case 5: return Mode.Lighten;
case 6: return Mode.Darken;
case 7: return Mode.Difference;
case 8: return Mode.Add;
case 9: return Mode.Subtract;
case 10: return Mode.Invert;
case 11: return Mode.Alpha;
case 12: return Mode.Erase;
case 13: return Mode.Overlay;
case 14: return Mode.Hardlight;
default:
throw new System.Exception(string.Format(
"Incorrect blend mode id: {0}",
mode_id));
}
}
}
}

View File

@@ -1,6 +1,4 @@
using UnityEngine; namespace SwfTools.SwfTypes {
namespace FlashTools.Internal.SwfTools.SwfTypes {
public struct SwfClipActions { public struct SwfClipActions {
public static SwfClipActions identity { public static SwfClipActions identity {
get { get {
@@ -9,7 +7,7 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
} }
public static SwfClipActions Read(SwfStreamReader reader) { public static SwfClipActions Read(SwfStreamReader reader) {
throw new UnityException("Clip actions is unsupported"); throw new System.Exception("Clip actions is unsupported");
} }
public override string ToString() { public override string ToString() {

View File

@@ -1,6 +1,4 @@
using UnityEngine; namespace SwfTools.SwfTypes {
namespace FlashTools.Internal.SwfTools.SwfTypes {
public struct SwfColor { public struct SwfColor {
public byte R; public byte R;
public byte G; public byte G;
@@ -31,7 +29,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
public override string ToString() { public override string ToString() {
return string.Format( return string.Format(
"SwfColor. R: {0}, G: {1}, B: {2}, A: {3}", "SwfColor. " +
"R: {0}, G: {1}, B: {2}, A: {3}",
R, G, B, A); R, G, B, A);
} }
} }

View File

@@ -1,6 +1,4 @@
using UnityEngine; namespace SwfTools.SwfTypes {
namespace FlashTools.Internal.SwfTools.SwfTypes {
public struct SwfColorTransform { public struct SwfColorTransform {
public short RMul; public short RMul;
public short GMul; public short GMul;
@@ -58,24 +56,5 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
RMul, GMul, GMul, AMul, HasMul, RMul, GMul, GMul, AMul, HasMul,
RAdd, GAdd, BAdd, AAdd, HasAdd); RAdd, GAdd, BAdd, AAdd, HasAdd);
} }
public SwfColorTransData ToColorTransData() {
var trans = SwfColorTransData.identity;
if ( HasAdd ) {
trans.addColor = new SwfVec4Data(
RAdd / 256.0f,
GAdd / 256.0f,
BAdd / 256.0f,
AAdd / 256.0f);
}
if ( HasMul ) {
trans.mulColor = new SwfVec4Data(
RMul / 256.0f,
GMul / 256.0f,
BMul / 256.0f,
AMul / 256.0f);
}
return trans;
}
} }
} }

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using FlashTools.Internal.SwfTools.SwfTags; using SwfTools.SwfTags;
namespace FlashTools.Internal.SwfTools.SwfTypes { namespace SwfTools.SwfTypes {
public struct SwfControlTags { public struct SwfControlTags {
public List<SwfTagBase> Tags; public List<SwfTagBase> Tags;
@@ -26,7 +26,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
public override string ToString() { public override string ToString() {
return string.Format( return string.Format(
"SwfControlTags. Tags: {0}", "SwfControlTags. " +
"Tags: {0}",
Tags.Count); Tags.Count);
} }
} }

View File

@@ -1,6 +1,4 @@
using UnityEngine; namespace SwfTools.SwfTypes {
namespace FlashTools.Internal.SwfTools.SwfTypes {
public struct SwfFillStyleType { public struct SwfFillStyleType {
public enum Type { public enum Type {
SolidColor, SolidColor,
@@ -29,7 +27,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
public override string ToString() { public override string ToString() {
return string.Format( return string.Format(
"SwfFillStyleType. Type: {0}", "SwfFillStyleType. " +
"Type: {0}",
Value); Value);
} }
@@ -65,8 +64,9 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
case 0x42: return Type.NonSmoothedRepeatingBitmap; case 0x42: return Type.NonSmoothedRepeatingBitmap;
case 0x43: return Type.NonSmoothedClippedBitmap; case 0x43: return Type.NonSmoothedClippedBitmap;
default: default:
throw new UnityException(string.Format( throw new System.Exception(string.Format(
"Incorrect fill stype type id: {0}", type_id)); "Incorrect fill stype type id: {0}",
type_id));
} }
} }
} }

View File

@@ -1,4 +1,4 @@
namespace FlashTools.Internal.SwfTools.SwfTypes { namespace SwfTools.SwfTypes {
public struct SwfLongHeader { public struct SwfLongHeader {
public SwfShortHeader ShortHeader; public SwfShortHeader ShortHeader;
public SwfRect FrameSize; public SwfRect FrameSize;
@@ -6,12 +6,11 @@
public ushort FrameCount; public ushort FrameCount;
public static SwfLongHeader Read(SwfStreamReader reader) { public static SwfLongHeader Read(SwfStreamReader reader) {
var header = new SwfLongHeader(); return new SwfLongHeader{
header.ShortHeader = SwfShortHeader.Read(reader); ShortHeader = SwfShortHeader.Read(reader),
header.FrameSize = SwfRect.Read(reader); FrameSize = SwfRect.Read(reader),
header.FrameRate = reader.ReadFixedPoint_8_8(); FrameRate = reader.ReadFixedPoint_8_8(),
header.FrameCount = reader.ReadUInt16(); FrameCount = reader.ReadUInt16()};
return header;
} }
public override string ToString() { public override string ToString() {

View File

@@ -1,6 +1,4 @@
using UnityEngine; namespace SwfTools.SwfTypes {
namespace FlashTools.Internal.SwfTools.SwfTypes {
public struct SwfMatrix { public struct SwfMatrix {
public float ScaleX; public float ScaleX;
public float ScaleY; public float ScaleY;
@@ -58,16 +56,5 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
RotateSkew0, RotateSkew1, RotateSkew0, RotateSkew1,
TranslateX, TranslateY); TranslateX, TranslateY);
} }
public Matrix4x4 ToUMatrix() {
var mat = Matrix4x4.identity;
mat.m00 = ScaleX;
mat.m10 = RotateSkew0;
mat.m01 = RotateSkew1;
mat.m11 = ScaleY;
mat.m03 = TranslateX;
mat.m13 = TranslateY;
return mat;
}
} }
} }

View File

@@ -1,6 +1,4 @@
using UnityEngine; namespace SwfTools.SwfTypes {
namespace FlashTools.Internal.SwfTools.SwfTypes {
public struct SwfRect { public struct SwfRect {
public float XMin; public float XMin;
public float XMax; public float XMax;

Some files were not shown because too many files have changed in this diff Show More