mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-24 08:54:50 +00:00
Changed: Export to FlashDevelop and IntelliJ IDEA is available only for SWFs without main timeline
This commit is contained in:
@@ -24,7 +24,14 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import static com.jpexs.decompiler.flash.exporters.swf.SwfIntelliJIdeaExporter.canExportSwf;
|
||||
import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag;
|
||||
import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag;
|
||||
import com.jpexs.decompiler.flash.tags.StartSound2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.StartSoundTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -37,6 +44,25 @@ import java.io.IOException;
|
||||
*/
|
||||
public class SwfFlashDevelopExporter {
|
||||
|
||||
public static boolean canExportSwf(SWF swf) {
|
||||
if (!swf.isAS3()) {
|
||||
return false;
|
||||
}
|
||||
//Cannot export if it has something on main timeline
|
||||
for (Tag t : swf.getTags()) {
|
||||
if (
|
||||
(t instanceof PlaceObjectTypeTag)
|
||||
|| (t instanceof SoundStreamBlockTag)
|
||||
|| (t instanceof VideoFrameTag)
|
||||
|| (t instanceof StartSoundTag)
|
||||
|| (t instanceof StartSound2Tag)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String doubleToString(double d) {
|
||||
String ds = "" + d;
|
||||
if (ds.endsWith(".0")) {
|
||||
@@ -68,6 +94,10 @@ public class SwfFlashDevelopExporter {
|
||||
if (!swf.isAS3()) {
|
||||
throw new IllegalArgumentException("SWF must be AS3");
|
||||
}
|
||||
|
||||
if (!canExportSwf(swf)) {
|
||||
throw new IllegalArgumentException("SWF must not contain main timeline");
|
||||
}
|
||||
|
||||
String simpleName = outFile.getName();
|
||||
if (simpleName.contains(".")) {
|
||||
|
||||
@@ -23,6 +23,12 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag;
|
||||
import com.jpexs.decompiler.flash.tags.StartSound2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.StartSoundTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -52,14 +58,26 @@ public class SwfIntelliJIdeaExporter {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String doubleToString(double d) {
|
||||
String ds = "" + d;
|
||||
if (ds.endsWith(".0")) {
|
||||
ds = ds.substring(0, ds.length() - 2);
|
||||
public static boolean canExportSwf(SWF swf) {
|
||||
if (!swf.isAS3()) {
|
||||
return false;
|
||||
}
|
||||
return ds;
|
||||
|
||||
//Cannot export if it has something on main timeline
|
||||
for (Tag t : swf.getTags()) {
|
||||
if (
|
||||
(t instanceof PlaceObjectTypeTag)
|
||||
|| (t instanceof SoundStreamBlockTag)
|
||||
|| (t instanceof VideoFrameTag)
|
||||
|| (t instanceof StartSoundTag)
|
||||
|| (t instanceof StartSound2Tag)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exports SWF to IntelliJ IDEA project.
|
||||
* @param swf SWF to export
|
||||
@@ -83,6 +101,10 @@ public class SwfIntelliJIdeaExporter {
|
||||
if (!swf.isAS3()) {
|
||||
throw new IllegalArgumentException("SWF must be AS3");
|
||||
}
|
||||
|
||||
if (!canExportSwf(swf)) {
|
||||
throw new IllegalArgumentException("SWF must not contain main timeline");
|
||||
}
|
||||
|
||||
if (!outDir.exists()) {
|
||||
if (!outDir.mkdirs()) {
|
||||
|
||||
Reference in New Issue
Block a user