Skip to content

Commit 64b1408

Browse files
Color unobfuscated tokens in blue (#569)
1 parent 9ec63bc commit 64b1408

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

enigma-swing/src/main/java/cuchaz/enigma/gui/config/Themes.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ public static Map<RenamableTokenType, BoxHighlightPainter> getBoxHighlightPainte
8989
return Map.of(
9090
RenamableTokenType.OBFUSCATED, BoxHighlightPainter.create(UiConfig.getObfuscatedColor(), UiConfig.getObfuscatedOutlineColor()),
9191
RenamableTokenType.PROPOSED, BoxHighlightPainter.create(UiConfig.getProposedColor(), UiConfig.getProposedOutlineColor()),
92-
RenamableTokenType.DEOBFUSCATED, BoxHighlightPainter.create(UiConfig.getDeobfuscatedColor(), UiConfig.getDeobfuscatedOutlineColor())
92+
RenamableTokenType.DEOBFUSCATED, BoxHighlightPainter.create(UiConfig.getDeobfuscatedColor(), UiConfig.getDeobfuscatedOutlineColor()),
93+
RenamableTokenType.UNOBFUSCATED, BoxHighlightPainter.create(UiConfig.getUnobfuscatedColor(), UiConfig.getUnobfuscatedOutlineColor())
9394
);
9495
}
9596

enigma-swing/src/main/java/cuchaz/enigma/gui/config/UiConfig.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ public static Color getDeobfuscatedOutlineColor() {
151151
return getThemeColorRgba("Deobfuscated Outline");
152152
}
153153

154+
public static Color getUnobfuscatedColor() {
155+
return getThemeColorRgba("Unobfuscated");
156+
}
157+
158+
public static Color getUnobfuscatedOutlineColor() {
159+
return getThemeColorRgba("Unobfuscated Outline");
160+
}
161+
154162
public static Color getEditorBackgroundColor() {
155163
return getThemeColorRgb("Editor Background");
156164
}
@@ -385,6 +393,10 @@ public static void setLookAndFeelDefaults(LookAndFeel laf, boolean isDark) {
385393
s.setIfAbsentDouble("Deobfuscated Alpha", 1.0);
386394
s.setIfAbsentRgbColor("Deobfuscated Outline", 0x50A050);
387395
s.setIfAbsentDouble("Deobfuscated Outline Alpha", 1.0);
396+
s.setIfAbsentRgbColor("Unobfuscated", 0x7FAAFF);
397+
s.setIfAbsentDouble("Unobfuscated Alpha", 1.0);
398+
s.setIfAbsentRgbColor("Unobfuscated Outline", 0x183060);
399+
s.setIfAbsentDouble("Unobfuscated Outline Alpha", 1.0);
388400
s.setIfAbsentRgbColor("Editor Background", 0xFFFFFF);
389401
s.setIfAbsentRgbColor("Highlight", 0x3333EE);
390402
s.setIfAbsentRgbColor("Caret", 0x000000);
@@ -413,6 +425,10 @@ public static void setLookAndFeelDefaults(LookAndFeel laf, boolean isDark) {
413425
s.setIfAbsentDouble("Deobfuscated Alpha", 0.3);
414426
s.setIfAbsentRgbColor("Deobfuscated Outline", 0x50FA7B);
415427
s.setIfAbsentDouble("Deobfuscated Outline Alpha", 0.5);
428+
s.setIfAbsentRgbColor("Unobfuscated", 0x3794FF);
429+
s.setIfAbsentDouble("Unobfuscated Alpha", 0.3);
430+
s.setIfAbsentRgbColor("Unobfuscated Outline", 0x3794FF);
431+
s.setIfAbsentDouble("Unobfuscated Outline Alpha", 0.5);
416432
s.setIfAbsentRgbColor("Editor Background", 0x282A36);
417433
s.setIfAbsentRgbColor("Highlight", 0xFF79C6);
418434
s.setIfAbsentRgbColor("Caret", 0xF8F8F2);

enigma/src/main/java/cuchaz/enigma/source/DecompiledClassSource.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import cuchaz.enigma.EnigmaServices;
1313
import cuchaz.enigma.analysis.EntryReference;
1414
import cuchaz.enigma.api.service.NameProposalService;
15+
import cuchaz.enigma.api.service.ObfuscationTestService;
1516
import cuchaz.enigma.translation.LocalNameGenerator;
1617
import cuchaz.enigma.translation.TranslateResult;
1718
import cuchaz.enigma.translation.Translator;
@@ -72,7 +73,11 @@ private String remapToken(TokenStore target, EnigmaProject project, Token token,
7273
return proposedName.get();
7374
}
7475

75-
target.add(RenamableTokenType.OBFUSCATED, movedToken);
76+
if (isUnobfuscated(project, entry)) {
77+
target.add(RenamableTokenType.UNOBFUSCATED, movedToken);
78+
} else {
79+
target.add(RenamableTokenType.OBFUSCATED, movedToken);
80+
}
7681
}
7782
}
7883

@@ -96,6 +101,12 @@ public static Optional<String> proposeName(EnigmaProject project, Entry<?> entry
96101
}).findFirst();
97102
}
98103

104+
private static boolean isUnobfuscated(EnigmaProject project, Entry<?> entry) {
105+
EnigmaServices services = project.getEnigma().getServices();
106+
107+
return services.get(ObfuscationTestService.TYPE).stream().anyMatch(service -> service.testDeobfuscated(entry));
108+
}
109+
99110
@Nullable
100111
private String generateDefaultName(Entry<?> entry) {
101112
if (entry instanceof LocalVariableDefEntry) {

enigma/src/main/java/cuchaz/enigma/source/RenamableTokenType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
public enum RenamableTokenType {
44
OBFUSCATED,
55
DEOBFUSCATED,
6-
PROPOSED
6+
PROPOSED,
7+
UNOBFUSCATED,
78
}

0 commit comments

Comments
 (0)