forked from Luca1991/NDSFactory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfatpatchingtabsignals.cpp
49 lines (40 loc) · 1.28 KB
/
fatpatchingtabsignals.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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!"));
}