diff options
| author | 2015-02-28 23:36:47 -0500 | |
|---|---|---|
| committer | 2015-02-28 23:36:47 -0500 | |
| commit | 88671184e20b3ad3791125cf96c83ca048cb2861 (patch) | |
| tree | 6c86f1ea61666ff2584b434d5f8df4d3fd83263c /src/cuchaz/enigma/ConvertMain.java | |
| parent | switch to better-maintained version of JSyntaxPane (diff) | |
| download | enigma-fork-88671184e20b3ad3791125cf96c83ca048cb2861.tar.gz enigma-fork-88671184e20b3ad3791125cf96c83ca048cb2861.tar.xz enigma-fork-88671184e20b3ad3791125cf96c83ca048cb2861.zip | |
refactor converter a bit for upcoming convert gui
Diffstat (limited to 'src/cuchaz/enigma/ConvertMain.java')
| -rw-r--r-- | src/cuchaz/enigma/ConvertMain.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/ConvertMain.java b/src/cuchaz/enigma/ConvertMain.java new file mode 100644 index 0000000..7ba4761 --- /dev/null +++ b/src/cuchaz/enigma/ConvertMain.java | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | package cuchaz.enigma; | ||
| 2 | |||
| 3 | import java.io.File; | ||
| 4 | import java.io.FileReader; | ||
| 5 | import java.io.IOException; | ||
| 6 | import java.util.jar.JarFile; | ||
| 7 | |||
| 8 | import cuchaz.enigma.convert.MappingsConverter; | ||
| 9 | import cuchaz.enigma.convert.Matches; | ||
| 10 | import cuchaz.enigma.convert.MatchesReader; | ||
| 11 | import cuchaz.enigma.convert.MatchesWriter; | ||
| 12 | import cuchaz.enigma.gui.MatchingGui; | ||
| 13 | import cuchaz.enigma.mapping.MappingParseException; | ||
| 14 | import cuchaz.enigma.mapping.Mappings; | ||
| 15 | import cuchaz.enigma.mapping.MappingsReader; | ||
| 16 | |||
| 17 | |||
| 18 | public class ConvertMain { | ||
| 19 | |||
| 20 | public static void main(String[] args) | ||
| 21 | throws IOException, MappingParseException { | ||
| 22 | |||
| 23 | // init files | ||
| 24 | File home = new File(System.getProperty("user.home")); | ||
| 25 | JarFile sourceJar = new JarFile(new File(home, ".minecraft/versions/1.8/1.8.jar")); | ||
| 26 | JarFile destJar = new JarFile(new File(home, ".minecraft/versions/1.8.3/1.8.3.jar")); | ||
| 27 | File inMappingsFile = new File("../Enigma Mappings/1.8.mappings"); | ||
| 28 | File outMappingsFile = new File("../Enigma Mappings/1.8.3.mappings"); | ||
| 29 | Mappings mappings = new MappingsReader().read(new FileReader(inMappingsFile)); | ||
| 30 | File matchingFile = new File(inMappingsFile.getName() + ".matching"); | ||
| 31 | |||
| 32 | //computeMatches(matchingFile, sourceJar, destJar, mappings); | ||
| 33 | editMatches(matchingFile, sourceJar, destJar, mappings); | ||
| 34 | //convertMappings(outMappingsFile, mappings, matchingFile); | ||
| 35 | |||
| 36 | /* TODO | ||
| 37 | // write out the converted mappings | ||
| 38 | FileWriter writer = new FileWriter(outMappingsFile); | ||
| 39 | new MappingsWriter().write(writer, mappings); | ||
| 40 | writer.close(); | ||
| 41 | System.out.println("Wrote converted mappings to:\n\t" + outMappingsFile.getAbsolutePath()); | ||
| 42 | */ | ||
| 43 | } | ||
| 44 | |||
| 45 | private static void computeMatches(File matchingFile, JarFile sourceJar, JarFile destJar, Mappings mappings) | ||
| 46 | throws IOException { | ||
| 47 | Matches matches = MappingsConverter.computeMatches(sourceJar, destJar, mappings); | ||
| 48 | MatchesWriter.write(matches, matchingFile); | ||
| 49 | System.out.println("Wrote:\n\t" + matchingFile.getAbsolutePath()); | ||
| 50 | } | ||
| 51 | |||
| 52 | private static void editMatches(File matchingFile, JarFile sourceJar, JarFile destJar, Mappings mappings) | ||
| 53 | throws IOException { | ||
| 54 | System.out.println("Reading matches..."); | ||
| 55 | Matches matches = MatchesReader.read(matchingFile); | ||
| 56 | System.out.println("Indexing source jar..."); | ||
| 57 | Deobfuscator sourceDeobfuscator = new Deobfuscator(sourceJar); | ||
| 58 | sourceDeobfuscator.setMappings(mappings); | ||
| 59 | System.out.println("Indexing dest jar..."); | ||
| 60 | Deobfuscator destDeobfuscator = new Deobfuscator(destJar); | ||
| 61 | System.out.println("Starting GUI..."); | ||
| 62 | new MatchingGui(matches, sourceDeobfuscator, destDeobfuscator); | ||
| 63 | } | ||
| 64 | |||
| 65 | private static void convertMappings(File outMappingsFile, Mappings mappings, File matchingFile) | ||
| 66 | throws IOException { | ||
| 67 | Matches matches = MatchesReader.read(matchingFile); | ||
| 68 | MappingsConverter.convertMappings(mappings, matches.getUniqueMatches()); | ||
| 69 | } | ||
| 70 | } | ||