GuiEditKeyframe now allows the user to set the Keyframe's exact position on the timeline
This commit is contained in:
@@ -309,7 +309,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
GlStateManager.resetColor();
|
||||
this.drawModalRectWithCustomSizedTexture(time_ButtonX, time_ButtonY, x, y, 20, 20, 64, 64);
|
||||
|
||||
if(mouseX >= (timelineX + 4) && mouseX <= width - 18 && mouseY >= 11 && mouseY <= 29 && mc.currentScreen == null) {
|
||||
if(mouseX >= (timelineX + 4) && mouseX <= width - 18 && mouseY >= 11 && mouseY <= 29 && mc.currentScreen.getClass() == GuiMouseInput.class) {
|
||||
double tot = (width - 18) - (timelineX + 4);
|
||||
double perc = (mouseX - (timelineX + 4)) / tot;
|
||||
long time = Math.round(perc * (double) ReplayMod.replaySender.replayLength());
|
||||
@@ -476,7 +476,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
}
|
||||
|
||||
//show Time String
|
||||
if(mouseX >= zero && mouseX <= full && mouseY >= y && mouseY <= y + 22 && mc.currentScreen == null) {
|
||||
if(mouseX >= zero && mouseX <= full && mouseY >= y && mouseY <= y + 22 && mc.currentScreen.getClass() == GuiMouseInput.class) {
|
||||
long tot = Math.round((double) timelineLength * zoom_scale);
|
||||
double perc = (mouseX - (realTimelineX + 4)) / (double) (full - zero);
|
||||
|
||||
@@ -543,7 +543,7 @@ public class GuiReplayOverlay extends Gui {
|
||||
|
||||
//handle Mouse clicks on realTimeLine
|
||||
if(Mouse.isButtonDown(0) && FMLClientHandler.instance().isGUIOpen(GuiMouseInput.class) && !wasSliding && mouseX >= minX + tl_begin_width && mouseX <= maxX - tl_end_width &&
|
||||
mouseY >= y && mouseY <= y + 22) {
|
||||
mouseY >= y && mouseY <= y + 22 && !ReplayHandler.isInPath()) {
|
||||
|
||||
//calculate real time and set cursor accordingly
|
||||
int width = (maxX - tl_end_width) - (minX + tl_begin_width);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
|
||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||
import eu.crushedpixel.replaymod.holders.Position;
|
||||
@@ -44,6 +45,8 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
this.keyframe = keyframe;
|
||||
this.keyframeBackup = (Keyframe)keyframe.clone();
|
||||
this.posKeyframe = keyframe instanceof PositionKeyframe;
|
||||
|
||||
ReplayMod.replaySender.setReplaySpeed(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,17 +90,20 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
}
|
||||
}
|
||||
|
||||
w3 = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes"))+5+min.width+5+
|
||||
w3 = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10+
|
||||
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
|
||||
min.xPosition = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10 + l;
|
||||
sec.xPosition = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10 + l +
|
||||
min.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes")) + 5;
|
||||
ms.xPosition = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10 + 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;
|
||||
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-65;
|
||||
|
||||
if(posKeyframe) {
|
||||
w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")),
|
||||
@@ -136,10 +142,11 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
ReplayHandler.addKeyframe(keyframeBackup);
|
||||
ReplayHandler.selectKeyframe(keyframeBackup);
|
||||
} else {
|
||||
keyframe.setRealTimestamp(TimestampUtils.calculateTimestamp(min.getIntValue(), sec.getIntValue(), ms.getIntValue()));
|
||||
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))));
|
||||
((PositionKeyframe)keyframe).setPosition(new Position(xCoord.getPreciseValue(), yCoord.getPreciseValue(),
|
||||
zCoord.getPreciseValue(), new Float(pitch.getPreciseValue()), (float)yaw.getPreciseValue(),
|
||||
(float)roll.getPreciseValue()));
|
||||
}
|
||||
}
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
@@ -177,6 +184,11 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
drawGradientRect(10, virtualY, width - 10, virtualY + virtualHeight, -1072689136, -804253680);
|
||||
drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.title"), this.width / 2, virtualY + 5, Color.WHITE.getRGB());
|
||||
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.timelineposition")+":", (width-w3)/2, min.yPosition + 7, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.minutes"), min.xPosition + min.width + 5, min.yPosition + 7, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.seconds"), sec.xPosition+sec.width+5, sec.yPosition+7, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.milliseconds"), ms.xPosition+ms.width+5, ms.yPosition+7, Color.WHITE.getRGB());
|
||||
|
||||
if(posKeyframe) {
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.xpos"), left, virtualY + 27, Color.WHITE.getRGB());
|
||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.ypos"), left, virtualY + 57, Color.WHITE.getRGB());
|
||||
|
||||
@@ -31,12 +31,16 @@ public class GuiNumberInput extends GuiTextField {
|
||||
|
||||
@Override
|
||||
public void writeText(String text) {
|
||||
String textBefore = getText();
|
||||
int cursorPositionBefore = getCursorPosition();
|
||||
try {
|
||||
super.writeText(text);
|
||||
|
||||
double val;
|
||||
if(acceptFloats) {
|
||||
val = Double.valueOf(getText() + text);
|
||||
val = Double.valueOf(getText());
|
||||
} else {
|
||||
val = Integer.valueOf(getText() + text);
|
||||
val = Integer.valueOf(getText());
|
||||
}
|
||||
if(minimum != null && val < minimum) {
|
||||
setText(acceptFloats ? minimum.toString() : new Integer((int)Math.round(minimum)).toString());
|
||||
@@ -46,16 +50,42 @@ public class GuiNumberInput extends GuiTextField {
|
||||
setText(acceptFloats ? maximum.toString() : new Integer((int)Math.round(maximum)).toString());
|
||||
return;
|
||||
}
|
||||
super.writeText(text);
|
||||
|
||||
} catch(NumberFormatException e) {
|
||||
setText(textBefore);
|
||||
setCursorPosition(cursorPositionBefore);
|
||||
}
|
||||
}
|
||||
|
||||
public Double getValue(boolean nullable) {
|
||||
public int getIntValue() {
|
||||
try {
|
||||
return Integer.valueOf(getText());
|
||||
} catch(Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getIntValueNullable() {
|
||||
try {
|
||||
return Integer.valueOf(getText());
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public double getPreciseValue() {
|
||||
try {
|
||||
return Double.valueOf(getText());
|
||||
} catch(Exception e) {
|
||||
return nullable ? null : 0d;
|
||||
return 0d;
|
||||
}
|
||||
}
|
||||
|
||||
public Double getPreciseValueNullable() {
|
||||
try {
|
||||
return Double.valueOf(getText());
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -233,3 +233,4 @@ replaymod.gui.editkeyframe.zpos=Z Position
|
||||
replaymod.gui.editkeyframe.campitch=Camera Pitch
|
||||
replaymod.gui.editkeyframe.camyaw=Camera Yaw
|
||||
replaymod.gui.editkeyframe.camroll=Camera Roll
|
||||
replaymod.gui.editkeyframe.timelineposition=Timeline Position
|
||||
|
||||
Reference in New Issue
Block a user