diff options
| author | 2017-06-07 08:29:37 +0100 | |
|---|---|---|
| committer | 2017-06-07 08:29:37 +0100 | |
| commit | ba5ffc258f6d58bf9d01226baea016db10cfd811 (patch) | |
| tree | 4fd3b77e619198a47d95ee55a742c8057dea591a | |
| parent | Add support for custom themes (#59) (diff) | |
| download | enigma-ba5ffc258f6d58bf9d01226baea016db10cfd811.tar.gz enigma-ba5ffc258f6d58bf9d01226baea016db10cfd811.tar.xz enigma-ba5ffc258f6d58bf9d01226baea016db10cfd811.zip | |
Added theme switcher + dark theme (#60)
* Initial work on the color config
* Save and read config from file.+
* Allow changing the editor colors
* Remove the right margin
* Move config to the user's home dir
* Use Guava instead of Apache commons
* Add runtime theme switching, includes example "dark" theme.
* Rename dark theme as requested
* Small clean up
* Include suggestions from @Thog
9 files changed, 226 insertions, 88 deletions
diff --git a/src/main/java/cuchaz/enigma/Main.java b/src/main/java/cuchaz/enigma/Main.java index 9f34cd3c..688a55e0 100644 --- a/src/main/java/cuchaz/enigma/Main.java +++ b/src/main/java/cuchaz/enigma/Main.java | |||
| @@ -21,8 +21,7 @@ import java.util.jar.JarFile; | |||
| 21 | public class Main { | 21 | public class Main { |
| 22 | 22 | ||
| 23 | public static void main(String[] args) throws Exception { | 23 | public static void main(String[] args) throws Exception { |
| 24 | Config.loadConfig(); | 24 | if (Config.getInstance().useSystemLAF) |
| 25 | if (Config.INSTANCE.useSystemLAF) | ||
| 26 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); | 25 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
| 27 | Gui gui = new Gui(); | 26 | Gui gui = new Gui(); |
| 28 | 27 | ||
diff --git a/src/main/java/cuchaz/enigma/config/Config.java b/src/main/java/cuchaz/enigma/config/Config.java index 307b221d..87ef3531 100644 --- a/src/main/java/cuchaz/enigma/config/Config.java +++ b/src/main/java/cuchaz/enigma/config/Config.java | |||
| @@ -8,65 +8,109 @@ import java.io.IOException; | |||
| 8 | import java.lang.reflect.Type; | 8 | import java.lang.reflect.Type; |
| 9 | import java.nio.charset.Charset; | 9 | import java.nio.charset.Charset; |
| 10 | 10 | ||
| 11 | /** | ||
| 12 | * Created by Mark on 04/06/2017. | ||
| 13 | */ | ||
| 14 | public class Config { | 11 | public class Config { |
| 15 | 12 | ||
| 16 | public static Config INSTANCE = new Config(); | 13 | private static final File DIR_HOME = new File(System.getProperty("user.home")); |
| 17 | 14 | private static final File ENIGMA_DIR = new File(DIR_HOME, ".enigma"); | |
| 18 | public Integer obfuscatedColor = 0xFFDCDC; | 15 | private static final File CONFIG_FILE = new File(ENIGMA_DIR, "config.json"); |
| 19 | public float obfuscatedHiglightAlpha = 1.0F; | 16 | private static final Config INSTANCE = new Config(); |
| 20 | public Integer obfuscatedColorOutline = 0xA05050; | 17 | |
| 21 | public float obfuscatedOutlineAlpha = 1.0F; | 18 | private final transient Gson gson; // transient to exclude it from being exposed |
| 22 | 19 | ||
| 23 | public Integer deobfuscatedColor = 0xDCFFDC; | 20 | public Integer obfuscatedColor; |
| 24 | public float deobfuscatedHiglightAlpha = 1.0F; | 21 | public float obfuscatedHiglightAlpha; |
| 25 | public Integer deobfuscatedColorOutline = 0x50A050; | 22 | public Integer obfuscatedColorOutline; |
| 26 | public float deobfuscatedOutlineAlpha = 1.0F; | 23 | public float obfuscatedOutlineAlpha; |
| 27 | 24 | public Integer deobfuscatedColor; | |
| 28 | public Integer otherColorOutline = 0xB4B4B4; | 25 | public float deobfuscatedHiglightAlpha; |
| 29 | public float otherOutlineAlpha = 1.0F; | 26 | public Integer deobfuscatedColorOutline; |
| 30 | 27 | public float deobfuscatedOutlineAlpha; | |
| 31 | //Defaults found here: https://github.com/Sciss/SyntaxPane/blob/122da367ff7a5d31627a70c62a48a9f0f4f85a0a/src/main/resources/de/sciss/syntaxpane/defaultsyntaxkit/config.properties#L139 | 28 | public Integer otherColorOutline; |
| 32 | public Integer editorBackground = 0xFFFFFF; | 29 | public float otherOutlineAlpha; |
| 33 | public Integer highlightColor = 0x3333EE; | 30 | |
| 34 | public Integer stringColor = 0xCC6600; | 31 | //Defaults found here: https://github.com/Sciss/SyntaxPane/blob/122da367ff7a5d31627a70c62a48a9f0f4f85a0a/src/main/resources/de/sciss/syntaxpane/defaultsyntaxkit/config.properties#L139 |
| 35 | public Integer numberColor = 0x999933; | 32 | public Integer editorBackground; |
| 36 | public Integer operatorColor = 0x000000; | 33 | public Integer highlightColor; |
| 37 | public Integer delimiterColor = 0x000000; | 34 | |
| 38 | public Integer typeColor = 0x000000; | 35 | public Integer stringColor; |
| 39 | public Integer identifierColor = 0x000000; | 36 | public Integer numberColor; |
| 40 | public Integer defaultTextColor = 0x000000; | 37 | public Integer operatorColor; |
| 41 | 38 | public Integer delimiterColor; | |
| 42 | public boolean useSystemLAF = true; | 39 | public Integer typeColor; |
| 43 | 40 | public Integer identifierColor; | |
| 44 | public static void loadConfig() throws IOException { | 41 | public Integer defaultTextColor; |
| 45 | Gson gson = new GsonBuilder().registerTypeAdapter(Integer.class, new IntSerializer()).registerTypeAdapter(Integer.class, new IntDeserializer()).setPrettyPrinting().create(); | 42 | |
| 46 | File dirHome = new File(System.getProperty("user.home")); | 43 | public boolean useSystemLAF = true; |
| 47 | File engimaDir = new File(dirHome, ".enigma"); | 44 | |
| 48 | if(!engimaDir.exists()){ | 45 | private Config() { |
| 49 | engimaDir.mkdirs(); | 46 | gson = new GsonBuilder() |
| 50 | } | 47 | .registerTypeAdapter(Integer.class, new IntSerializer()) |
| 51 | File configFile = new File(engimaDir, "config.json"); | 48 | .registerTypeAdapter(Integer.class, new IntDeserializer()) |
| 52 | if (configFile.exists()) { | 49 | .registerTypeAdapter(Config.class, (InstanceCreator<Config>) type -> this) |
| 53 | INSTANCE = gson.fromJson(Files.toString(configFile, Charset.defaultCharset()), Config.class); | 50 | .setPrettyPrinting() |
| 54 | } else { | 51 | .create(); |
| 55 | Files.touch(configFile); | 52 | try { |
| 56 | } | 53 | this.loadConfig(); |
| 57 | Files.write(gson.toJson(INSTANCE), configFile, Charset.defaultCharset()); | 54 | } catch (IOException ignored) { |
| 58 | } | 55 | try { |
| 59 | 56 | this.reset(); | |
| 60 | private static class IntSerializer implements JsonSerializer<Integer> { | 57 | } catch (IOException ignored1) { |
| 61 | public JsonElement serialize(Integer src, Type typeOfSrc, JsonSerializationContext context) { | 58 | } |
| 62 | return new JsonPrimitive("#" + Integer.toHexString(src).toUpperCase()); | 59 | } |
| 63 | } | 60 | } |
| 64 | } | 61 | |
| 65 | 62 | public void loadConfig() throws IOException { | |
| 66 | private static class IntDeserializer implements JsonDeserializer<Integer> { | 63 | if (!ENIGMA_DIR.exists()) ENIGMA_DIR.mkdirs(); |
| 67 | public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { | 64 | File configFile = new File(ENIGMA_DIR, "config.json"); |
| 68 | return (int) Long.parseLong(json.getAsString().replace("#", ""), 16); | 65 | if (configFile.exists()) gson.fromJson(Files.toString(configFile, Charset.defaultCharset()), Config.class); |
| 69 | } | 66 | else { |
| 70 | } | 67 | this.reset(); |
| 71 | 68 | Files.touch(configFile); | |
| 72 | } | 69 | } |
| 70 | saveConfig(); | ||
| 71 | } | ||
| 72 | |||
| 73 | public void saveConfig() throws IOException { | ||
| 74 | Files.write(gson.toJson(this), CONFIG_FILE, Charset.defaultCharset()); | ||
| 75 | } | ||
| 76 | |||
| 77 | public void reset() throws IOException { | ||
| 78 | this.obfuscatedColor = 0xFFDCDC; | ||
| 79 | this.obfuscatedHiglightAlpha = 1.0F; | ||
| 80 | this.obfuscatedColorOutline = 0xA05050; | ||
| 81 | this.obfuscatedOutlineAlpha = 1.0F; | ||
| 82 | this.deobfuscatedColor = 0xDCFFDC; | ||
| 83 | this.deobfuscatedHiglightAlpha = 1.0F; | ||
| 84 | this.deobfuscatedColorOutline = 0x50A050; | ||
| 85 | this.deobfuscatedOutlineAlpha = 1.0F; | ||
| 86 | this.otherColorOutline = 0xB4B4B4; | ||
| 87 | this.otherOutlineAlpha = 1.0F; | ||
| 88 | this.editorBackground = 0xFFFFFF; | ||
| 89 | this.highlightColor = 0x3333EE; | ||
| 90 | this.stringColor = 0xCC6600; | ||
| 91 | this.numberColor = 0x999933; | ||
| 92 | this.operatorColor = 0x000000; | ||
| 93 | this.delimiterColor = 0x000000; | ||
| 94 | this.typeColor = 0x000000; | ||
| 95 | this.identifierColor = 0x000000; | ||
| 96 | this.defaultTextColor = 0x000000; | ||
| 97 | this.useSystemLAF = true; | ||
| 98 | this.saveConfig(); | ||
| 99 | } | ||
| 100 | |||
| 101 | private static class IntSerializer implements JsonSerializer<Integer> { | ||
| 102 | public JsonElement serialize(Integer src, Type typeOfSrc, JsonSerializationContext context) { | ||
| 103 | return new JsonPrimitive("#" + Integer.toHexString(src).toUpperCase()); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | private static class IntDeserializer implements JsonDeserializer<Integer> { | ||
| 108 | public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { | ||
| 109 | return (int) Long.parseLong(json.getAsString().replace("#", ""), 16); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | public static Config getInstance() { | ||
| 114 | return INSTANCE; | ||
| 115 | } | ||
| 116 | } \ No newline at end of file | ||
diff --git a/src/main/java/cuchaz/enigma/config/Themes.java b/src/main/java/cuchaz/enigma/config/Themes.java new file mode 100644 index 00000000..79c245b4 --- /dev/null +++ b/src/main/java/cuchaz/enigma/config/Themes.java | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | package cuchaz.enigma.config; | ||
| 2 | |||
| 3 | import cuchaz.enigma.gui.Gui; | ||
| 4 | import cuchaz.enigma.gui.MinecraftSyntaxKit; | ||
| 5 | import cuchaz.enigma.gui.highlight.DeobfuscatedHighlightPainter; | ||
| 6 | import cuchaz.enigma.gui.highlight.ObfuscatedHighlightPainter; | ||
| 7 | import cuchaz.enigma.gui.highlight.OtherHighlightPainter; | ||
| 8 | import de.sciss.syntaxpane.DefaultSyntaxKit; | ||
| 9 | |||
| 10 | import java.awt.*; | ||
| 11 | import java.io.IOException; | ||
| 12 | |||
| 13 | public class Themes { | ||
| 14 | |||
| 15 | public static void setDefault(Gui gui) { | ||
| 16 | //TODO set to default | ||
| 17 | try { | ||
| 18 | Config.getInstance().reset(); | ||
| 19 | } catch (IOException e) { | ||
| 20 | e.printStackTrace(); | ||
| 21 | } | ||
| 22 | updateTheme(gui); | ||
| 23 | } | ||
| 24 | |||
| 25 | public static void setDark(Gui gui) { | ||
| 26 | //Based off colors found here: https://github.com/dracula/dracula-theme/ | ||
| 27 | Config.getInstance().obfuscatedColor = 0xFF5555; | ||
| 28 | Config.getInstance().obfuscatedHiglightAlpha = 0.3F; | ||
| 29 | Config.getInstance().obfuscatedColorOutline = 0xFF5555; | ||
| 30 | Config.getInstance().obfuscatedOutlineAlpha = 0.5F; | ||
| 31 | Config.getInstance().deobfuscatedColor = 0x50FA7B; | ||
| 32 | Config.getInstance().deobfuscatedHiglightAlpha = 0.3F; | ||
| 33 | Config.getInstance().deobfuscatedColorOutline = 0x50FA7B; | ||
| 34 | Config.getInstance().deobfuscatedOutlineAlpha = 0.5F; | ||
| 35 | Config.getInstance().otherColorOutline = 0xB4B4B4; | ||
| 36 | Config.getInstance().otherOutlineAlpha = 0.0F; | ||
| 37 | Config.getInstance().editorBackground = 0x282A36; | ||
| 38 | Config.getInstance().highlightColor = 0xFF79C6; | ||
| 39 | Config.getInstance().stringColor = 0xF1FA8C; | ||
| 40 | Config.getInstance().numberColor = 0xBD93F9; | ||
| 41 | Config.getInstance().operatorColor = 0xF8F8F2; | ||
| 42 | Config.getInstance().delimiterColor = 0xF8F8F2; | ||
| 43 | Config.getInstance().typeColor = 0xF8F8F2; | ||
| 44 | Config.getInstance().identifierColor = 0xF8F8F2; | ||
| 45 | Config.getInstance().defaultTextColor = 0xF8F8F2; | ||
| 46 | updateTheme(gui); | ||
| 47 | } | ||
| 48 | |||
| 49 | public static void updateTheme(Gui gui) { | ||
| 50 | try { | ||
| 51 | Config.getInstance().saveConfig(); | ||
| 52 | } catch (IOException e) { | ||
| 53 | e.printStackTrace(); | ||
| 54 | } | ||
| 55 | MinecraftSyntaxKit.invalidate(); | ||
| 56 | DefaultSyntaxKit.initKit(); | ||
| 57 | DefaultSyntaxKit.registerContentType("text/minecraft", MinecraftSyntaxKit.class.getName()); | ||
| 58 | gui.obfuscatedHighlightPainter = new ObfuscatedHighlightPainter(); | ||
| 59 | gui.deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); | ||
| 60 | gui.otherHighlightPainter = new OtherHighlightPainter(); | ||
| 61 | gui.editor.updateUI(); | ||
| 62 | gui.editor.setBackground(new Color(Config.getInstance().editorBackground)); | ||
| 63 | gui.getController().refreshCurrentClass(); | ||
| 64 | } | ||
| 65 | |||
| 66 | } | ||
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index 86c97aa3..4a891cf4 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -68,13 +68,13 @@ public class Gui { | |||
| 68 | public JFileChooser exportJarFileChooser; | 68 | public JFileChooser exportJarFileChooser; |
| 69 | private GuiController controller; | 69 | private GuiController controller; |
| 70 | private JFrame frame; | 70 | private JFrame frame; |
| 71 | private PanelEditor editor; | 71 | public PanelEditor editor; |
| 72 | private JPanel classesPanel; | 72 | private JPanel classesPanel; |
| 73 | private JSplitPane splitClasses; | 73 | private JSplitPane splitClasses; |
| 74 | private PanelIdentifier infoPanel; | 74 | private PanelIdentifier infoPanel; |
| 75 | private ObfuscatedHighlightPainter obfuscatedHighlightPainter; | 75 | public ObfuscatedHighlightPainter obfuscatedHighlightPainter; |
| 76 | private DeobfuscatedHighlightPainter deobfuscatedHighlightPainter; | 76 | public DeobfuscatedHighlightPainter deobfuscatedHighlightPainter; |
| 77 | private OtherHighlightPainter otherHighlightPainter; | 77 | public OtherHighlightPainter otherHighlightPainter; |
| 78 | private SelectionHighlightPainter selectionHighlightPainter; | 78 | private SelectionHighlightPainter selectionHighlightPainter; |
| 79 | private JTree inheritanceTree; | 79 | private JTree inheritanceTree; |
| 80 | private JTree implementationsTree; | 80 | private JTree implementationsTree; |
| @@ -134,7 +134,7 @@ public class Gui { | |||
| 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/minecraft"); | 136 | this.editor.setContentType("text/minecraft"); |
| 137 | this.editor.setBackground(new Color(Config.INSTANCE.editorBackground)); | 137 | this.editor.setBackground(new Color(Config.getInstance().editorBackground)); |
| 138 | DefaultSyntaxKit kit = (DefaultSyntaxKit) this.editor.getEditorKit(); | 138 | DefaultSyntaxKit kit = (DefaultSyntaxKit) this.editor.getEditorKit(); |
| 139 | kit.toggleComponent(this.editor, "de.sciss.syntaxpane.components.TokenMarker"); | 139 | kit.toggleComponent(this.editor, "de.sciss.syntaxpane.components.TokenMarker"); |
| 140 | 140 | ||
diff --git a/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java b/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java index 41de0350..96327abd 100644 --- a/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java +++ b/src/main/java/cuchaz/enigma/gui/MinecraftSyntaxKit.java | |||
| @@ -4,12 +4,8 @@ import cuchaz.enigma.config.Config; | |||
| 4 | import de.sciss.syntaxpane.syntaxkits.JavaSyntaxKit; | 4 | import de.sciss.syntaxpane.syntaxkits.JavaSyntaxKit; |
| 5 | import de.sciss.syntaxpane.util.Configuration; | 5 | import de.sciss.syntaxpane.util.Configuration; |
| 6 | 6 | ||
| 7 | /** | ||
| 8 | * Created by Mark on 04/06/2017. | ||
| 9 | */ | ||
| 10 | public class MinecraftSyntaxKit extends JavaSyntaxKit { | 7 | public class MinecraftSyntaxKit extends JavaSyntaxKit { |
| 11 | 8 | private static Configuration configuration = null; | |
| 12 | public Configuration configuration = null; | ||
| 13 | 9 | ||
| 14 | @Override | 10 | @Override |
| 15 | public Configuration getConfig() { | 11 | public Configuration getConfig() { |
| @@ -22,17 +18,21 @@ public class MinecraftSyntaxKit extends JavaSyntaxKit { | |||
| 22 | public void initConfig(Configuration baseConfig){ | 18 | public void initConfig(Configuration baseConfig){ |
| 23 | configuration = baseConfig; | 19 | configuration = baseConfig; |
| 24 | //See de.sciss.syntaxpane.TokenType | 20 | //See de.sciss.syntaxpane.TokenType |
| 25 | configuration.put("Style.KEYWORD", Config.INSTANCE.highlightColor + ", 0"); | 21 | configuration.put("Style.KEYWORD", Config.getInstance().highlightColor + ", 0"); |
| 26 | configuration.put("Style.KEYWORD2", Config.INSTANCE.highlightColor + ", 3"); | 22 | configuration.put("Style.KEYWORD2", Config.getInstance().highlightColor + ", 3"); |
| 27 | configuration.put("Style.STRING", Config.INSTANCE.stringColor + ", 0"); | 23 | configuration.put("Style.STRING", Config.getInstance().stringColor + ", 0"); |
| 28 | configuration.put("Style.STRING2", Config.INSTANCE.stringColor + ", 1"); | 24 | configuration.put("Style.STRING2", Config.getInstance().stringColor + ", 1"); |
| 29 | configuration.put("Style.NUMBER", Config.INSTANCE.numberColor + ", 1"); | 25 | configuration.put("Style.NUMBER", Config.getInstance().numberColor + ", 1"); |
| 30 | configuration.put("Style.OPERATOR", Config.INSTANCE.operatorColor + ", 0"); | 26 | configuration.put("Style.OPERATOR", Config.getInstance().operatorColor + ", 0"); |
| 31 | configuration.put("Style.DELIMITER", Config.INSTANCE.delimiterColor + ", 1"); | 27 | configuration.put("Style.DELIMITER", Config.getInstance().delimiterColor + ", 1"); |
| 32 | configuration.put("Style.TYPE", Config.INSTANCE.typeColor + ", 2"); | 28 | configuration.put("Style.TYPE", Config.getInstance().typeColor + ", 2"); |
| 33 | configuration.put("Style.TYPE2", Config.INSTANCE.typeColor + ", 1"); | 29 | configuration.put("Style.TYPE2", Config.getInstance().typeColor + ", 1"); |
| 34 | configuration.put("Style.IDENTIFIER", Config.INSTANCE.identifierColor + ", 0"); | 30 | configuration.put("Style.IDENTIFIER", Config.getInstance().identifierColor + ", 0"); |
| 35 | configuration.put("Style.DEFAULT", Config.INSTANCE.defaultTextColor + ", 0"); | 31 | configuration.put("Style.DEFAULT", Config.getInstance().defaultTextColor + ", 0"); |
| 36 | configuration.put("RightMarginColumn", "999"); //No need to have a right margin, if someone wants it add a config | 32 | configuration.put("RightMarginColumn", "999"); //No need to have a right margin, if someone wants it add a config |
| 37 | } | 33 | } |
| 34 | |||
| 35 | public static void invalidate(){ | ||
| 36 | configuration = null; | ||
| 37 | } | ||
| 38 | } | 38 | } |
diff --git a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java index e446c5a5..c0568bfb 100644 --- a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java +++ b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | package cuchaz.enigma.gui.elements; | 1 | package cuchaz.enigma.gui.elements; |
| 2 | 2 | ||
| 3 | import cuchaz.enigma.config.Config; | ||
| 4 | import cuchaz.enigma.config.Themes; | ||
| 3 | import cuchaz.enigma.gui.Gui; | 5 | import cuchaz.enigma.gui.Gui; |
| 4 | import cuchaz.enigma.gui.dialog.AboutDialog; | 6 | import cuchaz.enigma.gui.dialog.AboutDialog; |
| 5 | import cuchaz.enigma.throwables.MappingParseException; | 7 | import cuchaz.enigma.throwables.MappingParseException; |
| @@ -211,6 +213,35 @@ public class MenuBar extends JMenuBar { | |||
| 211 | } | 213 | } |
| 212 | } | 214 | } |
| 213 | { | 215 | { |
| 216 | JMenu menu = new JMenu("View"); | ||
| 217 | this.add(menu); | ||
| 218 | { | ||
| 219 | JMenu themes = new JMenu("Themes"); | ||
| 220 | menu.add(themes); | ||
| 221 | { | ||
| 222 | JMenuItem defaultTheme = new JMenuItem("Default"); | ||
| 223 | themes.add(defaultTheme); | ||
| 224 | defaultTheme.addActionListener(event -> Themes.setDefault(gui)); | ||
| 225 | JMenuItem dark = new JMenuItem("Dank"); | ||
| 226 | themes.add(dark); | ||
| 227 | dark.addActionListener(event -> Themes.setDark(gui)); | ||
| 228 | themes.addSeparator(); | ||
| 229 | JMenuItem refresh = new JMenuItem("Reload From config"); | ||
| 230 | themes.add(refresh); | ||
| 231 | refresh.addActionListener(event -> { | ||
| 232 | try { | ||
| 233 | Config.getInstance().reset(); | ||
| 234 | Config.getInstance().saveConfig(); | ||
| 235 | Themes.updateTheme(gui); | ||
| 236 | } catch (IOException e) { | ||
| 237 | e.printStackTrace(); | ||
| 238 | } | ||
| 239 | }); | ||
| 240 | } | ||
| 241 | |||
| 242 | } | ||
| 243 | } | ||
| 244 | { | ||
| 214 | JMenu menu = new JMenu("Help"); | 245 | JMenu menu = new JMenu("Help"); |
| 215 | this.add(menu); | 246 | this.add(menu); |
| 216 | { | 247 | { |
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java index ef651e3e..41aa97f8 100644 --- a/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java +++ b/src/main/java/cuchaz/enigma/gui/highlight/DeobfuscatedHighlightPainter.java | |||
| @@ -16,6 +16,6 @@ import cuchaz.enigma.config.Config; | |||
| 16 | public class DeobfuscatedHighlightPainter extends BoxHighlightPainter { | 16 | public class DeobfuscatedHighlightPainter extends BoxHighlightPainter { |
| 17 | 17 | ||
| 18 | public DeobfuscatedHighlightPainter() { | 18 | public DeobfuscatedHighlightPainter() { |
| 19 | super(getColor(Config.INSTANCE.deobfuscatedColor, Config.INSTANCE.deobfuscatedHiglightAlpha), getColor(Config.INSTANCE.deobfuscatedColorOutline, Config.INSTANCE.deobfuscatedOutlineAlpha)); | 19 | super(getColor(Config.getInstance().deobfuscatedColor, Config.getInstance().deobfuscatedHiglightAlpha), getColor(Config.getInstance().deobfuscatedColorOutline, Config.getInstance().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 78879069..d7358743 100644 --- a/src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java +++ b/src/main/java/cuchaz/enigma/gui/highlight/ObfuscatedHighlightPainter.java | |||
| @@ -13,11 +13,9 @@ package cuchaz.enigma.gui.highlight; | |||
| 13 | 13 | ||
| 14 | import cuchaz.enigma.config.Config; | 14 | import cuchaz.enigma.config.Config; |
| 15 | 15 | ||
| 16 | import java.awt.*; | ||
| 17 | |||
| 18 | public class ObfuscatedHighlightPainter extends BoxHighlightPainter { | 16 | public class ObfuscatedHighlightPainter extends BoxHighlightPainter { |
| 19 | 17 | ||
| 20 | public ObfuscatedHighlightPainter() { | 18 | public ObfuscatedHighlightPainter() { |
| 21 | super(getColor(Config.INSTANCE.obfuscatedColor, Config.INSTANCE.obfuscatedHiglightAlpha), getColor(Config.INSTANCE.obfuscatedColorOutline, Config.INSTANCE.obfuscatedOutlineAlpha)); | 19 | super(getColor(Config.getInstance().obfuscatedColor, Config.getInstance().obfuscatedHiglightAlpha), getColor(Config.getInstance().obfuscatedColorOutline, Config.getInstance().obfuscatedOutlineAlpha)); |
| 22 | } | 20 | } |
| 23 | } | 21 | } |
diff --git a/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java index c5154e13..f4ae235a 100644 --- a/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java +++ b/src/main/java/cuchaz/enigma/gui/highlight/OtherHighlightPainter.java | |||
| @@ -16,6 +16,6 @@ import cuchaz.enigma.config.Config; | |||
| 16 | public class OtherHighlightPainter extends BoxHighlightPainter { | 16 | public class OtherHighlightPainter extends BoxHighlightPainter { |
| 17 | 17 | ||
| 18 | public OtherHighlightPainter() { | 18 | public OtherHighlightPainter() { |
| 19 | super(null, getColor(Config.INSTANCE.otherColorOutline, Config.INSTANCE.otherOutlineAlpha)); | 19 | super(null, getColor(Config.getInstance().otherColorOutline, Config.getInstance().otherOutlineAlpha)); |
| 20 | } | 20 | } |
| 21 | } | 21 | } |