Compare commits

...

5 Commits

Author SHA1 Message Date
Luca D'Amico
a2739a9ca8 Remember last used path in file/directory picker 2024-08-19 17:06:18 +02:00
Luca D'Amico
e17d3805aa Fixed a bug that caused the overlay dump buttons to be grayed out 2024-08-19 16:27:55 +02:00
Luca D'Amico
099d04d432 Fixed a9ovr_data and a7ovr_data dumping from Single Binary Extractor 2024-08-19 16:23:34 +02:00
Luca D'Amico
dadd1d5c1f Added option to save all file IDs while extracting FAT data 2024-08-19 15:59:06 +02:00
Luca D'Amico
ca8ad8259b Now use C++20 2024-08-19 15:58:33 +02:00
12 changed files with 117 additions and 77 deletions

View File

@ -84,7 +84,7 @@ else()
endif() endif()
# Set C++ standard for the target # Set C++ standard for the target
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
# Enable Qt's automatic features for the target # Enable Qt's automatic features for the target
set_target_properties(${PROJECT_NAME} PROPERTIES set_target_properties(${PROJECT_NAME} PROPERTIES

View File

@ -3,6 +3,7 @@
#include <fstream> #include <fstream>
#include <cmath> #include <cmath>
#include <filesystem> #include <filesystem>
#include <format>
#include "ndsfactory.h" #include "ndsfactory.h"
#include "fatstruct.h" #include "fatstruct.h"
#include "crctable.h" #include "crctable.h"
@ -61,6 +62,18 @@ bool NDSFactory::dumpDataFromFile(const std::string& romPath, const std::string&
return false; return false;
} }
bool NDSFactory::logToFile(const std::string& logPath, const std::string& log)
{
std::ofstream savedFile(logPath, std::ios::out | std::ios::binary | std::ios::app);
if (savedFile.is_open())
{
savedFile.write(log.c_str(), log.size());
savedFile.close();
return true;
}
return false;
}
bool NDSFactory::readBytesFromFile(std::vector<char>& byteBuffer, const std::string& romPath, uint32_t startAddr, uint32_t size) bool NDSFactory::readBytesFromFile(std::vector<char>& byteBuffer, const std::string& romPath, uint32_t startAddr, uint32_t size)
{ {
@ -135,7 +148,7 @@ bool NDSFactory::checkArm9FooterPresence(const std::string& sectionPath, uint32_
} }
bool NDSFactory::extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath, bool NDSFactory::extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath,
const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath) const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath, bool logFileIDs)
{ {
std::vector<char> fatDataBytes; std::vector<char> fatDataBytes;
std::vector<char> fatBytes; std::vector<char> fatBytes;
@ -169,7 +182,7 @@ bool NDSFactory::extractFatData(const std::string& fatDataSectionPath, const std
// This lambda function was written by NyuBlara, all credits to him. // This lambda function was written by NyuBlara, all credits to him.
// I edited it a bit to make it work with the rest of the updated code. // I edited it a bit to make it work with the rest of the updated code.
auto parseFolder = [this, fntBytes, pfatrange, fatDataSectionPath, originalFatDataAddr](uint32_t folderId, std::string curPath, auto& parseFolder) { auto parseFolder = [this, fntBytes, pfatrange, fatDataSectionPath, originalFatDataAddr, savePath, logFileIDs](uint32_t folderId, std::string curPath, auto& parseFolder) {
uint32_t currentOffset = 8 * (folderId & FNT_HEADER_OFFSET_MASK); // offset for the current directory's info in the FNT header uint32_t currentOffset = 8 * (folderId & FNT_HEADER_OFFSET_MASK); // offset for the current directory's info in the FNT header
// Only the lower 12 bit of the given offset are relevant // Only the lower 12 bit of the given offset are relevant
@ -236,6 +249,12 @@ bool NDSFactory::extractFatData(const std::string& fatDataSectionPath, const std
if (!std::filesystem::exists(newPath)) if (!std::filesystem::exists(newPath))
if (!std::filesystem::create_directory(newPath)) return false; if (!std::filesystem::create_directory(newPath)) return false;
if (logFileIDs)
{
std::string log = std::format("{:x}",subFolderId) + "::D::" + newPath.substr(savePath.size()+1) + '\n';
if (!logToFile(savePath + "/_file_IDs.txt", log)) return false;
}
// Jump back to the FNT header and repeat the process for subdirectory ! // Jump back to the FNT header and repeat the process for subdirectory !
if (!parseFolder(subFolderId, newPath, parseFolder)) return false; if (!parseFolder(subFolderId, newPath, parseFolder)) return false;
} }
@ -249,6 +268,12 @@ bool NDSFactory::extractFatData(const std::string& fatDataSectionPath, const std
uint32_t fileSize = (pfatrange + fatOffset)->endAddr - (pfatrange + fatOffset)->startAddr; uint32_t fileSize = (pfatrange + fatOffset)->endAddr - (pfatrange + fatOffset)->startAddr;
if (!dumpDataFromFile(fatDataSectionPath, newPath, fileStartAddr, fileSize)) return false; if (!dumpDataFromFile(fatDataSectionPath, newPath, fileStartAddr, fileSize)) return false;
if (logFileIDs)
{
std::string log = std::format("{:x}", fatOffset) + "::F::" + newPath.substr(savePath.size()+1) + '\n';
if (!logToFile(savePath + "/_file_IDs.txt", log)) return false;
}
fatOffset++; fatOffset++;
} }
} }

View File

@ -14,6 +14,7 @@ public:
NDSFactory(); NDSFactory();
bool loadRomHeader(const std::string& romPath, std::vector<char>& header); bool loadRomHeader(const std::string& romPath, std::vector<char>& header);
bool dumpDataFromFile(const std::string& romPath, const std::string& savePath, uint32_t startAddr, uint32_t size); bool dumpDataFromFile(const std::string& romPath, const std::string& savePath, uint32_t startAddr, uint32_t size);
bool logToFile(const std::string& logPath, const std::string& log);
bool readBytesFromFile(std::vector<char>& byteBuffer, const std::string& romPath, uint32_t startAddr, uint32_t size); bool readBytesFromFile(std::vector<char>& byteBuffer, const std::string& romPath, uint32_t startAddr, uint32_t size);
bool writeSectionToFile(const std::string& sectionPath, const std::string& savePath, uint32_t startAddr, uint32_t size); bool writeSectionToFile(const std::string& sectionPath, const std::string& savePath, uint32_t startAddr, uint32_t size);
bool writeBytesToFile(std::vector<char>& byteBuffer, const std::string& savePath, uint32_t startAddr, uint32_t size); bool writeBytesToFile(std::vector<char>& byteBuffer, const std::string& savePath, uint32_t startAddr, uint32_t size);
@ -21,7 +22,7 @@ public:
int getCardSizeInBytes(int cardType); int getCardSizeInBytes(int cardType);
bool checkArm9FooterPresence(const std::string& sectionPath, uint32_t size); bool checkArm9FooterPresence(const std::string& sectionPath, uint32_t size);
bool extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath, bool extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath,
const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath); const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath, bool logFileIDs);
bool patchFat(const std::string& sectionPath, uint32_t shiftSize, const std::string& savePath); bool patchFat(const std::string& sectionPath, uint32_t shiftSize, const std::string& savePath);
uint16_t calcHeaderCrc16(const std::vector<char>& romHeader); uint16_t calcHeaderCrc16(const std::vector<char>& romHeader);

View File

@ -1,6 +1,6 @@
#ifndef REVISION_H #ifndef REVISION_H
#define REVISION_H #define REVISION_H
#define GIT_COMMIT_HASH "e788d95" #define GIT_COMMIT_HASH "fb12309"
#endif #endif

View File

@ -108,6 +108,6 @@ private:
QString extractPackerHeaderTableData(int index); QString extractPackerHeaderTableData(int index);
bool extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath, bool extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath,
const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath); const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath, bool logFileIDs);
bool patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath); bool patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath);
}; };

View File

@ -697,6 +697,17 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QCheckBox" name="fatExtractorSaveFileIDsCbx">
<property name="text">
<string>Save file IDs to _file_IDs.txt (required for games that access files by their ID)</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_41"> <layout class="QHBoxLayout" name="horizontalLayout_41">
<property name="leftMargin"> <property name="leftMargin">

View File

@ -2,9 +2,9 @@
bool MainWindow::extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath, bool MainWindow::extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath,
const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath) const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath, bool logFileIDs)
{ {
return ndsFactory.extractFatData(fatDataSectionPath, fatSectionPath, fntSectionPath, originalFatDataAddr, savePath); return ndsFactory.extractFatData(fatDataSectionPath, fatSectionPath, fntSectionPath, originalFatDataAddr, savePath, logFileIDs);
} }
bool MainWindow::patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath) bool MainWindow::patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath)

View File

@ -8,7 +8,7 @@ void MainWindow::on_fatExtractorLoadFatDataBtn_clicked()
QString FatDataPath = QFileDialog::getOpenFileName( QString FatDataPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Fat Data", "NDS Fat Data",
QDir::currentPath(), "",
"NDS FAT_DATA (*.bin)"); "NDS FAT_DATA (*.bin)");
if (!FatDataPath.isNull()) if (!FatDataPath.isNull())
@ -22,7 +22,7 @@ void MainWindow::on_fatExtractorLoadFatBtn_clicked()
QString FatPath = QFileDialog::getOpenFileName( QString FatPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Fat", "NDS Fat",
QDir::currentPath(), "",
"NDS FAT (*.bin)"); "NDS FAT (*.bin)");
if (!FatPath.isNull()) if (!FatPath.isNull())
@ -36,7 +36,7 @@ void MainWindow::on_fatExtractorLoadFntBtn_clicked()
QString FntPath = QFileDialog::getOpenFileName( QString FntPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Fnt", "NDS Fnt",
QDir::currentPath(), "",
"NDS FNT (*.bin)"); "NDS FNT (*.bin)");
if (!FntPath.isNull()) if (!FntPath.isNull())
@ -54,10 +54,11 @@ void MainWindow::on_fatExtractorExtractBtn_clicked()
if (!dirPath.isNull()) if (!dirPath.isNull())
extractFatData(ui->fatExtractorFatDataPathEdt->text().toStdString(), extractFatData(ui->fatExtractorFatDataPathEdt->text().toStdString(),
ui->fatExtractorFatPathEdt->text().toStdString(), ui->fatExtractorFatPathEdt->text().toStdString(),
ui->fatExtractorFntPathEdt->text().toStdString(), ui->fatExtractorFntPathEdt->text().toStdString(),
ui->fatExtractorOriginalFatFilesAddrEdt->text().toUInt(nullptr, 16), ui->fatExtractorOriginalFatFilesAddrEdt->text().toUInt(nullptr, 16),
dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("FAT files extraction completed!")) 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!")); : QMessageBox::critical(this, tr("NDS Factory"), tr("Error extracting FAT files!"));
} }
@ -67,7 +68,7 @@ void MainWindow::on_fatPatcherLoadFatBtn_clicked()
QString fatPath = QFileDialog::getOpenFileName( QString fatPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Fat", "NDS Fat",
QDir::currentPath(), "",
"NDS Fat (*.bin)"); "NDS Fat (*.bin)");
if( !fatPath.isNull() ) if( !fatPath.isNull() )

View File

@ -35,7 +35,7 @@ void MainWindow::on_packerLoadArm9BinBtn_clicked()
QString arm9BinPath = QFileDialog::getOpenFileName( QString arm9BinPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Arm9Bin", "NDS Arm9Bin",
QDir::currentPath(), "",
"NDS Arm9Bin (*.bin)"); "NDS Arm9Bin (*.bin)");
if(!arm9BinPath.isNull()) if(!arm9BinPath.isNull())
@ -49,7 +49,7 @@ void MainWindow::on_packerLoadArm7BinBtn_clicked()
QString arm7BinPath = QFileDialog::getOpenFileName( QString arm7BinPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Arm7Bin", "NDS Arm7Bin",
QDir::currentPath(), "",
"NDS Arm7Bin (*.bin)"); "NDS Arm7Bin (*.bin)");
if(!arm7BinPath.isNull()) if(!arm7BinPath.isNull())
@ -63,7 +63,7 @@ void MainWindow::on_packerLoadFntBtn_clicked()
QString fntPath = QFileDialog::getOpenFileName( QString fntPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Fnt", "NDS Fnt",
QDir::currentPath(), "",
"NDS Fnt (*.bin)"); "NDS Fnt (*.bin)");
if(!fntPath.isNull()) if(!fntPath.isNull())
@ -77,7 +77,7 @@ void MainWindow::on_packerLoadFatBtn_clicked()
QString fatPath = QFileDialog::getOpenFileName( QString fatPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Fat", "NDS Fat",
QDir::currentPath(), "",
"NDS Fat (*.bin)"); "NDS Fat (*.bin)");
if(!fatPath.isNull()) if(!fatPath.isNull())
@ -91,7 +91,7 @@ void MainWindow::on_packerLoadArm9OverlayBtn_clicked()
QString arm9OverlayPath = QFileDialog::getOpenFileName( QString arm9OverlayPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Arm9Overlay", "NDS Arm9Overlay",
QDir::currentPath(), "",
"NDS A9OVR (*.bin)"); "NDS A9OVR (*.bin)");
if( !arm9OverlayPath.isNull() ) if( !arm9OverlayPath.isNull() )
@ -105,7 +105,7 @@ void MainWindow::on_packerLoadArm9OverlayFilesBtn_clicked()
QString arm9OverlayFilesPath = QFileDialog::getOpenFileName( QString arm9OverlayFilesPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Arm9Overlay Data", "NDS Arm9Overlay Data",
QDir::currentPath(), "",
"NDS A9OVR_DATA (*.bin)"); "NDS A9OVR_DATA (*.bin)");
if(!arm9OverlayFilesPath.isNull()) if(!arm9OverlayFilesPath.isNull())
@ -119,7 +119,7 @@ void MainWindow::on_packerLoadArm7OverlayBtn_clicked()
QString arm7OverlayPath = QFileDialog::getOpenFileName( QString arm7OverlayPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Arm7Overlay", "NDS Arm7Overlay",
QDir::currentPath(), "",
"NDS A7OVR (*.bin)"); "NDS A7OVR (*.bin)");
if(!arm7OverlayPath.isNull()) if(!arm7OverlayPath.isNull())
@ -133,7 +133,7 @@ void MainWindow::on_packerLoadArm7OverlayFilesBtn_clicked()
QString arm7OverlayFilesPath = QFileDialog::getOpenFileName( QString arm7OverlayFilesPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Arm7Overlay Data", "NDS Arm7Overlay Data",
QDir::currentPath(), "",
"NDS A7OVR_DATA (*.bin)"); "NDS A7OVR_DATA (*.bin)");
if(!arm7OverlayFilesPath.isNull()) if(!arm7OverlayFilesPath.isNull())
@ -147,7 +147,7 @@ void MainWindow::on_packerLoadIconTitleBtn_clicked()
QString iconTitlePath = QFileDialog::getOpenFileName( QString iconTitlePath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS IconTitleLogo", "NDS IconTitleLogo",
QDir::currentPath(), "",
"NDS ITL (*.bin)"); "NDS ITL (*.bin)");
if(!iconTitlePath.isNull()) if(!iconTitlePath.isNull())
@ -161,7 +161,7 @@ void MainWindow::on_packerLoadFatFilesBtn_clicked()
QString fatFilesPath = QFileDialog::getOpenFileName( QString fatFilesPath = QFileDialog::getOpenFileName(
Q_NULLPTR, Q_NULLPTR,
"NDS Fat Data", "NDS Fat Data",
QDir::currentPath(), "",
"NDS FAT_DATA (*.bin)"); "NDS FAT_DATA (*.bin)");
if(!fatFilesPath.isNull()) if(!fatFilesPath.isNull())

View File

@ -23,14 +23,26 @@ void MainWindow::enableExtractionButtons()
{ {
ui->unpackerExtractorGbx->setEnabled(true); ui->unpackerExtractorGbx->setEnabled(true);
ui->unpackerExtraGbx->setEnabled(true); ui->unpackerExtraGbx->setEnabled(true);
if (ui->unpackerHeaderDataTable->model()->index(NDSHeaderNames::ARM9OverlayAddress, 1).data().toString().toUInt(nullptr,16) == 0){ if (ui->unpackerHeaderDataTable->model()->index(NDSHeaderNames::ARM9OverlayAddress, 1).data().toString().toUInt(nullptr,16) == 0)
{
ui->unpackerDumpArm9OverlayBtn->setEnabled(false); ui->unpackerDumpArm9OverlayBtn->setEnabled(false);
ui->unpackerDumpArm9OverlayFilesBtn->setEnabled(false); ui->unpackerDumpArm9OverlayFilesBtn->setEnabled(false);
} }
if (ui->unpackerHeaderDataTable->model()->index(NDSHeaderNames::ARM7OverlayAddress, 1).data().toString().toUInt(nullptr,16) == 0){ else
{
ui->unpackerDumpArm9OverlayBtn->setEnabled(true);
ui->unpackerDumpArm9OverlayFilesBtn->setEnabled(true);
}
if (ui->unpackerHeaderDataTable->model()->index(NDSHeaderNames::ARM7OverlayAddress, 1).data().toString().toUInt(nullptr,16) == 0)
{
ui->unpackerDumpArm7OverlayBtn->setEnabled(false); ui->unpackerDumpArm7OverlayBtn->setEnabled(false);
ui->unpackerDumpArm7OverlayFilesBtn->setEnabled(false); ui->unpackerDumpArm7OverlayFilesBtn->setEnabled(false);
} }
else
{
ui->unpackerDumpArm7OverlayBtn->setEnabled(true);
ui->unpackerDumpArm7OverlayFilesBtn->setEnabled(true);
}
} }
void MainWindow::disableExtractionButtons() void MainWindow::disableExtractionButtons()

View File

