Fix timeline not saving when completely overwritten (fixes #505)
Either when it is cleared or when it is loaded from the keyframe repository, if you exit the replay without any further changes, this used to not be saved.
This commit is contained in:
@@ -150,9 +150,9 @@ public class ReplayModSimplePathing extends EventRegistrations implements Module
|
|||||||
synchronized (replayFile) {
|
synchronized (replayFile) {
|
||||||
Timeline timeline = replayFile.getTimelines(new SPTimeline()).get("");
|
Timeline timeline = replayFile.getTimelines(new SPTimeline()).get("");
|
||||||
if (timeline != null) {
|
if (timeline != null) {
|
||||||
setCurrentTimeline(new SPTimeline(timeline));
|
setCurrentTimeline(new SPTimeline(timeline), false);
|
||||||
} else {
|
} else {
|
||||||
setCurrentTimeline(new SPTimeline());
|
setCurrentTimeline(new SPTimeline(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -225,8 +225,16 @@ public class ReplayModSimplePathing extends EventRegistrations implements Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentTimeline(SPTimeline newTimeline) {
|
public void setCurrentTimeline(SPTimeline newTimeline) {
|
||||||
|
setCurrentTimeline(newTimeline, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCurrentTimeline(SPTimeline newTimeline, boolean save) {
|
||||||
selectedPath = null;
|
selectedPath = null;
|
||||||
currentTimeline = newTimeline;
|
currentTimeline = newTimeline;
|
||||||
|
if (!save) {
|
||||||
|
lastTimeline = newTimeline;
|
||||||
|
lastChange = newTimeline.getTimeline().peekUndoStack();
|
||||||
|
}
|
||||||
updateDefaultInterpolatorType();
|
updateDefaultInterpolatorType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,18 +262,21 @@ public class ReplayModSimplePathing extends EventRegistrations implements Module
|
|||||||
|
|
||||||
private final AtomicInteger lastSaveId = new AtomicInteger();
|
private final AtomicInteger lastSaveId = new AtomicInteger();
|
||||||
private ExecutorService saveService;
|
private ExecutorService saveService;
|
||||||
|
private SPTimeline lastTimeline;
|
||||||
private Change lastChange;
|
private Change lastChange;
|
||||||
private void maybeSaveTimeline(ReplayFile replayFile) {
|
private void maybeSaveTimeline(ReplayFile replayFile) {
|
||||||
SPTimeline spTimeline = currentTimeline;
|
SPTimeline spTimeline = currentTimeline;
|
||||||
if (spTimeline == null || saveService == null) {
|
if (spTimeline == null || saveService == null) {
|
||||||
|
lastTimeline = null;
|
||||||
lastChange = null;
|
lastChange = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Change latestChange = spTimeline.getTimeline().peekUndoStack();
|
Change latestChange = spTimeline.getTimeline().peekUndoStack();
|
||||||
if (latestChange == null || latestChange == lastChange) {
|
if (spTimeline == lastTimeline && latestChange == lastChange) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
lastTimeline = spTimeline;
|
||||||
lastChange = latestChange;
|
lastChange = latestChange;
|
||||||
|
|
||||||
// Clone the timeline for async saving
|
// Clone the timeline for async saving
|
||||||
|
|||||||
Reference in New Issue
Block a user