Skip to content

Commit

Permalink
LevelCelView: Fix frame not being displayed properly in Tile/Megatile
Browse files Browse the repository at this point in the history
This patch fixes the incorrect behaviour where we click on tile/megatile,
selecting a certain frame, and then after pressing
"next/previous/first/last frame button" frame in the frame preview is not the
same one displayed in tile/megatile view.

This is caused by the celFrameIndices QList in D1Min class, which holds
frame indices starting from 1, not 0. This patch adds 1 to all the frame
indices when they are selected from QList in D1Min class, so the offset
is the same one as it is in LevelCelView.
  • Loading branch information
tetektoza authored and AJenbo committed Nov 8, 2023
1 parent ffb5b1a commit 0aea247
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/levelcelview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ void LevelCelView::on_firstFrameButton_clicked()
this->currentFrameIndex = 0;

if (this->mode == TILESET_MODE::SUBTILE) {
this->min->getCelFrameIndices(this->currentSubtileIndex)[this->editIndex] = this->currentFrameIndex;
this->min->getCelFrameIndices(this->currentSubtileIndex)[this->editIndex] = this->currentFrameIndex + 1;
} else {
this->mode = TILESET_MODE::FREE;
this->update();
Expand All @@ -1593,7 +1593,7 @@ void LevelCelView::on_previousFrameButton_clicked()
this->currentFrameIndex = std::max(0, this->gfx->getFrameCount() - 1);

if (this->mode == TILESET_MODE::SUBTILE) {
this->min->getCelFrameIndices(this->currentSubtileIndex)[this->editIndex] = this->currentFrameIndex;
this->min->getCelFrameIndices(this->currentSubtileIndex)[this->editIndex] = this->currentFrameIndex + 1;
} else {
this->mode = TILESET_MODE::FREE;
this->update();
Expand All @@ -1610,7 +1610,7 @@ void LevelCelView::on_nextFrameButton_clicked()
this->currentFrameIndex = 0;

if (this->mode == TILESET_MODE::SUBTILE) {
this->min->getCelFrameIndices(this->currentSubtileIndex)[this->editIndex] = this->currentFrameIndex;
this->min->getCelFrameIndices(this->currentSubtileIndex)[this->editIndex] = this->currentFrameIndex + 1;
} else {
this->mode = TILESET_MODE::FREE;
this->update();
Expand All @@ -1624,7 +1624,7 @@ void LevelCelView::on_lastFrameButton_clicked()
this->currentFrameIndex = std::max(0, this->gfx->getFrameCount() - 1);

if (this->mode == TILESET_MODE::SUBTILE) {
this->min->getCelFrameIndices(this->currentSubtileIndex)[this->editIndex] = this->currentFrameIndex;
this->min->getCelFrameIndices(this->currentSubtileIndex)[this->editIndex] = this->currentFrameIndex + 1;
} else {
this->mode = TILESET_MODE::FREE;
this->update();
Expand Down

0 comments on commit 0aea247

Please sign in to comment.