~ubuntu-branches/ubuntu/trusty/hedgewars/trusty-proposed

« back to all changes in this revision

Viewing changes to QTfrontend/gamecfgwidget.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-11-20 18:31:17 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20111120183117-pjhz1n2pvnmxa246
Tags: 0.9.17-1
* [Paul Wise]
 * Mention the homing bee in the package description (Closes: #577092)
 * Also install the hwengine desktop file (LP: #811770)
 * Depend on ttf-dejavu-core since it is smaller
 * Depend on ttf-wqy-zenhei instead of embedding a copy of it
* [Dmitry E. Oboukhov]
 * New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Hedgewars, a free turn based strategy game
3
 
 * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; version 2 of the License
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17
 
 */
18
 
 
19
 
#include <QResizeEvent>
20
 
#include <QGroupBox>
21
 
#include <QCheckBox>
22
 
#include <QGridLayout>
23
 
#include <QSpinBox>
24
 
#include <QLabel>
25
 
#include <QMessageBox>
26
 
#include <QTableView>
27
 
#include <QPushButton>
28
 
 
29
 
#include "gamecfgwidget.h"
30
 
#include "igbox.h"
31
 
#include "hwconsts.h"
32
 
#include "ammoSchemeModel.h"
33
 
#include "proto.h"
34
 
 
35
 
GameCFGWidget::GameCFGWidget(QWidget* parent) :
36
 
  QGroupBox(parent)
37
 
  , mainLayout(this)
38
 
  , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}")
39
 
{
40
 
    mainLayout.setMargin(0);
41
 
//  mainLayout.setSizeConstraint(QLayout::SetMinimumSize);
42
 
 
43
 
    pMapContainer = new HWMapContainer(this);
44
 
    mainLayout.addWidget(pMapContainer, 0, 0);
45
 
 
46
 
    IconedGroupBox *GBoxOptions = new IconedGroupBox(this);
47
 
    GBoxOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
48
 
    mainLayout.addWidget(GBoxOptions, 1, 0);
49
 
 
50
 
    QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions);
51
 
 
52
 
    GBoxOptions->setTitle(tr("Game Options"));
53
 
    GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), GBoxOptions), 1, 0);
54
 
 
55
 
    Scripts = new QComboBox(GBoxOptions);
56
 
    GBoxOptionsLayout->addWidget(Scripts, 1, 1);
57
 
 
58
 
    Scripts->addItem("Normal");
59
 
    Scripts->insertSeparator(1);
60
 
 
61
 
    for (int i = 0; i < scriptList->size(); ++i) {
62
 
        QString script = (*scriptList)[i].remove(".lua", Qt::CaseInsensitive);
63
 
        QList<QVariant> scriptInfo;
64
 
        scriptInfo.push_back(script);
65
 
        QFile scriptCfgFile;
66
 
        scriptCfgFile.setFileName(QString("%1/Data/Scripts/Multiplayer/%2.cfg").arg(cfgdir->absolutePath()).arg(script));
67
 
        if (!scriptCfgFile.exists()) scriptCfgFile.setFileName(QString("%1/Scripts/Multiplayer/%2.cfg").arg(datadir->absolutePath()).arg(script));
68
 
        if (scriptCfgFile.exists() && scriptCfgFile.open(QFile::ReadOnly)) {
69
 
            QString scheme;
70
 
            QString weapons;
71
 
            QTextStream input(&scriptCfgFile);
72
 
            input >> scheme;
73
 
            input >> weapons;
74
 
            if (scheme.isEmpty())
75
 
                scheme = "locked";
76
 
            scheme.replace("_", " ");
77
 
            if (weapons.isEmpty())
78
 
                weapons = "locked";
79
 
            weapons.replace("_", " ");
80
 
            scriptInfo.push_back(scheme);
81
 
            scriptInfo.push_back(weapons);
82
 
            scriptCfgFile.close();
83
 
        }
84
 
        else
85
 
        {
86
 
            scriptInfo.push_back("locked");
87
 
            scriptInfo.push_back("locked");
88
 
        }
89
 
        Scripts->addItem(script.replace("_", " "), scriptInfo);
90
 
    }
91
 
 
92
 
    connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int)));
93
 
 
94
 
    QWidget *SchemeWidget = new QWidget(GBoxOptions);
