mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-19 13:08:07 +00:00
Import scripts into ABC file
This commit is contained in:
@@ -212,8 +212,8 @@ public class Main {
|
||||
public static final int LIBRARY_AIR = 0;
|
||||
public static final int LIBRARY_FLASH = 1;
|
||||
|
||||
public static boolean isSwfAir(SWF swf) {
|
||||
SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(swf.getShortPathTitle());
|
||||
public static boolean isSwfAir(Openable openable) {
|
||||
SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(openable.getShortPathTitle());
|
||||
if (conf != null) {
|
||||
String libraryAsStr = conf.getCustomData(CustomConfigurationKeys.KEY_LIBRARY, "" + LIBRARY_FLASH);
|
||||
int libraryAsInt = Integer.parseInt(libraryAsStr);
|
||||
|
||||
@@ -290,7 +290,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
return;
|
||||
}
|
||||
|
||||
mainFrame.getPanel().importScript((SWF) openable);
|
||||
mainFrame.getPanel().importScript(openable);
|
||||
}
|
||||
|
||||
protected void importImagesActionPerformed(ActionEvent evt) {
|
||||
@@ -803,16 +803,25 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
boolean swfIsNew = openableSelected && openable.getOpenableList() != null && openable.getOpenableList().sourceInfo.isEmpty();
|
||||
|
||||
boolean allSameSwf = true;
|
||||
boolean allSameOpenable = true;
|
||||
if (mainPanel != null) {
|
||||
List<TreeItem> items = mainPanel.getCurrentTree().getSelected();
|
||||
SWF firstSwf = null;
|
||||
Openable firstOpenable = null;
|
||||
for (TreeItem item : items) {
|
||||
if (item instanceof OpenableList) {
|
||||
allSameSwf = false;
|
||||
break;
|
||||
}
|
||||
if (firstSwf == null) {
|
||||
Openable fopenable = item.getOpenable();
|
||||
Openable fopenable = item.getOpenable();
|
||||
if (firstOpenable == null) {
|
||||
firstOpenable = fopenable;
|
||||
} else {
|
||||
if (fopenable != firstOpenable) {
|
||||
allSameOpenable = false;
|
||||
}
|
||||
}
|
||||
if (firstSwf == null) {
|
||||
if (fopenable instanceof SWF) {
|
||||
firstSwf = (SWF) fopenable;
|
||||
} else {
|
||||
@@ -852,7 +861,7 @@ public abstract class MainFrameMenu implements MenuBuilder {
|
||||
|
||||
setMenuEnabled("/file/import", openableSelected);
|
||||
setMenuEnabled("/file/import/importText", allSameSwf && swfSelected && !isWorking);
|
||||
setMenuEnabled("/file/import/importScript", allSameSwf && swfSelected && !isWorking);
|
||||
setMenuEnabled("/file/import/importScript", allSameOpenable && openableSelected && !isWorking);
|
||||
setMenuEnabled("/file/import/importOther", allSameSwf && swfSelected && !isWorking);
|
||||
setMenuEnabled("/file/import/importXml", allSameSwf && swfSelected && !isWorking);
|
||||
|
||||
|
||||
@@ -3237,14 +3237,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
return r;
|
||||
}
|
||||
|
||||
public void importScript(final SWF swf) {
|
||||
As3ScriptReplacerInterface as3ScriptReplacer = getAs3ScriptReplacer(Main.isSwfAir(swf));
|
||||
public void importScript(final Openable openable) {
|
||||
As3ScriptReplacerInterface as3ScriptReplacer = getAs3ScriptReplacer(Main.isSwfAir(openable));
|
||||
if (as3ScriptReplacer == null) {
|
||||
return;
|
||||
}
|
||||
ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importScripts"), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportScriptsInfo);
|
||||
|
||||
String flexLocation = Configuration.flexSdkLocation.get();
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get()));
|
||||
chooser.setDialogTitle(translate("import.select.directory"));
|
||||
@@ -3260,13 +3259,27 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
|
||||
SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf();
|
||||
|
||||
new AS2ScriptImporter().importScripts(scriptsFolder, swf.getASMs(true), new ScriptImporterProgressListener() {
|
||||
@Override
|
||||
public void scriptImported() {
|
||||
countAs2++;
|
||||
}
|
||||
});
|
||||
new AS3ScriptImporter().importScripts(as3ScriptReplacer, scriptsFolder, swf.getAS3Packs(), new ScriptImporterProgressListener() {
|
||||
|
||||
List<ScriptPack> packs;
|
||||
if (openable instanceof SWF) {
|
||||
packs = swf.getAS3Packs();
|
||||
} else {
|
||||
List<ABC> allAbcs = new ArrayList<>();
|
||||
ABC abc = (ABC) openable;
|
||||
allAbcs.add(abc);
|
||||
packs = abc.getScriptPacks(null, allAbcs);
|
||||
}
|
||||
|
||||
new AS3ScriptImporter().importScripts(as3ScriptReplacer, scriptsFolder, packs, new ScriptImporterProgressListener() {
|
||||
@Override
|
||||
public void scriptImported() {
|
||||
countAs3++;
|
||||
|
||||
@@ -238,7 +238,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
return;
|
||||
}
|
||||
|
||||
if (Main.isSwfAir(abc.getSwf())) {
|
||||
if (Main.isSwfAir(abc.getOpenable())) {
|
||||
libraryComboBox.setSelectedIndex(Main.LIBRARY_AIR);
|
||||
} else {
|
||||
libraryComboBox.setSelectedIndex(Main.LIBRARY_FLASH);
|
||||
@@ -285,6 +285,10 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
public SWF getSwf() {
|
||||
return abc == null ? null : abc.getSwf();
|
||||
}
|
||||
|
||||
public Openable getOpenable() {
|
||||
return abc == null ? null : abc.getOpenable();
|
||||
}
|
||||
|
||||
public List<ABCContainerTag> getAbcList() {
|
||||
SWF swf = getSwf();
|
||||
@@ -1480,7 +1484,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
}
|
||||
|
||||
private void editDecompiledButtonActionPerformed(ActionEvent evt) {
|
||||
scriptReplacer = mainPanel.getAs3ScriptReplacer(Main.isSwfAir(getSwf()));
|
||||
scriptReplacer = mainPanel.getAs3ScriptReplacer(Main.isSwfAir(getOpenable()));
|
||||
if (scriptReplacer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user