mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-10 01:45:34 -05:00
Unsaved changes prompt for tileset editor when switching tilesets or maps
This commit is contained in:
@@ -2248,9 +2248,23 @@ void MainWindow::onMapCacheCleared() {
|
||||
}
|
||||
|
||||
void MainWindow::onTilesetsSaved(QString primaryTilesetLabel, QString secondaryTilesetLabel) {
|
||||
this->editor->updatePrimaryTileset(primaryTilesetLabel, true);
|
||||
this->editor->updateSecondaryTileset(secondaryTilesetLabel, true);
|
||||
redrawMapScene();
|
||||
// If saved tilesets are currently in-use, update them and redraw
|
||||
// Otherwise overwrite the cache for the saved tileset
|
||||
bool updated = false;
|
||||
if (primaryTilesetLabel == this->editor->map->layout->tileset_primary_label) {
|
||||
this->editor->updatePrimaryTileset(primaryTilesetLabel, true);
|
||||
updated = true;
|
||||
} else {
|
||||
this->editor->project->getTileset(primaryTilesetLabel, true);
|
||||
}
|
||||
if (secondaryTilesetLabel == this->editor->map->layout->tileset_secondary_label) {
|
||||
this->editor->updateSecondaryTileset(secondaryTilesetLabel, true);
|
||||
updated = true;
|
||||
} else {
|
||||
this->editor->project->getTileset(secondaryTilesetLabel, true);
|
||||
}
|
||||
if (updated)
|
||||
redrawMapScene();
|
||||
}
|
||||
|
||||
void MainWindow::onWildMonDataChanged() {
|
||||
|
||||
@@ -116,6 +116,17 @@ void TilesetEditor::setMap(Map *map) {
|
||||
}
|
||||
|
||||
void TilesetEditor::setTilesets(QString primaryTilesetLabel, QString secondaryTilesetLabel) {
|
||||
if (this->hasUnsavedChanges) {
|
||||
QMessageBox::StandardButton result = QMessageBox::question(
|
||||
this,
|
||||
"porymap",
|
||||
"Tileset has been modified, save changes?",
|
||||
QMessageBox::No | QMessageBox::Yes,
|
||||
QMessageBox::Yes);
|
||||
if (result == QMessageBox::Yes)
|
||||
this->on_actionSave_Tileset_triggered();
|
||||
}
|
||||
this->hasUnsavedChanges = false;
|
||||
delete this->primaryTileset;
|
||||
delete this->secondaryTileset;
|
||||
Tileset *primaryTileset = project->getTileset(primaryTilesetLabel);
|
||||
|
||||
Reference in New Issue
Block a user