FLA export stub

This commit is contained in:
Jindra Petk
2013-05-14 22:02:41 +02:00
parent fa994055e5
commit 137b14a9c2
24 changed files with 1814 additions and 19 deletions

View File

@@ -514,8 +514,13 @@ public class Main {
if (!exportFormat.toLowerCase().equals("text")) {
if (!exportFormat.toLowerCase().equals("textplain")) {
if (!exportFormat.toLowerCase().equals("all")) {
System.err.println("Invalid export format:" + exportFormat);
badArguments();
if (!exportFormat.toLowerCase().equals("fla")) {
if (!exportFormat.toLowerCase().equals("xfl")) {
System.err.println("Invalid export format:" + exportFormat);
badArguments();
}
}
}
}
@@ -593,6 +598,12 @@ public class Main {
} else if (exportFormat.equals("textplain")) {
exfile.exportTexts(outDir.getAbsolutePath(), false);
exportOK = true;
} else if (exportFormat.equals("fla")) {
exfile.exportFla(outDir.getAbsolutePath(), inFile.getName());
exportOK = true;
} else if (exportFormat.equals("xfl")) {
exfile.exportXfl(outDir.getAbsolutePath(), inFile.getName());
exportOK = true;
} else {
exportOK = false;
}

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash;
import SevenZip.Compression.LZMA.Encoder;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionGraphSource;
import com.jpexs.decompiler.flash.action.swf4.ActionEquals;
@@ -75,6 +74,7 @@ import com.jpexs.decompiler.flash.tags.base.ImageTag;
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.xfl.XFLConverter;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
@@ -1147,4 +1147,12 @@ public class SWF {
}
return ret;
}
public void exportFla(String outfile, String swfName) {
XFLConverter.convertSWF(this, swfName, outfile, true);
}
public void exportXfl(String outfile, String swfName) {
XFLConverter.convertSWF(this, swfName, outfile, false);
}
}

View File

@@ -16,7 +16,6 @@
*/
package com.jpexs.decompiler.flash.abc;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;

View File

@@ -16,11 +16,9 @@
*/
package com.jpexs.decompiler.flash.abc.gui;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.Main;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;

View File

@@ -16,8 +16,8 @@
*/
package com.jpexs.decompiler.flash.abc.gui;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;

View File

@@ -20,12 +20,12 @@ import com.jpexs.decompiler.flash.Configuration;
import com.jpexs.decompiler.flash.Main;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.gui.ABCPanel;
import com.jpexs.decompiler.flash.abc.gui.ClassesListTreeModel;
import com.jpexs.decompiler.flash.abc.gui.DeobfuscationDialog;
import com.jpexs.decompiler.flash.abc.gui.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.abc.gui.TreeElement;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.TraitClass;
import com.jpexs.decompiler.flash.action.gui.ActionPanel;

View File

