mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 14:11:19 +07:00
little refactor
This commit is contained in:
@@ -31,16 +31,14 @@ namespace FlashTools.Internal.SwfTools.SwfTags {
|
||||
}
|
||||
|
||||
public static DefineSceneAndFrameLabelDataTag Create(SwfStreamReader reader) {
|
||||
var scene_count = (int)reader.ReadEncodedU32();
|
||||
var scenes = new List<SceneOffsetData>(scene_count);
|
||||
var scenes = new List<SceneOffsetData>((int)reader.ReadEncodedU32());
|
||||
for ( var i = 0; i < scenes.Capacity; ++i ) {
|
||||
scenes.Add(new SceneOffsetData{
|
||||
Offset = reader.ReadEncodedU32(),
|
||||
Name = reader.ReadString()
|
||||
});
|
||||
}
|
||||
var frame_count = (int)reader.ReadEncodedU32();
|
||||
var frames = new List<FrameLabelData>(frame_count);
|
||||
var frames = new List<FrameLabelData>((int)reader.ReadEncodedU32());
|
||||
for ( var i = 0; i < frames.Capacity; ++i ) {
|
||||
frames.Add(new FrameLabelData{
|
||||
Number = reader.ReadEncodedU32(),
|
||||
|
||||
@@ -22,16 +22,15 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
|
||||
public static SwfBlendMode identity {
|
||||
get {
|
||||
return new SwfBlendMode {
|
||||
Value = Mode.Normal
|
||||
};
|
||||
return new SwfBlendMode{
|
||||
Value = Mode.Normal};
|
||||
}
|
||||
}
|
||||
|
||||
public static SwfBlendMode Read(SwfStreamReader reader) {
|
||||
var mode_id = reader.ReadByte();
|
||||
var mode = ModeFromByte(mode_id);
|
||||
return new SwfBlendMode{Value = mode};
|
||||
return new SwfBlendMode{
|
||||
Value = ModeFromByte(mode_id)};
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
|
||||
@@ -10,20 +10,23 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
public static SwfColor identity {
|
||||
get {
|
||||
return new SwfColor {
|
||||
R = 1,
|
||||
G = 1,
|
||||
B = 1,
|
||||
A = 1};
|
||||
R = byte.MaxValue,
|
||||
G = byte.MaxValue,
|
||||
B = byte.MaxValue,
|
||||
A = byte.MaxValue};
|
||||
}
|
||||
}
|
||||
|
||||
public static SwfColor Read(SwfStreamReader reader, bool with_alpha) {
|
||||
var color = SwfColor.identity;
|
||||
color.R = reader.ReadByte();
|
||||
color.G = reader.ReadByte();
|
||||
color.B = reader.ReadByte();
|
||||
color.A = with_alpha ? reader.ReadByte() : byte.MaxValue;
|
||||
return color;
|
||||
var r = reader.ReadByte();
|
||||
var g = reader.ReadByte();
|
||||
var b = reader.ReadByte();
|
||||
var a = with_alpha ? reader.ReadByte() : byte.MaxValue;
|
||||
return new SwfColor{
|
||||
R = r,
|
||||
G = g,
|
||||
B = b,
|
||||
A = a};
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
|
||||
@@ -8,8 +8,7 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
public static SwfControlTags identity {
|
||||
get {
|
||||
return new SwfControlTags {
|
||||
Tags = new List<SwfTagBase>()
|
||||
};
|
||||
Tags = new List<SwfTagBase>()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,16 +16,15 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
|
||||
public static SwfFillStyleType identity {
|
||||
get {
|
||||
return new SwfFillStyleType {
|
||||
Value = Type.SolidColor
|
||||
};
|
||||
return new SwfFillStyleType{
|
||||
Value = Type.SolidColor};
|
||||
}
|
||||
}
|
||||
|
||||
public static SwfFillStyleType Read(SwfStreamReader reader) {
|
||||
var type_id = reader.ReadByte();
|
||||
var type = TypeFromByte(type_id);
|
||||
return new SwfFillStyleType{Value = type};
|
||||
return new SwfFillStyleType{
|
||||
Value = TypeFromByte(type_id)};
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
|
||||
@@ -7,15 +7,28 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
public float YMin;
|
||||
public float YMax;
|
||||
|
||||
public static SwfRect identity {
|
||||
get {
|
||||
return new SwfRect{
|
||||
XMin = 0,
|
||||
XMax = 0,
|
||||
YMin = 0,
|
||||
YMax = 0};
|
||||
}
|
||||
}
|
||||
|
||||
public static SwfRect Read(SwfStreamReader reader) {
|
||||
var rect = new SwfRect();
|
||||
var bits = reader.ReadUnsignedBits(5);
|
||||
rect.XMin = reader.ReadSignedBits(bits) / 20.0f;
|
||||
rect.XMax = reader.ReadSignedBits(bits) / 20.0f;
|
||||
rect.YMin = reader.ReadSignedBits(bits) / 20.0f;
|
||||
rect.YMax = reader.ReadSignedBits(bits) / 20.0f;
|
||||
var bits = reader.ReadUnsignedBits(5);
|
||||
var xmin = reader.ReadSignedBits(bits) / 20.0f;
|
||||
var xmax = reader.ReadSignedBits(bits) / 20.0f;
|
||||
var ymin = reader.ReadSignedBits(bits) / 20.0f;
|
||||
var ymax = reader.ReadSignedBits(bits) / 20.0f;
|
||||
reader.AlignToByte();
|
||||
return rect;
|
||||
return new SwfRect{
|
||||
XMin = xmin,
|
||||
XMax = xmax,
|
||||
YMin = ymin,
|
||||
YMax = ymax};
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
|
||||
@@ -26,9 +26,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
|
||||
public static SwfShapesWithStyle identity {
|
||||
get {
|
||||
return new SwfShapesWithStyle {
|
||||
FillStyles = new List<FillStyle>()
|
||||
};
|
||||
return new SwfShapesWithStyle{
|
||||
FillStyles = new List<FillStyle>()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,24 +3,23 @@ using System.Collections.Generic;
|
||||
|
||||
namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
public struct SwfSurfaceFilters {
|
||||
public enum FilterType {
|
||||
DropShadow,
|
||||
Blur,
|
||||
Glow,
|
||||
Bevel,
|
||||
GradientGlow,
|
||||
Convolution,
|
||||
ColorMatrix,
|
||||
GradientBevel
|
||||
}
|
||||
|
||||
public abstract class Filter {
|
||||
public abstract FilterType Type { get; }
|
||||
public enum Types {
|
||||
DropShadow,
|
||||
Blur,
|
||||
Glow,
|
||||
Bevel,
|
||||
GradientGlow,
|
||||
Convolution,
|
||||
ColorMatrix,
|
||||
GradientBevel
|
||||
}
|
||||
public abstract Types Type { get; }
|
||||
}
|
||||
|
||||
public class DropShadowFilter : Filter {
|
||||
public override FilterType Type {
|
||||
get { return FilterType.DropShadow; }
|
||||
public override Types Type {
|
||||
get { return Types.DropShadow; }
|
||||
}
|
||||
public SwfColor DropShadowColor;
|
||||
public float BlurX;
|
||||
@@ -35,8 +34,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
}
|
||||
|
||||
public class BlurFilter : Filter {
|
||||
public override FilterType Type {
|
||||
get { return FilterType.Blur; }
|
||||
public override Types Type {
|
||||
get { return Types.Blur; }
|
||||
}
|
||||
public float BlurX;
|
||||
public float BlurY;
|
||||
@@ -44,8 +43,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
}
|
||||
|
||||
public class GlowFilter : Filter {
|
||||
public override FilterType Type {
|
||||
get { return FilterType.Glow; }
|
||||
public override Types Type {
|
||||
get { return Types.Glow; }
|
||||
}
|
||||
public SwfColor GlowColor;
|
||||
public float BlurX;
|
||||
@@ -58,8 +57,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
}
|
||||
|
||||
public class BevelFilter : Filter {
|
||||
public override FilterType Type {
|
||||
get { return FilterType.Bevel; }
|
||||
public override Types Type {
|
||||
get { return Types.Bevel; }
|
||||
}
|
||||
public SwfColor ShadowColor;
|
||||
public SwfColor HighlightColor;
|
||||
@@ -76,8 +75,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
}
|
||||
|
||||
public class GradientGlowFilter : Filter {
|
||||
public override FilterType Type {
|
||||
get { return FilterType.GradientGlow; }
|
||||
public override Types Type {
|
||||
get { return Types.GradientGlow; }
|
||||
}
|
||||
public SwfColor[] GradientColors;
|
||||
public byte[] GradientRatio;
|
||||
@@ -94,8 +93,8 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
}
|
||||
|
||||
public class ConvolutionFilter : Filter {
|
||||
public override FilterType Type {
|
||||
get { return FilterType.Convolution; }
|
||||
public override Types Type {
|
||||
get { return Types.Convolution; }
|
||||
}
|
||||
public byte MatrixX;
|
||||
public byte MatrixY;
|
||||
@@ -108,15 +107,15 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
}
|
||||
|
||||
public class ColorMatrixFilter : Filter {
|
||||
public override FilterType Type {
|
||||
get { return FilterType.ColorMatrix; }
|
||||
public override Types Type {
|
||||
get { return Types.ColorMatrix; }
|
||||
}
|
||||
public float[] Matrix;
|
||||
}
|
||||
|
||||
public class GradientBevelFilter : Filter {
|
||||
public override FilterType Type {
|
||||
get { return FilterType.GradientBevel; }
|
||||
public override Types Type {
|
||||
get { return Types.GradientBevel; }
|
||||
}
|
||||
public SwfColor[] GradientColors;
|
||||
public byte[] GradientRatio;
|
||||
@@ -137,18 +136,17 @@ namespace FlashTools.Internal.SwfTools.SwfTypes {
|
||||
public static SwfSurfaceFilters identity {
|
||||
get {
|
||||
return new SwfSurfaceFilters{
|
||||
Filters = new List<Filter>()
|
||||
};
|
||||
Filters = new List<Filter>()};
|
||||
}
|
||||
}
|
||||
|
||||
public static SwfSurfaceFilters Read(SwfStreamReader reader) {
|
||||
var count = reader.ReadByte();
|
||||
var filters = new List<Filter>(count);
|
||||
var filters = new List<Filter>(reader.ReadByte());
|
||||
for ( var i = 0; i < filters.Capacity; ++i ) {
|
||||
filters.Add(ReadFilter(reader));
|
||||
}
|
||||
return new SwfSurfaceFilters{Filters = filters};
|
||||
return new SwfSurfaceFilters{
|
||||
Filters = filters};
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
|
||||
Reference in New Issue
Block a user