54 GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), GBoxOptions), 1, 0); |
54 GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), GBoxOptions), 1, 0); |
55 |
55 |
56 Scripts = new QComboBox(GBoxOptions); |
56 Scripts = new QComboBox(GBoxOptions); |
57 GBoxOptionsLayout->addWidget(Scripts, 1, 1); |
57 GBoxOptionsLayout->addWidget(Scripts, 1, 1); |
58 |
58 |
59 Scripts->addItem("Normal"); |
59 Scripts->setModel(DataManager::instance().gameStyleModel()); |
60 Scripts->insertSeparator(1); |
|
61 |
|
62 for (int i = 0; i < scriptList->size(); ++i) |
|
63 { |
|
64 QString script = (*scriptList)[i].remove(".lua", Qt::CaseInsensitive); |
|
65 QList<QVariant> scriptInfo; |
|
66 scriptInfo.push_back(script); |
|
67 QFile scriptCfgFile(DataManager::instance().findFileForRead( |
|
68 QString("Scripts/Multiplayer/%2.cfg").arg(script))); |
|
69 if (scriptCfgFile.exists() && scriptCfgFile.open(QFile::ReadOnly)) |
|
70 { |
|
71 QString scheme; |
|
72 QString weapons; |
|
73 QTextStream input(&scriptCfgFile); |
|
74 input >> scheme; |
|
75 input >> weapons; |
|
76 if (scheme.isEmpty()) |
|
77 scheme = "locked"; |
|
78 scheme.replace("_", " "); |
|
79 if (weapons.isEmpty()) |
|
80 weapons = "locked"; |
|
81 weapons.replace("_", " "); |
|
82 scriptInfo.push_back(scheme); |
|
83 scriptInfo.push_back(weapons); |
|
84 scriptCfgFile.close(); |
|
85 } |
|
86 else |
|
87 { |
|
88 scriptInfo.push_back("locked"); |
|
89 scriptInfo.push_back("locked"); |
|
90 } |
|
91 Scripts->addItem(script.replace("_", " "), scriptInfo); |
|
92 } |
|
93 |
|
94 connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int))); |
60 connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int))); |
95 |
61 |
96 QWidget *SchemeWidget = new QWidget(GBoxOptions); |
62 QWidget *SchemeWidget = new QWidget(GBoxOptions); |
97 GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2); |
63 GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2); |
98 |
64 |
242 } |
208 } |
243 bcfg << QString("etheme " + pMapContainer->getCurrentTheme()).toUtf8(); |
209 bcfg << QString("etheme " + pMapContainer->getCurrentTheme()).toUtf8(); |
244 |
210 |
245 if (Scripts->currentIndex() > 0) |
211 if (Scripts->currentIndex() > 0) |
246 { |
212 { |
247 bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex()).toList()[0].toString()).toUtf8(); |
213 bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString()).toUtf8(); |
248 } |
214 } |
249 |
215 |
250 bcfg << QString("eseed " + pMapContainer->getCurrentSeed()).toUtf8(); |
216 bcfg << QString("eseed " + pMapContainer->getCurrentSeed()).toUtf8(); |
251 bcfg << QString("e$gmflags %1").arg(getGameFlags()).toUtf8(); |
217 bcfg << QString("e$gmflags %1").arg(getGameFlags()).toUtf8(); |
252 bcfg << QString("e$damagepct %1").arg(schemeData(26).toInt()).toUtf8(); |
218 bcfg << QString("e$damagepct %1").arg(schemeData(26).toInt()).toUtf8(); |
525 |
491 |
526 void GameCFGWidget::scriptChanged(int index) |
492 void GameCFGWidget::scriptChanged(int index) |
527 { |
493 { |
528 if(isEnabled() && index > 0) |
494 if(isEnabled() && index > 0) |
529 { |
495 { |
530 QString scheme = Scripts->itemData(Scripts->currentIndex()).toList()[1].toString(); |
496 QString scheme = Scripts->itemData(Scripts->currentIndex(), GameStyleModel::SchemeRole).toString(); |
531 QString weapons = Scripts->itemData(Scripts->currentIndex()).toList()[2].toString(); |
497 QString weapons = Scripts->itemData(Scripts->currentIndex(), GameStyleModel::WeaponsRole).toString(); |
532 |
498 |
533 if (scheme == "locked") |
499 if (scheme == "locked") |
534 { |
500 { |
535 GameSchemes->setEnabled(false); |
501 GameSchemes->setEnabled(false); |
536 GameSchemes->setCurrentIndex(GameSchemes->findText("Default")); |
502 GameSchemes->setCurrentIndex(GameSchemes->findText("Default")); |