mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-05 18:34:45 +00:00
timeline panel refactored
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.timeline;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.decompiler.flash.types.CLIPACTIONS;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.MATRIX;
|
||||
@@ -64,6 +65,8 @@ public class DepthState {
|
||||
|
||||
public Frame frame;
|
||||
|
||||
public PlaceObjectTypeTag placeObjectTag;
|
||||
|
||||
public long instanceId;
|
||||
|
||||
public boolean motionTween = false;
|
||||
@@ -96,6 +99,7 @@ public class DepthState {
|
||||
ratio = obj.ratio;
|
||||
clipDepth = obj.clipDepth;
|
||||
time = obj.time;
|
||||
placeObjectTag = obj.placeObjectTag;
|
||||
if (sameInstance) {
|
||||
time++;
|
||||
instanceId = obj.instanceId;
|
||||
|
||||
@@ -257,11 +257,12 @@ public class Timeline {
|
||||
newFrameNeeded = true;
|
||||
PlaceObjectTypeTag po = (PlaceObjectTypeTag) t;
|
||||
int depth = po.getDepth();
|
||||
if (!frame.layers.containsKey(depth)) {
|
||||
frame.layers.put(depth, new DepthState(swf, frame));
|
||||
DepthState fl = frame.layers.get(depth);
|
||||
if (fl == null) {
|
||||
frame.layers.put(depth, fl = new DepthState(swf, frame));
|
||||
}
|
||||
frame.layersChanged = true;
|
||||
DepthState fl = frame.layers.get(depth);
|
||||
fl.placeObjectTag = po;
|
||||
int characterId = po.getCharacterId();
|
||||
if (characterId != -1) {
|
||||
fl.characterId = characterId;
|
||||
@@ -314,7 +315,7 @@ public class Timeline {
|
||||
fl.clipActions = po.getClipActions();
|
||||
fl.clipDepth = po.getClipDepth();
|
||||
}
|
||||
fl.key = true;
|
||||
fl.key = characterId != -1;
|
||||
} else if (t instanceof RemoveTag) {
|
||||
newFrameNeeded = true;
|
||||
RemoveTag r = (RemoveTag) t;
|
||||
@@ -342,8 +343,7 @@ public class Timeline {
|
||||
|
||||
maxDepth = getMaxDepthInternal();
|
||||
|
||||
// todo: enable again after TweenDetector.detectRanges implemented
|
||||
//detectTweens();
|
||||
detectTweens();
|
||||
calculateMaxDepthFrames();
|
||||
|
||||
createASPackages();
|
||||
@@ -355,10 +355,6 @@ public class Timeline {
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
private boolean compare(int a, int b, int c, int tolerance) {
|
||||
return Math.abs((b - a) - (c - b)) < tolerance;
|
||||
}
|
||||
|
||||
private void detectTweens() {
|
||||
for (int d = 1; d <= maxDepth; d++) {
|
||||
int characterId = -1;
|
||||
@@ -366,26 +362,31 @@ public class Timeline {
|
||||
for (int f = 0; f <= frames.size(); f++) {
|
||||
DepthState ds = f >= frames.size() ? null : frames.get(f).layers.get(d);
|
||||
|
||||
if (f < frames.size() && ds != null && ds.characterId == characterId && ds.characterId != -1) {
|
||||
if (ds != null && characterId != -1 && ds.characterId == characterId) {
|
||||
len++;
|
||||
} else {
|
||||
if (characterId != -1) {
|
||||
List<MATRIX> matrices = new ArrayList<>();
|
||||
int startPos = f - len;
|
||||
List<DepthState> matrices = new ArrayList<>(len);
|
||||
for (int k = 0; k < len; k++) {
|
||||
matrices.add(frames.get(f - len + k).layers.get(d).matrix);
|
||||
matrices.add(frames.get(startPos + k).layers.get(d));
|
||||
}
|
||||
|
||||
List<TweenRange> ranges = TweenDetector.detectRanges(matrices);
|
||||
for (TweenRange r : ranges) {
|
||||
for (int t = r.startPosition; t <= r.endPosition; t++) {
|
||||
DepthState layer = frames.get(f - len + t).layers.get(d);
|
||||
DepthState layer = frames.get(startPos + t).layers.get(d);
|
||||
layer.motionTween = true;
|
||||
layer.key = false;
|
||||
}
|
||||
frames.get(r.startPosition).layers.get(d).key = true;
|
||||
|
||||
frames.get(startPos + r.startPosition).layers.get(d).key = true;
|
||||
}
|
||||
}
|
||||
|
||||
len = 1;
|
||||
}
|
||||
|
||||
characterId = ds == null ? -1 : ds.characterId;
|
||||
}
|
||||
}
|
||||
@@ -396,7 +397,7 @@ public class Timeline {
|
||||
for (int d = 1; d <= maxDepth; d++) {
|
||||
for (int f = frames.size() - 1; f >= 0; f--) {
|
||||
if (frames.get(f).layers.get(d) != null) {
|
||||
depthMaxFrame.put(d, f + 1);
|
||||
depthMaxFrame.put(d, f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library 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
|
||||
* 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.timeline;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -27,11 +28,15 @@ import java.util.List;
|
||||
*/
|
||||
public class TweenDetector {
|
||||
|
||||
|
||||
public static List<TweenRange> detectRanges(List<DepthState> depthStates) {
|
||||
//TODO: make this working :-(
|
||||
//TODO: make this working :-(
|
||||
if (depthStates.size() < 2 || depthStates.get(0).placeObjectTag == depthStates.get(1).placeObjectTag) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return new ArrayList<>(Arrays.asList(new TweenRange(0, depthStates.size() - 1)));
|
||||
/*
|
||||
/*
|
||||
|
||||
List<TweenRange> ret = new ArrayList<>();
|
||||
double tolerance = 1;
|
||||
int min = 3;
|
||||
@@ -44,20 +49,20 @@ public class TweenDetector {
|
||||
List<Double> scaleY=new ArrayList<>();
|
||||
List<Double> rotateSkew0=new ArrayList<>();
|
||||
List<Double> rotateSkew1=new ArrayList<>();
|
||||
List<Double> rotateSkew1=new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
Set<MATRIX> ms=new HashSet<MATRIX>();
|
||||
ms.addAll(matrices);
|
||||
if(ms.size()==1){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(MATRIX n:matrices){
|
||||
//...
|
||||
//...
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (; startpos + i <= matrices.size() + 1; i++) {
|
||||
double errTranslateX = startpos + i > matrices.size() ? Double.MAX_VALUE : getErrorLevel(translateX, startpos, i);
|
||||
double errTranslateY = startpos + i > matrices.size() ? Double.MAX_VALUE : getErrorLevel(translateY, startpos, i);
|
||||
double errScaleX = startpos + i > matrices.size() ? Double.MAX_VALUE : getErrorLevel(scaleX, startpos, i);
|
||||
@@ -71,7 +76,7 @@ public class TweenDetector {
|
||||
i = min - 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ret.add(new TweenRange(startpos, startpos+i-1-1));
|
||||
startpos = startpos + i -1;
|
||||
i = min - 1;
|
||||
last = null;
|
||||
|
||||
Reference in New Issue
Block a user