diff --git a/ui/dialogs/about/aboutdialog.ui b/ui/dialogs/about/aboutdialog.ui index a1d237c..4ffe75b 100644 --- a/ui/dialogs/about/aboutdialog.ui +++ b/ui/dialogs/about/aboutdialog.ui @@ -42,7 +42,7 @@ false - NDS Factory V1.2 + NDSFactory V1.2 Qt::AlignmentFlag::AlignCenter diff --git a/ui/dialogs/about/revision.h b/ui/dialogs/about/revision.h index 087233a..62dc2ff 100644 --- a/ui/dialogs/about/revision.h +++ b/ui/dialogs/about/revision.h @@ -1,6 +1,6 @@ #ifndef REVISION_H #define REVISION_H -#define GIT_COMMIT_HASH "a2739a9" +#define GIT_COMMIT_HASH "e2e53cb" #endif diff --git a/ui/models/ndsheadermodel.cpp b/ui/models/ndsheadermodel.cpp index 9c0d770..e57b9f7 100644 --- a/ui/models/ndsheadermodel.cpp +++ b/ui/models/ndsheadermodel.cpp @@ -151,7 +151,7 @@ bool NDSHeaderModel::setData(const QModelIndex &index, const QVariant &value, in case 37: ndsHeader->DebugRomAddr = static_cast(value.toString().toUInt(nullptr, 16)); break; case 38: ndsHeader->DebugSize = static_cast(value.toString().toUInt(nullptr, 16)); break; case 39: ndsHeader->DebugRamAddr = static_cast(value.toString().toUInt(nullptr, 16)); break; - case 40: QMessageBox::information(nullptr, tr("NDS Factory"), tr("FAT files address is automatically calculated based on Icon/Title address!")); break; + case 40: QMessageBox::information(nullptr, tr("NDSFactory"), tr("FAT files address is automatically calculated based on Icon/Title address!")); break; default: return false; } Q_EMIT this->dataChanged(index, index); diff --git a/ui/tabs/fattools/fattoolstabsignals.cpp b/ui/tabs/fattools/fattoolstabsignals.cpp index 76fe0cb..aa42101 100644 --- a/ui/tabs/fattools/fattoolstabsignals.cpp +++ b/ui/tabs/fattools/fattoolstabsignals.cpp @@ -2,6 +2,7 @@ #include #include "./../../mainwindow.h" #include "./../../ui_mainwindow.h" +#include "./../../utils/filepicker.h" void MainWindow::on_fatExtractorLoadFatDataBtn_clicked() { @@ -47,6 +48,8 @@ void MainWindow::on_fatExtractorLoadFntBtn_clicked() void MainWindow::on_fatExtractorExtractBtn_clicked() { + ui->fatExtractorExtractBtn->setEnabled(false); + QString dirPath = QFileDialog::getExistingDirectory( this, tr("Select Directory"), "", @@ -58,8 +61,10 @@ void MainWindow::on_fatExtractorExtractBtn_clicked() ui->fatExtractorFntPathEdt->text().toStdString(), ui->fatExtractorOriginalFatFilesAddrEdt->text().toUInt(nullptr, 16), dirPath.toStdString(), - ui->fatExtractorSaveFileIDsCbx->isChecked()) ? QMessageBox::information(this, tr("NDS Factory"), tr("FAT files extraction completed!")) - : QMessageBox::critical(this, tr("NDS Factory"), tr("Error extracting FAT files!")); + ui->fatExtractorSaveFileIDsCbx->isChecked()) ? QMessageBox::information(this, tr("NDSFactory"), tr("FAT files extraction completed!")) + : QMessageBox::critical(this, tr("NDSFactory"), tr("Error extracting FAT files!")); + + ui->fatExtractorExtractBtn->setEnabled(true); } @@ -71,38 +76,33 @@ void MainWindow::on_fatPatcherLoadFatBtn_clicked() "", "NDS Fat (*.bin)"); - if( !fatPath.isNull() ) - { - ui->fatPatcherFatPathEdt->setText(fatPath.toUtf8()); - } + if(!fatPath.isNull()) + ui->fatPatcherFatPathEdt->setText(fatPath.toUtf8()); } void MainWindow::on_fatPatcherPatchFatBtn_clicked() { + ui->fatPatcherPatchFatBtn->setEnabled(false); + uint32_t positionDiff = 0; uint32_t originalPos = ui->fatPatcherOriginalFatFilesAddrEdt->text().toUInt(nullptr, 16); uint32_t newPos = ui->fatPatcherNewFatFilesAddrEdt->text().toUInt(nullptr, 16); - QString dirPath = QFileDialog::getSaveFileName( - Q_NULLPTR, - "NDS FAT", - "fat.bin", - "Binary (*.bin)"); + QString dirPath = customSaveFileDialog("NDS FAT", + "fat.bin", + "Binary (*.bin)"); - if(dirPath.isNull()) + if (!dirPath.isNull()) { - return; + if(originalPos < newPos) + positionDiff = newPos - originalPos; + else + positionDiff = originalPos - newPos; + + patchFat(ui->fatPatcherFatPathEdt->text().toStdString(), positionDiff, dirPath.toStdString()) + ? QMessageBox::information(this, tr("NDSFactory"), tr("FAT patching completed!")) + : QMessageBox::critical(this, tr("NDSFactory"), tr("Error patching FAT!")); } - if (originalPos < newPos) - { - positionDiff = newPos-originalPos; - } else { - positionDiff = originalPos-newPos; - } - - patchFat(ui->fatPatcherFatPathEdt->text().toStdString(), positionDiff, dirPath.toStdString()) - ? QMessageBox::information(this, tr("NDS Factory"), tr("FAT patching completed!")) - : QMessageBox::critical(this, tr("NDS Factory"), tr("Error patching FAT!")); - + ui->fatPatcherPatchFatBtn->setEnabled(true); } diff --git a/ui/tabs/packer/packertabsignals.cpp b/ui/tabs/packer/packertabsignals.cpp index 48b59f9..8db62ca 100644 --- a/ui/tabs/packer/packertabsignals.cpp +++ b/ui/tabs/packer/packertabsignals.cpp @@ -2,6 +2,7 @@ #include #include "./../../mainwindow.h" #include "./../../ui_mainwindow.h" +#include "./../../utils/filepicker.h" #include "../commons/headernames.h" @@ -17,7 +18,7 @@ void MainWindow::on_packerLoadHeaderBtn_clicked() if(headerPath.isNull()) { - QMessageBox::critical(this, tr("NDS Factory"), tr("Unable to open file!")); + QMessageBox::critical(this, tr("NDSFactory"), tr("Unable to open file!")); return; } @@ -172,17 +173,17 @@ void MainWindow::on_packerLoadFatFilesBtn_clicked() void MainWindow::on_packerBuildNDSRomBtn_clicked() { - QString dirPath = QFileDialog::getSaveFileName( - Q_NULLPTR, - "NDS Rom", - "rom.nds", - "NDS ROM (*.nds)"); + ui->packerBuildNDSRomBtn->setEnabled(false); + + QString dirPath = customSaveFileDialog("NDS Rom", + "rom.nds", + "NDS ROM (*.nds)"); if (!dirPath.isNull()) - { - writeEverything(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Creation completed!")) - : QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the creation!")); - } + writeEverything(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDSFactory"), tr("Creation completed!")) + : QMessageBox::critical(this, tr("NDSFactory"), tr("Error during the creation!")); + + ui->packerBuildNDSRomBtn->setEnabled(true); } void MainWindow::on_packerCalcHeaderCrcBtn_clicked() diff --git a/ui/tabs/unpacker/unpackertabsignals.cpp b/ui/tabs/unpacker/unpackertabsignals.cpp index f74d06f..0122003 100644 --- a/ui/tabs/unpacker/unpackertabsignals.cpp +++ b/ui/tabs/unpacker/unpackertabsignals.cpp @@ -36,100 +36,145 @@ void MainWindow::on_loadRomBtn_clicked() void MainWindow::on_unpackerDumpHeaderBtn_clicked() { + ui->unpackerDumpHeaderBtn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS Header", "header.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpHeader(dirPath.toStdString())); + + ui->unpackerDumpHeaderBtn->setEnabled(true); } void MainWindow::on_unpackerDumpArm9Btn_clicked() { + ui->unpackerDumpArm9Btn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS ARM9", "arm9.bin", "Binary (*.bin)"); QMessageBox::StandardButton dumpExtraBytes = QMessageBox::question( this, - "NDS Factory", + "NDSFactory", "Do you want to dump the extra 12 bytes? (click yes if you want a 1:1 arm9 dump)", QMessageBox::Yes|QMessageBox::No); if (!dirPath.isNull()) notifyExtractionResult(dumpArm9Bin(dirPath.toStdString(), dumpExtraBytes == QMessageBox::Yes ? true : false)); + + ui->unpackerDumpArm9Btn->setEnabled(true); } void MainWindow::on_unpackerDumpArm7Btn_clicked() { + ui->unpackerDumpArm7Btn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS ARM7", "arm7.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpArm7Bin(dirPath.toStdString())); + + ui->unpackerDumpArm7Btn->setEnabled(true); } void MainWindow::on_unpackerDumpFntBtn_clicked() { + ui->unpackerDumpFntBtn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS FNT", "fnt.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpFnt(dirPath.toStdString())); + + ui->unpackerDumpFntBtn->setEnabled(true); } void MainWindow::on_unpackerDumpFatBtn_clicked() { + ui->unpackerDumpFatBtn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS FAT", "fat.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpFat(dirPath.toStdString())); + + ui->unpackerDumpFatBtn->setEnabled(true); } void MainWindow::on_unpackerDumpArm9OverlayBtn_clicked() { + ui->unpackerDumpArm9OverlayBtn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS ARM9 Overlay", "a9ovr.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpArm9Overlay(dirPath.toStdString())); + + ui->unpackerDumpArm9OverlayBtn->setEnabled(true); } void MainWindow::on_unpackerDumpArm7OverlayBtn_clicked() { + ui->unpackerDumpArm7OverlayBtn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS ARM7 Overlay", "a7ovr.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpArm7Overlay(dirPath.toStdString())); + + ui->unpackerDumpArm7OverlayBtn->setEnabled(true); } void MainWindow::on_unpackerDumpIconTitleLogoBtn_clicked() { + ui->unpackerDumpIconTitleLogoBtn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS IconTitleLogo", "itl.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpIconTitle(dirPath.toStdString())); + + ui->unpackerDumpIconTitleLogoBtn->setEnabled(true); } void MainWindow::on_unpackerDumpFatFilesBtn_clicked() { + ui->unpackerDumpFatFilesBtn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS FAT Files", "fat_data.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpFatFiles(dirPath.toStdString())); + + ui->unpackerDumpFatFilesBtn->setEnabled(true); } void MainWindow::on_unpackerDumpArm9OverlayFilesBtn_clicked() { + ui->unpackerDumpArm9OverlayFilesBtn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS ARM9 Overlay Data", "a9ovr_data.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpArm9OverlayFiles(dirPath.toStdString())); + + ui->unpackerDumpArm9OverlayFilesBtn->setEnabled(true); } void MainWindow::on_unpackerDumpArm7OverlayFilesBtn_clicked() { + ui->unpackerDumpArm7OverlayFilesBtn->setEnabled(false); + QString dirPath = customSaveFileDialog("NDS ARM7 Overlay Data", "a7ovr_data.bin", "Binary (*.bin)"); if (!dirPath.isNull()) notifyExtractionResult(dumpArm7OverlayFiles(dirPath.toStdString())); + + ui->unpackerDumpArm7OverlayFilesBtn->setEnabled(true); } void MainWindow::on_unpackerDumpEverythingBtn_clicked() { + ui->unpackerDumpEverythingBtn->setEnabled(false); QString dirPath = QFileDialog::getExistingDirectory( this, tr("Select Directory"), "", @@ -137,4 +182,5 @@ void MainWindow::on_unpackerDumpEverythingBtn_clicked() if (!dirPath.isNull()) notifyExtractionResult(dumpEverything(dirPath)); + ui->unpackerDumpEverythingBtn->setEnabled(true); } diff --git a/ui/utils/filepicker.h b/ui/utils/filepicker.h index 6a4bb49..f2a94ce 100644 --- a/ui/utils/filepicker.h +++ b/ui/utils/filepicker.h @@ -1,9 +1,8 @@ #pragma once - #include -QString customSaveFileDialog(const QString& title, const QString& defaultName, const QString& filter) +inline QString customSaveFileDialog(const QString& title, const QString& defaultName, const QString& filter) { static QString lastUsedPath; diff --git a/ui/utils/theme.h b/ui/utils/theme.h index d5f0a10..4e7c188 100644 --- a/ui/utils/theme.h +++ b/ui/utils/theme.h @@ -49,7 +49,7 @@ inline void setTheme(QString themeValue) { QSettings settings; settings.setValue("theme", themeValue); - QMessageBox::information(nullptr, "NDS Factory", "Restart NDSFactory to change theme!"); + QMessageBox::information(nullptr, "NDSFactory", "Restart NDSFactory to change theme!"); } diff --git a/ui/utils/ui.h b/ui/utils/ui.h index d06f44d..d4f26f5 100644 --- a/ui/utils/ui.h +++ b/ui/utils/ui.h @@ -6,10 +6,10 @@ void notifyExtractionResult(bool result) { if (result) { - QMessageBox::information(Q_NULLPTR, "NDS Factory", "Extraction completed!"); + QMessageBox::information(Q_NULLPTR, "NDSFactory", "Extraction completed!"); } else { - QMessageBox::critical(Q_NULLPTR, "NDS Factory", "Error during the extraction!"); + QMessageBox::critical(Q_NULLPTR, "NDSFactory", "Error during the extraction!"); } } \ No newline at end of file