From ca75962a1dd8e5e629d6d4a794d7460dadf430a5 Mon Sep 17 00:00:00 2001 From: asie Date: Wed, 28 Nov 2018 10:11:47 +0100 Subject: refactors and bugfixes --- src/main/java/cuchaz/enigma/config/Themes.java | 49 +++----------------------- 1 file changed, 4 insertions(+), 45 deletions(-) (limited to 'src/main/java/cuchaz/enigma/config/Themes.java') diff --git a/src/main/java/cuchaz/enigma/config/Themes.java b/src/main/java/cuchaz/enigma/config/Themes.java index 4b1f478..b3132f2 100644 --- a/src/main/java/cuchaz/enigma/config/Themes.java +++ b/src/main/java/cuchaz/enigma/config/Themes.java @@ -14,42 +14,14 @@ import java.io.IOException; public class Themes { - public static void setDefault(Gui gui) { - // TODO set to default - try { - Config.getInstance().reset(); - } catch (IOException e) { - e.printStackTrace(); - } + public static void setLookAndFeel(Gui gui, Config.LookAndFeel lookAndFeel) { + Config.getInstance().lookAndFeel = lookAndFeel; updateTheme(gui); } - public static void setDark(Gui gui) { - //Based off colors found here: https://github.com/dracula/dracula-theme/ - Config.getInstance().obfuscatedColor = 0xFF5555; - Config.getInstance().obfuscatedHiglightAlpha = 0.3F; - Config.getInstance().obfuscatedColorOutline = 0xFF5555; - Config.getInstance().obfuscatedOutlineAlpha = 0.5F; - Config.getInstance().deobfuscatedColor = 0x50FA7B; - Config.getInstance().deobfuscatedHiglightAlpha = 0.3F; - Config.getInstance().deobfuscatedColorOutline = 0x50FA7B; - Config.getInstance().deobfuscatedOutlineAlpha = 0.5F; - Config.getInstance().otherColorOutline = 0xB4B4B4; - Config.getInstance().otherOutlineAlpha = 0.0F; - Config.getInstance().editorBackground = 0x282A36; - Config.getInstance().highlightColor = 0xFF79C6; - Config.getInstance().stringColor = 0xF1FA8C; - Config.getInstance().numberColor = 0xBD93F9; - Config.getInstance().operatorColor = 0xF8F8F2; - Config.getInstance().delimiterColor = 0xF8F8F2; - Config.getInstance().typeColor = 0xF8F8F2; - Config.getInstance().identifierColor = 0xF8F8F2; - Config.getInstance().defaultTextColor = 0xF8F8F2; - Config.getInstance().useDraculaLAF = true; - updateTheme(gui); - } - public static void updateTheme(Gui gui) { + Config.getInstance().lookAndFeel.apply(Config.getInstance()); + Config.getInstance().lookAndFeel.setGlobalLAF(); try { Config.getInstance().saveConfig(); } catch (IOException e) { @@ -63,20 +35,7 @@ public class Themes { gui.otherHighlightPainter = new OtherHighlightPainter(); gui.editor.updateUI(); gui.editor.setBackground(new Color(Config.getInstance().editorBackground)); - setLAF(); SwingUtilities.updateComponentTreeUI(gui.getFrame()); gui.getController().refreshCurrentClass(); } - - public static void setLAF(){ - try { - if (Config.getInstance().useDraculaLAF){ - UIManager.setLookAndFeel(new DarculaLaf()); - } else if (Config.getInstance().useSystemLAF) - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Exception e){ - throw new Error("Failed to set LAF", e); - } - } - } -- cgit v1.2.3