#1485 night mode for AS3 p-code docs window

This commit is contained in:
Jindra Petřík
2021-04-08 18:19:14 +02:00
parent 6e0b35c06b
commit dfc724ec02
5 changed files with 76 additions and 32 deletions

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.docs;
import com.jpexs.decompiler.flash.ApplicationInfo;
@@ -82,14 +83,14 @@ public class As3PCodeDocs extends AbstractDocs {
return identName.toString();
}
public static String getDocsForIns(String insName, boolean showDataSize, boolean ui, boolean withStyle, boolean nightMode) {
if (!nameToDef.containsKey(insName)) {
return null;
}
}
return getDocsForIns(nameToDef.get(insName), showDataSize, ui, withStyle, nightMode);
}
public static String getDocsForIns(InstructionDefinition def, boolean showDataSize, boolean ui, boolean standalone, boolean nightMode) {
final String cacheKey = def.instructionName + "|" + (showDataSize ? 1 : 0) + "|" + (ui ? 1 : 0) + "|" + (standalone ? 1 : 0);
String v = docsCache.get(cacheKey);
if (v != null) {
@@ -98,7 +99,7 @@ public class As3PCodeDocs extends AbstractDocs {
StringBuilder sb = new StringBuilder();
if (standalone) {
if (standalone) {
sb.append(htmlHeader("", getStyle(), nightMode));
}
String insName = def.instructionName;
@@ -122,9 +123,17 @@ public class As3PCodeDocs extends AbstractDocs {
String stack = def.hasFlag(AVM2InstructionFlag.UNKNOWN_STACK) ? getProperty("ui.unknown") : stackBefore + "<span class=\"stack-to\">" + getProperty("ui.stack.to") + "</span>" + stackAfter;
String operandsDoc = def.hasFlag(AVM2InstructionFlag.UNKNOWN_OPERANDS) ? getProperty("ui.unknown") : getProperty("instruction." + insName + ".operands");
sb.append("<");
sb.append(standalone ? "body" : "div");
if (standalone) {
sb.append("<body class=\"");
if (nightMode) {
sb.append("standalonenight");
} else {
sb.append("standalone");
}
sb.append("\">");
}
sb.append("<div class=\"instruction");
for (AVM2InstructionFlag fl : def.flags) {
sb.append(" instruction-flag-").append(makeIdent(fl.toString()));
@@ -213,10 +222,9 @@ public class As3PCodeDocs extends AbstractDocs {
if (flagsPrinted) {
sb.append("</ul>").append(NEWLINE);
}
}
sb.append("</");
sb.append(standalone ? "body" : "div"); //.instruction
sb.append("</div>").append(NEWLINE); //.instruction
if (standalone) {
sb.append("</body>");
sb.append(htmlFooter());
}
String r = sb.toString();
@@ -241,7 +249,7 @@ public class As3PCodeDocs extends AbstractDocs {
return js;
}
public static String getAllInstructionDocs(boolean nightMode) {
String jsData = "";
jsData += "var txt_filter_hide = \"" + getProperty("ui.filter.hide") + "\";" + NEWLINE;
@@ -264,7 +272,12 @@ public class As3PCodeDocs extends AbstractDocs {
}
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder();
sb.append(htmlHeader(jsData + getJs(), getStyle(), nightMode));
sb.append("<body");
if (nightMode) {
sb.append(" class=\"night\"");
}
sb.append(">");
sb.append("\t\t<h1>").append(getProperty("ui.list.heading")).append("</h1>").append(NEWLINE);
sb.append("<span id=\"js-switcher\" class=\"js\"></span>");
sb.append("\t\t<ul class=\"instruction-list\">").append(NEWLINE);
@@ -275,7 +288,7 @@ public class As3PCodeDocs extends AbstractDocs {
continue;
}
sb.append("\t\t\t<li class=\"instruction-item\">").append(NEWLINE);
sb.append("\t\t\t<li class=\"instruction-item\">").append(NEWLINE);
sb.append("\t\t\t\t").append(getDocsForIns(def, true, false, false, nightMode).trim().replace(NEWLINE, NEWLINE + "\t\t\t\t")).append(NEWLINE);
sb.append("\t\t\t</li>").append(NEWLINE);
}
sb.append("\t\t</ul>").append(NEWLINE);
@@ -285,10 +298,10 @@ public class As3PCodeDocs extends AbstractDocs {
}
public static void main(String[] args) throws UnsupportedEncodingException {
public static void main(String[] args) throws UnsupportedEncodingException {
System.out.println(getAllInstructionDocs(false));
}
protected static String htmlHeader(String js, String style, boolean nightMode) {
Date dateGenerated = new Date();
StringBuilder sb = new StringBuilder();
sb.append("<!DOCTYPE html>").append(NEWLINE).

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.docs;
import com.jpexs.decompiler.flash.ApplicationInfo;
@@ -30,12 +31,12 @@ public class As3PCodeOtherDocs extends AbstractDocs {
prop = ResourceBundle.getBundle("com.jpexs.decompiler.flash.locales.docs.pcode.AS3other");
}
public static String getDocsForPath(String path, boolean nightMode) {
return getDocsForPath(path, true, nightMode);
}
private static String getDocsForPath(String path, boolean standalone, boolean nightMode) {
final String cacheKey = path + "|" + (standalone ? 1 : 0);
String v = docsCache.get(cacheKey);
@@ -53,10 +54,16 @@ public class As3PCodeOtherDocs extends AbstractDocs {
sb.append(htmlHeader("", getStyle()));
}
sb.append("<");
sb.append(standalone ? "body" : "div");
sb.append(" class=\"otherdoc\"");
if (standalone) {
sb.append("<body class=\"");
if (nightMode) {
sb.append("standalonenight");
} else {
sb.append("standalone");
}
sb.append("\">");
}
sb.append("<div class=\"otherdoc\">");
String pathParts[] = new String[]{path};
if (path.contains(".")) {
@@ -88,10 +95,9 @@ public class As3PCodeOtherDocs extends AbstractDocs {
}
}
sb.append("</");
sb.append(standalone ? "body" : "div"); //.instruction
sb.append("</div>").append(NEWLINE); //.instruction
if (standalone) {
sb.append("</body>");
sb.append(htmlFooter());
}
String r = sb.toString();

View File

@@ -9,11 +9,25 @@ strong.flags-title {font-weight: bold;}
.hidden {display:none}
.filter-flag-title {display:inline-block; width: 50ex;}
.instruction {padding:5px;}
.instruction.instruction-flag-noFlashPlayer {background-color: #ccc;}
.instruction.instruction-flag-noFlashPlayer {background-color: #cccccc;}
body {font-family: serif;}
h1, h2, h3, h4, h5 {font-family: sans-serif;}
.instruction-signature {font-family: "Courier New", monospace; font-size: 1.05em;}
.filter {font-family: sans-serif; }
.path {font-weight: bold; color: blue;}
.path-block {}
.path-docs {}
.path-docs {}
.night {background-color: red;}
body.standalone {background-color: #f5f5b5;}
body.standalonenight {background-color: #330;}
body.standalonenight .instruction {background-color: #330; color:white;}
body.standalonenight .otherdoc {background-color: #330; color:white;}
body.standalonenight .instruction.instruction-flag-noFlashPlayer {background-color: #333;}
body.standalonenight strong.instruction-name {color: #88f;}
body.standalonenight .path {color: #88f;}