forked from noxious/server
Removed extra lines that made no differenec
This commit is contained in:
parent
54c75896f9
commit
3b0138130b
@ -46,22 +46,10 @@ export default class SpriteUpdateEvent {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const parsedSpriteActions = validateSpriteActions(data.spriteActions)
|
const parsedSpriteActions = validateSpriteActions(data.spriteActions)
|
||||||
// First, process sprites to get dimensions
|
|
||||||
const processedActions = await processSprites(parsedSpriteActions)
|
const processedActions = await processSprites(parsedSpriteActions)
|
||||||
|
|
||||||
// Find the maximum dimensions across all actions
|
await updateDatabase(data.id, data.name, processedActions)
|
||||||
const maxFrameWidth = Math.max(...processedActions.map(action => action.frameWidth))
|
await saveSpritesToDisk(data.id, processedActions)
|
||||||
const maxFrameHeight = Math.max(...processedActions.map(action => action.frameHeight))
|
|
||||||
|
|
||||||
// Update all actions to use the maximum dimensions
|
|
||||||
const normalizedActions = processedActions.map(action => ({
|
|
||||||
...action,
|
|
||||||
frameWidth: maxFrameWidth,
|
|
||||||
frameHeight: maxFrameHeight
|
|
||||||
}))
|
|
||||||
|
|
||||||
await updateDatabase(data.id, data.name, normalizedActions)
|
|
||||||
await saveSpritesToDisk(data.id, normalizedActions)
|
|
||||||
|
|
||||||
callback(true)
|
callback(true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -141,6 +129,7 @@ export default class SpriteUpdateEvent {
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
processedActions.map(async ({ action, buffersWithDimensions, frameWidth, frameHeight }) => {
|
processedActions.map(async ({ action, buffersWithDimensions, frameWidth, frameHeight }) => {
|
||||||
|
// Get and validate all frame dimensions first
|
||||||
const frames = await Promise.all(
|
const frames = await Promise.all(
|
||||||
buffersWithDimensions.map(async ({ buffer }) => {
|
buffersWithDimensions.map(async ({ buffer }) => {
|
||||||
const metadata = await sharp(buffer).metadata()
|
const metadata = await sharp(buffer).metadata()
|
||||||
@ -163,9 +152,10 @@ export default class SpriteUpdateEvent {
|
|||||||
.composite(
|
.composite(
|
||||||
frames.map(({ buffer, width, height }, index) => ({
|
frames.map(({ buffer, width, height }, index) => ({
|
||||||
input: buffer,
|
input: buffer,
|
||||||
// Center horizontally and vertically in the frame
|
// Center horizontally based on the exact middle of each frame
|
||||||
left: (index * frameWidth) + ((frameWidth - width) >> 1),
|
left: (index * frameWidth) + ((frameWidth - width) >> 1),
|
||||||
top: 0,
|
// Calculate vertical position to center in the available space
|
||||||
|
top: 0
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
.png()
|
.png()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user