Merge branch 'stable' into develop
This commit is contained in:
@@ -443,4 +443,32 @@ public class RenderSettings {
|
||||
public boolean isHighPerformance() {
|
||||
return highPerformance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RenderSettings{" +
|
||||
"renderMethod=" + renderMethod +
|
||||
", encodingPreset=" + encodingPreset +
|
||||
", videoWidth=" + videoWidth +
|
||||
", videoHeight=" + videoHeight +
|
||||
", framesPerSecond=" + framesPerSecond +
|
||||
", bitRate=" + bitRate +
|
||||
", outputFile=" + outputFile +
|
||||
", renderNameTags=" + renderNameTags +
|
||||
", stabilizeYaw=" + stabilizeYaw +
|
||||
", stabilizePitch=" + stabilizePitch +
|
||||
", stabilizeRoll=" + stabilizeRoll +
|
||||
", chromaKeyingColor=" + chromaKeyingColor +
|
||||
", sphericalFovX=" + sphericalFovX +
|
||||
", sphericalFovY=" + sphericalFovY +
|
||||
", injectSphericalMetadata=" + injectSphericalMetadata +
|
||||
", depthMap=" + depthMap +
|
||||
", cameraPathExport=" + cameraPathExport +
|
||||
", antiAliasing=" + antiAliasing +
|
||||
", exportCommand='" + exportCommand + '\'' +
|
||||
", exportArgumentsPreBgra='" + exportArgumentsPreBgra + '\'' +
|
||||
", exportArguments='" + exportArguments + '\'' +
|
||||
", highPerformance=" + highPerformance +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
||||
|
||||
@@ -148,8 +149,15 @@ public class GuiRenderQueue extends AbstractGuiPopup<GuiRenderQueue> implements
|
||||
renderButton.onClick(() -> {
|
||||
LOGGER.trace("Render button clicked");
|
||||
List<RenderJob> renderQueue = new ArrayList<>();
|
||||
for (Entry entry : selectedEntries) {
|
||||
renderQueue.add(entry.job);
|
||||
if (selectedEntries.isEmpty()) {
|
||||
renderQueue.addAll(jobs);
|
||||
} else {
|
||||
Set<RenderJob> selectedJobs = selectedEntries.stream().map(it -> it.job).collect(Collectors.toSet());
|
||||
for (RenderJob job : jobs) {
|
||||
if (selectedJobs.contains(job)) {
|
||||
renderQueue.add(job);
|
||||
}
|
||||
}
|
||||
}
|
||||
ReplayMod.instance.runLaterWithoutLock(() -> processQueue(container, replayHandler, renderQueue, () -> {}));
|
||||
});
|
||||
@@ -337,7 +345,7 @@ public class GuiRenderQueue extends AbstractGuiPopup<GuiRenderQueue> implements
|
||||
addButton.setEnabled(timelineSupplier != null);
|
||||
editButton.setEnabled(selected == 1);
|
||||
removeButton.setEnabled(selected >= 1);
|
||||
renderButton.setEnabled(selected > 0);
|
||||
renderButton.setEnabled(jobs.size() > 0);
|
||||
renderButton.setI18nLabel("replaymod.gui.renderqueue.render" + (selected > 0 ? "selected" : "all"));
|
||||
|
||||
String[] compatError = VideoRenderer.checkCompat();
|
||||
|
||||
@@ -126,7 +126,7 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
public void run() {
|
||||
GuiFileChooserPopup popup = GuiFileChooserPopup.openSaveGui(GuiRenderSettings.this, "replaymod.gui.save",
|
||||
encodingPresetDropdown.getSelectedValue().getFileExtension());
|
||||
popup.setFolder(outputFile.getParentFile());
|
||||
popup.setFolder(getParentFile(outputFile));
|
||||
popup.setFileName(outputFile.getName());
|
||||
popup.onAccept(file -> {
|
||||
if (!file.getName().equals(outputFile.getName())) {
|
||||
@@ -523,13 +523,13 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
bitRateUnit.setSelected(0);
|
||||
}
|
||||
File savedOutputFile = settings.getOutputFile();
|
||||
if (savedOutputFile == null || !savedOutputFile.getParentFile().exists()) {
|
||||
if (savedOutputFile == null || !getParentFile(savedOutputFile).exists()) {
|
||||
this.outputFile = generateOutputFile(encodingPreset);
|
||||
userDefinedOutputFileName = false;
|
||||
} else if (savedOutputFile.exists()) {
|
||||
String name = generateOutputFile(encodingPreset).getName();
|
||||
boolean isFolder = savedOutputFile.isDirectory() && !savedOutputFile.getName().endsWith(".exr");
|
||||
this.outputFile = new File(isFolder ? savedOutputFile : savedOutputFile.getParentFile(), name);
|
||||
this.outputFile = new File(isFolder ? savedOutputFile : getParentFile(savedOutputFile), name);
|
||||
userDefinedOutputFileName = false;
|
||||
} else {
|
||||
this.outputFile = conformExtension(savedOutputFile, encodingPreset);
|
||||
@@ -573,7 +573,7 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
videoHeight.getInteger(),
|
||||
frameRateSlider.getValue() + 10,
|
||||
bitRateField.getInteger() << (10 * bitRateUnit.getSelected()),
|
||||
serialize && !userDefinedOutputFileName ? outputFile.getParentFile() : outputFile,
|
||||
serialize && !userDefinedOutputFileName ? getParentFile(outputFile) : outputFile,
|
||||
nametagCheckbox.isChecked(),
|
||||
stabilizeYaw.isChecked() && (serialize || stabilizeYaw.isEnabled()),
|
||||
stabilizePitch.isChecked() && (serialize || stabilizePitch.isEnabled()),
|
||||
@@ -602,7 +602,7 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
|
||||
public void setOutputFileBaseName(String base) {
|
||||
RenderSettings.EncodingPreset preset = encodingPresetDropdown.getSelectedValue();
|
||||
File file = new File(outputFile.getParentFile(), base + "." + preset.getFileExtension());
|
||||
File file = new File(getParentFile(outputFile), base + "." + preset.getFileExtension());
|
||||
// Ensure the file name is valid
|
||||
try {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
@@ -619,7 +619,7 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
if (name.contains(".")) {
|
||||
name = name.substring(0, name.lastIndexOf('.'));
|
||||
}
|
||||
return new File(file.getParentFile(), name + "." + preset.getFileExtension());
|
||||
return new File(getParentFile(file), name + "." + preset.getFileExtension());
|
||||
}
|
||||
|
||||
protected Path getSettingsPath() {
|
||||
@@ -662,4 +662,10 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
screen.setBackground(AbstractGuiScreen.Background.NONE);
|
||||
return screen;
|
||||
}
|
||||
|
||||
private static File getParentFile(File file) {
|
||||
File parent = file.getParentFile();
|
||||
// parent this can be null if file is just a name (i.e. in CWD)
|
||||
return parent == null ? new File(".") : parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.replaymod.render.gui.GuiRenderingDone;
|
||||
import com.replaymod.render.gui.GuiVideoRenderer;
|
||||
import com.replaymod.render.metadata.MetadataInjector;
|
||||
import com.replaymod.render.mixin.WorldRendererAccessor;
|
||||
import com.replaymod.render.utils.SoundHandler;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||
import com.replaymod.replaystudio.pathing.path.Path;
|
||||
@@ -29,6 +28,7 @@ import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import com.mojang.blaze3d.platform.GLX;
|
||||
import net.minecraft.client.gl.Framebuffer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.crash.CrashException;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
@@ -422,7 +422,7 @@ public class VideoRenderer implements RenderInfo {
|
||||
}
|
||||
}
|
||||
|
||||
new SoundHandler().playRenderSuccessSound();
|
||||
MCVer.playSound(new Identifier("replaymod", "render_success"));
|
||||
|
||||
try {
|
||||
if (!hasFailed() && ffmpegWriter != null) {
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.replaymod.render.utils;
|
||||
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.Clip;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class SoundHandler {
|
||||
|
||||
private final Identifier successSoundLocation = new Identifier("replaymod", "render_success.wav");
|
||||
|
||||
public void playRenderSuccessSound() {
|
||||
playSound(successSoundLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays a <b>.wav</b> Sound from a ResourceLocation. This method does <b>not</b> respect Game Settings like Audio Volume.
|
||||
* @param loc The Sound File's ResourceLocation
|
||||
*/
|
||||
public void playSound(Identifier loc) {
|
||||
try {
|
||||
InputStream is = MCVer.getMinecraft().getResourceManager().getResource(loc).getInputStream();
|
||||
byte[] bytes = IOUtils.toByteArray(is);
|
||||
is.close();
|
||||
AudioInputStream ais = AudioSystem.getAudioInputStream(new ByteArrayInputStream(bytes));
|
||||
|
||||
Clip clip = AudioSystem.getClip();
|
||||
clip.open(ais);
|
||||
clip.start();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user