public TagDefineMovie(Flash flash, byte[] data, Cursor cursor) : base(flash, data, cursor) { int tagsCount = Utils.ReadInt32(data, cursor); _tags = new ITag[tagsCount]; for (int i = 0; i < tagsCount; i++) { byte type = Utils.ReadByte(data, cursor); if (type == TagPlaceObject.TYPE) { ITag tag = new TagPlaceObject(this.flash, data, cursor); _tags[i] = tag; } else if (type == TagRemoveObject.TYPE) { ITag tag = new TagRemoveObject(this.flash, data, cursor); _tags[i] = tag; } } _maxDepth = Utils.ReadInt32(data, cursor); int framesCount = Utils.ReadInt32(data, cursor); _frames = new Frame[framesCount]; for (int i = 0; i < framesCount; i++) { Frame frame = new Frame(i, data, cursor); _frames[i] = frame; } }
void readDefines(byte[] data, Cursor cursor) { int len = Utils.ReadLength(data, cursor); int newIndex = cursor.index + len; int maxcharacterId = Utils.ReadInt32(data, cursor); int definesCount = Utils.ReadInt32(data, cursor); chId_defs = new TagDefine[maxcharacterId + 1]; classNameDefs = new Dictionary <string, TagDefine> (definesCount / 4); for (int i = 0; i < definesCount; i++) { TagDefine define = parseDefine(this, data, cursor); if (define != null) { chId_defs[define.characterId] = define; if (define is TagDefine && (define as TagDefine).className != null) { classNameDefs[(define as TagDefine).className] = define; } } } cursor.index = newIndex; }
public FrameObject(byte[] data, Cursor cursor) { this.characterId = Utils.ReadInt32(data, cursor); this.placedAtIndex = Utils.ReadInt32(data, cursor); this.lastModfiedAtIndex = Utils.ReadInt32(data, cursor); this.isKeyFrame = Utils.ReadByte(data, cursor) != 0; }
public TagRemoveObject(Flash flash, byte[] data, Cursor cursor) { this.flash = flash; int dataLength = Utils.ReadInt32(data, cursor); int nextIndex = cursor.index + dataLength; depth = Utils.ReadInt32(data, cursor); cursor.index = nextIndex; }
public TagPlaceObject(Flash flash, byte[] data, Cursor cursor) { this.flash = flash; int dataLength = Utils.ReadInt32(data, cursor); int nextIndex = cursor.index + dataLength; //parse hasMatrix = Utils.ReadByte(data, cursor) != 0; hasMove = Utils.ReadByte(data, cursor) != 0; hasCharacter = Utils.ReadByte(data, cursor) != 0; hasColorTransform = Utils.ReadByte(data, cursor) != 0; bool hasName = Utils.ReadByte(data, cursor) != 0; hasVisible = Utils.ReadByte(data, cursor) != 0; depth = Utils.ReadInt32(data, cursor); if (hasCharacter) { characterId = Utils.ReadInt32(data, cursor); } if (hasMatrix) { position = Utils.ReadVector2(data, cursor); rotation = Utils.ReadFloat(data, cursor); scaleX = Utils.ReadFloat(data, cursor); scaleY = Utils.ReadFloat(data, cursor); } else { position = Vector2.zero; rotation = 0; scaleX = 1; scaleY = 1; } if (hasVisible) { visible = Utils.ReadByte(data, cursor) != 0; } if (hasColorTransform) { colorTransform = Utils.ReadColorTransform(data, cursor); } else { colorTransform = ColorTransform.Default; } if (hasName) { instanceName = Utils.ReadString(data, cursor); } cursor.index = nextIndex; }
public static string ReadString(byte[] data, Cursor cursor) { int len = Utils.ReadInt32(data, cursor); if (len == 0) { return(null); } System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); string s = enc.GetString(data, cursor.index, len); cursor.index += len; return(s); }
public static ColorTransform ReadColorTransform(byte[] data, Cursor cursor) { ColorTransform ctr = new ColorTransform(); int mtype = Utils.ReadInt32(data, cursor); if (mtype == 1) { ctr.tint = new Color(1, 1, 1, 1); } else if (mtype == 2) { Color color = new Color(); color.r = Utils.ReadFloat(data, cursor); color.g = Utils.ReadFloat(data, cursor); color.b = Utils.ReadFloat(data, cursor); color.a = Utils.ReadFloat(data, cursor); ctr.tint = color; } else { ctr.tint = new Color(0, 0, 0, 0); } int atype = Utils.ReadInt32(data, cursor); if (atype == 1) { ctr.add = new Color(255, 255, 255, 255); } else if (atype == 2) { Color32 color = new Color(); color.r = Utils.ReadByte(data, cursor); color.g = Utils.ReadByte(data, cursor); color.b = Utils.ReadByte(data, cursor); color.a = Utils.ReadByte(data, cursor); ctr.add = color; } else { ctr.add = new Color(0, 0, 0, 0); } return(ctr); }
void readHeader(byte[] data, Cursor cursor) { int len = Utils.ReadLength(data, cursor); int newIndex = cursor.index + len; version = Utils.ReadInt32(data, cursor); int supportedVersion = Utils.ReadInt32(data, cursor); NSUtils.Assert(LIB_VERSION >= supportedVersion, "BBGamelib:flash: library {0} is not supported by swf parser {1} ", versionToString(LIB_VERSION), versionToString(supportedVersion)); flashVersion = Utils.ReadByte(data, cursor); frameRate = Utils.ReadByte(data, cursor); frameSize = Utils.ReadVector2(data, cursor); prefix = Utils.ReadString(data, cursor); cursor.index = newIndex; }
public Frame(int frameIndex, byte[] data, Cursor cursor) { this.frameIndex = frameIndex; int dataLength = Utils.ReadInt32(data, cursor); int nextIndex = cursor.index + dataLength; //parse label = Utils.ReadString(data, cursor); int objsCount = Utils.ReadInt32(data, cursor); objs = new FrameObject[objsCount]; for (int i = 0; i < objsCount; i++) { FrameObject obj = new FrameObject(data, cursor); objs[i] = obj; } cursor.index = nextIndex; }
public TagDefine parseDefine(Flash flash, byte[] data, Cursor cursor) { //find nextIndex int dataLength = Utils.ReadInt32(data, cursor); int nextIndex = cursor.index + dataLength; //parse byte type = Utils.ReadByte(data, cursor); TagDefine def = null; if (type == TagDefine.DEF_TYPE_GRAPHIC) { def = new TagDefineGraphic(flash, data, cursor); } else if (type == TagDefine.DEF_TYPE_SPRITE) { def = new TagDefineMovie(flash, data, cursor); } //nextIndex cursor.index = nextIndex; return(def); }
public static int ReadLength(byte[] data, Cursor cursor) { return(Utils.ReadInt32(data, cursor)); }
public TagDefine(Flash flash, byte[] data, Cursor cursor) { this.flash = flash; this.characterId = Utils.ReadInt32(data, cursor); this.className = Utils.ReadString(data, cursor); }