From 6e5bc394895db9de12405ffcb0f6d73303d01a9e Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Mon, 27 Apr 2020 17:58:53 +0200 Subject: [PATCH] finish extension console --- .../adminonconnect/AdminOnConnect.java | 1 + .../java/gearth/extensions/Extension.java | 44 ++++++++++++------- .../logger/ExtensionLoggerController.java | 6 +++ .../gearth/ui/extensions/logger/logger.css | 30 +++++++++++-- 4 files changed, 63 insertions(+), 18 deletions(-) diff --git a/Extensions/AdminOnConnect/src/main/java/extensions/adminonconnect/AdminOnConnect.java b/Extensions/AdminOnConnect/src/main/java/extensions/adminonconnect/AdminOnConnect.java index e36ca78..44ef20a 100644 --- a/Extensions/AdminOnConnect/src/main/java/extensions/adminonconnect/AdminOnConnect.java +++ b/Extensions/AdminOnConnect/src/main/java/extensions/adminonconnect/AdminOnConnect.java @@ -37,6 +37,7 @@ public class AdminOnConnect extends Extension { packet.replaceBoolean(14, true); done = true; + writeToConsole("Replaced user permissions"); } } } diff --git a/G-Earth/src/main/java/gearth/extensions/Extension.java b/G-Earth/src/main/java/gearth/extensions/Extension.java index 3f9be54..8e2ecec 100644 --- a/G-Earth/src/main/java/gearth/extensions/Extension.java +++ b/G-Earth/src/main/java/gearth/extensions/Extension.java @@ -160,7 +160,7 @@ public abstract class Extension implements IExtension { } else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.INIT) { initExtension(); - writeToConsole("green","Extension \"" + getInfoAnnotations().Title() + "\" succesfully initialized"); + writeToConsole("green","Extension \"" + getInfoAnnotations().Title() + "\" succesfully initialized", false); } else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.ONDOUBLECLICK) { onClick(); @@ -301,26 +301,40 @@ public abstract class Extension implements IExtension { return true; } - /** - * Write to the console in G-Earth - * @param s the text to be written - */ - public void writeToConsole(String s) { - HPacket packet = new HPacket(NetworkExtensionInfo.INCOMING_MESSAGES_IDS.EXTENSIONCONSOLELOG); - packet.appendString(s); - try { - writeToStream(packet.toBytes()); - } catch (IOException e) { - e.printStackTrace(); - } - } /** * Write to the console in G-Earth * @param s the text to be written */ + public void writeToConsole(String s) { + writeToConsole("black", s, true); + } + + /** + * Write to the console in G-Earth + * @param s the text to be written + * @param colorClass color of the text to be written + */ public void writeToConsole(String colorClass, String s) { - writeToConsole("[" + colorClass + "]" + s); + writeToConsole(colorClass, s, true); + } + + /** + * Write to the console in G-Earth + * @param s the text to be written + * @param colorClass color of the text to be written + * @param mentionTitle log the extension title as well + */ + private void writeToConsole(String colorClass, String s, boolean mentionTitle) { + String text = "[" + colorClass + "]" + (mentionTitle ? (getInfoAnnotations().Title() + " --> ") : "") + s; + + HPacket packet = new HPacket(NetworkExtensionInfo.INCOMING_MESSAGES_IDS.EXTENSIONCONSOLELOG); + packet.appendString(text); + try { + writeToStream(packet.toBytes()); + } catch (IOException e) { + e.printStackTrace(); + } } diff --git a/G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLoggerController.java b/G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLoggerController.java index 1a1540d..58f88a6 100644 --- a/G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLoggerController.java +++ b/G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLoggerController.java @@ -78,6 +78,12 @@ public class ExtensionLoggerController implements Initializable { text = s; } + if (text.contains(" --> ")) { + int index = text.indexOf(" --> ") + 5; + String extensionAnnouncement = text.substring(0, index); + text = text.substring(index); + elements.add(new Element(extensionAnnouncement, "black")); + } elements.add(new Element(text + "\n", classname.toLowerCase())); synchronized (appendOnLoad) { diff --git a/G-Earth/src/main/resources/gearth/ui/extensions/logger/logger.css b/G-Earth/src/main/resources/gearth/ui/extensions/logger/logger.css index a2afb71..6748947 100644 --- a/G-Earth/src/main/resources/gearth/ui/extensions/logger/logger.css +++ b/G-Earth/src/main/resources/gearth/ui/extensions/logger/logger.css @@ -11,8 +11,28 @@ -fx-fill: #ffff00; } +.orange { + -fx-fill: orange; +} + +.white { + -fx-fill: white; +} + +.purple { + -fx-fill: purple; +} + +.brown { + -fx-fill: brown; +} + +.pink { + -fx-fill: pink; +} + .red { - -fx-fill: #b22222; + -fx-fill: red; } .black { @@ -20,10 +40,10 @@ } .blue { - -fx-fill: #0066cc; + -fx-fill: blue; } -.lightblue { +.cyan { -fx-fill: cyan; } @@ -31,6 +51,10 @@ -fx-fill: #73b504; } +.darkergreen { + -fx-fill: green; +} + .dark { -fx-background-color: #000000; }