Custom Objects are now being saved with Path Presets instead of globally

This commit is contained in:
CrushedPixel
2015-08-16 18:30:00 +02:00
parent c95c2f0e4c
commit f2752f2790
10 changed files with 59 additions and 61 deletions

View File

@@ -1,26 +1,45 @@
package eu.crushedpixel.replaymod.holders;
import lombok.EqualsAndHashCode;
import eu.crushedpixel.replaymod.assets.CustomImageObject;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Data
@NoArgsConstructor
@EqualsAndHashCode
public class KeyframeSet implements GuiEntryListEntry {
private String name;
private Keyframe<AdvancedPosition>[] positionKeyframes;
private Keyframe<TimestampValue>[] timeKeyframes;
private CustomImageObject[] customObjects = new CustomImageObject[0];
public KeyframeSet(String name, Keyframe[] keyframes) {
public KeyframeSet(String name, Keyframe[] keyframes, List<CustomImageObject> customObjectRepository) {
this.name = name;
setCustomObjects(customObjectRepository.toArray(new CustomImageObject[customObjectRepository.size()]));
setKeyframes(keyframes);
}
public void setName(String name) {
public KeyframeSet(String name, Keyframe[] keyframes, CustomImageObject[] customObjects) {
this.name = name;
setCustomObjects(customObjects);
setKeyframes(keyframes);
}
public void setCustomObjects(CustomImageObject[] customObjects) {
this.customObjects = new CustomImageObject[customObjects.length];
int i = 0;
for(CustomImageObject object : customObjects) {
try {
this.customObjects[i] = object.copy();
} catch(IOException ioe) {
ioe.printStackTrace();
}
i++;
}
}
@SuppressWarnings("unchecked")
@@ -39,10 +58,6 @@ public class KeyframeSet implements GuiEntryListEntry {
timeKeyframes = timeKFList.toArray(new Keyframe[timeKFList.size()]);
}
public String getName() {
return name;
}
public Keyframe[] getKeyframes() {
Keyframe[] keyframes = new Keyframe[positionKeyframes.length + timeKeyframes.length];
System.arraycopy(positionKeyframes, 0, keyframes, 0, positionKeyframes.length);
@@ -73,6 +88,10 @@ public class KeyframeSet implements GuiEntryListEntry {
return last-first;
}
public int getCustomObjectCount() {
return customObjects.length;
}
@Override
public String getDisplayString() {
return name;