Removed MarkerKeyframe and replaced it with generic type of Keyframe using the new Marker POJO
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.elements.timelines;
|
package eu.crushedpixel.replaymod.gui.elements.timelines;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||||
|
import eu.crushedpixel.replaymod.holders.Marker;
|
||||||
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 net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -14,7 +15,7 @@ public class GuiMarkerTimeline extends GuiTimeline {
|
|||||||
private static final int KEYFRAME_MARKER_X = 109;
|
private static final int KEYFRAME_MARKER_X = 109;
|
||||||
private static final int KEYFRAME_MARKER_Y = 20;
|
private static final int KEYFRAME_MARKER_Y = 20;
|
||||||
|
|
||||||
private MarkerKeyframe clickedKeyFrame;
|
private Keyframe<Marker> clickedKeyFrame;
|
||||||
private long clickTime;
|
private long clickTime;
|
||||||
private boolean dragging;
|
private boolean dragging;
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ public class GuiMarkerTimeline extends GuiTimeline {
|
|||||||
|
|
||||||
int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
||||||
|
|
||||||
MarkerKeyframe closest = null;
|
Keyframe<Marker> closest = null;
|
||||||
if(mouseY >= positionY + BORDER_TOP + 10) {
|
if(mouseY >= positionY + BORDER_TOP + 10) {
|
||||||
closest = ReplayHandler.getClosestMarkerForRealTime((int) time, tolerance);
|
closest = ReplayHandler.getClosestMarkerForRealTime((int) time, tolerance);
|
||||||
}
|
}
|
||||||
@@ -71,14 +72,14 @@ public class GuiMarkerTimeline extends GuiTimeline {
|
|||||||
|
|
||||||
int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
int tolerance = (int) (2 * Math.round(zoom * timelineLength / width));
|
||||||
|
|
||||||
MarkerKeyframe closest = null;
|
Keyframe<Marker> closest = null;
|
||||||
if(mouseY >= positionY + BORDER_TOP + 10) {
|
if(mouseY >= positionY + BORDER_TOP + 10) {
|
||||||
closest = ReplayHandler.getClosestMarkerForRealTime((int) time, tolerance);
|
closest = ReplayHandler.getClosestMarkerForRealTime((int) time, tolerance);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(closest != null) {
|
if(closest != null) {
|
||||||
//Jump to clicked Marker Keyframe
|
//Jump to clicked Marker Keyframe
|
||||||
ReplayHandler.setLastPosition(closest.getPosition());
|
ReplayHandler.setLastPosition(closest.getValue().getPosition());
|
||||||
ReplayMod.replaySender.jumpToTime(closest.getRealTimestamp());
|
ReplayMod.replaySender.jumpToTime(closest.getRealTimestamp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +124,7 @@ public class GuiMarkerTimeline extends GuiTimeline {
|
|||||||
drawTimelineCursor(leftTime, rightTime, bodyWidth);
|
drawTimelineCursor(leftTime, rightTime, bodyWidth);
|
||||||
|
|
||||||
//Draw Keyframe logos
|
//Draw Keyframe logos
|
||||||
for (MarkerKeyframe kf : ReplayHandler.getMarkers()) {
|
for(Keyframe<Marker> kf : ReplayHandler.getMarkers()) {
|
||||||
if (kf != null && !kf.equals(ReplayHandler.getSelectedMarkerKeyframe()))
|
if (kf != null && !kf.equals(ReplayHandler.getSelectedMarkerKeyframe()))
|
||||||
drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
|
drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
|
||||||
}
|
}
|
||||||
@@ -148,12 +149,12 @@ public class GuiMarkerTimeline extends GuiTimeline {
|
|||||||
long leftTime = Math.round(timeStart * timelineLength);
|
long leftTime = Math.round(timeStart * timelineLength);
|
||||||
double segmentLength = timelineLength * zoom;
|
double segmentLength = timelineLength * zoom;
|
||||||
|
|
||||||
for(MarkerKeyframe marker : ReplayHandler.getMarkers()) {
|
for(Keyframe<Marker> marker : ReplayHandler.getMarkers()) {
|
||||||
int keyframeX = getKeyframeX(marker.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
int keyframeX = getKeyframeX(marker.getRealTimestamp(), leftTime, bodyWidth, segmentLength);
|
||||||
|
|
||||||
if(MouseUtils.isMouseWithinBounds(keyframeX - 2, this.positionY + BORDER_TOP + 10 + 1, 5, 5)) {
|
if(MouseUtils.isMouseWithinBounds(keyframeX - 2, this.positionY + BORDER_TOP + 10 + 1, 5, 5)) {
|
||||||
Point mouse = MouseUtils.getMousePos();
|
Point mouse = MouseUtils.getMousePos();
|
||||||
String markerName = marker.getName();
|
String markerName = marker.getValue().getName();
|
||||||
if(markerName == null) markerName = I18n.format("replaymod.gui.ingame.unnamedmarker");
|
if(markerName == null) markerName = I18n.format("replaymod.gui.ingame.unnamedmarker");
|
||||||
ReplayMod.tooltipRenderer.drawTooltip(mouse.getX(), mouse.getY(), markerName, null, Color.WHITE);
|
ReplayMod.tooltipRenderer.drawTooltip(mouse.getX(), mouse.getY(), markerName, null, Color.WHITE);
|
||||||
|
|
||||||
@@ -166,7 +167,7 @@ public class GuiMarkerTimeline extends GuiTimeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawKeyframe(MarkerKeyframe 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 = KEYFRAME_MARKER_X;
|
int textureX = KEYFRAME_MARKER_X;
|
||||||
int textureY = KEYFRAME_MARKER_Y;
|
int textureY = KEYFRAME_MARKER_Y;
|
||||||
|
|||||||
20
src/main/java/eu/crushedpixel/replaymod/holders/Marker.java
Normal file
20
src/main/java/eu/crushedpixel/replaymod/holders/Marker.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
|
import eu.crushedpixel.replaymod.interpolation.KeyframeValue;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Marker implements KeyframeValue {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private AdvancedPosition position;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KeyframeValue newInstance() {
|
||||||
|
return new Marker();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class MarkerKeyframe {
|
|
||||||
|
|
||||||
private int realTimestamp;
|
|
||||||
private AdvancedPosition position;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,8 @@ package eu.crushedpixel.replaymod.recording;
|
|||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||||
|
import eu.crushedpixel.replaymod.holders.Marker;
|
||||||
import eu.crushedpixel.replaymod.holders.PacketData;
|
import eu.crushedpixel.replaymod.holders.PacketData;
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||||
@@ -35,7 +36,7 @@ public abstract class DataListener extends ChannelInboundHandlerAdapter {
|
|||||||
protected boolean alive = true;
|
protected boolean alive = true;
|
||||||
protected DataWriter dataWriter;
|
protected DataWriter dataWriter;
|
||||||
protected Set<String> players = new HashSet<String>();
|
protected Set<String> players = new HashSet<String>();
|
||||||
protected Set<MarkerKeyframe> markers = new HashSet<MarkerKeyframe>();
|
protected Set<Keyframe<Marker>> markers = new HashSet<Keyframe<Marker>>();
|
||||||
private boolean singleplayer;
|
private boolean singleplayer;
|
||||||
|
|
||||||
private int saveState = 0; //0: Idle, 1: Saving, 2: Saved
|
private int saveState = 0; //0: Idle, 1: Saving, 2: Saved
|
||||||
@@ -161,7 +162,7 @@ public abstract class DataListener extends ChannelInboundHandlerAdapter {
|
|||||||
queue.add(new PacketData(bytes, timestamp));
|
queue.add(new PacketData(bytes, timestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestFinish(Set<String> players, Set<MarkerKeyframe> markers) {
|
public void requestFinish(Set<String> players, Set<Keyframe<Marker>> markers) {
|
||||||
active = false;
|
active = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import com.google.common.util.concurrent.Futures;
|
|||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.chat.ChatMessageHandler;
|
import eu.crushedpixel.replaymod.chat.ChatMessageHandler;
|
||||||
import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
||||||
|
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||||
|
import eu.crushedpixel.replaymod.holders.Marker;
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -207,7 +208,7 @@ public class PacketListener extends DataListener {
|
|||||||
AdvancedPosition pos = new AdvancedPosition(Minecraft.getMinecraft().getRenderViewEntity(), false);
|
AdvancedPosition pos = new AdvancedPosition(Minecraft.getMinecraft().getRenderViewEntity(), false);
|
||||||
int timestamp = (int) (System.currentTimeMillis() - startTime);
|
int timestamp = (int) (System.currentTimeMillis() - startTime);
|
||||||
|
|
||||||
MarkerKeyframe marker = new MarkerKeyframe(timestamp, pos, null);
|
Keyframe<Marker> marker = new Keyframe<Marker>(timestamp, new Marker(null, pos));
|
||||||
|
|
||||||
markers.add(marker);
|
markers.add(marker);
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class ReplayHandler {
|
|||||||
private static int realTimelinePosition = 0;
|
private static int realTimelinePosition = 0;
|
||||||
|
|
||||||
private static Keyframe selectedKeyframe;
|
private static Keyframe selectedKeyframe;
|
||||||
private static MarkerKeyframe selectedMarkerKeyframe;
|
private static Keyframe<Marker> selectedMarkerKeyframe;
|
||||||
|
|
||||||
private static boolean inPath = false;
|
private static boolean inPath = false;
|
||||||
private static CameraEntity cameraEntity;
|
private static CameraEntity cameraEntity;
|
||||||
@@ -59,8 +59,8 @@ public class ReplayHandler {
|
|||||||
private static Entity currentEntity = null;
|
private static Entity currentEntity = null;
|
||||||
private static AdvancedPosition lastPosition = null;
|
private static AdvancedPosition lastPosition = null;
|
||||||
|
|
||||||
private static MarkerKeyframe[] initialMarkers = new MarkerKeyframe[0];
|
private static Keyframe<Marker>[] initialMarkers = new Keyframe[0];
|
||||||
private static List<MarkerKeyframe> markerKeyframes = new ArrayList<MarkerKeyframe>();
|
private static List<Keyframe<Marker>> markerKeyframes = new ArrayList<Keyframe<Marker>>();
|
||||||
|
|
||||||
private static float cameraTilt = 0;
|
private static float cameraTilt = 0;
|
||||||
|
|
||||||
@@ -95,11 +95,11 @@ public class ReplayHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MarkerKeyframe[] getMarkers() {
|
public static Keyframe<Marker>[] getMarkers() {
|
||||||
return markerKeyframes.toArray(new MarkerKeyframe[markerKeyframes.size()]);
|
return markerKeyframes.toArray(new Keyframe[markerKeyframes.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMarkers(MarkerKeyframe[] m, boolean write) {
|
public static void setMarkers(Keyframe<Marker>[] m, boolean write) {
|
||||||
markerKeyframes.clear();
|
markerKeyframes.clear();
|
||||||
Collections.addAll(markerKeyframes, m);
|
Collections.addAll(markerKeyframes, m);
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ public class ReplayHandler {
|
|||||||
else {
|
else {
|
||||||
AdvancedPosition pos = new AdvancedPosition(mc.getRenderViewEntity(), false);
|
AdvancedPosition pos = new AdvancedPosition(mc.getRenderViewEntity(), false);
|
||||||
int timestamp = ReplayMod.replaySender.currentTimeStamp();
|
int timestamp = ReplayMod.replaySender.currentTimeStamp();
|
||||||
markerKeyframes.add(new MarkerKeyframe(timestamp, pos, null));
|
markerKeyframes.add(new Keyframe<Marker>(timestamp, new Marker(null, pos)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,17 +291,17 @@ public class ReplayHandler {
|
|||||||
fireKeyframesModifyEvent();
|
fireKeyframesModifyEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MarkerKeyframe getClosestMarkerForRealTime(int realTime, int tolerance) {
|
public static Keyframe<Marker> getClosestMarkerForRealTime(int realTime, int tolerance) {
|
||||||
List<MarkerKeyframe> found = new ArrayList<MarkerKeyframe>();
|
List<Keyframe<Marker>> found = new ArrayList<Keyframe<Marker>>();
|
||||||
for(MarkerKeyframe kf : markerKeyframes) {
|
for(Keyframe<Marker> kf : markerKeyframes) {
|
||||||
if(Math.abs(kf.getRealTimestamp() - realTime) <= tolerance) {
|
if(Math.abs(kf.getRealTimestamp() - realTime) <= tolerance) {
|
||||||
found.add(kf);
|
found.add(kf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkerKeyframe closest = null;
|
Keyframe<Marker> closest = null;
|
||||||
|
|
||||||
for(MarkerKeyframe kf : found) {
|
for(Keyframe<Marker> kf : found) {
|
||||||
if(closest == null || Math.abs(closest.getRealTimestamp() - realTime) > Math.abs(kf.getRealTimestamp() - realTime)) {
|
if(closest == null || Math.abs(closest.getRealTimestamp() - realTime) > Math.abs(kf.getRealTimestamp() - realTime)) {
|
||||||
closest = kf;
|
closest = kf;
|
||||||
}
|
}
|
||||||
@@ -309,15 +309,15 @@ public class ReplayHandler {
|
|||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MarkerKeyframe getPreviousMarkerKeyframe(int realTime) {
|
public static Keyframe<Marker> getPreviousMarkerKeyframe(int realTime) {
|
||||||
if(markerKeyframes.isEmpty()) return null;
|
if(markerKeyframes.isEmpty()) return null;
|
||||||
MarkerKeyframe backup = null;
|
Keyframe<Marker> backup = null;
|
||||||
List<MarkerKeyframe> found = new ArrayList<MarkerKeyframe>();
|
List<Keyframe<Marker>> found = new ArrayList<Keyframe<Marker>>();
|
||||||
for(MarkerKeyframe kf : markerKeyframes) {
|
for(Keyframe<Marker> kf : markerKeyframes) {
|
||||||
if(kf.getRealTimestamp() < realTime) {
|
if(kf.getRealTimestamp() < realTime) {
|
||||||
found.add((MarkerKeyframe)kf);
|
found.add((Keyframe<Marker>)kf);
|
||||||
} else if(kf.getRealTimestamp() == realTime) {
|
} else if(kf.getRealTimestamp() == realTime) {
|
||||||
backup = (MarkerKeyframe)kf;
|
backup = (Keyframe<Marker>)kf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,10 +326,10 @@ public class ReplayHandler {
|
|||||||
else return backup;
|
else return backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MarkerKeyframe getNextMarkerKeyframe(int realTime) {
|
public static Keyframe<Marker> getNextMarkerKeyframe(int realTime) {
|
||||||
if(markerKeyframes.isEmpty()) return null;
|
if(markerKeyframes.isEmpty()) return null;
|
||||||
MarkerKeyframe backup = null;
|
Keyframe<Marker> backup = null;
|
||||||
for(MarkerKeyframe kf : markerKeyframes) {
|
for(Keyframe<Marker> kf : markerKeyframes) {
|
||||||
if(kf.getRealTimestamp() > realTime) {
|
if(kf.getRealTimestamp() > realTime) {
|
||||||
return kf; //first found element is next
|
return kf; //first found element is next
|
||||||
} else if(kf.getRealTimestamp() == realTime) {
|
} else if(kf.getRealTimestamp() == realTime) {
|
||||||
@@ -384,19 +384,15 @@ public class ReplayHandler {
|
|||||||
fireKeyframesModifyEvent();
|
fireKeyframesModifyEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSelected(Keyframe kf) {
|
|
||||||
return kf == selectedKeyframe;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void selectKeyframe(Keyframe kf) {
|
public static void selectKeyframe(Keyframe kf) {
|
||||||
selectedKeyframe = kf;
|
selectedKeyframe = kf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSelected(MarkerKeyframe kf) {
|
public static boolean isSelected(Keyframe<Marker> kf) {
|
||||||
return kf == selectedMarkerKeyframe;
|
return kf == selectedMarkerKeyframe || kf == selectedMarkerKeyframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void selectMarkerKeyframe(MarkerKeyframe kf) { selectedMarkerKeyframe = kf; }
|
public static void selectMarkerKeyframe(Keyframe<Marker> kf) { selectedMarkerKeyframe = kf; }
|
||||||
|
|
||||||
public static boolean isInReplay() {
|
public static boolean isInReplay() {
|
||||||
return inReplay;
|
return inReplay;
|
||||||
@@ -444,8 +440,10 @@ public class ReplayHandler {
|
|||||||
KeyframeSet[] paths = currentReplayFile.paths().get();
|
KeyframeSet[] paths = currentReplayFile.paths().get();
|
||||||
ReplayHandler.setKeyframeRepository(paths == null ? new KeyframeSet[0] : paths, false);
|
ReplayHandler.setKeyframeRepository(paths == null ? new KeyframeSet[0] : paths, false);
|
||||||
|
|
||||||
MarkerKeyframe[] markers = currentReplayFile.markers().get();
|
List<Keyframe<Marker>> markerList = currentReplayFile.markers().get();
|
||||||
if(markers == null) markers = new MarkerKeyframe[0];
|
Keyframe<Marker>[] markers;
|
||||||
|
if(markerList == null) markers = new Keyframe[0];
|
||||||
|
else markers = markerList.toArray(new Keyframe[markerList.size()]);
|
||||||
ReplayHandler.setMarkers(markers, false);
|
ReplayHandler.setMarkers(markers, false);
|
||||||
ReplayHandler.initialMarkers = markers;
|
ReplayHandler.initialMarkers = markers;
|
||||||
|
|
||||||
@@ -557,7 +555,7 @@ public class ReplayHandler {
|
|||||||
return selectedKeyframe;
|
return selectedKeyframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MarkerKeyframe getSelectedMarkerKeyframe() { return selectedMarkerKeyframe; }
|
public static Keyframe<Marker> getSelectedMarkerKeyframe() { return selectedMarkerKeyframe; }
|
||||||
|
|
||||||
public static int getRealTimelineCursor() {
|
public static int getRealTimelineCursor() {
|
||||||
return realTimelinePosition;
|
return realTimelinePosition;
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
package eu.crushedpixel.replaymod.utils;
|
package eu.crushedpixel.replaymod.utils;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import eu.crushedpixel.replaymod.assets.AssetRepository;
|
import eu.crushedpixel.replaymod.assets.AssetRepository;
|
||||||
import eu.crushedpixel.replaymod.assets.CustomObjectRepository;
|
import eu.crushedpixel.replaymod.assets.CustomObjectRepository;
|
||||||
|
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||||
import eu.crushedpixel.replaymod.holders.KeyframeSet;
|
import eu.crushedpixel.replaymod.holders.KeyframeSet;
|
||||||
import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
import eu.crushedpixel.replaymod.holders.Marker;
|
||||||
import eu.crushedpixel.replaymod.holders.PlayerVisibility;
|
import eu.crushedpixel.replaymod.holders.PlayerVisibility;
|
||||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||||
@@ -16,10 +18,8 @@ import org.apache.commons.compress.archivers.zip.ZipFile;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Enumeration;
|
import java.lang.reflect.Type;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ReplayFile extends ZipFile {
|
public class ReplayFile extends ZipFile {
|
||||||
|
|
||||||
@@ -135,17 +135,20 @@ public class ReplayFile extends ZipFile {
|
|||||||
return getEntry(ENTRY_MARKERS);
|
return getEntry(ENTRY_MARKERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Supplier<MarkerKeyframe[]> markers() {
|
public Supplier<List<Keyframe<Marker>>> markers() {
|
||||||
return new Supplier<MarkerKeyframe[]>() {
|
return new Supplier<List<Keyframe<Marker>>>() {
|
||||||
@Override
|
@Override
|
||||||
public MarkerKeyframe[] get() {
|
public List<Keyframe<Marker>> get() {
|
||||||
try {
|
try {
|
||||||
ZipArchiveEntry entry = markersEntry();
|
ZipArchiveEntry entry = markersEntry();
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(entry)));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(entry)));
|
||||||
return new Gson().fromJson(reader, MarkerKeyframe[].class);
|
|
||||||
|
Type keyframeType = new TypeToken<ArrayList<Keyframe<Marker>>>(){}.getType();
|
||||||
|
|
||||||
|
return new Gson().fromJson(reader, keyframeType);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ package eu.crushedpixel.replaymod.utils;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.assets.CustomObjectRepository;
|
import eu.crushedpixel.replaymod.assets.CustomObjectRepository;
|
||||||
import eu.crushedpixel.replaymod.holders.KeyframeSet;
|
import eu.crushedpixel.replaymod.holders.*;
|
||||||
import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
|
||||||
import eu.crushedpixel.replaymod.holders.PacketData;
|
|
||||||
import eu.crushedpixel.replaymod.holders.PlayerVisibility;
|
|
||||||
import eu.crushedpixel.replaymod.recording.PacketSerializer;
|
import eu.crushedpixel.replaymod.recording.PacketSerializer;
|
||||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@@ -53,7 +50,7 @@ public class ReplayFileIO {
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeReplayFile(File replayFile, File tempFile, ReplayMetaData metaData, Set<MarkerKeyframe> markers,
|
public static void writeReplayFile(File replayFile, File tempFile, ReplayMetaData metaData, Set<Keyframe<Marker>> markers,
|
||||||
Map<String, File> resourcePacks, Map<Integer, String> resourcePackRequests) throws IOException {
|
Map<String, File> resourcePacks, Map<Integer, String> resourcePackRequests) throws IOException {
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
|
|
||||||
@@ -82,7 +79,7 @@ public class ReplayFileIO {
|
|||||||
zos.putNextEntry(new ZipEntry(ReplayFile.ENTRY_MARKERS));
|
zos.putNextEntry(new ZipEntry(ReplayFile.ENTRY_MARKERS));
|
||||||
|
|
||||||
pw = new PrintWriter(zos);
|
pw = new PrintWriter(zos);
|
||||||
pw.write(new Gson().toJson(markers.toArray(new MarkerKeyframe[markers.size()])));
|
pw.write(new Gson().toJson(markers.toArray(new Keyframe[markers.size()])));
|
||||||
pw.flush();
|
pw.flush();
|
||||||
zos.closeEntry();
|
zos.closeEntry();
|
||||||
}
|
}
|
||||||
@@ -166,7 +163,7 @@ public class ReplayFileIO {
|
|||||||
write((Object) metaData, file);
|
write((Object) metaData, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void write(MarkerKeyframe[] markers, File file) throws IOException {
|
public static void write(Keyframe<Marker>[] markers, File file) throws IOException {
|
||||||
write((Object) markers, file);
|
write((Object) markers, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user