Preserve import/export path in file dialogs
This commit is contained in:
parent
3a4ce68232
commit
f507b3e8a3
6 changed files with 30 additions and 13 deletions
|
@ -10,6 +10,9 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
||||||
### Added
|
### Added
|
||||||
- Add `setScale` to the scripting API.
|
- Add `setScale` to the scripting API.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- The last-used directory is now preserved in import/export file dialogs.
|
||||||
|
|
||||||
## [5.0.0] - 2022-10-30
|
## [5.0.0] - 2022-10-30
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
- Proper support for pokefirered's clone objects was added, which requires the changes made in [pokefirered/#484](https://github.com/pret/pokefirered/pull/484).
|
- Proper support for pokefirered's clone objects was added, which requires the changes made in [pokefirered/#484](https://github.com/pret/pokefirered/pull/484).
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
QFileSystemWatcher fileWatcher;
|
QFileSystemWatcher fileWatcher;
|
||||||
QMap<QString, qint64> modifiedFileTimestamps;
|
QMap<QString, qint64> modifiedFileTimestamps;
|
||||||
bool usingAsmTilesets;
|
bool usingAsmTilesets;
|
||||||
|
QString importExportPath;
|
||||||
|
|
||||||
const QPixmap entitiesPixmap = QPixmap(":/images/Entities_16x16.png");
|
const QPixmap entitiesPixmap = QPixmap(":/images/Entities_16x16.png");
|
||||||
|
|
||||||
|
@ -213,6 +214,8 @@ public:
|
||||||
QString getDefaultPrimaryTilesetLabel();
|
QString getDefaultPrimaryTilesetLabel();
|
||||||
QString getDefaultSecondaryTilesetLabel();
|
QString getDefaultSecondaryTilesetLabel();
|
||||||
|
|
||||||
|
void setImportExportPath(QString filename);
|
||||||
|
|
||||||
static int getNumTilesPrimary();
|
static int getNumTilesPrimary();
|
||||||
static int getNumTilesTotal();
|
static int getNumTilesTotal();
|
||||||
static int getNumMetatilesPrimary();
|
static int getNumMetatilesPrimary();
|
||||||
|
|
|
@ -91,6 +91,7 @@ void Project::initSignals() {
|
||||||
|
|
||||||
void Project::set_root(QString dir) {
|
void Project::set_root(QString dir) {
|
||||||
this->root = dir;
|
this->root = dir;
|
||||||
|
this->importExportPath = dir;
|
||||||
this->parser.set_root(dir);
|
this->parser.set_root(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2608,3 +2609,8 @@ int Project::getMaxObjectEvents()
|
||||||
{
|
{
|
||||||
return Project::max_object_events;
|
return Project::max_object_events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Project::setImportExportPath(QString filename)
|
||||||
|
{
|
||||||
|
this->importExportPath = QFileInfo(filename).absolutePath();
|
||||||
|
}
|
||||||
|
|
|
@ -64,12 +64,13 @@ void MapImageExporter::saveImage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString defaultFilepath = QString("%1/%2.%3")
|
QString defaultFilepath = QString("%1/%2.%3")
|
||||||
.arg(editor->project->root)
|
.arg(editor->project->importExportPath)
|
||||||
.arg(defaultFilename)
|
.arg(defaultFilename)
|
||||||
.arg(this->mode == ImageExporterMode::Timelapse ? "gif" : "png");
|
.arg(this->mode == ImageExporterMode::Timelapse ? "gif" : "png");
|
||||||
QString filter = this->mode == ImageExporterMode::Timelapse ? "Image Files (*.gif)" : "Image Files (*.png *.jpg *.bmp)";
|
QString filter = this->mode == ImageExporterMode::Timelapse ? "Image Files (*.gif)" : "Image Files (*.png *.jpg *.bmp)";
|
||||||
QString filepath = QFileDialog::getSaveFileName(this, title, defaultFilepath, filter);
|
QString filepath = QFileDialog::getSaveFileName(this, title, defaultFilepath, filter);
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
|
editor->project->setImportExportPath(filepath);
|
||||||
switch (this->mode) {
|
switch (this->mode) {
|
||||||
case ImageExporterMode::Normal:
|
case ImageExporterMode::Normal:
|
||||||
this->preview.save(filepath);
|
this->preview.save(filepath);
|
||||||
|
|
|
@ -384,12 +384,12 @@ void PaletteEditor::on_actionImport_Palette_triggered()
|
||||||
QString filepath = QFileDialog::getOpenFileName(
|
QString filepath = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
QString("Import Tileset Palette"),
|
QString("Import Tileset Palette"),
|
||||||
this->project->root,
|
this->project->importExportPath,
|
||||||
"Palette Files (*.pal *.act *tpl *gpl)");
|
"Palette Files (*.pal *.act *tpl *gpl)");
|
||||||
if (filepath.isEmpty()) {
|
if (filepath.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this->project->setImportExportPath(filepath);
|
||||||
bool error = false;
|
bool error = false;
|
||||||
QList<QRgb> palette = PaletteUtil::parse(filepath, &error);
|
QList<QRgb> palette = PaletteUtil::parse(filepath, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
|
@ -620,12 +620,12 @@ void TilesetEditor::importTilesetTiles(Tileset *tileset, bool primary) {
|
||||||
QString filepath = QFileDialog::getOpenFileName(
|
QString filepath = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
QString("Import %1 Tileset Tiles Image").arg(descriptorCaps),
|
QString("Import %1 Tileset Tiles Image").arg(descriptorCaps),
|
||||||
this->project->root,
|
this->project->importExportPath,
|
||||||
"Image Files (*.png *.bmp *.jpg *.dib)");
|
"Image Files (*.png *.bmp *.jpg *.dib)");
|
||||||
if (filepath.isEmpty()) {
|
if (filepath.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this->project->setImportExportPath(filepath);
|
||||||
logInfo(QString("Importing %1 tileset tiles '%2'").arg(descriptor).arg(filepath));
|
logInfo(QString("Importing %1 tileset tiles '%2'").arg(descriptor).arg(filepath));
|
||||||
|
|
||||||
// Read image data from buffer so that the built-in QImage doesn't try to detect file format
|
// Read image data from buffer so that the built-in QImage doesn't try to detect file format
|
||||||
|
@ -681,12 +681,12 @@ void TilesetEditor::importTilesetTiles(Tileset *tileset, bool primary) {
|
||||||
QString filepath = QFileDialog::getOpenFileName(
|
QString filepath = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
QString("Select Palette for Tiles Image").arg(descriptorCaps),
|
QString("Select Palette for Tiles Image").arg(descriptorCaps),
|
||||||
this->project->root,
|
this->project->importExportPath,
|
||||||
"Palette Files (*.pal *.act *tpl *gpl)");
|
"Palette Files (*.pal *.act *tpl *gpl)");
|
||||||
if (filepath.isEmpty()) {
|
if (filepath.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this->project->setImportExportPath(filepath);
|
||||||
bool error = false;
|
bool error = false;
|
||||||
QList<QRgb> palette = PaletteUtil::parse(filepath, &error);
|
QList<QRgb> palette = PaletteUtil::parse(filepath, &error);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -916,9 +916,10 @@ void TilesetEditor::pasteMetatile(const Metatile * toPaste)
|
||||||
void TilesetEditor::on_actionExport_Primary_Tiles_Image_triggered()
|
void TilesetEditor::on_actionExport_Primary_Tiles_Image_triggered()
|
||||||
{
|
{
|
||||||
QString defaultName = QString("%1_Tiles_Pal%2").arg(this->primaryTileset->name).arg(this->paletteId);
|
QString defaultName = QString("%1_Tiles_Pal%2").arg(this->primaryTileset->name).arg(this->paletteId);
|
||||||
QString defaultFilepath = QString("%1/%2.png").arg(this->project->root).arg(defaultName);
|
QString defaultFilepath = QString("%1/%2.png").arg(this->project->importExportPath).arg(defaultName);
|
||||||
QString filepath = QFileDialog::getSaveFileName(this, "Export Primary Tiles Image", defaultFilepath, "Image Files (*.png)");
|
QString filepath = QFileDialog::getSaveFileName(this, "Export Primary Tiles Image", defaultFilepath, "Image Files (*.png)");
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
|
this->project->setImportExportPath(filepath);
|
||||||
QImage image = this->tileSelector->buildPrimaryTilesIndexedImage();
|
QImage image = this->tileSelector->buildPrimaryTilesIndexedImage();
|
||||||
exportIndexed4BPPPng(image, filepath);
|
exportIndexed4BPPPng(image, filepath);
|
||||||
}
|
}
|
||||||
|
@ -927,9 +928,10 @@ void TilesetEditor::on_actionExport_Primary_Tiles_Image_triggered()
|
||||||
void TilesetEditor::on_actionExport_Secondary_Tiles_Image_triggered()
|
void TilesetEditor::on_actionExport_Secondary_Tiles_Image_triggered()
|
||||||
{
|
{
|
||||||
QString defaultName = QString("%1_Tiles_Pal%2").arg(this->secondaryTileset->name).arg(this->paletteId);
|
QString defaultName = QString("%1_Tiles_Pal%2").arg(this->secondaryTileset->name).arg(this->paletteId);
|
||||||
QString defaultFilepath = QString("%1/%2.png").arg(this->project->root).arg(defaultName);
|
QString defaultFilepath = QString("%1/%2.png").arg(this->project->importExportPath).arg(defaultName);
|
||||||
QString filepath = QFileDialog::getSaveFileName(this, "Export Secondary Tiles Image", defaultFilepath, "Image Files (*.png)");
|
QString filepath = QFileDialog::getSaveFileName(this, "Export Secondary Tiles Image", defaultFilepath, "Image Files (*.png)");
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
|
this->project->setImportExportPath(filepath);
|
||||||
QImage image = this->tileSelector->buildSecondaryTilesIndexedImage();
|
QImage image = this->tileSelector->buildSecondaryTilesIndexedImage();
|
||||||
exportIndexed4BPPPng(image, filepath);
|
exportIndexed4BPPPng(image, filepath);
|
||||||
}
|
}
|
||||||
|
@ -938,9 +940,10 @@ void TilesetEditor::on_actionExport_Secondary_Tiles_Image_triggered()
|
||||||
void TilesetEditor::on_actionExport_Primary_Metatiles_Image_triggered()
|
void TilesetEditor::on_actionExport_Primary_Metatiles_Image_triggered()
|
||||||
{
|
{
|
||||||
QString defaultName = QString("%1_Metatiles").arg(this->primaryTileset->name);
|
QString defaultName = QString("%1_Metatiles").arg(this->primaryTileset->name);
|
||||||
QString defaultFilepath = QString("%1/%2.png").arg(this->project->root).arg(defaultName);
|
QString defaultFilepath = QString("%1/%2.png").arg(this->project->importExportPath).arg(defaultName);
|
||||||
QString filepath = QFileDialog::getSaveFileName(this, "Export Primary Metatiles Image", defaultFilepath, "Image Files (*.png)");
|
QString filepath = QFileDialog::getSaveFileName(this, "Export Primary Metatiles Image", defaultFilepath, "Image Files (*.png)");
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
|
this->project->setImportExportPath(filepath);
|
||||||
QImage image = this->metatileSelector->buildPrimaryMetatilesImage();
|
QImage image = this->metatileSelector->buildPrimaryMetatilesImage();
|
||||||
image.save(filepath, "PNG");
|
image.save(filepath, "PNG");
|
||||||
}
|
}
|
||||||
|
@ -949,9 +952,10 @@ void TilesetEditor::on_actionExport_Primary_Metatiles_Image_triggered()
|
||||||
void TilesetEditor::on_actionExport_Secondary_Metatiles_Image_triggered()
|
void TilesetEditor::on_actionExport_Secondary_Metatiles_Image_triggered()
|
||||||
{
|
{
|
||||||
QString defaultName = QString("%1_Metatiles").arg(this->secondaryTileset->name);
|
QString defaultName = QString("%1_Metatiles").arg(this->secondaryTileset->name);
|
||||||
QString defaultFilepath = QString("%1/%2.png").arg(this->project->root).arg(defaultName);
|
QString defaultFilepath = QString("%1/%2.png").arg(this->project->importExportPath).arg(defaultName);
|
||||||
QString filepath = QFileDialog::getSaveFileName(this, "Export Secondary Metatiles Image", defaultFilepath, "Image Files (*.png)");
|
QString filepath = QFileDialog::getSaveFileName(this, "Export Secondary Metatiles Image", defaultFilepath, "Image Files (*.png)");
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
|
this->project->setImportExportPath(filepath);
|
||||||
QImage image = this->metatileSelector->buildSecondaryMetatilesImage();
|
QImage image = this->metatileSelector->buildSecondaryMetatilesImage();
|
||||||
image.save(filepath, "PNG");
|
image.save(filepath, "PNG");
|
||||||
}
|
}
|
||||||
|
@ -975,12 +979,12 @@ void TilesetEditor::importTilesetMetatiles(Tileset *tileset, bool primary)
|
||||||
QString filepath = QFileDialog::getOpenFileName(
|
QString filepath = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
QString("Import %1 Tileset Metatiles from Advance Map 1.92").arg(descriptorCaps),
|
QString("Import %1 Tileset Metatiles from Advance Map 1.92").arg(descriptorCaps),
|
||||||
this->project->root,
|
this->project->importExportPath,
|
||||||
"Advance Map 1.92 Metatile Files (*.bvd)");
|
"Advance Map 1.92 Metatile Files (*.bvd)");
|
||||||
if (filepath.isEmpty()) {
|
if (filepath.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this->project->setImportExportPath(filepath);
|
||||||
bool error = false;
|
bool error = false;
|
||||||
QList<Metatile*> metatiles = MetatileParser::parse(filepath, &error, primary);
|
QList<Metatile*> metatiles = MetatileParser::parse(filepath, &error, primary);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
Loading…
Reference in a new issue