Allow for simpler repositioning of the preview
This commit is contained in:
@@ -29,11 +29,9 @@ public class GuiVideoRenderer extends GuiScreen {
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked") // I blame forge for not re-adding generics to that list
|
@SuppressWarnings("unchecked") // I blame forge for not re-adding generics to that list
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
FrameRenderer frameRenderer = renderer.getFrameRenderer();
|
|
||||||
|
|
||||||
String text = PREVIEW;
|
String text = PREVIEW;
|
||||||
buttonList.add(previewCheckBox = new GuiCheckBox(0, (width - fontRendererObj.getStringWidth(text)) / 2 - 8,
|
buttonList.add(previewCheckBox = new GuiCheckBox(0, (width - fontRendererObj.getStringWidth(text)) / 2 - 8,
|
||||||
frameRenderer.getPreviewHeight(this), text, false));
|
height - 20, text, false));
|
||||||
|
|
||||||
text = PAUSE_RENDERING;
|
text = PAUSE_RENDERING;
|
||||||
buttonList.add(pauseButton = new GuiButton(1, width / 2 - 152, height / 2 - 23, text));
|
buttonList.add(pauseButton = new GuiButton(1, width / 2 - 152, height / 2 - 23, text));
|
||||||
@@ -88,11 +86,14 @@ public class GuiVideoRenderer extends GuiScreen {
|
|||||||
String framesProgress = I18n.format("replaymod.gui.rendering.progress", renderer.getFramesDone(), renderer.getTotalFrames());
|
String framesProgress = I18n.format("replaymod.gui.rendering.progress", renderer.getFramesDone(), renderer.getTotalFrames());
|
||||||
drawCenteredString(fontRendererObj, framesProgress, centerX, centerY - 45, 0xffffffff);
|
drawCenteredString(fontRendererObj, framesProgress, centerX, centerY - 45, 0xffffffff);
|
||||||
|
|
||||||
|
int previewX = width / 4;
|
||||||
|
int previewY = height / 2 + 10;
|
||||||
|
int previewWidth = width / 2;
|
||||||
|
int previewHeight = height - 30 - previewY;
|
||||||
if (previewCheckBox.isChecked()) {
|
if (previewCheckBox.isChecked()) {
|
||||||
frameRenderer.renderPreview(this);
|
frameRenderer.renderPreview(previewX, previewY, previewWidth, previewHeight);
|
||||||
} else {
|
} else {
|
||||||
int previewHeight = frameRenderer.getPreviewHeight(this) - height / 2 - 10;
|
FrameRenderer.renderNoPreview(previewX, previewY, previewWidth, previewHeight);
|
||||||
FrameRenderer.renderNoPreview(width, height, previewHeight);
|
|
||||||
}
|
}
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package eu.crushedpixel.replaymod.video.frame;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.util.concurrent.Runnables;
|
import com.google.common.util.concurrent.Runnables;
|
||||||
import eu.crushedpixel.replaymod.gui.GuiVideoRenderer;
|
|
||||||
import eu.crushedpixel.replaymod.video.entity.CustomEntityRenderer;
|
import eu.crushedpixel.replaymod.video.entity.CustomEntityRenderer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
@@ -174,48 +172,43 @@ public abstract class FrameRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the height including any borders of the preview.
|
* Draw a preview of the current scene within the specified box.
|
||||||
* No rendering should be performed by {@link #renderPreview(GuiVideoRenderer)} below this height.
|
* @param x Left border of the box
|
||||||
* @param guiScreen The gui screen
|
* @param y Upper border of the box
|
||||||
* @return Bottom of the preview
|
* @param width Width of the box
|
||||||
|
* @param height Height of the box
|
||||||
*/
|
*/
|
||||||
public int getPreviewHeight(GuiScreen guiScreen) {
|
public void renderPreview(int x, int y, int width, int height) {
|
||||||
int width = guiScreen.width / 2;
|
int actualWidth = width;
|
||||||
int height = guiScreen.height / 3;
|
int actualHeight = height;
|
||||||
if (width / height < getVideoWidth() / getVideoHeight()) {
|
|
||||||
height = width * getVideoHeight() / getVideoWidth();
|
|
||||||
}
|
|
||||||
return guiScreen.height / 2 + height + 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draw a preview of the current scene on the lower half of the screen.
|
|
||||||
* @param guiScreen The gui screen
|
|
||||||
*/
|
|
||||||
public void renderPreview(GuiVideoRenderer guiScreen) {
|
|
||||||
int width = guiScreen.width / 2;
|
|
||||||
int height = guiScreen.height / 3;
|
|
||||||
if (width / height > getVideoWidth() / getVideoHeight()) {
|
if (width / height > getVideoWidth() / getVideoHeight()) {
|
||||||
width = height * getVideoWidth() / getVideoHeight();
|
actualWidth = height * getVideoWidth() / getVideoHeight();
|
||||||
} else {
|
} else {
|
||||||
height = width * getVideoHeight() / getVideoWidth();
|
actualHeight = width * getVideoHeight() / getVideoWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = guiScreen.width / 2 - width / 2;
|
x += (width - actualWidth) / 2;
|
||||||
int y = guiScreen.height / 2 + 5;
|
y += (height - actualHeight) / 2;
|
||||||
|
|
||||||
bindTexture(previewTexture.getGlTextureId());
|
bindTexture(previewTexture.getGlTextureId());
|
||||||
color(1, 1, 1, 1);
|
color(1, 1, 1, 1);
|
||||||
Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, videoWidth, videoHeight, width, height, videoWidth, videoHeight);
|
Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, videoWidth, videoHeight, actualWidth, actualHeight, videoWidth, videoHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderNoPreview(int guiWidth, int guiHeight, int height) {
|
public static void renderNoPreview(int x, int y, int width, int height) {
|
||||||
int width = height * 1280 / 720;
|
int actualWidth = width;
|
||||||
int x = guiWidth / 2 - width / 2;
|
int actualHeight = height;
|
||||||
int y = guiHeight / 2 + 5;
|
if (width / height > 1280 / 720) {
|
||||||
|
actualWidth = height * 1280 / 720;
|
||||||
|
} else {
|
||||||
|
actualHeight = width * 720 / 1280;
|
||||||
|
}
|
||||||
|
|
||||||
|
x += (width - actualWidth) / 2;
|
||||||
|
y += (height - actualHeight) / 2;
|
||||||
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(noPreviewTexture);
|
Minecraft.getMinecraft().getTextureManager().bindTexture(noPreviewTexture);
|
||||||
color(1, 1, 1, 1);
|
color(1, 1, 1, 1);
|
||||||
Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, 1280, 720, width, height, 1280, 720);
|
Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, 1280, 720, actualWidth, actualHeight, 1280, 720);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user