Prefer oamtable name for sprite dimensions
This commit is contained in:
parent
0fb483b5d3
commit
1a2e7623ef
1 changed files with 11 additions and 8 deletions
|
@ -2267,16 +2267,19 @@ void Project::loadEventPixmaps(QList<Event*> 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue