external player preview fixes

This commit is contained in:
honfika@gmail.com
2015-12-24 17:37:17 +01:00
parent 5255d9e80e
commit f9254ef60b
11 changed files with 285 additions and 104 deletions

View File

@@ -149,15 +149,15 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
super(swf, ID, NAME, null);
}
public PlaceObject2Tag(SWF swf, boolean placeFlagHasClipActions, boolean placeFlagHasClipDepth, boolean placeFlagHasName, boolean placeFlagHasRatio, boolean placeFlagHasColorTransform, boolean placeFlagHasMatrix, boolean placeFlagHasCharacter, boolean placeFlagMove, int depth, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, CLIPACTIONS clipActions) {
public PlaceObject2Tag(SWF swf, boolean placeFlagMove, int depth, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, CLIPACTIONS clipActions) {
super(swf, ID, NAME, null);
this.placeFlagHasClipActions = placeFlagHasClipActions;
this.placeFlagHasClipDepth = placeFlagHasClipDepth;
this.placeFlagHasName = placeFlagHasName;
this.placeFlagHasRatio = placeFlagHasRatio;
this.placeFlagHasColorTransform = placeFlagHasColorTransform;
this.placeFlagHasMatrix = placeFlagHasMatrix;
this.placeFlagHasCharacter = placeFlagHasCharacter;
this.placeFlagHasClipActions = clipActions != null;
this.placeFlagHasClipDepth = clipDepth >= 0;
this.placeFlagHasName = name != null;
this.placeFlagHasRatio = ratio >= 0;
this.placeFlagHasColorTransform = colorTransform != null;
this.placeFlagHasMatrix = matrix != null;
this.placeFlagHasCharacter = characterId >= 0;
this.placeFlagMove = placeFlagMove;
this.depth = depth;
this.characterId = characterId;
@@ -256,6 +256,11 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
}
@Override
public int getPlaceObjectNum() {
return 2;
}
@Override
public int getClipDepth() {
if (placeFlagHasClipDepth) {
@@ -329,6 +334,11 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
}
@Override
public void setMatrix(MATRIX matrix) {
this.matrix = matrix;
}
@Override
public String getInstanceName() {
if (placeFlagHasName) {

View File

@@ -239,6 +239,38 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
super(swf, ID, NAME, null);
}
public PlaceObject3Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions) {
super(swf, ID, NAME, null);
this.placeFlagHasClassName = className != null;
this.placeFlagHasFilterList = surfaceFilterList != null;
this.placeFlagHasBlendMode = blendMode >= 0;
this.placeFlagHasCacheAsBitmap = bitmapCache >= 0;
this.placeFlagHasVisible = visible >= 0;
this.placeFlagOpaqueBackground = backgroundColor != null;
this.placeFlagHasClipActions = clipActions != null;
this.placeFlagHasClipDepth = clipDepth >= 0;
this.placeFlagHasName = name != null;
this.placeFlagHasRatio = ratio >= 0;
this.placeFlagHasColorTransform = colorTransform != null;
this.placeFlagHasMatrix = matrix != null;
this.placeFlagHasCharacter = characterId >= 0;
this.placeFlagMove = placeFlagMove;
this.depth = depth;
this.className = className;
this.characterId = characterId;
this.matrix = matrix;
this.colorTransform = colorTransform;
this.ratio = ratio;
this.name = name;
this.clipDepth = clipDepth;
this.surfaceFilterList = surfaceFilterList;
this.blendMode = blendMode;
this.bitmapCache = bitmapCache;
this.visible = visible;
this.backgroundColor = backgroundColor;
this.clipActions = clipActions;
}
/**
* Constructor
*
@@ -390,12 +422,8 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
@Override
public List<FILTER> getFilters() {
if (placeFlagHasFilterList) {
return surfaceFilterList;
} else {
return null;
}
public int getPlaceObjectNum() {
return 3;
}
@Override
@@ -406,6 +434,15 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
return -1;
}
@Override
public List<FILTER> getFilters() {
if (placeFlagHasFilterList) {
return surfaceFilterList;
} else {
return null;
}
}
/**
* Returns all sub-items
*
@@ -466,6 +503,11 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
}
@Override
public void setMatrix(MATRIX matrix) {
this.matrix = matrix;
}
@Override
public String getInstanceName() {
if (placeFlagHasName) {

View File

@@ -241,6 +241,39 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
super(swf, ID, NAME, null);
}
public PlaceObject4Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List<FILTER> surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions, byte[] amfData) {
super(swf, ID, NAME, null);
this.placeFlagHasClassName = className != null;
this.placeFlagHasFilterList = surfaceFilterList != null;
this.placeFlagHasBlendMode = blendMode >= 0;
this.placeFlagHasCacheAsBitmap = bitmapCache >= 0;
this.placeFlagHasVisible = visible >= 0;
this.placeFlagOpaqueBackground = backgroundColor != null;
this.placeFlagHasClipActions = clipActions != null;
this.placeFlagHasClipDepth = clipDepth >= 0;
this.placeFlagHasName = name != null;
this.placeFlagHasRatio = ratio >= 0;
this.placeFlagHasColorTransform = colorTransform != null;
this.placeFlagHasMatrix = matrix != null;
this.placeFlagHasCharacter = characterId >= 0;
this.placeFlagMove = placeFlagMove;
this.depth = depth;
this.className = className;
this.characterId = characterId;
this.matrix = matrix;
this.colorTransform = colorTransform;
this.ratio = ratio;
this.name = name;
this.clipDepth = clipDepth;
this.surfaceFilterList = surfaceFilterList;
this.blendMode = blendMode;
this.bitmapCache = bitmapCache;
this.visible = visible;
this.backgroundColor = backgroundColor;
this.clipActions = clipActions;
this.amfData = amfData;
}
/**
* Constructor
*
@@ -394,12 +427,8 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
@Override
public List<FILTER> getFilters() {
if (placeFlagHasFilterList) {
return surfaceFilterList;
} else {
return null;
}
public int getPlaceObjectNum() {
return 4;
}
@Override
@@ -410,6 +439,15 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
return -1;
}
@Override
public List<FILTER> getFilters() {
if (placeFlagHasFilterList) {
return surfaceFilterList;
} else {
return null;
}
}
/**
* Returns all sub-items
*
@@ -470,6 +508,11 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont
}
}
@Override
public void setMatrix(MATRIX matrix) {
this.matrix = matrix;
}
@Override
public String getInstanceName() {
if (placeFlagHasName) {

View File

@@ -127,8 +127,8 @@ public class PlaceObjectTag extends PlaceObjectTypeTag {
public CXFORM colorTransform;
@Override
public List<FILTER> getFilters() {
return null;
public int getPlaceObjectNum() {
return 1;
}
@Override
@@ -136,6 +136,11 @@ public class PlaceObjectTag extends PlaceObjectTypeTag {
return -1;
}
@Override
public List<FILTER> getFilters() {
return null;
}
@Override
public void getNeededCharacters(Set<Integer> needed) {
needed.add(characterId);
@@ -172,6 +177,11 @@ public class PlaceObjectTag extends PlaceObjectTypeTag {
return matrix;
}
@Override
public void setMatrix(MATRIX matrix) {
this.matrix = matrix;
}
@Override
public String getInstanceName() {
return null;

View File

@@ -38,10 +38,14 @@ public abstract class PlaceObjectTypeTag extends Tag implements CharacterIdTag {
super(swf, id, name, data);
}
public abstract int getPlaceObjectNum();
public abstract int getDepth();
public abstract MATRIX getMatrix();
public abstract void setMatrix(MATRIX matrix);
public abstract String getInstanceName();
public abstract void setInstanceName(String name);

View File

@@ -17,8 +17,14 @@
package com.jpexs.decompiler.flash.timeline;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.tags.PlaceObject2Tag;
import com.jpexs.decompiler.flash.tags.PlaceObject3Tag;
import com.jpexs.decompiler.flash.tags.PlaceObject4Tag;
import com.jpexs.decompiler.flash.tags.PlaceObjectTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
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.ColorTransform;
import com.jpexs.decompiler.flash.types.MATRIX;
import com.jpexs.decompiler.flash.types.RGBA;
@@ -35,11 +41,11 @@ public class DepthState {
public int characterId = -1;
public MATRIX matrix = null;
public MATRIX matrix;
public String instanceName = null;
public String instanceName;
public ColorTransform colorTransForm = null;
public ColorTransform colorTransForm;
public boolean cacheAsBitmap = false;
@@ -49,9 +55,11 @@ public class DepthState {
public boolean isVisible = true;
public RGBA backGroundColor = null;
public RGBA backGroundColor;
public CLIPACTIONS clipActions = null;
public CLIPACTIONS clipActions;
public byte[] amfData;
public int ratio = -1;
@@ -67,6 +75,8 @@ public class DepthState {
public PlaceObjectTypeTag placeObjectTag;
public int minPlaceObjectNum;
public long instanceId;
public boolean motionTween = false;
@@ -100,6 +110,7 @@ public class DepthState {
clipDepth = obj.clipDepth;
time = obj.time;
placeObjectTag = obj.placeObjectTag;
minPlaceObjectNum = obj.minPlaceObjectNum;
if (sameInstance) {
time++;
instanceId = obj.instanceId;
@@ -107,4 +118,20 @@ public class DepthState {
instanceId = getNewInstanceId();
}
}
public PlaceObjectTypeTag toPlaceObjectTag(int depth) {
if (minPlaceObjectNum <= 1) {
CXFORM cxForm0 = colorTransForm == null ? null : new CXFORM(colorTransForm);
return new PlaceObjectTag(swf, characterId, depth, matrix, cxForm0);
} else if (minPlaceObjectNum == 2) {
CXFORMWITHALPHA cxForm = colorTransForm == null ? null : new CXFORMWITHALPHA(colorTransForm);
return new PlaceObject2Tag(swf, false, depth, characterId, matrix, cxForm, ratio, instanceName, clipDepth, clipActions);
} else if (minPlaceObjectNum == 3) {
CXFORMWITHALPHA cxForm = colorTransForm == null ? null : new CXFORMWITHALPHA(colorTransForm);
return new PlaceObject3Tag(swf, false, depth, null/*todo: className*/, characterId, matrix, cxForm, ratio, instanceName, clipDepth, filters, blendMode, cacheAsBitmap ? 1 : 0, isVisible ? 1 : 0, backGroundColor, clipActions);
}
CXFORMWITHALPHA cxForm = colorTransForm == null ? null : new CXFORMWITHALPHA(colorTransForm);
return new PlaceObject4Tag(swf, false, depth, null/*todo: className*/, characterId, matrix, cxForm, ratio, instanceName, clipDepth, filters, blendMode, cacheAsBitmap ? 1 : 0, isVisible ? 1 : 0, backGroundColor, clipActions, null);
}
}

