better detecting single frame sprites

This commit is contained in:
honfika@gmail.com
2014-11-08 20:09:48 +01:00
parent 6b05121802
commit 2966f07444
4 changed files with 20 additions and 3 deletions

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.exporters.shape;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
@@ -129,6 +130,5 @@ public class PathExporter extends ShapeExporterBase {
protected void finalizePath() {
paths.add(path);
path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); //For correct intersections display
path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); //For correct intersections display
}
}

View File

@@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.timeline.DepthState;
import com.jpexs.decompiler.flash.timeline.Frame;
import com.jpexs.decompiler.flash.timeline.Timeline;
import com.jpexs.decompiler.flash.timeline.Timelined;
import com.jpexs.decompiler.flash.types.BasicType;
@@ -313,6 +314,18 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
public int getNumFrames() {
return frameCount;
}
private int getRealFrameCount() {
int cnt = 1;
List<Frame> frames = getTimeline().getFrames();
for (int i = 1; i < frames.size(); i++) {
if (frames.get(i).layersChanged) {
cnt++;
}
}
return cnt;
}
@Override
public boolean isSingleFrame() {
@@ -324,7 +337,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable
private synchronized void initialiteIsSingleFrame() {
if (!isSingleFrameInitialized) {
if (frameCount > 1) {
if (getRealFrameCount() > 1) {
isSingleFrameInitialized = true;
return;
}

View File

@@ -42,6 +42,7 @@ public class Frame implements TreeItem {
public List<DoActionTag> actions = new ArrayList<>();
public List<Tag> innerTags = new ArrayList<>();
public ShowFrameTag showFrameTag = null; // can be null for the last frame
public boolean layersChanged;
public Frame(Timeline timeline, int frame) {
this.timeline = timeline;

View File

@@ -153,6 +153,7 @@ public class Timeline {
private void initialize() {
int frameIdx = 0;
Frame frame = new Frame(this, frameIdx++);
frame.layersChanged = true;
boolean tagAdded = false;
for (Tag t : tags) {
tagAdded = true;
@@ -171,6 +172,7 @@ public class Timeline {
if (!frame.layers.containsKey(depth)) {
frame.layers.put(depth, new DepthState(swf, frame));
}
frame.layersChanged = true;
DepthState fl = frame.layers.get(depth);
int characterId = po.getCharacterId();
if (characterId != -1) {
@@ -229,6 +231,7 @@ public class Timeline {
RemoveTag r = (RemoveTag) t;
int depth = r.getDepth();
frame.layers.remove(depth);
frame.layersChanged = true;
} else if (t instanceof DoActionTag) {
frame.actions.add((DoActionTag) t);
actionFrames.put((DoActionTag) t, frame.frame);