Add "Add to Queue" button to keyframe repository (closes #168)

This commit is contained in:
Jonas Herzig
2020-08-29 19:13:59 +02:00
parent a92aa9cbbd
commit 4a6c0acc8b
4 changed files with 66 additions and 3 deletions

View File

@@ -45,6 +45,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
@@ -573,6 +574,20 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
return screen;
}
public void setOutputFileBaseName(String base) {
RenderSettings.EncodingPreset preset = encodingPresetDropdown.getSelectedValue();
File file = new File(outputFile.getParentFile(), base + "." + preset.getFileExtension());
// Ensure the file name is valid
try {
//noinspection ResultOfMethodCallIgnored
file.toPath();
outputFile = file;
outputFileButton.setLabel(file.getName());
} catch (InvalidPathException ignored) {
setOutputFileBaseName("filename_invalid_" + base.hashCode());
}
}
protected File conformExtension(File file, RenderSettings.EncodingPreset preset) {
String name = file.getName();
if (name.contains(".")) {