2583
|
1 |
#include <QtGui>
|
2572
|
2 |
#include "editor.h"
|
|
3 |
#include "ui_editor.h"
|
|
4 |
|
|
5 |
editor::editor(QWidget *parent)
|
|
6 |
: QMainWindow(parent), ui(new Ui::editor)
|
|
7 |
{
|
|
8 |
ui->setupUi(this);
|
2583
|
9 |
|
|
10 |
cbFlags
|
|
11 |
<< ui->cbForts
|
|
12 |
<< ui->cbMultiWeapon
|
|
13 |
<< ui->cbSolidLand
|
|
14 |
<< ui->cbBorder
|
|
15 |
<< ui->cbDivideTeams
|
|
16 |
<< ui->cbLowGravity
|
|
17 |
<< ui->cbLaserSight
|
|
18 |
<< ui->cbInvulnerable
|
|
19 |
<< ui->cbMines
|
|
20 |
<< ui->cbVampiric
|
|
21 |
<< ui->cbKarma
|
|
22 |
<< ui->cbArtillery
|
|
23 |
<< ui->cbOneClanMode
|
|
24 |
;
|
2572
|
25 |
}
|
|
26 |
|
|
27 |
editor::~editor()
|
|
28 |
{
|
|
29 |
delete ui;
|
|
30 |
}
|
2583
|
31 |
|
|
32 |
void editor::on_actionLoad_triggered()
|
|
33 |
{
|
|
34 |
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), "Missions (*.txt)");
|
|
35 |
|
|
36 |
if(!fileName.isEmpty())
|
|
37 |
load(fileName);
|
|
38 |
}
|
|
39 |
|
|
40 |
void editor::load(const QString & fileName)
|
|
41 |
{
|
|
42 |
QFile file(fileName);
|
|
43 |
|
|
44 |
if(!file.open(QIODevice::ReadOnly))
|
|
45 |
{
|
|
46 |
QMessageBox::warning(this, "File error", "No such file");
|
|
47 |
return ;
|
|
48 |
}
|
|
49 |
|
|
50 |
QTextStream stream(&file);
|
|
51 |
|
|
52 |
while(!stream.atEnd())
|
|
53 |
{
|
|
54 |
QString line = stream.readLine();
|
|
55 |
if (line.startsWith("seed"))
|
|
56 |
ui->leSeed->setText(line.mid(5));
|
|
57 |
else
|
|
58 |
if (line.startsWith("$turntime"))
|
|
59 |
ui->sbTurnTime->setValue(line.mid(10).toInt());
|
|
60 |
else
|
|
61 |
if (line.startsWith("$casefreq"))
|
|
62 |
ui->sbCrateDrops->setValue(line.mid(10).toInt());
|
|
63 |
else
|
|
64 |
if (line.startsWith("$damagepct"))
|
|
65 |
ui->sbDamageModifier->setValue(line.mid(11).toInt());
|
|
66 |
else
|
|
67 |
if (line.startsWith("$gmflags"))
|
|
68 |
{
|
|
69 |
quint32 flags = line.mid(9).toInt();
|
|
70 |
foreach(QCheckBox * cb, cbFlags)
|
|
71 |
{
|
|
72 |
cb->setChecked(flags & 1);
|
|
73 |
flags >>= 1;
|
|
74 |
}
|
|
75 |
}
|
|
76 |
}
|
|
77 |
}
|