summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/Main.java')
-rw-r--r--src/cuchaz/enigma/Main.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/Main.java b/src/cuchaz/enigma/Main.java
new file mode 100644
index 0000000..e08c16e
--- /dev/null
+++ b/src/cuchaz/enigma/Main.java
@@ -0,0 +1,63 @@
1/*******************************************************************************
2 * Copyright (c) 2014 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Public License v3.0
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/gpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11package cuchaz.enigma;
12
13import java.io.File;
14
15import cuchaz.enigma.analysis.Analyzer;
16import cuchaz.enigma.analysis.SourceIndex;
17import cuchaz.enigma.gui.ClassSelectionHandler;
18import cuchaz.enigma.gui.Gui;
19
20public class Main
21{
22 public static void main( String[] args )
23 throws Exception
24 {
25 startGui();
26 }
27
28 private static void startGui( )
29 throws Exception
30 {
31 final Gui gui = new Gui();
32
33 // settings
34 final File jarFile = new File( "/home/jeff/.minecraft/versions/1.7.10/1.7.10.jar" );
35 gui.setTitle( jarFile.getName() );
36
37 // init the deobfuscator
38 final Deobfuscator deobfuscator = new Deobfuscator( jarFile );
39 gui.setObfClasses( deobfuscator.getObfuscatedClasses() );
40
41 // handle events
42 gui.setClassSelectionHandler( new ClassSelectionHandler( )
43 {
44 @Override
45 public void classSelected( final ClassFile classFile )
46 {
47 gui.setSource( "(deobfuscating...)" );
48
49 // run the deobfuscator in a separate thread so we don't block the GUI event queue
50 new Thread( )
51 {
52 @Override
53 public void run( )
54 {
55 String source = deobfuscator.getSource( classFile );
56 SourceIndex index = Analyzer.analyze( classFile.getName(), source );
57 gui.setSource( source, index );
58 }
59 }.start();
60 }
61 } );
62 }
63}