Warn when closing with unsaved encounter changes

This commit is contained in:
GriffinR 2020-05-11 10:45:11 -04:00 committed by huderlem
parent fcb320bd79
commit 53ba6f5ab9
5 changed files with 14 additions and 0 deletions

View file

@ -194,6 +194,7 @@ signals:
void selectedObjectsChanged();
void loadMapRequested(QString, QString);
void tilesetChanged(QString);
void wildMonDataChanged();
void warpEventDoubleClicked(QString mapName, QString warpNum);
void currentMetatilesSelectionChanged();
void wheelZoom(int delta);

View file

@ -125,6 +125,7 @@ private slots:
void onMapChanged(Map *map);
void onMapNeedsRedrawing();
void onTilesetsSaved(QString, QString);
void onWildMonDataChanged();
void openNewMapPopupWindow(int, QVariant);
void onNewMapCreated();

View file

@ -355,6 +355,7 @@ void Editor::addNewWildMonGroup(QWidget *window) {
tabIndex++;
}
saveEncounterTabData();
emit wildMonDataChanged();
}
}
@ -586,6 +587,7 @@ void Editor::configureEncounterJSON(QWidget *window) {
// Re-draw the tab accordingly.
displayWildMonTables();
emit wildMonDataChanged();
}
}

View file

@ -115,6 +115,7 @@ void MainWindow::initEditor() {
connect(this->editor, SIGNAL(tilesetChanged(QString)), this, SLOT(onTilesetChanged(QString)));
connect(this->editor, SIGNAL(warpEventDoubleClicked(QString,QString)), this, SLOT(openWarpMap(QString,QString)));
connect(this->editor, SIGNAL(currentMetatilesSelectionChanged()), this, SLOT(currentMetatilesSelectionChanged()));
connect(this->editor, SIGNAL(wildMonDataChanged()), this, SLOT(onWildMonDataChanged()));
connect(this->editor, &Editor::wheelZoom, this, &MainWindow::scaleMapView);
this->loadUserSettings();
@ -2182,6 +2183,10 @@ void MainWindow::onTilesetsSaved(QString primaryTilesetLabel, QString secondaryT
this->editor->updateSecondaryTileset(secondaryTilesetLabel, true);
}
void MainWindow::onWildMonDataChanged() {
projectHasUnsavedChanges = true;
}
void MainWindow::on_action_Export_Map_Image_triggered() {
showExportMapImageWindow(false);
}

View file

@ -48,6 +48,7 @@ void MonTabWidget::askActivateTab(int tabIndex, QPoint menuPos) {
populateTab(tabIndex, getDefaultMonInfo(editor->project->wildMonFields.at(tabIndex)), tabText);
editor->saveEncounterTabData();
setCurrentIndex(tabIndex);
emit editor->wildMonDataChanged();
});
contextMenu.addAction(&actionActivateTab);
contextMenu.exec(mapToGlobal(menuPos));
@ -97,6 +98,7 @@ void MonTabWidget::populateTab(int tabIndex, WildMonInfo monInfo, QString fieldN
encounterRate->setValue(monInfo.encounterRate);
connect(encounterRate, QOverload<int>::of(&QSpinBox::valueChanged), [this](int) {
editor->saveEncounterTabData();
emit editor->wildMonDataChanged();
});
encounterLayout->addWidget(encounterRate);
encounterFrame->setLayout(encounterLayout);
@ -125,6 +127,7 @@ void MonTabWidget::createSpeciesTableRow(QTableWidget *table, WildPokemon mon, i
QObject::connect(monSelector, &QComboBox::currentTextChanged, [=](QString newSpecies) {
QPixmap monIcon = QPixmap(editor->project->speciesToIconPath.value(newSpecies)).copy(0, 0, 32, 32);
monLabel->setPixmap(monIcon);
emit editor->wildMonDataChanged();
if (!monIcon.isNull()) editor->saveEncounterTabData();
});
@ -141,10 +144,12 @@ void MonTabWidget::createSpeciesTableRow(QTableWidget *table, WildPokemon mon, i
connect(minLevel, QOverload<int>::of(&QSpinBox::valueChanged), [maxLevel, this](int min) {
maxLevel->setMinimum(min);
editor->saveEncounterTabData();
emit editor->wildMonDataChanged();
});
connect(maxLevel, QOverload<int>::of(&QSpinBox::valueChanged), [maxLevel, this](int) {
editor->saveEncounterTabData();
emit editor->wildMonDataChanged();
});
int fieldIndex = 0;