@@ -43,8 +43,8 @@ import javax.swing.UIManager;
*/
public class NewVersionDialog extends JDialog implements ActionListener {
Version latestVersion;
Version latestVersion;
public NewVersionDialog(List<Version> versions) {
setSize(new Dimension(500, 300));
Container cnt = getContentPane();
@@ -104,9 +104,9 @@ public class NewVersionDialog extends JDialog implements ActionListener {
this.getRootPane().setDefaultButton(buttonOk);
View.centerScreen(this);
setModalityType(ModalityType.APPLICATION_MODAL);
changesText.setCaretPosition(0);
changesText.setCaretPosition(0);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("OK")) {

View File

@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.types.BUTTONCONDACTION;
@@ -44,7 +45,7 @@ import java.util.logging.Logger;
*
* @author JPEXS
*/
public class DefineButton2Tag extends CharacterTag implements Container, BoundedTag {
public class DefineButton2Tag extends CharacterTag implements Container, BoundedTag, ButtonTag {
/**
* ID for this character
@@ -68,6 +69,11 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
return buttonId;
}
@Override
public List<BUTTONRECORD> getRecords() {
return characters;
}
/**
* Constructor
*

View File

@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.types.BUTTONRECORD;
import com.jpexs.decompiler.flash.types.RECT;
@@ -46,7 +47,7 @@ import java.util.logging.Logger;
*
* @author JPEXS
*/
public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedTag {
public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedTag, ButtonTag {
/**
* ID for this character
@@ -68,6 +69,11 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
}
private long hdrSize;
@Override
public List<BUTTONRECORD> getRecords() {
return characters;
}
/**
* Constructor
*

View File

@@ -33,6 +33,16 @@ public class DefineShape2Tag extends CharacterTag implements BoundedTag, ShapeTa
public RECT shapeBounds;
public SHAPEWITHSTYLE shapes;
@Override
public int getShapeNum() {
return 2;
}
@Override
public SHAPEWITHSTYLE getShapes() {
return shapes;
}
@Override
public Set<Integer> getNeededCharacters() {
return shapes.getNeededCharacters();

View File

@@ -33,6 +33,16 @@ public class DefineShape3Tag extends CharacterTag implements BoundedTag, ShapeTa
public RECT shapeBounds;
public SHAPEWITHSTYLE shapes;
@Override
public int getShapeNum() {
return 3;
}
@Override
public SHAPEWITHSTYLE getShapes() {
return shapes;
}
@Override
public Set<Integer> getNeededCharacters() {
return shapes.getNeededCharacters();

View File

@@ -37,6 +37,16 @@ public class DefineShape4Tag extends CharacterTag implements BoundedTag, ShapeTa
public boolean usesScalingStrokes;
public SHAPEWITHSTYLE shapes;
@Override
public int getShapeNum() {
return 4;
}
@Override
public SHAPEWITHSTYLE getShapes() {
return shapes;
}
@Override
public Set<Integer> getNeededCharacters() {
return shapes.getNeededCharacters();

View File

@@ -33,6 +33,16 @@ public class DefineShapeTag extends CharacterTag implements BoundedTag, ShapeTag
public RECT shapeBounds;
public SHAPEWITHSTYLE shapes;
@Override
public int getShapeNum() {
return 1;
}
@Override
public SHAPEWITHSTYLE getShapes() {
return shapes;
}
@Override
public Set<Integer> getNeededCharacters() {
return shapes.getNeededCharacters();

View File

@@ -22,8 +22,10 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.tags.base.Container;
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.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -105,6 +107,19 @@ public class PlaceObject2Tag extends Tag implements Container, PlaceObjectTypeTa
*/
public CLIPACTIONS clipActions;
@Override
public int getClipDepth() {
if (placeFlagHasClipDepth) {
return clipDepth;
}
return -1;
}
@Override
public List<FILTER> getFilters() {
return new ArrayList<FILTER>();
}
/**
* Gets data bytes
*
@@ -279,4 +294,31 @@ public class PlaceObject2Tag extends Tag implements Container, PlaceObjectTypeTa
return null;
}
}
@Override
public String getName() {
if (placeFlagHasName) {
return name;
}
return null;
}
@Override
public CXFORM getColorTransform() {
return null;
}
@Override
public CXFORMWITHALPHA getColorTransformWithAlpha() {
if (placeFlagHasColorTransform) {
return colorTransform;
} else {
return null;
}
}
@Override
public int getBlendMode() {
return 0;
}
}

View File

@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
import com.jpexs.decompiler.flash.tags.base.Container;
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;
@@ -148,6 +149,23 @@ public class PlaceObject3Tag extends Tag implements Container, PlaceObjectTypeTa
// FIXME bug found in ecoDrive.swf,
private boolean bitmapCacheBug;
@Override
public List<FILTER> getFilters() {
if (placeFlagHasFilterList) {
return surfaceFilterList;
} else {
return new ArrayList<FILTER>();
}
}
@Override
public int getClipDepth() {
if (placeFlagHasClipDepth) {
return clipDepth;
}
return -1;
}
/**
* Gets data bytes
*
@@ -181,7 +199,7 @@ public class PlaceObject3Tag extends Tag implements Container, PlaceObjectTypeTa
sos.writeUB(1, placeFlagHasBlendMode ? 1 : 0);
sos.writeUB(1, placeFlagHasFilterList ? 1 : 0);
sos.writeUI16(depth);
if (placeFlagHasClassName || (placeFlagHasImage && placeFlagHasCharacter)) {
if (placeFlagHasClassName) {
sos.writeString(className);
}
if (placeFlagHasCharacter) {
@@ -248,7 +266,7 @@ public class PlaceObject3Tag extends Tag implements Container, PlaceObjectTypeTa
placeFlagHasFilterList = sis.readUB(1) == 1;
depth = sis.readUI16();
if (placeFlagHasClassName || (placeFlagHasImage && placeFlagHasCharacter)) {
if (placeFlagHasClassName) {
className = sis.readString();
}
if (placeFlagHasCharacter) {
@@ -347,4 +365,31 @@ public class PlaceObject3Tag extends Tag implements Container, PlaceObjectTypeTa
return null;
}
}
@Override
public String getName() {
if (placeFlagHasName) {
return name;
}
return null;
}
@Override
public CXFORM getColorTransform() {
return null;
}
@Override
public CXFORMWITHALPHA getColorTransformWithAlpha() {
if (placeFlagHasColorTransform) {
return colorTransform;
} else {
return null;
}
}
@Override
public int getBlendMode() {
return blendMode;
}
}

View File

@@ -19,12 +19,16 @@ package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
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.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
@@ -51,6 +55,16 @@ public class PlaceObjectTag extends Tag implements PlaceObjectTypeTag {
*/
public CXFORM colorTransform;
@Override
public List<FILTER> getFilters() {
return new ArrayList<FILTER>();
}
@Override
public int getClipDepth() {
return -1;
}
/**
* Gets data bytes
*
@@ -121,4 +135,24 @@ public class PlaceObjectTag extends Tag implements PlaceObjectTypeTag {
public MATRIX getMatrix() {
return matrix;
}
@Override
public String getName() {
return null;
}
@Override
public CXFORM getColorTransform() {
return colorTransform;
}
@Override
public CXFORMWITHALPHA getColorTransformWithAlpha() {
return null;
}
@Override
public int getBlendMode() {
return 0;
}
}

View File

@@ -1,6 +1,10 @@
package com.jpexs.decompiler.flash.tags;
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.List;
/**
*
@@ -13,4 +17,16 @@ public interface PlaceObjectTypeTag {
public int getDepth();
public MATRIX getMatrix();
public String getName();
public CXFORM getColorTransform();
public CXFORMWITHALPHA getColorTransformWithAlpha();
public int getBlendMode();
public List<FILTER> getFilters();
public int getClipDepth();
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.tags.base;
import com.jpexs.decompiler.flash.types.BUTTONRECORD;
import java.util.List;
/**
*
* @author JPEXS
*/
public interface ButtonTag {
public List<BUTTONRECORD> getRecords();
}

View File

@@ -16,11 +16,17 @@
*/
package com.jpexs.decompiler.flash.tags.base;
import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
/**
*
* @author JPEXS
*/
public interface ShapeTag {
public SHAPEWITHSTYLE getShapes();
public String toSVG();
public int getShapeNum();
}

View File

@@ -25,7 +25,7 @@ public class GRADIENT {
public int spreadMode;
public static final int SPREAD_PAD_MODE = 0;
public static final int SPREAD_REFLECT_MODE = 1;
public static final int SPREAD_REPAT_MODE = 2;
public static final int SPREAD_REPEAT_MODE = 2;
public static final int SPREAD_RESERVED = 3;
public int interPolationMode;
public static final int INTERPOLATION_RGB_MODE = 0;

View File

@@ -26,4 +26,8 @@ public class GRADRECORD {
public boolean inShape3;
public RGB color;
public RGBA colorA;
public float getRatioFloat() {
return ((float) ratio) / 255.0f;
}
}

View File

@@ -68,7 +68,7 @@ public class MATRIX implements Serializable {
return "[MATRIX scale:" + scaleX + "," + scaleY + ", rotate:" + rotateSkew0 + "," + rotateSkew1 + ", translate:" + translateX + "," + translateY + "]";
}
private float toFloat(int i) {
public float toFloat(int i) {
return ((float) i) / (1 << 16);
}

View File

@@ -40,6 +40,10 @@ public class RGBA {
*/
public int alpha;
public float getAlphaFloat() {
return ((float) alpha) / 255.0f;
}
public String toHexRGB() {
String rh = Integer.toHexString(red);
if (rh.length() < 2) {

File diff suppressed because it is too large Load Diff