mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 10:50:47 +00:00
Display AS3 p-code docs in GUI, improvements.
This commit is contained in:
+8
-27
@@ -25,6 +25,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRootPane;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
@@ -32,47 +33,27 @@ import javax.swing.JScrollPane;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DocsWindow extends JFrame implements DocsListener {
|
||||
public class DocsPanel extends JPanel implements DocsListener {
|
||||
|
||||
private JEditorPane textDisplay = new JEditorPane();
|
||||
//TODO: Make this use skin somehow (?)
|
||||
public static final Color HINT_COLOR = new Color(245, 245, 181);
|
||||
|
||||
public DocsWindow() {
|
||||
setAlwaysOnTop(true);
|
||||
setSize(500, 250);
|
||||
setTitle("-");
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
getContentPane().add(new JScrollPane(textDisplay), BorderLayout.CENTER);
|
||||
public DocsPanel() {
|
||||
setLayout(new BorderLayout());
|
||||
add(new JScrollPane(textDisplay), BorderLayout.CENTER);
|
||||
textDisplay.setContentType("text/html");
|
||||
setAutoRequestFocus(false);
|
||||
textDisplay.setFocusable(false);
|
||||
View.setWindowIcon(this);
|
||||
this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
|
||||
textDisplay.setBackground(Color.white);
|
||||
textDisplay.setBackground(HINT_COLOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void docs(String identifier, String docs, Point screenLocation) {
|
||||
setTitle(identifier);
|
||||
textDisplay.setText(docs.replace("\r\n", "<br />"));
|
||||
if (screenLocation != null) {
|
||||
setLocation(screenLocation);
|
||||
}
|
||||
|
||||
setFocusableWindowState(false);
|
||||
setVisible(true);
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setFocusableWindowState(true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noDocs() {
|
||||
setVisible(false);
|
||||
setTitle("-");
|
||||
textDisplay.setText("");
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.jpexs.decompiler.flash.helpers.HighlightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import com.jpexs.decompiler.flash.locales.docs.pcode.As3Docs;
|
||||
import com.jpexs.decompiler.flash.docs.As3PCodeDocs;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.graph.ScopeStack;
|
||||
@@ -158,7 +158,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
|
||||
public ASMSourceEditorPane(DecompiledEditorPane decompiledEditor) {
|
||||
this.decompiledEditor = decompiledEditor;
|
||||
addCaretListener(this);
|
||||
for (InstructionDefinition def : AVM2Code.instructionSet) {
|
||||
for (InstructionDefinition def : AVM2Code.allInstructionSet) {
|
||||
if (def != null) {
|
||||
insNameToDef.put(def.instructionName, def);
|
||||
}
|
||||
@@ -419,7 +419,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
|
||||
}
|
||||
}
|
||||
|
||||
public void caretUpdateEdit(CaretEvent e) {
|
||||
public void updateDocs() {
|
||||
String curLine = getCurrentLineText();
|
||||
|
||||
if (curLine == null) {
|
||||
@@ -444,7 +444,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
|
||||
if (loc != null) {
|
||||
SwingUtilities.convertPointToScreen(loc, this);
|
||||
}
|
||||
fireDocs(insName, As3Docs.getDocsForIns(insName), loc);
|
||||
fireDocs(insName, As3PCodeDocs.getDocsForIns(insName, false, true), loc);
|
||||
} else {
|
||||
fireNoDocs();
|
||||
}
|
||||
@@ -452,11 +452,12 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
|
||||
|
||||
@Override
|
||||
public void caretUpdate(CaretEvent e) {
|
||||
if (isEditable()) {
|
||||
caretUpdateEdit(e);
|
||||
updateDocs();
|
||||
|
||||
if (ignoreCarret) {
|
||||
return;
|
||||
}
|
||||
if (ignoreCarret) {
|
||||
if (isEditable()) {
|
||||
return;
|
||||
}
|
||||
getCaret().setVisible(true);
|
||||
|
||||
@@ -21,9 +21,10 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.gui.DocsWindow;
|
||||
import com.jpexs.decompiler.flash.gui.DocsPanel;
|
||||
import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane;
|
||||
import com.jpexs.decompiler.flash.gui.controls.NoneSelectedButtonGroup;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
|
||||
import java.awt.BorderLayout;
|
||||
@@ -36,6 +37,7 @@ import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JToggleButton;
|
||||
|
||||
/**
|
||||
@@ -51,7 +53,7 @@ public class MethodCodePanel extends JPanel {
|
||||
private final JToggleButton hexButton;
|
||||
|
||||
private final JToggleButton hexOnlyButton;
|
||||
private final DocsWindow docsWindow;
|
||||
private final DocsPanel docsPanel;
|
||||
|
||||
public void refreshMarkers() {
|
||||
sourceTextArea.refreshMarkers();
|
||||
@@ -113,7 +115,10 @@ public class MethodCodePanel extends JPanel {
|
||||
sourceTextArea = new ASMSourceEditorPane(decompiledEditor);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(new JScrollPane(sourceTextArea), BorderLayout.CENTER);
|
||||
|
||||
docsPanel = new DocsPanel();
|
||||
sourceTextArea.addDocsListener(docsPanel);
|
||||
add(new JPersistentSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(sourceTextArea), new JScrollPane(docsPanel), Configuration.guiAvm2DocsSplitPaneDividerLocationPercent));
|
||||
sourceTextArea.changeContentType("text/flasm3");
|
||||
sourceTextArea.setFont(new Font("Monospaced", Font.PLAIN, sourceTextArea.getFont().getSize()));
|
||||
|
||||
@@ -146,11 +151,7 @@ public class MethodCodePanel extends JPanel {
|
||||
buttonsPanel.add(new JPanel());
|
||||
|
||||
add(buttonsPanel, BorderLayout.NORTH);
|
||||
docsWindow = new DocsWindow();
|
||||
|
||||
if (Configuration.as3pcodeDocWindow.get()) {
|
||||
sourceTextArea.addDocsListener(docsWindow);
|
||||
}
|
||||
}
|
||||
|
||||
private void graphButtonActionPerformed(ActionEvent evt) {
|
||||
|
||||
Reference in New Issue
Block a user