author | unc0rr |
Sun, 25 Oct 2009 12:40:47 +0000 | |
changeset 2584 | cc049fbb65ef |
parent 2583 | f8da275981e5 |
child 2594 | 0047e16dbacb |
permissions | -rw-r--r-- |
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 |
|
2584
cc049fbb65ef
Change mission file format to allow more flexible config
unc0rr
parents:
2583
diff
changeset
|
58 |
if (line.startsWith("map")) |
cc049fbb65ef
Change mission file format to allow more flexible config
unc0rr
parents:
2583
diff
changeset
|
59 |
ui->leMap->setText(line.mid(4)); |
cc049fbb65ef
Change mission file format to allow more flexible config
unc0rr
parents:
2583
diff
changeset
|
60 |
else |
cc049fbb65ef
Change mission file format to allow more flexible config
unc0rr
parents:
2583
diff
changeset
|
61 |
if (line.startsWith("theme")) |
cc049fbb65ef
Change mission file format to allow more flexible config
unc0rr
parents:
2583
diff
changeset
|
62 |
ui->leTheme->setText(line.mid(6)); |
cc049fbb65ef
Change mission file format to allow more flexible config
unc0rr
parents:
2583
diff
changeset
|
63 |
else |
2583 | 64 |
if (line.startsWith("$turntime")) |
65 |
ui->sbTurnTime->setValue(line.mid(10).toInt()); |
|
66 |
else |
|
67 |
if (line.startsWith("$casefreq")) |
|
68 |
ui->sbCrateDrops->setValue(line.mid(10).toInt()); |
|
69 |
else |
|
70 |
if (line.startsWith("$damagepct")) |
|
71 |
ui->sbDamageModifier->setValue(line.mid(11).toInt()); |
|
72 |
else |
|
73 |
if (line.startsWith("$gmflags")) |
|
74 |
{ |
|
75 |
quint32 flags = line.mid(9).toInt(); |
|
76 |
foreach(QCheckBox * cb, cbFlags) |
|
77 |
{ |
|
78 |
cb->setChecked(flags & 1); |
|
79 |
flags >>= 1; |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
} |