Fix output file render setting not being saved (fixes #229)
This commit is contained in:
@@ -95,10 +95,9 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
}
|
}
|
||||||
// Update export arguments to match new Preset
|
// Update export arguments to match new Preset
|
||||||
exportArguments.setText(newPreset.getValue());
|
exportArguments.setText(newPreset.getValue());
|
||||||
// If the user hasn't changed the output file by themselves,
|
// Update output file ending
|
||||||
if (!outputFileManuallySet) {
|
if (outputFile != null) {
|
||||||
// generate a new output file name with updated file extension
|
outputFile = conformExtension(outputFile, newPreset);
|
||||||
outputFile = generateOutputFile(newPreset);
|
|
||||||
outputFileButton.setLabel(outputFile.getName());
|
outputFileButton.setLabel(outputFile.getName());
|
||||||
}
|
}
|
||||||
updateInputs();
|
updateInputs();
|
||||||
@@ -135,8 +134,10 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(@Nullable File result) {
|
public void onSuccess(@Nullable File result) {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
if (!result.getName().equals(outputFile.getName())) {
|
||||||
|
userDefinedOutputFileName = true;
|
||||||
|
}
|
||||||
outputFile = result;
|
outputFile = result;
|
||||||
outputFileManuallySet = true;
|
|
||||||
outputFileButton.setLabel(result.getName());
|
outputFileButton.setLabel(result.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,7 +322,7 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
private final ReplayHandler replayHandler;
|
private final ReplayHandler replayHandler;
|
||||||
private final Timeline timeline;
|
private final Timeline timeline;
|
||||||
private File outputFile;
|
private File outputFile;
|
||||||
private boolean outputFileManuallySet;
|
private boolean userDefinedOutputFileName;
|
||||||
|
|
||||||
public GuiRenderSettings(ReplayHandler replayHandler, Timeline timeline) {
|
public GuiRenderSettings(ReplayHandler replayHandler, Timeline timeline) {
|
||||||
this.replayHandler = replayHandler;
|
this.replayHandler = replayHandler;
|
||||||
@@ -503,14 +504,19 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
bitRateField.setValue(settings.getBitRate());
|
bitRateField.setValue(settings.getBitRate());
|
||||||
bitRateUnit.setSelected(0);
|
bitRateUnit.setSelected(0);
|
||||||
}
|
}
|
||||||
if (settings.getOutputFile() == null) {
|
File savedOutputFile = settings.getOutputFile();
|
||||||
outputFile = generateOutputFile(settings.getEncodingPreset());
|
if (savedOutputFile == null || !savedOutputFile.getParentFile().exists()) {
|
||||||
outputFileManuallySet = false;
|
this.outputFile = generateOutputFile(settings.getEncodingPreset());
|
||||||
|
userDefinedOutputFileName = false;
|
||||||
|
} else if (savedOutputFile.exists()) {
|
||||||
|
String name = generateOutputFile(settings.getEncodingPreset()).getName();
|
||||||
|
this.outputFile = new File(savedOutputFile.isDirectory() ? savedOutputFile : savedOutputFile.getParentFile(), name);
|
||||||
|
userDefinedOutputFileName = false;
|
||||||
} else {
|
} else {
|
||||||
outputFile = settings.getOutputFile();
|
this.outputFile = conformExtension(savedOutputFile, settings.getEncodingPreset());
|
||||||
outputFileManuallySet = true;
|
userDefinedOutputFileName = true;
|
||||||
}
|
}
|
||||||
outputFileButton.setLabel(outputFile.getName());
|
outputFileButton.setLabel(this.outputFile.getName());
|
||||||
nametagCheckbox.setChecked(settings.isRenderNameTags());
|
nametagCheckbox.setChecked(settings.isRenderNameTags());
|
||||||
stabilizeYaw.setChecked(settings.isStabilizeYaw());
|
stabilizeYaw.setChecked(settings.isStabilizeYaw());
|
||||||
stabilizePitch.setChecked(settings.isStabilizePitch());
|
stabilizePitch.setChecked(settings.isStabilizePitch());
|
||||||
@@ -546,7 +552,7 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
videoHeight.getInteger(),
|
videoHeight.getInteger(),
|
||||||
frameRateSlider.getValue() + 10,
|
frameRateSlider.getValue() + 10,
|
||||||
bitRateField.getInteger() << (10 * bitRateUnit.getSelected()),
|
bitRateField.getInteger() << (10 * bitRateUnit.getSelected()),
|
||||||
serialize ? null : outputFile,
|
serialize && !userDefinedOutputFileName ? outputFile.getParentFile() : outputFile,
|
||||||
nametagCheckbox.isChecked(),
|
nametagCheckbox.isChecked(),
|
||||||
stabilizeYaw.isChecked() && (serialize || stabilizeYaw.isEnabled()),
|
stabilizeYaw.isChecked() && (serialize || stabilizeYaw.isEnabled()),
|
||||||
stabilizePitch.isChecked() && (serialize || stabilizePitch.isEnabled()),
|
stabilizePitch.isChecked() && (serialize || stabilizePitch.isEnabled()),
|
||||||
@@ -567,6 +573,14 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
return new File(folder, fileName + "." + encodingPreset.getFileExtension());
|
return new File(folder, fileName + "." + encodingPreset.getFileExtension());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected File conformExtension(File file, RenderSettings.EncodingPreset preset) {
|
||||||
|
String name = file.getName();
|
||||||
|
if (name.contains(".")) {
|
||||||
|
name = name.substring(0, name.lastIndexOf('.'));
|
||||||
|
}
|
||||||
|
return new File(file.getParentFile(), name + "." + preset.getFileExtension());
|
||||||
|
}
|
||||||
|
|
||||||
protected Path getSettingsPath() {
|
protected Path getSettingsPath() {
|
||||||
return ReplayModRender.instance.getRenderSettingsPath();
|
return ReplayModRender.instance.getRenderSettingsPath();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user