diff options
| author | 2018-11-28 10:54:38 +0100 | |
|---|---|---|
| committer | 2018-11-28 10:54:38 +0100 | |
| commit | ec03792398d1b78ab5af20dbf5a2d171871396ce (patch) | |
| tree | 8df37c2e47ba719c89a623b81cf85572915f5cf7 /src | |
| parent | refactors and bugfixes (diff) | |
| download | enigma-ec03792398d1b78ab5af20dbf5a2d171871396ce.tar.gz enigma-ec03792398d1b78ab5af20dbf5a2d171871396ce.tar.xz enigma-ec03792398d1b78ab5af20dbf5a2d171871396ce.zip | |
add line number coloring, bugfixes
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/cuchaz/enigma/Main.java | 2 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/config/Config.java | 12 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/config/Themes.java | 6 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/ClassSelector.java | 2 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/Gui.java | 43 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/GuiController.java | 3 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java | 4 |
7 files changed, 44 insertions, 28 deletions
diff --git a/src/main/java/cuchaz/enigma/Main.java b/src/main/java/cuchaz/enigma/Main.java index 8c5d813b..0f151934 100644 --- a/src/main/java/cuchaz/enigma/Main.java +++ b/src/main/java/cuchaz/enigma/Main.java | |||
| @@ -15,6 +15,7 @@ import cuchaz.enigma.config.Config; | |||
| 15 | import cuchaz.enigma.config.Themes; | 15 | import cuchaz.enigma.config.Themes; |
| 16 | import cuchaz.enigma.gui.Gui; | 16 | import cuchaz.enigma.gui.Gui; |
| 17 | 17 | ||
| 18 | import javax.swing.*; | ||
| 18 | import java.io.File; | 19 | import java.io.File; |
| 19 | import java.util.jar.JarFile; | 20 | import java.util.jar.JarFile; |
| 20 | 21 | ||
| @@ -22,7 +23,6 @@ public class Main { | |||
| 22 | 23 | ||
| 23 | public static void main(String[] args) throws Exception { | 24 | public static void main(String[] args) throws Exception { |
| 24 | Gui gui = new Gui(); | 25 | Gui gui = new Gui(); |
| 25 | Config.LookAndFeel.DEFAULT.setGlobalLAF(); | ||
| 26 | 26 | ||
| 27 | // parse command-line args | 27 | // parse command-line args |
| 28 | if (args.length >= 1) { | 28 | if (args.length >= 1) { |
diff --git a/src/main/java/cuchaz/enigma/config/Config.java b/src/main/java/cuchaz/enigma/config/Config.java index 034d077c..8c16c47b 100644 --- a/src/main/java/cuchaz/enigma/config/Config.java +++ b/src/main/java/cuchaz/enigma/config/Config.java | |||
| @@ -12,7 +12,7 @@ import java.lang.reflect.Type; | |||
| 12 | import java.nio.charset.Charset; | 12 | import java.nio.charset.Charset; |
| 13 | 13 | ||
| 14 | public class Config { | 14 | public class Config { |
| 15 | public enum LookAndFeel { | 15 | public enum LookAndFeel { |
| 16 | DEFAULT("Default"), | 16 | DEFAULT("Default"), |
| 17 | DARCULA("Dank"); | 17 | DARCULA("Dank"); |
| 18 | 18 | ||
| @@ -44,6 +44,9 @@ public class Config { | |||
| 44 | public void apply(Config config) { | 44 | public void apply(Config config) { |
| 45 | switch (this) { | 45 | switch (this) { |
| 46 | case DEFAULT: | 46 | case DEFAULT: |
| 47 | config.lineNumbersForeground = 0x333300; | ||
| 48 | config.lineNumbersBackground = 0xEEEEFF; | ||
| 49 | config.lineNumbersSelected = 0xCCCCEE; | ||
| 47 | config.obfuscatedColor = 0xFFDCDC; | 50 | config.obfuscatedColor = 0xFFDCDC; |
| 48 | config.obfuscatedHiglightAlpha = 1.0F; | 51 | config.obfuscatedHiglightAlpha = 1.0F; |
| 49 | config.obfuscatedColorOutline = 0xA05050; | 52 | config.obfuscatedColorOutline = 0xA05050; |
| @@ -66,6 +69,9 @@ public class Config { | |||
| 66 | break; | 69 | break; |
| 67 | case DARCULA: | 70 | case DARCULA: |
| 68 | //Based off colors found here: https://github.com/dracula/dracula-theme/ | 71 | //Based off colors found here: https://github.com/dracula/dracula-theme/ |
| 72 | config.lineNumbersForeground = 0xA4A4A3; | ||
| 73 | config.lineNumbersBackground = 0x313335; | ||
| 74 | config.lineNumbersSelected = 0x606366; | ||
| 69 | config.obfuscatedColor = 0xFF5555; | 75 | config.obfuscatedColor = 0xFF5555; |
| 70 | config.obfuscatedHiglightAlpha = 0.3F; | 76 | config.obfuscatedHiglightAlpha = 0.3F; |
| 71 | config.obfuscatedColorOutline = 0xFF5555; | 77 | config.obfuscatedColorOutline = 0xFF5555; |
| @@ -120,6 +126,10 @@ public class Config { | |||
| 120 | public Integer identifierColor; | 126 | public Integer identifierColor; |
| 121 | public Integer defaultTextColor; | 127 | public Integer defaultTextColor; |
| 122 | 128 | ||
| 129 | public Integer lineNumbersBackground; | ||
| 130 | public Integer lineNumbersSelected; | ||
| 131 | public Integer lineNumbersForeground; | ||
| 132 | |||
| 123 | public LookAndFeel lookAndFeel = LookAndFeel.DEFAULT; | 133 | public LookAndFeel lookAndFeel = LookAndFeel.DEFAULT; |
| 124 | 134 | ||
| 125 | private Config() { | 135 | private Config() { |
diff --git a/src/main/java/cuchaz/enigma/config/Themes.java b/src/main/java/cuchaz/enigma/config/Themes.java index b3132f24..8a4c3417 100644 --- a/src/main/java/cuchaz/enigma/config/Themes.java +++ b/src/main/java/cuchaz/enigma/config/Themes.java | |||
| @@ -33,9 +33,7 @@ public class Themes { | |||
| 33 | gui.obfuscatedHighlightPainter = new ObfuscatedHighlightPainter(); | 33 | gui.obfuscatedHighlightPainter = new ObfuscatedHighlightPainter(); |
| 34 | gui.deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); | 34 | gui.deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); |
| 35 | gui.otherHighlightPainter = new OtherHighlightPainter(); | 35 | gui.otherHighlightPainter = new OtherHighlightPainter(); |
| 36 | gui.editor.updateUI(); | 36 | gui.setEditorTheme(Config.getInstance().lookAndFeel); |
| 37 | gui.editor.setBackground(new Color(Config.getInstance().editorBackground)); | 37 | SwingUtilities.updateComponentTreeUI(gui.getFrame()); |
| 38 | SwingUtilities.updateComponentTreeUI(gui.getFrame()); | ||
| 39 | gui.getController().refreshCurrentClass(); | ||
| 40 | } | 38 | } |
| 41 | } | 39 | } |
diff --git a/src/main/java/cuchaz/enigma/gui/ClassSelector.java b/src/main/java/cuchaz/enigma/gui/ClassSelector.java index b032526f..974a7b2b 100644 --- a/src/main/java/cuchaz/enigma/gui/ClassSelector.java +++ b/src/main/java/cuchaz/enigma/gui/ClassSelector.java | |||
| @@ -24,9 +24,11 @@ import javax.swing.*; | |||
| 24 | import javax.swing.event.CellEditorListener; | 24 | import javax.swing.event.CellEditorListener; |
| 25 | import javax.swing.event.ChangeEvent; | 25 | import javax.swing.event.ChangeEvent; |
| 26 | import javax.swing.tree.*; | 26 | import javax.swing.tree.*; |
| 27 | import java.awt.*; | ||
| 27 | import java.awt.event.MouseAdapter; | 28 | import java.awt.event.MouseAdapter; |
| 28 | import java.awt.event.MouseEvent; | 29 | import java.awt.event.MouseEvent; |
| 29 | import java.util.*; | 30 | import java.util.*; |
| 31 | import java.util.List; | ||
| 30 | 32 | ||
| 31 | public class ClassSelector extends JTree { | 33 | public class ClassSelector extends JTree { |
| 32 | 34 | ||
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index 95fde436..06e78420 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -70,6 +70,7 @@ public class Gui { | |||
| 70 | public FileDialog exportJarFileChooser; | 70 | public FileDialog exportJarFileChooser; |
| 71 | private GuiController controller; | 71 | private GuiController controller; |
| 72 | private JFrame frame; | 72 | private JFrame frame; |
| 73 | public Config.LookAndFeel editorFeel; | ||
| 73 | public PanelEditor editor; | 74 | public PanelEditor editor; |
| 74 | private JPanel classesPanel; | 75 | private JPanel classesPanel; |
| 75 | private JSplitPane splitClasses; | 76 | private JSplitPane splitClasses; |
| @@ -84,13 +85,26 @@ public class Gui { | |||
| 84 | private JList<Token> tokens; | 85 | private JList<Token> tokens; |
| 85 | private JTabbedPane tabs; | 86 | private JTabbedPane tabs; |
| 86 | 87 | ||
| 87 | public Gui() { | 88 | public void setEditorTheme(Config.LookAndFeel feel) { |
| 89 | if (editor != null && (editorFeel == null || editorFeel != feel)) { | ||
| 90 | editor.updateUI(); | ||
| 91 | editor.setBackground(new Color(Config.getInstance().editorBackground)); | ||
| 92 | if (editorFeel != null) { | ||
| 93 | getController().refreshCurrentClass(); | ||
| 94 | } | ||
| 95 | |||
| 96 | editorFeel = feel; | ||
| 97 | } | ||
| 98 | } | ||
| 88 | 99 | ||
| 100 | public Gui() { | ||
| 89 | // init frame | 101 | // init frame |
| 90 | this.frame = new JFrame(Constants.NAME); | 102 | this.frame = new JFrame(Constants.NAME); |
| 91 | final Container pane = this.frame.getContentPane(); | 103 | final Container pane = this.frame.getContentPane(); |
| 92 | pane.setLayout(new BorderLayout()); | 104 | pane.setLayout(new BorderLayout()); |
| 93 | 105 | ||
| 106 | Config.getInstance().lookAndFeel.setGlobalLAF(); | ||
| 107 | |||
| 94 | if (Boolean.parseBoolean(System.getProperty("enigma.catchExceptions", "true"))) { | 108 | if (Boolean.parseBoolean(System.getProperty("enigma.catchExceptions", "true"))) { |
| 95 | // install a global exception handler to the event thread | 109 | // install a global exception handler to the event thread |
| 96 | CrashDialog.init(this.frame); | 110 | CrashDialog.init(this.frame); |
| @@ -127,11 +141,7 @@ public class Gui { | |||
| 127 | infoPanel.clearReference(); | 141 | infoPanel.clearReference(); |
| 128 | 142 | ||
| 129 | // init editor | 143 | // init editor |
| 130 | DefaultSyntaxKit.initKit(); | 144 | Themes.updateTheme(this); |
| 131 | DefaultSyntaxKit.registerContentType("text/minecraft", MinecraftSyntaxKit.class.getName()); | ||
| 132 | obfuscatedHighlightPainter = new ObfuscatedHighlightPainter(); | ||
| 133 | deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); | ||
| 134 | otherHighlightPainter = new OtherHighlightPainter(); | ||
| 135 | selectionHighlightPainter = new SelectionHighlightPainter(); | 145 | selectionHighlightPainter = new SelectionHighlightPainter(); |
| 136 | this.editor = new PanelEditor(this); | 146 | this.editor = new PanelEditor(this); |
| 137 | JScrollPane sourceScroller = new JScrollPane(this.editor); | 147 | JScrollPane sourceScroller = new JScrollPane(this.editor); |
| @@ -308,8 +318,6 @@ public class Gui { | |||
| 308 | panel.add(new JLabel("Loading...")); | 318 | panel.add(new JLabel("Loading...")); |
| 309 | this.classesPanel.add(panel); | 319 | this.classesPanel.add(panel); |
| 310 | 320 | ||
| 311 | Themes.updateTheme(this); | ||
| 312 | |||
| 313 | redraw(); | 321 | redraw(); |
| 314 | } | 322 | } |
| 315 | 323 | ||
| @@ -332,8 +340,6 @@ public class Gui { | |||
| 332 | this.menuBar.exportSourceMenu.setEnabled(true); | 340 | this.menuBar.exportSourceMenu.setEnabled(true); |
| 333 | this.menuBar.exportJarMenu.setEnabled(true); | 341 | this.menuBar.exportJarMenu.setEnabled(true); |
| 334 | 342 | ||
| 335 | Themes.updateTheme(this); | ||
| 336 | |||
| 337 | redraw(); | 343 | redraw(); |
| 338 | } | 344 | } |
| 339 | 345 | ||
| @@ -357,8 +363,6 @@ public class Gui { | |||
| 357 | this.menuBar.exportSourceMenu.setEnabled(false); | 363 | this.menuBar.exportSourceMenu.setEnabled(false); |
| 358 | this.menuBar.exportJarMenu.setEnabled(false); | 364 | this.menuBar.exportJarMenu.setEnabled(false); |
| 359 | 365 | ||
| 360 | Themes.updateTheme(this); | ||
| 361 | |||
| 362 | redraw(); | 366 | redraw(); |
| 363 | } | 367 | } |
| 364 | 368 | ||
| @@ -489,13 +493,14 @@ public class Gui { | |||
| 489 | private void addNameValue(JPanel container, String name, String value) { | 493 | private void addNameValue(JPanel container, String name, String value) { |
| 490 | JPanel panel = new JPanel(); | 494 | JPanel panel = new JPanel(); |
| 491 | panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); | 495 | panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); |
| 492 | container.add(panel); | ||
| 493 | 496 | ||
| 494 | JLabel label = new JLabel(name + ":", JLabel.RIGHT); | 497 | JLabel label = new JLabel(name + ":", JLabel.RIGHT); |
| 495 | label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); | 498 | label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); |
| 496 | panel.add(label); | 499 | panel.add(label); |
| 497 | 500 | ||
| 498 | panel.add(Utils.unboldLabel(new JLabel(value, JLabel.LEFT))); | 501 | panel.add(Utils.unboldLabel(new JLabel(value, JLabel.LEFT))); |
| 502 | |||
| 503 | container.add(panel); | ||
| 499 | } | 504 | } |
| 500 | 505 | ||
| 501 | private JComboBox<Mappings.EntryModifier> addModifierComboBox(JPanel container, String name, Entry entry) { | 506 | private JComboBox<Mappings.EntryModifier> addModifierComboBox(JPanel container, String name, Entry entry) { |
| @@ -503,7 +508,6 @@ public class Gui { | |||
| 503 | return null; | 508 | return null; |
| 504 | JPanel panel = new JPanel(); | 509 | JPanel panel = new JPanel(); |
| 505 | panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); | 510 | panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); |
| 506 | container.add(panel); | ||
| 507 | JLabel label = new JLabel(name + ":", JLabel.RIGHT); | 511 | JLabel label = new JLabel(name + ":", JLabel.RIGHT); |
| 508 | label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); | 512 | label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); |
| 509 | panel.add(label); | 513 | panel.add(label); |
| @@ -513,6 +517,9 @@ public class Gui { | |||
| 513 | combo.setSelectedIndex(getController().getDeobfuscator().getModifier(entry).ordinal()); | 517 | combo.setSelectedIndex(getController().getDeobfuscator().getModifier(entry).ordinal()); |
| 514 | combo.addItemListener(getController()::modifierChange); | 518 | combo.addItemListener(getController()::modifierChange); |
| 515 | panel.add(combo); | 519 | panel.add(combo); |
| 520 | |||
| 521 | container.add(panel); | ||
| 522 | |||
| 516 | return combo; | 523 | return combo; |
| 517 | } | 524 | } |
| 518 | 525 | ||
| @@ -607,8 +614,6 @@ public class Gui { | |||
| 607 | else | 614 | else |
| 608 | text.selectAll(); | 615 | text.selectAll(); |
| 609 | 616 | ||
| 610 | Themes.updateTheme(this); | ||
| 611 | |||
| 612 | redraw(); | 617 | redraw(); |
| 613 | } | 618 | } |
| 614 | 619 | ||
| @@ -665,8 +670,6 @@ public class Gui { | |||
| 665 | 670 | ||
| 666 | tabs.setSelectedIndex(0); | 671 | tabs.setSelectedIndex(0); |
| 667 | 672 | ||
| 668 | Themes.updateTheme(this); | ||
| 669 | |||
| 670 | redraw(); | 673 | redraw(); |
| 671 | } | 674 | } |
| 672 | 675 | ||
| @@ -697,8 +700,6 @@ public class Gui { | |||
| 697 | 700 | ||
| 698 | tabs.setSelectedIndex(1); | 701 | tabs.setSelectedIndex(1); |
| 699 | 702 | ||
| 700 | Themes.updateTheme(this); | ||
| 701 | |||
| 702 | redraw(); | 703 | redraw(); |
| 703 | } | 704 | } |
| 704 | 705 | ||
| @@ -720,8 +721,6 @@ public class Gui { | |||
| 720 | 721 | ||
| 721 | tabs.setSelectedIndex(2); | 722 | tabs.setSelectedIndex(2); |
| 722 | 723 | ||
| 723 | Themes.updateTheme(this); | ||
| 724 | |||
| 725 | redraw(); | 724 | redraw(); |
| 726 | } | 725 | } |
| 727 | 726 | ||
diff --git a/src/main/java/cuchaz/enigma/gui/GuiController.java b/src/main/java/cuchaz/enigma/gui/GuiController.java index 653f0244..6e15bb02 100644 --- a/src/main/java/cuchaz/enigma/gui/GuiController.java +++ b/src/main/java/cuchaz/enigma/gui/GuiController.java | |||
| @@ -16,6 +16,8 @@ import com.google.common.collect.Queues; | |||
| 16 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; | 16 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; |
| 17 | import cuchaz.enigma.Deobfuscator; | 17 | import cuchaz.enigma.Deobfuscator; |
| 18 | import cuchaz.enigma.analysis.*; | 18 | import cuchaz.enigma.analysis.*; |
| 19 | import cuchaz.enigma.config.Config; | ||
| 20 | import cuchaz.enigma.config.Themes; | ||
| 19 | import cuchaz.enigma.gui.dialog.ProgressDialog; | 21 | import cuchaz.enigma.gui.dialog.ProgressDialog; |
| 20 | import cuchaz.enigma.mapping.*; | 22 | import cuchaz.enigma.mapping.*; |
| 21 | import cuchaz.enigma.mapping.entry.ClassEntry; | 23 | import cuchaz.enigma.mapping.entry.ClassEntry; |
| @@ -353,6 +355,7 @@ public class GuiController { | |||
| 353 | otherTokens.add(token); | 355 | otherTokens.add(token); |
| 354 | } | 356 | } |
| 355 | } | 357 | } |
| 358 | gui.setEditorTheme(Config.getInstance().lookAndFeel); | ||
| 356 | gui.setHighlightedTokens(obfuscatedTokens, deobfuscatedTokens, otherTokens); | 359 | gui.setHighlightedTokens(obfuscatedTokens, deobfuscatedTokens, otherTokens); |
| 357 | }).start(); | 360 | }).start(); |
| 358 | } | 361 | } |
diff --git a/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java b/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java index 96327abd..d9fcee53 100644 --- a/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java +++ b/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | package cuchaz.enigma.gui; | 1 | package cuchaz.enigma.gui; |
| 2 | 2 | ||
| 3 | import cuchaz.enigma.config.Config; | 3 | import cuchaz.enigma.config.Config; |
| 4 | import de.sciss.syntaxpane.components.LineNumbersRuler; | ||
| 4 | import de.sciss.syntaxpane.syntaxkits.JavaSyntaxKit; | 5 | import de.sciss.syntaxpane.syntaxkits.JavaSyntaxKit; |
| 5 | import de.sciss.syntaxpane.util.Configuration; | 6 | import de.sciss.syntaxpane.util.Configuration; |
| 6 | 7 | ||
| @@ -29,6 +30,9 @@ public class MinecraftSyntaxKit extends JavaSyntaxKit { | |||
| 29 | configuration.put("Style.TYPE2", Config.getInstance().typeColor + ", 1"); | 30 | configuration.put("Style.TYPE2", Config.getInstance().typeColor + ", 1"); |
| 30 | configuration.put("Style.IDENTIFIER", Config.getInstance().identifierColor + ", 0"); | 31 | configuration.put("Style.IDENTIFIER", Config.getInstance().identifierColor + ", 0"); |
| 31 | configuration.put("Style.DEFAULT", Config.getInstance().defaultTextColor + ", 0"); | 32 | configuration.put("Style.DEFAULT", Config.getInstance().defaultTextColor + ", 0"); |
| 33 | configuration.put(LineNumbersRuler.PROPERTY_BACKGROUND, Config.getInstance().lineNumbersBackground + ""); | ||
| 34 | configuration.put(LineNumbersRuler.PROPERTY_FOREGROUND, Config.getInstance().lineNumbersForeground + ""); | ||
| 35 | configuration.put(LineNumbersRuler.PROPERTY_CURRENT_BACK, Config.getInstance().lineNumbersSelected + ""); | ||
| 32 | configuration.put("RightMarginColumn", "999"); //No need to have a right margin, if someone wants it add a config | 36 | configuration.put("RightMarginColumn", "999"); //No need to have a right margin, if someone wants it add a config |
| 33 | } | 37 | } |
| 34 | 38 | ||