summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/GuiController.java
diff options
context:
space:
mode:
authorGravatar Thomas Guillemard2016-08-12 19:23:54 +0200
committerGravatar Adrian Siekierka2016-08-12 19:23:54 +0200
commitc4970cc4addedd4565cf8c3ed9ea92b6a4487e0c (patch)
treea6f00a59cd0d5bc41014768506d9c4d3aad48de8 /src/main/java/cuchaz/enigma/gui/GuiController.java
parentAllow exporting mappings as SRG or Enigma (diff)
downloadenigma-fork-c4970cc4addedd4565cf8c3ed9ea92b6a4487e0c.tar.gz
enigma-fork-c4970cc4addedd4565cf8c3ed9ea92b6a4487e0c.tar.xz
enigma-fork-c4970cc4addedd4565cf8c3ed9ea92b6a4487e0c.zip
Implement Enigma directory format (#1)
Others changes: ~ Rework File menu ~ Force UTF-8 for all I/O operations ~ Enigma now detect the original file format and use the correct one when you save a mapping
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/GuiController.java')
-rw-r--r--src/main/java/cuchaz/enigma/gui/GuiController.java35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/GuiController.java b/src/main/java/cuchaz/enigma/gui/GuiController.java
index fe7d097..d416345 100644
--- a/src/main/java/cuchaz/enigma/gui/GuiController.java
+++ b/src/main/java/cuchaz/enigma/gui/GuiController.java
@@ -16,7 +16,6 @@ import com.google.common.collect.Queues;
16import com.strobel.decompiler.languages.java.ast.CompilationUnit; 16import com.strobel.decompiler.languages.java.ast.CompilationUnit;
17 17
18import java.io.File; 18import java.io.File;
19import java.io.FileReader;
20import java.io.FileWriter; 19import java.io.FileWriter;
21import java.io.IOException; 20import java.io.IOException;
22import java.util.Collection; 21import java.util.Collection;
@@ -65,18 +64,16 @@ public class GuiController {
65 this.gui.onCloseJar(); 64 this.gui.onCloseJar();
66 } 65 }
67 66
68 public void openOldMappings(File file) throws IOException, MappingParseException { 67 public void openEnigmaMappings(File file) throws IOException, MappingParseException {
69 FileReader in = new FileReader(file); 68 this.deobfuscator.setMappings(new MappingsEnigmaReader().read(file));
70 this.deobfuscator.setMappings(new MappingsReaderOld().read(in));
71 in.close();
72 this.isDirty = false; 69 this.isDirty = false;
73 this.gui.setMappingsFile(file); 70 this.gui.setMappingsFile(file);
74 refreshClasses(); 71 refreshClasses();
75 refreshCurrentClass(); 72 refreshCurrentClass();
76 } 73 }
77 74
78 public void openMappings(File file) throws IOException { 75 public void openJsonMappings(File file) throws IOException {
79 this.deobfuscator.setMappings(new MappingsReader().read(file)); 76 this.deobfuscator.setMappings(new MappingsJsonReader().read(file));
80 this.isDirty = false; 77 this.isDirty = false;
81 this.gui.setMappingsFile(file); 78 this.gui.setMappingsFile(file);
82 refreshClasses(); 79 refreshClasses();
@@ -84,13 +81,29 @@ public class GuiController {
84 } 81 }
85 82
86 public void saveMappings(File file) throws IOException { 83 public void saveMappings(File file) throws IOException {
87 new MappingsWriter().write(file, this.deobfuscator.getMappings()); 84 Mappings mappings = this.deobfuscator.getMappings();
85 switch (mappings.getOriginMappingFormat())
86 {
87 case SRG_FILE:
88 saveSRGMappings(file);
89 break;
90 case JSON_DIRECTORY:
91 saveJsonMappings(file);
92 break;
93 default:
94 saveEnigmaMappings(file, Mappings.FormatType.ENIGMA_FILE != mappings.getOriginMappingFormat());
95 break;
96 }
97
98 }
99
100 public void saveJsonMappings(File file) throws IOException {
101 new MappingsJsonWriter().write(file, this.deobfuscator.getMappings());
88 this.isDirty = false; 102 this.isDirty = false;
89 } 103 }
90 104
91 public void saveOldMappings(File file) throws IOException { 105 public void saveEnigmaMappings(File file, boolean isDirectoryFormat) throws IOException {
92 FileWriter out = new FileWriter(file); 106 new MappingsEnigmaWriter().write(file, this.deobfuscator.getMappings(), isDirectoryFormat);
93 new MappingsOldWriter().write(out, this.deobfuscator.getMappings());
94 this.isDirty = false; 107 this.isDirty = false;
95 } 108 }
96 109