diff options
| author | 2023-11-16 14:40:57 +0100 | |
|---|---|---|
| committer | 2023-11-16 14:40:57 +0100 | |
| commit | edeeb253c9143b3cf53311e1c156fb9f1b2fe4db (patch) | |
| tree | 40cbb06940ecf657f01bd9fb3628e62e4322d41d | |
| parent | Fix importing mappings without field source descriptors (diff) | |
| download | enigma-fork-edeeb253c9143b3cf53311e1c156fb9f1b2fe4db.tar.gz enigma-fork-edeeb253c9143b3cf53311e1c156fb9f1b2fe4db.tar.xz enigma-fork-edeeb253c9143b3cf53311e1c156fb9f1b2fe4db.zip | |
Don't only write diffs when MIO writer was last used
| -rw-r--r-- | enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java | 3 | ||||
| -rw-r--r-- | enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java index 6eab0f8..c579901 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java | |||
| @@ -29,6 +29,7 @@ import javax.swing.JOptionPane; | |||
| 29 | import javax.swing.SwingUtilities; | 29 | import javax.swing.SwingUtilities; |
| 30 | 30 | ||
| 31 | import com.google.common.collect.Lists; | 31 | import com.google.common.collect.Lists; |
| 32 | import org.jetbrains.annotations.ApiStatus; | ||
| 32 | 33 | ||
| 33 | import cuchaz.enigma.Enigma; | 34 | import cuchaz.enigma.Enigma; |
| 34 | import cuchaz.enigma.EnigmaProfile; | 35 | import cuchaz.enigma.EnigmaProfile; |
| @@ -139,6 +140,7 @@ public class GuiController implements ClientPacketHandler { | |||
| 139 | this.gui.onCloseJar(); | 140 | this.gui.onCloseJar(); |
| 140 | } | 141 | } |
| 141 | 142 | ||
| 143 | @ApiStatus.Internal | ||
| 142 | public CompletableFuture<Void> openMappings(MappingFormat format, Path path, boolean useMappingIo) { | 144 | public CompletableFuture<Void> openMappings(MappingFormat format, Path path, boolean useMappingIo) { |
| 143 | System.getProperties().setProperty("enigma.use_mappingio", useMappingIo ? "true" : "false"); | 145 | System.getProperties().setProperty("enigma.use_mappingio", useMappingIo ? "true" : "false"); |
| 144 | return openMappings(format, path); | 146 | return openMappings(format, path); |
| @@ -182,6 +184,7 @@ public class GuiController implements ClientPacketHandler { | |||
| 182 | return saveMappings(path, loadedMappingFormat); | 184 | return saveMappings(path, loadedMappingFormat); |
| 183 | } | 185 | } |
| 184 | 186 | ||
| 187 | @ApiStatus.Internal | ||
| 185 | public CompletableFuture<Void> saveMappings(Path path, MappingFormat format, boolean useMappingIo) { | 188 | public CompletableFuture<Void> saveMappings(Path path, MappingFormat format, boolean useMappingIo) { |
| 186 | System.getProperties().setProperty("enigma.use_mappingio", useMappingIo ? "true" : "false"); | 189 | System.getProperties().setProperty("enigma.use_mappingio", useMappingIo ? "true" : "false"); |
| 187 | return saveMappings(path, format); | 190 | return saveMappings(path, format); |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java b/enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java index 530aff4..88f722c 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/mapping/serde/MappingFormat.java | |||
| @@ -49,6 +49,7 @@ public enum MappingFormat { | |||
| 49 | private final MappingsReader reader; | 49 | private final MappingsReader reader; |
| 50 | private final net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart; | 50 | private final net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart; |
| 51 | private final boolean hasMappingIoWriter; | 51 | private final boolean hasMappingIoWriter; |
| 52 | private boolean lastUsedMappingIoWriter; | ||
| 52 | 53 | ||
| 53 | MappingFormat(MappingsWriter writer, MappingsReader reader, net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart, boolean hasMappingIoWriter) { | 54 | MappingFormat(MappingsWriter writer, MappingsReader reader, net.fabricmc.mappingio.format.MappingFormat mappingIoCounterpart, boolean hasMappingIoWriter) { |
| 54 | this.writer = writer; | 55 | this.writer = writer; |
| @@ -67,7 +68,8 @@ public enum MappingFormat { | |||
| 67 | throw new IllegalStateException(name() + " does not support writing"); | 68 | throw new IllegalStateException(name() + " does not support writing"); |
| 68 | } | 69 | } |
| 69 | 70 | ||
| 70 | writer.write(mappings, delta, path, progressListener, saveParameters); | 71 | writer.write(mappings, lastUsedMappingIoWriter ? MappingDelta.added(mappings) : delta, path, progressListener, saveParameters); |
| 72 | lastUsedMappingIoWriter = false; | ||
| 71 | return; | 73 | return; |
| 72 | } | 74 | } |
| 73 | 75 | ||
| @@ -78,6 +80,7 @@ public enum MappingFormat { | |||
| 78 | 80 | ||
| 79 | tree.accept(MappingWriter.create(path, mappingIoCounterpart), VisitOrder.createByName()); | 81 | tree.accept(MappingWriter.create(path, mappingIoCounterpart), VisitOrder.createByName()); |
| 80 | progressListener.step(1, I18n.translate("progress.done")); | 82 | progressListener.step(1, I18n.translate("progress.done")); |
| 83 | lastUsedMappingIoWriter = true; | ||
| 81 | } catch (IOException e) { | 84 | } catch (IOException e) { |
| 82 | throw new UncheckedIOException(e); | 85 | throw new UncheckedIOException(e); |
| 83 | } | 86 | } |