From 1a2e7623efc388b0d71622a56d9ade207cccba95 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 27 Mar 2020 09:22:54 -0400 Subject: [PATCH] Prefer oamtable name for sprite dimensions --- src/project.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/project.cpp b/src/project.cpp index 4f6c554d..5b79b29f 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -2267,16 +2267,19 @@ void Project::loadEventPixmaps(QList objects) { QImage spritesheet(root + "/" + path); if (!spritesheet.isNull()) { // Infer the sprite dimensions from the OAM labels. - int spriteWidth = spritesheet.width(); - int spriteHeight = spritesheet.height(); + int spriteWidth, spriteHeight; QRegularExpression re("\\S+_(\\d+)x(\\d+)"); QRegularExpressionMatch dimensionMatch = re.match(dimensions_label); - if (dimensionMatch.hasMatch()) { - QRegularExpressionMatch oamTablesMatch = re.match(subsprites_label); - if (oamTablesMatch.hasMatch()) { - spriteWidth = dimensionMatch.captured(1).toInt(); - spriteHeight = dimensionMatch.captured(2).toInt(); - } + QRegularExpressionMatch oamTablesMatch = re.match(subsprites_label); + if (oamTablesMatch.hasMatch()) { + spriteWidth = oamTablesMatch.captured(1).toInt(); + spriteHeight = oamTablesMatch.captured(2).toInt(); + } else if (dimensionMatch.hasMatch()) { + spriteWidth = dimensionMatch.captured(1).toInt(); + spriteHeight = dimensionMatch.captured(2).toInt(); + } else { + spriteWidth = spritesheet.width(); + spriteHeight = spritesheet.height(); } object->setPixmapFromSpritesheet(spritesheet, spriteWidth, spriteHeight, object->frame, object->hFlip); }