95
 
    GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2);
96
 
 
97
 
    QGridLayout *SchemeWidgetLayout = new QGridLayout(SchemeWidget);
98
 
    SchemeWidgetLayout->setMargin(0);
99
 
 
100
 
    GameSchemes = new QComboBox(SchemeWidget);
101
 
    SchemeWidgetLayout->addWidget(GameSchemes, 0, 2);
102
 
    connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int)));
103
 
 
104
 
    SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Scheme"), SchemeWidget), 0, 0);
105
 
 
106
 
    QPixmap pmEdit(":/res/edit.png");
107
 
    
108
 
    QPushButton * goToSchemePage = new QPushButton(SchemeWidget);
109
 
    goToSchemePage->setToolTip(tr("Edit schemes"));
110
 
    goToSchemePage->setIconSize(pmEdit.size());
111
 
    goToSchemePage->setIcon(pmEdit);
112
 
    goToSchemePage->setMaximumWidth(pmEdit.width() + 6);
113
 
    SchemeWidgetLayout->addWidget(goToSchemePage, 0, 3);
114
 
    connect(goToSchemePage, SIGNAL(clicked()), this, SLOT(jumpToSchemes()));
115
 
 
116
 
    SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Weapons"), SchemeWidget), 1, 0);
117
 
 
118
 
    WeaponsName = new QComboBox(SchemeWidget);
119
 
    SchemeWidgetLayout->addWidget(WeaponsName, 1, 2);
120
 
 
121
 
    connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int)));
122
 
 
123
 
    QPushButton * goToWeaponPage = new QPushButton(SchemeWidget);
124
 
    goToWeaponPage->setToolTip(tr("Edit weapons"));
125
 
    goToWeaponPage->setIconSize(pmEdit.size());
126
 
    goToWeaponPage->setIcon(pmEdit);
127
 
    goToWeaponPage->setMaximumWidth(pmEdit.width() + 6);
128
 
    SchemeWidgetLayout->addWidget(goToWeaponPage, 1, 3);
129
 
    connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons()));
130
 
 
131
 
    bindEntries = new QCheckBox(SchemeWidget);
132
 
    bindEntries->setToolTip(tr("When this option is enabled selecting a game scheme will auto-select a weapon"));
133
 
    bindEntries->setChecked(true);
134
 
    bindEntries->setMaximumWidth(42);
135
 
    bindEntries->setStyleSheet( "QCheckBox::indicator:checked   { image: url(\":/res/lock.png\"); }"
136
 
                                "QCheckBox::indicator:unchecked { image: url(\":/res/unlock.png\");   }" );
137
 
    SchemeWidgetLayout->addWidget(bindEntries, 0, 1, 0, 1, Qt::AlignVCenter);
138
 
 
139
 
    connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
140
 
    connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &)));
141
 
    connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator)));
142
 
    connect(pMapContainer, SIGNAL(mazeSizeChanged(int)), this, SLOT(maze_sizeChanged(int)));
143
 
    connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &)));
144
 
    connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int)));
145
 
    connect(pMapContainer, SIGNAL(drawMapRequested()), this, SIGNAL(goToDrawMap()));
146
 
    connect(pMapContainer, SIGNAL(drawnMapChanged(const QByteArray &)), this, SLOT(onDrawnMapChanged(const QByteArray &)));
147
 
}
148
 
 
149
 
void GameCFGWidget::jumpToSchemes()
150
 
{
151
 
    emit goToSchemes(GameSchemes->currentIndex());
152
 
}
153
 
 
154
 
void GameCFGWidget::jumpToWeapons()
155
 
{
156
 
    emit goToWeapons(WeaponsName->currentIndex());
157
 
}
158
 
 
159
 
QVariant GameCFGWidget::schemeData(int column) const
160
 
{
161
 
    return GameSchemes->model()->data(GameSchemes->model()->index(GameSchemes->currentIndex(), column));
162
 
}
163
 
 
164
 
quint32 GameCFGWidget::getGameFlags() const
165
 
