diff options
| author | 2014-09-28 15:20:54 -0400 | |
|---|---|---|
| committer | 2014-09-28 15:20:54 -0400 | |
| commit | cf3ffcee30083a71e68e3edb9ecbb936cc255992 (patch) | |
| tree | f9a6415d7eef1e76640b07238d2d08daecedde17 /src/cuchaz/enigma/gui | |
| parent | implemented mark-as-deobfuscated and reset-to-obfuscated (diff) | |
| download | enigma-fork-cf3ffcee30083a71e68e3edb9ecbb936cc255992.tar.gz enigma-fork-cf3ffcee30083a71e68e3edb9ecbb936cc255992.tar.xz enigma-fork-cf3ffcee30083a71e68e3edb9ecbb936cc255992.zip | |
added proper support for renaming constructors
Diffstat (limited to 'src/cuchaz/enigma/gui')
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 15 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/GuiController.java | 34 |
2 files changed, 29 insertions, 20 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index 8bf6ce9..920bc0b 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -1038,6 +1038,7 @@ public class Gui | |||
| 1038 | boolean isMethodEntry = isToken && m_reference.entry instanceof MethodEntry; | 1038 | boolean isMethodEntry = isToken && m_reference.entry instanceof MethodEntry; |
| 1039 | boolean isConstructorEntry = isToken && m_reference.entry instanceof ConstructorEntry; | 1039 | boolean isConstructorEntry = isToken && m_reference.entry instanceof ConstructorEntry; |
| 1040 | boolean isInJar = isToken && m_controller.entryIsInJar( m_reference.entry ); | 1040 | boolean isInJar = isToken && m_controller.entryIsInJar( m_reference.entry ); |
| 1041 | boolean isRenameable = isToken && m_controller.referenceIsRenameable( m_reference ); | ||
| 1041 | 1042 | ||
| 1042 | if( isToken ) | 1043 | if( isToken ) |
| 1043 | { | 1044 | { |
| @@ -1048,15 +1049,15 @@ public class Gui | |||
| 1048 | clearReference(); | 1049 | clearReference(); |
| 1049 | } | 1050 | } |
| 1050 | 1051 | ||
| 1051 | m_renameMenu.setEnabled( isInJar && isToken ); | 1052 | m_renameMenu.setEnabled( isRenameable && isToken ); |
| 1052 | m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry || isConstructorEntry ); | 1053 | m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry || isConstructorEntry ); |
| 1053 | m_showImplementationsMenu.setEnabled( isClassEntry || isMethodEntry ); | 1054 | m_showImplementationsMenu.setEnabled( isClassEntry || isMethodEntry ); |
| 1054 | m_showCallsMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ); | 1055 | m_showCallsMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ); |
| 1055 | m_openEntryMenu.setEnabled( isInJar && ( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ) ); | 1056 | m_openEntryMenu.setEnabled( isInJar && ( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ) ); |
| 1056 | m_openPreviousMenu.setEnabled( m_controller.hasPreviousLocation() ); | 1057 | m_openPreviousMenu.setEnabled( m_controller.hasPreviousLocation() ); |
| 1057 | m_toggleMappingMenu.setEnabled( isInJar && isToken ); | 1058 | m_toggleMappingMenu.setEnabled( isRenameable && isToken ); |
| 1058 | 1059 | ||
| 1059 | if( isToken && m_controller.entryHasMapping( m_reference.entry ) ) | 1060 | if( isToken && m_controller.entryHasDeobfuscatedName( m_reference.entry ) ) |
| 1060 | { | 1061 | { |
| 1061 | m_toggleMappingMenu.setText( "Reset to obfuscated" ); | 1062 | m_toggleMappingMenu.setText( "Reset to obfuscated" ); |
| 1062 | } | 1063 | } |
| @@ -1082,7 +1083,7 @@ public class Gui | |||
| 1082 | 1083 | ||
| 1083 | private void navigateTo( EntryReference<Entry,Entry> reference ) | 1084 | private void navigateTo( EntryReference<Entry,Entry> reference ) |
| 1084 | { | 1085 | { |
| 1085 | if( !m_controller.entryIsInJar( reference.getClassEntry() ) ) | 1086 | if( !m_controller.entryIsInJar( reference.getLocationClassEntry() ) ) |
| 1086 | { | 1087 | { |
| 1087 | // reference is not in the jar. Ignore it | 1088 | // reference is not in the jar. Ignore it |
| 1088 | return; | 1089 | return; |
| @@ -1098,7 +1099,7 @@ public class Gui | |||
| 1098 | { | 1099 | { |
| 1099 | // init the text box | 1100 | // init the text box |
| 1100 | final JTextField text = new JTextField(); | 1101 | final JTextField text = new JTextField(); |
| 1101 | text.setText( m_reference.entry.getName() ); | 1102 | text.setText( m_reference.getNameableEntry().getName() ); |
| 1102 | text.setPreferredSize( new Dimension( 360, text.getPreferredSize().height ) ); | 1103 | text.setPreferredSize( new Dimension( 360, text.getPreferredSize().height ) ); |
| 1103 | text.addKeyListener( new KeyAdapter( ) | 1104 | text.addKeyListener( new KeyAdapter( ) |
| 1104 | { | 1105 | { |
| @@ -1149,7 +1150,7 @@ public class Gui | |||
| 1149 | // abort the rename | 1150 | // abort the rename |
| 1150 | JPanel panel = (JPanel)m_infoPanel.getComponent( 0 ); | 1151 | JPanel panel = (JPanel)m_infoPanel.getComponent( 0 ); |
| 1151 | panel.remove( panel.getComponentCount() - 1 ); | 1152 | panel.remove( panel.getComponentCount() - 1 ); |
| 1152 | panel.add( GuiTricks.unboldLabel( new JLabel( m_reference.entry.getName(), JLabel.LEFT ) ) ); | 1153 | panel.add( GuiTricks.unboldLabel( new JLabel( m_reference.getNameableEntry().getName(), JLabel.LEFT ) ) ); |
| 1153 | 1154 | ||
| 1154 | m_editor.grabFocus(); | 1155 | m_editor.grabFocus(); |
| 1155 | 1156 | ||
| @@ -1268,7 +1269,7 @@ public class Gui | |||
| 1268 | 1269 | ||
| 1269 | private void toggleMapping() | 1270 | private void toggleMapping() |
| 1270 | { | 1271 | { |
| 1271 | if( m_controller.entryHasMapping( m_reference.entry ) ) | 1272 | if( m_controller.entryHasDeobfuscatedName( m_reference.entry ) ) |
| 1272 | { | 1273 | { |
| 1273 | m_controller.removeMapping( m_reference ); | 1274 | m_controller.removeMapping( m_reference ); |
| 1274 | } | 1275 | } |
diff --git a/src/cuchaz/enigma/gui/GuiController.java b/src/cuchaz/enigma/gui/GuiController.java index 3adaf91..c7efbce 100644 --- a/src/cuchaz/enigma/gui/GuiController.java +++ b/src/cuchaz/enigma/gui/GuiController.java | |||
| @@ -165,9 +165,9 @@ public class GuiController | |||
| 165 | ); | 165 | ); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | public boolean entryHasMapping( Entry deobfEntry ) | 168 | public boolean entryHasDeobfuscatedName( Entry deobfEntry ) |
| 169 | { | 169 | { |
| 170 | return m_deobfuscator.hasMapping( m_deobfuscator.obfuscateEntry( deobfEntry ) ); | 170 | return m_deobfuscator.hasDeobfuscatedName( m_deobfuscator.obfuscateEntry( deobfEntry ) ); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | public boolean entryIsInJar( Entry deobfEntry ) | 173 | public boolean entryIsInJar( Entry deobfEntry ) |
| @@ -175,6 +175,11 @@ public class GuiController | |||
| 175 | return m_deobfuscator.isObfuscatedIdentifier( m_deobfuscator.obfuscateEntry( deobfEntry ) ); | 175 | return m_deobfuscator.isObfuscatedIdentifier( m_deobfuscator.obfuscateEntry( deobfEntry ) ); |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | public boolean referenceIsRenameable( EntryReference<Entry,Entry> deobfReference ) | ||
| 179 | { | ||
| 180 | return m_deobfuscator.isRenameable( m_deobfuscator.obfuscateReference( deobfReference ) ); | ||
| 181 | } | ||
| 182 | |||
| 178 | public ClassInheritanceTreeNode getClassInheritance( ClassEntry deobfClassEntry ) | 183 | public ClassInheritanceTreeNode getClassInheritance( ClassEntry deobfClassEntry ) |
| 179 | { | 184 | { |
| 180 | ClassEntry obfClassEntry = m_deobfuscator.obfuscateEntry( deobfClassEntry ); | 185 | ClassEntry obfClassEntry = m_deobfuscator.obfuscateEntry( deobfClassEntry ); |
| @@ -243,7 +248,7 @@ public class GuiController | |||
| 243 | public void rename( EntryReference<Entry,Entry> deobfReference, String newName ) | 248 | public void rename( EntryReference<Entry,Entry> deobfReference, String newName ) |
| 244 | { | 249 | { |
| 245 | EntryReference<Entry,Entry> obfReference = m_deobfuscator.obfuscateReference( deobfReference ); | 250 | EntryReference<Entry,Entry> obfReference = m_deobfuscator.obfuscateReference( deobfReference ); |
| 246 | m_deobfuscator.rename( obfReference.entry, newName ); | 251 | m_deobfuscator.rename( obfReference.getNameableEntry(), newName ); |
| 247 | m_isDirty = true; | 252 | m_isDirty = true; |
| 248 | refreshClasses(); | 253 | refreshClasses(); |
| 249 | refreshCurrentClass( obfReference ); | 254 | refreshCurrentClass( obfReference ); |
| @@ -252,7 +257,7 @@ public class GuiController | |||
| 252 | public void removeMapping( EntryReference<Entry,Entry> deobfReference ) | 257 | public void removeMapping( EntryReference<Entry,Entry> deobfReference ) |
| 253 | { | 258 | { |
| 254 | EntryReference<Entry,Entry> obfReference = m_deobfuscator.obfuscateReference( deobfReference ); | 259 | EntryReference<Entry,Entry> obfReference = m_deobfuscator.obfuscateReference( deobfReference ); |
| 255 | m_deobfuscator.removeMapping( obfReference.entry ); | 260 | m_deobfuscator.removeMapping( obfReference.getNameableEntry() ); |
| 256 | m_isDirty = true; | 261 | m_isDirty = true; |
| 257 | refreshClasses(); | 262 | refreshClasses(); |
| 258 | refreshCurrentClass( obfReference ); | 263 | refreshCurrentClass( obfReference ); |
| @@ -261,7 +266,7 @@ public class GuiController | |||
| 261 | public void markAsDeobfuscated( EntryReference<Entry,Entry> deobfReference ) | 266 | public void markAsDeobfuscated( EntryReference<Entry,Entry> deobfReference ) |
| 262 | { | 267 | { |
| 263 | EntryReference<Entry,Entry> obfReference = m_deobfuscator.obfuscateReference( deobfReference ); | 268 | EntryReference<Entry,Entry> obfReference = m_deobfuscator.obfuscateReference( deobfReference ); |
| 264 | m_deobfuscator.markAsDeobfuscated( obfReference.entry ); | 269 | m_deobfuscator.markAsDeobfuscated( obfReference.getNameableEntry() ); |
| 265 | m_isDirty = true; | 270 | m_isDirty = true; |
| 266 | refreshClasses(); | 271 | refreshClasses(); |
| 267 | refreshCurrentClass( obfReference ); | 272 | refreshCurrentClass( obfReference ); |
| @@ -273,7 +278,7 @@ public class GuiController | |||
| 273 | { | 278 | { |
| 274 | throw new IllegalArgumentException( "Entry cannot be null!" ); | 279 | throw new IllegalArgumentException( "Entry cannot be null!" ); |
| 275 | } | 280 | } |
| 276 | openReference( new EntryReference<Entry,Entry>( deobfEntry ) ); | 281 | openReference( new EntryReference<Entry,Entry>( deobfEntry, deobfEntry.getName() ) ); |
| 277 | } | 282 | } |
| 278 | 283 | ||
| 279 | public void openReference( EntryReference<Entry,Entry> deobfReference ) | 284 | public void openReference( EntryReference<Entry,Entry> deobfReference ) |
| @@ -285,7 +290,7 @@ public class GuiController | |||
| 285 | 290 | ||
| 286 | // get the reference target class | 291 | // get the reference target class |
| 287 | EntryReference<Entry,Entry> obfReference = m_deobfuscator.obfuscateReference( deobfReference ); | 292 | EntryReference<Entry,Entry> obfReference = m_deobfuscator.obfuscateReference( deobfReference ); |
| 288 | ClassEntry obfClassEntry = obfReference.getClassEntry().getOuterClassEntry(); | 293 | ClassEntry obfClassEntry = obfReference.getLocationClassEntry().getOuterClassEntry(); |
| 289 | if( !m_deobfuscator.isObfuscatedIdentifier( obfClassEntry ) ) | 294 | if( !m_deobfuscator.isObfuscatedIdentifier( obfClassEntry ) ) |
| 290 | { | 295 | { |
| 291 | throw new IllegalArgumentException( "Obfuscated class " + obfClassEntry + " was not found in the jar!" ); | 296 | throw new IllegalArgumentException( "Obfuscated class " + obfClassEntry + " was not found in the jar!" ); |
| @@ -390,13 +395,16 @@ public class GuiController | |||
| 390 | for( Token token : m_index.referenceTokens() ) | 395 | for( Token token : m_index.referenceTokens() ) |
| 391 | { | 396 | { |
| 392 | EntryReference<Entry,Entry> reference = m_index.getDeobfReference( token ); | 397 | EntryReference<Entry,Entry> reference = m_index.getDeobfReference( token ); |
| 393 | if( entryHasMapping( reference.entry ) ) | 398 | if( referenceIsRenameable( reference ) ) |
| 394 | { | ||
| 395 | deobfuscatedTokens.add( token ); | ||
| 396 | } | ||
| 397 | else if( entryIsInJar( reference.entry ) ) | ||
| 398 | { | 399 | { |
| 399 | obfuscatedTokens.add( token ); | 400 | if( entryHasDeobfuscatedName( reference.getNameableEntry() ) ) |
| 401 | { | ||
| 402 | deobfuscatedTokens.add( token ); | ||
| 403 | } | ||
| 404 | else | ||
| 405 | { | ||
| 406 | obfuscatedTokens.add( token ); | ||
| 407 | } | ||
| 400 | } | 408 | } |
| 401 | else | 409 | else |
| 402 | { | 410 | { |