-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexportdialog.cpp
More file actions
83 lines (75 loc) · 2.16 KB
/
exportdialog.cpp
File metadata and controls
83 lines (75 loc) · 2.16 KB
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
#include "exportdialog.h"
#include "ui_exportdialog.h"
#include <QFileDialog>
#include <QMessageBox>
#include "project.h"
extern Project project;
ExportDialog::ExportDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::ExportDialog)
{
ui->setupUi(this);
switch (project.tileset.format)
{
case Tileset::GBA_4bpp:
ui->cmbFormat->setCurrentIndex(1);
break;
case Tileset::GBA_8bpp:
ui->cmbFormat->setCurrentIndex(0);
break;
}
}
ExportDialog::~ExportDialog()
{
delete ui;
}
void ExportDialog::on_btnBrowseOFile_clicked()
{
QString ofile_name= QFileDialog::getSaveFileName(this, "Export map as source file", "", "GAS (*.s)\nC (*.c)");
if (ofile_name == "")
return;
ui->txtOFilePath->setText(ofile_name);
}
void ExportDialog::on_btnDialog_accepted()
{
if (ui->txtOFilePath->text() == "")
{
on_btnBrowseOFile_clicked();
if (ui->txtOFilePath->text() == "")
{
QMessageBox::critical(this, "Error - export as source file", "No valid output file path given.\r\nExport canceled.");
return;
}
}
int export_flags= 0;
export_flags+= ui->chkExportGfx->isChecked()?Project::ExportGfx:0;
export_flags+= ui->chkExportMap->isChecked()?Project::ExportMap:0;
export_flags+= ui->chkExportPal->isChecked()?Project::ExportPal:0;
export_flags+= ui->chkIncludeHFile->isChecked()?Project::ExportHFile:0;
export_flags+= ui->chkOptimize->isChecked()?Project::ExportOptimize:0;
switch(ui->cmbFormat->currentIndex())
{
case 0:
export_flags+= Project::ExportGBA8bpp;
break;
case 1:
export_flags+= Project::ExportGBA4bpp;
break;
case 2:
export_flags+= Project::ExportGBAAffine;
break;
}
if ((export_flags&Project::ExportAll) == Project::ExportNone)
{
QMessageBox::warning(this, "", "Nothing to do...");
return;
}
int err= project.ExportToSourceFile(ui->txtOFilePath->text(), export_flags);
if (!err)
this->close();
else
{
QMessageBox::critical(this, "Error - export as source file", "Export failed");
return;
}
}