{
166
 
    quint32 result = 0;
167
 
 
168
 
    if (schemeData(1).toBool())
169
 
        result |= 0x00001000;       // fort
170
 
    if (schemeData(2).toBool())
171
 
        result |= 0x00000010;       // divide teams
172
 
    if (schemeData(3).toBool())
173
 
        result |= 0x00000004;       // solid land
174
 
    if (schemeData(4).toBool())
175
 
        result |= 0x00000008;       // border
176
 
    if (schemeData(5).toBool())
177
 
        result |= 0x00000020;       // low gravity
178
 
    if (schemeData(6).toBool())
179
 
        result |= 0x00000040;       // laser sight
180
 
    if (schemeData(7).toBool())
181
 
        result |= 0x00000080;       // invulnerable
182
 
    if (schemeData(8).toBool())
183
 
        result |= 0x00000100;       // mines
184
 
    if (schemeData(9).toBool())
185
 
        result |= 0x00000200;       // vampirism
186
 
    if (schemeData(10).toBool())
187
 
        result |= 0x00000400;       // karma
188
 
    if (schemeData(11).toBool())
189
 
        result |= 0x00000800;       // artillery
190
 
    if (schemeData(12).toBool())
191
 
        result |= 0x00002000;       // random
192
 
    if (schemeData(13).toBool())
193
 
        result |= 0x00004000;       // king
194
 
    if (schemeData(14).toBool())
195
 
        result |= 0x00008000;       // place hogs
196
 
    if (schemeData(15).toBool())
197
 
        result |= 0x00010000;       // shared ammo
198
 
    if (schemeData(16).toBool())
199
 
        result |= 0x00020000;       // disable girders
200
 
    if (schemeData(17).toBool())
201
 
        result |= 0x00040000;       // disable land obj
202
 
    if (schemeData(18).toBool())
203
 
        result |= 0x00080000;       // ai survival
204
 
    if (schemeData(19).toBool())
205
 
        result |= 0x00100000;       // infinite attacks
206
 
    if (schemeData(20).toBool())
207
 
        result |= 0x00200000;       // reset weaps
208
 
    if (schemeData(21).toBool())
209
 
        result |= 0x00400000;       // per hog ammo
210
 
    if (schemeData(22).toBool())
211
 
        result |= 0x00800000;       // no wind
212
 
    if (schemeData(23).toBool())
213
 
        result |= 0x01000000;       // more wind
214
 
    if (schemeData(24).toBool())
215
 
        result |= 0x02000000;       // tag team
216
 
    if (schemeData(25).toBool())
217
 
        result |= 0x04000000;       // bottom border
218
 
 
219
 
    return result;
220
 
}
221
 
 
222
 
quint32 GameCFGWidget::getInitHealth() const
223
 
{
224
 
    return schemeData(28).toInt();
225
 
}
226
 
 
227
 
QByteArray GameCFGWidget::getFullConfig() const
228
 
{
229
 
    QList<QByteArray> bcfg;
230
 
    int mapgen = pMapContainer->get_mapgen();
231
 
 
232
 
    QString currentMap = pMapContainer->getCurrentMap();
233
 
    if (currentMap.size() > 0)
234
 
    {
235
 
        bcfg << QString("emap " + currentMap).toUtf8();
236
 
        if(pMapContainer->getCurrentIsMission())
237
 
            bcfg << QString("escript Maps/%1/map.lua").arg(currentMap).toUtf8();
238
 
    }
239
 
    bcfg << QString("etheme " + pMapContainer->getCurrentTheme()).toUtf8();
240
 
 
241
 
    if (Scripts->currentIndex() > 0)
242
 
    {
243
 
        bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex()).toList()[0].toString()).toUtf8();
244
 
    }
245
 
 
246
 
    bcfg << QString("eseed " + pMapContainer->getCurrentSeed()).toUtf8();
247
 
    bcfg << QString("e$gmflags %1").arg(getGameFlags()).toUtf8();
248
 
    bcfg << QString("e$damagepct %1").arg(schemeData(26).toInt()).toUtf8();
249
 
    bcfg << QString("e$turntime %1").arg(schemeData(27).toInt() * 1000).toUtf8();
250
 
    bcfg << QString("e$sd_turns %1").arg(schemeData(29).toInt()).toUtf8();
251
 
    bcfg << QString("e$casefreq %1").arg(schemeData(30).toInt()).toUtf8();
252
 
    bcfg << QString("e$minestime %1").arg(schemeData(31).toInt() * 1000).toUtf8();
