diff options
| author | 2025-10-16 18:26:55 +0100 | |
|---|---|---|
| committer | 2025-10-16 18:26:55 +0100 | |
| commit | 64b1408b96d1ca115f705c8ec59c3bc4c1e82780 (patch) | |
| tree | 955f64e1bd53a42404c13fbe5b65ff1e2192fa08 | |
| parent | Bump version (diff) | |
| download | enigma-64b1408b96d1ca115f705c8ec59c3bc4c1e82780.tar.gz enigma-64b1408b96d1ca115f705c8ec59c3bc4c1e82780.tar.xz enigma-64b1408b96d1ca115f705c8ec59c3bc4c1e82780.zip | |
Color unobfuscated tokens in blue (#569)
4 files changed, 32 insertions, 3 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/config/Themes.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/config/Themes.java index d2a6608c..b8a72c5e 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/config/Themes.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/config/Themes.java | |||
| @@ -89,7 +89,8 @@ public class Themes { | |||
| 89 | return Map.of( | 89 | return Map.of( |
| 90 | RenamableTokenType.OBFUSCATED, BoxHighlightPainter.create(UiConfig.getObfuscatedColor(), UiConfig.getObfuscatedOutlineColor()), | 90 | RenamableTokenType.OBFUSCATED, BoxHighlightPainter.create(UiConfig.getObfuscatedColor(), UiConfig.getObfuscatedOutlineColor()), |
| 91 | RenamableTokenType.PROPOSED, BoxHighlightPainter.create(UiConfig.getProposedColor(), UiConfig.getProposedOutlineColor()), | 91 | 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()) | ||
| 93 | ); | 94 | ); |
| 94 | } | 95 | } |
| 95 | 96 | ||
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/config/UiConfig.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/config/UiConfig.java index ecd17f28..f0117ee8 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/config/UiConfig.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/config/UiConfig.java | |||
| @@ -151,6 +151,14 @@ public final class UiConfig { | |||
| 151 | return getThemeColorRgba("Deobfuscated Outline"); | 151 | return getThemeColorRgba("Deobfuscated Outline"); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | public static Color getUnobfuscatedColor() { | ||
| 155 | return getThemeColorRgba("Unobfuscated"); | ||
| 156 | } | ||
| 157 | |||
| 158 | public static Color getUnobfuscatedOutlineColor() { | ||
| 159 | return getThemeColorRgba("Unobfuscated Outline"); | ||
| 160 | } | ||
| 161 | |||
| 154 | public static Color getEditorBackgroundColor() { | 162 | public static Color getEditorBackgroundColor() { |
| 155 | return getThemeColorRgb("Editor Background"); | 163 | return getThemeColorRgb("Editor Background"); |
| 156 | } | 164 | } |
| @@ -385,6 +393,10 @@ public final class UiConfig { | |||
| 385 | s.setIfAbsentDouble("Deobfuscated Alpha", 1.0); | 393 | s.setIfAbsentDouble("Deobfuscated Alpha", 1.0); |
| 386 | s.setIfAbsentRgbColor("Deobfuscated Outline", 0x50A050); | 394 | s.setIfAbsentRgbColor("Deobfuscated Outline", 0x50A050); |
| 387 | s.setIfAbsentDouble("Deobfuscated Outline Alpha", 1.0); | 395 | 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); | ||
| 388 | s.setIfAbsentRgbColor("Editor Background", 0xFFFFFF); | 400 | s.setIfAbsentRgbColor("Editor Background", 0xFFFFFF); |
| 389 | s.setIfAbsentRgbColor("Highlight", 0x3333EE); | 401 | s.setIfAbsentRgbColor("Highlight", 0x3333EE); |
| 390 | s.setIfAbsentRgbColor("Caret", 0x000000); | 402 | s.setIfAbsentRgbColor("Caret", 0x000000); |
| @@ -413,6 +425,10 @@ public final class UiConfig { | |||
| 413 | s.setIfAbsentDouble("Deobfuscated Alpha", 0.3); | 425 | s.setIfAbsentDouble("Deobfuscated Alpha", 0.3); |
| 414 | s.setIfAbsentRgbColor("Deobfuscated Outline", 0x50FA7B); | 426 | s.setIfAbsentRgbColor("Deobfuscated Outline", 0x50FA7B); |
| 415 | s.setIfAbsentDouble("Deobfuscated Outline Alpha", 0.5); | 427 | 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); | ||
| 416 | s.setIfAbsentRgbColor("Editor Background", 0x282A36); | 432 | s.setIfAbsentRgbColor("Editor Background", 0x282A36); |
| 417 | s.setIfAbsentRgbColor("Highlight", 0xFF79C6); | 433 | s.setIfAbsentRgbColor("Highlight", 0xFF79C6); |
| 418 | s.setIfAbsentRgbColor("Caret", 0xF8F8F2); | 434 | s.setIfAbsentRgbColor("Caret", 0xF8F8F2); |
diff --git a/enigma/src/main/java/cuchaz/enigma/source/DecompiledClassSource.java b/enigma/src/main/java/cuchaz/enigma/source/DecompiledClassSource.java index 4f78e9ce..69692db0 100644 --- a/enigma/src/main/java/cuchaz/enigma/source/DecompiledClassSource.java +++ b/enigma/src/main/java/cuchaz/enigma/source/DecompiledClassSource.java | |||
| @@ -12,6 +12,7 @@ import cuchaz.enigma.EnigmaProject; | |||
| 12 | import cuchaz.enigma.EnigmaServices; | 12 | import cuchaz.enigma.EnigmaServices; |
| 13 | import cuchaz.enigma.analysis.EntryReference; | 13 | import cuchaz.enigma.analysis.EntryReference; |
| 14 | import cuchaz.enigma.api.service.NameProposalService; | 14 | import cuchaz.enigma.api.service.NameProposalService; |
| 15 | import cuchaz.enigma.api.service.ObfuscationTestService; | ||
| 15 | import cuchaz.enigma.translation.LocalNameGenerator; | 16 | import cuchaz.enigma.translation.LocalNameGenerator; |
| 16 | import cuchaz.enigma.translation.TranslateResult; | 17 | import cuchaz.enigma.translation.TranslateResult; |
| 17 | import cuchaz.enigma.translation.Translator; | 18 | import cuchaz.enigma.translation.Translator; |
| @@ -72,7 +73,11 @@ public class DecompiledClassSource { | |||
| 72 | return proposedName.get(); | 73 | return proposedName.get(); |
| 73 | } | 74 | } |
| 74 | 75 | ||
| 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 | } | ||
| 76 | } | 81 | } |
| 77 | } | 82 | } |
| 78 | 83 | ||
| @@ -96,6 +101,12 @@ public class DecompiledClassSource { | |||
| 96 | }).findFirst(); | 101 | }).findFirst(); |
| 97 | } | 102 | } |
| 98 | 103 | ||
| 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 | |||
| 99 | @Nullable | 110 | @Nullable |
| 100 | private String generateDefaultName(Entry<?> entry) { | 111 | private String generateDefaultName(Entry<?> entry) { |
| 101 | if (entry instanceof LocalVariableDefEntry) { | 112 | if (entry instanceof LocalVariableDefEntry) { |
diff --git a/enigma/src/main/java/cuchaz/enigma/source/RenamableTokenType.java b/enigma/src/main/java/cuchaz/enigma/source/RenamableTokenType.java index c63aad91..aad3ada9 100644 --- a/enigma/src/main/java/cuchaz/enigma/source/RenamableTokenType.java +++ b/enigma/src/main/java/cuchaz/enigma/source/RenamableTokenType.java | |||
| @@ -3,5 +3,6 @@ package cuchaz.enigma.source; | |||
| 3 | public enum RenamableTokenType { | 3 | public enum RenamableTokenType { |
| 4 | OBFUSCATED, | 4 | OBFUSCATED, |
| 5 | DEOBFUSCATED, | 5 | DEOBFUSCATED, |
| 6 | PROPOSED | 6 | PROPOSED, |
| 7 | UNOBFUSCATED, | ||
| 7 | } | 8 | } |