mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-17 13:26:01 -05:00
Move metatile labels to tilesets
This commit is contained in:
@@ -598,32 +598,30 @@ Metatile * MainWindow::getMetatile(int metatileId) {
|
||||
}
|
||||
|
||||
QString MainWindow::getMetatileLabel(int metatileId) {
|
||||
Metatile * metatile = this->getMetatile(metatileId);
|
||||
if (!metatile || metatile->label.size() == 0)
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout)
|
||||
return QString();
|
||||
return metatile->label;
|
||||
return Tileset::getMetatileLabel(metatileId, this->editor->map->layout->tileset_primary, this->editor->map->layout->tileset_secondary);
|
||||
}
|
||||
|
||||
void MainWindow::setMetatileLabel(int metatileId, QString label) {
|
||||
Metatile * metatile = this->getMetatile(metatileId);
|
||||
if (!metatile)
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout)
|
||||
return;
|
||||
|
||||
static const QRegularExpression expression("[_A-Za-z0-9]*$");
|
||||
QRegularExpressionValidator validator(expression);
|
||||
int pos = 0;
|
||||
if (validator.validate(label, pos) != QValidator::Acceptable) {
|
||||
logError(QString("Invalid metatile label %1").arg(label));
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->tilesetEditor && this->tilesetEditor->getSelectedMetatileId() == metatileId) {
|
||||
// If the Tileset Editor is opened on this metatile we need to update the text box
|
||||
if (this->tilesetEditor && this->tilesetEditor->getSelectedMetatileId() == metatileId){
|
||||
this->tilesetEditor->setMetatileLabel(label);
|
||||
} else if (metatile->label != label) {
|
||||
metatile->label = label;
|
||||
if (this->editor->project)
|
||||
this->editor->project->saveTilesetMetatileLabels(this->editor->map->layout->tileset_primary, this->editor->map->layout->tileset_secondary);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Tileset::setMetatileLabel(metatileId, label, this->editor->map->layout->tileset_primary, this->editor->map->layout->tileset_secondary)) {
|
||||
logError("Failed to set metatile label. Must be a valid metatile id and a label containing only letters, numbers, and underscores.");
|
||||
return;
|
||||
}
|
||||
|
||||
// The user may not have the Tileset Editor open. This forcefully saves the change for them.
|
||||
// If they do have the Tileset Editor open, this has the unintended side effect of saving other unsaved label changes.
|
||||
if (this->editor->project)
|
||||
this->editor->project->saveTilesetMetatileLabels(this->editor->map->layout->tileset_primary, this->editor->map->layout->tileset_secondary);
|
||||
}
|
||||
|
||||
int MainWindow::getMetatileLayerType(int metatileId) {
|
||||
|
||||
Reference in New Issue
Block a user