253
 
    bcfg << QString("e$minesnum %1").arg(schemeData(32).toInt()).toUtf8();
254
 
    bcfg << QString("e$minedudpct %1").arg(schemeData(33).toInt()).toUtf8();
255
 
    bcfg << QString("e$explosives %1").arg(schemeData(34).toInt()).toUtf8();
256
 
    bcfg << QString("e$healthprob %1").arg(schemeData(35).toInt()).toUtf8();
257
 
    bcfg << QString("e$hcaseamount %1").arg(schemeData(36).toInt()).toUtf8();
258
 
    bcfg << QString("e$waterrise %1").arg(schemeData(37).toInt()).toUtf8();
259
 
    bcfg << QString("e$healthdec %1").arg(schemeData(38).toInt()).toUtf8();
260
 
    bcfg << QString("e$ropepct %1").arg(schemeData(39).toInt()).toUtf8();
261
 
    bcfg << QString("e$getawaytime %1").arg(schemeData(40).toInt()).toUtf8();
262
 
    bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8();
263
 
    bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8();
264
 
 
265
 
    switch (mapgen)
266
 
    {
267
 
        case MAPGEN_MAZE:
268
 
            bcfg << QString("e$maze_size %1").arg(pMapContainer->getMazeSize()).toUtf8();
269
 
            break;
270
 
 
271
 
        case MAPGEN_DRAWN:
272
 
        {
273
 
            QByteArray data = pMapContainer->getDrawnMapData();
274
 
            while(data.size() > 0)
275
 
            {
276
 
                QByteArray tmp = data;
277
 
                tmp.truncate(200);
278
 
                tmp.prepend("edraw ");
279
 
                bcfg << tmp;
280
 
                data.remove(0, 200);
281
 
            }
282
 
            break;
283
 
        }
284
 
        default: ;
285
 
    }
286
 
 
287
 
    QByteArray result;
288
 
 
289
 
    foreach(QByteArray ba, bcfg)
290
 
        HWProto::addByteArrayToBuffer(result, ba);
291
 
 
292
 
    return result;
293
 
}
294
 
 
295
 
void GameCFGWidget::setNetAmmo(const QString& name, const QString& ammo)
296
 
{
297
 
    bool illegal = ammo.size() != cDefaultAmmoStore->size();
298
 
    if (illegal)
299
 
        QMessageBox::critical(this, tr("Error"), tr("Illegal ammo scheme"));
300
 
 
301
 
    int pos = WeaponsName->findText(name);
302
 
    if ((pos == -1) || illegal) { // prevent from overriding schemes with bad ones
303
 
        WeaponsName->addItem(name, ammo);
304
 
        WeaponsName->setCurrentIndex(WeaponsName->count() - 1);
305
 
    } else {
306
 
        WeaponsName->setItemData(pos, ammo);
307
 
        WeaponsName->setCurrentIndex(pos);
308
 
    }
309
 
}
310
 
 
311
 
void GameCFGWidget::fullNetConfig()
312
 
{
313
 
    ammoChanged(WeaponsName->currentIndex());
314
 
 
315
 
    seedChanged(pMapContainer->getCurrentSeed());
316
 
    templateFilterChanged(pMapContainer->getTemplateFilter());
317
 
    themeChanged(pMapContainer->getCurrentTheme());
318
 
 
319
 
    schemeChanged(GameSchemes->currentIndex());
320
 
    scriptChanged(Scripts->currentIndex());
321
 
 
322
 
    mapgenChanged(pMapContainer->get_mapgen());
323
 
    maze_sizeChanged(pMapContainer->getMazeSize());
324
 
 
325
 
    // map must be the last
326
 
    QString map = pMapContainer->getCurrentMap();
327
 
    if (map.size())
328
 
        mapChanged(map);
329
 
}
330
 
 
331
 
void GameCFGWidget::setParam(const QString & param, const QStringList & slValue)
332
 
