Issue #1244 Allow to compile back Unknown instructions

This commit is contained in:
2016-05-29 10:00:33 +02:00
parent d000457330
commit 81c3df016d
6 changed files with 118 additions and 108 deletions
@@ -192,7 +192,7 @@ public class FontPanel extends JPanel {
TextTag textTag = (TextTag) tag;
if (textTag.getFontIds().contains(fontId)) {
String text = textTag.getFormattedText(true).text;
mainPanel.saveText(textTag, text, null);
mainPanel.saveText(textTag, text, null, null);
}
}
}
@@ -84,6 +84,7 @@ import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane;
import com.jpexs.decompiler.flash.gui.dumpview.DumpTree;
import com.jpexs.decompiler.flash.gui.dumpview.DumpTreeModel;
import com.jpexs.decompiler.flash.gui.dumpview.DumpViewPanel;
import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.gui.helpers.ObservableList;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.decompiler.flash.gui.tagtree.TagTree;
@@ -2554,12 +2555,17 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
};
}
public boolean saveText(TextTag textTag, String formattedText, String[] texts) {
public boolean saveText(TextTag textTag, String formattedText, String[] texts, LineMarkedEditorPane editor) {
try {
if (textTag.setFormattedText(getMissingCharacterHandler(), formattedText, texts)) {
return true;
}
} catch (TextParseException ex) {
if (editor != null) {
editor.gotoLine((int) ex.line);
editor.markError();
}
View.showMessageDialog(null, translate("error.text.invalid").replace("%text%", ex.text).replace("%line%", Long.toString(ex.line)), translate("error"), JOptionPane.ERROR_MESSAGE);
}
@@ -339,7 +339,7 @@ public class TextPanel extends JPanel implements TagEditorPanel {
}
private void saveText(boolean refresh) {
if (mainPanel.saveText(textTag, textValue.getText(), null)) {
if (mainPanel.saveText(textTag, textValue.getText(), null, textValue)) {
setEditText(false);
setModified(false);
textTag.getSwf().clearImageCache();
@@ -307,9 +307,9 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
} catch (IOException ex) {
} catch (InterruptedException ex) {
} catch (AVM2ParseException ex) {
View.showMessageDialog(this, (ex.text + " on line " + ex.line));
gotoLine((int) ex.line);
markError();
View.showMessageDialog(this, (ex.text + " on line " + ex.line));
return false;
}
return true;
@@ -215,7 +215,7 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
}
public void gotoLine(int line) {
setCaretPosition(ActionUtils.getDocumentPosition(this, line + 1, 0));
setCaretPosition(ActionUtils.getDocumentPosition(this, line, 0));
}
public Point getLineLocation(int line) {