mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-29 03:16:51 -05:00
Open tileset editor with selected metatile
This commit is contained in:
@@ -2452,6 +2452,7 @@ void MainWindow::on_actionTileset_Editor_triggered()
|
||||
} else {
|
||||
this->tilesetEditor->activateWindow();
|
||||
}
|
||||
this->tilesetEditor->selectMetatile(this->editor->metatile_selector_item->getSelectedMetatiles()->at(0));
|
||||
}
|
||||
|
||||
void MainWindow::on_toolButton_ExpandAll_clicked()
|
||||
|
||||
@@ -105,6 +105,12 @@ void TilesetEditor::init(Project *project, QString primaryTilesetLabel, QString
|
||||
metatileHistory.push(commit);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
void TilesetEditor::setTilesets(QString primaryTilesetLabel, QString secondaryTilesetLabel) {
|
||||
delete this->primaryTileset;
|
||||
delete this->secondaryTileset;
|
||||
|
||||
@@ -117,3 +117,10 @@ QPoint TilesetEditorMetatileSelector::getMetatileIdCoords(uint16_t metatileId) {
|
||||
: metatileId - Project::getNumMetatilesPrimary() + this->primaryTileset->metatiles->length();
|
||||
return QPoint(index % this->numMetatilesWide, index / this->numMetatilesWide);
|
||||
}
|
||||
|
||||
QPoint TilesetEditorMetatileSelector::getMetatileIdCoordsOnWidget(uint16_t metatileId) {
|
||||
QPoint pos = getMetatileIdCoords(metatileId);
|
||||
pos.rx() = (pos.x() * this->cellWidth) + (this->cellWidth / 2);
|
||||
pos.ry() = (pos.y() * this->cellHeight) + (this->cellHeight / 2);
|
||||
return pos;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user