From 9fb4dce3676a7758f74aeb7acc8ec59df6f55159 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Thu, 7 May 2020 18:42:36 +0200 Subject: [PATCH] Reset export arguments when upgrading from old version (fixes #148) --- src/main/java/com/replaymod/render/RenderSettings.java | 8 ++++++++ .../java/com/replaymod/render/gui/GuiRenderSettings.java | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/replaymod/render/RenderSettings.java b/src/main/java/com/replaymod/render/RenderSettings.java index e64a72dc..cf975c8d 100644 --- a/src/main/java/com/replaymod/render/RenderSettings.java +++ b/src/main/java/com/replaymod/render/RenderSettings.java @@ -1,5 +1,6 @@ package com.replaymod.render; +import com.google.gson.annotations.SerializedName; import com.replaymod.core.versions.MCVer; import de.johni0702.minecraft.gui.utils.lwjgl.ReadableColor; import lombok.AllArgsConstructor; @@ -125,6 +126,13 @@ public class RenderSettings { private final AntiAliasing antiAliasing; private final String exportCommand; + // We switched from rgb24 to bgra for performance at one point, so for backwards compatibility we need to + // reset the arguments if they're from an older version. Easiest way to do that is to just change the key + // and handle the null during loading. + @SerializedName("exportArguments") + // using an empty string as default because old versions will realize it's not a preset and prompt the user + private final String exportArgumentsPreBgra = ""; + @SerializedName("exportArgumentsBgra") private final String exportArguments; private final boolean highPerformance; diff --git a/src/main/java/com/replaymod/render/gui/GuiRenderSettings.java b/src/main/java/com/replaymod/render/gui/GuiRenderSettings.java index 30c2f1fb..754e4553 100644 --- a/src/main/java/com/replaymod/render/gui/GuiRenderSettings.java +++ b/src/main/java/com/replaymod/render/gui/GuiRenderSettings.java @@ -523,7 +523,12 @@ public class GuiRenderSettings extends GuiScreen implements Closeable { injectSphericalMetadata.setChecked(settings.isInjectSphericalMetadata()); antiAliasingDropdown.setSelected(settings.getAntiAliasing()); exportCommand.setText(settings.getExportCommand()); - exportArguments.setText(settings.getExportArguments()); + String exportArguments = settings.getExportArguments(); + if (exportArguments == null) { + // backwards compat, see RenderSettings#exportArguments + exportArguments = settings.getEncodingPreset().getValue(); + } + this.exportArguments.setText(exportArguments); updateInputs(); }