Ignore invalid metatiles in tileset editor when syncing

This commit is contained in:
GriffinR 2020-07-07 17:53:22 -04:00 committed by garak
parent b04638b4cf
commit 0e04d2250b
2 changed files with 6 additions and 4 deletions

View file

@ -106,9 +106,11 @@ void TilesetEditor::init(Project *project, Map *map) {
}
void TilesetEditor::selectMetatile(uint16_t metatileId) {
this->metatileSelector->select(metatileId);
QPoint pos = this->metatileSelector->getMetatileIdCoordsOnWidget(metatileId);
this->ui->scrollArea_Metatiles->ensureVisible(pos.x(), pos.y());
if (Tileset::metatileIsValid(metatileId, this->primaryTileset, this->secondaryTileset)) {
this->metatileSelector->select(metatileId);
QPoint pos = this->metatileSelector->getMetatileIdCoordsOnWidget(metatileId);
this->ui->scrollArea_Metatiles->ensureVisible(pos.x(), pos.y());
}
}
void TilesetEditor::setMap(Map *map) {

View file

@ -62,7 +62,7 @@ void TilesetEditorMetatileSelector::updateSelectedMetatile() {
if (Tileset::metatileIsValid(metatileId, this->primaryTileset, this->secondaryTileset))
this->selectedMetatile = metatileId;
else
this->selectedMetatile = 0;
this->selectedMetatile = Project::getNumMetatilesPrimary() + this->secondaryTileset->metatiles->length() - 1;
emit selectedMetatileChanged(this->selectedMetatile);
}