QTfrontend/gamecfgwidget.cpp
changeset 1517 27caa8c6e73a
parent 1479 91e399fc8f5f
child 1530 3b8d723661b2
equal deleted inserted replaced
1516:bb9fa5809c49 1517:27caa8c6e73a
    20 #include <QGroupBox>
    20 #include <QGroupBox>
    21 #include <QCheckBox>
    21 #include <QCheckBox>
    22 #include <QGridLayout>
    22 #include <QGridLayout>
    23 #include <QSpinBox>
    23 #include <QSpinBox>
    24 #include <QLabel>
    24 #include <QLabel>
       
    25 #include <QMessageBox>
    25 
    26 
    26 #include "gamecfgwidget.h"
    27 #include "gamecfgwidget.h"
    27 #include "igbox.h"
    28 #include "igbox.h"
       
    29 #include "hwconsts.h"
    28 
    30 
    29 GameCFGWidget::GameCFGWidget(QWidget* parent, bool externalControl) :
    31 GameCFGWidget::GameCFGWidget(QWidget* parent, bool externalControl) :
    30   QGroupBox(parent), mainLayout(this)
    32   QGroupBox(parent), mainLayout(this)
    31 {
    33 {
    32 	mainLayout.setMargin(0);
    34 	mainLayout.setMargin(0);
   116 quint32 GameCFGWidget::getTurnTime() const
   118 quint32 GameCFGWidget::getTurnTime() const
   117 {
   119 {
   118 	return SB_TurnTime->value();
   120 	return SB_TurnTime->value();
   119 }
   121 }
   120 
   122 
   121 QString GameCFGWidget::getNetAmmo() const
       
   122 {
       
   123   return curNetAmmo;
       
   124 }
       
   125 
       
   126 QStringList GameCFGWidget::getFullConfig() const
   123 QStringList GameCFGWidget::getFullConfig() const
   127 {
   124 {
   128 	QStringList sl;
   125 	QStringList sl;
   129 	sl.append("eseed " + getCurrentSeed());
   126 	sl.append("eseed " + getCurrentSeed());
   130 	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
   127 	sl.append(QString("e$gmflags %1").arg(getGameFlags()));
   171 	CB_teamsDivide->setChecked(value);
   168 	CB_teamsDivide->setChecked(value);
   172 }
   169 }
   173 
   170 
   174 void GameCFGWidget::setNetAmmo(const QString& name, const QString& ammo)
   171 void GameCFGWidget::setNetAmmo(const QString& name, const QString& ammo)
   175 {
   172 {
   176   curNetAmmoName=name;
   173 	if (ammo.size() != cDefaultAmmoStore->size() - 10)
   177   curNetAmmo=ammo;
   174 		QMessageBox::critical(this, tr("Error"), tr("Illegal ammo scheme"));
   178 
   175 
   179   WeaponsName->setEditable(false);
   176 	int pos = WeaponsName->findText(name);
   180   WeaponsName->clear();
   177 	if (pos == -1) {
   181   WeaponsName->addItem(name);
   178 		WeaponsName->addItem(name, ammo);
   182 }
   179 		WeaponsName->setCurrentIndex(WeaponsName->count() - 1);
       
   180 	} else {
       
   181 		WeaponsName->setItemData(pos, ammo);
       
   182 		WeaponsName->setCurrentIndex(pos);
       
   183 	}
       
   184 	}