mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2026-03-22 04:44:08 +07:00
refactor public symbols from dll
This commit is contained in:
@@ -6,11 +6,10 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using FTRuntime;
|
||||
using FTRuntime.Internal;
|
||||
|
||||
namespace FTEditor.Editors {
|
||||
[CustomEditor(typeof(SwfAsset)), CanEditMultipleObjects]
|
||||
public class SwfAssetEditor : Editor {
|
||||
class SwfAssetEditor : Editor {
|
||||
List<SwfAsset> _assets = new List<SwfAsset>();
|
||||
|
||||
//
|
||||
|
||||
@@ -9,7 +9,7 @@ using FTRuntime;
|
||||
|
||||
namespace FTEditor.Editors {
|
||||
[CustomEditor(typeof(SwfClipAsset)), CanEditMultipleObjects]
|
||||
public class SwfClipAssetEditor : Editor {
|
||||
class SwfClipAssetEditor : Editor {
|
||||
List<SwfClipAsset> _clips = new List<SwfClipAsset>();
|
||||
|
||||
static string GetClipPath(SwfClipAsset clip) {
|
||||
|
||||
@@ -7,7 +7,7 @@ using FTRuntime;
|
||||
|
||||
namespace FTEditor.Editors {
|
||||
[CustomPreview(typeof(SwfClipAsset))]
|
||||
public class SwfClipAssetPreview : ObjectPreview {
|
||||
class SwfClipAssetPreview : ObjectPreview {
|
||||
int _sequence = 0;
|
||||
static MaterialPropertyBlock _matPropBlock = null;
|
||||
static PreviewRenderUtility _previewUtils = null;
|
||||
|
||||
@@ -8,7 +8,7 @@ using FTRuntime;
|
||||
|
||||
namespace FTEditor.Editors {
|
||||
[CustomEditor(typeof(SwfClipController)), CanEditMultipleObjects]
|
||||
public class SwfClipControllerEditor : Editor {
|
||||
class SwfClipControllerEditor : Editor {
|
||||
List<SwfClipController> _controllers = new List<SwfClipController>();
|
||||
|
||||
void AllControllersForeach(System.Action<SwfClipController> act) {
|
||||
|
||||
@@ -8,7 +8,7 @@ using FTRuntime;
|
||||
|
||||
namespace FTEditor.Editors {
|
||||
[CustomEditor(typeof(SwfClip)), CanEditMultipleObjects]
|
||||
public class SwfClipEditor : Editor {
|
||||
class SwfClipEditor : Editor {
|
||||
List<SwfClip> _clips = new List<SwfClip>();
|
||||
Dictionary<SwfClip, SwfClipAssetPreview> _previews = new Dictionary<SwfClip, SwfClipAssetPreview>();
|
||||
|
||||
|
||||
@@ -4,14 +4,13 @@ using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using FTRuntime;
|
||||
using FTRuntime.Internal;
|
||||
|
||||
namespace FTEditor.Editors {
|
||||
[CustomEditor(typeof(SwfManager))]
|
||||
public class SwfManagerEditor : Editor {
|
||||
SwfManager _manager = null;
|
||||
SwfList<SwfClipController> _controllers = new SwfList<SwfClipController>();
|
||||
bool _groupsFoldout = true;
|
||||
class SwfManagerEditor : Editor {
|
||||
SwfManager _manager = null;
|
||||
List<SwfClipController> _controllers = new List<SwfClipController>();
|
||||
bool _groupsFoldout = true;
|
||||
|
||||
void DrawCounts() {
|
||||
SwfEditorUtils.DoWithEnabledGUI(false, () => {
|
||||
|
||||
@@ -7,10 +7,9 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using FTRuntime;
|
||||
using FTRuntime.Internal;
|
||||
|
||||
namespace FTEditor.Postprocessors {
|
||||
public class SwfAssetPostprocessor : AssetPostprocessor {
|
||||
class SwfAssetPostprocessor : AssetPostprocessor {
|
||||
static void OnPostprocessAllAssets(
|
||||
string[] imported_assets,
|
||||
string[] deleted_assets,
|
||||
@@ -359,18 +358,18 @@ namespace FTEditor.Postprocessors {
|
||||
baked_vertices.Add(matrix.MultiplyPoint3x4(v3));
|
||||
|
||||
var source_rect = bitmap.SourceRect;
|
||||
baked_uvs.Add(SwfUtils.PackUV(source_rect.xMin, source_rect.yMin));
|
||||
baked_uvs.Add(SwfUtils.PackUV(source_rect.xMax, source_rect.yMax));
|
||||
baked_uvs.Add(SwfEditorUtils.PackUV(source_rect.xMin, source_rect.yMin));
|
||||
baked_uvs.Add(SwfEditorUtils.PackUV(source_rect.xMax, source_rect.yMax));
|
||||
|
||||
uint mul_pack0, mul_pack1;
|
||||
SwfUtils.PackFColorToUInts(
|
||||
SwfEditorUtils.PackFColorToUInts(
|
||||
inst.ColorTrans.mulColor.ToUVector4(),
|
||||
out mul_pack0, out mul_pack1);
|
||||
baked_mulcolors.Add(mul_pack0);
|
||||
baked_mulcolors.Add(mul_pack1);
|
||||
|
||||
uint add_pack0, add_pack1;
|
||||
SwfUtils.PackFColorToUInts(
|
||||
SwfEditorUtils.PackFColorToUInts(
|
||||
inst.ColorTrans.addColor.ToUVector4(),
|
||||
out add_pack0, out add_pack1);
|
||||
baked_addcolors.Add(add_pack0);
|
||||
|
||||
@@ -6,15 +6,14 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using FTRuntime;
|
||||
|
||||
using FTSwfTools;
|
||||
using FTSwfTools.SwfTags;
|
||||
using FTSwfTools.SwfTypes;
|
||||
|
||||
using FTRuntime;
|
||||
using FTRuntime.Internal;
|
||||
|
||||
namespace FTEditor.Postprocessors {
|
||||
public class SwfPostprocessor : AssetPostprocessor {
|
||||
class SwfPostprocessor : AssetPostprocessor {
|
||||
static void OnPostprocessAllAssets(
|
||||
string[] imported_assets,
|
||||
string[] deleted_assets,
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace FTEditor {
|
||||
[System.Serializable]
|
||||
public struct SwfVec2Data {
|
||||
struct SwfVec2Data {
|
||||
public float x;
|
||||
public float y;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace FTEditor {
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct SwfVec4Data {
|
||||
struct SwfVec4Data {
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
@@ -54,7 +54,7 @@ namespace FTEditor {
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct SwfRectData {
|
||||
struct SwfRectData {
|
||||
public float xMin;
|
||||
public float xMax;
|
||||
public float yMin;
|
||||
@@ -80,7 +80,7 @@ namespace FTEditor {
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct SwfMatrixData {
|
||||
struct SwfMatrixData {
|
||||
public SwfVec2Data sc;
|
||||
public SwfVec2Data sk;
|
||||
public SwfVec2Data tr;
|
||||
@@ -114,7 +114,7 @@ namespace FTEditor {
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct SwfBlendModeData {
|
||||
struct SwfBlendModeData {
|
||||
public enum Types : byte {
|
||||
Normal,
|
||||
Layer,
|
||||
@@ -150,7 +150,7 @@ namespace FTEditor {
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct SwfColorTransData {
|
||||
struct SwfColorTransData {
|
||||
public SwfVec4Data mulColor;
|
||||
public SwfVec4Data addColor;
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace FTEditor {
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfInstanceData {
|
||||
class SwfInstanceData {
|
||||
public enum Types {
|
||||
Mask,
|
||||
Group,
|
||||
@@ -204,19 +204,19 @@ namespace FTEditor {
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfFrameData {
|
||||
class SwfFrameData {
|
||||
public string Name = string.Empty;
|
||||
public List<SwfInstanceData> Instances = new List<SwfInstanceData>();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfSymbolData {
|
||||
class SwfSymbolData {
|
||||
public string Name = string.Empty;
|
||||
public List<SwfFrameData> Frames = new List<SwfFrameData>();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfBitmapData {
|
||||
class SwfBitmapData {
|
||||
public ushort Id = 0;
|
||||
public byte[] ARGB32 = new byte[0];
|
||||
public ushort Redirect = 0;
|
||||
@@ -226,7 +226,7 @@ namespace FTEditor {
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SwfAssetData {
|
||||
class SwfAssetData {
|
||||
public float FrameRate = 0.0f;
|
||||
public List<SwfSymbolData> Symbols = new List<SwfSymbolData>();
|
||||
public List<SwfBitmapData> Bitmaps = new List<SwfBitmapData>();
|
||||
|
||||
@@ -9,10 +9,63 @@ using System.Runtime.Serialization.Formatters.Binary;
|
||||
using Ionic.Zlib;
|
||||
|
||||
using FTRuntime;
|
||||
using FTRuntime.Internal;
|
||||
|
||||
namespace FTEditor {
|
||||
public static class SwfEditorUtils {
|
||||
static class SwfEditorUtils {
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// Packing
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const ushort UShortMax = ushort.MaxValue;
|
||||
const float FColorPrecision = 1.0f / 512.0f;
|
||||
|
||||
public static uint PackUV(float u, float v) {
|
||||
var uu = (uint)(Mathf.Clamp01(u) * UShortMax);
|
||||
var vv = (uint)(Mathf.Clamp01(v) * UShortMax);
|
||||
return (uu << 16) + vv;
|
||||
}
|
||||
|
||||
public static ushort PackFloatColorToUShort(float v) {
|
||||
return (ushort)Mathf.Clamp(
|
||||
v * (1.0f / FColorPrecision),
|
||||
short.MinValue,
|
||||
short.MaxValue);
|
||||
}
|
||||
|
||||
public static uint PackUShortsToUInt(ushort x, ushort y) {
|
||||
var xx = (uint)x;
|
||||
var yy = (uint)y;
|
||||
return (xx << 16) + yy;
|
||||
}
|
||||
|
||||
public static void PackFColorToUInts(
|
||||
Color v,
|
||||
out uint pack0, out uint pack1)
|
||||
{
|
||||
PackFColorToUInts(v.r, v.g, v.b, v.a, out pack0, out pack1);
|
||||
}
|
||||
|
||||
public static void PackFColorToUInts(
|
||||
Vector4 v,
|
||||
out uint pack0, out uint pack1)
|
||||
{
|
||||
PackFColorToUInts(v.x, v.y, v.z, v.w, out pack0, out pack1);
|
||||
}
|
||||
|
||||
public static void PackFColorToUInts(
|
||||
float v0, float v1, float v2, float v3,
|
||||
out uint pack0, out uint pack1)
|
||||
{
|
||||
pack0 = PackUShortsToUInt(
|
||||
PackFloatColorToUShort(v0),
|
||||
PackFloatColorToUShort(v1));
|
||||
pack1 = PackUShortsToUInt(
|
||||
PackFloatColorToUShort(v2),
|
||||
PackFloatColorToUShort(v3));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Collections.Generic;
|
||||
using FTRuntime;
|
||||
|
||||
namespace FTEditor {
|
||||
public class SwfMaterialCache {
|
||||
class SwfMaterialCache {
|
||||
|
||||
const string SwfSimpleShaderName = "SwfSimpleShader";
|
||||
const string SwfMaskedShaderName = "SwfMaskedShader";
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace FTEditor {
|
||||
//
|
||||
|
||||
[CustomPropertyDrawer(typeof(SwfIntRangeAttribute))]
|
||||
public class SwfIntRangeDrawer : PropertyDrawer {
|
||||
class SwfIntRangeDrawer : PropertyDrawer {
|
||||
static void ValidateProperty(SerializedProperty property, int min, int max) {
|
||||
if ( !property.hasMultipleDifferentValues ) {
|
||||
if ( property.propertyType == SerializedPropertyType.Integer ) {
|
||||
@@ -39,7 +39,7 @@ namespace FTEditor {
|
||||
//
|
||||
|
||||
[CustomPropertyDrawer(typeof(SwfFloatRangeAttribute))]
|
||||
public class SwfFloatRangeDrawer : PropertyDrawer {
|
||||
class SwfFloatRangeDrawer : PropertyDrawer {
|
||||
static void ValidateProperty(SerializedProperty property, float min, float max) {
|
||||
if ( !property.hasMultipleDifferentValues ) {
|
||||
if ( property.propertyType == SerializedPropertyType.Float ) {
|
||||
@@ -65,7 +65,7 @@ namespace FTEditor {
|
||||
//
|
||||
|
||||
[CustomPropertyDrawer(typeof(SwfSortingLayerAttribute))]
|
||||
public class SwfSortingLayerDrawer : PropertyDrawer {
|
||||
class SwfSortingLayerDrawer : PropertyDrawer {
|
||||
|
||||
const string DefaultLayerName = "Default";
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace FTEditor {
|
||||
//
|
||||
|
||||
[CustomPropertyDrawer(typeof(SwfPowerOfTwoIfAttribute))]
|
||||
public class SwfPowerOfTwoIfDrawer : PropertyDrawer {
|
||||
class SwfPowerOfTwoIfDrawer : PropertyDrawer {
|
||||
|
||||
static SerializedProperty FindNextBoolProperty(SerializedProperty property, string next_prop) {
|
||||
var prop = property.Copy();
|
||||
@@ -227,7 +227,7 @@ namespace FTEditor {
|
||||
//
|
||||
|
||||
[CustomPropertyDrawer(typeof(SwfReadOnlyAttribute))]
|
||||
public class SwfReadOnlyDrawer : PropertyDrawer {
|
||||
class SwfReadOnlyDrawer : PropertyDrawer {
|
||||
public override void OnGUI(
|
||||
Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
@@ -242,7 +242,7 @@ namespace FTEditor {
|
||||
//
|
||||
|
||||
[CustomPropertyDrawer(typeof(SwfDisplayNameAttribute))]
|
||||
public class SwfDisplayNameDrawer : PropertyDrawer {
|
||||
class SwfDisplayNameDrawer : PropertyDrawer {
|
||||
public override void OnGUI(
|
||||
Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FTRuntime.Internal {
|
||||
public class SwfAssocList<T> {
|
||||
class SwfAssocList<T> {
|
||||
SwfList<T> _list;
|
||||
Dictionary<T, int> _dict;
|
||||
IEqualityComparer<T> _comp;
|
||||
@@ -63,6 +63,10 @@ namespace FTRuntime.Internal {
|
||||
_dict.Clear();
|
||||
}
|
||||
|
||||
public void AssignTo(List<T> list) {
|
||||
_list.AssignTo(list);
|
||||
}
|
||||
|
||||
public void AssignTo(SwfList<T> list) {
|
||||
_list.AssignTo(list);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FTRuntime.Internal {
|
||||
public class SwfList<T> {
|
||||
class SwfList<T> {
|
||||
T[] _data;
|
||||
int _size;
|
||||
|
||||
@@ -107,6 +108,16 @@ namespace FTRuntime.Internal {
|
||||
}
|
||||
}
|
||||
|
||||
public void AssignTo(List<T> list) {
|
||||
list.Clear();
|
||||
if ( list.Capacity < Count ) {
|
||||
list.Capacity = Count * 2;
|
||||
}
|
||||
for ( int i = 0, e = Count; i < e; ++i ) {
|
||||
list.Add(this[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void AssignTo(SwfList<T> list) {
|
||||
if ( list._data.Length < _size ) {
|
||||
var new_data = new T[_size * 2];
|
||||
|
||||
@@ -2,92 +2,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FTRuntime.Internal {
|
||||
public static class SwfUtils {
|
||||
static class SwfUtils {
|
||||
|
||||
public const float UVPrecision = 1.0f / 16384.0f;
|
||||
public const float FColorPrecision = 1.0f / 512.0f;
|
||||
|
||||
const ushort UShortMax = ushort.MaxValue;
|
||||
const float InvFColorPrecision = 1.0f / FColorPrecision;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
public static uint PackUShortsToUInt(ushort x, ushort y) {
|
||||
var xx = (uint)x;
|
||||
var yy = (uint)y;
|
||||
return (xx << 16) + yy;
|
||||
}
|
||||
|
||||
public static void UnpackUShortsFromUInt(
|
||||
uint pack,
|
||||
out ushort x, out ushort y)
|
||||
{
|
||||
x = (ushort)((pack >> 16) & 0xFFFF);
|
||||
y = (ushort)((pack ) & 0xFFFF);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
public static uint PackUV(float u, float v) {
|
||||
var uu = (uint)(Mathf.Clamp01(u) * UShortMax);
|
||||
var vv = (uint)(Mathf.Clamp01(v) * UShortMax);
|
||||
return (uu << 16) + vv;
|
||||
}
|
||||
const ushort UShortMax = ushort.MaxValue;
|
||||
const float FColorPrecision = 1.0f / 512.0f;
|
||||
const float InvFColorPrecision = 1.0f / FColorPrecision;
|
||||
|
||||
public static void UnpackUV(uint pack, out float u, out float v) {
|
||||
u = (float)((pack >> 16) & 0xFFFF) / UShortMax;
|
||||
v = (float)((pack ) & 0xFFFF) / UShortMax;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
public static ushort PackFloatColorToUShort(float v) {
|
||||
return (ushort)Mathf.Clamp(
|
||||
v * (1.0f / FColorPrecision),
|
||||
short.MinValue,
|
||||
short.MaxValue);
|
||||
}
|
||||
|
||||
public static float UnpackFloatColorFromUShort(ushort pack) {
|
||||
return (short)pack / InvFColorPrecision;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
public static void PackFColorToUInts(
|
||||
Color v,
|
||||
out uint pack0, out uint pack1)
|
||||
{
|
||||
PackFColorToUInts(v.r, v.g, v.b, v.a, out pack0, out pack1);
|
||||
}
|
||||
|
||||
public static void PackFColorToUInts(
|
||||
Vector4 v,
|
||||
out uint pack0, out uint pack1)
|
||||
{
|
||||
PackFColorToUInts(v.x, v.y, v.z, v.w, out pack0, out pack1);
|
||||
}
|
||||
|
||||
public static void PackFColorToUInts(
|
||||
float v0, float v1, float v2, float v3,
|
||||
out uint pack0, out uint pack1)
|
||||
{
|
||||
pack0 = PackUShortsToUInt(
|
||||
PackFloatColorToUShort(v0),
|
||||
PackFloatColorToUShort(v1));
|
||||
pack1 = PackUShortsToUInt(
|
||||
PackFloatColorToUShort(v2),
|
||||
PackFloatColorToUShort(v3));
|
||||
}
|
||||
|
||||
public static void UnpackFColorFromUInts(
|
||||
uint pack0, uint pack1,
|
||||
out float c0, out float c1, out float c2, out float c3)
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace FTRuntime {
|
||||
_clips.Remove(clip);
|
||||
}
|
||||
|
||||
public void GetAllClips(SwfList<SwfClip> clips) {
|
||||
public void GetAllClips(List<SwfClip> clips) {
|
||||
_clips.AssignTo(clips);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace FTRuntime {
|
||||
_controllers.Remove(controller);
|
||||
}
|
||||
|
||||
public void GetAllControllers(SwfList<SwfClipController> controllers) {
|
||||
public void GetAllControllers(List<SwfClipController> controllers) {
|
||||
_controllers.AssignTo(controllers);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<Properties StartupItem="FTEditor/FTEditor.csproj">
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="FTRuntime/Sources/SwfAsset.cs">
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="FTSwfTools/Sources/SwfTags/SwfTagBase.cs">
|
||||
<Files>
|
||||
<File FileName="FTRuntime/Sources/SwfAsset.cs" Line="22" Column="4" />
|
||||
<File FileName="FTEditor/Sources/Postprocessors/SwfPostprocessor.cs" Line="87" Column="54" />
|
||||
<File FileName="FTSwfTools/Sources/SwfContextExecuter.cs" Line="18" Column="3" />
|
||||
<File FileName="FTSwfTools/Sources/SwfTags/SwfTagBase.cs" Line="215" Column="2" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release|x86" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
|
||||
|
||||
Reference in New Issue
Block a user