First Commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
public class Keyframe {
|
||||
|
||||
private int realTimestamp;
|
||||
|
||||
public Keyframe(int realTimestamp) {
|
||||
this.realTimestamp = realTimestamp;
|
||||
}
|
||||
|
||||
public int getRealTimestamp() {
|
||||
return realTimestamp;
|
||||
}
|
||||
|
||||
public void setRealTimestamp(int realTimestamp) {
|
||||
this.realTimestamp = realTimestamp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
|
||||
public class KeyframeComparator implements Comparator<Keyframe> {
|
||||
|
||||
@Override
|
||||
public int compare(Keyframe o1, Keyframe o2) {
|
||||
if(ReplayHandler.isSelected(o1)) return 1;
|
||||
if(ReplayHandler.isSelected(o2)) return -1;
|
||||
return o1.getRealTimestamp()-o2.getRealTimestamp();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
public class Position {
|
||||
|
||||
private double x, y, z;
|
||||
private float pitch, yaw;
|
||||
|
||||
public Position(double x, double y, double z, float pitch, float yaw) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.pitch = pitch;
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public void setPitch(float pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public void setYaw(float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
public class PositionKeyframe extends Keyframe {
|
||||
|
||||
private Position position;
|
||||
|
||||
public PositionKeyframe(int realTime, Position position) {
|
||||
super(realTime);
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Position position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
}
|
||||
100
src/main/java/eu/crushedpixel/replaymod/holders/TimeInfo.java
Normal file
100
src/main/java/eu/crushedpixel/replaymod/holders/TimeInfo.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2014 Johni0702
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
**/
|
||||
public final class TimeInfo {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return start+" | "+speedSince+" | "+speed+" | "+jumpTo;
|
||||
}
|
||||
|
||||
public static TimeInfo create() {
|
||||
long now = System.currentTimeMillis();
|
||||
return new TimeInfo(now, now, 1, -1);
|
||||
}
|
||||
|
||||
public TimeInfo(long start, long speedSince, double speed, long jumpTo) {
|
||||
this.start = start;
|
||||
this.speedSince = speedSince;
|
||||
this.speed = speed;
|
||||
this.jumpTo = jumpTo;
|
||||
}
|
||||
|
||||
private final long start;
|
||||
private final long speedSince;
|
||||
private final double speed;
|
||||
private final long jumpTo;
|
||||
|
||||
public long getActualStartTime(long now) {
|
||||
long realTimePassed = now - speedSince;
|
||||
long ingameTimePassed = (long) (realTimePassed * this.speed);
|
||||
return start + realTimePassed - ingameTimePassed;
|
||||
}
|
||||
|
||||
public long getInGameTimePassed(long now) {
|
||||
long realTimePassed = now - speedSince;
|
||||
long ingameTimePassed = (long) (realTimePassed * this.speed);
|
||||
return speedSince - start + ingameTimePassed;
|
||||
}
|
||||
|
||||
public TimeInfo updateSpeed(long now, double speed) {
|
||||
if (isJumping()) {
|
||||
return new TimeInfo(now-jumpTo, now, speed, -1);
|
||||
} else {
|
||||
if (this.speed == speed) {
|
||||
return this;
|
||||
}
|
||||
long start;
|
||||
if (this.speed == 1) {
|
||||
start = this.start;
|
||||
} else {
|
||||
start = getActualStartTime(now);
|
||||
}
|
||||
return new TimeInfo(start, now, speed, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isJumping() {
|
||||
return jumpTo != -1;
|
||||
}
|
||||
|
||||
public TimeInfo jumpTo(long jumpTo) {
|
||||
return new TimeInfo(start, speedSince, speed, jumpTo);
|
||||
}
|
||||
|
||||
public long getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public long getSpeedSince() {
|
||||
return speedSince;
|
||||
}
|
||||
|
||||
public double getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public long getJumpTo() {
|
||||
return jumpTo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
public class TimeKeyframe extends Keyframe {
|
||||
|
||||
private int timestamp;
|
||||
|
||||
public TimeKeyframe(int realTime, int timestamp) {
|
||||
super(realTime);
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public int getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(int timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user