mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 14:11:19 +07:00
new swf animation wip
This commit is contained in:
@@ -49,12 +49,17 @@
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\FlashAnimAssetPostprocessor.cs" />
|
||||
<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\SwfAnimationAssetEditor.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfAnimationAssetPostprocessor.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfAnimationEditor.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfPostprocessor.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfContext.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfContextExecuter.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfDecoder.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfDisplayList.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfStreamReader.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineBitsLossless2Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineBitsLosslessTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineScalingGridTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineSceneAndFrameLabelDataTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineShape2Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\DefineShape3Tag.cs" />
|
||||
@@ -70,20 +75,18 @@
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\RemoveObject2Tag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\RemoveObjectTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\SetBackgroundColorTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\SetTabIndexTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\ShowFrameTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\SwfTagBase.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\SwfTagVisitor.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTags\UnknownTag.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfBlendMode.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfClipActions.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfColorTransformRGB.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfColorTransformRGBA.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfColor.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfColorTransform.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfControlTags.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfFillStyleType.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfLongHeaderType.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfMatrix.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfRGB.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfRGBA.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfRect.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfShapesWithStyle.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\Internal\Editor\SwfTools\SwfTypes\SwfShortHeader.cs" />
|
||||
@@ -113,6 +116,9 @@
|
||||
<Reference Include="UnityEditor.TreeEditor">
|
||||
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/TreeEditor/Editor/UnityEditor.TreeEditor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Ionic.Zip.Unity">
|
||||
<HintPath>/Users/matov/Programming/Projects/unityflash/Assets/Plugins/Ionic.Zip.Unity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEditor.Graphs">
|
||||
<HintPath>/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEditor.Graphs.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -142,9 +148,6 @@
|
||||
</Reference>
|
||||
<Reference Include="UnityEditor.OSXStandalone.Extensions">
|
||||
<HintPath>/Applications/Unity/PlaybackEngines/MacStandaloneSupport/UnityEditor.OSXStandalone.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Ionic.Zip.Unity">
|
||||
<HintPath>/Users/matov/Programming/Projects/unityflash/Assets/Plugins/Ionic.Zip.Unity.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Assets\FlashTools\Scripts\FlashAnim.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\FlashAnimAsset.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\SwfAnimation.cs" />
|
||||
<Compile Include="Assets\FlashTools\Scripts\SwfAnimationAsset.cs" />
|
||||
<None Include="Assets\FlashTools\Shaders\FlashAnim.shader" />
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>/Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
|
||||
|
||||
Binary file not shown.
@@ -1,71 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using FlashTools.Internal.SwfTools;
|
||||
using FlashTools.Internal.SwfTools.SwfTags;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
public class FlashAnimSwfPostprocessor : AssetPostprocessor {
|
||||
static void OnPostprocessAllAssets(
|
||||
string[] imported_assets, string[] deleted_assets,
|
||||
string[] moved_assets, string[] moved_from_asset_paths)
|
||||
{
|
||||
var swf_asset_paths = imported_assets
|
||||
.Where(p => Path.GetExtension(p).ToLower().Equals(".swf"));
|
||||
foreach ( var swf_asset_path in swf_asset_paths ) {
|
||||
SwfAssetProcess(swf_asset_path);
|
||||
}
|
||||
}
|
||||
|
||||
static void SwfAssetProcess(string swf_asset) {
|
||||
Debug.LogFormat("SwfAssetProcess: {0}", swf_asset);
|
||||
var decoder = new SwfDecoder(swf_asset);
|
||||
Debug.LogWarningFormat(
|
||||
"OriginalHeader: {0}",
|
||||
decoder.OriginalHeader);
|
||||
Debug.LogWarningFormat(
|
||||
"UncompressedHeader: {0}",
|
||||
decoder.UncompressedHeader);
|
||||
Debug.LogWarningFormat(
|
||||
"Tags: {0}",
|
||||
decoder.Tags.Count);
|
||||
foreach ( var tag in decoder.Tags ) {
|
||||
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);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
[CustomEditor(typeof(SwfAnimationAsset))]
|
||||
public class SwfAnimationAssetEditor : Editor {
|
||||
SwfAnimationAsset _asset = null;
|
||||
|
||||
static void ApplySettings(SwfAnimationAsset asset) {
|
||||
if ( asset.Atlas ) {
|
||||
AssetDatabase.DeleteAsset(
|
||||
AssetDatabase.GetAssetPath(asset.Atlas));
|
||||
asset.Atlas = null;
|
||||
}
|
||||
AssetDatabase.ImportAsset(
|
||||
AssetDatabase.GetAssetPath(asset),
|
||||
ImportAssetOptions.ForceUncompressedImport);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
// Messages
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
void OnEnable() {
|
||||
_asset = target as SwfAnimationAsset;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
DrawDefaultInspector();
|
||||
if ( GUILayout.Button("Apply settings") ) {
|
||||
ApplySettings(_asset);
|
||||
}
|
||||
GUILayout.BeginHorizontal();
|
||||
if ( GUILayout.Button("Create animation prefab") ) {
|
||||
}
|
||||
if ( GUILayout.Button("Create animation on scene") ) {
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3941fb765685542b5b22249c0820b023
|
||||
timeCreated: 1457806104
|
||||
guid: 68f7548b1be4a4629a59fd17ff62f1c2
|
||||
timeCreated: 1458054584
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
public class SwfAnimationAssetPostprocessor : AssetPostprocessor {
|
||||
static void OnPostprocessAllAssets(
|
||||
string[] imported_assets, string[] deleted_assets,
|
||||
string[] moved_assets, string[] moved_from_asset_paths)
|
||||
{
|
||||
var asset_paths = imported_assets
|
||||
.Where(p => Path.GetExtension(p).ToLower().Equals(".asset"));
|
||||
foreach ( var asset_path in asset_paths ) {
|
||||
var asset = AssetDatabase.LoadAssetAtPath<SwfAnimationAsset>(asset_path);
|
||||
if ( asset ) {
|
||||
AssetProcess(asset_path, asset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void AssetProcess(string asset_path, SwfAnimationAsset asset) {
|
||||
try {
|
||||
} catch ( Exception e ) {
|
||||
Debug.LogErrorFormat(
|
||||
"Postprocess swf animation asset error: {0}",
|
||||
e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b74e206a586d948f880a7f2bd86cb469
|
||||
timeCreated: 1457881464
|
||||
guid: 91866390a580d4f728f84d5fab9202b8
|
||||
timeCreated: 1458057686
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
[CustomEditor(typeof(SwfAnimation))]
|
||||
public class SwfAnimationEditor : Editor {
|
||||
SwfAnimation _animation = null;
|
||||
|
||||
void OnEnable() {
|
||||
_animation = target as SwfAnimation;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
DrawDefaultInspector();
|
||||
if ( _animation.Asset && _animation.frameCount > 1 ) {
|
||||
var new_current_frame = EditorGUILayout.IntSlider(
|
||||
"Frame", _animation.currentFrame,
|
||||
0, _animation.frameCount - 1);
|
||||
if ( new_current_frame != _animation.currentFrame ) {
|
||||
_animation.currentFrame = new_current_frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03bab2d6ff7054cac9a8d14d9ba20731
|
||||
timeCreated: 1457806116
|
||||
guid: 40e69fd373e75451283f0389b624e18e
|
||||
timeCreated: 1458054572
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
138
Assets/FlashTools/Scripts/Internal/Editor/SwfPostprocessor.cs
Normal file
138
Assets/FlashTools/Scripts/Internal/Editor/SwfPostprocessor.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using FlashTools.Internal.SwfTools;
|
||||
using FlashTools.Internal.SwfTools.SwfTags;
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal {
|
||||
public class SwfPostprocessor : AssetPostprocessor {
|
||||
static void OnPostprocessAllAssets(
|
||||
string[] imported_assets, string[] deleted_assets,
|
||||
string[] moved_assets, string[] moved_from_asset_paths)
|
||||
{
|
||||
var swf_asset_paths = imported_assets
|
||||
.Where(p => Path.GetExtension(p).ToLower().Equals(".swf"));
|
||||
foreach ( var swf_asset_path in swf_asset_paths ) {
|
||||
SwfAssetProcess(swf_asset_path);
|
||||
}
|
||||
}
|
||||
|
||||
static void SwfAssetProcess(string swf_asset) {
|
||||
var swf_animation_data = LoadDataFromSwfFile(swf_asset);
|
||||
if ( swf_animation_data != null ) {
|
||||
var new_asset_path = Path.ChangeExtension(swf_asset, ".asset");
|
||||
var new_asset = AssetDatabase.LoadAssetAtPath<SwfAnimationAsset>(new_asset_path);
|
||||
if ( !new_asset ) {
|
||||
new_asset = ScriptableObject.CreateInstance<SwfAnimationAsset>();
|
||||
AssetDatabase.CreateAsset(new_asset, new_asset_path);
|
||||
}
|
||||
new_asset.Data = swf_animation_data;
|
||||
EditorUtility.SetDirty(new_asset);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
static SwfAnimationData LoadDataFromSwfFile(string swf_asset) {
|
||||
try {
|
||||
var decoder = new SwfDecoder(swf_asset);
|
||||
return new SwfAnimationData{
|
||||
FrameRate = decoder.UncompressedHeader.FrameRate,
|
||||
Frames = LoadFramesFromSwfDecoder(decoder)};
|
||||
} catch ( Exception e ) {
|
||||
Debug.LogErrorFormat("Parsing swf error: {0}", e.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static List<SwfAnimationFrameData> LoadFramesFromSwfDecoder(SwfDecoder decoder) {
|
||||
var frames = new List<SwfAnimationFrameData>();
|
||||
var context = new SwfContext();
|
||||
var executer = new SwfContextExecuter(context, 0);
|
||||
while ( executer.NextFrame(decoder.Tags, context.DisplayList) ) {
|
||||
var frame = new SwfAnimationFrameData();
|
||||
frame.Name = context.DisplayList.FrameName;
|
||||
AddDisplayListToFrame(
|
||||
context,
|
||||
context.DisplayList,
|
||||
Matrix4x4.identity,
|
||||
SwfAnimationColorTransform.identity,
|
||||
frame);
|
||||
frames.Add(frame);
|
||||
}
|
||||
return frames;
|
||||
}
|
||||
|
||||
static void AddDisplayListToFrame(
|
||||
SwfContext ctx, SwfDisplayList dl,
|
||||
Matrix4x4 parent_matrix, SwfAnimationColorTransform parent_color_transform,
|
||||
SwfAnimationFrameData frame)
|
||||
{
|
||||
foreach ( var inst in dl.Insts.Values ) {
|
||||
switch ( inst.Type ) {
|
||||
case SwfDisplayInstType.Shape:
|
||||
var shape_def = ctx.Library.FindDefine<SwfLibraryShapeDefine>(inst.Id);
|
||||
if ( shape_def != null ) {
|
||||
for ( var i = 0; i < shape_def.Bitmaps.Length; ++i ) {
|
||||
var bitmap_id = shape_def.Bitmaps[i];
|
||||
var bitmap_matrix = i < shape_def.Matrices.Length
|
||||
? shape_def.Matrices[i] : SwfMatrix.Identity;
|
||||
var bitmap_def = ctx.Library.FindDefine<SwfLibraryBitmapDefine>(bitmap_id);
|
||||
if ( bitmap_def != null ) {
|
||||
frame.Insts.Add(new SwfAnimationInstData{
|
||||
Bitmap = bitmap_id,
|
||||
Matrix = parent_matrix * inst.Matrix.ToUnityMatrix() * bitmap_matrix.ToUnityMatrix(),
|
||||
ColorTransform = parent_color_transform * inst.ColorTransform.ToAnimationColorTransform()});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SwfDisplayInstType.Sprite:
|
||||
var sprite_def = ctx.Library.FindDefine<SwfLibrarySpriteDefine>(inst.Id);
|
||||
if ( sprite_def != null ) {
|
||||
var sprite_inst = inst as SwfDisplaySpriteInst;
|
||||
AddDisplayListToFrame(
|
||||
ctx,
|
||||
sprite_inst.DisplayList,
|
||||
parent_matrix * sprite_inst.Matrix.ToUnityMatrix(),
|
||||
parent_color_transform * sprite_inst.ColorTransform.ToAnimationColorTransform(),
|
||||
frame);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new UnityException(string.Format(
|
||||
"Unsupported SwfDisplayInstType: {0}", inst.Type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
108
Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfContext.cs
Normal file
108
Assets/FlashTools/Scripts/Internal/Editor/SwfTools/SwfContext.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System.Collections.Generic;
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools {
|
||||
|
||||
//
|
||||
// SwfDisplayList
|
||||
//
|
||||
|
||||
public enum SwfDisplayInstType {
|
||||
Shape,
|
||||
Sprite
|
||||
}
|
||||
|
||||
public abstract class SwfDisplayInst {
|
||||
public abstract SwfDisplayInstType Type { get; }
|
||||
|
||||
public ushort Id;
|
||||
public ushort Depth;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransform ColorTransform;
|
||||
}
|
||||
|
||||
public class SwfDisplayShapeInst : SwfDisplayInst {
|
||||
public override SwfDisplayInstType Type {
|
||||
get { return SwfDisplayInstType.Shape; }
|
||||
}
|
||||
}
|
||||
|
||||
public class SwfDisplaySpriteInst : SwfDisplayInst {
|
||||
public int CurrentTag = 0;
|
||||
public SwfDisplayList DisplayList = new SwfDisplayList();
|
||||
public override SwfDisplayInstType Type {
|
||||
get { return SwfDisplayInstType.Sprite; }
|
||||
}
|
||||
}
|
||||
|
||||
public class SwfDisplayList {
|
||||
public string FrameName = string.Empty;
|
||||
public SortedDictionary<ushort, SwfDisplayInst> Insts =
|
||||
new SortedDictionary<ushort, SwfDisplayInst>();
|
||||
}
|
||||
|
||||
//
|
||||
// SwfLibrary
|
||||
//
|
||||
|
||||
public enum SwfLibraryDefineType {
|
||||
Shape,
|
||||
Bitmap,
|
||||
Sprite
|
||||
}
|
||||
|
||||
public abstract class SwfLibraryDefine {
|
||||
public abstract SwfLibraryDefineType Type { get; }
|
||||
}
|
||||
|
||||
public class SwfLibraryShapeDefine : SwfLibraryDefine {
|
||||
public ushort[] Bitmaps = new ushort[0];
|
||||
public SwfMatrix[] Matrices = new SwfMatrix[0];
|
||||
public override SwfLibraryDefineType Type {
|
||||
get { return SwfLibraryDefineType.Shape; }
|
||||
}
|
||||
}
|
||||
|
||||
public class SwfLibraryBitmapDefine : SwfLibraryDefine {
|
||||
public override SwfLibraryDefineType Type {
|
||||
get { return SwfLibraryDefineType.Bitmap; }
|
||||
}
|
||||
}
|
||||
|
||||
public class SwfLibrarySpriteDefine : SwfLibraryDefine {
|
||||
public SwfControlTags ControlTags = new SwfControlTags();
|
||||
public override SwfLibraryDefineType Type {
|
||||
get { return SwfLibraryDefineType.Sprite; }
|
||||
}
|
||||
}
|
||||
|
||||
public class SwfLibrary {
|
||||
public SortedDictionary<ushort, SwfLibraryDefine> Defines =
|
||||
new SortedDictionary<ushort, SwfLibraryDefine>();
|
||||
|
||||
public bool HasDefine<T>(ushort define_id) where T : SwfLibraryDefine {
|
||||
SwfLibraryDefine def;
|
||||
if ( Defines.TryGetValue(define_id, out def) ) {
|
||||
return (def as T) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public T FindDefine<T>(ushort define_id) where T : SwfLibraryDefine {
|
||||
SwfLibraryDefine def;
|
||||
if ( Defines.TryGetValue(define_id, out def) ) {
|
||||
return def as T;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// SwfContext
|
||||
//
|
||||
|
||||
public class SwfContext {
|
||||
public SwfLibrary Library = new SwfLibrary();
|
||||
public SwfDisplayList DisplayList = new SwfDisplayList();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b8e88250d67a42979b1d9f40699c769
|
||||
timeCreated: 1457881364
|
||||
guid: 45e892bdc5efe44c0bef4552f2dcb5b0
|
||||
timeCreated: 1458464395
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,190 @@
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using FlashTools.Internal.SwfTools.SwfTags;
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools {
|
||||
public class SwfContextExecuter : SwfTagVisitor<SwfDisplayList, SwfDisplayList> {
|
||||
public SwfContext MainContex = null;
|
||||
public int CurrentTag = 0;
|
||||
|
||||
public SwfContextExecuter(SwfContext main_context, int current_tag) {
|
||||
MainContex = main_context;
|
||||
CurrentTag = current_tag;
|
||||
}
|
||||
|
||||
public bool NextFrame(List<SwfTagBase> tags, SwfDisplayList dl) {
|
||||
dl.FrameName = string.Empty;
|
||||
while ( CurrentTag < tags.Count ) {
|
||||
var tag = tags[CurrentTag++];
|
||||
tag.AcceptVistor(this, dl);
|
||||
if ( tag.TagType == SwfTagType.ShowFrame ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(PlaceObjectTag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(PlaceObject2Tag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
var is_shape = tag.HasCharacter
|
||||
? MainContex.Library.HasDefine<SwfLibraryShapeDefine >(tag.CharacterId)
|
||||
: false;
|
||||
var is_sprite = tag.HasCharacter
|
||||
? MainContex.Library.HasDefine<SwfLibrarySpriteDefine>(tag.CharacterId)
|
||||
: false;
|
||||
if ( !tag.Move && tag.HasCharacter ) { // new character
|
||||
SwfDisplayInst new_inst = null;
|
||||
if ( is_shape ) {
|
||||
new_inst = new SwfDisplayShapeInst();
|
||||
} else if ( is_sprite ) {
|
||||
new_inst = new SwfDisplaySpriteInst();
|
||||
}
|
||||
if ( new_inst != null ) {
|
||||
new_inst.Id = tag.CharacterId;
|
||||
new_inst.Depth = tag.Depth;
|
||||
new_inst.Matrix = tag.HasMatrix ? tag.Matrix : SwfMatrix.Identity;
|
||||
new_inst.ColorTransform = tag.HasColorTransform ? tag.ColorTransform : SwfColorTransform.Identity;
|
||||
dl.Insts.Add(new_inst.Depth, new_inst);
|
||||
}
|
||||
} else if ( tag.Move && !tag.HasCharacter ) { // move character
|
||||
} else if ( tag.Move && tag.HasCharacter ) { // replace character
|
||||
}
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(PlaceObject3Tag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(RemoveObjectTag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
dl.Insts.Remove(tag.Depth);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(RemoveObject2Tag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
dl.Insts.Remove(tag.Depth);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(ShowFrameTag tag, SwfDisplayList dl) {
|
||||
Debug.LogError(tag);
|
||||
var sprites = dl.Insts.Values
|
||||
.Where (p => p.Type == SwfDisplayInstType.Sprite)
|
||||
.Select(p => p as SwfDisplaySpriteInst);
|
||||
foreach ( var sprite in sprites ) {
|
||||
var sprite_def = MainContex.Library.FindDefine<SwfLibrarySpriteDefine>(sprite.Id);
|
||||
if ( sprite_def != null ) {
|
||||
var sprite_executer = new SwfContextExecuter(MainContex, sprite.CurrentTag);
|
||||
sprite_executer.NextFrame(sprite_def.ControlTags.Tags, sprite.DisplayList);
|
||||
sprite.CurrentTag = sprite_executer.CurrentTag;
|
||||
}
|
||||
}
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(SetBackgroundColorTag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(FrameLabelTag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
dl.FrameName = tag.Name;
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(EndTag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(DefineSceneAndFrameLabelDataTag tag, SwfDisplayList dl) {
|
||||
Debug.LogWarning(tag);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(DefineShapeTag tag, SwfDisplayList dl) {
|
||||
Debug.LogWarning(tag);
|
||||
AddShapesToLibrary(tag.ShapeId, tag.Shapes);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(DefineShape2Tag tag, SwfDisplayList dl) {
|
||||
Debug.LogWarning(tag);
|
||||
AddShapesToLibrary(tag.ShapeId, tag.Shapes);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(DefineShape3Tag tag, SwfDisplayList dl) {
|
||||
Debug.LogWarning(tag);
|
||||
AddShapesToLibrary(tag.ShapeId, tag.Shapes);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(DefineShape4Tag tag, SwfDisplayList dl) {
|
||||
Debug.LogWarning(tag);
|
||||
AddShapesToLibrary(tag.ShapeId, tag.Shapes);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(DefineBitsLosslessTag tag, SwfDisplayList dl) {
|
||||
Debug.LogWarning(tag);
|
||||
AddZlibBitmapToLibrary(tag.CharacterId);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(DefineBitsLossless2Tag tag, SwfDisplayList dl) {
|
||||
Debug.LogWarning(tag);
|
||||
AddZlibBitmapToLibrary(tag.CharacterId);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(DefineSpriteTag tag, SwfDisplayList dl) {
|
||||
Debug.LogWarning(tag);
|
||||
var define = new SwfLibrarySpriteDefine{
|
||||
ControlTags = tag.ControlTags
|
||||
};
|
||||
MainContex.Library.Defines.Add(tag.SpriteId, define);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(FileAttributesTag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
return dl;
|
||||
}
|
||||
|
||||
public SwfDisplayList Visit(UnknownTag tag, SwfDisplayList dl) {
|
||||
Debug.Log(tag);
|
||||
return dl;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
void AddShapesToLibrary(ushort define_id, SwfShapesWithStyle shapes) {
|
||||
var bitmap_styles = shapes.FillStyles.Where(p => p.Type.IsBitmapType);
|
||||
var define = new SwfLibraryShapeDefine{
|
||||
Bitmaps = bitmap_styles.Select(p => p.BitmapId).ToArray(),
|
||||
Matrices = bitmap_styles.Select(p => p.BitmapMatrix).ToArray()
|
||||
};
|
||||
MainContex.Library.Defines.Add(define_id, define);
|
||||
}
|
||||
|
||||
void AddZlibBitmapToLibrary(ushort define_id) {
|
||||
//TODO: IMPLME
|
||||
var define = new SwfLibraryBitmapDefine{};
|
||||
MainContex.Library.Defines.Add(define_id, define);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 642f43b0b67924926879406770376159
|
||||
timeCreated: 1458066637
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,10 +3,9 @@ using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using FlashTools.Internal.SwfTools.SwfTags;
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
using Ionic.Zlib;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools {
|
||||
class SwfDecoder {
|
||||
public class SwfDecoder {
|
||||
public SwfShortHeader OriginalHeader;
|
||||
public SwfLongHeader UncompressedHeader;
|
||||
public List<SwfTagBase> Tags = new List<SwfTagBase>();
|
||||
@@ -24,13 +23,14 @@ namespace FlashTools.Internal.SwfTools {
|
||||
case "FWS":
|
||||
return new MemoryStream(raw_swf_data);
|
||||
case "CWS":
|
||||
var rest_stream = DecompressZBytes(raw_reader.ReadRest());
|
||||
var rest_stream = SwfStreamReader.DecompressZBytes(
|
||||
raw_reader.ReadRest());
|
||||
var new_short_header = new SwfShortHeader{
|
||||
Format = "FWS",
|
||||
Version = OriginalHeader.Version,
|
||||
FileLength = OriginalHeader.FileLength
|
||||
};
|
||||
var uncompressed_stream = new MemoryStream((int)OriginalHeader.FileLength);
|
||||
var uncompressed_stream = new MemoryStream();
|
||||
new_short_header.Write(uncompressed_stream);
|
||||
rest_stream.WriteTo(uncompressed_stream);
|
||||
uncompressed_stream.Position = 0;
|
||||
@@ -44,16 +44,12 @@ namespace FlashTools.Internal.SwfTools {
|
||||
void DecodeSwf(SwfStreamReader reader) {
|
||||
UncompressedHeader = SwfLongHeader.Read(reader);
|
||||
while ( !reader.IsEOF ) {
|
||||
Tags.Add(SwfTagBase.Read(reader));
|
||||
var tag = SwfTagBase.Read(reader);
|
||||
if ( tag.TagType == SwfTagType.End ) {
|
||||
break;
|
||||
}
|
||||
Tags.Add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
static public MemoryStream DecompressZBytes(byte[] compressed_bytes) {
|
||||
var target = new MemoryStream();
|
||||
var zip_stream = new ZlibStream(target, CompressionMode.Decompress);
|
||||
zip_stream.Write(compressed_bytes, 0, compressed_bytes.Length);
|
||||
target.Position = 0;
|
||||
return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System.Collections.Generic;
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools {
|
||||
|
||||
/*
|
||||
using SwfDisplayStack = List<SwfDisplayInst>;
|
||||
using SwfDisplayLibrary = Dictionary<ushort, SwfDisplayDefine>;
|
||||
|
||||
public enum SwfDisplayDefineType {
|
||||
Shape,
|
||||
Sprite
|
||||
}
|
||||
|
||||
public enum SwfDisplayInstType {
|
||||
Shape,
|
||||
Sprite
|
||||
}
|
||||
|
||||
//
|
||||
// SwfDisplayDefine
|
||||
//
|
||||
|
||||
public interface SwfDisplayDefine {
|
||||
SwfDisplayDefineType Type { get; }
|
||||
}
|
||||
|
||||
public struct SwfDisplayShapeDefine : SwfDisplayDefine {
|
||||
public ushort[] Bitmaps;
|
||||
public SwfMatrix[] Matrices;
|
||||
public SwfDisplayDefineType Type {
|
||||
get { return SwfDisplayDefineType.Shape; }
|
||||
}
|
||||
}
|
||||
|
||||
public struct SwfDisplaySpriteDefine : SwfDisplayDefine {
|
||||
public SwfControlTags ControlTags;
|
||||
public SwfDisplayDefineType Type {
|
||||
get { return SwfDisplayDefineType.Sprite; }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// SwfDisplayInst
|
||||
//
|
||||
|
||||
public interface SwfDisplayInst {
|
||||
SwfDisplayInstType Type { get; }
|
||||
}
|
||||
|
||||
public struct SwfDisplayShapeInst : SwfDisplayInst {
|
||||
public ushort Id;
|
||||
public ushort Depth;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransform ColorTransform;
|
||||
public SwfDisplayInstType Type {
|
||||
get { return SwfDisplayInstType.Shape; }
|
||||
}
|
||||
}
|
||||
|
||||
public struct SwfDisplaySpriteInst : SwfDisplayInst {
|
||||
public ushort Id;
|
||||
public ushort Depth;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransform ColorTransform;
|
||||
public SwfDisplayInstType Type {
|
||||
get { return SwfDisplayInstType.Sprite; }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// SwfDisplayList
|
||||
//
|
||||
|
||||
public class SwfDisplayList {
|
||||
public SwfDisplayStack Stack = new SwfDisplayStack();
|
||||
public SwfDisplayLibrary Library = new SwfDisplayLibrary();
|
||||
public string FrameName = string.Empty;
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5766901c2b9314167a2ae682d52c622e
|
||||
timeCreated: 1458066561
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +1,10 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Ionic.Zlib;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools {
|
||||
class SwfStreamReader {
|
||||
public class SwfStreamReader {
|
||||
struct BitContext {
|
||||
public byte CachedByte;
|
||||
public byte BitIndex;
|
||||
@@ -165,5 +166,13 @@ namespace FlashTools.Internal.SwfTools {
|
||||
val |= (bt & 0x7Fu) << 28;
|
||||
return val;
|
||||
}
|
||||
|
||||
static public MemoryStream DecompressZBytes(byte[] compressed_bytes) {
|
||||
var target = new MemoryStream();
|
||||
var zip_stream = new ZlibStream(target, CompressionMode.Decompress);
|
||||
zip_stream.Write(compressed_bytes, 0, compressed_bytes.Length);
|
||||
target.Position = 0;
|
||||
return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class DefineBitsLossless2Tag : SwfTagBase {
|
||||
public class DefineBitsLossless2Tag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public byte BitmapFormat;
|
||||
public ushort BitmapWidth;
|
||||
@@ -11,6 +11,10 @@
|
||||
get { return SwfTagType.DefineBitsLossless2; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineBitsLossless2Tag. " +
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class DefineBitsLosslessTag : SwfTagBase {
|
||||
public class DefineBitsLosslessTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public byte BitmapFormat;
|
||||
public ushort BitmapWidth;
|
||||
@@ -11,6 +11,10 @@
|
||||
get { return SwfTagType.DefineBitsLossless; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineBitsLosslessTag. " +
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.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.ReadUInt16();
|
||||
tag.Splitter = SwfRect.Read(reader);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class DefineSceneAndFrameLabelDataTag : SwfTagBase {
|
||||
public class DefineSceneAndFrameLabelDataTag : SwfTagBase {
|
||||
public struct SceneOffsetData {
|
||||
public uint Offset;
|
||||
public string Name;
|
||||
@@ -19,6 +19,10 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
get { return SwfTagType.DefineSceneAndFrameLabelData; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineSceneAndFrameLabelDataTag. " +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class DefineShape2Tag : SwfTagBase {
|
||||
public class DefineShape2Tag : SwfTagBase {
|
||||
public ushort ShapeId;
|
||||
public SwfRect ShapeBounds;
|
||||
public SwfShapesWithStyle Shapes;
|
||||
@@ -10,6 +10,10 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
get { return SwfTagType.DefineShape2; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineShape2Tag. " +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class DefineShape3Tag : SwfTagBase {
|
||||
public class DefineShape3Tag : SwfTagBase {
|
||||
public ushort ShapeId;
|
||||
public SwfRect ShapeBounds;
|
||||
public SwfShapesWithStyle Shapes;
|
||||
@@ -10,6 +10,10 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
get { return SwfTagType.DefineShape3; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineShape3Tag. " +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class DefineShape4Tag : SwfTagBase {
|
||||
public class DefineShape4Tag : SwfTagBase {
|
||||
public ushort ShapeId;
|
||||
public SwfRect ShapeBounds;
|
||||
public SwfRect EdgeBounds;
|
||||
@@ -11,6 +11,10 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
get { return SwfTagType.DefineShape4; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineShape4Tag. " +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class DefineShapeTag : SwfTagBase {
|
||||
public class DefineShapeTag : SwfTagBase {
|
||||
public ushort ShapeId;
|
||||
public SwfRect ShapeBounds;
|
||||
public SwfShapesWithStyle Shapes;
|
||||
@@ -10,6 +10,10 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
get { return SwfTagType.DefineShape; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineShapeTag. " +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class DefineSpriteTag : SwfTagBase {
|
||||
public class DefineSpriteTag : SwfTagBase {
|
||||
public ushort SpriteId;
|
||||
public ushort FrameCount;
|
||||
public SwfControlTags ControlTags;
|
||||
@@ -10,11 +10,15 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
get { return SwfTagType.DefineSprite; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"DefineSpriteTag. " +
|
||||
"SpriteId: {0}, FrameCount: {1}, ControlTags: {2}",
|
||||
SpriteId, FrameCount, ControlTags.Tags);
|
||||
SpriteId, FrameCount, ControlTags.Tags.Count);
|
||||
}
|
||||
|
||||
public static DefineSpriteTag Create(SwfStreamReader reader) {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class EndTag : SwfTagBase {
|
||||
public class EndTag : SwfTagBase {
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.End; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "EndTag.";
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class FileAttributesTag : SwfTagBase {
|
||||
public class FileAttributesTag : SwfTagBase {
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.FileAttributes; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "FileAttributesTag.";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class FrameLabelTag : SwfTagBase {
|
||||
public class FrameLabelTag : SwfTagBase {
|
||||
public string Name;
|
||||
public byte AnchorFlag;
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
get { return SwfTagType.FrameLabel; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"FrameLabelTag. " +
|
||||
|
||||
@@ -2,28 +2,32 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.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 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 SwfColorTransform ColorTransform;
|
||||
public ushort Ratio;
|
||||
public string Name;
|
||||
public ushort ClipDepth;
|
||||
public SwfClipActions ClipActions;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.PlaceObject2; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder(1024);
|
||||
sb.Append("PlaceObject2Tag. ");
|
||||
@@ -70,7 +74,7 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
tag.Matrix = SwfMatrix.Read(reader);
|
||||
}
|
||||
if ( tag.HasColorTransform ) {
|
||||
tag.ColorTransform = SwfColorTransformRGBA.Read(reader);
|
||||
tag.ColorTransform = SwfColorTransform.Read(reader, true);
|
||||
}
|
||||
if ( tag.HasRatio ) {
|
||||
tag.Ratio = reader.ReadUInt16();
|
||||
|
||||
@@ -2,41 +2,45 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.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 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 SwfColorTransform ColorTransform;
|
||||
public ushort Ratio;
|
||||
public string Name;
|
||||
public ushort ClipDepth;
|
||||
public SwfSurfaceFilters SurfaceFilters;
|
||||
public SwfBlendMode BlendMode;
|
||||
public byte BitmapCache;
|
||||
public byte Visible;
|
||||
public SwfColor BackgroundColor;
|
||||
public SwfClipActions ClipActions;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.PlaceObject3; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder(1024);
|
||||
sb.Append("PlaceObject3Tag. ");
|
||||
@@ -94,7 +98,7 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
tag.Matrix = SwfMatrix.Read(reader);
|
||||
}
|
||||
if ( tag.HasColorTransform ) {
|
||||
tag.ColorTransform = SwfColorTransformRGBA.Read(reader);
|
||||
tag.ColorTransform = SwfColorTransform.Read(reader, true);
|
||||
}
|
||||
if ( tag.HasRatio ) {
|
||||
tag.Ratio = reader.ReadUInt16();
|
||||
@@ -116,7 +120,7 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
}
|
||||
if ( tag.HasVisible ) {
|
||||
tag.Visible = reader.ReadByte();
|
||||
tag.BackgroundColor = SwfRGBA.Read(reader);
|
||||
tag.BackgroundColor = SwfColor.Read(reader, true);
|
||||
}
|
||||
if ( tag.HasClipActions ) {
|
||||
tag.ClipActions = SwfClipActions.Read(reader);
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class PlaceObjectTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public ushort Depth;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransformRGB ColorTransform;
|
||||
public class PlaceObjectTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public ushort Depth;
|
||||
public SwfMatrix Matrix;
|
||||
public SwfColorTransform ColorTransform;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.PlaceObject; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"PlaceObjectTag. " +
|
||||
@@ -23,8 +27,10 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
tag.CharacterId = reader.ReadUInt16();
|
||||
tag.Depth = reader.ReadUInt16();
|
||||
tag.Matrix = SwfMatrix.Read(reader);
|
||||
if ( !reader.IsEOF ) {
|
||||
tag.ColorTransform = SwfColorTransformRGB.Read(reader);
|
||||
if ( reader.IsEOF ) {
|
||||
tag.ColorTransform = SwfColorTransform.Identity;
|
||||
} else {
|
||||
tag.ColorTransform = SwfColorTransform.Read(reader, false);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class RemoveObject2Tag : SwfTagBase {
|
||||
public class RemoveObject2Tag : SwfTagBase {
|
||||
public ushort Depth;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.RemoveObject2; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"RemoveObject2Tag. " +
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class RemoveObjectTag : SwfTagBase {
|
||||
public class RemoveObjectTag : SwfTagBase {
|
||||
public ushort CharacterId;
|
||||
public ushort Depth;
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
get { return SwfTagType.RemoveObject; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"RemoveObjectTag. " +
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class SetBackgroundColorTag : SwfTagBase {
|
||||
public SwfRGB BackgroundColor;
|
||||
public class SetBackgroundColorTag : SwfTagBase {
|
||||
public SwfColor BackgroundColor;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.SetBackgroundColor; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SetBackgroundColorTag. " +
|
||||
@@ -17,7 +21,7 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
|
||||
public static SetBackgroundColorTag Create(SwfStreamReader reader) {
|
||||
var tag = new SetBackgroundColorTag();
|
||||
tag.BackgroundColor = SwfRGB.Read(reader);
|
||||
tag.BackgroundColor = SwfColor.Read(reader, false);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
namespace FlashTools.Internal.SwfTools.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.ReadUInt16();
|
||||
tag.TabIndex = reader.ReadUInt16();
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class ShowFrameTag : SwfTagBase {
|
||||
public class ShowFrameTag : SwfTagBase {
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.ShowFrame; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "ShowFrameTag.";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
enum SwfTagType {
|
||||
public enum SwfTagType {
|
||||
// -----------------------------
|
||||
// Display list
|
||||
// -----------------------------
|
||||
@@ -24,11 +24,11 @@
|
||||
//EnableDebugger = 58,
|
||||
//EnableDebugger2 = 64,
|
||||
//ScriptLimits = 65,
|
||||
SetTabIndex = 66,
|
||||
//SetTabIndex = 66,
|
||||
//ImportAssets2 = 71,
|
||||
//SymbolClass = 76,
|
||||
//Metadata = 77,
|
||||
DefineScalingGrid = 78,
|
||||
//DefineScalingGrid = 78,
|
||||
DefineSceneAndFrameLabelData = 86,
|
||||
|
||||
// -----------------------------
|
||||
@@ -132,13 +132,15 @@
|
||||
Unknown
|
||||
}
|
||||
|
||||
abstract class SwfTagBase {
|
||||
public abstract class SwfTagBase {
|
||||
struct SwfTagData {
|
||||
public int TagId;
|
||||
public byte[] TagData;
|
||||
}
|
||||
|
||||
public abstract SwfTagType TagType { get; }
|
||||
public abstract TResult AcceptVistor<TArg, TResult>(
|
||||
SwfTagVisitor<TArg, TResult> visitor, TArg arg);
|
||||
|
||||
public static SwfTagBase Read(SwfStreamReader reader) {
|
||||
var type_and_size = reader.ReadUInt16();
|
||||
@@ -163,8 +165,6 @@
|
||||
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);
|
||||
@@ -178,4 +178,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
public interface SwfTagVisitor<TArg, TResult> {
|
||||
TResult Visit(PlaceObjectTag tag, TArg arg);
|
||||
TResult Visit(PlaceObject2Tag tag, TArg arg);
|
||||
TResult Visit(PlaceObject3Tag tag, TArg arg);
|
||||
TResult Visit(RemoveObjectTag tag, TArg arg);
|
||||
TResult Visit(RemoveObject2Tag tag, TArg arg);
|
||||
TResult Visit(ShowFrameTag tag, TArg arg);
|
||||
TResult Visit(SetBackgroundColorTag tag, TArg arg);
|
||||
TResult Visit(FrameLabelTag tag, TArg arg);
|
||||
TResult Visit(EndTag tag, TArg arg);
|
||||
TResult Visit(DefineSceneAndFrameLabelDataTag tag, TArg arg);
|
||||
TResult Visit(DefineShapeTag tag, TArg arg);
|
||||
TResult Visit(DefineShape2Tag tag, TArg arg);
|
||||
TResult Visit(DefineShape3Tag tag, TArg arg);
|
||||
TResult Visit(DefineShape4Tag tag, TArg arg);
|
||||
TResult Visit(DefineBitsLosslessTag tag, TArg arg);
|
||||
TResult Visit(DefineBitsLossless2Tag tag, TArg arg);
|
||||
TResult Visit(DefineSpriteTag tag, TArg arg);
|
||||
TResult Visit(FileAttributesTag tag, TArg arg);
|
||||
TResult Visit(UnknownTag tag, TArg arg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a50cd5b2e4fdc4596a01180777325faa
|
||||
timeCreated: 1458065417
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +1,15 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
class UnknownTag : SwfTagBase {
|
||||
public class UnknownTag : SwfTagBase {
|
||||
public int TagId;
|
||||
|
||||
public override SwfTagType TagType {
|
||||
get { return SwfTagType.Unknown; }
|
||||
}
|
||||
|
||||
public override TResult AcceptVistor<TArg, TResult>(SwfTagVisitor<TArg, TResult> visitor, TArg arg) {
|
||||
return visitor.Visit(this, arg);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"TagId: {0}", TagId);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfBlendMode {
|
||||
public struct SwfBlendMode {
|
||||
public enum Mode {
|
||||
Normal,
|
||||
Layer,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfClipActions {
|
||||
public struct SwfClipActions {
|
||||
public static SwfClipActions Read(SwfStreamReader reader) {
|
||||
//TODO: IMPLME
|
||||
return new SwfClipActions();
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
public struct SwfColor {
|
||||
public byte R;
|
||||
public byte G;
|
||||
public byte B;
|
||||
public byte A;
|
||||
|
||||
public static SwfColor Read(SwfStreamReader reader, bool with_alpha) {
|
||||
var color = new SwfColor();
|
||||
color.R = reader.ReadByte();
|
||||
color.G = reader.ReadByte();
|
||||
color.B = reader.ReadByte();
|
||||
color.A = with_alpha ? reader.ReadByte() : byte.MaxValue;
|
||||
return color;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SwfColor. R: {0}, G: {1}, B: {2}, A: {3}",
|
||||
R, G, B, A);
|
||||
}
|
||||
|
||||
public Color ToUnityColor() {
|
||||
return new Color(
|
||||
R / 255.0f,
|
||||
G / 255.0f,
|
||||
B / 255.0f,
|
||||
A / 255.0f);
|
||||
}
|
||||
|
||||
public Color ToUnityColor32() {
|
||||
return new Color32(
|
||||
R,
|
||||
G,
|
||||
B,
|
||||
A);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
public struct SwfColorTransform {
|
||||
public short RMul;
|
||||
public short GMul;
|
||||
public short BMul;
|
||||
public short AMul;
|
||||
public bool HasMul;
|
||||
public short RAdd;
|
||||
public short GAdd;
|
||||
public short BAdd;
|
||||
public short AAdd;
|
||||
public bool HasAdd;
|
||||
|
||||
public static SwfColorTransform Read(SwfStreamReader reader, bool with_alpha) {
|
||||
var transform = SwfColorTransform.Identity;
|
||||
transform.HasAdd = reader.ReadBit();
|
||||
transform.HasMul = reader.ReadBit();
|
||||
var bits = reader.ReadUnsignedBits(4);
|
||||
if ( transform.HasMul ) {
|
||||
transform.RMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.GMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.BMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.AMul = with_alpha ? (short)reader.ReadSignedBits(bits) : byte.MaxValue;
|
||||
}
|
||||
if ( transform.HasAdd ) {
|
||||
transform.RAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.GAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.BAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.AAdd = with_alpha ? (short)reader.ReadSignedBits(bits) : (short)0;
|
||||
}
|
||||
reader.AlignToByte();
|
||||
return transform;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SwfColorTransform. " +
|
||||
"RMul: {0}, GMul: {1}, BMul: {2}, AMul: {3}, HasMul: {4}, " +
|
||||
"RAdd: {5}, GAdd: {6}, BAdd: {7}, AAdd: {8}, HasAdd: {9}",
|
||||
RMul, GMul, GMul, AMul, HasMul,
|
||||
RAdd, GAdd, BAdd, AAdd, HasAdd);
|
||||
}
|
||||
|
||||
public SwfAnimationColorTransform ToAnimationColorTransform() {
|
||||
var trans = SwfAnimationColorTransform.identity;
|
||||
if ( HasAdd ) {
|
||||
trans.Add = new Vector4(
|
||||
RAdd / 255.0f,
|
||||
GAdd / 255.0f,
|
||||
BAdd / 255.0f,
|
||||
AAdd / 255.0f);
|
||||
}
|
||||
if ( HasMul ) {
|
||||
trans.Mul = new Vector4(
|
||||
RMul / 255.0f,
|
||||
GMul / 255.0f,
|
||||
BMul / 255.0f,
|
||||
AMul / 255.0f);
|
||||
}
|
||||
return trans;
|
||||
}
|
||||
|
||||
public static SwfColorTransform Identity {
|
||||
get {
|
||||
return new SwfColorTransform {
|
||||
RMul = byte.MaxValue,
|
||||
GMul = byte.MaxValue,
|
||||
BMul = byte.MaxValue,
|
||||
AMul = byte.MaxValue,
|
||||
HasMul = false,
|
||||
RAdd = 0,
|
||||
GAdd = 0,
|
||||
BAdd = 0,
|
||||
AAdd = 0,
|
||||
HasAdd = false};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfColorTransformRGB {
|
||||
public short RMul;
|
||||
public short GMul;
|
||||
public short BMul;
|
||||
public bool HasMul;
|
||||
public short RAdd;
|
||||
public short GAdd;
|
||||
public short BAdd;
|
||||
public bool HasAdd;
|
||||
|
||||
public static SwfColorTransformRGB Read(SwfStreamReader reader) {
|
||||
var transform = SwfColorTransformRGB.Identity;
|
||||
var has_add = reader.ReadBit();
|
||||
var has_mul = reader.ReadBit();
|
||||
var bits = reader.ReadUnsignedBits(4);
|
||||
if ( has_mul ) {
|
||||
transform.RMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.GMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.BMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.HasMul = true;
|
||||
}
|
||||
if ( has_add ) {
|
||||
transform.RAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.GAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.BAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.HasAdd = true;
|
||||
}
|
||||
reader.AlignToByte();
|
||||
return transform;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SwfColorTransformRGB. " +
|
||||
"RMul: {0}, GMul: {1}, BMul: {2}, HasMul: {3}, " +
|
||||
"RAdd: {4}, GAdd: {5}, BAdd: {6}, HasAdd: {7}",
|
||||
RMul, GMul, GMul, HasMul,
|
||||
RAdd, GAdd, BAdd, HasAdd);
|
||||
}
|
||||
|
||||
public static SwfColorTransformRGB Identity {
|
||||
get {
|
||||
return new SwfColorTransformRGB {
|
||||
RMul = 1,
|
||||
GMul = 1,
|
||||
BMul = 1,
|
||||
HasMul = false,
|
||||
RAdd = 0,
|
||||
GAdd = 0,
|
||||
BAdd = 0,
|
||||
HasAdd = false};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfColorTransformRGBA {
|
||||
public short RMul;
|
||||
public short GMul;
|
||||
public short BMul;
|
||||
public short AMul;
|
||||
public bool HasMul;
|
||||
public short RAdd;
|
||||
public short GAdd;
|
||||
public short BAdd;
|
||||
public short AAdd;
|
||||
public bool HasAdd;
|
||||
|
||||
public static SwfColorTransformRGBA Read(SwfStreamReader reader) {
|
||||
var transform = SwfColorTransformRGBA.Identity;
|
||||
var has_add = reader.ReadBit();
|
||||
var has_mul = reader.ReadBit();
|
||||
var bits = reader.ReadUnsignedBits(4);
|
||||
if ( has_mul ) {
|
||||
transform.RMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.GMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.BMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.AMul = (short)reader.ReadSignedBits(bits);
|
||||
transform.HasMul = true;
|
||||
}
|
||||
if ( has_add ) {
|
||||
transform.RAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.GAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.BAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.AAdd = (short)reader.ReadSignedBits(bits);
|
||||
transform.HasAdd = true;
|
||||
}
|
||||
reader.AlignToByte();
|
||||
return transform;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SwfColorTransformRGBA. " +
|
||||
"RMul: {0}, GMul: {1}, BMul: {2}, AMul: {3}, HasMul: {4}, " +
|
||||
"RAdd: {5}, GAdd: {6}, BAdd: {7}, AAdd: {8}, HasAdd: {9}",
|
||||
RMul, GMul, GMul, AMul, HasMul,
|
||||
RAdd, GAdd, BAdd, AAdd, HasAdd);
|
||||
}
|
||||
|
||||
public static SwfColorTransformRGBA Identity {
|
||||
get {
|
||||
return new SwfColorTransformRGBA {
|
||||
RMul = 1,
|
||||
GMul = 1,
|
||||
BMul = 1,
|
||||
AMul = 1,
|
||||
HasMul = false,
|
||||
RAdd = 0,
|
||||
GAdd = 0,
|
||||
BAdd = 0,
|
||||
AAdd = 0,
|
||||
HasAdd = false};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using FlashTools.Internal.SwfTools.SwfTags;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfControlTags {
|
||||
public struct SwfControlTags {
|
||||
public List<SwfTagBase> Tags;
|
||||
|
||||
public static SwfControlTags Read(SwfStreamReader reader) {
|
||||
@@ -10,10 +10,10 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
control_tags.Tags = new List<SwfTagBase>();
|
||||
while ( true ) {
|
||||
var tag = SwfTagBase.Read(reader);
|
||||
control_tags.Tags.Add(tag);
|
||||
if ( tag.TagType == SwfTagType.End ) {
|
||||
break;
|
||||
}
|
||||
control_tags.Tags.Add(tag);
|
||||
}
|
||||
return control_tags;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfFillStyleType {
|
||||
public struct SwfFillStyleType {
|
||||
public enum Type {
|
||||
SolidColor,
|
||||
LinearGradient,
|
||||
@@ -26,6 +26,27 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
Value);
|
||||
}
|
||||
|
||||
public bool IsSolidType {
|
||||
get { return Value == Type.SolidColor; }
|
||||
}
|
||||
|
||||
public bool IsBitmapType {
|
||||
get { return
|
||||
Value == Type.RepeatingBitmap ||
|
||||
Value == Type.ClippedBitmap ||
|
||||
Value == Type.NonSmoothedRepeatingBitmap ||
|
||||
Value == Type.NonSmoothedClippedBitmap;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsGradientType {
|
||||
get { return
|
||||
Value == Type.LinearGradient ||
|
||||
Value == Type.RadialGradient ||
|
||||
Value == Type.FocalGradient;
|
||||
}
|
||||
}
|
||||
|
||||
static Type TypeFromByte(byte type_id) {
|
||||
switch ( type_id ) {
|
||||
case 0x00: return Type.SolidColor;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfLongHeader {
|
||||
public struct SwfLongHeader {
|
||||
public SwfShortHeader ShortHeader;
|
||||
public SwfRect FrameSize;
|
||||
public float FrameRate;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfMatrix {
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
public struct SwfMatrix {
|
||||
public float ScaleX;
|
||||
public float ScaleY;
|
||||
public float RotateSkew0;
|
||||
@@ -14,12 +16,18 @@
|
||||
var bits = (byte)reader.ReadUnsignedBits(5);
|
||||
matrix.ScaleX = reader.ReadFixedPoint16(bits) / 20.0f;
|
||||
matrix.ScaleY = reader.ReadFixedPoint16(bits) / 20.0f;
|
||||
} else {
|
||||
matrix.ScaleX =
|
||||
matrix.ScaleY = 1.0f;
|
||||
}
|
||||
var has_rotate = reader.ReadBit();
|
||||
if ( has_rotate ) {
|
||||
var bits = (byte)reader.ReadUnsignedBits(5);
|
||||
matrix.RotateSkew0 = reader.ReadFixedPoint16(bits) / 20.0f;
|
||||
matrix.RotateSkew1 = reader.ReadFixedPoint16(bits) / 20.0f;
|
||||
} else {
|
||||
matrix.RotateSkew0 =
|
||||
matrix.RotateSkew1 = 0.0f;
|
||||
}
|
||||
var translate_bits = (byte)reader.ReadUnsignedBits(5);
|
||||
matrix.TranslateX = reader.ReadSignedBits(translate_bits) / 20.0f;
|
||||
@@ -39,6 +47,17 @@
|
||||
TranslateX, TranslateY);
|
||||
}
|
||||
|
||||
public Matrix4x4 ToUnityMatrix() {
|
||||
var mat = Matrix4x4.identity;
|
||||
mat.m00 = ScaleX;
|
||||
mat.m10 = RotateSkew0;
|
||||
mat.m01 = RotateSkew1;
|
||||
mat.m11 = ScaleY;
|
||||
mat.m03 = TranslateX;
|
||||
mat.m13 = TranslateY;
|
||||
return mat;
|
||||
}
|
||||
|
||||
public static SwfMatrix Identity {
|
||||
get {
|
||||
return new SwfMatrix {
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfRGB {
|
||||
public byte R;
|
||||
public byte G;
|
||||
public byte B;
|
||||
|
||||
public static SwfRGB Read(SwfStreamReader reader) {
|
||||
var rgb = new SwfRGB();
|
||||
rgb.R = reader.ReadByte();
|
||||
rgb.G = reader.ReadByte();
|
||||
rgb.B = reader.ReadByte();
|
||||
return rgb;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SwfRGB. R: {0}, G: {1}, B: {2}",
|
||||
R, G, B);
|
||||
}
|
||||
|
||||
public SwfRGBA ToRGBA(byte alpha) {
|
||||
return new SwfRGBA{
|
||||
R = R,
|
||||
G = G,
|
||||
B = B,
|
||||
A = alpha};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfRGBA {
|
||||
public byte R;
|
||||
public byte G;
|
||||
public byte B;
|
||||
public byte A;
|
||||
|
||||
public static SwfRGBA Read(SwfStreamReader reader) {
|
||||
var rgba = new SwfRGBA();
|
||||
rgba.R = reader.ReadByte();
|
||||
rgba.G = reader.ReadByte();
|
||||
rgba.B = reader.ReadByte();
|
||||
rgba.A = reader.ReadByte();
|
||||
return rgba;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format(
|
||||
"SwfRGBA. R: {0}, G: {1}, B: {2}, A: {3}",
|
||||
R, G, B, A);
|
||||
}
|
||||
|
||||
public SwfRGB ToRGB() {
|
||||
return new SwfRGB{
|
||||
R = R,
|
||||
G = G,
|
||||
B = B};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfRect {
|
||||
public struct SwfRect {
|
||||
public float XMin;
|
||||
public float XMax;
|
||||
public float YMin;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfShapesWithStyle {
|
||||
public struct SwfShapesWithStyle {
|
||||
public enum ShapeStyleType {
|
||||
Shape,
|
||||
Shape2,
|
||||
@@ -87,45 +87,25 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
static FillStyle ReadFillStyle(SwfStreamReader reader, bool with_alpha) {
|
||||
var fill_style = new FillStyle();
|
||||
fill_style.Type = SwfFillStyleType.Read(reader);
|
||||
switch ( fill_style.Type.Value ) {
|
||||
case SwfFillStyleType.Type.SolidColor:
|
||||
if ( with_alpha ) {
|
||||
SwfRGBA.Read(reader);
|
||||
} else {
|
||||
SwfRGB.Read(reader);
|
||||
} // Color
|
||||
break;
|
||||
if ( fill_style.Type.IsSolidType ) {
|
||||
SwfColor.Read(reader, with_alpha);
|
||||
}
|
||||
switch ( fill_style.Type.Value ) {
|
||||
case SwfFillStyleType.Type.LinearGradient:
|
||||
case SwfFillStyleType.Type.RadialGradient:
|
||||
case SwfFillStyleType.Type.FocalGradient:
|
||||
if ( fill_style.Type.IsGradientType ) {
|
||||
SwfMatrix.Read(reader); // GradientMatrix
|
||||
break;
|
||||
switch ( fill_style.Type.Value ) {
|
||||
case SwfFillStyleType.Type.LinearGradient:
|
||||
case SwfFillStyleType.Type.RadialGradient:
|
||||
SkipGradient(reader, with_alpha); // Gradient
|
||||
break;
|
||||
case SwfFillStyleType.Type.FocalGradient:
|
||||
SkipFocalGradient(reader, with_alpha); // FocalGradient
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch ( fill_style.Type.Value ) {
|
||||
case SwfFillStyleType.Type.LinearGradient:
|
||||
case SwfFillStyleType.Type.RadialGradient:
|
||||
SkipGradient(reader, with_alpha); // Gradient
|
||||
break;
|
||||
case SwfFillStyleType.Type.FocalGradient:
|
||||
SkipFocalGradient(reader, with_alpha); // FocalGradient
|
||||
break;
|
||||
}
|
||||
switch ( fill_style.Type.Value ) {
|
||||
case SwfFillStyleType.Type.RepeatingBitmap:
|
||||
case SwfFillStyleType.Type.ClippedBitmap:
|
||||
case SwfFillStyleType.Type.NonSmoothedRepeatingBitmap:
|
||||
case SwfFillStyleType.Type.NonSmoothedClippedBitmap:
|
||||
if ( fill_style.Type.IsBitmapType ) {
|
||||
fill_style.BitmapId = reader.ReadUInt16();
|
||||
fill_style.BitmapMatrix = SwfMatrix.Read(reader);
|
||||
break;
|
||||
default:
|
||||
fill_style.BitmapId = 0;
|
||||
fill_style.BitmapMatrix = SwfMatrix.Identity;
|
||||
break;
|
||||
}
|
||||
Debug.LogErrorFormat("ReadFillStyle: {0}", fill_style);
|
||||
return fill_style;
|
||||
}
|
||||
|
||||
@@ -139,11 +119,7 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
var count = reader.ReadUnsignedBits(4);
|
||||
for ( var i = 0; i < count; ++i ) {
|
||||
reader.ReadByte(); // Ratio
|
||||
if ( with_alpha ) {
|
||||
SwfRGBA.Read(reader);
|
||||
} else {
|
||||
SwfRGB.Read(reader);
|
||||
} // Color
|
||||
SwfColor.Read(reader, with_alpha);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,11 +133,7 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
var count = reader.ReadUnsignedBits(4);
|
||||
for ( var i = 0; i < count; ++i ) {
|
||||
reader.ReadByte(); // Ratio
|
||||
if ( with_alpha ) {
|
||||
SwfRGBA.Read(reader);
|
||||
} else {
|
||||
SwfRGB.Read(reader);
|
||||
} // Color
|
||||
SwfColor.Read(reader, with_alpha);
|
||||
}
|
||||
reader.ReadFixedPoint8(); // FocalPoint
|
||||
}
|
||||
@@ -194,11 +166,7 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
|
||||
static void SkipLineStyle(SwfStreamReader reader, bool with_alpha) {
|
||||
reader.ReadUInt16(); // Width
|
||||
if ( with_alpha ) {
|
||||
SwfRGBA.Read(reader);
|
||||
} else {
|
||||
SwfRGB.Read(reader);
|
||||
} // Color
|
||||
SwfColor.Read(reader, with_alpha);
|
||||
}
|
||||
|
||||
static void SkipLine2Style(SwfStreamReader reader) {
|
||||
@@ -218,7 +186,7 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
if ( has_fill_flag ) {
|
||||
ReadFillStyle(reader, true); // FillStyle
|
||||
} else {
|
||||
SwfRGBA.Read(reader); // Color
|
||||
SwfColor.Read(reader, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,13 +196,6 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
public enum ShapeRecordType {
|
||||
EndRecord,
|
||||
StyleChangeRecord,
|
||||
StraightEdge,
|
||||
CurvedEdgeRecord
|
||||
}
|
||||
|
||||
static void SkipShapeRecords(
|
||||
SwfStreamReader reader,
|
||||
bool allow_big_array, bool with_alpha, bool line2_type)
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
using FlashTools.Internal.SwfTools.SwfTypes;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfShortHeader {
|
||||
public struct SwfShortHeader {
|
||||
public string Format;
|
||||
public byte Version;
|
||||
public uint FileLength;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
struct SwfSurfaceFilters {
|
||||
public struct SwfSurfaceFilters {
|
||||
public static SwfSurfaceFilters Read(SwfStreamReader reader) {
|
||||
//TODO: IMPLME
|
||||
return new SwfSurfaceFilters();
|
||||
|
||||
26
Assets/FlashTools/Scripts/SwfAnimation.cs
Normal file
26
Assets/FlashTools/Scripts/SwfAnimation.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlashTools {
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
|
||||
public class SwfAnimation : MonoBehaviour {
|
||||
public SwfAnimationAsset Asset = null;
|
||||
|
||||
int _current_frame = 0;
|
||||
|
||||
public int frameCount {
|
||||
get { return Asset ? Asset.Data.Frames.Count : 0; }
|
||||
}
|
||||
|
||||
public int currentFrame {
|
||||
get { return _current_frame; }
|
||||
set { _current_frame = Mathf.Clamp(value, 0, frameCount - 1); }
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
// Messages
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
12
Assets/FlashTools/Scripts/SwfAnimation.cs.meta
Normal file
12
Assets/FlashTools/Scripts/SwfAnimation.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2baa05cb4bda40e5ac10a5f833e104e
|
||||
timeCreated: 1458054531
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
74
Assets/FlashTools/Scripts/SwfAnimationAsset.cs
Normal file
74
Assets/FlashTools/Scripts/SwfAnimationAsset.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FlashTools {
|
||||
[System.Serializable]
|
||||
public struct SwfAnimationColorTransform {
|
||||
public Vector4 Mul;
|
||||
public Vector4 Add;
|
||||
|
||||
public SwfAnimationColorTransform(Vector4 Mul, Vector4 Add) {
|
||||
this.Mul = Mul;
|
||||
this.Add = Add;
|
||||
}
|
||||
|
||||
public static SwfAnimationColorTransform identity {
|
||||
get {
|
||||
return new SwfAnimationColorTransform(
|
||||
new Vector4(1,1,1,1),
|
||||
new Vector4(0,0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
public static SwfAnimationColorTransform operator*(
|
||||
SwfAnimationColorTransform a, SwfAnimationColorTransform b)
|
||||
{
|
||||
var res = new SwfAnimationColorTransform();
|
||||
res.Mul.x = b.Mul.x * a.Mul.x;
|
||||
res.Mul.y = b.Mul.y * a.Mul.y;
|
||||
res.Mul.z = b.Mul.z * a.Mul.z;
|
||||
res.Mul.w = b.Mul.w * a.Mul.w;
|
||||
res.Add.x = b.Add.x * a.Mul.x + a.Add.x;
|
||||
res.Add.y = b.Add.y * a.Mul.y + a.Add.y;
|
||||
res.Add.z = b.Add.z * a.Mul.z + a.Add.z;
|
||||
res.Add.w = b.Add.w * a.Mul.w + a.Add.w;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfAnimationInstData {
|
||||
public ushort Bitmap = 0;
|
||||
public Matrix4x4 Matrix = Matrix4x4.identity;
|
||||
public SwfAnimationColorTransform ColorTransform = SwfAnimationColorTransform.identity;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfAnimationFrameData {
|
||||
public string Name = string.Empty;
|
||||
public List<SwfAnimationInstData> Insts = new List<SwfAnimationInstData>();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfAnimationBitmapData {
|
||||
public int Id = 0;
|
||||
public Vector2 RealSize = Vector2.zero;
|
||||
public Rect SourceRect = new Rect();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfAnimationData {
|
||||
public float FrameRate = 0.0f;
|
||||
public List<SwfAnimationFrameData> Frames = new List<SwfAnimationFrameData>();
|
||||
public List<SwfAnimationBitmapData> Bitmaps = new List<SwfAnimationBitmapData>();
|
||||
}
|
||||
|
||||
public class SwfAnimationAsset : ScriptableObject {
|
||||
//[HideInInspector]
|
||||
public SwfAnimationData Data = new SwfAnimationData();
|
||||
public Texture2D Atlas = null;
|
||||
public int MaxAtlasSize = 1024;
|
||||
public int AtlasPadding = 1;
|
||||
public int PixelsPerUnit = 100;
|
||||
}
|
||||
}
|
||||
12
Assets/FlashTools/Scripts/SwfAnimationAsset.cs.meta
Normal file
12
Assets/FlashTools/Scripts/SwfAnimationAsset.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f76a446beb44b46088888ed3f078b2a0
|
||||
timeCreated: 1458054544
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user