forked from Luca1991/NDSFactory
/
unpackertabsignals.cpp
209 lines (179 loc) · 6.56 KB
/
unpackertabsignals.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include <QFileDialog>
#include <vector>
#include <QMessageBox>
#include "mainwindow.h"
#include "ui_mainwindow.h"
void MainWindow::on_loadRomBtn_clicked()
{
std::vector<char> romHeader;
NDSHeader *pNDSHeader;
QString romPath = QFileDialog::getOpenFileName(
Q_NULLPTR,
"NDS Rom",
QDir::currentPath(),
"NDS Rom (*.nds)");
if( !romPath.isNull() )
{
ui->loadedRomPath->setText(romPath.toUtf8());
}
if (ndsFactory.loadRomHeader(ui->loadedRomPath->text().toStdString(), romHeader))
{
pNDSHeader = reinterpret_cast<NDSHeader*>(romHeader.data());
populateHeader(pNDSHeader);
enableExtractionButtons();
}
else
{
disableExtractionButtons();
}
}
void MainWindow::on_unpackerDumpHeaderBtn_clicked()
{
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS Header",
"header.bin",
"Binary (*.bin)");
if (!dirPath.isNull())
{
dumpHeader(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDumpArm9Btn_clicked()
{
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS ARM9",
"arm9.bin",
"Binary (*.bin)");
QMessageBox::StandardButton dumpExtraBytes = QMessageBox::question(
this,
"NDS Factory",
"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())
{
dumpArm9Bin(dirPath.toStdString(), dumpExtraBytes == QMessageBox::Yes ? true : false)
? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDumpArm7Btn_clicked()
{
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS ARM7",
"arm7.bin",
"Binary (*.bin)");
if (!dirPath.isNull())
{
dumpArm7Bin(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDumpFntBtn_clicked()
{
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS FNT",
"fnt.bin",
"Binary (*.bin)");
if (!dirPath.isNull())
{
dumpFnt(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDumpFatBtn_clicked()
{
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS FAT",
"fat.bin",
"Binary (*.bin)");
if (!dirPath.isNull())
{
dumpFat(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDumpArm9OverlayBtn_clicked()
{
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS ARM9 Overlay",
"a9ovr.bin",
"Binary (*.bin)");
if (!dirPath.isNull())
{
dumpArm9Overlay(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDumpArm7OverlayBtn_clicked()
{
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS ARM7 Overlay",
"a7ovr.bin",
"Binary (*.bin)");
if (!dirPath.isNull())
{
dumpArm7Overlay(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDumpIconTitleLogoBtn_clicked()
{
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS IconTitleLogo",
"itl.bin",
"Binary (*.bin)");
if (!dirPath.isNull())
{
dumpIconTitle(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDumpFatFilesBtn_clicked()
{
QString dirPath = QFileDialog::getSaveFileName(
Q_NULLPTR,
"NDS FAT Files",
"fat_data.bin",
"Binary (*.bin)");
if (!dirPath.isNull())
{
dumpFatFiles(dirPath.toStdString()) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDumpArm9OverlayFilesBtn_clicked()
{
QMessageBox::warning(this, tr("NDS Factory"), tr("This function is currently not implemented!"));
//dumpArm9OverlayFiles()
}
void MainWindow::on_unpackerDumpArm7OverlayFilesBtn_clicked()
{
QMessageBox::warning(this, tr("NDS Factory"), tr("This function is currently not implemented!"));
//dumpArm7OverlayFiles()
}
void MainWindow::on_unpackerDumpEverythingBtn_clicked()
{
QString dirPath = QFileDialog::getExistingDirectory(
this, tr("Select Directory"),
"",
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (!dirPath.isNull())
{
dumpEverything(dirPath) ? QMessageBox::information(this, tr("NDS Factory"), tr("Extraction completed!"))
: QMessageBox::critical(this, tr("NDS Factory"), tr("Error during the extraction!"));
}
}
void MainWindow::on_unpackerDecodeFatFilesBtn_clicked()
{
QMessageBox::warning(this, tr("NDS Factory"), tr("This function is currently not implemented!"));
decodeFatFiles();
}