From cbbc50a37a361a7f5ac04e3bf89f45859bd9b2b6 Mon Sep 17 00:00:00 2001 From: CrushedPixel Date: Fri, 22 May 2015 17:06:36 +0200 Subject: [PATCH] Renamed "Camera Tilt" to "Camera Roll" (new naming convention!) Changed Camera Roll to use Degree Values Started adding Timeline Position Editing to GuiEditKeyframe --- ...CameraTiltingCT.java => CameraRollCT.java} | 5 +- ...ansformer.java => EnchantmentTimerCT.java} | 2 +- .../replaymod/coremod/LoadingPlugin.java | 4 +- .../replaymod/events/GuiReplayOverlay.java | 2 +- .../replaymod/events/KeyInputHandler.java | 8 +- .../replaymod/gui/GuiConstants.java | 7 ++ .../replaymod/gui/GuiEditKeyframe.java | 83 ++++++++++++++++--- .../gui/elements/GuiNumberInput.java | 31 ++++++- .../gui/replaystudio/GuiTrimPart.java | 17 ++-- .../replaymod/holders/Position.java | 15 ++-- .../replaymod/interpolation/LinearPoint.java | 2 +- .../replaymod/registry/KeybindRegistry.java | 8 +- .../replaymod/replay/ReplayProcess.java | 2 +- .../replaymod/utils/TimestampUtils.java | 20 +++++ .../assets/replaymod/lang/en_US.lang | 9 +- 15 files changed, 166 insertions(+), 49 deletions(-) rename src/main/java/eu/crushedpixel/replaymod/coremod/{CameraTiltingCT.java => CameraRollCT.java} (90%) rename src/main/java/eu/crushedpixel/replaymod/coremod/{ClassTransformer.java => EnchantmentTimerCT.java} (98%) create mode 100644 src/main/java/eu/crushedpixel/replaymod/utils/TimestampUtils.java diff --git a/src/main/java/eu/crushedpixel/replaymod/coremod/CameraTiltingCT.java b/src/main/java/eu/crushedpixel/replaymod/coremod/CameraRollCT.java similarity index 90% rename from src/main/java/eu/crushedpixel/replaymod/coremod/CameraTiltingCT.java rename to src/main/java/eu/crushedpixel/replaymod/coremod/CameraRollCT.java index 9251bb51..710be795 100644 --- a/src/main/java/eu/crushedpixel/replaymod/coremod/CameraTiltingCT.java +++ b/src/main/java/eu/crushedpixel/replaymod/coremod/CameraRollCT.java @@ -9,7 +9,7 @@ import java.util.ListIterator; import static org.objectweb.asm.Opcodes.*; -public class CameraTiltingCT implements IClassTransformer { +public class CameraRollCT implements IClassTransformer { private static final String REPLAY_HANDLER = "eu/crushedpixel/replaymod/replay/ReplayHandler"; private static final String CLASS_NAME = "net.minecraft.client.renderer.EntityRenderer"; @@ -47,7 +47,7 @@ public class CameraTiltingCT implements IClassTransformer { * public void orientCamera(float f) { * ... * if (ReplayHandler.isInReplay()) { - * GL11.glRotated(Math.toRadians(ReplayHandler.getCameraTilt()), 0, 0, 1); + * GL11.glRotated(ReplayHandler.getCameraTilt(), 0, 0, 1); * } * ... * } @@ -58,7 +58,6 @@ public class CameraTiltingCT implements IClassTransformer { iter.add(new JumpInsnNode(IFEQ, l)); iter.add(new MethodInsnNode(INVOKESTATIC, REPLAY_HANDLER, "getCameraTilt", "()F", false)); iter.add(new InsnNode(F2D)); - iter.add(new MethodInsnNode(INVOKESTATIC, "java/lang/Math", "toRadians", "(D)D", false)); iter.add(new LdcInsnNode(0D)); iter.add(new LdcInsnNode(0D)); iter.add(new LdcInsnNode(1D)); diff --git a/src/main/java/eu/crushedpixel/replaymod/coremod/ClassTransformer.java b/src/main/java/eu/crushedpixel/replaymod/coremod/EnchantmentTimerCT.java similarity index 98% rename from src/main/java/eu/crushedpixel/replaymod/coremod/ClassTransformer.java rename to src/main/java/eu/crushedpixel/replaymod/coremod/EnchantmentTimerCT.java index f9aea6c0..da72b042 100755 --- a/src/main/java/eu/crushedpixel/replaymod/coremod/ClassTransformer.java +++ b/src/main/java/eu/crushedpixel/replaymod/coremod/EnchantmentTimerCT.java @@ -14,7 +14,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -public class ClassTransformer implements IClassTransformer { +public class EnchantmentTimerCT implements IClassTransformer { @Override public byte[] transform(String name, String transformedName, diff --git a/src/main/java/eu/crushedpixel/replaymod/coremod/LoadingPlugin.java b/src/main/java/eu/crushedpixel/replaymod/coremod/LoadingPlugin.java index 9c6b6adc..ad70116f 100755 --- a/src/main/java/eu/crushedpixel/replaymod/coremod/LoadingPlugin.java +++ b/src/main/java/eu/crushedpixel/replaymod/coremod/LoadingPlugin.java @@ -9,8 +9,8 @@ public class LoadingPlugin implements IFMLLoadingPlugin { @Override public String[] getASMTransformerClass() { return new String[]{ - CameraTiltingCT.class.getName(), - ClassTransformer.class.getName() + CameraRollCT.class.getName(), + EnchantmentTimerCT.class.getName() }; } diff --git a/src/main/java/eu/crushedpixel/replaymod/events/GuiReplayOverlay.java b/src/main/java/eu/crushedpixel/replaymod/events/GuiReplayOverlay.java index 96bcedff..386d3318 100755 --- a/src/main/java/eu/crushedpixel/replaymod/events/GuiReplayOverlay.java +++ b/src/main/java/eu/crushedpixel/replaymod/events/GuiReplayOverlay.java @@ -557,7 +557,7 @@ public class GuiReplayOverlay extends Gui { if(liftedSinceSelection) { ReplayHandler.setRealTimelineCursor(real_pos); } else if(ReplayHandler.getSelectedKeyframe() != null) { - int tolerance = Math.round(abs_width / (float) width); + int tolerance = 2 * Math.round(abs_width / (float) width); if(Math.abs(selectionTimestamp - real_pos) > tolerance || overcameToleranceSinceSelection) { ReplayHandler.setRealTimelineCursor(real_pos); diff --git a/src/main/java/eu/crushedpixel/replaymod/events/KeyInputHandler.java b/src/main/java/eu/crushedpixel/replaymod/events/KeyInputHandler.java index 4f5ad9e1..c6216342 100755 --- a/src/main/java/eu/crushedpixel/replaymod/events/KeyInputHandler.java +++ b/src/main/java/eu/crushedpixel/replaymod/events/KeyInputHandler.java @@ -108,12 +108,12 @@ public class KeyInputHandler { ReplayMod.overlay.playOrPause(); } - if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROTATE_CLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) { - ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? 1 : 5); + if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_CLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) { + ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? 0.2f : 1); } - if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROTATE_COUNTERCLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) { - ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? -1 : -5); + if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_COUNTERCLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) { + ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? -0.2f : -1); } if(kb.getKeyDescription().equals(KeybindRegistry.KEY_RESET_TILT) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !found && !ReplayHandler.isInPath()) { diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java index d5ddb999..45265fc9 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiConstants.java @@ -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; diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java index 99257ff6..58759d02 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiEditKeyframe.java @@ -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 inputs = new ArrayList(); + private List posInputs = new ArrayList(); 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); + } + } } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiNumberInput.java b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiNumberInput.java index 3a47b032..4cd500fe 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiNumberInput.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/elements/GuiNumberInput.java @@ -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; + } + } + } diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiTrimPart.java b/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiTrimPart.java index 9bf3104b..9c72b27b 100755 --- a/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiTrimPart.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/replaystudio/GuiTrimPart.java @@ -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()); diff --git a/src/main/java/eu/crushedpixel/replaymod/holders/Position.java b/src/main/java/eu/crushedpixel/replaymod/holders/Position.java index 4f503f2a..99bd4747 100755 --- a/src/main/java/eu/crushedpixel/replaymod/holders/Position.java +++ b/src/main/java/eu/crushedpixel/replaymod/holders/Position.java @@ -6,8 +6,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; public class Position { private double x, y, z; - private float pitch, yaw; - private float rotation = 0; + private float pitch, yaw, roll; public Position(Entity e) { this.x = e.posX; @@ -17,13 +16,13 @@ public class Position { this.yaw = e.rotationYaw; } - public Position(double x, double y, double z, float pitch, float yaw, float rotation) { + public Position(double x, double y, double z, float pitch, float yaw, float roll) { this.x = x; this.y = y; this.z = z; this.pitch = pitch; this.yaw = yaw; - this.rotation = rotation; + this.roll = roll; } public Position(double x, double y, double z, float pitch, float yaw) { @@ -74,13 +73,13 @@ public class Position { this.yaw = yaw; } - public float getRotation() { return rotation; } + public float getRoll() { return roll; } - public void setRotation(float rotation) { this.rotation = rotation; } + public void setRoll(float roll) { this.roll = roll; } @Override public String toString() { - return "X=" + x + ", Y=" + y + ", Z=" + z + ", Yaw=" + yaw + ", Pitch=" + pitch; + return "X=" + x + ", Y=" + y + ", Z=" + z + ", Yaw=" + yaw + ", Pitch=" + pitch + ", Roll="+roll; } @Override @@ -99,7 +98,7 @@ public class Position { .append(z) .append(pitch) .append(yaw) - .append(rotation) + .append(roll) .toHashCode(); } } diff --git a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java index f69a1279..986b715f 100755 --- a/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java +++ b/src/main/java/eu/crushedpixel/replaymod/interpolation/LinearPoint.java @@ -22,7 +22,7 @@ public class LinearPoint extends LinearInterpolation { float pitch = (float)getInterpolatedValue(first.getPitch(), second.getPitch(), perc); float yaw = (float)getInterpolatedValue(first.getYaw(), second.getYaw(), perc); - float rot = (float)getInterpolatedValue(first.getRotation(), second.getRotation(), perc); + float rot = (float)getInterpolatedValue(first.getRoll(), second.getRoll(), perc); Position inter = new Position(x, y, z, pitch, yaw, rot); diff --git a/src/main/java/eu/crushedpixel/replaymod/registry/KeybindRegistry.java b/src/main/java/eu/crushedpixel/replaymod/registry/KeybindRegistry.java index d3c00cb7..f087f820 100755 --- a/src/main/java/eu/crushedpixel/replaymod/registry/KeybindRegistry.java +++ b/src/main/java/eu/crushedpixel/replaymod/registry/KeybindRegistry.java @@ -16,8 +16,8 @@ public class KeybindRegistry { public static final String KEY_CLEAR_KEYFRAMES = "replaymod.input.clearkeyframes"; public static final String KEY_SYNC_TIMELINE = "replaymod.input.synctimeline"; public static final String KEY_KEYFRAME_PRESETS = "replaymod.input.keyframerepository"; - public static final String KEY_ROTATE_CLOCKWISE = "replaymod.input.rotateclockwise"; - public static final String KEY_ROTATE_COUNTERCLOCKWISE = "replaymod.input.rotatecounterclockwise"; + public static final String KEY_ROLL_CLOCKWISE = "replaymod.input.rollclockwise"; + public static final String KEY_ROLL_COUNTERCLOCKWISE = "replaymod.input.rollcounterclockwise"; public static final String KEY_RESET_TILT = "replaymod.input.resettilt"; public static final String KEY_PLAY_PAUSE = "replaymod.input.playpause"; private static Minecraft mc = Minecraft.getMinecraft(); @@ -31,9 +31,9 @@ public class KeybindRegistry { bindings.add(new KeyBinding(KEY_SYNC_TIMELINE, Keyboard.KEY_V, "replaymod.title")); bindings.add(new KeyBinding(KEY_CLEAR_KEYFRAMES, Keyboard.KEY_C, "replaymod.title")); bindings.add(new KeyBinding(KEY_KEYFRAME_PRESETS, Keyboard.KEY_X, "replaymod.title")); - bindings.add(new KeyBinding(KEY_ROTATE_CLOCKWISE, Keyboard.KEY_L, "replaymod.title")); + bindings.add(new KeyBinding(KEY_ROLL_CLOCKWISE, Keyboard.KEY_L, "replaymod.title")); bindings.add(new KeyBinding(KEY_RESET_TILT, Keyboard.KEY_K, "replaymod.title")); - bindings.add(new KeyBinding(KEY_ROTATE_COUNTERCLOCKWISE, Keyboard.KEY_J, "replaymod.title")); + bindings.add(new KeyBinding(KEY_ROLL_COUNTERCLOCKWISE, Keyboard.KEY_J, "replaymod.title")); bindings.add(new KeyBinding(KEY_PLAY_PAUSE, Keyboard.KEY_P, "replaymod.title")); mc.gameSettings.keyBindings = bindings.toArray(new KeyBinding[bindings.size()]); diff --git a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java index 9cfa5cc8..40af0ca4 100755 --- a/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java +++ b/src/main/java/eu/crushedpixel/replaymod/replay/ReplayProcess.java @@ -333,7 +333,7 @@ public class ReplayProcess { } } - ReplayHandler.setCameraTilt(pos.getRotation()); + ReplayHandler.setCameraTilt(pos.getRoll()); Integer curTimestamp = null; if(timeLinear != null && timeCount > 1) { diff --git a/src/main/java/eu/crushedpixel/replaymod/utils/TimestampUtils.java b/src/main/java/eu/crushedpixel/replaymod/utils/TimestampUtils.java new file mode 100644 index 00000000..436aef80 --- /dev/null +++ b/src/main/java/eu/crushedpixel/replaymod/utils/TimestampUtils.java @@ -0,0 +1,20 @@ +package eu.crushedpixel.replaymod.utils; + +public class TimestampUtils { + + public static int getMinutesFromTimestamp(long timestamp) { + return (int)((timestamp / (1000*60)) % 60); + } + + public static int getSecondsFromTimestamp(long timestamp) { + return (int)(timestamp / 1000) % 60; + } + + public static int getMillisecondsFromTimestamp(long timestamp) { + return(int)(timestamp % 1000); + } + + public static int calculateTimestamp(int min, int sec, int ms) { + return (min * 60 * 1000) + (sec * 1000) + ms; + } +} diff --git a/src/main/resources/assets/replaymod/lang/en_US.lang b/src/main/resources/assets/replaymod/lang/en_US.lang index c4c1958e..c58569f2 100644 --- a/src/main/resources/assets/replaymod/lang/en_US.lang +++ b/src/main/resources/assets/replaymod/lang/en_US.lang @@ -73,6 +73,10 @@ replaymod.gui.register=Register replaymod.gui.mail=Email Address replaymod.gui.loading=Loading +replaymod.gui.minutes=min +replaymod.gui.seconds=sec +replaymod.gui.milliseconds=ms + replaymod.gui.unknownerror=An unknown error occured replaymod.gui.exit=Exit Replay @@ -203,8 +207,8 @@ replaymod.input.playeroverview=Player Overview replaymod.input.clearkeyframes=Clear Keyframes replaymod.input.synctimeline=Synchronize Timeline replaymod.input.keyframerepository=Open Keyframe Presets -replaymod.input.rotateclockwise=Rotate Clockwise -replaymod.input.rotatecounterclockwise=Rotate Counterclockwise +replaymod.input.rollclockwise=Roll Clockwise +replaymod.input.rollcounterclockwise=Roll Counterclockwise replaymod.input.resettilt=Reset Camera Tilt replaymod.input.playpause=Play/Pause Replay @@ -228,3 +232,4 @@ replaymod.gui.editkeyframe.ypos=Y Position replaymod.gui.editkeyframe.zpos=Z Position replaymod.gui.editkeyframe.campitch=Camera Pitch replaymod.gui.editkeyframe.camyaw=Camera Yaw +replaymod.gui.editkeyframe.camroll=Camera Roll