Rewrote GuiRenderSettings to use the semi-new Gui System and have three instead of two pages (Video Settings, Advanced Settings, Command Line Settings)
This commit is contained in:
@@ -2,6 +2,7 @@ package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.*;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.CheckBoxListener;
|
||||
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
|
||||
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
||||
import eu.crushedpixel.replaymod.holders.GuiEntryListEntry;
|
||||
@@ -13,13 +14,10 @@ import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.utils.StringUtils;
|
||||
import eu.crushedpixel.replaymod.video.rendering.Pipelines;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -29,301 +27,308 @@ import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
//for default file
|
||||
private static final String DATE_FORMAT = "yyyy_MM_dd_HH_mm_ss";
|
||||
private static final SimpleDateFormat FILE_FORMAT = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
private static final int LEFT_BORDER = 10;
|
||||
|
||||
private GuiAdvancedButton renderButton, cancelButton, advancedButton;
|
||||
private GuiDropdown<RendererSettings> rendererDropdown;
|
||||
private GuiDropdown<EncodingPreset> encodingPresetDropdown;
|
||||
private GuiAdvancedButton renderButton = new GuiAdvancedButton(0, 0, 100, 20, I18n.format("replaymod.gui.render"), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startRendering();
|
||||
}
|
||||
}, null);
|
||||
|
||||
private GuiAdvancedButton cancelButton = new GuiAdvancedButton(0, 0, 100, 20, I18n.format("replaymod.gui.cancel"), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
}, null);
|
||||
|
||||
private GuiAdvancedButton toggleTabButton = new GuiAdvancedButton(0, 0, 150, 20, I18n.format("replaymod.gui.rendersettings.advanced"), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
toggleTab();
|
||||
}
|
||||
}, null);
|
||||
|
||||
private GuiNumberInput xRes = new GuiNumberInput(mc.fontRendererObj, 0, 0, 50, 1, 100000, mc.displayWidth, false) {
|
||||
@Override
|
||||
public void moveCursorBy(int move) {
|
||||
super.moveCursorBy(move);
|
||||
RendererSettings renderer = rendererDropdown.getElement(rendererDropdown.getSelectionIndex());
|
||||
Integer value = getIntValueNullable();
|
||||
if (value != null) {
|
||||
if (renderer == RendererSettings.CUBIC) {
|
||||
yRes.text = Integer.toString(Math.max(1, value * 3 / 4));
|
||||
}
|
||||
if (renderer == RendererSettings.EQUIRECTANGULAR) {
|
||||
yRes.text = Integer.toString(Math.max(1, value / 2));
|
||||
}
|
||||
}
|
||||
yRes.setCursorPositionEnd();
|
||||
validateInputs();
|
||||
}
|
||||
};
|
||||
|
||||
private GuiNumberInput yRes = new GuiNumberInput(mc.fontRendererObj, 0, 0, 50, 1, 10000, mc.displayHeight, false) {
|
||||
@Override
|
||||
public void moveCursorBy(int move) {
|
||||
super.moveCursorBy(move);
|
||||
RendererSettings renderer = rendererDropdown.getElement(rendererDropdown.getSelectionIndex());
|
||||
Integer value = getIntValueNullable();
|
||||
if (value != null) {
|
||||
if (renderer == RendererSettings.CUBIC) {
|
||||
xRes.text = Integer.toString(value * 4 / 3);
|
||||
}
|
||||
if (renderer == RendererSettings.EQUIRECTANGULAR) {
|
||||
xRes.text = Integer.toString(value * 2);
|
||||
}
|
||||
}
|
||||
xRes.setCursorPositionEnd();
|
||||
validateInputs();
|
||||
}
|
||||
};
|
||||
|
||||
private GuiString rendererString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.rendersettings.renderer")+":");
|
||||
private GuiString presetsString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.rendersettings.presets")+":");
|
||||
private GuiString resolutionString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.rendersettings.customresolution")+":");
|
||||
private GuiString asteriksString = new GuiString(0, 0, Color.WHITE, "*");
|
||||
private GuiString bitrateString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.settings.bitrate")+":");
|
||||
private GuiString fileChooserString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.rendersettings.outputfile")+":");
|
||||
|
||||
private GuiDropdown<RendererSettings> rendererDropdown = new GuiDropdown<RendererSettings>(mc.fontRendererObj, 0, 0, 200, 5);
|
||||
private GuiDropdown<EncodingPreset> encodingPresetDropdown = new GuiDropdown<EncodingPreset>(mc.fontRendererObj, 0, 1, 200, 5);
|
||||
|
||||
private GuiString stabilizeString = new GuiString(0, 0, Color.WHITE, I18n.format("replaymod.gui.rendersettings.stabilizecamera")+":");
|
||||
|
||||
private GuiAdvancedCheckBox stablePitch = new GuiAdvancedCheckBox(I18n.format("replaymod.gui.pitch"), false, false);
|
||||
private GuiAdvancedCheckBox stableYaw = new GuiAdvancedCheckBox(I18n.format("replaymod.gui.yaw"), false, false);
|
||||
private GuiAdvancedCheckBox stableRoll = new GuiAdvancedCheckBox(I18n.format("replaymod.gui.roll"), false, false);
|
||||
|
||||
private int virtualY, virtualHeight;
|
||||
|
||||
private GuiCheckBox ignoreCamDir, enableGreenscreen, renderNameTags;
|
||||
private GuiNumberInput xRes, yRes;
|
||||
private GuiToggleButton interpolation, forceChunks;
|
||||
private GuiVideoFramerateSlider framerateSlider;
|
||||
private GuiNumberInput bitrateInput;
|
||||
private GuiColorPicker colorPicker;
|
||||
private GuiAdvancedTextField commandInput, ffmpegArguments;
|
||||
private GuiFileChooser outputFileChooser;
|
||||
private GuiAdvancedCheckBox enableGreenscreen = new GuiAdvancedCheckBox(0, 0, I18n.format("replaymod.gui.rendersettings.chromakey"), false);
|
||||
private GuiAdvancedCheckBox renderNameTags = new GuiAdvancedCheckBox(0, 0, I18n.format("replaymod.gui.rendersettings.nametags"), true);
|
||||
|
||||
private List<GuiButton> permanentButtons = new ArrayList<GuiButton>();
|
||||
private List<GuiButton> defaultButtons = new ArrayList<GuiButton>();
|
||||
private List<GuiButton> advancedButtons = new ArrayList<GuiButton>();
|
||||
|
||||
private boolean advancedTab = false;
|
||||
|
||||
private int w1;
|
||||
|
||||
private boolean initialized;
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
if(!initialized) {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
|
||||
rendererDropdown = new GuiDropdown<RendererSettings>(fontRendererObj, 0, 0, 200, 5);
|
||||
rendererDropdown.addSelectionListener(new RendererDropdownListener());
|
||||
|
||||
int i = 0;
|
||||
for (RendererSettings r : RendererSettings.values()) {
|
||||
rendererDropdown.addElement(r);
|
||||
rendererDropdown.setHoverText(i, r.getDescription());
|
||||
i++;
|
||||
{
|
||||
enableGreenscreen.addCheckBoxListener(new CheckBoxListener() {
|
||||
@Override
|
||||
public void onCheck(boolean checked) {
|
||||
colorPicker.setElementEnabled(checked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
encodingPresetDropdown = new GuiDropdown<EncodingPreset>(fontRendererObj, 0, 0, 200, 5);
|
||||
encodingPresetDropdown.addSelectionListener(new EncodingDropdownListener());
|
||||
private GuiVideoFramerateSlider framerateSlider = new GuiVideoFramerateSlider(0, 0, ReplayMod.replaySettings.getVideoFramerate(),
|
||||
I18n.format("replaymod.gui.rendersettings.framerate"));
|
||||
|
||||
for (EncodingPreset preset : EncodingPreset.values()) {
|
||||
encodingPresetDropdown.addElement(preset);
|
||||
}
|
||||
private GuiNumberInput bitrateInput = new GuiNumberInputWithText(mc.fontRendererObj, 0, 0, 50, 1D, null, 10000D, false, " kbps");
|
||||
private GuiColorPicker colorPicker = new GuiColorPicker(GuiConstants.RENDER_SETTINGS_COLOR_PICKER, 0, 0, I18n.format("replaymod.gui.rendersettings.skycolor")+": ", 0, 0);
|
||||
private GuiAdvancedTextField commandInput = new GuiAdvancedTextField(mc.fontRendererObj, I18n.format("replaymod.gui.rendersettings.command"), 3000);
|
||||
private GuiAdvancedTextField ffmpegArguments = new GuiAdvancedTextField(mc.fontRendererObj, I18n.format("replaymod.gui.rendersettings.ffmpeghint"), 3000);
|
||||
|
||||
renderButton = new GuiAdvancedButton(GuiConstants.RENDER_SETTINGS_RENDER_BUTTON, 0, 0, I18n.format("replaymod.gui.render"));
|
||||
cancelButton = new GuiAdvancedButton(GuiConstants.RENDER_SETTINGS_CANCEL_BUTTON, 0, 0, I18n.format("replaymod.gui.cancel"));
|
||||
advancedButton = new GuiAdvancedButton(GuiConstants.RENDER_SETTINGS_ADVANCED_BUTTON, 0, 0, I18n.format("replaymod.gui.rendersettings.advanced"));
|
||||
|
||||
xRes = new GuiNumberInput(fontRendererObj, 0, 0, 50, 1, 100000, mc.displayWidth, false) {
|
||||
@Override
|
||||
public void moveCursorBy(int move) {
|
||||
super.moveCursorBy(move);
|
||||
RendererSettings renderer = rendererDropdown.getElement(rendererDropdown.getSelectionIndex());
|
||||
Integer value = getIntValueNullable();
|
||||
if (value != null) {
|
||||
if (renderer == RendererSettings.CUBIC) {
|
||||
yRes.text = Integer.toString(Math.max(1, value * 3 / 4));
|
||||
}
|
||||
if (renderer == RendererSettings.EQUIRECTANGULAR) {
|
||||
yRes.text = Integer.toString(Math.max(1, value / 2));
|
||||
}
|
||||
}
|
||||
yRes.setCursorPositionEnd();
|
||||
validateInputs();
|
||||
}
|
||||
};
|
||||
yRes = new GuiNumberInput(fontRendererObj, 0, 0, 50, 1, 10000, mc.displayHeight, false) {
|
||||
@Override
|
||||
public void moveCursorBy(int move) {
|
||||
super.moveCursorBy(move);
|
||||
RendererSettings renderer = rendererDropdown.getElement(rendererDropdown.getSelectionIndex());
|
||||
Integer value = getIntValueNullable();
|
||||
if (value != null) {
|
||||
if (renderer == RendererSettings.CUBIC) {
|
||||
xRes.text = Integer.toString(value * 4 / 3);
|
||||
}
|
||||
if (renderer == RendererSettings.EQUIRECTANGULAR) {
|
||||
xRes.text = Integer.toString(value * 2);
|
||||
}
|
||||
}
|
||||
xRes.setCursorPositionEnd();
|
||||
validateInputs();
|
||||
}
|
||||
};
|
||||
|
||||
bitrateInput = new GuiNumberInputWithText(fontRendererObj, 0, 0, 50, 1D, null, 10000D, false, " kbps");
|
||||
|
||||
bitrateInput.setElementEnabled(true);
|
||||
|
||||
framerateSlider = new GuiVideoFramerateSlider(GuiConstants.RENDER_SETTINGS_FRAMERATE_SLIDER, 0, 0, ReplayMod.replaySettings.getVideoFramerate(),
|
||||
I18n.format("replaymod.gui.rendersettings.framerate"));
|
||||
|
||||
File defaultFile = null;
|
||||
try {
|
||||
defaultFile = new File(ReplayFileIO.getRenderFolder(), FILE_FORMAT.format(Calendar.getInstance().getTime())+"."+ EncodingPreset.MP4DEFAULT.getFileExtension());
|
||||
} catch(IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
|
||||
outputFileChooser = new GuiFileChooser(GuiConstants.RENDER_SETTINGS_OUTPUT_CHOOSER, 0, 0, I18n.format("replaymod.gui.rendersettings.outputfile")+": ", defaultFile, new String[]{"webm"}, true);
|
||||
|
||||
interpolation = new GuiToggleButton(GuiConstants.RENDER_SETTINGS_INTERPOLATION_BUTTON, 0, 0,
|
||||
I18n.format("replaymod.gui.rendersettings.interpolation")+": ",
|
||||
new String[]{I18n.format("replaymod.gui.settings.interpolation.cubic"),
|
||||
I18n.format("replaymod.gui.settings.interpolation.linear")});
|
||||
|
||||
interpolation.setValue(ReplayMod.replaySettings.isLinearMovement() ? 1 : 0);
|
||||
|
||||
forceChunks = new GuiToggleButton(GuiConstants.RENDER_SETTINGS_FORCECHUNKS_BUTTON, 0, 0,
|
||||
I18n.format("replaymod.gui.rendersettings.forcechunks")+": ",
|
||||
new String[]{I18n.format("options.on"), I18n.format("options.off")});
|
||||
|
||||
forceChunks.setValue(ReplayMod.replaySettings.getWaitForChunks() ? 0 : 1);
|
||||
|
||||
forceChunks.width = interpolation.width = framerateSlider.width = 150;
|
||||
|
||||
enableGreenscreen = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_ENABLE_GREENSCREEN, 0, 0, I18n.format("replaymod.gui.rendersettings.chromakey"), false);
|
||||
renderNameTags = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_RENDER_NAMETAGS, 0, 0, I18n.format("replaymod.gui.rendersettings.nametags"), true);
|
||||
|
||||
colorPicker = new GuiColorPicker(GuiConstants.RENDER_SETTINGS_COLOR_PICKER, 0, 0, I18n.format("replaymod.gui.rendersettings.skycolor")+": ", 0, 0);
|
||||
colorPicker.enabled = enableGreenscreen.isChecked();
|
||||
|
||||
commandInput = new GuiAdvancedTextField(fontRendererObj, 0, 0, 50, 20);
|
||||
commandInput.hint = I18n.format("replaymod.gui.rendersettings.command");
|
||||
commandInput.setMaxStringLength(3200);
|
||||
|
||||
ffmpegArguments = new GuiAdvancedTextField(fontRendererObj, 0, 0, 50, 20);
|
||||
ffmpegArguments.hint = I18n.format("replaymod.gui.rendersettings.ffmpeghint");
|
||||
ffmpegArguments.setMaxStringLength(3200);
|
||||
|
||||
ignoreCamDir = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_STATIC_CAMERA, 0, 0, I18n.format("replaymod.gui.rendersettings.stablecamera"), false);
|
||||
ignoreCamDir.enabled = false;
|
||||
|
||||
encodingPresetDropdown.setSelectionIndex(2);
|
||||
|
||||
permanentButtons.add(advancedButton);
|
||||
permanentButtons.add(renderButton);
|
||||
permanentButtons.add(cancelButton);
|
||||
|
||||
defaultButtons.add(framerateSlider);
|
||||
defaultButtons.add(ignoreCamDir);
|
||||
defaultButtons.add(outputFileChooser);
|
||||
|
||||
advancedButtons.add(interpolation);
|
||||
advancedButtons.add(forceChunks);
|
||||
advancedButtons.add(enableGreenscreen);
|
||||
advancedButtons.add(colorPicker);
|
||||
advancedButtons.add(renderNameTags);
|
||||
private File defaultFile = null;
|
||||
{
|
||||
try {
|
||||
defaultFile = new File(ReplayFileIO.getRenderFolder(), FILE_FORMAT.format(Calendar.getInstance().getTime())+"."+ EncodingPreset.MP4DEFAULT.getFileExtension());
|
||||
} catch(IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
virtualHeight = 200;
|
||||
virtualY = (this.height-virtualHeight)/2;
|
||||
private GuiFileChooser outputFileChooser = new GuiFileChooser(GuiConstants.RENDER_SETTINGS_OUTPUT_CHOOSER, 0, 0,
|
||||
"", defaultFile, new String[]{"webm"}, true);
|
||||
|
||||
cancelButton.width = renderButton.width = advancedButton.width = 100;
|
||||
{
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
|
||||
cancelButton.xPosition = width-10-5-100;
|
||||
renderButton.xPosition = cancelButton.xPosition-5-100;
|
||||
advancedButton.xPosition = renderButton.xPosition-5-100;
|
||||
|
||||
cancelButton.yPosition = renderButton.yPosition = advancedButton.yPosition = virtualY+virtualHeight-5-18;
|
||||
|
||||
w1 = rendererDropdown.width + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.rendersettings.renderer") + ":")+10;
|
||||
rendererDropdown.yPosition = virtualY + 15 + 15;
|
||||
rendererDropdown.xPosition = encodingPresetDropdown.xPosition =
|
||||
(width-w1)/2 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.rendersettings.renderer") + ":")+10;
|
||||
|
||||
encodingPresetDropdown.yPosition = rendererDropdown.yPosition + 20 + 10;
|
||||
|
||||
String customResString = I18n.format("replaymod.gui.rendersettings.customresolution");
|
||||
int customResWidth = fontRendererObj.getStringWidth(customResString);
|
||||
|
||||
int w2 = customResWidth + 5 + xRes.width + 5 + fontRendererObj.getStringWidth("*") + 5 + yRes.width;
|
||||
|
||||
int yPos = virtualY + 15 + 5 + 50 + 10 + 5+fontRendererObj.getStringWidth("*")+5;
|
||||
int xPos = (width- w2)/2;
|
||||
|
||||
xRes.xPosition = xPos + customResWidth + 5;
|
||||
yRes.xPosition = xRes.xPosition+xRes.width+5+fontRendererObj.getStringWidth("*")+5;
|
||||
xRes.yPosition = yRes.yPosition = yPos-3;
|
||||
|
||||
int w3 = interpolation.width + 10 + forceChunks.width;
|
||||
|
||||
interpolation.xPosition = (width- w3)/2;
|
||||
interpolation.yPosition = xRes.yPosition+20+10;
|
||||
|
||||
forceChunks.xPosition = interpolation.xPosition+interpolation.width+10;
|
||||
forceChunks.yPosition = interpolation.yPosition;
|
||||
|
||||
String bitrateString = I18n.format("replaymod.gui.settings.bitrate")+": ";
|
||||
int bsw = fontRendererObj.getStringWidth(bitrateString);
|
||||
bitrateInput.xPosition = forceChunks.xPosition + bsw;
|
||||
bitrateInput.width = forceChunks.width - bsw;
|
||||
|
||||
framerateSlider.xPosition = outputFileChooser.xPosition = interpolation.xPosition;
|
||||
framerateSlider.yPosition = bitrateInput.yPosition = xRes.yPosition + 20 + 10;
|
||||
|
||||
ignoreCamDir.xPosition = framerateSlider.xPosition + (framerateSlider.width - ignoreCamDir.width)/2;
|
||||
|
||||
ignoreCamDir.yPosition = framerateSlider.yPosition+20+10;
|
||||
|
||||
outputFileChooser.yPosition = framerateSlider.yPosition+20+10;
|
||||
outputFileChooser.width = 312;
|
||||
|
||||
//align all advanced buttons
|
||||
rendererDropdown.addSelectionListener(new RendererDropdownListener());
|
||||
|
||||
int i = 0;
|
||||
for(GuiButton b : advancedButtons) {
|
||||
b.width = 150;
|
||||
b.xPosition = i % 2 == 0 ? this.width/2 - b.width - 2 : this.width/2 + 2;
|
||||
|
||||
b.yPosition = this.virtualY + 20 + ((i/2)*25);
|
||||
|
||||
if(b instanceof GuiColorPicker) {
|
||||
GuiColorPicker picker = (GuiColorPicker)b;
|
||||
picker.pickerX = b.xPosition + 25;
|
||||
picker.pickerY = b.yPosition + 20 + 5;
|
||||
} else if(b instanceof GuiCheckBox) {
|
||||
b.yPosition += 5;
|
||||
}
|
||||
|
||||
for (RendererSettings r : RendererSettings.values()) {
|
||||
rendererDropdown.addElement(r);
|
||||
rendererDropdown.setHoverText(i, r.getDescription());
|
||||
i++;
|
||||
}
|
||||
|
||||
encodingPresetDropdown.addSelectionListener(new EncodingDropdownListener());
|
||||
|
||||
for (EncodingPreset preset : EncodingPreset.values()) {
|
||||
encodingPresetDropdown.addElement(preset);
|
||||
}
|
||||
|
||||
encodingPresetDropdown.setSelectionIndex(2);
|
||||
}
|
||||
|
||||
private String[] tabNames = new String[]{I18n.format("replaymod.gui.rendersettings.video"),
|
||||
I18n.format("replaymod.gui.rendersettings.advanced"), I18n.format("replaymod.gui.rendersettings.commandline")};
|
||||
|
||||
private int currentTab = 0;
|
||||
|
||||
private void toggleTab() {
|
||||
currentTab++;
|
||||
if(currentTab >= 3) currentTab = 0;
|
||||
|
||||
int nextTab = currentTab+1;
|
||||
if(nextTab >= 3) nextTab = 0;
|
||||
toggleTabButton.displayString = tabNames[nextTab];
|
||||
}
|
||||
|
||||
private DelegatingElement currentScreen = new DelegatingElement() {
|
||||
|
||||
private ComposedElement videoSettings = new ComposedElement(renderButton, cancelButton, toggleTabButton,
|
||||
rendererString, rendererDropdown, presetsString, encodingPresetDropdown, resolutionString, asteriksString,
|
||||
xRes, yRes, framerateSlider, bitrateString, bitrateInput, fileChooserString, outputFileChooser);
|
||||
|
||||
private ComposedElement advancedSettings = new ComposedElement(renderButton, cancelButton, toggleTabButton,
|
||||
renderNameTags, stabilizeString, stablePitch, stableYaw, stableRoll, enableGreenscreen, colorPicker);
|
||||
|
||||
private ComposedElement commandLineSettings = new ComposedElement(renderButton, cancelButton, toggleTabButton,
|
||||
commandInput, ffmpegArguments);
|
||||
|
||||
@Override
|
||||
public GuiElement delegate() {
|
||||
switch(currentTab) {
|
||||
case 0:
|
||||
return videoSettings;
|
||||
case 1:
|
||||
return advancedSettings;
|
||||
case 2:
|
||||
return commandLineSettings;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
virtualHeight = 200;
|
||||
virtualY = (this.height-virtualHeight)/2;
|
||||
|
||||
cancelButton.xPosition = width-LEFT_BORDER-5-100;
|
||||
renderButton.xPosition = cancelButton.xPosition-5-100;
|
||||
toggleTabButton.xPosition = renderButton.xPosition-5-150;
|
||||
|
||||
cancelButton.yPosition = renderButton.yPosition = toggleTabButton.yPosition = virtualY+virtualHeight-5-20;
|
||||
|
||||
initializeVideoTab();
|
||||
initializeAdvancedTab();
|
||||
initializeCommandLineTab();
|
||||
|
||||
validateInputs();
|
||||
}
|
||||
|
||||
private void initializeVideoTab() {
|
||||
int largerWidth = Math.max(Math.max(rendererString.getWidth(), presetsString.getWidth()),
|
||||
resolutionString.getWidth())+10;
|
||||
int rowWidth = largerWidth+rendererDropdown.getWidth();
|
||||
rendererDropdown.xPosition = encodingPresetDropdown.xPosition = xRes.xPosition =
|
||||
bitrateInput.xPosition = outputFileChooser.xPosition = (width - rowWidth)/2 + largerWidth;
|
||||
|
||||
rendererString.positionX = presetsString.positionX = fileChooserString.positionX =
|
||||
resolutionString.positionX = bitrateString.positionX = (width - rowWidth)/2;
|
||||
|
||||
rendererString.positionX += (largerWidth-10)-rendererString.getWidth();
|
||||
presetsString.positionX += (largerWidth-10)-presetsString.getWidth();
|
||||
fileChooserString.positionX += (largerWidth-10)-fileChooserString.getWidth();
|
||||
resolutionString.positionX += (largerWidth-10)-resolutionString.getWidth();
|
||||
bitrateString.positionX += (largerWidth-10)-bitrateString.getWidth();
|
||||
|
||||
rendererDropdown.yPosition = virtualY + 25;
|
||||
rendererString.positionY = rendererDropdown.yPosition + 6;
|
||||
|
||||
encodingPresetDropdown.yPosition = rendererDropdown.yPosition+20+10;
|
||||
presetsString.positionY = encodingPresetDropdown.yPosition + 6;
|
||||
|
||||
asteriksString.positionX = xRes.xPosition+xRes.width+5;
|
||||
yRes.xPosition = asteriksString.positionX+asteriksString.getWidth()+5;
|
||||
|
||||
xRes.yPosition = yRes.yPosition = encodingPresetDropdown.yPosition+20+10;
|
||||
resolutionString.positionY = asteriksString.positionY = xRes.yPosition + 6;
|
||||
|
||||
bitrateInput.width = 70;
|
||||
|
||||
framerateSlider.xPosition = bitrateInput.xPosition + bitrateInput.width + 5;
|
||||
framerateSlider.width = 125;
|
||||
|
||||
bitrateInput.yPosition = framerateSlider.yPosition = xRes.yPosition+20+10;
|
||||
bitrateString.positionY = bitrateInput.yPosition+6;
|
||||
|
||||
outputFileChooser.yPosition = bitrateInput.yPosition+20+10;
|
||||
fileChooserString.positionY = outputFileChooser.yPosition+6;
|
||||
|
||||
outputFileChooser.width = 200;
|
||||
}
|
||||
|
||||
private void initializeAdvancedTab() {
|
||||
int singleWidth = 150;
|
||||
int middleGap = 10;
|
||||
|
||||
int totalWidth = (2*singleWidth)+middleGap;
|
||||
|
||||
int leftX = width/2 - (singleWidth+middleGap/2);
|
||||
|
||||
//might be of use in the future
|
||||
//int rightX = width/2 + (middleGap/2);
|
||||
|
||||
int heightDiff = 25;
|
||||
|
||||
renderNameTags.xPosition = leftX;
|
||||
renderNameTags.yPosition = virtualY + 25;
|
||||
renderNameTags.width = singleWidth;
|
||||
|
||||
stabilizeString.positionX = leftX;
|
||||
|
||||
int left = leftX+stabilizeString.getWidth()+middleGap;
|
||||
int width = (totalWidth - (stabilizeString.getWidth()+middleGap)) / 3;
|
||||
|
||||
stableYaw.xPosition = left;
|
||||
stablePitch.xPosition = left + width;
|
||||
stableRoll.xPosition = left + 2*width;
|
||||
|
||||
stablePitch.yPosition = stableYaw.yPosition = stableRoll.yPosition = renderNameTags.yPosition+heightDiff;
|
||||
stabilizeString.positionY = stablePitch.yPosition + 2;
|
||||
|
||||
enableGreenscreen.xPosition = leftX;
|
||||
colorPicker.xPosition = leftX + (enableGreenscreen.width+5);
|
||||
colorPicker.width = totalWidth - (enableGreenscreen.width+5);
|
||||
|
||||
colorPicker.yPosition = stablePitch.yPosition+heightDiff;
|
||||
enableGreenscreen.yPosition = colorPicker.yPosition+4;
|
||||
|
||||
colorPicker.pickerX = colorPicker.xPosition;
|
||||
colorPicker.pickerY = colorPicker.yPosition + 20;
|
||||
|
||||
colorPicker.setElementEnabled(enableGreenscreen.isChecked());
|
||||
}
|
||||
|
||||
private void initializeCommandLineTab() {
|
||||
commandInput.width = 55;
|
||||
commandInput.xPosition = (this.width-305)/2;
|
||||
commandInput.yPosition = ffmpegArguments.yPosition = advancedButtons.get(advancedButtons.size()-1).yPosition + 20;
|
||||
commandInput.yPosition = ffmpegArguments.yPosition = virtualY + 25;
|
||||
|
||||
ffmpegArguments.width = 245;
|
||||
ffmpegArguments.xPosition = commandInput.xPosition+commandInput.width+5;
|
||||
|
||||
initialized = true;
|
||||
|
||||
validateInputs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
drawGradientRect(LEFT_BORDER, virtualY, width - LEFT_BORDER, virtualY + virtualHeight, -1072689136, -804253680);
|
||||
|
||||
this.drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.title"),
|
||||
this.drawCenteredString(fontRendererObj, tabNames[currentTab],
|
||||
this.width / 2, virtualY + 5, Color.WHITE.getRGB());
|
||||
|
||||
|
||||
List<GuiButton> toHandle = new ArrayList<GuiButton>();
|
||||
toHandle.addAll(permanentButtons);
|
||||
toHandle.addAll(advancedTab ? advancedButtons : defaultButtons);
|
||||
|
||||
for(GuiButton b : toHandle) {
|
||||
b.drawButton(mc, mouseX, mouseY);
|
||||
GlStateManager.enableBlend();
|
||||
}
|
||||
|
||||
if(!advancedTab) {
|
||||
this.drawString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.renderer") + ":",
|
||||
(width - w1) / 2, rendererDropdown.yPosition + 6, Color.WHITE.getRGB());
|
||||
|
||||
this.drawString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.presets") + ":",
|
||||
(width - w1) / 2, encodingPresetDropdown.yPosition + 6, Color.WHITE.getRGB());
|
||||
|
||||
String resString = I18n.format("replaymod.gui.rendersettings.customresolution")+":";
|
||||
int strWidth = fontRendererObj.getStringWidth(resString);
|
||||
|
||||
this.drawString(fontRendererObj, resString,
|
||||
xRes.xPosition - strWidth - 5, xRes.yPosition+6, Color.WHITE.getRGB());
|
||||
|
||||
xRes.drawTextBox();
|
||||
yRes.drawTextBox();
|
||||
bitrateInput.drawTextBox();
|
||||
this.drawString(fontRendererObj, "*", xRes.xPosition + xRes.width + 5, xRes.yPosition + 6, Color.WHITE.getRGB());
|
||||
|
||||
String bitrateString = I18n.format("replaymod.gui.settings.bitrate")+": ";
|
||||
this.drawString(fontRendererObj, bitrateString, forceChunks.xPosition, bitrateInput.yPosition + 6, Color.WHITE.getRGB());
|
||||
|
||||
encodingPresetDropdown.drawTextBox();
|
||||
rendererDropdown.drawTextBox();
|
||||
} else if(advancedTab) {
|
||||
commandInput.drawTextBox();
|
||||
ffmpegArguments.drawTextBox();
|
||||
if(currentTab == 2) {
|
||||
String[] rows = StringUtils.splitStringInMultipleRows(I18n.format("replaymod.gui.rendersettings.ffmpeg.description"), 305);
|
||||
|
||||
int i = 0;
|
||||
@@ -333,71 +338,28 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
}
|
||||
}
|
||||
|
||||
renderButton.drawOverlay(mc, mouseX, mouseY);
|
||||
currentScreen.draw(mc, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if(!rendererDropdown.mouseClickedResult(mouseX, mouseY)) {
|
||||
if(!encodingPresetDropdown.mouseClickedResult(mouseX, mouseY)) {
|
||||
if(!advancedTab) {
|
||||
xRes.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
yRes.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
bitrateInput.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
} else {
|
||||
commandInput.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
ffmpegArguments.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
if(mouseButton == 0) {
|
||||
List<GuiButton> toHandle = new ArrayList<GuiButton>();
|
||||
toHandle.addAll(permanentButtons);
|
||||
toHandle.addAll(advancedTab ? advancedButtons : defaultButtons);
|
||||
|
||||
for(GuiButton b : toHandle) {
|
||||
b.mousePressed(this.mc, mouseX, mouseY);
|
||||
if(b.mousePressed(this.mc, mouseX, mouseY)) {
|
||||
b.playPressSound(this.mc.getSoundHandler());
|
||||
actionPerformed(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
currentScreen.mouseClick(mc, mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
framerateSlider.mouseReleased(mouseX, mouseY);
|
||||
currentScreen.mouseRelease(mc, mouseX, mouseX, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
if(advancedTab) colorPicker.mouseDragged(mc, mouseX, mouseY);
|
||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
currentScreen.mouseDrag(mc, mouseX, mouseY, clickedMouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
if(!advancedTab) {
|
||||
if(keyCode == Keyboard.KEY_TAB) {
|
||||
if(xRes.isFocused()) {
|
||||
xRes.setFocused(false);
|
||||
yRes.setFocused(true);
|
||||
} else if(yRes.isFocused()) {
|
||||
yRes.setFocused(false);
|
||||
xRes.setFocused(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
xRes.textboxKeyTyped(typedChar, keyCode);
|
||||
yRes.textboxKeyTyped(typedChar, keyCode);
|
||||
bitrateInput.textboxKeyTyped(typedChar, keyCode);
|
||||
} else {
|
||||
commandInput.textboxKeyTyped(typedChar, keyCode);
|
||||
ffmpegArguments.textboxKeyTyped(typedChar, keyCode);
|
||||
validateInputs();
|
||||
}
|
||||
Point mousePos = MouseUtils.getMousePos();
|
||||
currentScreen.buttonPressed(mc, mousePos.getX(), mousePos.getY(), typedChar, keyCode);
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
@@ -411,49 +373,6 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
super.updateScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
if(!button.enabled) return;
|
||||
|
||||
if(permanentButtons.contains(button)) {
|
||||
if(button instanceof GuiCheckBox)
|
||||
((GuiCheckBox)button).setIsChecked(!((GuiCheckBox)button).isChecked());
|
||||
|
||||
if(button.id == GuiConstants.RENDER_SETTINGS_RENDER_BUTTON) {
|
||||
startRendering();
|
||||
} else if(button.id == GuiConstants.RENDER_SETTINGS_CANCEL_BUTTON) {
|
||||
mc.displayGuiScreen(null);
|
||||
} else if(button.id == GuiConstants.RENDER_SETTINGS_ADVANCED_BUTTON) {
|
||||
advancedTab = !advancedTab;
|
||||
advancedButton.displayString = advancedTab ? I18n.format("replaymod.gui.rendersettings.basic")
|
||||
: I18n.format("replaymod.gui.rendersettings.advanced");
|
||||
}
|
||||
|
||||
} else if(defaultButtons.contains(button) && !advancedTab) {
|
||||
if(button instanceof GuiCheckBox)
|
||||
((GuiCheckBox)button).setIsChecked(!((GuiCheckBox)button).isChecked());
|
||||
else if(button.id == GuiConstants.RENDER_SETTINGS_OUTPUT_CHOOSER) {
|
||||
Point mouse = MouseUtils.getMousePos();
|
||||
outputFileChooser.mouseClick(mc, mouse.getX(), mouse.getY(), 0);
|
||||
}
|
||||
|
||||
} else if(advancedButtons.contains(button) && advancedTab) {
|
||||
if(button instanceof GuiCheckBox)
|
||||
((GuiCheckBox)button).setIsChecked(!((GuiCheckBox)button).isChecked());
|
||||
|
||||
if(button instanceof GuiColorPicker) {
|
||||
((GuiColorPicker) button).pickerToggled();
|
||||
} else if(button instanceof GuiToggleButton) {
|
||||
((GuiToggleButton) button).toggle();
|
||||
} else {
|
||||
if(button.id == GuiConstants.RENDER_SETTINGS_ENABLE_GREENSCREEN) {
|
||||
colorPicker.enabled = enableGreenscreen.isChecked();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private enum RendererSettings implements GuiEntryListEntry {
|
||||
DEFAULT("default"),
|
||||
STEREOSCOPIC("stereoscopic"),
|
||||
@@ -485,11 +404,9 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
|
||||
RenderOptions options = new RenderOptions();
|
||||
|
||||
options.setLinearMovement(interpolation.getValue() == 1);
|
||||
ReplayMod.replaySettings.setLinearMovement(interpolation.getValue() == 1);
|
||||
options.setLinearMovement(ReplayMod.replaySettings.isLinearMovement());
|
||||
|
||||
options.setWaitForChunks(forceChunks.getValue() == 0);
|
||||
ReplayMod.replaySettings.setWaitForChunks(forceChunks.getValue() == 0);
|
||||
options.setWaitForChunks(true);
|
||||
|
||||
options.setFps(framerateSlider.getFPS());
|
||||
ReplayMod.replaySettings.setVideoFramerate(framerateSlider.getFPS());
|
||||
@@ -524,7 +441,8 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
}
|
||||
options.setMode(pipePreset);
|
||||
|
||||
options.setIgnoreCameraRotation(ignoreCamDir.isChecked(), ignoreCamDir.isChecked(), ignoreCamDir.isChecked());
|
||||
options.setIgnoreCameraRotation(stableYaw.enabled && stableYaw.isChecked(),
|
||||
stablePitch.enabled && stablePitch.isChecked(), stableRoll.enabled && stableRoll.isChecked());
|
||||
|
||||
if (isCtrlKeyDown()) {
|
||||
options.setHighPerformance(true);
|
||||
@@ -555,22 +473,6 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
private class RendererDropdownListener implements SelectionListener {
|
||||
@Override
|
||||
public void onSelectionChanged(int selectionIndex) {
|
||||
RendererSettings s = rendererDropdown.getElement(selectionIndex);
|
||||
|
||||
if(s == RendererSettings.DEFAULT) {
|
||||
ignoreCamDir.enabled = false;
|
||||
} else if(s == RendererSettings.STEREOSCOPIC) {
|
||||
ignoreCamDir.enabled = false;
|
||||
} else if(s == RendererSettings.CUBIC) {
|
||||
ignoreCamDir.enabled = false;
|
||||
} else if(s == RendererSettings.EQUIRECTANGULAR) {
|
||||
ignoreCamDir.enabled = true;
|
||||
}
|
||||
|
||||
if (!ignoreCamDir.enabled) {
|
||||
ignoreCamDir.setIsChecked(false);
|
||||
}
|
||||
|
||||
xRes.setCursorPositionEnd();
|
||||
xRes.setSelectionPos(xRes.getCursorPosition());
|
||||
|
||||
@@ -590,6 +492,7 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
|
||||
bitrateInput.setEnabled(preset.hasBitrateSetting());
|
||||
ffmpegArguments.setText(preset.getCommandLineArgs());
|
||||
ffmpegArguments.setCursorPositionZero();
|
||||
|
||||
outputFileChooser.setAllowedExtensions(new String[]{preset.getFileExtension()});
|
||||
|
||||
@@ -625,8 +528,11 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
}
|
||||
}
|
||||
|
||||
boolean isPanoramic = false;
|
||||
|
||||
switch (rendererDropdown.getElement(rendererDropdown.getSelectionIndex())) {
|
||||
case CUBIC:
|
||||
isPanoramic = true;
|
||||
if (getWidthSetting() * 3 / 4 != getHeightSetting()
|
||||
|| getWidthSetting() * 3 % 4 != 0) {
|
||||
valid = false;
|
||||
@@ -634,6 +540,7 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
}
|
||||
break;
|
||||
case EQUIRECTANGULAR:
|
||||
isPanoramic = true;
|
||||
if (getWidthSetting() / 2 != getHeightSetting()
|
||||
|| getWidthSetting() % 2 != 0) {
|
||||
valid = false;
|
||||
@@ -641,6 +548,12 @@ public class GuiRenderSettings extends GuiScreen implements GuiReplayOverlay.NoO
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
stabilizeString.setElementEnabled(isPanoramic);
|
||||
stableYaw.setElementEnabled(isPanoramic);
|
||||
stablePitch.setElementEnabled(isPanoramic);
|
||||
stableRoll.setElementEnabled(isPanoramic);
|
||||
|
||||
if (valid) {
|
||||
renderButton.enabled = true;
|
||||
renderButton.hoverText = "";
|
||||
|
||||
@@ -96,6 +96,10 @@ replaymod.gui.minutes=min
|
||||
replaymod.gui.seconds=sec
|
||||
replaymod.gui.milliseconds=ms
|
||||
|
||||
replaymod.gui.pitch=Pitch
|
||||
replaymod.gui.yaw=Yaw
|
||||
replaymod.gui.roll=Roll
|
||||
|
||||
replaymod.gui.unknownerror=An unknown error occured
|
||||
|
||||
replaymod.gui.exit=Exit Replay
|
||||
@@ -329,11 +333,12 @@ replaymod.gui.rendersettings.command=Command
|
||||
replaymod.gui.rendersettings.arguments=Command Line Arguments
|
||||
replaymod.gui.rendersettings.ffmpeg.description=If you are an advanced user, you can customize the command line parameters used to export the video. For more information, check http://replaymod.com/docs
|
||||
|
||||
replaymod.gui.rendersettings.stablecamera=Ignore Camera Rotation
|
||||
replaymod.gui.rendersettings.stabilizecamera=Stabilize Camera
|
||||
replaymod.gui.rendersettings.exportyoutube=Export for YouTube
|
||||
|
||||
replaymod.gui.rendersettings.basic=Basic Settings
|
||||
replaymod.gui.rendersettings.video=Video Settings
|
||||
replaymod.gui.rendersettings.advanced=Advanced Settings
|
||||
replaymod.gui.rendersettings.commandline=Command Line Settings
|
||||
|
||||
replaymod.gui.rendersettings.presets=Encoding Presets
|
||||
replaymod.gui.rendersettings.presets.mp4.custom=MP4 - Custom Bitrate
|
||||
|
||||
Reference in New Issue
Block a user