Better project organization

This commit is contained in:
Luca D'Amico
2021-03-01 18:56:19 +01:00
parent c8fc9006f2
commit 658ca1b74c
19 changed files with 35 additions and 31 deletions

View File

@@ -0,0 +1,7 @@
#include "./../../mainwindow.h"
bool MainWindow::patchFat(const std::string& loadPath, uint32_t shiftSize, const std::string& savePath)
{
return ndsFactory.patchFat(loadPath, shiftSize, savePath);
}

View File

@@ -0,0 +1,49 @@
#include <QFileDialog>
#include <QMessageBox>
#include "./../../mainwindow.h"
#include "./../../ui_mainwindow.h"
void MainWindow::on_fatPatchingLoadFatBtn_clicked()
{
QString fatPath = QFileDialog::getOpenFileName(
Q_NULLPTR,
"NDS Fat",
QDir::currentPath(),
"NDS Fat (*.bin)");
if( !fatPath.isNull() )
{
ui->fatPatchingFatPathEdt->setText(fatPath.toUtf8());
}
}
void MainWindow::on_fatPatchingPatchFatBtn_clicked()
{
uint32_t positionDiff = 0;
uint32_t originalPos = ui->fatPatchingOriginalFatFilesAddrEdt->text().toUInt(nullptr, 16);
uint32_t newPos = ui->fatPatchingNewFatFilesAddrEdt->text().toUInt(nullptr, 16);
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS FAT",
"fat.bin",
"Binary (*.bin)");
if(dirPath.isNull())
{
return;
}
if (originalPos < newPos)
{
positionDiff = newPos-originalPos;
} else {
positionDiff = originalPos-newPos;
}
patchFat(ui->fatPatchingFatPathEdt->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!"));
}