summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/config/Config.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/config/Config.java')
-rw-r--r--src/main/java/cuchaz/enigma/config/Config.java106
1 files changed, 83 insertions, 23 deletions
diff --git a/src/main/java/cuchaz/enigma/config/Config.java b/src/main/java/cuchaz/enigma/config/Config.java
index 4441468..034d077 100644
--- a/src/main/java/cuchaz/enigma/config/Config.java
+++ b/src/main/java/cuchaz/enigma/config/Config.java
@@ -1,14 +1,94 @@
1package cuchaz.enigma.config; 1package cuchaz.enigma.config;
2 2
3import com.bulenkov.darcula.DarculaLaf;
3import com.google.common.io.Files; 4import com.google.common.io.Files;
4import com.google.gson.*; 5import com.google.gson.*;
5 6
7import javax.swing.*;
8import javax.swing.plaf.metal.MetalLookAndFeel;
6import java.io.File; 9import java.io.File;
7import java.io.IOException; 10import java.io.IOException;
8import java.lang.reflect.Type; 11import java.lang.reflect.Type;
9import java.nio.charset.Charset; 12import java.nio.charset.Charset;
10 13
11public class Config { 14public class Config {
15 public enum LookAndFeel {
16 DEFAULT("Default"),
17 DARCULA("Dank");
18
19 private final String name;
20
21 LookAndFeel(String name) {
22 this.name = name;
23 }
24
25 public String getName() {
26 return name;
27 }
28
29 public void setGlobalLAF() {
30 try {
31 switch (this) {
32 case DEFAULT:
33 UIManager.setLookAndFeel(new MetalLookAndFeel());
34 break;
35 case DARCULA:
36 UIManager.setLookAndFeel(new DarculaLaf());
37 break;
38 }
39 } catch (Exception e){
40 throw new Error("Failed to set global look and feel", e);
41 }
42 }
43
44 public void apply(Config config) {
45 switch (this) {
46 case DEFAULT:
47 config.obfuscatedColor = 0xFFDCDC;
48 config.obfuscatedHiglightAlpha = 1.0F;
49 config.obfuscatedColorOutline = 0xA05050;
50 config.obfuscatedOutlineAlpha = 1.0F;
51 config.deobfuscatedColor = 0xDCFFDC;
52 config.deobfuscatedHiglightAlpha = 1.0F;
53 config.deobfuscatedColorOutline = 0x50A050;
54 config.deobfuscatedOutlineAlpha = 1.0F;
55 config.otherColorOutline = 0xB4B4B4;
56 config.otherOutlineAlpha = 1.0F;
57 config.editorBackground = 0xFFFFFF;
58 config.highlightColor = 0x3333EE;
59 config.stringColor = 0xCC6600;
60 config.numberColor = 0x999933;
61 config.operatorColor = 0x000000;
62 config.delimiterColor = 0x000000;
63 config.typeColor = 0x000000;
64 config.identifierColor = 0x000000;
65 config.defaultTextColor = 0x000000;
66 break;
67 case DARCULA:
68 //Based off colors found here: https://github.com/dracula/dracula-theme/
69 config.obfuscatedColor = 0xFF5555;
70 config.obfuscatedHiglightAlpha = 0.3F;
71 config.obfuscatedColorOutline = 0xFF5555;
72 config.obfuscatedOutlineAlpha = 0.5F;
73 config.deobfuscatedColor = 0x50FA7B;
74 config.deobfuscatedHiglightAlpha = 0.3F;
75 config.deobfuscatedColorOutline = 0x50FA7B;
76 config.deobfuscatedOutlineAlpha = 0.5F;
77 config.otherColorOutline = 0xB4B4B4;
78 config.otherOutlineAlpha = 0.0F;
79 config.editorBackground = 0x282A36;
80 config.highlightColor = 0xFF79C6;
81 config.stringColor = 0xF1FA8C;
82 config.numberColor = 0xBD93F9;
83 config.operatorColor = 0xF8F8F2;
84 config.delimiterColor = 0xF8F8F2;
85 config.typeColor = 0xF8F8F2;
86 config.identifierColor = 0xF8F8F2;
87 config.defaultTextColor = 0xF8F8F2;
88 break;
89 }
90 }
91 }
12 92
13 private static final File DIR_HOME = new File(System.getProperty("user.home")); 93 private static final File DIR_HOME = new File(System.getProperty("user.home"));
14 private static final File ENIGMA_DIR = new File(DIR_HOME, ".enigma"); 94 private static final File ENIGMA_DIR = new File(DIR_HOME, ".enigma");
@@ -40,8 +120,7 @@ public class Config {
40 public Integer identifierColor; 120 public Integer identifierColor;
41 public Integer defaultTextColor; 121 public Integer defaultTextColor;
42 122
43 public boolean useSystemLAF; 123 public LookAndFeel lookAndFeel = LookAndFeel.DEFAULT;
44 public boolean useDraculaLAF;
45 124
46 private Config() { 125 private Config() {
47 gson = new GsonBuilder() 126 gson = new GsonBuilder()
@@ -76,27 +155,8 @@ public class Config {
76 } 155 }
77 156
78 public void reset() throws IOException { 157 public void reset() throws IOException {
79 this.obfuscatedColor = 0xFFDCDC; 158 this.lookAndFeel = LookAndFeel.DEFAULT;
80 this.obfuscatedHiglightAlpha = 1.0F; 159 this.lookAndFeel.apply(this);
81 this.obfuscatedColorOutline = 0xA05050;
82 this.obfuscatedOutlineAlpha = 1.0F;
83 this.deobfuscatedColor = 0xDCFFDC;
84 this.deobfuscatedHiglightAlpha = 1.0F;
85 this.deobfuscatedColorOutline = 0x50A050;
86 this.deobfuscatedOutlineAlpha = 1.0F;
87 this.otherColorOutline = 0xB4B4B4;
88 this.otherOutlineAlpha = 1.0F;
89 this.editorBackground = 0xFFFFFF;
90 this.highlightColor = 0x3333EE;
91 this.stringColor = 0xCC6600;
92 this.numberColor = 0x999933;
93 this.operatorColor = 0x000000;
94 this.delimiterColor = 0x000000;
95 this.typeColor = 0x000000;
96 this.identifierColor = 0x000000;
97 this.defaultTextColor = 0x000000;
98 this.useSystemLAF = true;
99 this.useDraculaLAF = false;
100 this.saveConfig(); 160 this.saveConfig();
101 } 161 }
102 162