Reset export arguments when upgrading from old version (fixes #148)

This commit is contained in:
Jonas Herzig
2020-05-07 18:42:36 +02:00
parent 811f52dc17
commit 9fb4dce367
2 changed files with 14 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
package com.replaymod.render; package com.replaymod.render;
import com.google.gson.annotations.SerializedName;
import com.replaymod.core.versions.MCVer; import com.replaymod.core.versions.MCVer;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableColor; import de.johni0702.minecraft.gui.utils.lwjgl.ReadableColor;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -125,6 +126,13 @@ public class RenderSettings {
private final AntiAliasing antiAliasing; private final AntiAliasing antiAliasing;
private final String exportCommand; 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 String exportArguments;
private final boolean highPerformance; private final boolean highPerformance;

View File

@@ -523,7 +523,12 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
injectSphericalMetadata.setChecked(settings.isInjectSphericalMetadata()); injectSphericalMetadata.setChecked(settings.isInjectSphericalMetadata());
antiAliasingDropdown.setSelected(settings.getAntiAliasing()); antiAliasingDropdown.setSelected(settings.getAntiAliasing());
exportCommand.setText(settings.getExportCommand()); 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(); updateInputs();
} }