View File

@@ -263,6 +263,7 @@ public class Timeline {
}
frame.layersChanged = true;
fl.placeObjectTag = po;
fl.minPlaceObjectNum = Math.max(fl.minPlaceObjectNum, po.getPlaceObjectNum());
int characterId = po.getCharacterId();
if (characterId != -1) {
fl.characterId = characterId;

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.types.annotations.Calculated;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
/**
@@ -44,36 +45,42 @@ public class CXFORM extends ColorTransform {
/**
* Red multiply value
*/
@Conditional("hasMultTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int redMultTerm;
/**
* Green multiply value
*/
@Conditional("hasMultTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int greenMultTerm;
/**
* Blue multiply value
*/
@Conditional("hasMultTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int blueMultTerm;
/**
* Red addition value
*/
@Conditional("hasAddTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int redAddTerm;
/**
* Green addition value
*/
@Conditional("hasAddTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int greenAddTerm;
/**
* Blue addition value
*/
@Conditional("hasAddTerms")
@SWFType(value = BasicType.SB, countField = "nbits")
public int blueAddTerm;
@@ -107,6 +114,20 @@ public class CXFORM extends ColorTransform {
return hasMultTerms ? blueMultTerm : super.getBlueMulti();
}
public CXFORM() {
}
public CXFORM(ColorTransform colorTransform) {
redMultTerm = colorTransform.getRedMulti();
greenMultTerm = colorTransform.getGreenMulti();
blueMultTerm = colorTransform.getBlueMulti();
redAddTerm = colorTransform.getRedAdd();
greenAddTerm = colorTransform.getGreenAdd();
blueAddTerm = colorTransform.getBlueAdd();
hasAddTerms = redAddTerm != 0 || greenAddTerm != 0 || blueAddTerm != 0;
hasMultTerms = redMultTerm != 255 || greenMultTerm != 255 || blueMultTerm != 255;
}
@Override
public CXFORM clone() {
CXFORM ret = (CXFORM) super.clone();

View File

@@ -38,6 +38,10 @@ public class CXFORMWITHALPHA extends ColorTransform {
*/
public boolean hasMultTerms;
@Calculated
@SWFType(value = BasicType.UB, count = 4)
public int nbits;
/**
* Red multiply value
*/
@@ -94,10 +98,6 @@ public class CXFORMWITHALPHA extends ColorTransform {
@SWFType(value = BasicType.SB, countField = "nbits")
public int alphaAddTerm;
@Calculated
@SWFType(value = BasicType.UB, count = 4)
public int nbits;
@Override
public int getRedAdd() {
return hasAddTerms ? redAddTerm : super.getRedAdd();
@@ -138,6 +138,22 @@ public class CXFORMWITHALPHA extends ColorTransform {
return hasMultTerms ? alphaMultTerm : super.getAlphaMulti();
}
public CXFORMWITHALPHA() {
}
public CXFORMWITHALPHA(ColorTransform colorTransform) {
redMultTerm = colorTransform.getRedMulti();
greenMultTerm = colorTransform.getGreenMulti();
blueMultTerm = colorTransform.getBlueMulti();
alphaMultTerm = colorTransform.getAlphaMulti();
redAddTerm = colorTransform.getRedAdd();
greenAddTerm = colorTransform.getGreenAdd();
blueAddTerm = colorTransform.getBlueAdd();
alphaAddTerm = colorTransform.getAlphaAdd();
hasAddTerms = redAddTerm != 0 || greenAddTerm != 0 || blueAddTerm != 0 || alphaAddTerm != 0;
hasMultTerms = redMultTerm != 255 || greenMultTerm != 255 || blueMultTerm != 255 || alphaMultTerm != 255;
}
@Override
public CXFORMWITHALPHA clone() {
CXFORMWITHALPHA ret = (CXFORMWITHALPHA) super.clone();

View File

@@ -951,7 +951,9 @@ public final class ImagePanel extends JPanel implements MediaDisplay {
float frameRate = timeline.frameRate;
int msPerFrame = frameRate == 0 ? 1000 : (int) (1000.0 / frameRate);
final boolean singleFrame = !playing || (timeline.getRealFrameCount() <= 1 && timeline.isSingleFrame());
final boolean singleFrame = !playing
|| (stillFrame && timeline.isSingleFrame(frame))
|| (!stillFrame && timeline.getRealFrameCount() <= 1 && timeline.isSingleFrame());
timer = new Timer();
TimerTask task = new TimerTask() {

View File

@@ -55,9 +55,11 @@ import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.tags.base.RemoveTag;
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
import com.jpexs.decompiler.flash.timeline.DepthState;
import com.jpexs.decompiler.flash.timeline.Frame;
import com.jpexs.decompiler.flash.timeline.TagScript;
import com.jpexs.decompiler.flash.timeline.Timelined;
@@ -69,7 +71,6 @@ import com.jpexs.decompiler.flash.types.RGB;
import com.jpexs.decompiler.flash.types.SHAPE;
import com.jpexs.decompiler.flash.types.TEXTRECORD;
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.SerializableImage;
import java.awt.BorderLayout;
import java.awt.CardLayout;
@@ -93,6 +94,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -588,7 +590,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
return t;
}
public void createAndShowTempSwf(TreeItem tagObj) {
public void createAndShowTempSwf(TreeItem treeItem) {
SWF swf = null;
try {
if (tempFile != null) {
@@ -600,14 +602,14 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
Color backgroundColor = View.getSwfBackgroundColor();
if (tagObj instanceof Tag) {
Tag tag = (Tag) tagObj;
if (treeItem instanceof Tag) {
Tag tag = (Tag) treeItem;
swf = tag.getSwf();
if (tag instanceof FontTag) { //Fonts are always black on white
backgroundColor = View.getDefaultBackgroundColor();
}
} else if (tagObj instanceof Frame) {
Frame fn = (Frame) tagObj;
} else if (treeItem instanceof Frame) {
Frame fn = (Frame) treeItem;
swf = fn.getSwf();
if (fn.timeline.timelined == swf) {
SetBackgroundColorTag setBgColorTag = swf.getBackgroundColor();
@@ -620,29 +622,29 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
int frameCount = 1;
float frameRate = swf.frameRate;
HashMap<Integer, VideoFrameTag> videoFrames = new HashMap<>();
if (tagObj instanceof DefineVideoStreamTag) {
DefineVideoStreamTag vs = (DefineVideoStreamTag) tagObj;
if (treeItem instanceof DefineVideoStreamTag) {
DefineVideoStreamTag vs = (DefineVideoStreamTag) treeItem;
SWF.populateVideoFrames(vs.getCharacterId(), swf.tags, videoFrames);
frameCount = videoFrames.size();
}
List<SoundStreamBlockTag> soundFrames = new ArrayList<>();
if (tagObj instanceof SoundStreamHeadTypeTag) {
soundFrames = ((SoundStreamHeadTypeTag) tagObj).getBlocks();
if (treeItem instanceof SoundStreamHeadTypeTag) {
soundFrames = ((SoundStreamHeadTypeTag) treeItem).getBlocks();
frameCount = soundFrames.size();
}
if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
if ((treeItem instanceof DefineMorphShapeTag) || (treeItem instanceof DefineMorphShape2Tag)) {
frameRate = MainPanel.MORPH_SHAPE_ANIMATION_FRAME_RATE;
frameCount = (int) (MainPanel.MORPH_SHAPE_ANIMATION_LENGTH * frameRate);
}
if (tagObj instanceof DefineSoundTag) {
if (treeItem instanceof DefineSoundTag) {
frameCount = 1;
}
if (tagObj instanceof DefineSpriteTag) {
frameCount = ((DefineSpriteTag) tagObj).frameCount;
if (treeItem instanceof DefineSpriteTag) {
frameCount = ((DefineSpriteTag) treeItem).frameCount;
}
byte[] data;
@@ -650,12 +652,28 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
SWFOutputStream sos2 = new SWFOutputStream(baos, SWF.DEFAULT_VERSION);
RECT outrect = new RECT(swf.displayRect);
if (tagObj instanceof FontTag) {
RECT treeItemBounds = null;
if (treeItem instanceof FontTag) {
outrect.Xmin = 0;
outrect.Ymin = 0;
outrect.Xmax = FontTag.PREVIEWSIZE * 20;
outrect.Ymax = FontTag.PREVIEWSIZE * 20;
} else if (treeItem instanceof BoundedTag) {
treeItemBounds = ((BoundedTag) treeItem).getRect();
} else if (treeItem instanceof Frame) {
treeItemBounds = ((Frame) treeItem).timeline.timelined.getRect();
}
if (treeItemBounds != null) {
if (outrect.getWidth() < treeItemBounds.getWidth()) {
outrect.Xmax += treeItemBounds.getWidth() - outrect.getWidth();
}
if (outrect.getHeight() < treeItemBounds.getHeight()) {
outrect.Ymax += treeItemBounds.getHeight() - outrect.getHeight();
}
}
int width = outrect.getWidth();
int height = outrect.getHeight();
@@ -675,26 +693,15 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
setBgColorTag.writeTag(sos2);
if (tagObj instanceof Frame) {
Frame fn = (Frame) tagObj;
if (treeItem instanceof Frame) {
Frame fn = (Frame) treeItem;
Timelined parent = fn.timeline.timelined;
List<Tag> subs = fn.timeline.tags;
List<Integer> doneCharacters = new ArrayList<>();
int frameCnt = 0;
for (Tag t : subs) {
for (Tag t : fn.timeline.tags) {
if (t instanceof FileAttributesTag || t instanceof SetBackgroundColorTag) {
continue;
}
if (t instanceof ShowFrameTag) {
frameCnt++;
continue;
}
if (frameCnt > fn.frame) {
break;
}
if (t instanceof DoActionTag || t instanceof DoInitActionTag) {
// todo: Maybe DoABC tags should be removed, too
continue;
@@ -708,53 +715,52 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
doneCharacters.add(n);
}
}
if (t instanceof ShowFrameTag || t instanceof PlaceObjectTypeTag || t instanceof RemoveTag) {
continue;
}
if (t instanceof CharacterTag) {
int characterId = ((CharacterTag) t).getCharacterId();
if (!doneCharacters.contains(characterId)) {
doneCharacters.add(((CharacterTag) t).getCharacterId());
}
}
classicTag(t).writeTag(sos2);
if (parent != null) {
if (t instanceof PlaceObjectTypeTag) {
PlaceObjectTypeTag pot = (PlaceObjectTypeTag) t;
int chid = pot.getCharacterId();
int depth = pot.getDepth();
MATRIX mat = pot.getMatrix();
if (mat == null) {
mat = new MATRIX();
}
mat = Helper.deepCopy(mat);
RECT r = parent.getRect();
mat.translateX += width / 2 - r.getWidth() / 2;
mat.translateY += height / 2 - r.getHeight() / 2;
new PlaceObject2Tag(swf, false, false, false, false, false, true, false, true, depth, chid, mat, null, 0, null, 0, null).writeTag(sos2);
}
}
}
RECT r = parent.getRect();
for (Map.Entry<Integer, DepthState> value : fn.layers.entrySet()) {
PlaceObjectTypeTag pot = value.getValue().toPlaceObjectTag(value.getKey());
MATRIX mat = new MATRIX(pot.getMatrix());
mat.translateX += width / 2 - r.getWidth() / 2;
mat.translateY += height / 2 - r.getHeight() / 2;
pot.setMatrix(mat);
pot.writeTag(sos2);
}
new ShowFrameTag(swf).writeTag(sos2);
} else {
boolean isSprite = false;
if (tagObj instanceof DefineSpriteTag) {
if (treeItem instanceof DefineSpriteTag) {
isSprite = true;
}
int chtId = 0;
if (tagObj instanceof CharacterTag) {
chtId = ((CharacterTag) tagObj).getCharacterId();
if (treeItem instanceof CharacterTag) {
chtId = ((CharacterTag) treeItem).getCharacterId();
}
if (tagObj instanceof DefineBitsTag) {
if (treeItem instanceof DefineBitsTag) {
JPEGTablesTag jtt = swf.getJtt();
if (jtt != null) {
jtt.writeTag(sos2);
}
} else if (tagObj instanceof AloneTag) {
} else if (treeItem instanceof AloneTag) {
} else {
Set<Integer> needed = new HashSet<>();
((Tag) tagObj).getNeededCharactersDeep(needed);
((Tag) treeItem).getNeededCharactersDeep(needed);
for (int n : needed) {
if (isSprite && chtId == n) {
continue;
@@ -772,15 +778,15 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
}
}
classicTag((Tag) tagObj).writeTag(sos2);
classicTag((Tag) treeItem).writeTag(sos2);
MATRIX mat = new MATRIX();
mat.hasRotate = false;
mat.hasScale = false;
mat.translateX = 0;
mat.translateY = 0;
if (tagObj instanceof BoundedTag) {
RECT r = ((BoundedTag) tagObj).getRect();
if (treeItem instanceof BoundedTag) {
RECT r = ((BoundedTag) treeItem).getRect();
mat.translateX = -r.Xmin;
mat.translateY = -r.Ymin;
mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2;
@@ -789,9 +795,8 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
mat.translateX = width / 4;
mat.translateY = height / 4;
}
if (tagObj instanceof FontTag) {
FontTag ft = (FontTag) classicTag((Tag) tagObj);
if (treeItem instanceof FontTag) {
FontTag ft = (FontTag) classicTag((Tag) treeItem);
int countGlyphsTotal = ft.getGlyphShapeTable().size();
int countGlyphs = Math.min(SHAPERECORD.MAX_CHARACTERS_IN_FONT_PREVIEW, countGlyphsTotal);
@@ -875,25 +880,25 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
tmat.translateX = x * width / cols + width / cols / 2 - w / 2;
tmat.translateY = y * height / rows + height / rows / 2;
new DefineTextTag(swf, 999 + f, new RECT(0, cw, ymin, ymin + h), new MATRIX(), rec).writeTag(sos2);
new PlaceObject2Tag(swf, false, false, false, true, false, true, true, false, 1 + f, 999 + f, tmat, null, 0, null, 0, null).writeTag(sos2);
new PlaceObject2Tag(swf, false, 1 + f, 999 + f, tmat, null, 0, null, -1, null).writeTag(sos2);
x++;
}
new ShowFrameTag(swf).writeTag(sos2);
} else if ((tagObj instanceof DefineMorphShapeTag) || (tagObj instanceof DefineMorphShape2Tag)) {
new PlaceObject2Tag(swf, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
} else if ((treeItem instanceof DefineMorphShapeTag) || (treeItem instanceof DefineMorphShape2Tag)) {
new PlaceObject2Tag(swf, false, 1, chtId, mat, null, 0, null, -1, null).writeTag(sos2);
new ShowFrameTag(swf).writeTag(sos2);
for (int ratio = 0; ratio < 65536; ratio += 65536 / frameCount) {
new PlaceObject2Tag(swf, false, false, false, true, false, true, false, true, 1, chtId, mat, null, ratio, null, 0, null).writeTag(sos2);
new PlaceObject2Tag(swf, true, 1, chtId, mat, null, ratio, null, -1, null).writeTag(sos2);
new ShowFrameTag(swf).writeTag(sos2);
}
} else if (tagObj instanceof SoundStreamHeadTypeTag) {
} else if (treeItem instanceof SoundStreamHeadTypeTag) {
for (SoundStreamBlockTag blk : soundFrames) {
blk.writeTag(sos2);
new ShowFrameTag(swf).writeTag(sos2);
}
} else if (tagObj instanceof DefineSoundTag) {
} else if (treeItem instanceof DefineSoundTag) {
ExportAssetsTag ea = new ExportAssetsTag(swf);
DefineSoundTag ds = (DefineSoundTag) tagObj;
DefineSoundTag ds = (DefineSoundTag) treeItem;
ea.tags.add(ds.soundId);
ea.names.add("my_define_sound");
ea.writeTag(sos2);
@@ -999,9 +1004,9 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
new ShowFrameTag(swf).writeTag(sos2);
new ShowFrameTag(swf).writeTag(sos2);
} else if (tagObj instanceof DefineVideoStreamTag) {
} else if (treeItem instanceof DefineVideoStreamTag) {
new PlaceObject2Tag(swf, false, false, false, false, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
new PlaceObject2Tag(swf, false, 1, chtId, mat, null, -1, null, -1, null).writeTag(sos2);
List<VideoFrameTag> frs = new ArrayList<>(videoFrames.values());
Collections.sort(frs, new Comparator<VideoFrameTag>() {
@Override
@@ -1014,14 +1019,14 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
for (VideoFrameTag f : frs) {
if (!first) {
ratio++;
new PlaceObject2Tag(swf, false, false, false, true, false, false, false, true, 1, 0, null, null, ratio, null, 0, null).writeTag(sos2);
new PlaceObject2Tag(swf, true, 1, 0, null, null, ratio, null, -1, null).writeTag(sos2);
}
f.writeTag(sos2);
new ShowFrameTag(swf).writeTag(sos2);
first = false;
}
} else if (tagObj instanceof DefineSpriteTag) {
DefineSpriteTag s = (DefineSpriteTag) tagObj;
} else if (treeItem instanceof DefineSpriteTag) {
DefineSpriteTag s = (DefineSpriteTag) treeItem;
Tag lastTag = null;
for (Tag t : s.subTags) {
if (t instanceof EndTag) {
@@ -1041,7 +1046,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
new ShowFrameTag(swf).writeTag(sos2);
}
} else {
new PlaceObject2Tag(swf, false, false, false, true, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);
new PlaceObject2Tag(swf, false, 1, chtId, mat, null, 0, null, -1, null).writeTag(sos2);
new ShowFrameTag(swf).writeTag(sos2);
}