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 region_map_layout_bin_path;
QString city_map_tiles_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 img_index_(int x, int y);
int layout_index_(int x, int y); int layout_index_(int x, int y);
}; };

View file

@ -40,22 +40,28 @@ void RegionMap::save() {
} }
void RegionMap::saveTileImages() { void RegionMap::saveTileImages() {
QFile backgroundTileFile(pngPath()); if (region_map_png_needs_saving) {
if (backgroundTileFile.open(QIODevice::ReadOnly)) { QFile backgroundTileFile(pngPath());
QByteArray imageData = backgroundTileFile.readAll(); if (backgroundTileFile.open(QIODevice::ReadOnly)) {
QImage pngImage = QImage::fromData(imageData); QByteArray imageData = backgroundTileFile.readAll();
this->region_map_png_path = project->root + "/graphics/pokenav/region_map.png"; QImage pngImage = QImage::fromData(imageData);
pngImage.save(pngPath()); this->region_map_png_path = project->root + "/graphics/pokenav/region_map.png";
pngImage.save(pngPath());
PaletteUtil parser; PaletteUtil parser;
parser.writeJASC(project->root + "/graphics/pokenav/region_map.pal", pngImage.colorTable(), 0x70, 0x20); parser.writeJASC(project->root + "/graphics/pokenav/region_map.pal", pngImage.colorTable(), 0x70, 0x20);
}
region_map_png_needs_saving = false;
} }
QFile cityTileFile(cityTilesPath()); if (city_map_png_needs_saving) {
if (cityTileFile.open(QIODevice::ReadOnly)) { QFile cityTileFile(cityTilesPath());
QByteArray imageData = cityTileFile.readAll(); if (cityTileFile.open(QIODevice::ReadOnly)) {
QImage cityTilesImage = QImage::fromData(imageData); QByteArray imageData = cityTileFile.readAll();
this->city_map_tiles_path = project->root + "/graphics/pokenav/zoom_tiles.png"; QImage cityTilesImage = QImage::fromData(imageData);
cityTilesImage.save(cityTilesPath()); this->city_map_tiles_path = project->root + "/graphics/pokenav/zoom_tiles.png";
cityTilesImage.save(cityTilesPath());
}
city_map_png_needs_saving = false;
} }
} }
@ -346,6 +352,7 @@ QString RegionMap::pngPath() {
void RegionMap::setTemporaryPngPath(QString path) { void RegionMap::setTemporaryPngPath(QString path) {
this->region_map_png_path = path; this->region_map_png_path = path;
this->region_map_png_needs_saving = true;
} }
QString RegionMap::cityTilesPath() { QString RegionMap::cityTilesPath() {
@ -354,6 +361,7 @@ QString RegionMap::cityTilesPath() {
void RegionMap::setTemporaryCityTilesPath(QString path) { void RegionMap::setTemporaryCityTilesPath(QString path) {
this->city_map_tiles_path = path; this->city_map_tiles_path = path;
this->city_map_png_needs_saving = true;
} }
// From x, y of image. // 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_width->setEnabled(enabled);
this->ui->spinBox_RM_Entry_height->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->ui->comboBox_RM_Entry_MapSection->setCurrentText(section);
this->activeEntry = section; this->activeEntry = section;
this->region_map_entries_item->currentSection = 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_y->setValue(entry.y);
this->ui->spinBox_RM_Entry_width->setValue(entry.width); this->ui->spinBox_RM_Entry_width->setValue(entry.width);
this->ui->spinBox_RM_Entry_height->setValue(entry.height); 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() { void RegionMapEditor::displayRegionMapTileSelector() {