Fix label history being ignored if metatile didn't change

This commit is contained in:
GriffinR 2023-02-17 15:40:10 -05:00
parent 465d51f4a0
commit 096c26b85a

View file

@ -842,15 +842,16 @@ void TilesetEditor::onPaletteEditorChangedPalette(int paletteId) {
this->on_spinBox_paletteSelector_valueChanged(paletteId);
}
bool TilesetEditor::replaceMetatile(uint16_t metatileId, const Metatile * src, QString label)
bool TilesetEditor::replaceMetatile(uint16_t metatileId, const Metatile * src, QString newLabel)
{
Metatile * dest = Tileset::getMetatile(metatileId, this->primaryTileset, this->secondaryTileset);
if (!dest || !src || *dest == *src)
QString oldLabel = Tileset::getOwnedMetatileLabel(metatileId, this->primaryTileset, this->secondaryTileset);
if (!dest || !src || (*dest == *src && oldLabel == newLabel))
return false;
Tileset::setMetatileLabel(metatileId, label, this->primaryTileset, this->secondaryTileset);
Tileset::setMetatileLabel(metatileId, newLabel, this->primaryTileset, this->secondaryTileset);
if (metatileId == this->getSelectedMetatileId())
this->ui->lineEdit_metatileLabel->setText(label);
this->ui->lineEdit_metatileLabel->setText(newLabel);
this->metatile = dest;
*this->metatile = *src;