Marker names are now being displayed when hovering over them
Marker names are now editable in GuiEditKeyframe
This commit is contained in:
@@ -85,6 +85,7 @@ public class GuiConstants {
|
|||||||
public static final int KEYFRAME_EDITOR_REAL_MIN_INPUT = 6013;
|
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_SEC_INPUT = 6014;
|
||||||
public static final int KEYFRAME_EDITOR_REAL_MS_INPUT = 6015;
|
public static final int KEYFRAME_EDITOR_REAL_MS_INPUT = 6015;
|
||||||
|
public static final int KEYFRAME_EDITOR_MARKER_NAME_INPUT = 6016;
|
||||||
|
|
||||||
public static final int PLAYER_OVERVIEW_HIDE_ALL = 1010;
|
public static final int PLAYER_OVERVIEW_HIDE_ALL = 1010;
|
||||||
public static final int PLAYER_OVERVIEW_SHOW_ALL = 0101;
|
public static final int PLAYER_OVERVIEW_SHOW_ALL = 0101;
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ package eu.crushedpixel.replaymod.gui;
|
|||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiArrowButton;
|
import eu.crushedpixel.replaymod.gui.elements.GuiArrowButton;
|
||||||
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.*;
|
||||||
import eu.crushedpixel.replaymod.holders.Position;
|
|
||||||
import eu.crushedpixel.replaymod.holders.PositionKeyframe;
|
|
||||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||||
import eu.crushedpixel.replaymod.utils.TimestampUtils;
|
import eu.crushedpixel.replaymod.utils.TimestampUtils;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
@@ -28,8 +27,10 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
|
private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
|
||||||
private GuiNumberInput min, sec, ms;
|
private GuiNumberInput min, sec, ms;
|
||||||
|
|
||||||
private List<GuiNumberInput> inputs = new ArrayList<GuiNumberInput>();
|
private GuiTextField markerNameInput;
|
||||||
private List<GuiNumberInput> posInputs = new ArrayList<GuiNumberInput>();
|
|
||||||
|
private List<GuiTextField> inputs = new ArrayList<GuiTextField>();
|
||||||
|
private List<GuiTextField> posInputs = new ArrayList<GuiTextField>();
|
||||||
|
|
||||||
private int virtualHeight = 200;
|
private int virtualHeight = 200;
|
||||||
private int virtualY;
|
private int virtualY;
|
||||||
@@ -38,6 +39,8 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
private Keyframe keyframeBackup;
|
private Keyframe keyframeBackup;
|
||||||
private boolean save;
|
private boolean save;
|
||||||
private boolean posKeyframe;
|
private boolean posKeyframe;
|
||||||
|
private boolean timeKeyframe;
|
||||||
|
private boolean markerKeyframe;
|
||||||
|
|
||||||
private Keyframe previous, next;
|
private Keyframe previous, next;
|
||||||
|
|
||||||
@@ -49,16 +52,22 @@ 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;
|
||||||
|
this.timeKeyframe = keyframe instanceof TimeKeyframe;
|
||||||
|
this.markerKeyframe = keyframe instanceof MarkerKeyframe;
|
||||||
|
|
||||||
ReplayHandler.selectKeyframe(null);
|
ReplayHandler.selectKeyframe(null);
|
||||||
|
|
||||||
if(posKeyframe) {
|
if(posKeyframe) {
|
||||||
previous = ReplayHandler.getPreviousPositionKeyframe(keyframe.getRealTimestamp()-1);
|
previous = ReplayHandler.getPreviousPositionKeyframe(keyframe.getRealTimestamp()-1);
|
||||||
next = ReplayHandler.getNextPositionKeyframe(keyframe.getRealTimestamp() + 1);
|
next = ReplayHandler.getNextPositionKeyframe(keyframe.getRealTimestamp() + 1);
|
||||||
} else {
|
} else if(timeKeyframe) {
|
||||||
previous = ReplayHandler.getPreviousTimeKeyframe(keyframe.getRealTimestamp()-1);
|
previous = ReplayHandler.getPreviousTimeKeyframe(keyframe.getRealTimestamp()-1);
|
||||||
next = ReplayHandler.getNextTimeKeyframe(keyframe.getRealTimestamp()+1);
|
next = ReplayHandler.getNextTimeKeyframe(keyframe.getRealTimestamp()+1);
|
||||||
|
} else if(markerKeyframe) {
|
||||||
|
previous = ReplayHandler.getPreviousMarkerKeyframe(keyframe.getRealTimestamp()-1);
|
||||||
|
next = ReplayHandler.getNextMarkerKeyframe(keyframe.getRealTimestamp()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplayHandler.selectKeyframe(keyframe);
|
ReplayHandler.selectKeyframe(keyframe);
|
||||||
|
|
||||||
ReplayMod.replaySender.setReplaySpeed(0);
|
ReplayMod.replaySender.setReplaySpeed(0);
|
||||||
@@ -108,6 +117,10 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
posInputs.add(roll);
|
posInputs.add(roll);
|
||||||
|
|
||||||
inputs.addAll(posInputs);
|
inputs.addAll(posInputs);
|
||||||
|
} else if(markerKeyframe) {
|
||||||
|
markerNameInput = new GuiTextField(GuiConstants.KEYFRAME_REPOSTORY_NAME_INPUT, fontRendererObj, 0, 0, 300, 20);
|
||||||
|
markerNameInput.setText(((MarkerKeyframe)keyframe).getName());
|
||||||
|
inputs.add(markerNameInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +135,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
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 +
|
ms.xPosition = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.timelineposition")+":")+10 + l +
|
||||||
min.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes")) + 5
|
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-65;
|
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-65;
|
||||||
|
|
||||||
@@ -139,11 +152,14 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
|
|
||||||
int x = w + left + 5;
|
int x = w + left + 5;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(GuiNumberInput input : posInputs) {
|
for(GuiTextField input : posInputs) {
|
||||||
input.xPosition = i < 3 ? x : left+totalWidth-100;
|
input.xPosition = i < 3 ? x : left+totalWidth-100;
|
||||||
input.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30;
|
input.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
} else if(markerKeyframe) {
|
||||||
|
markerNameInput.xPosition = (width-markerNameInput.width)/2;
|
||||||
|
markerNameInput.yPosition = virtualY + (virtualHeight-markerNameInput.height)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveButton.yPosition = cancelButton.yPosition = virtualY + virtualHeight - 20 - 5;
|
saveButton.yPosition = cancelButton.yPosition = virtualY + virtualHeight - 20 - 5;
|
||||||
@@ -175,6 +191,8 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
((PositionKeyframe)keyframe).setPosition(new Position(xCoord.getPreciseValue(), yCoord.getPreciseValue(),
|
((PositionKeyframe)keyframe).setPosition(new Position(xCoord.getPreciseValue(), yCoord.getPreciseValue(),
|
||||||
zCoord.getPreciseValue(), new Float(pitch.getPreciseValue()), (float)yaw.getPreciseValue(),
|
zCoord.getPreciseValue(), new Float(pitch.getPreciseValue()), (float)yaw.getPreciseValue(),
|
||||||
(float)roll.getPreciseValue()));
|
(float)roll.getPreciseValue()));
|
||||||
|
} else if(markerKeyframe) {
|
||||||
|
((MarkerKeyframe)keyframe).setName(markerNameInput.getText().trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Keyboard.enableRepeatEvents(false);
|
Keyboard.enableRepeatEvents(false);
|
||||||
@@ -182,7 +200,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||||
for(GuiNumberInput input : inputs) {
|
for(GuiTextField input : inputs) {
|
||||||
if(input != null) input.textboxKeyTyped(typedChar, keyCode);
|
if(input != null) input.textboxKeyTyped(typedChar, keyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +212,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||||
for(GuiNumberInput input : inputs) {
|
for(GuiTextField input : inputs) {
|
||||||
if(input != null) input.mouseClicked(mouseX, mouseY, mouseButton);
|
if(input != null) input.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
}
|
}
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
@@ -202,7 +220,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
for(GuiNumberInput input : inputs) {
|
for(GuiTextField input : inputs) {
|
||||||
if(input != null) input.updateCursorCounter();
|
if(input != null) input.updateCursorCounter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -226,7 +244,7 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camroll"), left+totalWidth-100-5-w2, virtualY + 87, 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) {
|
for(GuiTextField input : inputs) {
|
||||||
if(input != null) input.drawTextBox();
|
if(input != null) input.drawTextBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
|||||||
import eu.crushedpixel.replaymod.holders.PositionKeyframe;
|
import eu.crushedpixel.replaymod.holders.PositionKeyframe;
|
||||||
import eu.crushedpixel.replaymod.holders.TimeKeyframe;
|
import eu.crushedpixel.replaymod.holders.TimeKeyframe;
|
||||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||||
|
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import org.lwjgl.util.Point;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
public class GuiKeyframeTimeline extends GuiTimeline {
|
public class GuiKeyframeTimeline extends GuiTimeline {
|
||||||
@@ -177,6 +180,32 @@ public class GuiKeyframeTimeline extends GuiTimeline {
|
|||||||
return (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
return (int) (positionX + BORDER_LEFT + fractionOfSegment * bodyWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawOverlay(Minecraft mc, int mouseX, int mouseY) {
|
||||||
|
boolean drawn = false;
|
||||||
|
|
||||||
|
int bodyWidth = width - BORDER_LEFT - BORDER_RIGHT;
|
||||||
|
|
||||||
|
long leftTime = Math.round(timeStart * timelineLength);
|
||||||
|
double segmentLength = timelineLength * zoom;
|
||||||
|
|
||||||
|
|
||||||
|
for(MarkerKeyframe marker : ReplayHandler.getMarkers()) {
|
||||||
|
int keyframeX = getKeyframeX(marker.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||||
|
|
||||||
|
if(MouseUtils.isMouseWithinBounds(keyframeX - 2, this.positionY + BORDER_TOP + 10 + 1, 5, 5)) {
|
||||||
|
Point mouse = MouseUtils.getMousePos();
|
||||||
|
ReplayMod.tooltipRenderer.drawTooltip(mouse.getX(), mouse.getY(), marker.getName(), null, Color.WHITE.getRGB());
|
||||||
|
|
||||||
|
drawn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!drawn) {
|
||||||
|
super.drawOverlay(mc, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void drawKeyframe(Keyframe kf, int bodyWidth, long leftTime, long rightTime, double segmentLength) {
|
private void drawKeyframe(Keyframe kf, int bodyWidth, long leftTime, long rightTime, double segmentLength) {
|
||||||
if (kf.getRealTimestamp() <= rightTime && kf.getRealTimestamp() >= leftTime) {
|
if (kf.getRealTimestamp() <= rightTime && kf.getRealTimestamp() >= leftTime) {
|
||||||
int textureX;
|
int textureX;
|
||||||
|
|||||||
@@ -22,11 +22,14 @@ public class MarkerKeyframe extends Keyframe {
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o2) {
|
public boolean equals(Object o2) {
|
||||||
if(o2 == null) return false;
|
if(o2 == null) return false;
|
||||||
|
|||||||
@@ -380,6 +380,38 @@ public class ReplayHandler {
|
|||||||
return backup;
|
return backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MarkerKeyframe getPreviousMarkerKeyframe(int realTime) {
|
||||||
|
if(keyframes.isEmpty()) return null;
|
||||||
|
MarkerKeyframe backup = null;
|
||||||
|
List<MarkerKeyframe> found = new ArrayList<MarkerKeyframe>();
|
||||||
|
for(Keyframe kf : keyframes) {
|
||||||
|
if(!(kf instanceof MarkerKeyframe)) continue;
|
||||||
|
if(kf.getRealTimestamp() < realTime) {
|
||||||
|
found.add((MarkerKeyframe)kf);
|
||||||
|
} else if(kf.getRealTimestamp() == realTime) {
|
||||||
|
backup = (MarkerKeyframe)kf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(found.size() > 0)
|
||||||
|
return found.get(found.size() - 1); //last element is nearest
|
||||||
|
else return backup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MarkerKeyframe getNextMarkerKeyframe(int realTime) {
|
||||||
|
if(keyframes.isEmpty()) return null;
|
||||||
|
MarkerKeyframe backup = null;
|
||||||
|
for(Keyframe kf : keyframes) {
|
||||||
|
if(!(kf instanceof MarkerKeyframe)) continue;
|
||||||
|
if(kf.getRealTimestamp() > realTime) {
|
||||||
|
return (MarkerKeyframe) kf; //first found element is next
|
||||||
|
} else if(kf.getRealTimestamp() == realTime) {
|
||||||
|
backup = (MarkerKeyframe)kf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return backup;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Keyframe> getKeyframes() {
|
public static List<Keyframe> getKeyframes() {
|
||||||
return new ArrayList<Keyframe>(keyframes);
|
return new ArrayList<Keyframe>(keyframes);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user