Changed GuiRenderSettings to have "Advanced" settings

Added GuiColorPicker and implemented it for Greenscreen color choosing
This commit is contained in:
CrushedPixel
2015-06-02 02:41:11 +02:00
parent db030cf174
commit 2331634af9
9 changed files with 345 additions and 71 deletions

View File

@@ -100,4 +100,7 @@ public class GuiConstants {
public static final int RENDER_SETTINGS_QUALITY_SLIDER = 9010; public static final int RENDER_SETTINGS_QUALITY_SLIDER = 9010;
public static final int RENDER_SETTINGS_YOUTUBE_READY = 9011; public static final int RENDER_SETTINGS_YOUTUBE_READY = 9011;
public static final int RENDER_SETTINGS_STATIC_CAMERA = 9012; public static final int RENDER_SETTINGS_STATIC_CAMERA = 9012;
public static final int RENDER_SETTINGS_ADVANCED_BUTTON = 9013;
public static final int RENDER_SETTINGS_COLOR_PICKER = 9014;
public static final int RENDER_SETTINGS_ENABLE_GREENSCREEN = 9015;
} }

View File

@@ -2,8 +2,10 @@ package eu.crushedpixel.replaymod.gui;
import eu.crushedpixel.replaymod.ReplayMod; import eu.crushedpixel.replaymod.ReplayMod;
import eu.crushedpixel.replaymod.chat.ChatMessageHandler; import eu.crushedpixel.replaymod.chat.ChatMessageHandler;
import eu.crushedpixel.replaymod.gui.elements.GuiColorPicker;
import eu.crushedpixel.replaymod.gui.elements.GuiDropdown; import eu.crushedpixel.replaymod.gui.elements.GuiDropdown;
import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput; import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
import eu.crushedpixel.replaymod.gui.elements.GuiToggleButton;
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener; import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
import eu.crushedpixel.replaymod.replay.ReplayHandler; import eu.crushedpixel.replaymod.replay.ReplayHandler;
import eu.crushedpixel.replaymod.settings.RenderOptions; import eu.crushedpixel.replaymod.settings.RenderOptions;
@@ -17,35 +19,41 @@ import org.lwjgl.input.Keyboard;
import java.awt.*; import java.awt.*;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class GuiRenderSettings extends GuiScreen { public class GuiRenderSettings extends GuiScreen {
private GuiButton renderButton, cancelButton; private GuiButton renderButton, cancelButton, advancedButton;
private GuiDropdown<RendererSettings> rendererDropdown; private GuiDropdown<RendererSettings> rendererDropdown;
private int virtualY, virtualHeight; private int virtualY, virtualHeight;
private int leftBorder = 10; private int leftBorder = 10;
private GuiCheckBox customResolution, ignoreCamDir, youtubeExport; private GuiCheckBox customResolution, ignoreCamDir, youtubeExport, enableGreenscreen;
private GuiNumberInput xRes, yRes; private GuiNumberInput xRes, yRes;
private GuiButton interpolation, forceChunks; private GuiToggleButton interpolation, forceChunks;
private GuiVideoFramerateSlider framerateSlider; private GuiVideoFramerateSlider framerateSlider;
private GuiVideoQualitySlider qualitySlider; private GuiVideoQualitySlider qualitySlider;
private GuiColorPicker colorPicker;
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, w2, w3; private int w1, w2, w3;
private boolean initialized; private boolean initialized;
private boolean linear = false;
private boolean waitForChunks = true;
private final Minecraft mc = Minecraft.getMinecraft(); private final Minecraft mc = Minecraft.getMinecraft();
public GuiRenderSettings() { public GuiRenderSettings() {
//if not enough keyframes, abort and leave chat message //if not enough keyframes, abort and leave chat message
if(ReplayHandler.getPosKeyframeCount() < 2 && ReplayHandler.getTimeKeyframeCount() < 2) { if(ReplayHandler.getPosKeyframeCount() < 2 && ReplayHandler.getTimeKeyframeCount() < 2) {
ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.notenoughkeyframes", ChatMessageHandler.ChatMessageType.WARNING); ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.notenoughkeyframes", ChatMessageHandler.ChatMessageType.WARNING);
mc.displayGuiScreen(null); mc.displayGuiScreen(new GuiMouseInput(ReplayMod.overlay));
return; return;
} }
ReplayMod.replaySender.setReplaySpeed(0); ReplayMod.replaySender.setReplaySpeed(0);
@@ -60,6 +68,7 @@ public class GuiRenderSettings extends GuiScreen {
renderButton = new GuiButton(GuiConstants.RENDER_SETTINGS_RENDER_BUTTON, 0, 0, I18n.format("replaymod.gui.render")); renderButton = new GuiButton(GuiConstants.RENDER_SETTINGS_RENDER_BUTTON, 0, 0, I18n.format("replaymod.gui.render"));
cancelButton = new GuiButton(GuiConstants.RENDER_SETTINGS_CANCEL_BUTTON, 0, 0, I18n.format("replaymod.gui.cancel")); cancelButton = new GuiButton(GuiConstants.RENDER_SETTINGS_CANCEL_BUTTON, 0, 0, I18n.format("replaymod.gui.cancel"));
advancedButton = new GuiButton(GuiConstants.RENDER_SETTINGS_ADVANCED_BUTTON, 0, 0, I18n.format("replaymod.gui.rendersettings.advanced"));
customResolution = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_RESOLUTION_CHECKBOX, 0, 0, I18n.format("replaymod.gui.rendersettings.customresolution"), false); customResolution = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_RESOLUTION_CHECKBOX, 0, 0, I18n.format("replaymod.gui.rendersettings.customresolution"), false);
customResolution.enabled = false; customResolution.enabled = false;
@@ -70,37 +79,68 @@ public class GuiRenderSettings extends GuiScreen {
xRes.setEnabled(false); xRes.setEnabled(false);
yRes.setEnabled(false); yRes.setEnabled(false);
interpolation = new GuiButton(GuiConstants.RENDER_SETTINGS_INTERPOLATION_BUTTON, 0, 0, getInterpolationDisplayString());
forceChunks = new GuiButton(GuiConstants.RENDER_SETTINGS_FORCECHUNKS_BUTTON, 0, 0, getForceChunksDisplayString());
framerateSlider = new GuiVideoFramerateSlider(GuiConstants.RENDER_SETTINGS_FRAMERATE_SLIDER, 0, 0, ReplayMod.replaySettings.getVideoFramerate(), framerateSlider = new GuiVideoFramerateSlider(GuiConstants.RENDER_SETTINGS_FRAMERATE_SLIDER, 0, 0, ReplayMod.replaySettings.getVideoFramerate(),
I18n.format("replaymod.gui.rendersettings.framerate")); I18n.format("replaymod.gui.rendersettings.framerate"));
qualitySlider = new GuiVideoQualitySlider(GuiConstants.RENDER_SETTINGS_QUALITY_SLIDER, 0, 0, (float)ReplayMod.replaySettings.getVideoQuality(), qualitySlider = new GuiVideoQualitySlider(GuiConstants.RENDER_SETTINGS_QUALITY_SLIDER, 0, 0, (float)ReplayMod.replaySettings.getVideoQuality(),
I18n.format("replaymod.gui.rendersettings.quality")); I18n.format("replaymod.gui.rendersettings.quality"));
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 = qualitySlider.width = 150; forceChunks.width = interpolation.width = framerateSlider.width = qualitySlider.width = 150;
enableGreenscreen = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_ENABLE_GREENSCREEN, 0, 0, I18n.format("replaymod.gui.rendersettings.greenscreen"), false);
colorPicker = new GuiColorPicker(GuiConstants.RENDER_SETTINGS_COLOR_PICKER, 0, 0, I18n.format("replaymod.gui.rendersettings.skycolor")+": ", 0, 0);
colorPicker.enabled = enableGreenscreen.isChecked();
ignoreCamDir = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_STATIC_CAMERA, 0, 0, I18n.format("replaymod.gui.rendersettings.stablecamera"), false); ignoreCamDir = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_STATIC_CAMERA, 0, 0, I18n.format("replaymod.gui.rendersettings.stablecamera"), false);
youtubeExport = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_YOUTUBE_READY, 0, 0, I18n.format("replaymod.gui.rendersettings.exportyoutube"), true); youtubeExport = new GuiCheckBox(GuiConstants.RENDER_SETTINGS_YOUTUBE_READY, 0, 0, I18n.format("replaymod.gui.rendersettings.exportyoutube"), true);
ignoreCamDir.enabled = youtubeExport.enabled = false; ignoreCamDir.enabled = youtubeExport.enabled = false;
int i = 0;
for(RendererSettings r : RendererSettings.values()) { for(RendererSettings r : RendererSettings.values()) {
rendererDropdown.addElement(r); rendererDropdown.addElement(r);
rendererDropdown.setHoverText(i, r.getDescription());
i++;
} }
permanentButtons.add(advancedButton);
permanentButtons.add(renderButton);
permanentButtons.add(cancelButton);
defaultButtons.add(customResolution);
defaultButtons.add(framerateSlider);
defaultButtons.add(qualitySlider);
defaultButtons.add(ignoreCamDir);
defaultButtons.add(youtubeExport);
advancedButtons.add(interpolation);
advancedButtons.add(forceChunks);
advancedButtons.add(enableGreenscreen);
advancedButtons.add(colorPicker);
} }
virtualHeight = 200; virtualHeight = 200;
virtualY = (this.height-virtualHeight)/2; virtualY = (this.height-virtualHeight)/2;
cancelButton.width = renderButton.width = 100; cancelButton.width = renderButton.width = advancedButton.width = 100;
cancelButton.xPosition = width-10-5-100; cancelButton.xPosition = width-10-5-100;
renderButton.xPosition = cancelButton.xPosition-5-100; renderButton.xPosition = cancelButton.xPosition-5-100;
advancedButton.xPosition = renderButton.xPosition-5-100;
cancelButton.yPosition = renderButton.yPosition = virtualY+virtualHeight-5-18; cancelButton.yPosition = renderButton.yPosition = advancedButton.yPosition = virtualY+virtualHeight-5-18;
buttonList.add(cancelButton);
buttonList.add(renderButton);
w1 = rendererDropdown.width + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.rendersettings.renderer") + ":")+10; w1 = rendererDropdown.width + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.rendersettings.renderer") + ":")+10;
rendererDropdown.yPosition = virtualY + 15 + 15; rendererDropdown.yPosition = virtualY + 15 + 15;
@@ -110,7 +150,6 @@ public class GuiRenderSettings extends GuiScreen {
customResolution.yPosition = virtualY + 15 + 5 + 20 + 10 +5+fontRendererObj.getStringWidth("*")+5; customResolution.yPosition = virtualY + 15 + 5 + 20 + 10 +5+fontRendererObj.getStringWidth("*")+5;
customResolution.xPosition = (width-w2)/2; customResolution.xPosition = (width-w2)/2;
buttonList.add(customResolution);
xRes.xPosition = customResolution.xPosition + customResolution.width + 5; xRes.xPosition = customResolution.xPosition + customResolution.width + 5;
yRes.xPosition = xRes.xPosition+xRes.width+5+fontRendererObj.getStringWidth("*")+5; yRes.xPosition = xRes.xPosition+xRes.width+5+fontRendererObj.getStringWidth("*")+5;
@@ -120,30 +159,43 @@ public class GuiRenderSettings extends GuiScreen {
interpolation.xPosition = (width-w3)/2; interpolation.xPosition = (width-w3)/2;
interpolation.yPosition = xRes.yPosition+20+10; interpolation.yPosition = xRes.yPosition+20+10;
buttonList.add(interpolation);
forceChunks.xPosition = interpolation.xPosition+interpolation.width+10; forceChunks.xPosition = interpolation.xPosition+interpolation.width+10;
forceChunks.yPosition = interpolation.yPosition; forceChunks.yPosition = interpolation.yPosition;
buttonList.add(forceChunks);
framerateSlider.xPosition = interpolation.xPosition; framerateSlider.xPosition = interpolation.xPosition;
qualitySlider.xPosition = forceChunks.xPosition; qualitySlider.xPosition = forceChunks.xPosition;
framerateSlider.yPosition = qualitySlider.yPosition = interpolation.yPosition + 20 + 10; framerateSlider.yPosition = qualitySlider.yPosition = interpolation.yPosition + 20 + 10;
buttonList.add(framerateSlider);
buttonList.add(qualitySlider);
ignoreCamDir.xPosition = framerateSlider.xPosition + (framerateSlider.width - ignoreCamDir.width)/2; ignoreCamDir.xPosition = framerateSlider.xPosition + (framerateSlider.width - ignoreCamDir.width)/2;
youtubeExport.xPosition = qualitySlider.xPosition + (qualitySlider.width - youtubeExport.width)/2; youtubeExport.xPosition = qualitySlider.xPosition + (qualitySlider.width - youtubeExport.width)/2;
ignoreCamDir.yPosition = youtubeExport.yPosition = framerateSlider.yPosition+20+10; ignoreCamDir.yPosition = youtubeExport.yPosition = framerateSlider.yPosition+20+10;
buttonList.add(ignoreCamDir); //align all advanced buttons
buttonList.add(youtubeExport);
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;
}
i++;
}
initialized = true; initialized = true;
} }
@Override @Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) { public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawGradientRect(leftBorder, virtualY, width - leftBorder, virtualY + virtualHeight, -1072689136, -804253680); drawGradientRect(leftBorder, virtualY, width - leftBorder, virtualY + virtualHeight, -1072689136, -804253680);
@@ -151,16 +203,25 @@ public class GuiRenderSettings extends GuiScreen {
this.drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.title"), this.drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.title"),
this.width / 2, virtualY + 5, Color.WHITE.getRGB()); this.width / 2, virtualY + 5, Color.WHITE.getRGB());
this.drawString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.renderer") + ":",
(width-w1)/2, rendererDropdown.yPosition + 8, Color.WHITE.getRGB());
xRes.drawTextBox(); List<GuiButton> toHandle = new ArrayList<GuiButton>();
yRes.drawTextBox(); toHandle.addAll(permanentButtons);
this.drawString(fontRendererObj, "*", xRes.xPosition + xRes.width + 5, xRes.yPosition + 3, Color.WHITE.getRGB()); toHandle.addAll(advancedTab ? advancedButtons : defaultButtons);
super.drawScreen(mouseX, mouseY, partialTicks); for(GuiButton b : toHandle) {
b.drawButton(mc, mouseX, mouseY);
}
rendererDropdown.drawTextBox(); if(!advancedTab) {
this.drawString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.renderer") + ":",
(width - w1) / 2, rendererDropdown.yPosition + 8, Color.WHITE.getRGB());
xRes.drawTextBox();
yRes.drawTextBox();
this.drawString(fontRendererObj, "*", xRes.xPosition + xRes.width + 5, xRes.yPosition + 3, Color.WHITE.getRGB());
rendererDropdown.drawTextBox();
}
} }
@Override @Override
@@ -168,10 +229,29 @@ public class GuiRenderSettings extends GuiScreen {
if(!rendererDropdown.mouseClickedResult(mouseX, mouseY, mouseButton)) { if(!rendererDropdown.mouseClickedResult(mouseX, mouseY, mouseButton)) {
xRes.mouseClicked(mouseX, mouseY, mouseButton); xRes.mouseClicked(mouseX, mouseY, mouseButton);
yRes.mouseClicked(mouseX, mouseY, mouseButton); yRes.mouseClicked(mouseX, mouseY, mouseButton);
super.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);
}
}
}
} }
} }
@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);
}
@Override @Override
protected void keyTyped(char typedChar, int keyCode) throws IOException { protected void keyTyped(char typedChar, int keyCode) throws IOException {
if(keyCode == Keyboard.KEY_TAB) { if(keyCode == Keyboard.KEY_TAB) {
@@ -200,34 +280,42 @@ public class GuiRenderSettings extends GuiScreen {
@Override @Override
protected void actionPerformed(GuiButton button) throws IOException { protected void actionPerformed(GuiButton button) throws IOException {
if(!button.enabled) return; if(!button.enabled) return;
if(button.id == GuiConstants.RENDER_SETTINGS_RENDER_BUTTON) { if(permanentButtons.contains(button)) {
startRendering();
} else if(button.id == GuiConstants.RENDER_SETTINGS_CANCEL_BUTTON) { if(button.id == GuiConstants.RENDER_SETTINGS_RENDER_BUTTON) {
mc.displayGuiScreen(null); startRendering();
} else if(button.id == GuiConstants.RENDER_SETTINGS_RESOLUTION_CHECKBOX) { } else if(button.id == GuiConstants.RENDER_SETTINGS_CANCEL_BUTTON) {
boolean enabled = ((GuiCheckBox)button).isChecked(); mc.displayGuiScreen(null);
xRes.setEnabled(enabled); } else if(button.id == GuiConstants.RENDER_SETTINGS_ADVANCED_BUTTON) {
yRes.setEnabled(enabled); advancedTab = !advancedTab;
} else if(button.id == GuiConstants.RENDER_SETTINGS_INTERPOLATION_BUTTON) { advancedButton.displayString = advancedTab ? I18n.format("replaymod.gui.rendersettings.basic")
linear = !linear; : I18n.format("replaymod.gui.rendersettings.advanced");
button.displayString = getInterpolationDisplayString(); }
} else if(button.id == GuiConstants.RENDER_SETTINGS_FORCECHUNKS_BUTTON) {
waitForChunks = !waitForChunks; } else if(defaultButtons.contains(button) && !advancedTab) {
button.displayString = getForceChunksDisplayString();
if(button.id == GuiConstants.RENDER_SETTINGS_RESOLUTION_CHECKBOX) {
boolean enabled = ((GuiCheckBox)button).isChecked();
xRes.setEnabled(enabled);
yRes.setEnabled(enabled);
}
} else if(advancedButtons.contains(button) && advancedTab) {
if(button instanceof GuiToggleButton) {
((GuiToggleButton)button).toggle();
} else if(button instanceof GuiColorPicker) {
((GuiColorPicker)button).pickerToggled();
} else {
if(button.id == GuiConstants.RENDER_SETTINGS_ENABLE_GREENSCREEN) {
enableGreenscreen.setIsChecked(!enableGreenscreen.isChecked());
colorPicker.enabled = enableGreenscreen.isChecked();
}
}
} }
} }
private String getInterpolationDisplayString() {
return I18n.format("replaymod.gui.rendersettings.interpolation")+": "+
(linear ? I18n.format("replaymod.gui.settings.interpolation.linear") :
I18n.format("replaymod.gui.settings.interpolation.cubic"));
}
private String getForceChunksDisplayString() {
return I18n.format("replaymod.gui.rendersettings.forcechunks")+": "+
(waitForChunks ? I18n.format("options.on") : I18n.format("options.off"));
}
private enum RendererSettings { private enum RendererSettings {
DEFAULT("default"), DEFAULT("default"),
TILED("tiled"), TILED("tiled"),
@@ -239,7 +327,7 @@ public class GuiRenderSettings extends GuiScreen {
RendererSettings(String name) { RendererSettings(String name) {
this.name = "replaymod.gui.rendersettings.renderer."+name; this.name = "replaymod.gui.rendersettings.renderer."+name;
this.desc = name+".description"; this.desc = this.name+".description";
} }
@Override @Override
@@ -247,9 +335,7 @@ public class GuiRenderSettings extends GuiScreen {
return I18n.format(name); return I18n.format(name);
} }
public String getDescription() { public String getDescription() { return I18n.format(desc); }
return desc;
}
} }
private void startRendering() { private void startRendering() {
@@ -259,11 +345,11 @@ public class GuiRenderSettings extends GuiScreen {
RenderOptions options = new RenderOptions(); RenderOptions options = new RenderOptions();
options.setLinearMovement(linear); options.setLinearMovement(interpolation.getValue() == 1);
ReplayMod.replaySettings.setLinearMovement(linear); ReplayMod.replaySettings.setLinearMovement(interpolation.getValue() == 1);
options.setWaitForChunks(waitForChunks); options.setWaitForChunks(forceChunks.getValue() == 0);
ReplayMod.replaySettings.setWaitForChunks(waitForChunks); ReplayMod.replaySettings.setWaitForChunks(forceChunks.getValue() == 0);
options.setFps(framerateSlider.getFPS()); options.setFps(framerateSlider.getFPS());
ReplayMod.replaySettings.setVideoFramerate(framerateSlider.getFPS()); ReplayMod.replaySettings.setVideoFramerate(framerateSlider.getFPS());
@@ -271,6 +357,10 @@ public class GuiRenderSettings extends GuiScreen {
options.setQuality(qualitySlider.getQuality()); options.setQuality(qualitySlider.getQuality());
ReplayMod.replaySettings.setVideoQuality(qualitySlider.getQuality()); ReplayMod.replaySettings.setVideoQuality(qualitySlider.getQuality());
if(enableGreenscreen.isChecked()) {
options.setSkyColor(colorPicker.getPickedColor());
}
if(r == RendererSettings.DEFAULT) { if(r == RendererSettings.DEFAULT) {
renderer = new DefaultFrameRenderer(options); renderer = new DefaultFrameRenderer(options);
} else if(r == RendererSettings.TILED) { } else if(r == RendererSettings.TILED) {

View File

@@ -0,0 +1,110 @@
package eu.crushedpixel.replaymod.gui.elements;
import eu.crushedpixel.replaymod.utils.MouseUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Mouse;
import org.lwjgl.util.Point;
import java.awt.*;
public class GuiColorPicker extends GuiButton {
private final int PICKER_SIZE = 100;
private boolean pickerVisible = false;
private int pickedColor = Color.BLACK.getRGB();
public int pickerX, pickerY;
public GuiColorPicker(int buttonId, int x, int y, String text, int pickerX, int pickerY) {
super(buttonId, x, y, text);
this.pickerX = pickerX;
this.pickerY = pickerY;
}
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if(this.visible) {
FontRenderer fontrenderer = mc.fontRendererObj;
mc.getTextureManager().bindTexture(buttonTextures);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
int k = this.getHoverState(this.hovered);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.blendFunc(770, 771);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
this.mouseDragged(mc, mouseX, mouseY);
int l = 14737632;
if (packedFGColour != 0) {
l = packedFGColour;
}
else if (!this.enabled) {
l = 10526880;
}
else if (this.hovered) {
l = 16777120;
}
int strWidth = fontrenderer.getStringWidth(this.displayString);
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2 - 10, this.yPosition + (this.height - 8) / 2, l);
this.drawGradientRect(this.xPosition + (width+strWidth)/2, this.yPosition + 5, this.xPosition + (width+strWidth)/2 + 10,
this.yPosition + 5 + 10, pickedColor, pickedColor);
if(pickerVisible && this.enabled) {
for(int x=0; x < PICKER_SIZE; x++) {
for(int y=0; y < PICKER_SIZE; y++) {
int color = getColorAtPosition(x, y);
this.drawGradientRect(pickerX+x, pickerY+y, pickerX+x+1, pickerY+y+1, color, color);
}
}
}
}
}
@Override
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
if(pickerVisible && this.enabled) {
if(MouseUtils.isMouseWithinBounds(pickerX, pickerY, PICKER_SIZE, PICKER_SIZE)) {
Point mousePoint = MouseUtils.getMousePos();
setPickerColor(getColorAtPosition(mousePoint.getX() - pickerX, mousePoint.getY() - pickerY));
}
}
return super.mousePressed(mc, mouseX, mouseY);
}
@Override
public void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
if(Mouse.isButtonDown(0)) mousePressed(mc, mouseX, mouseY);
}
public void pickerToggled() {
pickerVisible = !pickerVisible;
}
private int getColorAtPosition(int x, int y) {
if(x < 0 || x > PICKER_SIZE || y < 0 || y > PICKER_SIZE) return 0;
boolean grey = x >= (PICKER_SIZE-5);
float h = grey ? 0 : (float)x / (PICKER_SIZE - 5);
float s = grey ? 0 : y <= (PICKER_SIZE/2) ? (float)y / (PICKER_SIZE/2) : 1;
float v = grey ? 1 - ((float)y / PICKER_SIZE) : y > (PICKER_SIZE/2) ? 1 - ((float)(y-(PICKER_SIZE/2)) / (PICKER_SIZE/2f)) : 1;
return Color.HSBtoRGB(h, s, v);
}
public void setPickerColor(int color) {
this.pickedColor = color;
}
public int getPickedColor() {
return pickedColor & 0xffffff;
}
}

View File

@@ -1,13 +1,17 @@
package eu.crushedpixel.replaymod.gui.elements; package eu.crushedpixel.replaymod.gui.elements;
import eu.crushedpixel.replaymod.ReplayMod;
import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener; import eu.crushedpixel.replaymod.gui.elements.listeners.SelectionListener;
import eu.crushedpixel.replaymod.utils.MouseUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiTextField;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.util.Point;
import java.awt.*; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
public class GuiDropdown<T> extends GuiTextField { public class GuiDropdown<T> extends GuiTextField {
@@ -22,6 +26,7 @@ public class GuiDropdown<T> extends GuiTextField {
private int upperIndex = 0; private int upperIndex = 0;
private List<T> elements = new ArrayList<T>(); private List<T> elements = new ArrayList<T>();
private HashMap<Integer, String> hoverTexts = new HashMap<Integer, String>();
public GuiDropdown(int id, FontRenderer fontRenderer, public GuiDropdown(int id, FontRenderer fontRenderer,
int xPos, int yPos, int width, int visibleDropout) { int xPos, int yPos, int width, int visibleDropout) {
@@ -49,6 +54,10 @@ public class GuiDropdown<T> extends GuiTextField {
drawHorizontalLine(xPosition + width - height + i + 4, xPosition + width - i - 4, yPosition + (height / 4) + i + 2, -6250336); drawHorizontalLine(xPosition + width - height + i + 4, xPosition + width - i - 4, yPosition + (height / 4) + i + 2, -6250336);
} }
boolean drawHover = false;
Point hoverPos = null;
String hoverText = null;
if(open && elements.size() > 0) { if(open && elements.size() > 0) {
//draw the dropout part when opened //draw the dropout part when opened
@@ -78,6 +87,16 @@ public class GuiDropdown<T> extends GuiTextField {
String toWrite = mc.fontRendererObj.trimStringToWidth(obj.toString(), width - 8); String toWrite = mc.fontRendererObj.trimStringToWidth(obj.toString(), width - 8);
drawString(mc.fontRendererObj, toWrite, xPosition + 4, yPosition + height + y + 4, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, toWrite, xPosition + 4, yPosition + height + y + 4, Color.WHITE.getRGB());
if(MouseUtils.isMouseWithinBounds(xPosition, yPosition + height + y, width, dropoutElementHeight)) {
String hover = hoverTexts.get(i);
if(hover != null) {
Point mousePos = MouseUtils.getMousePos();
drawHover = true;
hoverPos = mousePos;
hoverText = hover;
}
}
y += dropoutElementHeight; y += dropoutElementHeight;
i++; i++;
if(y >= requiredHeight) { if(y >= requiredHeight) {
@@ -106,6 +125,10 @@ public class GuiDropdown<T> extends GuiTextField {
drawRect(xPosition + width - 3, yPosition + height + barY, xPosition + width, yPosition + height + 2 + barY + barHeight, -6250336); drawRect(xPosition + width - 3, yPosition + height + barY, xPosition + width, yPosition + height + 2 + barY + barHeight, -6250336);
} }
if(drawHover) {
ReplayMod.tooltipRenderer.drawTooltip(hoverPos.getX(), hoverPos.getY(), hoverText, null, Color.WHITE.getRGB());
}
} }
} }
@@ -162,6 +185,10 @@ public class GuiDropdown<T> extends GuiTextField {
} }
} }
public void setHoverText(int index, String text) {
hoverTexts.put(index, text);
}
public T getElement(int index) { public T getElement(int index) {
return elements.get(index); return elements.get(index);
} }

View File

@@ -0,0 +1,38 @@
package eu.crushedpixel.replaymod.gui.elements;
import net.minecraft.client.gui.GuiButton;
public class GuiToggleButton extends GuiButton {
private String baseText;
private String[] values;
private int value;
public GuiToggleButton(int buttonId, int x, int y, String buttonText, String[] values) {
super(buttonId, x, y, buttonText);
this.values = values;
this.baseText = buttonText;
this.value = 0;
if(values.length <= 1) {
throw new RuntimeException("At least two elements need to be added to a GuiToggleButton");
}
this.displayString = baseText+values[value];
}
public void toggle() {
value++;
if(value >= values.length) value = 0;
this.displayString = baseText+values[value];
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}

View File

@@ -38,4 +38,10 @@ public class MouseUtils {
return new Point(width, heigth); return new Point(width, heigth);
} }
public static boolean isMouseWithinBounds(int minX, int minY, int width, int height) {
Point mousePos = getMousePos();
return mousePos.getX() >= minX && mousePos.getX() <= minX + width
&& mousePos.getY() >= minY && mousePos.getY() <= minY + height;
}
} }

View File

@@ -39,7 +39,7 @@ public class TooltipRenderer extends Gui {
int i1 = 8; int i1 = 8;
if (textLines.length > 1) { if (textLines.length > 1) {
i1 += 2 + (textLines.length - 1) * 10; i1 += (textLines.length - 1) * 12;
} }
if (j2 + maxLineWidth > screenWidth) { if (j2 + maxLineWidth > screenWidth) {
@@ -66,14 +66,9 @@ public class TooltipRenderer extends Gui {
this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxLineWidth + 3, k2 - 3 + 1, k1, k1); this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxLineWidth + 3, k2 - 3 + 1, k1, k1);
this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + maxLineWidth + 3, k2 + i1 + 3, l1, l1); this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + maxLineWidth + 3, k2 + i1 + 3, l1, l1);
int i = 0;
for(String line : textLines) { for(String line : textLines) {
mc.fontRendererObj.drawStringWithShadow(line, j2, k2, textColor); mc.fontRendererObj.drawStringWithShadow(line, j2, k2, textColor);
if(i == 0) {
k2 += 2;
}
k2 += 12; k2 += 12;
} }
} }

View File

@@ -93,7 +93,7 @@ public abstract class CustomEntityRenderer {
renderglobal.renderSky(partialTicks, renderPass); renderglobal.renderSky(partialTicks, renderPass);
} else { } else {
int c = options.getSkyColor(); int c = options.getSkyColor();
clearColor(c >> 16, c >> 8 & 0xff, c & 0xff, 0xff); clearColor((c >> 16 & 0xff) / (float) 0xff, (c >> 8 & 0xff) / (float) 0xff, (c & 0xff) / (float) 0xff, 1);
clear(GL_COLOR_BUFFER_BIT); clear(GL_COLOR_BUFFER_BIT);
} }
matrixMode(GL_PROJECTION); matrixMode(GL_PROJECTION);

View File

@@ -264,10 +264,15 @@ replaymod.gui.rendersettings.interpolation=Path Interpolation
replaymod.gui.rendersettings.forcechunks=Force Render Chunks replaymod.gui.rendersettings.forcechunks=Force Render Chunks
replaymod.gui.rendersettings.framerate=Video Framerate replaymod.gui.rendersettings.framerate=Video Framerate
replaymod.gui.rendersettings.quality=Video Quality replaymod.gui.rendersettings.quality=Video Quality
replaymod.gui.rendersettings.greenscreen=Render Greenscreen Sky
replaymod.gui.rendersettings.skycolor=Sky Color
replaymod.gui.rendersettings.stablecamera=Ignore Camera Rotation replaymod.gui.rendersettings.stablecamera=Ignore Camera Rotation
replaymod.gui.rendersettings.exportyoutube=Export for YouTube replaymod.gui.rendersettings.exportyoutube=Export for YouTube
replaymod.gui.rendersettings.basic=Basic Settings
replaymod.gui.rendersettings.advanced=Advanced Settings
#Rendering GUI #Rendering GUI
replaymod.gui.rendering.title=Rendering Video replaymod.gui.rendering.title=Rendering Video
replaymod.gui.rendering.pause=Pause Rendering replaymod.gui.rendering.pause=Pause Rendering