Renamed "Camera Tilt" to "Camera Roll" (new naming convention!)
Changed Camera Roll to use Degree Values Started adding Timeline Position Editing to GuiEditKeyframe
This commit is contained in:
@@ -76,6 +76,13 @@ public class GuiConstants {
|
||||
public static final int KEYFRAME_EDITOR_Z_INPUT = 6006;
|
||||
public static final int KEYFRAME_EDITOR_PITCH_INPUT = 6007;
|
||||
public static final int KEYFRAME_EDITOR_YAW_INPUT = 6008;
|
||||
public static final int KEYFRAME_EDITOR_ROLL_INPUT = 6009;
|
||||
public static final int KEYFRAME_EDITOR_MIN_INPUT = 6010;
|
||||
public static final int KEYFRAME_EDITOR_SEC_INPUT = 6011;
|
||||
public static final int KEYFRAME_EDITOR_MS_INPUT = 6012;
|
||||
public static final int KEYFRAME_EDITOR_REAL_MIN_INPUT = 6013;
|
||||
public static final int KEYFRAME_EDITOR_REAL_SEC_INPUT = 6014;
|
||||
public static final int KEYFRAME_EDITOR_REAL_MS_INPUT = 6015;
|
||||
|
||||
public static final int PLAYER_OVERVIEW_HIDE_ALL = 1010;
|
||||
public static final int PLAYER_OVERVIEW_SHOW_ALL = 0101;
|
||||
|
||||
@@ -4,6 +4,8 @@ import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
|
||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||
import eu.crushedpixel.replaymod.holders.Position;
|
||||
import eu.crushedpixel.replaymod.holders.PositionKeyframe;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.utils.TimestampUtils;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -20,8 +22,11 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
|
||||
private GuiButton saveButton, cancelButton;
|
||||
|
||||
private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw;
|
||||
private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
|
||||
private GuiNumberInput min, sec, ms;
|
||||
|
||||
private List<GuiNumberInput> inputs = new ArrayList<GuiNumberInput>();
|
||||
private List<GuiNumberInput> posInputs = new ArrayList<GuiNumberInput>();
|
||||
|
||||
private int virtualHeight = 200;
|
||||
private int virtualY;
|
||||
@@ -31,7 +36,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
private boolean save;
|
||||
private boolean posKeyframe;
|
||||
|
||||
private int w, w2;
|
||||
private int w, w2, w3;
|
||||
private int totalWidth;
|
||||
private int left;
|
||||
|
||||
@@ -51,6 +56,17 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
saveButton = new GuiButton(GuiConstants.KEYFRAME_EDITOR_SAVE_BUTTON, 0, 0, 100, 20, I18n.format("replaymod.gui.save"));
|
||||
cancelButton = new GuiButton(GuiConstants.KEYFRAME_EDITOR_CANCEL_BUTTON, 0, 0, 100, 20, I18n.format("replaymod.gui.cancel"));
|
||||
|
||||
//Real Time Input
|
||||
int timestamp = keyframe.getRealTimestamp();
|
||||
min = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_MIN_INPUT, fontRendererObj, 0, 0, 30, 0, 10, TimestampUtils.getMinutesFromTimestamp(timestamp), false);
|
||||
sec = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_SEC_INPUT, fontRendererObj, 0, 0, 25, 0, 59, TimestampUtils.getSecondsFromTimestamp(timestamp), false);
|
||||
ms = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_SEC_INPUT, fontRendererObj, 0, 0, 35, 0, 999, TimestampUtils.getMillisecondsFromTimestamp(timestamp), false);
|
||||
|
||||
inputs.add(min);
|
||||
inputs.add(sec);
|
||||
inputs.add(ms);
|
||||
|
||||
//Position/Virtual Time Input
|
||||
if(posKeyframe) {
|
||||
Position pos = ((PositionKeyframe)keyframe).getPosition();
|
||||
xCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_X_INPUT, fontRendererObj, 0, 0, 100, null, null, round(pos.getX()), true);
|
||||
@@ -58,28 +74,45 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
zCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_Z_INPUT, fontRendererObj, 0, 0, 100, null, null, round(pos.getZ()), true);
|
||||
yaw = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_YAW_INPUT, fontRendererObj, 0, 0, 100, -90d, 90d, round(pos.getYaw()), true);
|
||||
pitch = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_PITCH_INPUT, fontRendererObj, 0, 0, 100, -180d, 180d, round(pos.getPitch()), true);
|
||||
roll = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_ROLL_INPUT, fontRendererObj, 0, 0, 100, null, null, round(pos.getRoll()), true);
|
||||
|
||||
inputs.add(xCoord);
|
||||
inputs.add(yCoord);
|
||||
inputs.add(zCoord);
|
||||
inputs.add(yaw);
|
||||
inputs.add(pitch);
|
||||
posInputs.add(xCoord);
|
||||
posInputs.add(yCoord);
|
||||
posInputs.add(zCoord);
|
||||
posInputs.add(yaw);
|
||||
posInputs.add(pitch);
|
||||
posInputs.add(roll);
|
||||
|
||||
inputs.addAll(posInputs);
|
||||
}
|
||||
}
|
||||
|
||||
w3 = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes"))+5+min.width+5+
|
||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.seconds"))+5+sec.width+5+
|
||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.milliseconds"))+5+ms.width;
|
||||
|
||||
int l = (this.width-w3)/2;
|
||||
min.xPosition = l;
|
||||
sec.xPosition = l + min.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes")) + 5;
|
||||
ms.xPosition = l + min.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes")) + 5
|
||||
+ sec.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.seconds")) + 5;
|
||||
|
||||
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-60;
|
||||
|
||||
if(posKeyframe) {
|
||||
w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")),
|
||||
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.ypos")),
|
||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.zpos"))));
|
||||
w2 = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camyaw")),
|
||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.campitch")));
|
||||
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.campitch")),
|
||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camroll"))));
|
||||
|
||||
totalWidth = w+100+w2+100+5+5+10;
|
||||
left = (this.width - totalWidth)/2;
|
||||
|
||||
int x = w + left + 5;
|
||||
int i=0;
|
||||
for(GuiNumberInput input : inputs) {
|
||||
int i = 0;
|
||||
for(GuiNumberInput input : posInputs) {
|
||||
input.xPosition = i < 3 ? x : left+totalWidth-100;
|
||||
input.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30;
|
||||
i++;
|
||||
@@ -98,6 +131,17 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
if(!save) {
|
||||
ReplayHandler.removeKeyframe(keyframe);
|
||||
ReplayHandler.addKeyframe(keyframeBackup);
|
||||
ReplayHandler.selectKeyframe(keyframeBackup);
|
||||
} else {
|
||||
if(posKeyframe) {
|
||||
((PositionKeyframe)keyframe).setPosition(new Position(xCoord.getValue(false), yCoord.getValue(false),
|
||||
zCoord.getValue(false), new Float(pitch.getValue(false)), new Float(yaw.getValue(false)),
|
||||
new Float(roll.getValue(false))));
|
||||
}
|
||||
}
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
@@ -106,7 +150,11 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
for(GuiNumberInput input : inputs) {
|
||||
if(input != null) input.textboxKeyTyped(typedChar, keyCode);
|
||||
}
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
|
||||
if(keyCode == Keyboard.KEY_ESCAPE) {
|
||||
save = false;
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,6 +183,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.zpos"), left, virtualY + 87, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camyaw"), left+totalWidth-100-5-w2, virtualY + 27, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.campitch"), left+totalWidth-100-5-w2, virtualY + 57, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camroll"), left+totalWidth-100-5-w2, virtualY + 87, Color.WHITE.getRGB());
|
||||
}
|
||||
|
||||
for(GuiNumberInput input : inputs) {
|
||||
@@ -147,4 +196,16 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
private double round(double val) {
|
||||
return Math.round(val*100.0) / 100.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
if(!button.enabled) return;
|
||||
if(button.id == GuiConstants.KEYFRAME_EDITOR_SAVE_BUTTON) {
|
||||
save = true;
|
||||
mc.displayGuiScreen(null);
|
||||
} else if(button.id == GuiConstants.KEYFRAME_EDITOR_CANCEL_BUTTON) {
|
||||
save = false;
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,18 @@ public class GuiNumberInput extends GuiTextField {
|
||||
this.minimum = minimum;
|
||||
this.maximum = maximum;
|
||||
this.acceptFloats = acceptFloats;
|
||||
if(defaultValue != null) setText(""+defaultValue);
|
||||
if(defaultValue != null) {
|
||||
if(acceptFloats) {
|
||||
setText("" + defaultValue);
|
||||
} else {
|
||||
setText("" + (int)Math.round(defaultValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GuiNumberInput(int id, FontRenderer fontRenderer,
|
||||
int xPos, int yPos, int width, int minimum, int maximum, int defaultValue, boolean acceptFloats) {
|
||||
this(id, fontRenderer, xPos, yPos, width, new Double(minimum), new Double(maximum), new Double(defaultValue), acceptFloats);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,11 +38,25 @@ public class GuiNumberInput extends GuiTextField {
|
||||
} else {
|
||||
val = Integer.valueOf(getText() + text);
|
||||
}
|
||||
if(minimum != null && val < minimum) return;
|
||||
if(maximum != null && val > maximum) return;
|
||||
if(minimum != null && val < minimum) {
|
||||
setText(acceptFloats ? minimum.toString() : new Integer((int)Math.round(minimum)).toString());
|
||||
return;
|
||||
}
|
||||
if(maximum != null && val > maximum) {
|
||||
setText(acceptFloats ? maximum.toString() : new Integer((int)Math.round(maximum)).toString());
|
||||
return;
|
||||
}
|
||||
super.writeText(text);
|
||||
} catch(NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public Double getValue(boolean nullable) {
|
||||
try {
|
||||
return Double.valueOf(getText());
|
||||
} catch(Exception e) {
|
||||
return nullable ? null : 0d;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package eu.crushedpixel.replaymod.gui.replaystudio;
|
||||
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
|
||||
import eu.crushedpixel.replaymod.studio.StudioImplementation;
|
||||
import eu.crushedpixel.replaymod.utils.TimestampUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -50,7 +51,7 @@ public class GuiTrimPart extends GuiStudioPart {
|
||||
int secs = valueOf(startSecInput.getText());
|
||||
int ms = valueOf(startMsInput.getText());
|
||||
|
||||
return (mins * 60 * 1000) + (secs * 1000) + ms;
|
||||
return TimestampUtils.calculateTimestamp(mins, secs, ms);
|
||||
}
|
||||
|
||||
private int getEndTimestamp() {
|
||||
@@ -58,7 +59,7 @@ public class GuiTrimPart extends GuiStudioPart {
|
||||
int secs = valueOf(endSecInput.getText());
|
||||
int ms = valueOf(endMsInput.getText());
|
||||
|
||||
return (mins * 60 * 1000) + (secs * 1000) + ms;
|
||||
return TimestampUtils.calculateTimestamp(mins, secs, ms);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,12 +107,12 @@ public class GuiTrimPart extends GuiStudioPart {
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.start")+":", 30, yPos + 7, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.end")+":", 30, yPos + 7 + 30, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, "m", 105, yPos + 7, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, "m", 105, yPos + 7 + 30, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, "s", 150, yPos + 7, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, "s", 150, yPos + 7 + 30, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, "ms", 200, yPos + 7, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, "ms", 200, yPos + 7 + 30, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.minutes"), 105, yPos + 7, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.minutes"), 105, yPos + 7 + 30, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.seconds"), 150, yPos + 7, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.seconds"), 150, yPos + 7 + 30, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.milliseconds"), 200, yPos + 7, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.milliseconds"), 200, yPos + 7 + 30, Color.WHITE.getRGB());
|
||||
|
||||
drawString(mc.fontRendererObj, "Timestamp: " + getStartTimestamp(), 230, yPos + 7, Color.WHITE.getRGB());
|
||||
drawString(mc.fontRendererObj, "Timestamp: " + getEndTimestamp(), 230, yPos + 30 + 7, Color.WHITE.getRGB());
|
||||
|
||||
Reference in New Issue
Block a user