Fix old files opening with incorrect positions

This commit is contained in:
Skyler Lehmkuhl 2025-01-05 14:22:07 -05:00
parent 27fb6105cc
commit 568758d586
1 changed files with 24 additions and 0 deletions

View File

@ -3746,6 +3746,7 @@ async function _open(path, returnJson = false) {
}
const objectOffsets = {};
const frameIDs = []
for (let action of file.actions) {
if (!(action.name in actions)) {
await messageDialog(
@ -3783,6 +3784,9 @@ async function _open(path, returnJson = false) {
};
action.action.position = position;
objectOffsets[action.action.groupUuid] = position;
for (let shape of action.action.shapes) {
objectOffsets[shape] = position
}
} else if (action.name == "editFrame") {
for (let key in action.action.newState) {
if (key in objectOffsets) {
@ -3796,6 +3800,26 @@ async function _open(path, returnJson = false) {
action.action.oldState[key].y += objectOffsets[key].y;
}
}
} else if (action.name == "addKeyframe") {
for (let id in objectOffsets) {
objectOffsets[action.action.uuid.slice(0,8) + id.slice(8)] = objectOffsets[id]
}
} else if (action.name == "editShape") {
if (action.action.shape in objectOffsets) {
console.log("editing shape")
for (let curve of action.action.newCurves) {
for (let point of curve.points) {
point.x -= objectOffsets[action.action.shape].x
point.y -= objectOffsets[action.action.shape].y
}
}
for (let curve of action.action.oldCurves) {
for (let point of curve.points) {
point.x -= objectOffsets[action.action.shape].x
point.y -= objectOffsets[action.action.shape].y
}
}
}
}
}
if (file.version <= "1.6") {