fix rme close with unsaved changes

This commit is contained in:
garak 2019-08-19 10:21:40 -04:00 committed by huderlem
parent bb7e15785c
commit 11d6d35b68
3 changed files with 35 additions and 14 deletions

View file

@ -120,6 +120,9 @@ private:
QString region_map_layout_bin_path;
QString city_map_tiles_path;
bool region_map_png_needs_saving = false;
bool city_map_png_needs_saving = false;
int img_index_(int x, int y);
int layout_index_(int x, int y);
};

View file

@ -40,6 +40,7 @@ void RegionMap::save() {
}
void RegionMap::saveTileImages() {
if (region_map_png_needs_saving) {
QFile backgroundTileFile(pngPath());
if (backgroundTileFile.open(QIODevice::ReadOnly)) {
QByteArray imageData = backgroundTileFile.readAll();
@ -50,6 +51,9 @@ void RegionMap::saveTileImages() {
PaletteUtil parser;
parser.writeJASC(project->root + "/graphics/pokenav/region_map.pal", pngImage.colorTable(), 0x70, 0x20);
}
region_map_png_needs_saving = false;
}
if (city_map_png_needs_saving) {
QFile cityTileFile(cityTilesPath());
if (cityTileFile.open(QIODevice::ReadOnly)) {
QByteArray imageData = cityTileFile.readAll();
@ -57,6 +61,8 @@ void RegionMap::saveTileImages() {
this->city_map_tiles_path = project->root + "/graphics/pokenav/zoom_tiles.png";
cityTilesImage.save(cityTilesPath());
}
city_map_png_needs_saving = false;
}
}
void RegionMap::readBkgImgBin() {
@ -346,6 +352,7 @@ QString RegionMap::pngPath() {
void RegionMap::setTemporaryPngPath(QString path) {
this->region_map_png_path = path;
this->region_map_png_needs_saving = true;
}
QString RegionMap::cityTilesPath() {
@ -354,6 +361,7 @@ QString RegionMap::cityTilesPath() {
void RegionMap::setTemporaryCityTilesPath(QString path) {
this->city_map_tiles_path = path;
this->city_map_png_needs_saving = true;
}
// From x, y of image.

View file

@ -225,6 +225,11 @@ void RegionMapEditor::updateRegionMapEntryOptions(QString section) {
this->ui->spinBox_RM_Entry_width->setEnabled(enabled);
this->ui->spinBox_RM_Entry_height->setEnabled(enabled);
this->ui->spinBox_RM_Entry_x->blockSignals(true);
this->ui->spinBox_RM_Entry_y->blockSignals(true);
this->ui->spinBox_RM_Entry_width->blockSignals(true);
this->ui->spinBox_RM_Entry_height->blockSignals(true);
this->ui->comboBox_RM_Entry_MapSection->setCurrentText(section);
this->activeEntry = section;
this->region_map_entries_item->currentSection = section;
@ -233,6 +238,11 @@ void RegionMapEditor::updateRegionMapEntryOptions(QString section) {
this->ui->spinBox_RM_Entry_y->setValue(entry.y);
this->ui->spinBox_RM_Entry_width->setValue(entry.width);
this->ui->spinBox_RM_Entry_height->setValue(entry.height);
this->ui->spinBox_RM_Entry_x->blockSignals(false);
this->ui->spinBox_RM_Entry_y->blockSignals(false);
this->ui->spinBox_RM_Entry_width->blockSignals(false);
this->ui->spinBox_RM_Entry_height->blockSignals(false);
}
void RegionMapEditor::displayRegionMapTileSelector() {