allow to create swf from code only / export SWF to "Java code", which generates the SWF

This commit is contained in:
2015-01-17 12:17:03 +01:00
parent 30a3bc1e3e
commit 07eaafdc55
64 changed files with 841 additions and 259 deletions
+28 -28
View File
@@ -29,34 +29,34 @@ import java.util.Map;
*/
public class CacheAddr {
public static final int EXTERNAL = 0;
public static final int RANKINGS = 1;
public static final int BLOCK_256 = 2;
public static final int BLOCK_1K = 3;
public static final int BLOCK_4K = 4;
public static final int BLOCK_FILES = 5;
public static final int BLOCK_ENTRIES = 6;
public static final int BLOCK_EVICTED = 7;
public static final String blockNames[] = new String[]{"EXTERNAL", "RANKINGS", "BLOCK_256", "BLOCK_1K", "BLOCK_4K", "BLOCK_FILES", "BLOCK_ENTRIES", "BLOCK_EVICTED"};
public static final int blockSizes[] = new int[]{0, 36, 256, 1024, 4096, 8, 104, 48};
public static final long kInitializedMask = 0x80000000L;
public static final long kFileTypeMask = 0x70000000L;
public static final int kFileTypeOffset = 28;
public static final long kReservedBitsMask = 0x0c000000L;
public static final long kNumBlocksMask = 0x03000000L;
public static final int kNumBlocksOffset = 24;
public static final long kFileSelectorMask = 0x00ff0000L;
public static final int FileSelectorOffset = 16;
public static final long kStartBlockMask = 0x0000FFFFL;
public static final long kFileNameMask = 0x0FFFFFFFL;
public boolean initialized;
public int fileType;
public int numBlocks;
public int fileSelector;
public int startBlock;
public int fileName;
public long val;
public File rootPath;
private static final int EXTERNAL = 0;
private static final int RANKINGS = 1;
private static final int BLOCK_256 = 2;
private static final int BLOCK_1K = 3;
private static final int BLOCK_4K = 4;
private static final int BLOCK_FILES = 5;
private static final int BLOCK_ENTRIES = 6;
private static final int BLOCK_EVICTED = 7;
private static final String blockNames[] = new String[]{"EXTERNAL", "RANKINGS", "BLOCK_256", "BLOCK_1K", "BLOCK_4K", "BLOCK_FILES", "BLOCK_ENTRIES", "BLOCK_EVICTED"};
private static final int blockSizes[] = new int[]{0, 36, 256, 1024, 4096, 8, 104, 48};
private static final long kInitializedMask = 0x80000000L;
private static final long kFileTypeMask = 0x70000000L;
private static final int kFileTypeOffset = 28;
private static final long kReservedBitsMask = 0x0c000000L;
private static final long kNumBlocksMask = 0x03000000L;
private static final int kNumBlocksOffset = 24;
private static final long kFileSelectorMask = 0x00ff0000L;
private static final int FileSelectorOffset = 16;
private static final long kStartBlockMask = 0x0000FFFFL;
private static final long kFileNameMask = 0x0FFFFFFFL;
private final boolean initialized;
private final int fileType;
private int numBlocks;
private int fileSelector;
private int startBlock;
private int fileName;
private final long val;
private final File rootPath;
private final Map<Integer, RandomAccessFile> dataFiles;
private final File externalFilesDir;
@@ -514,8 +514,8 @@ public class CommandLineArgumentParser {
}
public boolean contains(int index) {
Integer minimum = min == null ? Integer.MIN_VALUE : min;
Integer maximum = max == null ? Integer.MAX_VALUE : max;
int minimum = min == null ? Integer.MIN_VALUE : min;
int maximum = max == null ? Integer.MAX_VALUE : max;
return index >= minimum && index <= maximum;
}
@@ -1216,8 +1216,8 @@ public class CommandLineArgumentParser {
fmts = new String[]{fmtStr};
}
Map<String, String> ret = new HashMap<>();
for (int i = 0; i < fmts.length; i++) {
String parts[] = fmts[i].split(":");
for (String fmt : fmts) {
String[] parts = fmt.split(":");
ret.put(parts[0].toLowerCase(), parts[1].toLowerCase());
}
return ret;
@@ -1327,12 +1327,12 @@ public class CommandLineArgumentParser {
System.err.println("CharacterId should be integer");
System.exit(1);
}
if (!swf.characters.containsKey(characterId)) {
if (!swf.getCharacters().containsKey(characterId)) {
System.err.println("CharacterId does not exist");
System.exit(1);
}
CharacterTag characterTag = swf.characters.get(characterId);
CharacterTag characterTag = swf.getCharacter(characterId);
String repFile = args.remove();
byte[] data = Helper.readFile(repFile);
if (characterTag instanceof DefineBinaryDataTag) {
@@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.RGB;
import com.jpexs.decompiler.flash.types.RGBA;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.flash.types.annotations.Multiline;
import com.jpexs.decompiler.flash.types.annotations.SWFArray;
@@ -828,6 +829,10 @@ public class GenericTagTreePanel extends GenericTagPanel {
if (inter != null) {
continue;
}
HideInRawEdit hide = f.getAnnotation(HideInRawEdit.class);
if (hide != null) {
continue;
}
ret.add(f);
}
return ret;
@@ -263,7 +263,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
ret += ", ";
}
first = false;
CharacterTag c = tim.swf.characters.get(ds.characterId);
CharacterTag c = tim.swf.getCharacter(ds.characterId);
if (c instanceof ButtonTag) {
newStateUnderCursor = ds;
handCursor = true;
@@ -298,7 +298,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
if (selectedDepth > -1 && frame > -1) {
DepthState ds = timelined.getTimeline().getFrames().get(frame).layers.get(selectedDepth);
if (ds != null) {
CharacterTag cht = timelined.getTimeline().swf.characters.get(ds.characterId);
CharacterTag cht = timelined.getTimeline().swf.getCharacter(ds.characterId);
if (cht != null) {
debugLabel.setText(cht.getName());
}
@@ -351,10 +351,10 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
lastMouseEvent = e;
shouldDraw.set(true);
if (stateUnderCursor != null) {
ButtonTag b = (ButtonTag) swf.characters.get(stateUnderCursor.characterId);
ButtonTag b = (ButtonTag) swf.getCharacter(stateUnderCursor.characterId);
DefineButtonSoundTag sounds = b.getSounds();
if (sounds != null && sounds.buttonSoundChar2 != 0) { //OverUpToOverDown
playSound((SoundTag) swf.characters.get(sounds.buttonSoundChar2), counter);
playSound((SoundTag) swf.getCharacter(sounds.buttonSoundChar2), counter);
}
}
}
@@ -367,10 +367,10 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
lastMouseEvent = e;
shouldDraw.set(true);
if (stateUnderCursor != null) {
ButtonTag b = (ButtonTag) swf.characters.get(stateUnderCursor.characterId);
ButtonTag b = (ButtonTag) swf.getCharacter(stateUnderCursor.characterId);
DefineButtonSoundTag sounds = b.getSounds();
if (sounds != null && sounds.buttonSoundChar3 != 0) { //OverDownToOverUp
playSound((SoundTag) swf.characters.get(sounds.buttonSoundChar3), counter);
playSound((SoundTag) swf.getCharacter(sounds.buttonSoundChar3), counter);
}
}
}
@@ -387,20 +387,20 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
if (stateUnderCursor != null) {
if (lastUnderCur == null || lastUnderCur.instanceId != stateUnderCursor.instanceId) {
// New mouse entered
ButtonTag b = (ButtonTag) swf.characters.get(stateUnderCursor.characterId);
ButtonTag b = (ButtonTag) swf.getCharacter(stateUnderCursor.characterId);
DefineButtonSoundTag sounds = b.getSounds();
if (sounds != null && sounds.buttonSoundChar1 != 0) { //IddleToOverUp
playSound((SoundTag) swf.characters.get(sounds.buttonSoundChar1), counter);
playSound((SoundTag) swf.getCharacter(sounds.buttonSoundChar1), counter);
}
}
}
if (lastUnderCur != null) {
if (stateUnderCursor == null || stateUnderCursor.instanceId != lastUnderCur.instanceId) {
// Old mouse leave
ButtonTag b = (ButtonTag) swf.characters.get(lastUnderCur.characterId);
ButtonTag b = (ButtonTag) swf.getCharacter(lastUnderCur.characterId);
DefineButtonSoundTag sounds = b.getSounds();
if (sounds != null && sounds.buttonSoundChar0 != 0) { //OverUpToIddle
playSound((SoundTag) swf.characters.get(sounds.buttonSoundChar0), counter);
playSound((SoundTag) swf.getCharacter(sounds.buttonSoundChar0), counter);
}
}
}
@@ -666,7 +666,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
List<Shape> os = new ArrayList<>();
DepthState ds = drawable.getTimeline().getFrames().get(frame).layers.get(selectedDepth);
if (ds != null) {
CharacterTag cht = swf.characters.get(ds.characterId);
CharacterTag cht = swf.getCharacter(ds.characterId);
if (cht != null) {
if (cht instanceof DrawableTag) {
DrawableTag dt = (DrawableTag) cht;
@@ -746,8 +746,8 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
List<Integer> sounds = new ArrayList<>();
List<String> soundClasses = new ArrayList<>();
timeline.getSounds(frame, time, stateUnderCursor, mouseButton, sounds, soundClasses);
for (int cid : swf.characters.keySet()) {
CharacterTag c = swf.characters.get(cid);
for (int cid : swf.getCharacters().keySet()) {
CharacterTag c = swf.getCharacter(cid);
for (String cls : soundClasses) {
if (cls.equals(c.getClassName())) {
sounds.add(cid);
@@ -756,7 +756,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
}
for (int sndId : sounds) {
CharacterTag c = swf.characters.get(sndId);
CharacterTag c = swf.getCharacter(sndId);
if (c instanceof SoundTag) {
SoundTag st = (SoundTag) c;
playSound(st, counter);
+8 -9
View File
@@ -125,7 +125,7 @@ public class Main {
public static final String DEBUGGER_PACKAGE = "com.jpexs.decompiler.flash.debugger";
private static ABCContainerTag getDebuggerABCTag(SWF swf) {
for (ABCContainerTag ac : swf.abcList) {
for (ABCContainerTag ac : swf.getAbcList()) {
ABC a = ac.getABC();
for (MyEntry<ClassPath, ScriptPack> m : a.getScriptPacks()) {
if (isDebuggerClass(m.getKey().packageStr, null)) {
@@ -308,7 +308,6 @@ public class Main {
}
}, Configuration.parallelSpeedUp.get());
swf.fileTitle = streamEntry.getKey();
swf.readOnly = true;
result.add(swf);
}
} else {
@@ -1177,7 +1176,7 @@ public class Main {
if (hasDebugger(swf)) {
String debuggerPkg = getDebuggerPackage(swf);
//change trace to fname
for (ABCContainerTag ct : swf.abcList) {
for (ABCContainerTag ct : swf.getAbcList()) {
ABC a = ct.getABC();
for (int i = 1; i < a.constants.constant_multiname.size(); i++) {
Multiname m = a.constants.constant_multiname.get(i);
@@ -1197,10 +1196,10 @@ public class Main {
ABCContainerTag found = getDebuggerABCTag(swf);
if (found != null) {
swf.tags.remove((Tag) found);
swf.abcList.remove(found);
swf.getAbcList().remove(found);
//Change all debugger calls to normal trace
for (ABCContainerTag ct : swf.abcList) {
for (ABCContainerTag ct : swf.getAbcList()) {
ABC a = ct.getABC();
for (int i = 1; i < a.constants.constant_multiname.size(); i++) {
Multiname m = a.constants.constant_multiname.get(i);
@@ -1223,7 +1222,7 @@ public class Main {
//load debug swf
SWF debugSWF = new SWF(Main.class.getClassLoader().getResourceAsStream("com/jpexs/decompiler/flash/gui/debugger/debug.swf"), false);
ABCContainerTag firstAbc = swf.abcList.get(0);
ABCContainerTag firstAbc = swf.getAbcList().get(0);
String newdebuggerpkg = DEBUGGER_PACKAGE;
if (Configuration.randomDebuggerPackage.get()) {
@@ -1231,7 +1230,7 @@ public class Main {
}
//add debug ABC tags to main SWF
for (ABCContainerTag ds : debugSWF.abcList) {
for (ABCContainerTag ds : debugSWF.getAbcList()) {
ABC a = ds.getABC();
//Append random hex to Debugger package name
for (int i = 1; i < a.constants.constant_namespace.size(); i++) {
@@ -1248,12 +1247,12 @@ public class Main {
//Add to target SWF
((Tag) ds).setSwf(swf);
swf.tags.add(swf.tags.indexOf(firstAbc), (Tag) ds);
swf.abcList.add(swf.abcList.indexOf(firstAbc), ds);
swf.getAbcList().add(swf.getAbcList().indexOf(firstAbc), ds);
((Tag) ds).setModified(true);
}
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "Error while attaching debugger", ex);
logger.log(Level.SEVERE, "Error while attaching debugger", ex);
//ignore
}
@@ -329,7 +329,7 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene
public void updateComponents(SWF swf) {
super.updateComponents(swf);
boolean swfLoaded = swf != null;
List<ABCContainerTag> abcList = swfLoaded ? swf.abcList : null;
List<ABCContainerTag> abcList = swfLoaded ? swf.getAbcList() : null;
boolean hasAbc = swfLoaded && abcList != null && !abcList.isEmpty();
/*saveCommandButton.setEnabled(swfLoaded);
@@ -94,6 +94,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
private static final String ACTION_CLOSE_ALL = "CLOSEALL";
private static final String ACTION_EXPORT_FLA = "EXPORTFLA";
public static final String ACTION_EXPORT_SEL = "EXPORTSEL";
public static final String ACTION_EXPORT_JAVA_SOURCE = "EXPORTJAVASOURCE";
private static final String ACTION_EXPORT = "EXPORT";
private static final String ACTION_IMPORT_TEXT = "IMPORTTEXT";
private static final String ACTION_CHECK_UPDATES = "CHECKUPDATES";
@@ -611,7 +612,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
public void updateComponents(SWF swf) {
super.updateComponents(swf);
boolean swfLoaded = swf != null;
List<ABCContainerTag> abcList = swfLoaded ? swf.abcList : null;
List<ABCContainerTag> abcList = swfLoaded ? swf.getAbcList() : null;
boolean hasAbc = swfLoaded && abcList != null && !abcList.isEmpty();
boolean hasDebugger = hasAbc && Main.hasDebugger(swf);
@@ -57,6 +57,7 @@ import com.jpexs.decompiler.flash.exporters.settings.MovieExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings;
import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings;
import com.jpexs.decompiler.flash.exporters.swf.SwfJavaExporter;
import com.jpexs.decompiler.flash.gui.abc.ABCPanel;
import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel;
import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog;
@@ -77,6 +78,7 @@ import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
import com.jpexs.decompiler.flash.tags.DefineSoundTag;
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
import com.jpexs.decompiler.flash.tags.FileAttributesTag;
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
@@ -628,7 +630,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
mainFrame.setTitle(ApplicationInfo.applicationVerName + (Configuration.displayFileName.get() ? " - " + swf.getFileTitle() : ""));
List<ABCContainerTag> abcList = swf.abcList;
List<ABCContainerTag> abcList = swf.getAbcList();
boolean hasAbc = !abcList.isEmpty();
@@ -1001,8 +1003,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
ret.addAll(swf.exportFrames(handler, selFile + File.separator + "frames", entry.getKey(), entry.getValue(),
new FramesExportSettings(export.getValue(FramesExportMode.class), export.getZoom())));
}
List<ABCContainerTag> abcList = swf.abcList;
if (swf.isAS3) {
List<ABCContainerTag> abcList = swf.getAbcList();
if (swf.isAS3()) {
for (int i = 0; i < as3scripts.size(); i++) {
ScriptPack tls = as3scripts.get(i);
Main.startWork(translate("work.exporting") + " " + (i + 1) + "/" + as3scripts.size() + " " + tls.getPath() + " ...");
@@ -1151,7 +1153,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
protected Void doInBackground() throws Exception {
boolean found = false;
if (searchDialog.searchInASRadioButton.isSelected()) {
if (swf.isAS3) {
if (swf.isAS3()) {
if (abcPanel != null && abcPanel.search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) {
found = true;
View.execInEventDispatch(new Runnable() {
@@ -1326,9 +1328,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
if (swf == null) {
return;
}
if (swf.fileAttributes != null && swf.fileAttributes.actionScript3) {
FileAttributesTag fileAttributes = swf.getFileAttributes();
if (fileAttributes != null && fileAttributes.actionScript3) {
final int multiName = getABCPanel().decompiledTextArea.getMultinameUnderCaret();
final List<ABCContainerTag> abcList = swf.abcList;
final List<ABCContainerTag> abcList = swf.getAbcList();
if (multiName > 0) {
new CancellableWorker() {
@Override
@@ -1389,9 +1393,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
List<FileFilter> flaFilters = new ArrayList<>();
List<FileFilter> xflFilters = new ArrayList<>();
List<FLAVersion> versions = new ArrayList<>();
boolean isAS3 = swf.isAS3();
for (int i = FLAVersion.values().length - 1; i >= 0; i--) {
final FLAVersion v = FLAVersion.values()[i];
if (!swf.isAS3 && v.minASVersion() > 2) {
if (!isAS3 && v.minASVersion() > 2) {
// This version does not support AS1/2
} else {
versions.add(v);
@@ -1594,7 +1599,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
new FontExportSettings(export.getValue(FontExportMode.class)));
swf.exportFrames(errorHandler, selFile + File.separator + "frames", 0, null,
new FramesExportSettings(export.getValue(FramesExportMode.class), export.getZoom()));
for (CharacterTag c : swf.characters.values()) {
for (CharacterTag c : swf.getCharacters().values()) {
if (c instanceof DefineSpriteTag) {
swf.exportFrames(errorHandler, selFile + File.separator + "frames", c.getCharacterId(), null,
new FramesExportSettings(export.getValue(FramesExportMode.class), export.getZoom()));
@@ -1629,6 +1634,23 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
}
public void exportJavaSource() {
List<TreeItem> sel = tagTree.getSelected(tagTree);
for (TreeItem item : sel) {
if (item instanceof SWF) {
SWF swf = (SWF) item;
final String selFile = selectExportDir();
if (selFile != null) {
try {
new SwfJavaExporter().exportJavaCode(swf, selFile);
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
}
}
}
}
}
public void restoreControlFlow(final boolean all) {
Main.startWork(translate("work.restoringControlFlow"));
if ((!all) || confirmExperimental()) {
@@ -1637,7 +1659,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
protected Object doInBackground() throws Exception {
int cnt = 0;
if (all) {
for (ABCContainerTag tag : getABCPanel().swf.abcList) {
for (ABCContainerTag tag : getABCPanel().swf.getAbcList()) {
tag.getABC().restoreControlFlow();
}
} else {
@@ -1725,7 +1747,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
protected Object doInBackground() throws Exception {
try {
if (deobfuscationDialog.processAllCheckbox.isSelected()) {
for (ABCContainerTag tag : getABCPanel().swf.abcList) {
for (ABCContainerTag tag : getABCPanel().swf.getAbcList()) {
if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_DEAD_CODE) {
tag.getABC().removeDeadCode();
} else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_TRAPS) {
@@ -1978,6 +2000,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
switch (e.getActionCommand()) {
case MainFrameRibbonMenu.ACTION_EXPORT_JAVA_SOURCE: {
exportJavaSource();
}
case MainFrameRibbonMenu.ACTION_EXPORT_SEL:
export(true);
break;
@@ -2264,7 +2289,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
stopFlashPlayer();
if (treeItem instanceof ScriptPack) {
final ScriptPack scriptLeaf = (ScriptPack) treeItem;
final List<ABCContainerTag> abcList = scriptLeaf.abc.swf.abcList;
final List<ABCContainerTag> abcList = scriptLeaf.abc.swf.getAbcList();
if (setSourceWorker != null) {
setSourceWorker.cancel(true);
setSourceWorker = null;
@@ -2283,7 +2308,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
}
getABCPanel().detailPanel.methodTraitPanel.methodCodePanel.clear();
getABCPanel().navigator.setABC(abcList, scriptLeaf.abc);
getABCPanel().navigator.setAbc(abcList, scriptLeaf.abc);
getABCPanel().navigator.setClassIndex(classIndex, scriptLeaf.scriptIndex);
getABCPanel().setAbc(scriptLeaf.abc);
getABCPanel().decompiledTextArea.setScript(scriptLeaf, abcList);
@@ -589,7 +589,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
t.getNeededCharactersDeep(needed);
for (int n : needed) {
if (!doneCharacters.contains(n)) {
classicTag(swf.characters.get(n)).writeTag(sos2);
classicTag(swf.getCharacter(n)).writeTag(sos2);
doneCharacters.add(n);
}
}
@@ -649,7 +649,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
if (isSprite && chtId == n) {
continue;
}
classicTag(swf.characters.get(n)).writeTag(sos2);
classicTag(swf.getCharacter(n)).writeTag(sos2);
}
}
@@ -257,16 +257,17 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
this.swf = null;
this.abc = null;
constantTable.setModel(new DefaultTableModel());
navigator.clearABC();
navigator.clearAbc();
}
public void setSwf(SWF swf) {
if (this.swf != swf) {
this.swf = swf;
if (swf.abcList.size() > 0) {
this.abc = swf.abcList.get(0).getABC();
List<ABCContainerTag> abcList = swf.getAbcList();
if (abcList.size() > 0) {
this.abc = abcList.get(0).getABC();
}
navigator.setABC(swf.abcList, abc);
navigator.setAbc(abcList, abc);
}
}
@@ -394,7 +395,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
@Override
public void propertyChange(PropertyChangeEvent pce) {
if (!directEditing) {
Configuration.guiAvm2SplitPaneDividerLocation.set((int) pce.getNewValue());
Configuration.guiAvm2SplitPaneDividerLocation.set((Integer) pce.getNewValue());
}
}
});
@@ -407,7 +408,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
public void actionPerformed(ActionEvent e) {
int multinameIndex = decompiledTextArea.getMultinameUnderCaret();
if (multinameIndex > -1) {
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this, false);
UsageFrame usageFrame = new UsageFrame(swf.getAbcList(), abc, multinameIndex, ABCPanel.this, false);
usageFrame.setVisible(true);
}
}
@@ -471,7 +472,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
}
int multinameIndex = constantTable.convertRowIndexToModel(rowIndex);
if (multinameIndex > 0) {
UsageFrame usageFrame = new UsageFrame(t.swf.abcList, abc, multinameIndex, t, false);
UsageFrame usageFrame = new UsageFrame(t.swf.getAbcList(), abc, multinameIndex, t, false);
usageFrame.setVisible(true);
}
}
@@ -505,19 +506,19 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
if (multinameIndex == 0) {
return false;
}
List<MultinameUsage> usages = abc.findMultinameDefinition(swf.abcList, multinameIndex);
List<MultinameUsage> usages = abc.findMultinameDefinition(swf.getAbcList(), multinameIndex);
Multiname m = abc.constants.constant_multiname.get(multinameIndex);
//search other ABC tags if this is not private multiname
if (m.namespace_index > 0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE) {
for (ABCContainerTag at : swf.abcList) {
for (ABCContainerTag at : swf.getAbcList()) {
ABC a = at.getABC();
if (a == abc) {
continue;
}
int mid = a.constants.getMultinameId(m, false);
if (mid > 0) {
usages.addAll(a.findMultinameDefinition(swf.abcList, mid));
usages.addAll(a.findMultinameDefinition(swf.getAbcList(), mid));
}
}
}
@@ -539,32 +540,32 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
Reference<Integer> multinameIndexRef = new Reference<>(0);
if (decompiledTextArea.getPropertyTypeAtPos(pos, abcIndex, classIndex, traitIndex, classTrait, multinameIndexRef)) {
UsageFrame.gotoUsage(ABCPanel.this, new TraitMultinameUsage(swf.abcList, swf.abcList.get(abcIndex.getVal()).getABC(), multinameIndexRef.getVal(), classIndex.getVal(), traitIndex.getVal(), classTrait.getVal(), null, -1) {
UsageFrame.gotoUsage(ABCPanel.this, new TraitMultinameUsage(swf.getAbcList(), swf.getAbcList().get(abcIndex.getVal()).getABC(), multinameIndexRef.getVal(), classIndex.getVal(), traitIndex.getVal(), classTrait.getVal(), null, -1) {
});
return;
}
int multinameIndex = decompiledTextArea.getMultinameAtPos(pos);
if (multinameIndex > -1) {
List<MultinameUsage> usages = abc.findMultinameDefinition(swf.abcList, multinameIndex);
List<MultinameUsage> usages = abc.findMultinameDefinition(swf.getAbcList(), multinameIndex);
Multiname m = abc.constants.constant_multiname.get(multinameIndex);
//search other ABC tags if this is not private multiname
if (m.namespace_index > 0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE) {
for (ABCContainerTag at : swf.abcList) {
for (ABCContainerTag at : swf.getAbcList()) {
ABC a = at.getABC();
if (a == abc) {
continue;
}
int mid = a.constants.getMultinameId(m, false);
if (mid > 0) {
usages.addAll(a.findMultinameDefinition(swf.abcList, mid));
usages.addAll(a.findMultinameDefinition(swf.getAbcList(), mid));
}
}
}
//more than one? display list
if (usages.size() > 1) {
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this, true);
UsageFrame usageFrame = new UsageFrame(swf.getAbcList(), abc, multinameIndex, ABCPanel.this, true);
usageFrame.setVisible(true);
return;
} else if (!usages.isEmpty()) { //one
@@ -699,7 +700,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
public void updateSearchPos(ABCPanelSearchResult item) {
ScriptPack pack = item.scriptPack;
setAbc(pack.abc);
decompiledTextArea.setScript(pack, swf.abcList);
decompiledTextArea.setScript(pack, swf.getAbcList());
hilightScript(pack);
decompiledTextArea.setCaretPosition(0);
@@ -76,7 +76,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
}
public void setHex(ScriptExportMode exportMode, boolean force) {
if (this.exportMode == exportMode & !force) {
if (this.exportMode == exportMode && !force) {
return;
}
this.exportMode = exportMode;
@@ -274,9 +274,9 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
lineStart = i + 1;
}
}
if (lineCnt == -1) {
//lineEnd = text.length() - 1;
}
//if (lineCnt == -1) {
// lineEnd = text.length() - 1;
//}
//select(lineStart, lineEnd);
setCaretPosition(lineStart);
//requestFocus();
@@ -85,8 +85,8 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
}
public void fireScript() {
for (int i = 0; i < scriptListeners.size(); i++) {
scriptListeners.get(i).run();
for (Runnable scriptListener : scriptListeners) {
scriptListener.run();
}
}
@@ -55,13 +55,13 @@ public class TraitsList extends JList<Object> implements ListSelectionListener {
setBackground(Color.white);
}
public void clearABC() {
public void clearAbc() {
this.abc = null;
this.abcTags = null;
setModel(new DefaultListModel<>());
}
public void setABC(List<ABCContainerTag> abcTags, ABC abc) {
public void setAbc(List<ABCContainerTag> abcTags, ABC abc) {
this.abc = abc;
this.abcTags = abcTags;
setModel(new DefaultListModel<>());
@@ -548,3 +548,5 @@ menu.tools.replace = Text Replace
message.confirm.close = There are unsaved changes. Do you really want to close {swfName}?
message.confirm.closeAll = There are unsaved changes. Do you really want to close all SWFs?
contextmenu.exportJavaSource = Export Java Source
@@ -548,3 +548,5 @@ menu.tools.replace = Sz\u00f6veg csere
message.confirm.close = Mentetlen v\u00e1ltoz\u00e1sok vannak. Szeretm\u00e9 m\u00e9gis bez\u00e9rni a k\u00f6vetkez\u0151t: {swfName}?
message.confirm.closeAll = Mentetlen v\u00e1ltoz\u00e1sok vannak. Szeretn\u00e9 bez\u00e1rni az \u00f6sszes SWF-t ?
contextmenu.exportJavaSource = Java k\u00f3d export\u00e1l\u00e1s
@@ -76,6 +76,7 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
private JMenuItem replaceMenuItem;
private JMenuItem rawEditMenuItem;
private JMenuItem jumpToCharacterMenuItem;
private JMenuItem exportJavaSourceMenuItem;
private JMenuItem closeMenuItem;
private JMenu addTagMenu;
private JMenu moveTagMenu;
@@ -122,6 +123,11 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
jumpToCharacterMenuItem.setVisible(false);
add(jumpToCharacterMenuItem);
exportJavaSourceMenuItem = new JMenuItem(mainPanel.translate("contextmenu.exportJavaSource"));
exportJavaSourceMenuItem.setActionCommand(MainFrameRibbonMenu.ACTION_EXPORT_JAVA_SOURCE);
exportJavaSourceMenuItem.addActionListener(mainPanel);
add(exportJavaSourceMenuItem);
closeMenuItem = new JMenuItem(mainPanel.translate("contextmenu.closeSwf"));
closeMenuItem.setActionCommand(ACTION_CLOSE_SWF);
closeMenuItem.addActionListener(this);
@@ -398,7 +404,7 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener {
}
CharacterIdTag characterIdTag = (CharacterIdTag) itemj;
mainPanel.setTagTreeSelectedNode(itemj.getSwf().characters.get(characterIdTag.getCharacterId()));
mainPanel.setTagTreeSelectedNode(itemj.getSwf().getCharacter(characterIdTag.getCharacterId()));
}
break;
case ACTION_EXPAND_RECURSIVE: {
@@ -227,8 +227,8 @@ public class TagTreeModel implements TreeModel {
nodeList.add(otherNode);
}
if (swf.isAS3) {
if (!swf.abcList.isEmpty()) {
if (swf.isAS3()) {
if (!swf.getAbcList().isEmpty()) {
nodeList.add(new ClassesListTreeModel(swf));
}
} else {
@@ -142,7 +142,7 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
flPrev = timeLine.getFrames().get(f - 1).layers.get(d);
}
CharacterTag cht = fl == null ? null : timeLine.swf.characters.get(fl.characterId);
CharacterTag cht = fl == null ? null : timeLine.swf.getCharacter(fl.characterId);
boolean shapeTween = cht != null && (cht instanceof MorphShapeTag);
boolean motionTweenStart = (!motionTween) && (flNext != null && flNext.motionTween);
boolean motionTweenEnd = (!motionTween) && (flPrev != null && flPrev.motionTween);