diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline2.java b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline2.java new file mode 100644 index 000000000..dff866bef --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline2.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.timeline; + +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.tags.DoActionTag; +import com.jpexs.decompiler.flash.tags.ShowFrameTag; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; +import com.jpexs.decompiler.flash.tags.base.RemoveTag; +import com.jpexs.decompiler.flash.types.CLIPACTIONS; +import com.jpexs.decompiler.flash.types.CXFORM; +import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; +import com.jpexs.decompiler.flash.types.MATRIX; +import com.jpexs.decompiler.flash.types.filters.FILTER; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JPEXS + */ +public class Timeline { + + public List frames = new ArrayList<>(); + + public Timeline() { + } + + public int getMaxDepth() { + int max_depth = 0; + for (Frame f : frames) { + for (int depth : f.layers.keySet()) { + if (depth > max_depth) { + max_depth = depth; + } + } + } + return max_depth; + } + + public int getFrameCount() { + return frames.size(); + } + + public Timeline(SWF swf) { + Frame frame = new Frame(); + for (Tag t : swf.tags) { + if (t instanceof PlaceObjectTypeTag) { + PlaceObjectTypeTag po = (PlaceObjectTypeTag) t; + int depth = po.getDepth(); + if (!frame.layers.containsKey(depth)) { + frame.layers.put(depth, new DepthState()); + } + DepthState fl = frame.layers.get(depth); + int characterId = po.getCharacterId(); + if (characterId != -1) { + fl.characterId = characterId; + } + if (po.flagMove()) { + MATRIX matrix2 = po.getMatrix(); + if (matrix2 != null) { + fl.matrix = matrix2; + } + String instanceName2 = po.getInstanceName(); + if (instanceName2 != null) { + fl.instanceName = instanceName2; + } + CXFORM colorTransForm2 = po.getColorTransform(); + if (colorTransForm2 != null) { + fl.colorTransForm = colorTransForm2; + } + + CXFORMWITHALPHA colorTransFormAlpha2 = po.getColorTransformWithAlpha(); + if (colorTransFormAlpha2 != null) { + fl.colorTransFormAlpha = colorTransFormAlpha2; + } + + CLIPACTIONS clipActions2 = po.getClipActions(); + if (clipActions2 != null) { + fl.clipActions = clipActions2; + } + if (po.cacheAsBitmap()) { + fl.cacheAsBitmap = true; + } + int blendMode2 = po.getBlendMode(); + if (blendMode2 > 0) { + fl.blendMode = blendMode2; + } + List filters2 = po.getFilters(); + if (filters2 != null) { + fl.filters = filters2; + } + int ratio2 = po.getRatio(); + if (ratio2 > -1) { + fl.ratio = ratio2; + } + } else { + fl.matrix = po.getMatrix(); + fl.instanceName = po.getInstanceName(); + fl.colorTransForm = po.getColorTransform(); + fl.colorTransFormAlpha = po.getColorTransformWithAlpha(); + fl.cacheAsBitmap = po.cacheAsBitmap(); + fl.blendMode = po.getBlendMode(); + fl.filters = po.getFilters(); + fl.ratio = po.getRatio(); + fl.clipActions = po.getClipActions(); + } + fl.key = true; + } + if (t instanceof RemoveTag) { + RemoveTag r = (RemoveTag) t; + int depth = r.getDepth(); + frame.layers.remove(depth); + } + if (t instanceof DoActionTag) { + frame.action = (DoActionTag) t; + } + if (t instanceof ShowFrameTag) { + frames.add(frame); + frame = new Frame(frame); + } + } + } +}