Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly render empty CEL frame placeholder in LevelCelView #148

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions source/views/levelcelview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,36 +1590,40 @@ void LevelCelView::displayFrame()
this->tabTileWidget->update();
this->tabFrameWidget->update();

// Building a gray background of the width/height of the CEL frame
QImage celFrameBackground = QImage(celFrame.width(), celFrame.height(), QImage::Format_ARGB32);
celFrameBackground.fill(Qt::gray);
// Building a gray background of the width/height of the MIN subtile
QImage subtileBackground = QImage(subtile.width(), subtile.height(), QImage::Format_ARGB32);
subtileBackground.fill(Qt::gray);
// Building a gray background of the width/height of the MIN subtile
QImage tileBackground = QImage(tile.width(), tile.height(), QImage::Format_ARGB32);
tileBackground.fill(Qt::gray);

// Resize the scene rectangle to include some padding around the CEL frame
// the MIN subtile and the TIL tile
this->celScene->setSceneRect(0, 0,
celFrame.width() + subtile.width() + tile.width() + CEL_SCENE_SPACING * 4,
tile.height() + CEL_SCENE_SPACING * 2);

// Add the backgrond and CEL frame while aligning it in the center
this->celScene->addPixmap(QPixmap::fromImage(celFrameBackground))
->setPos(CEL_SCENE_SPACING, CEL_SCENE_SPACING);
int celFrameWidth = this->gfx->getFrameWidth(this->currentFrameIndex);
int celFrameHeight = this->gfx->getFrameHeight(this->currentFrameIndex);
if (celFrameWidth > 0 && celFrameHeight > 0) {
// Building a gray background of the width/height of the CEL frame
QImage celFrameBackground = QImage(celFrame.width(), celFrame.height(), QImage::Format_ARGB32);
celFrameBackground.fill(Qt::gray);

// Add the background behind the CEL frame
this->celScene->addPixmap(QPixmap::fromImage(celFrameBackground))
->setPos(CEL_SCENE_SPACING, CEL_SCENE_SPACING);
}

// Add the CEL frame while aligning it in the center
this->celScene->addPixmap(QPixmap::fromImage(celFrame))
->setPos(CEL_SCENE_SPACING, CEL_SCENE_SPACING);

// Set current frame width and height
this->ui->celFrameWidthEdit->setText(QString::number(celFrame.width()) + " px");
this->ui->celFrameHeightEdit->setText(QString::number(celFrame.height()) + " px");
this->ui->celFrameWidthEdit->setText(QString::number(celFrameWidth) + " px");
this->ui->celFrameHeightEdit->setText(QString::number(celFrameHeight) + " px");

// Set current frame text
this->ui->frameIndexEdit->setText(
QString::number(this->gfx->getFrameCount() != 0 ? this->currentFrameIndex + 1 : 0));

// Building a gray background of the width/height of the MIN subtile
QImage subtileBackground = QImage(subtile.width(), subtile.height(), QImage::Format_ARGB32);
subtileBackground.fill(Qt::gray);

// MIN
minPosX = celFrame.width() + CEL_SCENE_SPACING * 2;
this->celScene->addPixmap(QPixmap::fromImage(subtileBackground))
Expand All @@ -1637,6 +1641,10 @@ void LevelCelView::displayFrame()
this->ui->subtileIndexEdit->setText(
QString::number(this->min->getSubtileCount() != 0 ? this->currentSubtileIndex + 1 : 0));

// Building a gray background of the width/height of the TIL tile
QImage tileBackground = QImage(tile.width(), tile.height(), QImage::Format_ARGB32);
tileBackground.fill(Qt::gray);

// TIL
tilPosX = minPosX + subtile.width() + CEL_SCENE_SPACING;
this->celScene->addPixmap(QPixmap::fromImage(tileBackground))
Expand Down
Loading