mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 14:38:50 +00:00
Implement scene switcher
This commit is contained in:
1 parent
3600e535d5
commit
775b49bd8a
15 files changed
+473
-314
No files matched your search
@@ -35,14 +35,13 @@ public class EditorState {
|
||||
transient boolean dirty = false;
|
||||
public transient int modCount = ThreadLocalRandom.current().nextInt();
|
||||
|
||||
public final List<KeyframeTrack> keyframeTracks = new ArrayList<>();
|
||||
public final ReplayVisuals replayVisuals = new ReplayVisuals();
|
||||
private final EditorStateHistory history = new EditorStateHistory();
|
||||
|
||||
public final List<EditorScene> scenes;
|
||||
public int sceneIndex = 0;
|
||||
|
||||
public double zoomMin = 0.0;
|
||||
public double zoomMax = 1.0;
|
||||
public int exportStartTicks = -1;
|
||||
public int exportEndTicks = -1;
|
||||
|
||||
public UUID audioSourceEntity = null;
|
||||
public Set<UUID> hideDuringExport = new HashSet<>();
|
||||
@@ -50,28 +49,16 @@ public class EditorState {
|
||||
public Map<UUID, GameProfile> skinOverride = new HashMap<>();
|
||||
public Map<UUID, String> nameOverride = new HashMap<>();
|
||||
|
||||
public void setKeyframe(int trackIndex, int tick, Keyframe keyframe) {
|
||||
if (trackIndex >= this.keyframeTracks.size()) {
|
||||
return;
|
||||
public EditorState() {
|
||||
this.scenes = new ArrayList<>();
|
||||
this.scenes.add(new EditorScene("Scene 1"));
|
||||
}
|
||||
|
||||
public EditorScene currentScene() {
|
||||
if (this.scenes.isEmpty()) {
|
||||
this.scenes.add(new EditorScene("Scene 1"));
|
||||
}
|
||||
|
||||
List<EditorStateHistoryAction> undo = new ArrayList<>();
|
||||
List<EditorStateHistoryAction> redo = new ArrayList<>();
|
||||
|
||||
String description;
|
||||
|
||||
KeyframeTrack track = this.keyframeTracks.get(trackIndex);
|
||||
Keyframe old = track.keyframesByTick.get(tick);
|
||||
if (old != null) {
|
||||
undo.add(new EditorStateHistoryAction.SetKeyframe(track.keyframeType, trackIndex, tick, old.copy()));
|
||||
description = "Replaced " + track.keyframeType.name() + " keyframe";
|
||||
} else {
|
||||
undo.add(new EditorStateHistoryAction.RemoveKeyframe(track.keyframeType, trackIndex, tick));
|
||||
description = "Added " + track.keyframeType.name() + " keyframe";
|
||||
}
|
||||
redo.add(new EditorStateHistoryAction.SetKeyframe(track.keyframeType, trackIndex, tick, keyframe.copy()));
|
||||
|
||||
this.push(new EditorStateHistoryEntry(undo, redo, description));
|
||||
return this.scenes.get(this.sceneIndex);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -96,54 +83,6 @@ public class EditorState {
|
||||
return dummyCamera;
|
||||
}
|
||||
|
||||
public void push(EditorStateHistoryEntry entry) {
|
||||
if (entry.undo().isEmpty() && entry.redo().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.history.push(this, entry);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void undo(Consumer<String> descriptionConsumer) {
|
||||
this.history.undo(this, descriptionConsumer);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void redo(Consumer<String> descriptionConsumer) {
|
||||
this.history.redo(this, descriptionConsumer);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void setExportTicks(int start, int end, int totalTicks) {
|
||||
if (this.exportEndTicks < 0) {
|
||||
this.exportEndTicks = totalTicks;
|
||||
}
|
||||
this.exportStartTicks = Math.max(0, Math.min(totalTicks, this.exportStartTicks));
|
||||
this.exportEndTicks = Math.max(0, Math.min(totalTicks, this.exportEndTicks));
|
||||
|
||||
if (start >= 0) {
|
||||
this.exportStartTicks = start;
|
||||
if (this.exportEndTicks < start) {
|
||||
this.exportEndTicks = start;
|
||||
}
|
||||
}
|
||||
|
||||
if (end >= 0) {
|
||||
this.exportEndTicks = end;
|
||||
if (this.exportStartTicks > end) {
|
||||
this.exportStartTicks = end;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.exportStartTicks <= 0 && this.exportEndTicks >= totalTicks) {
|
||||
this.exportStartTicks = -1;
|
||||
this.exportEndTicks = -1;
|
||||
}
|
||||
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public void markDirty() {
|
||||
this.dirty = true;
|
||||
this.modCount += 1;
|
||||
@@ -187,7 +126,7 @@ public class EditorState {
|
||||
|
||||
public void applyKeyframes(KeyframeHandler keyframeHandler, float tick) {
|
||||
Set<KeyframeType<?>> applied = new HashSet<>();
|
||||
for (KeyframeTrack keyframeTrack : this.keyframeTracks) {
|
||||
for (KeyframeTrack keyframeTrack : this.currentScene().keyframeTracks) {
|
||||
// Ignore lines that are disabled
|
||||
if (!keyframeTrack.enabled) {
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user