[ts] Port of commit 7facce3: Draw order folder timeline property ID per slot with "all" special case.

This commit is contained in:
Davide Tantillo 2026-03-18 15:04:56 +01:00
parent e1ea92aad7
commit 161780fcac
2 changed files with 19 additions and 4 deletions

View File

@ -1789,7 +1789,8 @@ export class EventTimeline extends Timeline {
/** Changes a skeleton's {@link Skeleton#drawOrder}. */ /** Changes a skeleton's {@link Skeleton#drawOrder}. */
export class DrawOrderTimeline extends Timeline { export class DrawOrderTimeline extends Timeline {
static propertyIds = [`${Property.drawOrder}`]; static readonly propertyID = `${Property.drawOrder}`;
static propertyIds = [DrawOrderTimeline.propertyID];
/** The draw order for each key frame. See {@link #setFrame(int, float, int[])}. */ /** The draw order for each key frame. See {@link #setFrame(int, float, int[])}. */
private readonly drawOrders: Array<Array<number> | null>; private readonly drawOrders: Array<Array<number> | null>;
@ -1846,7 +1847,7 @@ export class DrawOrderFolderTimeline extends Timeline {
/** @param slots {@link Skeleton#slots} indices controlled by this timeline, in setup order. /** @param slots {@link Skeleton#slots} indices controlled by this timeline, in setup order.
* @param slotCount The maximum number of slots in the skeleton. */ * @param slotCount The maximum number of slots in the skeleton. */
constructor (frameCount: number, slots: number[], slotCount: number) { constructor (frameCount: number, slots: number[], slotCount: number) {
super(frameCount, ...DrawOrderTimeline.propertyIds); super(frameCount, ...DrawOrderFolderTimeline.propertyIds(slots));
this.slots = slots; this.slots = slots;
this.drawOrders = new Array(frameCount); this.drawOrders = new Array(frameCount);
this.inFolder = new Array(slotCount); this.inFolder = new Array(slotCount);
@ -1854,6 +1855,14 @@ export class DrawOrderFolderTimeline extends Timeline {
this.inFolder[i] = true; this.inFolder[i] = true;
} }
private static propertyIds (slots: number[]): string[] {
const n = slots.length;
const ids = new Array(n);
for (let i = 0; i < n; i++)
ids[i] = `d${slots[i]}`;
return ids;
}
getFrameCount (): number { getFrameCount (): number {
return this.frames.length; return this.frames.length;
} }

View File

@ -777,8 +777,12 @@ export class AnimationState {
const propertyIDs = this.propertyIDs; const propertyIDs = this.propertyIDs;
if (to?.holdPrevious) { if (to?.holdPrevious) {
for (let i = 0; i < timelinesCount; i++) for (let i = 0; i < timelinesCount; i++) {
timelineMode[i] = propertyIDs.addAll(timelines[i].getPropertyIds()) ? HOLD_FIRST : HOLD_SUBSEQUENT; let first = propertyIDs.addAll(timelines[i].getPropertyIds());
if (first && timelines[i] instanceof DrawOrderFolderTimeline && propertyIDs.contains(DrawOrderTimeline.propertyID))
first = false; // DrawOrderTimeline changed.
timelineMode[i] = first ? HOLD_FIRST : HOLD_SUBSEQUENT;
}
return; return;
} }
@ -788,6 +792,8 @@ export class AnimationState {
const ids = timeline.getPropertyIds(); const ids = timeline.getPropertyIds();
if (!propertyIDs.addAll(ids)) if (!propertyIDs.addAll(ids))
timelineMode[i] = SUBSEQUENT; timelineMode[i] = SUBSEQUENT;
else if (timeline instanceof DrawOrderFolderTimeline && propertyIDs.contains(DrawOrderTimeline.propertyID))
timelineMode[i] = SUBSEQUENT; // DrawOrderTimeline changed.
else if (!to || timeline instanceof AttachmentTimeline || timeline instanceof DrawOrderTimeline else if (!to || timeline instanceof AttachmentTimeline || timeline instanceof DrawOrderTimeline
|| timeline instanceof DrawOrderFolderTimeline || timeline instanceof EventTimeline || timeline instanceof DrawOrderFolderTimeline || timeline instanceof EventTimeline
|| !to.animation!.hasTimeline(ids)) { || !to.animation!.hasTimeline(ids)) {