{
333
 
    if (slValue.size() == 1)
334
 
    {
335
 
        QString value = slValue[0];
336
 
        if (param == "MAP") {
337
 
            pMapContainer->setMap(value);
338
 
            return;
339
 
        }
340
 
        if (param == "SEED") {
341
 
            pMapContainer->setSeed(value);
342
 
            if (!seedRegexp.exactMatch(value)) {
343
 
                pMapContainer->seedEdit->setVisible(true);
344
 
                }
345
 
            return;
346
 
        }
347
 
        if (param == "THEME") {
348
 
            pMapContainer->setTheme(value);
349
 
            return;
350
 
        }
351
 
        if (param == "TEMPLATE") {
352
 
            pMapContainer->setTemplateFilter(value.toUInt());
353
 
            return;
354
 
        }
355
 
        if (param == "MAPGEN") {
356
 
            pMapContainer->setMapgen((MapGenerator)value.toUInt());
357
 
            return;
358
 
        }
359
 
        if (param == "MAZE_SIZE") {
360
 
            pMapContainer->setMazeSize(value.toUInt());
361
 
            return;
362
 
        }
363
 
        if (param == "SCRIPT") {
364
 
            Scripts->setCurrentIndex(Scripts->findText(value));
365
 
            return;
366
 
        }
367
 
        if (param == "DRAWNMAP") {
368
 
            pMapContainer->setDrawnMapData(qUncompress(QByteArray::fromBase64(slValue[0].toLatin1())));
369
 
            return;
370
 
        }
371
 
    }
372
 
 
373
 
    if (slValue.size() == 2)
374
 
    {
375
 
        if (param == "AMMO") {
376
 
            setNetAmmo(slValue[0], slValue[1]);
377
 
            return;
378
 
        }
379
 
    }
380
 
 
381
 
    if (slValue.size() == 5)
382
 
    {
383
 
        if (param == "FULLMAPCONFIG")
384
 
        {
385
 
            QString seed = slValue[3];
386
 
            if (!seedRegexp.exactMatch(seed))
387
 
                pMapContainer->seedEdit->setVisible(true);
388
 
 
389
 
            pMapContainer->setAllMapParameters(
390
 
                    slValue[0],
391
 
                    (MapGenerator)slValue[1].toUInt(),
392
 
                    slValue[2].toUInt(),
393
 
                    seed,
394
 
                    slValue[4].toUInt()
395
 
                    );
396
 
            return;
397
 
        }
398
 
    }
399
 
 
400
 
    qWarning("Got bad config param from net");
401
 
}
402
 
 
403
 
void GameCFGWidget::ammoChanged(int index)
404
 
{
405
 
    if (index >= 0) {
406
 
        emit paramChanged(
407
 
            "AMMO",
408
 
            QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
409
 
        );
410
 
    }
411
 
}
412
 
 
413
 
void GameCFGWidget::mapChanged(const QString & value)
414
 
{
415
 
    if(isEnabled() && pMapContainer->getCurrentIsMission())
416
 
    {
417
 
        Scripts->setEnabled(false);
418
 
        Scripts->setCurrentIndex(0);
419
 
 
420
 
        if (pMapContainer->getCurrentScheme() == "locked")
421
 
        {
422
 
            GameSchemes->setEnabled(false);
423
 
            GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
424
 
        }
425
 
        else
426
 
        {
427
 
            GameSchemes->setEnabled(true);
428
 
            int num = GameSchemes->findText(pMapContainer->getCurrentScheme());
429
 
            if (num != -1)
430
 
                GameSchemes->setCurrentIndex(num);
431
 
            else
432
 
                GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
433
 
        }
434
 
 
435
 
        if (pMapContainer->getCurrentWeapons() == "locked")
436
 
        {
437
 
            WeaponsName->setEnabled(false);
438
 
            WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
439
 
        }
440
 
        else
441
 
        {
442
 
            WeaponsName->setEnabled(true);
443
 
            int num = WeaponsName->findText(pMapContainer->getCurrentWeapons());
444
 
            if (num != -1)
445
 
                WeaponsName->setCurrentIndex(num);
446
 
            else
447
 
                WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
448
 
        }
449
 
 
450
 
        if (pMapContainer->getCurrentScheme() != "locked" && pMapContainer->getCurrentWeapons() != "locked")
451
 
            bindEntries->setEnabled(true);
452
 
        else
453
 
            bindEntries->setEnabled(false);
454
 
    }
455
 
    else
456
 
    {
457
 
        Scripts->setEnabled(true);
458
 
        GameSchemes->setEnabled(true);
459
 
        WeaponsName->setEnabled(true);
460
 
        bindEntries->setEnabled(true);
461
 
    }
462
 
    emit paramChanged("MAP", QStringList(value));
463
 
}
464
 
 
465
 
