Timelines now only jump when left-clicked, and jumping to a Marker is done via right-click

This commit is contained in:
CrushedPixel
2015-06-18 15:52:34 +02:00
parent cb6f3426f4
commit ceb40d2468

View File

@@ -9,6 +9,7 @@ import eu.crushedpixel.replaymod.holders.TimeKeyframe;
import eu.crushedpixel.replaymod.replay.ReplayHandler;
import eu.crushedpixel.replaymod.utils.MouseUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import org.lwjgl.util.Point;
import java.awt.*;
@@ -42,6 +43,8 @@ public class GuiKeyframeTimeline extends GuiTimeline {
@Override
public void mouseClick(Minecraft mc, int mouseX, int mouseY, int button) {
//left mouse button
if(button == 0) {
long time = getTimeAt(mouseX, mouseY);
if(time == -1) {
return;
@@ -77,6 +80,28 @@ public class GuiKeyframeTimeline extends GuiTimeline {
this.dragging = true;
}
this.clickTime = currentTime;
} else if(button == 1) {
if(markerKeyframes) {
long time = getTimeAt(mouseX, mouseY);
if(time == -1) {
return;
}
int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
MarkerKeyframe closest = null;
if(mouseY >= positionY + BORDER_TOP + 10 && markerKeyframes) {
closest = ReplayHandler.getClosestMarkerForRealTime((int) time, tolerance);
}
if(closest != null) {
//Jump to clicked Marker Keyframe
ReplayHandler.setLastPosition(closest.getPosition());
ReplayMod.replaySender.jumpToTime(closest.getRealTimestamp());
}
}
}
}
@Override
@@ -194,7 +219,9 @@ public class GuiKeyframeTimeline extends GuiTimeline {
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);
String markerName = marker.getName();
if(markerName == null) markerName = I18n.format("replaymod.gui.ingame.unnamedmarker");
ReplayMod.tooltipRenderer.drawTooltip(mouse.getX(), mouse.getY(), markerName, null, Color.WHITE);
drawn = true;
}