Implemented Left and Right Direction GuiArrowButton
Added quick way to switch between Keyframes of similar type in GuiEditKeyframe
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiArrowButton;
|
||||
import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
|
||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||
import eu.crushedpixel.replaymod.holders.Position;
|
||||
@@ -22,6 +23,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
private boolean initialized = false;
|
||||
|
||||
private GuiButton saveButton, cancelButton;
|
||||
private GuiArrowButton leftButton, rightButton;
|
||||
|
||||
private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
|
||||
private GuiNumberInput min, sec, ms;
|
||||
@@ -37,6 +39,8 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
private boolean save;
|
||||
private boolean posKeyframe;
|
||||
|
||||
private Keyframe previous, next;
|
||||
|
||||
private int w, w2, w3;
|
||||
private int totalWidth;
|
||||
private int left;
|
||||
@@ -46,6 +50,17 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
this.keyframeBackup = (Keyframe)keyframe.clone();
|
||||
this.posKeyframe = keyframe instanceof PositionKeyframe;
|
||||
|
||||
ReplayHandler.selectKeyframe(null);
|
||||
|
||||
if(posKeyframe) {
|
||||
previous = ReplayHandler.getPreviousPositionKeyframe(keyframe.getRealTimestamp()-1);
|
||||
next = ReplayHandler.getNextPositionKeyframe(keyframe.getRealTimestamp() + 1);
|
||||
} else {
|
||||
previous = ReplayHandler.getPreviousTimeKeyframe(keyframe.getRealTimestamp()-1);
|
||||
next = ReplayHandler.getNextTimeKeyframe(keyframe.getRealTimestamp()+1);
|
||||
}
|
||||
ReplayHandler.selectKeyframe(keyframe);
|
||||
|
||||
ReplayMod.replaySender.setReplaySpeed(0);
|
||||
}
|
||||
|
||||
@@ -59,9 +74,15 @@ 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"));
|
||||
|
||||
leftButton = new GuiArrowButton(GuiConstants.KEYFRAME_EDITOR_LEFT_BUTTON, 0, 0, "", GuiArrowButton.Direction.LEFT);
|
||||
rightButton = new GuiArrowButton(GuiConstants.KEYFRAME_EDITOR_RIGHT_BUTTON, 0, 0, "", GuiArrowButton.Direction.RIGHT);
|
||||
|
||||
leftButton.enabled = previous != null;
|
||||
rightButton.enabled = next != null;
|
||||
|
||||
//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);
|
||||
min = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_MIN_INPUT, fontRendererObj, 0, 0, 30, 0, 9, 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);
|
||||
|
||||
@@ -132,6 +153,13 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
buttonList.add(saveButton);
|
||||
buttonList.add(cancelButton);
|
||||
|
||||
leftButton.xPosition = 15;
|
||||
rightButton.xPosition = width-35;
|
||||
leftButton.yPosition = rightButton.yPosition = virtualY + ((virtualHeight - leftButton.height)/2);
|
||||
|
||||
buttonList.add(leftButton);
|
||||
buttonList.add(rightButton);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@@ -218,6 +246,12 @@ public class GuiEditKeyframe extends GuiScreen {
|
||||
} else if(button.id == GuiConstants.KEYFRAME_EDITOR_CANCEL_BUTTON) {
|
||||
save = false;
|
||||
mc.displayGuiScreen(null);
|
||||
} else if(button.id == GuiConstants.KEYFRAME_EDITOR_LEFT_BUTTON) {
|
||||
save = false;
|
||||
mc.displayGuiScreen(new GuiEditKeyframe(previous));
|
||||
} else if(button.id == GuiConstants.KEYFRAME_EDITOR_RIGHT_BUTTON) {
|
||||
save = false;
|
||||
mc.displayGuiScreen(new GuiEditKeyframe(next));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,13 @@ public class GuiArrowButton extends GuiButton {
|
||||
drawHorizontalLine(xPosition + width - height + i + 4, xPosition + width - i - 6, yPosition + (height / 3) + i + 2, Color.BLACK.getRGB());
|
||||
}
|
||||
} else if(dir == Direction.LEFT) {
|
||||
|
||||
for(int i = -1; i < Math.ceil(height / 2) - 5; i++) {
|
||||
drawVerticalLine(xPosition + height - ((height / 3) + i + 4), yPosition + width - height + i + 4, yPosition + width - i - 6, Color.BLACK.getRGB());
|
||||
}
|
||||
} else if(dir == Direction.RIGHT) {
|
||||
|
||||
for(int i = -1; i < Math.ceil(height / 2) - 5; i++) {
|
||||
drawVerticalLine(xPosition + (height / 3) + i + 2, yPosition + width - height + i + 4, yPosition + width - i - 6, Color.BLACK.getRGB());
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -237,54 +237,66 @@ public class ReplayHandler {
|
||||
|
||||
public static PositionKeyframe getPreviousPositionKeyframe(int realTime) {
|
||||
if(keyframes.isEmpty()) return null;
|
||||
PositionKeyframe backup = null;
|
||||
List<PositionKeyframe> found = new ArrayList<PositionKeyframe>();
|
||||
for(Keyframe kf : keyframes) {
|
||||
if(!(kf instanceof PositionKeyframe)) continue;
|
||||
if(kf.getRealTimestamp() < realTime) {
|
||||
found.add((PositionKeyframe) kf);
|
||||
found.add((PositionKeyframe)kf);
|
||||
} else if(kf.getRealTimestamp() == realTime) {
|
||||
backup = (PositionKeyframe)kf;
|
||||
}
|
||||
}
|
||||
|
||||
if(found.size() > 0)
|
||||
return found.get(found.size() - 1); //last element is nearest
|
||||
else return null;
|
||||
else return backup;
|
||||
}
|
||||
|
||||
public static PositionKeyframe getNextPositionKeyframe(int realTime) {
|
||||
if(keyframes.isEmpty()) return null;
|
||||
PositionKeyframe backup = null;
|
||||
for(Keyframe kf : keyframes) {
|
||||
if(!(kf instanceof PositionKeyframe)) continue;
|
||||
if(kf.getRealTimestamp() >= realTime) {
|
||||
return (PositionKeyframe) kf; //first found element is next
|
||||
if(kf.getRealTimestamp() > realTime) {
|
||||
return (PositionKeyframe)kf; //first found element is next
|
||||
} else if(kf.getRealTimestamp() == realTime) {
|
||||
backup = (PositionKeyframe)kf;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return backup;
|
||||
}
|
||||
|
||||
public static TimeKeyframe getPreviousTimeKeyframe(int realTime) {
|
||||
if(keyframes.isEmpty()) return null;
|
||||
TimeKeyframe backup = null;
|
||||
List<TimeKeyframe> found = new ArrayList<TimeKeyframe>();
|
||||
for(Keyframe kf : keyframes) {
|
||||
if(!(kf instanceof TimeKeyframe)) continue;
|
||||
if(kf.getRealTimestamp() < realTime) {
|
||||
found.add((TimeKeyframe) kf);
|
||||
found.add((TimeKeyframe)kf);
|
||||
} else if(kf.getRealTimestamp() == realTime) {
|
||||
backup = (TimeKeyframe)kf;
|
||||
}
|
||||
}
|
||||
|
||||
if(found.size() > 0)
|
||||
return found.get(found.size() - 1); //last element is nearest
|
||||
else return null;
|
||||
else return backup;
|
||||
}
|
||||
|
||||
public static TimeKeyframe getNextTimeKeyframe(int realTime) {
|
||||
if(keyframes.isEmpty()) return null;
|
||||
TimeKeyframe backup = null;
|
||||
for(Keyframe kf : keyframes) {
|
||||
if(!(kf instanceof TimeKeyframe)) continue;
|
||||
if(kf.getRealTimestamp() >= realTime) {
|
||||
if(kf.getRealTimestamp() > realTime) {
|
||||
return (TimeKeyframe) kf; //first found element is next
|
||||
} else if(kf.getRealTimestamp() == realTime) {
|
||||
backup = (TimeKeyframe)kf;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return backup;
|
||||
}
|
||||
|
||||
public static List<Keyframe> getKeyframes() {
|
||||
|
||||
Reference in New Issue
Block a user