npm run format
This commit is contained in:
@ -38,4 +38,4 @@ export default class ItemCreateEvent {
|
||||
callback(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,4 +37,4 @@ export default class ItemDeleteEvent {
|
||||
callback(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,4 +33,4 @@ export default class ItemListEvent {
|
||||
const items = await itemRepository.getAll()
|
||||
callback(items)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,4 @@ export default class ItemUpdateEvent {
|
||||
return callback(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ export default class SpriteCopyEvent {
|
||||
data: {
|
||||
name: `${sourceSprite.name} (Copy)`,
|
||||
spriteActions: {
|
||||
create: sourceSprite.spriteActions.map(action => ({
|
||||
create: sourceSprite.spriteActions.map((action) => ({
|
||||
action: action.action,
|
||||
sprites: action.sprites as Prisma.InputJsonValue,
|
||||
originX: action.originX,
|
||||
@ -74,4 +74,4 @@ export default class SpriteCopyEvent {
|
||||
private getErrorMessage(error: unknown): string {
|
||||
return error instanceof Error ? error.message : String(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,23 +78,28 @@ export default class SpriteUpdateEvent {
|
||||
const parsedActions = this.validateSpriteActions(payload.spriteActions)
|
||||
|
||||
// Process sprites
|
||||
const processedActions = await Promise.all(parsedActions.map(async (action) => {
|
||||
const spriteBuffers = await this.convertBase64ToBuffers(action.sprites)
|
||||
const frameWidth = ISOMETRIC_CONFIG.tileWidth
|
||||
const frameHeight = await this.calculateOptimalHeight(spriteBuffers)
|
||||
const processedFrames = await this.normalizeFrames(spriteBuffers, frameWidth, frameHeight)
|
||||
const processedActions = await Promise.all(
|
||||
parsedActions.map(async (action) => {
|
||||
const spriteBuffers = await this.convertBase64ToBuffers(action.sprites)
|
||||
const frameWidth = ISOMETRIC_CONFIG.tileWidth
|
||||
const frameHeight = await this.calculateOptimalHeight(spriteBuffers)
|
||||
const processedFrames = await this.normalizeFrames(spriteBuffers, frameWidth, frameHeight)
|
||||
|
||||
return {
|
||||
...action,
|
||||
frameWidth,
|
||||
frameHeight,
|
||||
buffersWithDimensions: processedFrames
|
||||
}
|
||||
}))
|
||||
return {
|
||||
...action,
|
||||
frameWidth,
|
||||
frameHeight,
|
||||
buffersWithDimensions: processedFrames
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
await Promise.all([
|
||||
this.updateDatabase(payload.id, payload.name, processedActions),
|
||||
this.saveSpritesToDisk(payload.id, processedActions.filter(a => a.buffersWithDimensions.length > 0))
|
||||
this.saveSpritesToDisk(
|
||||
payload.id,
|
||||
processedActions.filter((a) => a.buffersWithDimensions.length > 0)
|
||||
)
|
||||
])
|
||||
|
||||
callback(true)
|
||||
@ -158,9 +163,9 @@ export default class SpriteUpdateEvent {
|
||||
const processedInput = await sharp(buffer)
|
||||
.ensureAlpha()
|
||||
.resize({
|
||||
width: frameWidth, // Set maximum width
|
||||
width: frameWidth, // Set maximum width
|
||||
height: frameHeight, // Set maximum height
|
||||
fit: 'inside', // Ensure image fits within dimensions
|
||||
fit: 'inside', // Ensure image fits within dimensions
|
||||
kernel: sharp.kernel.nearest,
|
||||
position: 'center',
|
||||
withoutEnlargement: true // Don't enlarge smaller images
|
||||
|
Reference in New Issue
Block a user