store parents in json

This commit is contained in:
Skyler Lehmkuhl 2025-01-17 23:44:41 -05:00
parent a24128ab08
commit c76cc75337
1 changed files with 19 additions and 0 deletions

View File

@ -3689,6 +3689,9 @@ class GraphicsObject extends Widget {
graphicsObject.currentFrameNum = json.currentFrameNum; graphicsObject.currentFrameNum = json.currentFrameNum;
graphicsObject.currentLayer = json.currentLayer; graphicsObject.currentLayer = json.currentLayer;
graphicsObject.children = []; graphicsObject.children = [];
if (json.parent in pointerList) {
graphicsObject.parent = pointerList[json.parent]
}
for (let layer of json.layers) { for (let layer of json.layers) {
graphicsObject.layers.push(Layer.fromJSON(layer)); graphicsObject.layers.push(Layer.fromJSON(layer));
} }
@ -3715,6 +3718,7 @@ class GraphicsObject extends Widget {
json.currentFrameNum = this.currentFrameNum; json.currentFrameNum = this.currentFrameNum;
json.currentLayer = this.currentLayer; json.currentLayer = this.currentLayer;
json.layers = []; json.layers = [];
json.parent = this.parent?.idx
for (let layer of this.layers) { for (let layer of this.layers) {
json.layers.push(layer.toJSON(randomizeUuid)); json.layers.push(layer.toJSON(randomizeUuid));
} }
@ -4588,6 +4592,20 @@ async function _open(path, returnJson = false) {
undoStack.push(action); undoStack.push(action);
} }
} else { } else {
if (file.version < "1.7.7") {
function setParentReferences(obj, parentIdx = null) {
if (obj.type === "GraphicsObject") {
obj.parent = parentIdx; // Set the parent property
}
if (Array.isArray(obj.children)) {
for (const child of obj.children) {
setParentReferences(child, obj.type === "GraphicsObject" ? obj.idx : parentIdx);
}
}
}
setParentReferences(file.json)
}
if (file.version < "1.7.6") { if (file.version < "1.7.6") {
function restoreLineColors(obj) { function restoreLineColors(obj) {
// Step 1: Create colorMapping dictionary // Step 1: Create colorMapping dictionary
@ -6395,6 +6413,7 @@ function timeline() {
const frame = layer.getFrame(timeline_cvs.clicked_frame); const frame = layer.getFrame(timeline_cvs.clicked_frame);
if (frame.exists) { if (frame.exists) {
console.log(frame.keys)
if (!e.shiftKey) { if (!e.shiftKey) {
// Check if the clicked frame is already in the selection // Check if the clicked frame is already in the selection
const existingIndex = context.selectedFrames.findIndex( const existingIndex = context.selectedFrames.findIndex(