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);
|
QImage spritesheet(root + "/" + path);
|
||||||
if (!spritesheet.isNull()) {
|
if (!spritesheet.isNull()) {
|
||||||
// Infer the sprite dimensions from the OAM labels.
|
// Infer the sprite dimensions from the OAM labels.
|
||||||
int spriteWidth = spritesheet.width();
|
int spriteWidth, spriteHeight;
|
||||||
int spriteHeight = spritesheet.height();
|
|
||||||
QRegularExpression re("\\S+_(\\d+)x(\\d+)");
|
QRegularExpression re("\\S+_(\\d+)x(\\d+)");
|
||||||
QRegularExpressionMatch dimensionMatch = re.match(dimensions_label);
|
QRegularExpressionMatch dimensionMatch = re.match(dimensions_label);
|
||||||
if (dimensionMatch.hasMatch()) {
|
QRegularExpressionMatch oamTablesMatch = re.match(subsprites_label);
|
||||||
QRegularExpressionMatch oamTablesMatch = re.match(subsprites_label);
|
if (oamTablesMatch.hasMatch()) {
|
||||||
if (oamTablesMatch.hasMatch()) {
|
spriteWidth = oamTablesMatch.captured(1).toInt();
|
||||||
spriteWidth = dimensionMatch.captured(1).toInt();
|
spriteHeight = oamTablesMatch.captured(2).toInt();
|
||||||
spriteHeight = dimensionMatch.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);
|
object->setPixmapFromSpritesheet(spritesheet, spriteWidth, spriteHeight, object->frame, object->hFlip);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue