mirror of
https://github.com/Luca1991/NDSFactory.git
synced 2026-02-07 23:26:14 +01:00
Implemented better error handling
This commit is contained in:
@@ -2,19 +2,18 @@
|
||||
#include "./../../mainwindow.h"
|
||||
|
||||
|
||||
bool MainWindow::extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath,
|
||||
NFResult MainWindow::extractFatData(const std::string& fatDataSectionPath, const std::string& fatSectionPath,
|
||||
const std::string& fntSectionPath, uint32_t originalFatDataAddr, const std::string& savePath, bool logFileIDs)
|
||||
{
|
||||
return ndsFactory.extractFatData(fatDataSectionPath, fatSectionPath, fntSectionPath, originalFatDataAddr, savePath, logFileIDs);
|
||||
}
|
||||
|
||||
bool MainWindow::patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath)
|
||||
NFResult MainWindow::patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath)
|
||||
{
|
||||
return ndsFactory.patchFat(loadPath, shiftSize, savePath);
|
||||
}
|
||||
|
||||
bool MainWindow::buildFatData(const std::string& fatDataDirPath, const std::string& originalFatPath, uint32_t fatDataAddr, const std::string& savePath)
|
||||
NFResult MainWindow::buildFatData(const std::string& fatDataDirPath, const std::string& originalFatPath, uint32_t fatDataAddr, const std::string& savePath)
|
||||
{
|
||||
if (!std::filesystem::exists(fatDataDirPath + "/_file_IDs.txt")) return false;
|
||||
return ndsFactory.buildFatData(fatDataDirPath, originalFatPath, fatDataAddr, savePath);
|
||||
}
|
||||
|
||||
@@ -55,14 +55,16 @@ void MainWindow::on_fatExtractorExtractBtn_clicked()
|
||||
"",
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (!dirPath.isNull())
|
||||
extractFatData(ui->fatExtractorFatDataPathEdt->text().toStdString(),
|
||||
if (!dirPath.isNull()) {
|
||||
NFResult nfResult = extractFatData(ui->fatExtractorFatDataPathEdt->text().toStdString(),
|
||||
ui->fatExtractorFatPathEdt->text().toStdString(),
|
||||
ui->fatExtractorFntPathEdt->text().toStdString(),
|
||||
ui->fatExtractorOriginalFatFilesAddrEdt->text().toUInt(nullptr, 16),
|
||||
dirPath.toStdString(),
|
||||
ui->fatExtractorSaveFileIDsCbx->isChecked()) ? QMessageBox::information(this, tr("NDSFactory"), tr("FAT files extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDSFactory"), tr("Error extracting FAT files!"));
|
||||
ui->fatExtractorSaveFileIDsCbx->isChecked());
|
||||
nfResult.result? QMessageBox::information(this, tr("NDSFactory"), tr("FAT files extraction completed!"))
|
||||
: QMessageBox::critical(this, tr("NDSFactory"), nfResult.message.c_str());
|
||||
}
|
||||
|
||||
ui->fatExtractorExtractBtn->setEnabled(true);
|
||||
|
||||
@@ -99,9 +101,9 @@ void MainWindow::on_fatPatcherPatchFatBtn_clicked()
|
||||
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!"));
|
||||
NFResult nfResult = patchFat(ui->fatPatcherFatPathEdt->text().toStdString(), positionDiff, dirPath.toStdString());
|
||||
nfResult.result ? QMessageBox::information(this, tr("NDSFactory"), tr("FAT patching completed!"))
|
||||
: QMessageBox::critical(this, tr("NDSFactory"), nfResult.message.c_str());
|
||||
}
|
||||
|
||||
ui->fatPatcherPatchFatBtn->setEnabled(true);
|
||||
@@ -140,11 +142,14 @@ void MainWindow::on_fatBuilderBuildBtn_clicked()
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (!dirPath.isNull())
|
||||
buildFatData(ui->fatBuilderFatDirPathEdt->text().toStdString(),
|
||||
ui->fatBuilderOriginalFatPathEdt->text().toStdString(),
|
||||
{
|
||||
NFResult nfResult = buildFatData(ui->fatBuilderFatDirPathEdt->text().toStdString(),
|
||||
ui->fatBuilderOriginalFatPathEdt->text().toStdString(),
|
||||
ui->fatBuilderFatAddrEdt->text().toUInt(nullptr, 16),
|
||||
dirPath.toStdString()) ? QMessageBox::information(this, tr("NDSFactory"), tr("fat_data.bin and fat.bin correctly built!"))
|
||||
: QMessageBox::critical(this, tr("NDSFactory"), tr("Error building FAT!"));
|
||||
dirPath.toStdString());
|
||||
nfResult.result? QMessageBox::information(this, tr("NDSFactory"), tr("fat_data.bin and fat.bin correctly built!"))
|
||||
: QMessageBox::critical(this, tr("NDSFactory"), nfResult.message.c_str());
|
||||
}
|
||||
|
||||
ui->fatBuilderOpenFatDataDirBtn->setEnabled(true);
|
||||
}
|
||||
Reference in New Issue
Block a user