mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 14:00:45 +00:00
Issue #282: FLA export to CS5, CS5.5 and CC format.
This commit is contained in:
@@ -143,7 +143,7 @@ public class XFLConverter {
|
||||
public static final int KEY_MODE_SHAPE_TWEEN = 17922;
|
||||
public static final int KEY_MODE_MOTION_TWEEN = 8195;
|
||||
public static final int KEY_MODE_SHAPE_LAYERS = 8192;
|
||||
|
||||
|
||||
private XFLConverter() {
|
||||
}
|
||||
|
||||
@@ -971,7 +971,7 @@ public class XFLConverter {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String convertSymbolInstance(String name, MATRIX matrix, CXFORM colorTransform, CXFORMWITHALPHA colorTransformAlpha, boolean cacheAsBitmap, int blendMode, List<FILTER> filters, boolean isVisible, RGBA backgroundColor, CLIPACTIONS clipActions, CharacterTag tag, HashMap<Integer, CharacterTag> characters, List<Tag> tags) {
|
||||
public static String convertSymbolInstance(String name, MATRIX matrix, CXFORM colorTransform, CXFORMWITHALPHA colorTransformAlpha, boolean cacheAsBitmap, int blendMode, List<FILTER> filters, boolean isVisible, RGBA backgroundColor, CLIPACTIONS clipActions, CharacterTag tag, HashMap<Integer, CharacterTag> characters, List<Tag> tags, FLAVersion flaVersion) {
|
||||
String ret = "";
|
||||
if (matrix == null) {
|
||||
matrix = new MATRIX();
|
||||
@@ -1013,7 +1013,7 @@ public class XFLConverter {
|
||||
if (cacheAsBitmap) {
|
||||
ret += " cacheAsBitmap=\"true\"";
|
||||
}
|
||||
if (!isVisible) {
|
||||
if (!isVisible && flaVersion.ordinal()>=FLAVersion.CS5_5.ordinal()) {
|
||||
ret += " isVisible=\"false\"";
|
||||
}
|
||||
ret += ">";
|
||||
@@ -1107,7 +1107,7 @@ public class XFLConverter {
|
||||
return new Date().getTime() / 1000;
|
||||
}
|
||||
|
||||
public static String convertLibrary(SWF swf, Map<Integer, String> characterVariables, Map<Integer, String> characterClasses, List<Integer> oneInstanceShapes, String backgroundColor, List<Tag> tags, HashMap<Integer, CharacterTag> characters, HashMap<String, byte[]> files, HashMap<String, byte[]> datfiles) {
|
||||
public static String convertLibrary(SWF swf, Map<Integer, String> characterVariables, Map<Integer, String> characterClasses, List<Integer> oneInstanceShapes, String backgroundColor, List<Tag> tags, HashMap<Integer, CharacterTag> characters, HashMap<String, byte[]> files, HashMap<String, byte[]> datfiles,FLAVersion flaVersion) {
|
||||
|
||||
//TODO: Imported assets
|
||||
//linkageImportForRS="true" linkageIdentifier="xxx" linkageURL="yyy.swf"
|
||||
@@ -1211,7 +1211,7 @@ public class XFLConverter {
|
||||
} else if (character instanceof DefineVideoStreamTag) {
|
||||
recCharStr = convertVideoInstance(null, matrix, (DefineVideoStreamTag) character, null);
|
||||
} else {
|
||||
recCharStr = convertSymbolInstance(null, matrix, null, colorTransformAlpha, false, blendMode, filters, true, null, null, characters.get(rec.characterId), characters, tags);
|
||||
recCharStr = convertSymbolInstance(null, matrix, null, colorTransformAlpha, false, blendMode, filters, true, null, null, characters.get(rec.characterId), characters, tags,flaVersion);
|
||||
}
|
||||
int duration = frame - lastFrame;
|
||||
lastFrame = frame;
|
||||
@@ -1248,7 +1248,7 @@ public class XFLConverter {
|
||||
if (sprite.subTags.isEmpty()) { //probably AS2 class
|
||||
continue;
|
||||
}
|
||||
symbolStr += convertTimeline(sprite.spriteId, oneInstanceShapes, backgroundColor, tags, sprite.getSubTags(), characters, "Symbol " + symbol.getCharacterId());
|
||||
symbolStr += convertTimeline(sprite.spriteId, oneInstanceShapes, backgroundColor, tags, sprite.getSubTags(), characters, "Symbol " + symbol.getCharacterId(),flaVersion);
|
||||
} else if (symbol instanceof ShapeTag) {
|
||||
itemIcon = "1";
|
||||
ShapeTag shape = (ShapeTag) symbol;
|
||||
@@ -1268,7 +1268,12 @@ public class XFLConverter {
|
||||
if (itemIcon != null) {
|
||||
symbLinkStr += " itemIcon=\"" + itemIcon + "\"";
|
||||
}
|
||||
symbLinkStr += " loadImmediate=\"false\" lastModified=\"" + getTimestamp() + "\"/>"; //TODO: itemID=\"518de416-00000341\"
|
||||
symbLinkStr += " loadImmediate=\"false\"";
|
||||
if(flaVersion.ordinal()>=FLAVersion.CS5_5.ordinal()) {
|
||||
symbLinkStr += " lastModified=\"" + getTimestamp() + "\"";
|
||||
//TODO: itemID=\"518de416-00000341\"
|
||||
}
|
||||
symbLinkStr += "/>";
|
||||
symbols.add(symbLinkStr);
|
||||
} else if (symbol instanceof ImageTag) {
|
||||
ImageTag imageTag = (ImageTag) symbol;
|
||||
@@ -1584,7 +1589,7 @@ public class XFLConverter {
|
||||
ret += " keyMode=\"" + KEY_MODE_NORMAL + "\"";
|
||||
}
|
||||
String soundEnvelopeStr = "";
|
||||
if (soundStreamHead != null) {
|
||||
if (soundStreamHead != null && startSound == null) {
|
||||
ret += " soundName=\"sound" + soundStreamHead.getCharacterId() + "." + soundStreamHead.getExportFormat() + "\"";
|
||||
ret += " soundSync=\"stream\"";
|
||||
soundEnvelopeStr += "<SoundEnvelope>";
|
||||
@@ -1684,7 +1689,7 @@ public class XFLConverter {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static String convertFrames(String prevStr, String afterStr, List<Integer> oneInstanceShapes, List<Tag> tags, List<Tag> timelineTags, HashMap<Integer, CharacterTag> characters, int depth) {
|
||||
private static String convertFrames(String prevStr, String afterStr, List<Integer> oneInstanceShapes, List<Tag> tags, List<Tag> timelineTags, HashMap<Integer, CharacterTag> characters, int depth, FLAVersion flaVersion) {
|
||||
String ret = "";
|
||||
prevStr += "<frames>";
|
||||
int frame = -1;
|
||||
@@ -1815,7 +1820,7 @@ public class XFLConverter {
|
||||
} else if (character instanceof DefineVideoStreamTag) {
|
||||
elements += convertVideoInstance(instanceName, matrix, (DefineVideoStreamTag) character, clipActions);
|
||||
} else {
|
||||
elements += convertSymbolInstance(instanceName, matrix, colorTransForm, colorTransFormAlpha, cacheAsBitmap, blendMode, filters, isVisible, backGroundColor, clipActions, character, characters, tags);
|
||||
elements += convertSymbolInstance(instanceName, matrix, colorTransForm, colorTransFormAlpha, cacheAsBitmap, blendMode, filters, isVisible, backGroundColor, clipActions, character, characters, tags,flaVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2018,7 +2023,7 @@ public class XFLConverter {
|
||||
return outlineColor.toHexRGB();
|
||||
}
|
||||
|
||||
public static String convertTimeline(int spriteId, List<Integer> oneInstanceShapes, String backgroundColor, List<Tag> tags, List<Tag> timelineTags, HashMap<Integer, CharacterTag> characters, String name) {
|
||||
public static String convertTimeline(int spriteId, List<Integer> oneInstanceShapes, String backgroundColor, List<Tag> tags, List<Tag> timelineTags, HashMap<Integer, CharacterTag> characters, String name, FLAVersion flaVersion) {
|
||||
String ret = "";
|
||||
ret += "<DOMTimeline name=\"" + name + "\">";
|
||||
ret += "<layers>";
|
||||
@@ -2041,7 +2046,7 @@ public class XFLConverter {
|
||||
ret += "<DOMLayer name=\"Layer " + (index + 1) + "\" color=\"" + randomOutlineColor() + "\" ";
|
||||
ret += " layerType=\"mask\" locked=\"true\"";
|
||||
ret += ">";
|
||||
ret += convertFrames("", "", oneInstanceShapes, tags, timelineTags, characters, po.getDepth());
|
||||
ret += convertFrames("", "", oneInstanceShapes, tags, timelineTags, characters, po.getDepth(),flaVersion);
|
||||
ret += "</DOMLayer>";
|
||||
index++;
|
||||
break;
|
||||
@@ -2082,7 +2087,7 @@ public class XFLConverter {
|
||||
}
|
||||
layerPrev += ">";
|
||||
String layerAfter = "</DOMLayer>";
|
||||
String cf = convertFrames(layerPrev, layerAfter, oneInstanceShapes, tags, timelineTags, characters, d);
|
||||
String cf = convertFrames(layerPrev, layerAfter, oneInstanceShapes, tags, timelineTags, characters, d,flaVersion);
|
||||
if (cf.isEmpty()) {
|
||||
index--;
|
||||
}
|
||||
@@ -2486,7 +2491,25 @@ public class XFLConverter {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void convertSWF(AbortRetryIgnoreHandler handler, SWF swf, String swfFileName, String outfile, boolean compressed, String generator, String generatorVerName, String generatorVersion, boolean parallel) throws IOException {
|
||||
public static void convertSWF(AbortRetryIgnoreHandler handler, SWF swf, String swfFileName, String outfile, boolean compressed, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion flaVersion) throws IOException {
|
||||
|
||||
FileAttributesTag fa = null;
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FileAttributesTag) {
|
||||
fa = (FileAttributesTag) t;
|
||||
}
|
||||
}
|
||||
|
||||
boolean useAS3 = false;
|
||||
boolean useNetwork = false;
|
||||
if (fa != null) {
|
||||
useAS3 = fa.actionScript3;
|
||||
useNetwork = fa.useNetwork;
|
||||
}
|
||||
|
||||
if(!useAS3 && flaVersion.minASVersion()>2){
|
||||
throw new IllegalArgumentException("FLA version "+flaVersion+" does not support AS1/2");
|
||||
}
|
||||
File file = new File(outfile);
|
||||
File outDir = file.getParentFile();
|
||||
if (!outDir.exists()) {
|
||||
@@ -2510,19 +2533,7 @@ public class XFLConverter {
|
||||
Map<Integer, String> characterClasses = getCharacterClasses(swf.tags);
|
||||
Map<Integer, String> characterVariables = getCharacterVariables(swf.tags);
|
||||
|
||||
FileAttributesTag fa = null;
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FileAttributesTag) {
|
||||
fa = (FileAttributesTag) t;
|
||||
}
|
||||
}
|
||||
|
||||
boolean useAS3 = false;
|
||||
boolean useNetwork = false;
|
||||
if (fa != null) {
|
||||
useAS3 = fa.actionScript3;
|
||||
useNetwork = fa.useNetwork;
|
||||
}
|
||||
|
||||
String backgroundColor = "#ffffff";
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof SetBackgroundColorTag) {
|
||||
@@ -2530,7 +2541,7 @@ public class XFLConverter {
|
||||
backgroundColor = sbc.backgroundColor.toHexRGB();
|
||||
}
|
||||
}
|
||||
domDocument += "<DOMDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://ns.adobe.com/xfl/2008/\" currentTimeline=\"1\" xflVersion=\"2.2\" creatorInfo=\"" + generator + "\" platform=\"Windows\" versionInfo=\"Saved by " + generatorVerName + "\" majorVersion=\"" + generatorVersion + "\" buildNumber=\"\" nextSceneIdentifier=\"2\" playOptionsPlayLoop=\"false\" playOptionsPlayPages=\"false\" playOptionsPlayFrameActions=\"false\" autoSaveHasPrompted=\"true\"";
|
||||
domDocument += "<DOMDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://ns.adobe.com/xfl/2008/\" currentTimeline=\"1\" xflVersion=\""+flaVersion.xflVersion()+"\" creatorInfo=\"" + generator + "\" platform=\"Windows\" versionInfo=\"Saved by " + generatorVerName + "\" majorVersion=\"" + generatorVersion + "\" buildNumber=\"\" nextSceneIdentifier=\"2\" playOptionsPlayLoop=\"false\" playOptionsPlayPages=\"false\" playOptionsPlayFrameActions=\"false\" autoSaveHasPrompted=\"true\"";
|
||||
domDocument += " backgroundColor=\"" + backgroundColor + "\"";
|
||||
domDocument += " frameRate=\"" + swf.frameRate + "\"";
|
||||
|
||||
@@ -2544,9 +2555,9 @@ public class XFLConverter {
|
||||
}
|
||||
domDocument += ">";
|
||||
|
||||
domDocument += convertLibrary(swf, characterVariables, characterClasses, oneInstaceShapes, backgroundColor, swf.tags, characters, files, datfiles);
|
||||
domDocument += convertLibrary(swf, characterVariables, characterClasses, oneInstaceShapes, backgroundColor, swf.tags, characters, files, datfiles,flaVersion);
|
||||
domDocument += "<timelines>";
|
||||
domDocument += convertTimeline(0, oneInstaceShapes, backgroundColor, swf.tags, swf.tags, characters, "Scene 1");
|
||||
domDocument += convertTimeline(0, oneInstaceShapes, backgroundColor, swf.tags, swf.tags, characters, "Scene 1",flaVersion);
|
||||
domDocument += "</timelines>";
|
||||
domDocument += "</DOMDocument>";
|
||||
domDocument = prettyFormatXML(domDocument);
|
||||
@@ -2586,6 +2597,7 @@ public class XFLConverter {
|
||||
}
|
||||
}
|
||||
|
||||
int flaSwfVersion = swf.version>flaVersion.maxSwfVersion()?flaVersion.maxSwfVersion():swf.version;
|
||||
String publishSettings = "<flash_profiles>\n"
|
||||
+ "<flash_profile version=\"1.0\" name=\"Default\" current=\"true\">\n"
|
||||
+ " <PublishFormatProperties enabled=\"true\">\n"
|
||||
@@ -2597,7 +2609,7 @@ public class XFLConverter {
|
||||
+ " <gif>0</gif>\n"
|
||||
+ " <jpeg>0</jpeg>\n"
|
||||
+ " <png>0</png>\n"
|
||||
+ " <qt>0</qt>\n"
|
||||
+ (flaVersion.ordinal()>=FLAVersion.CC.ordinal()?" <svg>0</svg>\n":" <qt>0</qt>\n")
|
||||
+ " <rnwk>0</rnwk>\n"
|
||||
+ " <swc>0</swc>\n"
|
||||
+ " <flashDefaultName>1</flashDefaultName>\n"
|
||||
@@ -2607,7 +2619,7 @@ public class XFLConverter {
|
||||
+ " <gifDefaultName>1</gifDefaultName>\n"
|
||||
+ " <jpegDefaultName>1</jpegDefaultName>\n"
|
||||
+ " <pngDefaultName>1</pngDefaultName>\n"
|
||||
+ " <qtDefaultName>1</qtDefaultName>\n"
|
||||
+ (flaVersion.ordinal()>=FLAVersion.CC.ordinal()?" <svgDefaultName>1</svgDefaultName>\n":" <qtDefaultName>1</qtDefaultName>\n")
|
||||
+ " <rnwkDefaultName>1</rnwkDefaultName>\n"
|
||||
+ " <swcDefaultName>1</swcDefaultName>\n"
|
||||
+ " <flashFileName>" + baseName + ".swf</flashFileName>\n"
|
||||
@@ -2617,7 +2629,7 @@ public class XFLConverter {
|
||||
+ " <gifFileName>" + baseName + ".gif</gifFileName>\n"
|
||||
+ " <jpegFileName>" + baseName + ".jpg</jpegFileName>\n"
|
||||
+ " <pngFileName>" + baseName + ".png</pngFileName>\n"
|
||||
+ " <qtFileName>" + baseName + ".mov</qtFileName>\n"
|
||||
+ (flaVersion.ordinal()>=FLAVersion.CC.ordinal()?" <svgFileName>1</svgFileName>\n":" <qtFileName>1</qtFileName>\n")
|
||||
+ " <rnwkFileName>" + baseName + ".smil</rnwkFileName>\n"
|
||||
+ " <swcFileName>" + baseName + ".swc</swcFileName>\n"
|
||||
+ " </PublishFormatProperties>\n"
|
||||
@@ -2660,8 +2672,8 @@ public class XFLConverter {
|
||||
+ " <EventFormat>0</EventFormat>\n"
|
||||
+ " <EventCompress>7</EventCompress>\n"
|
||||
+ " <OverrideSounds>0</OverrideSounds>\n"
|
||||
+ " <Version>15</Version>\n"
|
||||
+ " <ExternalPlayer>FlashPlayer11.2</ExternalPlayer>\n"
|
||||
+ " <Version>"+flaSwfVersion+"</Version>\n"
|
||||
+ " <ExternalPlayer>"+FLAVersion.swfVersionToPlayer(flaSwfVersion)+"</ExternalPlayer>\n"
|
||||
+ " <ActionScriptVersion>" + (useAS3 ? "3" : "2") + "</ActionScriptVersion>\n"
|
||||
+ " <PackageExportFrame>1</PackageExportFrame>\n"
|
||||
+ " <PackagePaths></PackagePaths>\n"
|
||||
@@ -2691,7 +2703,27 @@ public class XFLConverter {
|
||||
+ " <DefaultLibraryLinkage>rsl</DefaultLibraryLinkage>\n"
|
||||
+ " <RSLPreloaderMethod>wrap</RSLPreloaderMethod>\n"
|
||||
+ " <RSLPreloaderSWF>$(AppConfig)/ActionScript 3.0/rsls/loader_animation.swf</RSLPreloaderSWF>\n"
|
||||
+ " <LibraryPath>\n"
|
||||
+ ((flaVersion.ordinal()>=FLAVersion.CC.ordinal())?(
|
||||
" <LibraryPath>\n"
|
||||
+ " <library-path-entry>\n"
|
||||
+ " <swc-path>$(AppConfig)/ActionScript 3.0/libs</swc-path>\n"
|
||||
+ " <linkage>merge</linkage>\n"
|
||||
+ " </library-path-entry>\n"
|
||||
+ " <library-path-entry>\n"
|
||||
+ " <swc-path>$(FlexSDK)/frameworks/libs/flex.swc</swc-path>\n"
|
||||
+ " <linkage>merge</linkage>\n"
|
||||
+ " <rsl-url>textLayout_2.0.0.232.swz</rsl-url>\n"
|
||||
+ " </library-path-entry>\n"
|
||||
+ " <library-path-entry>\n"
|
||||
+ " <swc-path>$(FlexSDK)/frameworks/libs/core.swc</swc-path>\n"
|
||||
+ " <linkage>merge</linkage>\n"
|
||||
+ " <rsl-url>textLayout_2.0.0.232.swz</rsl-url>\n"
|
||||
+ " </library-path-entry>\n"
|
||||
+ " </LibraryPath>\n"
|
||||
+ " <LibraryVersions>\n"
|
||||
+ " </LibraryVersions> "):
|
||||
|
||||
" <LibraryPath>\n"
|
||||
+ " <library-path-entry>\n"
|
||||
+ " <swc-path>$(AppConfig)/ActionScript 3.0/libs</swc-path>\n"
|
||||
+ " <linkage>merge</linkage>\n"
|
||||
@@ -2712,7 +2744,9 @@ public class XFLConverter {
|
||||
+ " <policy-file-url>http://fpdownload.adobe.com/pub/swz/crossdomain.xml</policy-file-url>\n"
|
||||
+ " <rsl-url>textLayout_2.0.0.232.swz</rsl-url>\n"
|
||||
+ " </library-version>\n"
|
||||
+ " </LibraryVersions>\n"
|
||||
+ " </LibraryVersions>\n")
|
||||
|
||||
|
||||
+ " </PublishFlashProperties>\n"
|
||||
+ " <PublishJpegProperties enabled=\"true\">\n"
|
||||
+ " <Width>" + width + "</Width>\n"
|
||||
@@ -2776,7 +2810,9 @@ public class XFLConverter {
|
||||
+ " <MaxColors>255</MaxColors>\n"
|
||||
+ " <PaletteName></PaletteName>\n"
|
||||
+ " </PublishPNGProperties>\n"
|
||||
+ " <PublishQTProperties enabled=\"true\">\n"
|
||||
|
||||
+ ((flaVersion.ordinal()>=FLAVersion.CC.ordinal())?"":
|
||||
(" <PublishQTProperties enabled=\"true\">\n"
|
||||
+ " <Width>" + width + "</Width>\n"
|
||||
+ " <Height>" + height + "</Height>\n"
|
||||
+ " <MatchMovieDim>1</MatchMovieDim>\n"
|
||||
@@ -2789,7 +2825,7 @@ public class XFLConverter {
|
||||
+ " <PausedAtStart>0</PausedAtStart>\n"
|
||||
+ " <PlayEveryFrame>0</PlayEveryFrame>\n"
|
||||
+ " <Flatten>1</Flatten>\n"
|
||||
+ " </PublishQTProperties>\n"
|
||||
+ " </PublishQTProperties>\n"))
|
||||
+ "</flash_profile>\n"
|
||||
+ "</flash_profiles>";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user