diff options
| author | 2017-06-04 16:36:21 +0100 | |
|---|---|---|
| committer | 2017-06-04 17:36:21 +0200 | |
| commit | e35b611da3c068bfea344be9a90c79fd68fac4ff (patch) | |
| tree | f0bf3d9a2fd6ebef0a38e771f5799c249cd81b92 /src/main/java/cuchaz/enigma/gui | |
| parent | Remove the converter + some reorganization (diff) | |
| download | enigma-fork-e35b611da3c068bfea344be9a90c79fd68fac4ff.tar.gz enigma-fork-e35b611da3c068bfea344be9a90c79fd68fac4ff.tar.xz enigma-fork-e35b611da3c068bfea344be9a90c79fd68fac4ff.zip | |
Add support for custom themes (#59)
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui')
6 files changed, 55 insertions, 9 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index 77065a9..86c97aa 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -15,6 +15,7 @@ import com.google.common.collect.Lists; | |||
| 15 | import cuchaz.enigma.Constants; | 15 | import cuchaz.enigma.Constants; |
| 16 | import cuchaz.enigma.ExceptionIgnorer; | 16 | import cuchaz.enigma.ExceptionIgnorer; |
| 17 | import cuchaz.enigma.analysis.*; | 17 | import cuchaz.enigma.analysis.*; |
| 18 | import cuchaz.enigma.config.Config; | ||
| 18 | import cuchaz.enigma.gui.dialog.CrashDialog; | 19 | import cuchaz.enigma.gui.dialog.CrashDialog; |
| 19 | import cuchaz.enigma.gui.elements.MenuBar; | 20 | import cuchaz.enigma.gui.elements.MenuBar; |
| 20 | import cuchaz.enigma.gui.elements.PopupMenuBar; | 21 | import cuchaz.enigma.gui.elements.PopupMenuBar; |
| @@ -47,10 +48,8 @@ import java.awt.*; | |||
| 47 | import java.awt.event.*; | 48 | import java.awt.event.*; |
| 48 | import java.io.File; | 49 | import java.io.File; |
| 49 | import java.io.IOException; | 50 | import java.io.IOException; |
| 50 | import java.util.Collection; | 51 | import java.util.*; |
| 51 | import java.util.Collections; | ||
| 52 | import java.util.List; | 52 | import java.util.List; |
| 53 | import java.util.Vector; | ||
| 54 | import java.util.function.Function; | 53 | import java.util.function.Function; |
| 55 | 54 | ||
| 56 | public class Gui { | 55 | public class Gui { |
| @@ -127,13 +126,15 @@ public class Gui { | |||
| 127 | 126 | ||
| 128 | // init editor | 127 | // init editor |
| 129 | DefaultSyntaxKit.initKit(); | 128 | DefaultSyntaxKit.initKit(); |
| 129 | DefaultSyntaxKit.registerContentType("text/minecraft", MinecraftSyntaxKit.class.getName()); | ||
| 130 | obfuscatedHighlightPainter = new ObfuscatedHighlightPainter(); | 130 | obfuscatedHighlightPainter = new ObfuscatedHighlightPainter(); |
| 131 | deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); | 131 | deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); |
| 132 | otherHighlightPainter = new OtherHighlightPainter(); | 132 | otherHighlightPainter = new OtherHighlightPainter(); |
| 133 | selectionHighlightPainter = new SelectionHighlightPainter(); | 133 | selectionHighlightPainter = new SelectionHighlightPainter(); |
| 134 | this.editor = new PanelEditor(this); | 134 | this.editor = new PanelEditor(this); |
| 135 | JScrollPane sourceScroller = new JScrollPane(this.editor); | 135 | JScrollPane sourceScroller = new JScrollPane(this.editor); |
| 136 | this.editor.setContentType("text/java"); | 136 | this.editor.setContentType("text/minecraft"); |
| 137 | this.editor.setBackground(new Color(Config.INSTANCE.editorBackground)); | ||
| 137 | DefaultSyntaxKit kit = (DefaultSyntaxKit) this.editor.getEditorKit(); | 138 | DefaultSyntaxKit kit = (DefaultSyntaxKit) this.editor.getEditorKit(); |
| 138 | kit.toggleComponent(this.editor, "de.sciss.syntaxpane.components.TokenMarker"); | 139 | kit.toggleComponent(this.editor, "de.sciss.syntaxpane.components.TokenMarker"); |
| 139 | 140 | ||
diff --git a/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java b/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java new file mode 100644 index 0000000..41de035 --- /dev/null +++ b/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | package cuchaz.enigma.gui; | ||
| 2 | |||
| 3 | import cuchaz.enigma.config.Config; | ||
| 4 | import de.sciss.syntaxpane.syntaxkits.JavaSyntaxKit; | ||
| 5 | import de.sciss.syntaxpane.util.Configuration; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * Created by Mark on 04/06/2017. | ||
| 9 | */ | ||
| 10 | public class MinecraftSyntaxKit extends JavaSyntaxKit { | ||
| 11 | |||
| 12 | public Configuration configuration = null; | ||
| 13 | |||
| 14 | @Override | ||
| 15 | public Configuration getConfig() { | ||
| 16 | if(configuration == null){ | ||
| 17 | initConfig(super.getConfig(JavaSyntaxKit.class)); | ||
| 18 | } | ||
| 19 | return configuration; | ||
| 20 | } | ||
| 21 | |||
| 22 | public void initConfig(Configuration baseConfig){ | ||
| 23 | configuration = baseConfig; | ||
| 24 | //See de.sciss.syntaxpane.TokenType | ||
| 25 | configuration.put("Style.KEYWORD", Config.INSTANCE.highlightColor + ", 0"); | ||
| 26 | configuration.put("Style.KEYWORD2", Config.INSTANCE.highlightColor + ", 3"); | ||
| 27 | configuration.put("Style.STRING", Config.INSTANCE.stringColor + ", 0"); | ||
| 28 | configuration.put("Style.STRING2", Config.INSTANCE.stringColor + ", 1"); | ||
| 29 | configuration.put("Style.NUMBER", Config.INSTANCE.numberColor + ", 1"); | ||
| 30 | configuration.put("Style.OPERATOR", Config.INSTANCE.operatorColor + ", 0"); | ||
| 31 | configuration.put("Style.DELIMITER", Config.INSTANCE.delimiterColor + ", 1"); | ||
| 32 | configuration.put("Style.TYPE", Config.INSTANCE.typeColor + ", 2"); | ||
| 33 | configuration.put("Style.TYPE2", Config.INSTANCE.typeColor + ", 1"); | ||
| 34 | configuration.put("Style.IDENTIFIER", Config.INSTANCE.identifierColor + ", 0"); | ||
| 35 | configuration.put("Style.DEFAULT", Config.INSTANCE.defaultTextColor + ", 0"); | ||
| 36 | configuration.put("RightMarginColumn", "999"); //No need to have a right margin, if someone wants it add a config | ||
| 37 | } | ||
| 38 | } | ||
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/BoxHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/BoxHighlightPainter.java index 0f64927..976c215 100644 --- a/src/main/java/cuchaz/enigma/gui/highlight/BoxHighlightPainter.java +++ b/src/main/java/cuchaz/enigma/gui/highlight/BoxHighlightPainter.java | |||
| @@ -58,4 +58,9 @@ public abstract class BoxHighlightPainter implements Highlighter.HighlightPainte | |||
| 58 | g.setColor(this.borderColor); | 58 | g.setColor(this.borderColor); |
| 59 | g.drawRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4); | 59 | g.drawRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4); |
| 60 | } | 60 | } |
| 61 | |||
| 62 | protected static Color getColor(int rgb, float alpha){ | ||
| 63 | Color baseColor = new Color(rgb); | ||
| 64 | return new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), (int)(255 * alpha)); | ||
| 65 | } | ||
| 61 | } | 66 | } |
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java index a2d2884..ef651e3 100644 --- a/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java +++ b/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java | |||
| @@ -11,11 +11,11 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.gui.highlight; | 12 | package cuchaz.enigma.gui.highlight; |
| 13 | 13 | ||
| 14 | import java.awt.*; | 14 | import cuchaz.enigma.config.Config; |
| 15 | 15 | ||
| 16 | public class DeobfuscatedHighlightPainter extends BoxHighlightPainter { | 16 | public class DeobfuscatedHighlightPainter extends BoxHighlightPainter { |
| 17 | 17 | ||
| 18 | public DeobfuscatedHighlightPainter() { | 18 | public DeobfuscatedHighlightPainter() { |
| 19 | super(new Color(220, 255, 220), new Color(80, 160, 80)); | 19 | super(getColor(Config.INSTANCE.deobfuscatedColor, Config.INSTANCE.deobfuscatedHiglightAlpha), getColor(Config.INSTANCE.deobfuscatedColorOutline, Config.INSTANCE.deobfuscatedOutlineAlpha)); |
| 20 | } | 20 | } |
| 21 | } | 21 | } |
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java index 0947d4b..7887906 100644 --- a/src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java +++ b/src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java | |||
| @@ -11,11 +11,13 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.gui.highlight; | 12 | package cuchaz.enigma.gui.highlight; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.config.Config; | ||
| 15 | |||
| 14 | import java.awt.*; | 16 | import java.awt.*; |
| 15 | 17 | ||
| 16 | public class ObfuscatedHighlightPainter extends BoxHighlightPainter { | 18 | public class ObfuscatedHighlightPainter extends BoxHighlightPainter { |
| 17 | 19 | ||
| 18 | public ObfuscatedHighlightPainter() { | 20 | public ObfuscatedHighlightPainter() { |
| 19 | super(new Color(255, 220, 220), new Color(160, 80, 80)); | 21 | super(getColor(Config.INSTANCE.obfuscatedColor, Config.INSTANCE.obfuscatedHiglightAlpha), getColor(Config.INSTANCE.obfuscatedColorOutline, Config.INSTANCE.obfuscatedOutlineAlpha)); |
| 20 | } | 22 | } |
| 21 | } | 23 | } |
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java index 74e7273..c5154e1 100644 --- a/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java +++ b/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java | |||
| @@ -11,11 +11,11 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.gui.highlight; | 12 | package cuchaz.enigma.gui.highlight; |
| 13 | 13 | ||
| 14 | import java.awt.*; | 14 | import cuchaz.enigma.config.Config; |
| 15 | 15 | ||
| 16 | public class OtherHighlightPainter extends BoxHighlightPainter { | 16 | public class OtherHighlightPainter extends BoxHighlightPainter { |
| 17 | 17 | ||
| 18 | public OtherHighlightPainter() { | 18 | public OtherHighlightPainter() { |
| 19 | super(null, new Color(180, 180, 180)); | 19 | super(null, getColor(Config.INSTANCE.otherColorOutline, Config.INSTANCE.otherOutlineAlpha)); |
| 20 | } | 20 | } |
| 21 | } | 21 | } |