QTfrontend/gamecfgwidget.cpp
branchexperimental3D
changeset 4343 19cbea33e4d2
parent 4337 85e02b1a8e8f
child 4396 3cfd2e15464a
equal deleted inserted replaced
4006:45b63c2a694f 4343:19cbea33e4d2
    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 
    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);
       
    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)));
    85     connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &)));
    92     connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &)));
    99 quint32 GameCFGWidget::getGameFlags() const
   106 quint32 GameCFGWidget::getGameFlags() const
   100 {
   107 {
   101     quint32 result = 0;
   108     quint32 result = 0;
   102 
   109 
   103     if (schemeData(1).toBool())
   110     if (schemeData(1).toBool())
   104         result |= 0x00001000;
   111         result |= 0x00001000;       // fort
   105     if (schemeData(2).toBool())
   112     if (schemeData(2).toBool())
   106         result |= 0x00000010;
   113         result |= 0x00000010;       // divide teams
   107     if (schemeData(3).toBool())
   114     if (schemeData(3).toBool())
   108         result |= 0x00000004;
   115         result |= 0x00000004;       // solid land
   109     if (schemeData(4).toBool())
   116     if (schemeData(4).toBool())
   110         result |= 0x00000008;
   117         result |= 0x00000008;       // border
   111     if (schemeData(5).toBool())
   118     if (schemeData(5).toBool())
   112         result |= 0x00000020;
   119         result |= 0x00000020;       // low gravity
   113     if (schemeData(6).toBool())
   120     if (schemeData(6).toBool())
   114         result |= 0x00000040;
   121         result |= 0x00000040;       // laser sight
   115     if (schemeData(7).toBool())
   122     if (schemeData(7).toBool())
   116         result |= 0x00000080;
   123         result |= 0x00000080;       // invulnerable
   117     if (schemeData(8).toBool())
   124     if (schemeData(8).toBool())
   118         result |= 0x00000100;
   125         result |= 0x00000100;       // mines
   119     if (schemeData(9).toBool())
   126     if (schemeData(9).toBool())
   120         result |= 0x00000200;
   127         result |= 0x00000200;       // vampirism
   121     if (schemeData(10).toBool())
   128     if (schemeData(10).toBool())
   122         result |= 0x00000400;
   129         result |= 0x00000400;       // karma
   123     if (schemeData(11).toBool())
   130     if (schemeData(11).toBool())
   124         result |= 0x00000800;
   131         result |= 0x00000800;       // artillery
   125     if (schemeData(12).toBool())
   132     if (schemeData(12).toBool())
   126         result |= 0x00002000;
   133         result |= 0x00002000;       // random
   127     if (schemeData(13).toBool())
   134     if (schemeData(13).toBool())
   128         result |= 0x00004000;
   135         result |= 0x00004000;       // king
   129     if (schemeData(14).toBool())
   136     if (schemeData(14).toBool())
   130         result |= 0x00008000;
   137         result |= 0x00008000;       // place hogs
   131     if (schemeData(15).toBool())
   138     if (schemeData(15).toBool())
   132         result |= 0x00010000;
   139         result |= 0x00010000;       // shared ammo
   133     if (schemeData(16).toBool())
   140     if (schemeData(16).toBool())
   134         result |= 0x00020000;
   141         result |= 0x00020000;       // disable girders
   135     if (schemeData(17).toBool())
   142     if (schemeData(17).toBool())
   136         result |= 0x00040000;
   143         result |= 0x00040000;       // disable land obj
   137     if (schemeData(18).toBool())
   144     if (schemeData(18).toBool())
   138         result |= 0x00080000;
   145         result |= 0x00080000;       // ai survival
   139     if (schemeData(19).toBool())
   146     if (schemeData(19).toBool())
   140         result |= 0x00100000;
   147         result |= 0x00100000;       // infinite attacks
   141     if (schemeData(20).toBool())
   148     if (schemeData(20).toBool())
   142         result |= 0x00200000;
   149         result |= 0x00200000;       // reset weaps
   143     if (schemeData(21).toBool())
   150     if (schemeData(21).toBool())
   144         result |= 0x00400000;
   151         result |= 0x00400000;       // per hog ammo
       
   152     if (schemeData(22).toBool())
       
   153         result |= 0x00800000;       // no wind
       
   154     if (schemeData(23).toBool())
       
   155         result |= 0x01000000;       // more wind
   145 
   156 
   146     return result;
   157     return result;
   147 }
   158 }
   148 
   159 
   149 quint32 GameCFGWidget::getInitHealth() const
   160 quint32 GameCFGWidget::getInitHealth() const
   150 {
   161 {
   151     return schemeData(24).toInt();
   162     return schemeData(26).toInt();
   152 }
   163 }
   153 
   164 
   154 QStringList GameCFGWidget::getFullConfig() const
   165 QStringList GameCFGWidget::getFullConfig() const
   155 {
   166 {
   156     QStringList sl;
   167     QStringList sl;
   157     sl.append("eseed " + pMapContainer->getCurrentSeed());
   168     sl.append("eseed " + pMapContainer->getCurrentSeed());
   158     sl.append(QString("e$gmflags %1").arg(getGameFlags()));
   169     sl.append(QString("e$gmflags %1").arg(getGameFlags()));
   159     sl.append(QString("e$damagepct %1").arg(schemeData(22).toInt()));
   170     sl.append(QString("e$damagepct %1").arg(schemeData(24).toInt()));
   160     sl.append(QString("e$turntime %1").arg(schemeData(23).toInt() * 1000));
   171     sl.append(QString("e$turntime %1").arg(schemeData(25).toInt() * 1000));
   161     sl.append(QString("e$minestime %1").arg(schemeData(27).toInt() * 1000));
   172     sl.append(QString("e$sd_turns %1").arg(schemeData(27).toInt()));
   162     sl.append(QString("e$landadds %1").arg(schemeData(28).toInt()));
   173     sl.append(QString("e$casefreq %1").arg(schemeData(28).toInt()));
   163     sl.append(QString("e$sd_turns %1").arg(schemeData(25).toInt()));
   174     sl.append(QString("e$minestime %1").arg(schemeData(29).toInt()));
   164     sl.append(QString("e$casefreq %1").arg(schemeData(26).toInt()));
   175     sl.append(QString("e$minesnum %1").arg(schemeData(30).toInt()));
   165     sl.append(QString("e$minedudpct %1").arg(schemeData(29).toInt()));
   176     sl.append(QString("e$minedudpct %1").arg(schemeData(31).toInt()));
   166     sl.append(QString("e$explosives %1").arg(schemeData(30).toInt()));
   177     sl.append(QString("e$explosives %1").arg(schemeData(32).toInt()));
       
   178     sl.append(QString("e$healthprob %1").arg(schemeData(33).toInt()));
       
   179     sl.append(QString("e$hcaseamount %1").arg(schemeData(34).toInt()));
       
   180     sl.append(QString("e$waterrise %1").arg(schemeData(35).toInt()));
       
   181     sl.append(QString("e$healthdec %1").arg(schemeData(36).toInt()));
   167     sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
   182     sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()));
   168     sl.append(QString("e$mapgen %1").arg(pMapContainer->get_mapgen()));
   183     sl.append(QString("e$mapgen %1").arg(pMapContainer->get_mapgen()));
   169     sl.append(QString("e$maze_size %1").arg(pMapContainer->get_maze_size()));
   184     sl.append(QString("e$maze_size %1").arg(pMapContainer->get_maze_size()));
   170 
   185 
   171     QString currentMap = pMapContainer->getCurrentMap();
   186     QString currentMap = pMapContainer->getCurrentMap();
   257     qWarning("Got bad config param from net");
   272     qWarning("Got bad config param from net");
   258 }
   273 }
   259 
   274 
   260 void GameCFGWidget::ammoChanged(int index)
   275 void GameCFGWidget::ammoChanged(int index)
   261 {
   276 {
   262     if (index >= 0)
   277     if (index >= 0) {
   263         emit paramChanged(
   278         emit paramChanged(
   264             "AMMO",
   279             "AMMO",
   265             QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
   280             QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
   266         );
   281         );
       
   282         if (bindEntries->isChecked() == true) {
       
   283             QString weapName = WeaponsName->itemText(index);
       
   284             for (int i = 0; i < GameSchemes->count(); i++) {
       
   285                  QString schemeName = GameSchemes->itemText(i);
       
   286                  int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
       
   287                  if (0 == res) {
       
   288                      GameSchemes->setCurrentIndex(i);
       
   289                      break;
       
   290                  }
       
   291             }
       
   292         }
       
   293     }
   267 }
   294 }
   268 
   295 
   269 void GameCFGWidget::mapChanged(const QString & value)
   296 void GameCFGWidget::mapChanged(const QString & value)
   270 {
   297 {
   271     if(pMapContainer->getCurrentIsMission())
   298     if(pMapContainer->getCurrentIsMission())
   272     {
   299     {
   273         GameSchemes->setEnabled(false);
   300         GameSchemes->setEnabled(false);
   274         WeaponsName->setEnabled(false);
   301         WeaponsName->setEnabled(false);
       
   302         bindEntries->setEnabled(false);
   275         GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
   303         GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
   276         WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
   304         WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
   277     }
   305     }
   278     else
   306     else
   279     {
   307     {
   280         GameSchemes->setEnabled(true);
   308         GameSchemes->setEnabled(true);
   281         WeaponsName->setEnabled(true);
   309         WeaponsName->setEnabled(true);
       
   310         bindEntries->setEnabled(true);
   282     }
   311     }
   283     emit paramChanged("MAP", QStringList(value));
   312     emit paramChanged("MAP", QStringList(value));
   284 }
   313 }
   285 
   314 
   286 void GameCFGWidget::templateFilterChanged(int value)
   315 void GameCFGWidget::templateFilterChanged(int value)
   296 void GameCFGWidget::themeChanged(const QString & value)
   325 void GameCFGWidget::themeChanged(const QString & value)
   297 {
   326 {
   298     emit paramChanged("THEME", QStringList(value));
   327     emit paramChanged("THEME", QStringList(value));
   299 }
   328 }
   300 
   329 
   301 void GameCFGWidget::schemeChanged(int value)
   330 void GameCFGWidget::schemeChanged(int index)
   302 {
   331 {
   303     QStringList sl;
   332     QStringList sl;
   304 
   333 
   305     int size = GameSchemes->model()->columnCount();
   334     int size = GameSchemes->model()->columnCount();
   306     for(int i = 0; i < size; ++i)
   335     for(int i = 0; i < size; ++i)
   307         sl << schemeData(i).toString();
   336         sl << schemeData(i).toString();
   308 
   337 
   309     emit paramChanged("SCHEME", sl);
   338     emit paramChanged("SCHEME", sl);
       
   339 
       
   340     if (bindEntries->isChecked() == true) {
       
   341         QString schemeName = GameSchemes->itemText(index);
       
   342         for (int i = 0; i < WeaponsName->count(); i++) {
       
   343              QString weapName = WeaponsName->itemText(i);
       
   344              int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
       
   345              if (0 == res) {
       
   346                  WeaponsName->setCurrentIndex(i);
       
   347                  break;
       
   348              }
       
   349         }
       
   350     }
   310 }
   351 }
   311 
   352 
   312 void GameCFGWidget::mapgenChanged(MapGenerator m)
   353 void GameCFGWidget::mapgenChanged(MapGenerator m)
   313 {
   354 {
   314     emit paramChanged("MAPGEN", QStringList(QString::number(m)));
   355     emit paramChanged("MAPGEN", QStringList(QString::number(m)));