@ -3,6 +3,7 @@
#include <QMessageBox> #include <QMessageBox>
#include "./../../mainwindow.h" #include "./../../mainwindow.h"
#include "./../../ui_mainwindow.h" #include "./../../ui_mainwindow.h"
#include "./../../utils/filepicker.h"
void MainWindow::on_loadRomBtn_clicked() void MainWindow::on_loadRomBtn_clicked()
@ -34,11 +35,7 @@ void MainWindow::on_loadRomBtn_clicked()
void MainWindow::on_unpackerDumpHeaderBtn_clicked() void MainWindow::on_unpackerDumpHeaderBtn_clicked()
{ {
QString dirPath = QFileDialog::getSaveFileName( QString dirPath = customSaveFileDialog("NDS Header", "header.bin", "Binary (*.bin)");
Q_NULLPTR,
"NDS Header",
"header.bin",
"Binary (*.bin)");
if (!dirPath.isNull()) if (!dirPath.isNull())
notifyExtractionResult(dumpHeader(dirPath.toStdString())); notifyExtractionResult(dumpHeader(dirPath.toStdString()));
@ -46,11 +43,7 @@ void MainWindow::on_unpackerDumpHeaderBtn_clicked()
void MainWindow::on_unpackerDumpArm9Btn_clicked() void MainWindow::on_unpackerDumpArm9Btn_clicked()
{ {
QString dirPath = QFileDialog::getSaveFileName( QString dirPath = customSaveFileDialog("NDS ARM9", "arm9.bin", "Binary (*.bin)");
Q_NULLPTR,
"NDS ARM9",
"arm9.bin",
"Binary (*.bin)");
QMessageBox::StandardButton dumpExtraBytes = QMessageBox::question( QMessageBox::StandardButton dumpExtraBytes = QMessageBox::question(
this, this,
@ -64,11 +57,7 @@ void MainWindow::on_unpackerDumpArm9Btn_clicked()
void MainWindow::on_unpackerDumpArm7Btn_clicked() void MainWindow::on_unpackerDumpArm7Btn_clicked()
{ {
QString dirPath = QFileDialog::getSaveFileName( QString dirPath = customSaveFileDialog("NDS ARM7", "arm7.bin", "Binary (*.bin)");
Q_NULLPTR,
"NDS ARM7",
"arm7.bin",
"Binary (*.bin)");
if (!dirPath.isNull()) if (!dirPath.isNull())
notifyExtractionResult(dumpArm7Bin(dirPath.toStdString())); notifyExtractionResult(dumpArm7Bin(dirPath.toStdString()));
@ -76,11 +65,7 @@ void MainWindow::on_unpackerDumpArm7Btn_clicked()
void MainWindow::on_unpackerDumpFntBtn_clicked() void MainWindow::on_unpackerDumpFntBtn_clicked()
{ {
QString dirPath = QFileDialog::getSaveFileName( QString dirPath = customSaveFileDialog("NDS FNT", "fnt.bin", "Binary (*.bin)");
Q_NULLPTR,
"NDS FNT",
"fnt.bin",
"Binary (*.bin)");
if (!dirPath.isNull()) if (!dirPath.isNull())
notifyExtractionResult(dumpFnt(dirPath.toStdString())); notifyExtractionResult(dumpFnt(dirPath.toStdString()));
@ -88,11 +73,7 @@ void MainWindow::on_unpackerDumpFntBtn_clicked()
void MainWindow::on_unpackerDumpFatBtn_clicked() void MainWindow::on_unpackerDumpFatBtn_clicked()
{ {
QString dirPath = QFileDialog::getSaveFileName( QString dirPath = customSaveFileDialog("NDS FAT", "fat.bin", "Binary (*.bin)");
Q_NULLPTR,
"NDS FAT",
"fat.bin",
"Binary (*.bin)");
if (!dirPath.isNull()) if (!dirPath.isNull())
notifyExtractionResult(dumpFat(dirPath.toStdString())); notifyExtractionResult(dumpFat(dirPath.toStdString()));
@ -100,11 +81,7 @@ void MainWindow::on_unpackerDumpFatBtn_clicked()
void MainWindow::on_unpackerDumpArm9OverlayBtn_clicked() void MainWindow::on_unpackerDumpArm9OverlayBtn_clicked()
{ {
QString dirPath = QFileDialog::getSaveFileName( QString dirPath = customSaveFileDialog("NDS ARM9 Overlay", "a9ovr.bin", "Binary (*.bin)");
Q_NULLPTR,
"NDS ARM9 Overlay",
"a9ovr.bin",
"Binary (*.bin)");
if (!dirPath.isNull()) if (!dirPath.isNull())
notifyExtractionResult(dumpArm9Overlay(dirPath.toStdString())); notifyExtractionResult(dumpArm9Overlay(dirPath.toStdString()));
@ -112,11 +89,7 @@ void MainWindow::on_unpackerDumpArm9OverlayBtn_clicked()
void MainWindow::on_unpackerDumpArm7OverlayBtn_clicked() void MainWindow::on_unpackerDumpArm7OverlayBtn_clicked()
{ {
QString dirPath = QFileDialog::getSaveFileName( QString dirPath = customSaveFileDialog("NDS ARM7 Overlay", "a7ovr.bin", "Binary (*.bin)");
Q_NULLPTR,
"NDS ARM7 Overlay",
"a7ovr.bin",
"Binary (*.bin)");
if (!dirPath.isNull()) if (!dirPath.isNull())
notifyExtractionResult(dumpArm7Overlay(dirPath.toStdString())); notifyExtractionResult(dumpArm7Overlay(dirPath.toStdString()));
@ -124,11 +97,7 @@ void MainWindow::on_unpackerDumpArm7OverlayBtn_clicked()
void MainWindow::on_unpackerDumpIconTitleLogoBtn_clicked() void MainWindow::on_unpackerDumpIconTitleLogoBtn_clicked()
{ {
QString dirPath = QFileDialog::getSaveFileName( QString dirPath = customSaveFileDialog("NDS IconTitleLogo", "itl.bin", "Binary (*.bin)");
Q_NULLPTR,
"NDS IconTitleLogo",
"itl.bin",
"Binary (*.bin)");
if (!dirPath.isNull()) if (!dirPath.isNull())
notifyExtractionResult(dumpIconTitle(dirPath.toStdString())); notifyExtractionResult(dumpIconTitle(dirPath.toStdString()));
@ -136,11 +105,7 @@ void MainWindow::on_unpackerDumpIconTitleLogoBtn_clicked()
void MainWindow::on_unpackerDumpFatFilesBtn_clicked() void MainWindow::on_unpackerDumpFatFilesBtn_clicked()
{ {
QString dirPath = QFileDialog::getSaveFileName( QString dirPath = customSaveFileDialog("NDS FAT Files", "fat_data.bin", "Binary (*.bin)");
Q_NULLPTR,
"NDS FAT Files",
"fat_data.bin",
"Binary (*.bin)");
if (!dirPath.isNull()) if (!dirPath.isNull())
notifyExtractionResult(dumpFatFiles(dirPath.toStdString())); notifyExtractionResult(dumpFatFiles(dirPath.toStdString()));
@ -148,14 +113,18 @@ void MainWindow::on_unpackerDumpFatFilesBtn_clicked()
void MainWindow::on_unpackerDumpArm9OverlayFilesBtn_clicked() void MainWindow::on_unpackerDumpArm9OverlayFilesBtn_clicked()
{ {
QMessageBox::warning(this, tr("NDS Factory"), tr("This function is currently not implemented!")); QString dirPath = customSaveFileDialog("NDS ARM9 Overlay Data", "a9ovr_data.bin", "Binary (*.bin)");
//dumpArm9OverlayFiles()
if (!dirPath.isNull())
notifyExtractionResult(dumpArm9OverlayFiles(dirPath.toStdString()));
} }
void MainWindow::on_unpackerDumpArm7OverlayFilesBtn_clicked() void MainWindow::on_unpackerDumpArm7OverlayFilesBtn_clicked()
{ {
QMessageBox::warning(this, tr("NDS Factory"), tr("This function is currently not implemented!")); QString dirPath = customSaveFileDialog("NDS ARM7 Overlay Data", "a7ovr_data.bin", "Binary (*.bin)");
//dumpArm7OverlayFiles()
if (!dirPath.isNull())
notifyExtractionResult(dumpArm7OverlayFiles(dirPath.toStdString()));
} }
void MainWindow::on_unpackerDumpEverythingBtn_clicked() void MainWindow::on_unpackerDumpEverythingBtn_clicked()

21
ui/utils/filepicker.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <QFileDialog>
QString customSaveFileDialog(const QString& title, const QString& defaultName, const QString& filter)
{
static QString lastUsedPath;
QString selectedPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
title,
lastUsedPath + defaultName,
filter);
if (!selectedPath.isNull())
lastUsedPath = selectedPath.mid(0, selectedPath.lastIndexOf('/', Qt::CaseInsensitive)+1);
return selectedPath;
}