Split GuiEditKeyframe into multiple classes depending on Keyframe type
This commit is contained in:
@@ -8,6 +8,7 @@ import eu.crushedpixel.replaymod.holders.Keyframe;
|
|||||||
import eu.crushedpixel.replaymod.holders.Marker;
|
import eu.crushedpixel.replaymod.holders.Marker;
|
||||||
import eu.crushedpixel.replaymod.holders.TimestampValue;
|
import eu.crushedpixel.replaymod.holders.TimestampValue;
|
||||||
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
|
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
|
||||||
|
import eu.crushedpixel.replaymod.interpolation.KeyframeValue;
|
||||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||||
import eu.crushedpixel.replaymod.utils.RoundUtils;
|
import eu.crushedpixel.replaymod.utils.RoundUtils;
|
||||||
@@ -23,80 +24,47 @@ import java.awt.*;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiEditKeyframe extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
public abstract class GuiEditKeyframe<T extends KeyframeValue> extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
||||||
|
|
||||||
private enum KeyframeType {
|
@SuppressWarnings("unchecked")
|
||||||
MARKER, POSITION, TIME, SPECTATOR;
|
public static GuiEditKeyframe create(Keyframe kf) {
|
||||||
|
if(kf.getValue() instanceof Marker) return new GuiEditKeyframeMarker(kf);
|
||||||
public static KeyframeType fromKeyframe(Keyframe kf) {
|
if(kf.getValue() instanceof TimestampValue) return new GuiEditKeyframeTime(kf);
|
||||||
if(kf.getValue() instanceof Marker) return MARKER;
|
if(kf.getValue() instanceof AdvancedPosition) return new GuiEditKeyframePosition(kf);
|
||||||
if(kf.getValue() instanceof TimestampValue) return TIME;
|
throw new UnsupportedOperationException("Keyframe type unknown: " + kf);
|
||||||
if(kf.getValue() instanceof AdvancedPosition) {
|
|
||||||
AdvancedPosition pos = (AdvancedPosition)kf.getValue();
|
|
||||||
if(pos.getSpectatedEntityID() == null) return POSITION;
|
|
||||||
else return SPECTATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean initialized = false;
|
protected boolean initialized = false;
|
||||||
|
|
||||||
private GuiAdvancedButton saveButton, cancelButton;
|
private GuiAdvancedButton saveButton, cancelButton;
|
||||||
private GuiArrowButton leftButton, rightButton;
|
private GuiArrowButton leftButton, rightButton;
|
||||||
|
|
||||||
|
protected GuiNumberInput min, sec, ms;
|
||||||
|
|
||||||
private GuiNumberInput kfMin, kfSec, kfMs;
|
protected ComposedElement inputs;
|
||||||
private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
|
|
||||||
private GuiNumberInput min, sec, ms;
|
|
||||||
|
|
||||||
private GuiAdvancedTextField markerNameInput;
|
|
||||||
|
|
||||||
private ComposedElement inputs;
|
|
||||||
private ComposedElement posInputs;
|
|
||||||
|
|
||||||
private int virtualHeight = 200;
|
private int virtualHeight = 200;
|
||||||
private int virtualY;
|
protected int virtualY;
|
||||||
|
|
||||||
private Keyframe keyframe;
|
protected Keyframe<T> keyframe;
|
||||||
private Keyframe keyframeBackup;
|
protected Keyframe<T> keyframeBackup;
|
||||||
private boolean save;
|
protected boolean save;
|
||||||
|
|
||||||
private KeyframeType keyframeType;
|
private Keyframe<?> previous, next;
|
||||||
|
|
||||||
private Keyframe previous, next;
|
protected int w2;
|
||||||
|
protected int w3;
|
||||||
|
protected int totalWidth;
|
||||||
|
protected int left;
|
||||||
|
|
||||||
private int w2;
|
protected String screenTitle;
|
||||||
private int w3;
|
|
||||||
private int totalWidth;
|
|
||||||
private int left;
|
|
||||||
|
|
||||||
private String screenTitle;
|
public GuiEditKeyframe(Keyframe<T> keyframe, KeyframeList<T> keyframes) {
|
||||||
|
|
||||||
public GuiEditKeyframe(Keyframe keyframe) {
|
|
||||||
this.keyframe = keyframe;
|
this.keyframe = keyframe;
|
||||||
this.keyframeBackup = keyframe.copy();
|
this.keyframeBackup = keyframe.copy();
|
||||||
this.keyframeType = KeyframeType.fromKeyframe(keyframe);
|
|
||||||
|
|
||||||
KeyframeList<AdvancedPosition> positionKeyframes = ReplayHandler.getPositionKeyframes();
|
previous = keyframes.getPreviousKeyframe(keyframe.getRealTimestamp(), false);
|
||||||
KeyframeList<TimestampValue> timeKeyframes = ReplayHandler.getTimeKeyframes();
|
next = keyframes.getNextKeyframe(keyframe.getRealTimestamp(), false);
|
||||||
KeyframeList<Marker> markerKeyframes = ReplayHandler.getMarkerKeyframes();
|
|
||||||
|
|
||||||
if(keyframeType == KeyframeType.POSITION) {
|
|
||||||
previous = positionKeyframes.getPreviousKeyframe(keyframe.getRealTimestamp(), false);
|
|
||||||
next = positionKeyframes.getNextKeyframe(keyframe.getRealTimestamp(), false);
|
|
||||||
|
|
||||||
screenTitle = I18n.format("replaymod.gui.editkeyframe.title.pos");
|
|
||||||
} else if(keyframeType == KeyframeType.TIME) {
|
|
||||||
previous = timeKeyframes.getPreviousKeyframe(keyframe.getRealTimestamp(), false);
|
|
||||||
next = timeKeyframes.getNextKeyframe(keyframe.getRealTimestamp(), false);
|
|
||||||
|
|
||||||
screenTitle = I18n.format("replaymod.gui.editkeyframe.title.time");
|
|
||||||
} else if(keyframeType == KeyframeType.MARKER) {
|
|
||||||
previous = markerKeyframes.getPreviousKeyframe(keyframe.getRealTimestamp(), false);
|
|
||||||
next = markerKeyframes.getNextKeyframe(keyframe.getRealTimestamp(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReplayMod.replaySender.setReplaySpeed(0);
|
ReplayMod.replaySender.setReplaySpeed(0);
|
||||||
}
|
}
|
||||||
@@ -128,7 +96,7 @@ public class GuiEditKeyframe extends GuiScreen implements GuiReplayOverlay.NoOve
|
|||||||
@Override
|
@Override
|
||||||
public void performAction() {
|
public void performAction() {
|
||||||
save = true;
|
save = true;
|
||||||
mc.displayGuiScreen(new GuiEditKeyframe(previous));
|
mc.displayGuiScreen(create(previous));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -136,7 +104,7 @@ public class GuiEditKeyframe extends GuiScreen implements GuiReplayOverlay.NoOve
|
|||||||
@Override
|
@Override
|
||||||
public void performAction() {
|
public void performAction() {
|
||||||
save = true;
|
save = true;
|
||||||
mc.displayGuiScreen(new GuiEditKeyframe(next));
|
mc.displayGuiScreen(create(next));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -152,38 +120,6 @@ public class GuiEditKeyframe extends GuiScreen implements GuiReplayOverlay.NoOve
|
|||||||
ms = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 35, 0d, 999d, (double)TimestampUtils.getMillisecondsFromTimestamp(timestamp), false, "", 1);
|
ms = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 35, 0d, 999d, (double)TimestampUtils.getMillisecondsFromTimestamp(timestamp), false, "", 1);
|
||||||
|
|
||||||
inputs = new ComposedElement(min, sec, ms, saveButton, cancelButton, leftButton, rightButton);
|
inputs = new ComposedElement(min, sec, ms, saveButton, cancelButton, leftButton, rightButton);
|
||||||
|
|
||||||
//Position/Virtual Time Input
|
|
||||||
if(keyframeType == KeyframeType.POSITION) {
|
|
||||||
AdvancedPosition pos = ((Keyframe<AdvancedPosition>) keyframe).getValue();
|
|
||||||
xCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getX()), true);
|
|
||||||
yCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getY()), true);
|
|
||||||
zCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getZ()), true);
|
|
||||||
yaw = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, -180d, 180d, RoundUtils.round2Decimals(pos.getYaw()), true);
|
|
||||||
pitch = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, -90d, 90d, RoundUtils.round2Decimals(pos.getPitch()), true);
|
|
||||||
roll = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getRoll()), true);
|
|
||||||
|
|
||||||
posInputs = new ComposedElement(xCoord, yCoord, zCoord, yaw, pitch, roll);
|
|
||||||
inputs.addPart(posInputs);
|
|
||||||
} else if(keyframeType == KeyframeType.TIME) {
|
|
||||||
int time = ((Keyframe<TimestampValue>) keyframe).getValue().asInt();
|
|
||||||
|
|
||||||
kfMin = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 30, 0d, null, (double)TimestampUtils.timestampToWholeMinutes(time), false, "", 1);
|
|
||||||
kfSec = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 25, 0d, 59d, (double)TimestampUtils.getSecondsFromTimestamp(time), false, "", 1);
|
|
||||||
kfMs = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 35, 0d, 999d, (double)TimestampUtils.getMillisecondsFromTimestamp(time), false, "", 1);
|
|
||||||
|
|
||||||
inputs.addPart(kfMin);
|
|
||||||
inputs.addPart(kfSec);
|
|
||||||
inputs.addPart(kfMs);
|
|
||||||
} else if(keyframeType == KeyframeType.MARKER) {
|
|
||||||
String name = ((Keyframe<Marker>)keyframe).getValue().getName();
|
|
||||||
if(name == null) name = "";
|
|
||||||
markerNameInput = new GuiAdvancedTextField(fontRendererObj, 0, 0, 200, 20);
|
|
||||||
markerNameInput.hint = I18n.format("replaymod.gui.editkeyframe.markername");
|
|
||||||
markerNameInput.setText(name);
|
|
||||||
|
|
||||||
inputs.addPart(markerNameInput);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w3 = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10+
|
w3 = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10+
|
||||||
@@ -201,38 +137,6 @@ public class GuiEditKeyframe extends GuiScreen implements GuiReplayOverlay.NoOve
|
|||||||
|
|
||||||
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-65;
|
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-65;
|
||||||
|
|
||||||
if(keyframeType == KeyframeType.POSITION) {
|
|
||||||
int 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")),
|
|
||||||
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(GuiElement input : posInputs.getParts()) {
|
|
||||||
if(input instanceof GuiTextField) {
|
|
||||||
GuiTextField textField = (GuiTextField)input;
|
|
||||||
textField.xPosition = i < 3 ? x : left+totalWidth-100;
|
|
||||||
textField.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(keyframeType == KeyframeType.TIME) {
|
|
||||||
kfMin.xPosition = min.xPosition;
|
|
||||||
kfSec.xPosition = sec.xPosition;
|
|
||||||
kfMs.xPosition = ms.xPosition;
|
|
||||||
|
|
||||||
kfMin.yPosition = kfSec.yPosition = kfMs.yPosition = min.yPosition - 10 - 20;
|
|
||||||
} else if(keyframeType == KeyframeType.MARKER) {
|
|
||||||
markerNameInput.xPosition = width/2 - 100;
|
|
||||||
markerNameInput.yPosition = height/2-10;
|
|
||||||
}
|
|
||||||
|
|
||||||
saveButton.yPosition = cancelButton.yPosition = virtualY + virtualHeight - 20 - 5;
|
saveButton.yPosition = cancelButton.yPosition = virtualY + virtualHeight - 20 - 5;
|
||||||
saveButton.xPosition = this.width - 100 - 5 - 10;
|
saveButton.xPosition = this.width - 100 - 5 - 10;
|
||||||
cancelButton.xPosition = saveButton.xPosition - 100 - 5;
|
cancelButton.xPosition = saveButton.xPosition - 100 - 5;
|
||||||
@@ -256,26 +160,9 @@ public class GuiEditKeyframe extends GuiScreen implements GuiReplayOverlay.NoOve
|
|||||||
@Override
|
@Override
|
||||||
public void onGuiClosed() {
|
public void onGuiClosed() {
|
||||||
if(!save) {
|
if(!save) {
|
||||||
if(keyframeType != KeyframeType.MARKER) {
|
|
||||||
ReplayHandler.removeKeyframe(keyframe);
|
|
||||||
ReplayHandler.addKeyframe(keyframeBackup);
|
|
||||||
} else {
|
|
||||||
ReplayHandler.getMarkerKeyframes().remove(keyframe);
|
|
||||||
ReplayHandler.getMarkerKeyframes().add(keyframeBackup);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReplayHandler.selectKeyframe(keyframeBackup);
|
ReplayHandler.selectKeyframe(keyframeBackup);
|
||||||
} else {
|
} else {
|
||||||
keyframe.setRealTimestamp(TimestampUtils.calculateTimestamp(min.getIntValue(), sec.getIntValue(), ms.getIntValue()));
|
keyframe.setRealTimestamp(TimestampUtils.calculateTimestamp(min.getIntValue(), sec.getIntValue(), ms.getIntValue()));
|
||||||
if(keyframeType == KeyframeType.POSITION) {
|
|
||||||
((Keyframe<AdvancedPosition>) keyframe).setValue(new AdvancedPosition(xCoord.getPreciseValue(), yCoord.getPreciseValue(),
|
|
||||||
zCoord.getPreciseValue(), new Float(pitch.getPreciseValue()), (float) yaw.getPreciseValue(),
|
|
||||||
(float) roll.getPreciseValue(), null));
|
|
||||||
} else if(keyframeType == KeyframeType.TIME) {
|
|
||||||
((Keyframe<TimestampValue>)keyframe).setValue(new TimestampValue(TimestampUtils.calculateTimestamp(kfMin.getIntValue(), kfSec.getIntValue(), kfMs.getIntValue())));
|
|
||||||
} else if(keyframeType == KeyframeType.MARKER) {
|
|
||||||
((Keyframe<Marker>)keyframe).getValue().setName(markerNameInput.getText().trim());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ReplayHandler.fireKeyframesModifyEvent();
|
ReplayHandler.fireKeyframesModifyEvent();
|
||||||
Keyboard.enableRepeatEvents(false);
|
Keyboard.enableRepeatEvents(false);
|
||||||
@@ -325,22 +212,182 @@ public class GuiEditKeyframe extends GuiScreen implements GuiReplayOverlay.NoOve
|
|||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.seconds"), sec.xPosition+sec.width+5, sec.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());
|
drawString(fontRendererObj, I18n.format("replaymod.gui.milliseconds"), ms.xPosition + ms.width + 5, ms.yPosition + 7, Color.WHITE.getRGB());
|
||||||
|
|
||||||
if(keyframeType == KeyframeType.POSITION) {
|
drawScreen0();
|
||||||
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.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());
|
|
||||||
} else if(keyframeType == KeyframeType.TIME) {
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.timestamp")+":", (width-w3)/2, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.minutes"), kfMin.xPosition + kfMin.width + 5, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.seconds"), kfSec.xPosition+kfSec.width+5, kfSec.yPosition+7, Color.WHITE.getRGB());
|
|
||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.milliseconds"), kfMs.xPosition+kfMs.width+5, kfMs.yPosition+7, Color.WHITE.getRGB());
|
|
||||||
}
|
|
||||||
|
|
||||||
inputs.draw(mc, mouseX, mouseY);
|
inputs.draw(mc, mouseX, mouseY);
|
||||||
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void drawScreen0() {}
|
||||||
|
|
||||||
|
private static class GuiEditKeyframeMarker extends GuiEditKeyframe<Marker> {
|
||||||
|
private GuiAdvancedTextField markerNameInput;
|
||||||
|
|
||||||
|
public GuiEditKeyframeMarker(Keyframe<Marker> keyframe) {
|
||||||
|
super(keyframe, ReplayHandler.getMarkerKeyframes());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
if (!initialized) {
|
||||||
|
String name = keyframe.getValue().getName();
|
||||||
|
if (name == null) name = "";
|
||||||
|
markerNameInput = new GuiAdvancedTextField(fontRendererObj, 0, 0, 200, 20);
|
||||||
|
markerNameInput.hint = I18n.format("replaymod.gui.editkeyframe.markername");
|
||||||
|
markerNameInput.setText(name);
|
||||||
|
|
||||||
|
inputs.addPart(markerNameInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
markerNameInput.xPosition = width/2 - 100;
|
||||||
|
markerNameInput.yPosition = height/2-10;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuiClosed() {
|
||||||
|
if (!save) {
|
||||||
|
ReplayHandler.getMarkerKeyframes().remove(keyframe);
|
||||||
|
ReplayHandler.getMarkerKeyframes().add(keyframeBackup);
|
||||||
|
} else {
|
||||||
|
keyframe.getValue().setName(markerNameInput.getText().trim());
|
||||||
|
}
|
||||||
|
super.onGuiClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class GuiEditKeyframeTime extends GuiEditKeyframe<TimestampValue> {
|
||||||
|
private GuiNumberInput kfMin, kfSec, kfMs;
|
||||||
|
|
||||||
|
public GuiEditKeyframeTime(Keyframe<TimestampValue> keyframe) {
|
||||||
|
super(keyframe, ReplayHandler.getTimeKeyframes());
|
||||||
|
screenTitle = I18n.format("replaymod.gui.editkeyframe.title.time");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
if (!initialized) {
|
||||||
|
int time = keyframe.getValue().asInt();
|
||||||
|
|
||||||
|
kfMin = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 30, 0d, null, (double)TimestampUtils.timestampToWholeMinutes(time), false, "", 1);
|
||||||
|
kfSec = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 25, 0d, 59d, (double)TimestampUtils.getSecondsFromTimestamp(time), false, "", 1);
|
||||||
|
kfMs = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 35, 0d, 999d, (double)TimestampUtils.getMillisecondsFromTimestamp(time), false, "", 1);
|
||||||
|
|
||||||
|
inputs.addPart(kfMin);
|
||||||
|
inputs.addPart(kfSec);
|
||||||
|
inputs.addPart(kfMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
kfMin.xPosition = min.xPosition;
|
||||||
|
kfSec.xPosition = sec.xPosition;
|
||||||
|
kfMs.xPosition = ms.xPosition;
|
||||||
|
|
||||||
|
kfMin.yPosition = kfSec.yPosition = kfMs.yPosition = min.yPosition - 10 - 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawScreen0() {
|
||||||
|
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.timestamp")+":", (width-w3)/2, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
||||||
|
drawString(fontRendererObj, I18n.format("replaymod.gui.minutes"), kfMin.xPosition + kfMin.width + 5, kfMin.yPosition + 7, Color.WHITE.getRGB());
|
||||||
|
drawString(fontRendererObj, I18n.format("replaymod.gui.seconds"), kfSec.xPosition + kfSec.width + 5, kfSec.yPosition + 7, Color.WHITE.getRGB());
|
||||||
|
drawString(fontRendererObj, I18n.format("replaymod.gui.milliseconds"), kfMs.xPosition + kfMs.width + 5, kfMs.yPosition + 7, Color.WHITE.getRGB());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuiClosed() {
|
||||||
|
if (!save) {
|
||||||
|
ReplayHandler.removeKeyframe(keyframe);
|
||||||
|
ReplayHandler.addKeyframe(keyframeBackup);
|
||||||
|
} else {
|
||||||
|
keyframe.setValue(new TimestampValue(TimestampUtils.calculateTimestamp(
|
||||||
|
kfMin.getIntValue(), kfSec.getIntValue(), kfMs.getIntValue())));
|
||||||
|
}
|
||||||
|
super.onGuiClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class GuiEditKeyframePosition extends GuiEditKeyframe<AdvancedPosition> {
|
||||||
|
private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
|
||||||
|
private ComposedElement posInputs;
|
||||||
|
|
||||||
|
public GuiEditKeyframePosition(Keyframe<AdvancedPosition> keyframe) {
|
||||||
|
super(keyframe, ReplayHandler.getPositionKeyframes());
|
||||||
|
screenTitle = I18n.format("replaymod.gui.editkeyframe.title.pos");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
if (keyframe.getValue().getSpectatedEntityID() != null) {
|
||||||
|
super.initGui();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!initialized) {
|
||||||
|
AdvancedPosition pos = keyframe.getValue();
|
||||||
|
xCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getX()), true);
|
||||||
|
yCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getY()), true);
|
||||||
|
zCoord = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getZ()), true);
|
||||||
|
yaw = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, -180d, 180d, RoundUtils.round2Decimals(pos.getYaw()), true);
|
||||||
|
pitch = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, -90d, 90d, RoundUtils.round2Decimals(pos.getPitch()), true);
|
||||||
|
roll = new GuiDraggingNumberInput(fontRendererObj, 0, 0, 100, null, null, RoundUtils.round2Decimals(pos.getRoll()), true);
|
||||||
|
|
||||||
|
posInputs = new ComposedElement(xCoord, yCoord, zCoord, yaw, pitch, roll);
|
||||||
|
inputs.addPart(posInputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
int 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")),
|
||||||
|
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(GuiElement input : posInputs.getParts()) {
|
||||||
|
if(input instanceof GuiTextField) {
|
||||||
|
GuiTextField textField = (GuiTextField)input;
|
||||||
|
textField.xPosition = i < 3 ? x : left+totalWidth-100;
|
||||||
|
textField.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuiClosed() {
|
||||||
|
if (!save) {
|
||||||
|
ReplayHandler.removeKeyframe(keyframe);
|
||||||
|
ReplayHandler.addKeyframe(keyframeBackup);
|
||||||
|
} else {
|
||||||
|
keyframe.setValue(new AdvancedPosition(xCoord.getPreciseValue(), yCoord.getPreciseValue(),
|
||||||
|
zCoord.getPreciseValue(), new Float(pitch.getPreciseValue()), (float) yaw.getPreciseValue(),
|
||||||
|
(float) roll.getPreciseValue(), null));
|
||||||
|
}
|
||||||
|
super.onGuiClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawScreen0() {
|
||||||
|
if (keyframe.getValue().getSpectatedEntityID() != null) return;
|
||||||
|
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.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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class GuiKeyframeTimeline extends GuiTimeline {
|
|||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if(closest != null) {
|
if(closest != null) {
|
||||||
if(currentTime - clickTime < 500) { // if double clicked then open GUI instead
|
if(currentTime - clickTime < 500) { // if double clicked then open GUI instead
|
||||||
mc.displayGuiScreen(new GuiEditKeyframe(closest));
|
mc.displayGuiScreen(GuiEditKeyframe.create(closest));
|
||||||
this.clickedKeyFrame = null;
|
this.clickedKeyFrame = null;
|
||||||
} else {
|
} else {
|
||||||
this.clickedKeyFrame = closest;
|
this.clickedKeyFrame = closest;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class GuiMarkerTimeline extends GuiTimeline {
|
|||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
if(closest != null) {
|
if(closest != null) {
|
||||||
if(currentTime - clickTime < 500) { // if double clicked then open GUI instead
|
if(currentTime - clickTime < 500) { // if double clicked then open GUI instead
|
||||||
mc.displayGuiScreen(new GuiEditKeyframe(closest));
|
mc.displayGuiScreen(GuiEditKeyframe.create(closest));
|
||||||
this.clickedKeyFrame = null;
|
this.clickedKeyFrame = null;
|
||||||
} else {
|
} else {
|
||||||
this.clickedKeyFrame = closest;
|
this.clickedKeyFrame = closest;
|
||||||
|
|||||||
Reference in New Issue
Block a user