mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-05 18:34:45 +00:00
AS3 p-code Popup docs for other items than instructions
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.jpexs.decompiler.flash.docs;
|
||||
|
||||
import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
import static com.jpexs.decompiler.flash.docs.As3PCodeOtherDocs.NEWLINE;
|
||||
import com.jpexs.helpers.Cache;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.InputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.TimeZone;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AbstractDocs {
|
||||
|
||||
protected static Cache<String, String> docsCache = Cache.getInstance(false, true, "abstractDocsCache");
|
||||
|
||||
protected static String htmlFooter() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("</html>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getStyle() {
|
||||
String cached = docsCache.get("__style");
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
String style = "";
|
||||
InputStream is = As3PCodeDocs.class.getResourceAsStream("/com/jpexs/decompiler/flash/docs/docs.css");
|
||||
if (is == null) {
|
||||
Logger.getLogger(As3PCodeDocs.class.getName()).log(Level.SEVERE, "docs.css needed for documentation not found");
|
||||
} else {
|
||||
style = new String(Helper.readStream(is), Utf8Helper.charset);
|
||||
}
|
||||
|
||||
docsCache.put("__style", style);
|
||||
return style;
|
||||
}
|
||||
|
||||
protected static String meta(String name, String content) {
|
||||
return "\t\t<meta name=\"" + name + "\" content=\"" + content + "\">" + NEWLINE;
|
||||
}
|
||||
|
||||
protected static String metaProp(String name, String content) {
|
||||
return "\t\t<meta property=\"" + name + "\" content=\"" + content + "\">" + NEWLINE;
|
||||
}
|
||||
|
||||
protected static String meta(String name, Date content) {
|
||||
return "\t\t<meta name=\"" + name + "\" content=\"" + getISO8601StringForDate(content) + "\">" + NEWLINE;
|
||||
}
|
||||
|
||||
protected static String getISO8601StringForDate(Date date) {
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,15 +28,12 @@ import java.util.logging.Logger;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class As3PCodeDocs {
|
||||
public class As3PCodeDocs extends AbstractDocs {
|
||||
|
||||
private static ResourceBundle prop;
|
||||
static ResourceBundle prop;
|
||||
private static final Map<AVM2InstructionFlag, String> flagDescriptions = new HashMap<>();
|
||||
|
||||
private static Map<AVM2InstructionFlag, String> flagDescriptions = new HashMap<>();
|
||||
|
||||
private static Cache<String, String> docsCache = Cache.getInstance(false, true, "as3DocsCache");
|
||||
|
||||
private static Map<String, InstructionDefinition> nameToDef = new HashMap<>();
|
||||
private final static Map<String, InstructionDefinition> nameToDef = new HashMap<>();
|
||||
|
||||
static final String NEWLINE = "\r\n";
|
||||
|
||||
@@ -82,56 +79,6 @@ public class As3PCodeDocs {
|
||||
return getDocsForIns(nameToDef.get(insName), showDataSize, ui, withStyle);
|
||||
}
|
||||
|
||||
private static String getProperty(String name) {
|
||||
if (prop.containsKey(name)) {
|
||||
return Helper.escapeHTML(prop.getString(name));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String htmlFooter() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("</html>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String meta(String name, String content) {
|
||||
return "\t\t<meta name=\"" + name + "\" content=\"" + content + "\">" + NEWLINE;
|
||||
}
|
||||
|
||||
private static String metaProp(String name, String content) {
|
||||
return "\t\t<meta property=\"" + name + "\" content=\"" + content + "\">" + NEWLINE;
|
||||
}
|
||||
|
||||
private static String meta(String name, Date content) {
|
||||
return "\t\t<meta name=\"" + name + "\" content=\"" + getISO8601StringForDate(content) + "\">" + NEWLINE;
|
||||
}
|
||||
|
||||
private static String htmlHeader(String js, String style) {
|
||||
Date dateGenerated = new Date();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<!DOCTYPE html>").append(NEWLINE).
|
||||
append("<html>").append(NEWLINE).
|
||||
append("\t<head>").append(NEWLINE);
|
||||
if (style != null && !style.isEmpty()) {
|
||||
sb.append("\t\t<style>").append(style).append("</style>").append(NEWLINE);
|
||||
}
|
||||
if (js != null && !js.isEmpty()) {
|
||||
sb.append("\t\t<script>").append(js).append("</script>").append(NEWLINE);
|
||||
}
|
||||
sb.append("\t\t<meta charset=\"UTF-8\">").append(NEWLINE).
|
||||
append(meta("generator", ApplicationInfo.applicationVerName)).
|
||||
append(meta("description", getProperty("ui.list.pageDescription"))).
|
||||
append(metaProp("og:title", getProperty("ui.list.pageTitle"))).
|
||||
append(metaProp("og:type", "article")).
|
||||
append(metaProp("og:description", getProperty("ui.list.pageDescription"))).
|
||||
append(meta("date", dateGenerated)).
|
||||
append("\t\t<title>").append(getProperty("ui.list.documentTitle")).append("</title>").append(NEWLINE).
|
||||
append("\t</head>").append(NEWLINE);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getDocsForIns(InstructionDefinition def, boolean showDataSize, boolean ui, boolean standalone) {
|
||||
final String cacheKey = def.instructionName + "|" + (showDataSize ? 1 : 0) + "|" + (ui ? 1 : 0) + "|" + (standalone ? 1 : 0);
|
||||
String v = docsCache.get(cacheKey);
|
||||
@@ -267,23 +214,6 @@ public class As3PCodeDocs {
|
||||
return r;
|
||||
}
|
||||
|
||||
public static String getStyle() {
|
||||
String cached = docsCache.get("__style");
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
String style = "";
|
||||
InputStream is = As3PCodeDocs.class.getResourceAsStream("/com/jpexs/decompiler/flash/docs/docs.css");
|
||||
if (is == null) {
|
||||
Logger.getLogger(As3PCodeDocs.class.getName()).log(Level.SEVERE, "docs.css needed for documentation not found");
|
||||
} else {
|
||||
style = new String(Helper.readStream(is), Utf8Helper.charset);
|
||||
}
|
||||
|
||||
docsCache.put("__style", style);
|
||||
return style;
|
||||
}
|
||||
|
||||
public static String getJs() {
|
||||
String cached = docsCache.get("__js");
|
||||
if (cached != null) {
|
||||
@@ -301,12 +231,6 @@ public class As3PCodeDocs {
|
||||
return js;
|
||||
}
|
||||
|
||||
private static String getISO8601StringForDate(Date date) {
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
return dateFormat.format(date);
|
||||
}
|
||||
|
||||
public static String getAllInstructionDocs() {
|
||||
|
||||
String jsData = "";
|
||||
@@ -353,4 +277,35 @@ public class As3PCodeDocs {
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
System.out.println(getAllInstructionDocs());
|
||||
}
|
||||
|
||||
protected static String htmlHeader(String js, String style) {
|
||||
Date dateGenerated = new Date();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<!DOCTYPE html>").append(NEWLINE).
|
||||
append("<html>").append(NEWLINE).
|
||||
append("\t<head>").append(NEWLINE);
|
||||
if (style != null && !style.isEmpty()) {
|
||||
sb.append("\t\t<style>").append(style).append("</style>").append(NEWLINE);
|
||||
}
|
||||
if (js != null && !js.isEmpty()) {
|
||||
sb.append("\t\t<script>").append(js).append("</script>").append(NEWLINE);
|
||||
}
|
||||
sb.append("\t\t<meta charset=\"UTF-8\">").append(NEWLINE).
|
||||
append(meta("generator", ApplicationInfo.applicationVerName)).
|
||||
append(meta("description", getProperty("ui.list.pageDescription"))).
|
||||
append(metaProp("og:title", getProperty("ui.list.pageTitle"))).
|
||||
append(metaProp("og:type", "article")).
|
||||
append(metaProp("og:description", getProperty("ui.list.pageDescription"))).
|
||||
append(meta("date", dateGenerated)).
|
||||
append("\t\t<title>").append(getProperty("ui.list.documentTitle")).append("</title>").append(NEWLINE).
|
||||
append("\t</head>").append(NEWLINE);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected static String getProperty(String name) {
|
||||
if (prop.containsKey(name)) {
|
||||
return Helper.escapeHTML(prop.getString(name));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.jpexs.decompiler.flash.docs;
|
||||
|
||||
import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
import static com.jpexs.decompiler.flash.docs.As3PCodeDocs.NEWLINE;
|
||||
import com.jpexs.helpers.Cache;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.InputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.TimeZone;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class As3PCodeOtherDocs extends AbstractDocs {
|
||||
|
||||
static ResourceBundle prop;
|
||||
static final String NEWLINE = "\r\n";
|
||||
|
||||
static {
|
||||
prop = ResourceBundle.getBundle("com.jpexs.decompiler.flash.locales.docs.pcode.AS3other");
|
||||
}
|
||||
|
||||
public static String getDocsForPath(String path) {
|
||||
|
||||
return getDocsForPath(path, true);
|
||||
}
|
||||
|
||||
private static String getDocsForPath(String path, boolean standalone) {
|
||||
|
||||
final String cacheKey = path + "|" + (standalone ? 1 : 0);
|
||||
String v = docsCache.get(cacheKey);
|
||||
if (v != null) {
|
||||
return v;
|
||||
}
|
||||
|
||||
String docStr = "";
|
||||
String pathNoTrait = path;
|
||||
if (path.startsWith("trait.method")) {
|
||||
pathNoTrait = path.substring("trait.".length());
|
||||
}
|
||||
if (prop.containsKey(pathNoTrait)) {
|
||||
docStr = prop.getString(pathNoTrait);
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (standalone) {
|
||||
sb.append(htmlHeader("", getStyle()));
|
||||
}
|
||||
|
||||
sb.append("<");
|
||||
sb.append(standalone ? "body" : "div");
|
||||
sb.append(" class=\"otherdoc\"");
|
||||
sb.append(">");
|
||||
|
||||
sb.append(docStr);
|
||||
|
||||
sb.append("</");
|
||||
sb.append(standalone ? "body" : "div"); //.instruction
|
||||
sb.append(">").append(NEWLINE);
|
||||
if (standalone) {
|
||||
sb.append(htmlFooter());
|
||||
}
|
||||
String r = sb.toString();
|
||||
docsCache.put(cacheKey, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
protected static String htmlHeader(String js, String style) {
|
||||
Date dateGenerated = new Date();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<!DOCTYPE html>").append(NEWLINE).
|
||||
append("<html>").append(NEWLINE).
|
||||
append("\t<head>").append(NEWLINE);
|
||||
if (style != null && !style.isEmpty()) {
|
||||
sb.append("\t\t<style>").append(style).append("</style>").append(NEWLINE);
|
||||
}
|
||||
if (js != null && !js.isEmpty()) {
|
||||
sb.append("\t\t<script>").append(js).append("</script>").append(NEWLINE);
|
||||
}
|
||||
sb.append("\t\t<meta charset=\"UTF-8\">").append(NEWLINE).
|
||||
append(meta("generator", ApplicationInfo.applicationVerName)).
|
||||
append(meta("description", getProperty("ui.list.pageDescription"))).
|
||||
append(metaProp("og:title", getProperty("ui.list.pageTitle"))).
|
||||
append(metaProp("og:type", "article")).
|
||||
append(metaProp("og:description", getProperty("ui.list.pageDescription"))).
|
||||
append(meta("date", dateGenerated)).
|
||||
append("\t\t<title>").append(getProperty("ui.list.documentTitle")).append("</title>").append(NEWLINE).
|
||||
append("\t</head>").append(NEWLINE);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected static String getProperty(String name) {
|
||||
if (prop.containsKey(name)) {
|
||||
return Helper.escapeHTML(prop.getString(name));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
html, body {margin:0px; padding: 0px;}
|
||||
.instruction {background-color: #f5f5b5; color:black;}
|
||||
.otherdoc {background-color: #f5f5b5; color:black;}
|
||||
li.instruction-item {list-style:none; padding:0px;border:1px solid black; border-bottom:none; border-collapse:collapse; }
|
||||
ul.instruction-list {padding-left:0; display:table; border-bottom:1px solid black;}
|
||||
strong.instruction-name {font-weight: bold; color: blue;}
|
||||
|
||||
Reference in New Issue
Block a user