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