Created CustomObjectRepository which can be serialized by Gson, storing all CustomImageObjects created

CustomObjectRepository is now being saved to and loaded from the ReplayFile
The CustomObjectRenderer uses the GuiObjectManager's timeline cursor position as interpolation timestamp for the CustomImageObjects which are drawn if a GuiObjectManager is open (instant preview)
KeyframeList's add() method now removes Keyframes with the same timestamp before adding the new Keyframe
Transformations class now holds default values to prevent NullPointerExceptions in methods calling getTransformationForTimestamp()
Added Javadoc to Transformation POJO
Created NumberValueChangeListener which can be applied to GuiNumberInput objects
Made step size customizable in GuiDraggingNumberInput
Changing a ReplayImageAssets image now notifies the CustomImageObjects linked to that asset
Modified RoundUtils to provide a round() method which uses the DecimalFormat class instead of Math.round which is unstable
This commit is contained in:
CrushedPixel
2015-07-12 16:21:11 +02:00
parent 6a6873c3d7
commit 45f64faa77
17 changed files with 393 additions and 65 deletions

View File

@@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile;
import eu.crushedpixel.replaymod.ReplayMod;
import eu.crushedpixel.replaymod.assets.AssetRepository;
import eu.crushedpixel.replaymod.assets.CustomImageObject;
import eu.crushedpixel.replaymod.assets.CustomObjectRepository;
import eu.crushedpixel.replaymod.entities.CameraEntity;
import eu.crushedpixel.replaymod.events.KeyframesModifyEvent;
import eu.crushedpixel.replaymod.events.ReplayExitEvent;
@@ -68,7 +69,7 @@ public class ReplayHandler {
@Getter @Setter
private static AssetRepository assetRepository;
private static List<CustomImageObject> customImageObjects = new ArrayList<CustomImageObject>();
private static CustomObjectRepository customImageObjects = new CustomObjectRepository();
/**
* The file currently being played.
@@ -455,6 +456,11 @@ public class ReplayHandler {
AssetRepository assets = currentReplayFile.assetRepository().get();
assetRepository = assets;
//load custom image objects
CustomObjectRepository objectRepository = currentReplayFile.customImageObjects().get();
customImageObjects = objectRepository;
if(customImageObjects == null) customImageObjects = new CustomObjectRepository();
ReplayMod.replaySender = new ReplaySender(currentReplayFile, asyncMode);
channel.pipeline().addFirst(ReplayMod.replaySender);
channel.pipeline().fireChannelActive();
@@ -604,15 +610,15 @@ public class ReplayHandler {
}
public static List<CustomImageObject> getCustomImageObjects() {
return customImageObjects;
return customImageObjects.getObjects();
}
public static void addCustomImageObject(CustomImageObject object) {
customImageObjects.add(object);
customImageObjects.getObjects().add(object);
}
public static void setCustomImageObjects(List<CustomImageObject> objects) {
customImageObjects = objects;
public static void setCustomImageObjects(ArrayList<CustomImageObject> objects) {
customImageObjects.setObjects(objects);
}
public static void fireKeyframesModifyEvent() {