mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 12:00:53 +00:00
Merge origin/master
This commit is contained in:
@@ -45,6 +45,7 @@ import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
|
||||
import com.jpexs.decompiler.flash.action.parser.script.ActionScript2Parser;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.configuration.ConfigurationItem;
|
||||
import com.jpexs.decompiler.flash.docs.As3PCodeDocs;
|
||||
import com.jpexs.decompiler.flash.exporters.BinaryDataExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.FontExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.FrameExporter;
|
||||
@@ -158,11 +159,13 @@ import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Stack;
|
||||
@@ -501,6 +504,19 @@ public class CommandLineArgumentParser {
|
||||
out.println(" ...Forwards all parameters after the -custom parameter to the plugins");
|
||||
}
|
||||
|
||||
if (filter == null || filter.equals("doc")) {
|
||||
out.println(" " + (cnt++) + ") -doc -type <type> [-out <outfile>] [-format <format>] [-locale <locale>]");
|
||||
out.println(" ...Generate documentation");
|
||||
out.println(" ...-type <type> Selects documentation type");
|
||||
out.println(" ...<type> can be currently only: as3.pcode.instructions for list of ActionScript3 AVM2 instructions");
|
||||
out.println(" ...-out <outfile> (optional) If specified, output is written to <outfile> instead of stdout");
|
||||
out.println(" ...-format <format> (optional, html is default) Selects output format");
|
||||
out.println(" ...<format> is currently only html");
|
||||
out.println(" ...-locale <locale> (optional) Override default locale");
|
||||
out.println(" ...<locale> is localization identifier, en for english for example");
|
||||
out.println(" ...<format> is currently only html");
|
||||
}
|
||||
|
||||
printCmdLineUsageExamples(out, filter);
|
||||
}
|
||||
|
||||
@@ -562,6 +578,12 @@ public class CommandLineArgumentParser {
|
||||
exampleFound = true;
|
||||
}
|
||||
|
||||
if (filter == null || filter.equals("doc")) {
|
||||
out.println("java -jar ffdec.jar -doc -type as3.pcode.instructions -format html");
|
||||
out.println("java -jar ffdec.jar -doc -type as3.pcode.instructions -format html -locale en -out as3_docs_en.html");
|
||||
exampleFound = true;
|
||||
}
|
||||
|
||||
if (!exampleFound) {
|
||||
out.println("Sorry, no example found for command " + filter + ", Let us know in issue tracker when you need it.");
|
||||
}
|
||||
@@ -734,6 +756,8 @@ public class CommandLineArgumentParser {
|
||||
parseRemoveCharacter(args, false);
|
||||
} else if (command.equals("removecharacterwithdependencies")) {
|
||||
parseRemoveCharacter(args, true);
|
||||
} else if (command.equals("doc")) {
|
||||
parseDoc(args);
|
||||
} else if (command.equals("importscript")) {
|
||||
parseImportScript(args);
|
||||
} else if (command.equals("importscript")) {
|
||||
@@ -2535,6 +2559,77 @@ public class CommandLineArgumentParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseDoc(Stack<String> args) {
|
||||
String type = null;
|
||||
String format = null;
|
||||
String out = null;
|
||||
String locale = null;
|
||||
while (!args.isEmpty()) {
|
||||
String arg = args.pop();
|
||||
switch (arg) {
|
||||
case "-out":
|
||||
if (args.isEmpty() || out != null) {
|
||||
badArguments("doc");
|
||||
}
|
||||
out = args.pop();
|
||||
break;
|
||||
case "-type":
|
||||
if (args.isEmpty() || type != null) {
|
||||
badArguments("doc");
|
||||
}
|
||||
type = args.pop();
|
||||
break;
|
||||
case "-format":
|
||||
if (args.isEmpty() || format != null) {
|
||||
badArguments("doc");
|
||||
}
|
||||
format = args.pop();
|
||||
break;
|
||||
case "-locale":
|
||||
if (args.isEmpty() || locale != null) {
|
||||
badArguments("doc");
|
||||
}
|
||||
locale = args.pop();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (format == null) {
|
||||
format = "html";
|
||||
}
|
||||
if (type == null) {
|
||||
badArguments("doc");
|
||||
} else if (!type.equals("as3.pcode.instructions")) {
|
||||
badArguments("doc");
|
||||
}
|
||||
|
||||
if (!format.equals("html")) {
|
||||
badArguments("doc");
|
||||
}
|
||||
if (locale != null) {
|
||||
Locale.setDefault(Locale.forLanguageTag(locale));
|
||||
}
|
||||
|
||||
String doc = As3PCodeDocs.getAllInstructionDocs();
|
||||
|
||||
PrintStream outStream;
|
||||
|
||||
if (out == null) {
|
||||
outStream = System.out;
|
||||
} else {
|
||||
try {
|
||||
outStream = new PrintStream(out, "UTF-8");
|
||||
} catch (UnsupportedEncodingException | FileNotFoundException ex) {
|
||||
Logger.getLogger(CommandLineArgumentParser.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage());
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
outStream.print(doc);
|
||||
}
|
||||
|
||||
private static void parseRemoveCharacter(Stack<String> args, boolean removeDependencies) {
|
||||
if (args.size() < 3) {
|
||||
badArguments("removecharacter");
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.gui.abc.DocsListener;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -36,25 +37,31 @@ import javax.swing.JScrollPane;
|
||||
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 DocsPanel() {
|
||||
setLayout(new BorderLayout());
|
||||
add(new JScrollPane(textDisplay), BorderLayout.CENTER);
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
JScrollPane sp = new JScrollPane(textDisplay);
|
||||
|
||||
textDisplay.setMargin(new Insets(0, 0, 0, 0));
|
||||
add(sp, BorderLayout.CENTER);
|
||||
textDisplay.setContentType("text/html");
|
||||
textDisplay.setFocusable(false);
|
||||
textDisplay.setBackground(HINT_COLOR);
|
||||
textDisplay.setBackground(Color.white);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getInsets() {
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void docs(String identifier, String docs, Point screenLocation) {
|
||||
textDisplay.setText(docs.replace("\r\n", "<br />"));
|
||||
textDisplay.setText(docs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noDocs() {
|
||||
textDisplay.setText("");
|
||||
textDisplay.setText("<body></body>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
|
||||
if (loc != null) {
|
||||
SwingUtilities.convertPointToScreen(loc, this);
|
||||
}
|
||||
fireDocs(insName, As3PCodeDocs.getDocsForIns(insName, false, true), loc);
|
||||
fireDocs(insName, As3PCodeDocs.getDocsForIns(insName, false, true, true), loc);
|
||||
} else {
|
||||
fireNoDocs();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user