void GameCFGWidget::templateFilterChanged(int value)
466
 
{
467
 
    emit paramChanged("TEMPLATE", QStringList(QString::number(value)));
468
 
}
469
 
 
470
 
void GameCFGWidget::seedChanged(const QString & value)
471
 
{
472
 
    emit paramChanged("SEED", QStringList(value));
473
 
}
474
 
 
475
 
void GameCFGWidget::themeChanged(const QString & value)
476
 
{
477
 
    emit paramChanged("THEME", QStringList(value));
478
 
}
479
 
 
480
 
void GameCFGWidget::schemeChanged(int index)
481
 
{
482
 
    QStringList sl;
483
 
 
484
 
    int size = GameSchemes->model()->columnCount();
485
 
    for(int i = 0; i < size; ++i)
486
 
        sl << schemeData(i).toString();
487
 
 
488
 
    emit paramChanged("SCHEME", sl);
489
 
 
490
 
    if (isEnabled() && bindEntries->isEnabled() && bindEntries->isChecked()) {
491
 
        QString schemeName = GameSchemes->itemText(index);
492
 
        for (int i = 0; i < WeaponsName->count(); i++) {
493
 
             QString weapName = WeaponsName->itemText(i);
494
 
             int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
495
 
             if (0 == res) {
496
 
                 WeaponsName->setCurrentIndex(i);
497
 
                 emit ammoChanged(i);
498
 
                 break;
499
 
             }
500
 
        }
501
 
    }
502
 
}
503
 
 
504
 
void GameCFGWidget::scriptChanged(int index)
505
 
{
506
 
    if(isEnabled() && index > 0)
507
 
    {
508
 
        QString scheme = Scripts->itemData(Scripts->currentIndex()).toList()[1].toString();
509
 
        QString weapons = Scripts->itemData(Scripts->currentIndex()).toList()[2].toString();
510
 
 
511
 
        if (scheme == "locked")
512
 
        {
513
 
            GameSchemes->setEnabled(false);
514
 
            GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
515
 
        }
516
 
        else
517
 
        {
518
 
            GameSchemes->setEnabled(true);
519
 
            int num = GameSchemes->findText(scheme);
520
 
            if (num != -1)
521
 
                GameSchemes->setCurrentIndex(num);
522
 
            else
523
 
                GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
524
 
        }
525
 
 
526
 
        if (weapons == "locked")
527
 
        {
528
 
            WeaponsName->setEnabled(false);
529
 
            WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
530
 
        }
531
 
        else
532
 
        {
533
 
            WeaponsName->setEnabled(true);
534
 
            int num = WeaponsName->findText(weapons);
535
 
            if (num != -1)
536
 
                WeaponsName->setCurrentIndex(num);
537
 
            else
538
 
                WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
539
 
        }
540
 
 
541
 
        if (scheme != "locked" && weapons != "locked")
542
 
            bindEntries->setEnabled(true);
543
 
        else
544
 
            bindEntries->setEnabled(false);
545
 
    }
546
 
    else
547
 
    {
548
 
        GameSchemes->setEnabled(true);
549
 
        WeaponsName->setEnabled(true);
550
 
        bindEntries->setEnabled(true);
551
 
    }
552
 
    emit paramChanged("SCRIPT", QStringList(Scripts->itemText(index)));
553
 
}
554
 
 
555
 
void GameCFGWidget::mapgenChanged(MapGenerator m)
556
 
{
557
 
    emit paramChanged("MAPGEN", QStringList(QString::number(m)));
558
 
}
559
 
 
560
 
void GameCFGWidget::maze_sizeChanged(int s)
561
 
{
562
 
    emit paramChanged("MAZE_SIZE", QStringList(QString::number(s)));
563
 
}
564
 
 
565
 
void GameCFGWidget::resendSchemeData()
566
 
{
567
 
    schemeChanged(GameSchemes->currentIndex());
568
 
}
569
 
 
570
 
void GameCFGWidget::onDrawnMapChanged(const QByteArray & data)
571
 
{
572
 
    emit paramChanged("DRAWNMAP", QStringList(qCompress(data, 9).toBase64()));
573
 
}