QTfrontend/gamecfgwidget.cpp
changeset 4237 ef9b201c97fe
parent 4225 ce9e2b05e9c1
child 4248 e127b3d26248
child 4324 43e3f1eeceb5
equal deleted inserted replaced
4236:fa2680cfff86 4237:ef9b201c97fe
    75     goToWeaponPage->setIcon(pmEdit);
    75     goToWeaponPage->setIcon(pmEdit);
    76     goToWeaponPage->setMaximumWidth(pmEdit.width() + 6);
    76     goToWeaponPage->setMaximumWidth(pmEdit.width() + 6);
    77     GBoxOptionsLayout->addWidget(goToWeaponPage, 1, 2);
    77     GBoxOptionsLayout->addWidget(goToWeaponPage, 1, 2);
    78 
    78 
    79     connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons()));
    79     connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons()));
       
    80 
       
    81     GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Bind schemes and weapons"), GBoxOptions), 2, 0);
       
    82 
       
    83     bindEntries = new QCheckBox(GBoxOptions);
       
    84     bindEntries->setToolTip(tr("When this option is enabled selecting a game scheme will auto-select a weapon (and viceversa)"));
       
    85     bindEntries->setChecked(true);
       
    86     GBoxOptionsLayout->addWidget(bindEntries, 2, 2);
    80 
    87 
    81     connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
    88     connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
    82     connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &)));
    89     connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &)));
    83     connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator)));
    90     connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator)));
    84     connect(pMapContainer, SIGNAL(maze_sizeChanged(int)), this, SLOT(maze_sizeChanged(int)));
    91     connect(pMapContainer, SIGNAL(maze_sizeChanged(int)), this, SLOT(maze_sizeChanged(int)));
   261     qWarning("Got bad config param from net");
   268     qWarning("Got bad config param from net");
   262 }
   269 }
   263 
   270 
   264 void GameCFGWidget::ammoChanged(int index)
   271 void GameCFGWidget::ammoChanged(int index)
   265 {
   272 {
   266     if (index >= 0)
   273     if (index >= 0) {
   267         emit paramChanged(
   274         emit paramChanged(
   268             "AMMO",
   275             "AMMO",
   269             QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
   276             QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
   270         );
   277         );
       
   278         if (bindEntries->isChecked() == true) {
       
   279             QString weapName = WeaponsName->itemText(index);
       
   280             for (int i = 0; i < GameSchemes->count(); i++) {
       
   281                  QString schemeName = GameSchemes->itemText(i);
       
   282                  int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
       
   283                  if (0 == res) {
       
   284                      GameSchemes->setCurrentIndex(i);
       
   285                      break;
       
   286                  }
       
   287             }
       
   288         }
       
   289     }
   271 }
   290 }
   272 
   291 
   273 void GameCFGWidget::mapChanged(const QString & value)
   292 void GameCFGWidget::mapChanged(const QString & value)
   274 {
   293 {
   275     if(pMapContainer->getCurrentIsMission())
   294     if(pMapContainer->getCurrentIsMission())
   276     {
   295     {
   277         GameSchemes->setEnabled(false);
   296         GameSchemes->setEnabled(false);
   278         WeaponsName->setEnabled(false);
   297         WeaponsName->setEnabled(false);
       
   298         bindEntries->setEnabled(false);
   279         GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
   299         GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
   280         WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
   300         WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
   281     }
   301     }
   282     else
   302     else
   283     {
   303     {
   284         GameSchemes->setEnabled(true);
   304         GameSchemes->setEnabled(true);
   285         WeaponsName->setEnabled(true);
   305         WeaponsName->setEnabled(true);
       
   306         bindEntries->setEnabled(true);
   286     }
   307     }
   287     emit paramChanged("MAP", QStringList(value));
   308     emit paramChanged("MAP", QStringList(value));
   288 }
   309 }
   289 
   310 
   290 void GameCFGWidget::templateFilterChanged(int value)
   311 void GameCFGWidget::templateFilterChanged(int value)
   300 void GameCFGWidget::themeChanged(const QString & value)
   321 void GameCFGWidget::themeChanged(const QString & value)
   301 {
   322 {
   302     emit paramChanged("THEME", QStringList(value));
   323     emit paramChanged("THEME", QStringList(value));
   303 }
   324 }
   304 
   325 
   305 void GameCFGWidget::schemeChanged(int value)
   326 void GameCFGWidget::schemeChanged(int index)
   306 {
   327 {
   307     QStringList sl;
   328     QStringList sl;
   308 
   329 
   309     int size = GameSchemes->model()->columnCount();
   330     int size = GameSchemes->model()->columnCount();
   310     for(int i = 0; i < size; ++i)
   331     for(int i = 0; i < size; ++i)
   311         sl << schemeData(i).toString();
   332         sl << schemeData(i).toString();
   312 
   333 
   313     emit paramChanged("SCHEME", sl);
   334     emit paramChanged("SCHEME", sl);
       
   335 
       
   336     if (bindEntries->isChecked() == true) {
       
   337         QString schemeName = GameSchemes->itemText(index);
       
   338         for (int i = 0; i < WeaponsName->count(); i++) {
       
   339              QString weapName = WeaponsName->itemText(i);
       
   340              int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
       
   341              if (0 == res) {
       
   342                  WeaponsName->setCurrentIndex(i);
       
   343                  break;
       
   344              }
       
   345         }
       
   346     }
   314 }
   347 }
   315 
   348 
   316 void GameCFGWidget::mapgenChanged(MapGenerator m)
   349 void GameCFGWidget::mapgenChanged(MapGenerator m)
   317 {
   350 {
   318     emit paramChanged("MAPGEN", QStringList(QString::number(m)));
   351     emit paramChanged("MAPGEN", QStringList(QString::number(m)));