Fix reintroduction of issue fixed by 79e384ef76

This commit is contained in:
BigBahss 2020-08-29 11:15:15 -04:00 committed by garak
parent 6251da65b2
commit bc788b6caa

View file

@ -66,8 +66,14 @@ void MetatileSelector::setTilesets(Tileset *primaryTileset, Tileset *secondaryTi
this->primaryTileset = primaryTileset;
this->secondaryTileset = secondaryTileset;
if (!this->selectionIsValid()) {
if (this->externalSelection) {
this->select(0);
} else {
this->select(Project::getNumMetatilesPrimary() + this->secondaryTileset->metatiles->length() - 1);
} else if (!this->externalSelection) {
}
} else if (this->externalSelection) {
emit selectedMetatilesChanged();
} else {
updateSelectedMetatiles();
}
this->draw();
@ -153,6 +159,14 @@ void MetatileSelector::updateSelectedMetatiles() {
}
bool MetatileSelector::selectionIsValid() {
if (this->externalSelection) {
for (int i = 0; i < this->externalSelectedMetatiles->count(); ++i) {
int tileId = this->externalSelectedMetatiles->at(i);
if (!Tileset::metatileIsValid(tileId, this->primaryTileset, this->secondaryTileset))
return false;
}
return true;
} else {
QPoint origin = this->getSelectionStart();
QPoint dimensions = this->getSelectionDimensions();
for (int j = 0; j < dimensions.y(); j++) {
@ -163,6 +177,7 @@ bool MetatileSelector::selectionIsValid() {
}
return true;
}
}
uint16_t MetatileSelector::getMetatileId(int x, int y) {
int index = y * this->numMetatilesWide + x;