1 /* |
1 /* |
2 * Hedgewars, a free turn based strategy game |
2 * Hedgewars, a free turn based strategy game |
3 * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
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 |
6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. |
12 * GNU General Public License for more details. |
13 * |
13 * |
14 * You should have received a copy of the GNU General Public License |
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 |
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 |
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 */ |
17 */ |
18 |
18 |
19 #include <QResizeEvent> |
19 #include <QResizeEvent> |
20 #include <QGroupBox> |
20 #include <QGroupBox> |
21 #include <QCheckBox> |
21 #include <QCheckBox> |
161 |
161 |
162 connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &))); |
162 connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &))); |
163 connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &))); |
163 connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &))); |
164 connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator))); |
164 connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator))); |
165 connect(pMapContainer, SIGNAL(mazeSizeChanged(int)), this, SLOT(maze_sizeChanged(int))); |
165 connect(pMapContainer, SIGNAL(mazeSizeChanged(int)), this, SLOT(maze_sizeChanged(int))); |
|
166 connect(pMapContainer, SIGNAL(mapFeatureSizeChanged(int)), this, SLOT(slMapFeatureSizeChanged(int))); |
166 connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &))); |
167 connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &))); |
167 connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int))); |
168 connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int))); |
168 connect(pMapContainer, SIGNAL(drawMapRequested()), this, SIGNAL(goToDrawMap())); |
169 connect(pMapContainer, SIGNAL(drawMapRequested()), this, SIGNAL(goToDrawMap())); |
169 connect(pMapContainer, SIGNAL(drawnMapChanged(const QByteArray &)), this, SLOT(onDrawnMapChanged(const QByteArray &))); |
170 connect(pMapContainer, SIGNAL(drawnMapChanged(const QByteArray &)), this, SLOT(onDrawnMapChanged(const QByteArray &))); |
170 |
171 |
313 bcfg << QString("e$casefreq %1").arg(schemeData(30).toInt()).toUtf8(); |
314 bcfg << QString("e$casefreq %1").arg(schemeData(30).toInt()).toUtf8(); |
314 bcfg << QString("e$minestime %1").arg(schemeData(31).toInt() * 1000).toUtf8(); |
315 bcfg << QString("e$minestime %1").arg(schemeData(31).toInt() * 1000).toUtf8(); |
315 bcfg << QString("e$minesnum %1").arg(schemeData(32).toInt()).toUtf8(); |
316 bcfg << QString("e$minesnum %1").arg(schemeData(32).toInt()).toUtf8(); |
316 bcfg << QString("e$minedudpct %1").arg(schemeData(33).toInt()).toUtf8(); |
317 bcfg << QString("e$minedudpct %1").arg(schemeData(33).toInt()).toUtf8(); |
317 bcfg << QString("e$explosives %1").arg(schemeData(34).toInt()).toUtf8(); |
318 bcfg << QString("e$explosives %1").arg(schemeData(34).toInt()).toUtf8(); |
318 bcfg << QString("e$healthprob %1").arg(schemeData(35).toInt()).toUtf8(); |
319 bcfg << QString("e$airmines %1").arg(schemeData(35).toInt()).toUtf8(); |
319 bcfg << QString("e$hcaseamount %1").arg(schemeData(36).toInt()).toUtf8(); |
320 bcfg << QString("e$healthprob %1").arg(schemeData(36).toInt()).toUtf8(); |
320 bcfg << QString("e$waterrise %1").arg(schemeData(37).toInt()).toUtf8(); |
321 bcfg << QString("e$hcaseamount %1").arg(schemeData(37).toInt()).toUtf8(); |
321 bcfg << QString("e$healthdec %1").arg(schemeData(38).toInt()).toUtf8(); |
322 bcfg << QString("e$waterrise %1").arg(schemeData(38).toInt()).toUtf8(); |
322 bcfg << QString("e$ropepct %1").arg(schemeData(39).toInt()).toUtf8(); |
323 bcfg << QString("e$healthdec %1").arg(schemeData(39).toInt()).toUtf8(); |
323 bcfg << QString("e$getawaytime %1").arg(schemeData(40).toInt()).toUtf8(); |
324 bcfg << QString("e$ropepct %1").arg(schemeData(40).toInt()).toUtf8(); |
324 bcfg << QString("e$worldedge %1").arg(schemeData(41).toInt()).toUtf8(); |
325 bcfg << QString("e$getawaytime %1").arg(schemeData(41).toInt()).toUtf8(); |
|
326 bcfg << QString("e$worldedge %1").arg(schemeData(42).toInt()).toUtf8(); |
325 bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8(); |
327 bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8(); |
|
328 bcfg << QString("e$feature_size %1").arg(pMapContainer->getFeatureSize()).toUtf8(); |
326 bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8(); |
329 bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8(); |
327 |
330 if(!schemeData(43).isNull()) |
|
331 bcfg << QString("e$scriptparam %1").arg(schemeData(43).toString()).toUtf8(); |
328 |
332 |
329 |
333 |
330 switch (mapgen) |
334 switch (mapgen) |
331 { |
335 { |
332 case MAPGEN_MAZE: |
336 case MAPGEN_MAZE: |
|
337 case MAPGEN_PERLIN: |
333 bcfg << QString("e$maze_size %1").arg(pMapContainer->getMazeSize()).toUtf8(); |
338 bcfg << QString("e$maze_size %1").arg(pMapContainer->getMazeSize()).toUtf8(); |
334 break; |
339 break; |
335 |
340 |
336 case MAPGEN_DRAWN: |
341 case MAPGEN_DRAWN: |
337 { |
342 { |
398 schemeChanged(GameSchemes->currentIndex()); |
403 schemeChanged(GameSchemes->currentIndex()); |
399 scriptChanged(Scripts->currentIndex()); |
404 scriptChanged(Scripts->currentIndex()); |
400 |
405 |
401 mapgenChanged(pMapContainer->get_mapgen()); |
406 mapgenChanged(pMapContainer->get_mapgen()); |
402 maze_sizeChanged(pMapContainer->getMazeSize()); |
407 maze_sizeChanged(pMapContainer->getMazeSize()); |
|
408 slMapFeatureSizeChanged(pMapContainer->getFeatureSize()); |
|
409 |
|
410 if(pMapContainer->get_mapgen() == 2) |
|
411 onDrawnMapChanged(pMapContainer->getDrawnMapData()); |
403 |
412 |
404 // map must be the last |
413 // map must be the last |
405 QString map = pMapContainer->getCurrentMap(); |
414 QString map = pMapContainer->getCurrentMap(); |
406 if (map.size()) |
415 if (map.size()) |
407 mapChanged(map); |
416 mapChanged(map); |
435 if (param == "MAPGEN") |
444 if (param == "MAPGEN") |
436 { |
445 { |
437 pMapContainer->setMapgen((MapGenerator)value.toUInt()); |
446 pMapContainer->setMapgen((MapGenerator)value.toUInt()); |
438 return; |
447 return; |
439 } |
448 } |
|
449 if (param == "FEATURE_SIZE") |
|
450 { |
|
451 pMapContainer->setFeatureSize(value.toUInt()); |
|
452 return; |
|
453 } |
440 if (param == "MAZE_SIZE") |
454 if (param == "MAZE_SIZE") |
441 { |
455 { |
442 pMapContainer->setMazeSize(value.toUInt()); |
456 pMapContainer->setMazeSize(value.toUInt()); |
443 return; |
457 return; |
444 } |
458 } |
445 if (param == "SCRIPT") |
459 if (param == "SCRIPT") |
446 { |
460 { |
447 Scripts->setCurrentIndex(Scripts->findText(value)); |
461 Scripts->setCurrentIndex(Scripts->findText(value)); |
|
462 pMapContainer->setScript(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString().toUtf8(), schemeData(43).toString()); |
448 return; |
463 return; |
449 } |
464 } |
450 if (param == "DRAWNMAP") |
465 if (param == "DRAWNMAP") |
451 { |
466 { |
452 pMapContainer->setDrawnMapData(qUncompress(QByteArray::fromBase64(slValue[0].toLatin1()))); |
467 pMapContainer->setDrawnMapData(qUncompress(QByteArray::fromBase64(slValue[0].toLatin1()))); |
461 setNetAmmo(slValue[0], slValue[1]); |
476 setNetAmmo(slValue[0], slValue[1]); |
462 return; |
477 return; |
463 } |
478 } |
464 } |
479 } |
465 |
480 |
466 if (slValue.size() == 5) |
481 if (slValue.size() == 6) |
467 { |
482 { |
468 if (param == "FULLMAPCONFIG") |
483 if (param == "FULLMAPCONFIG") |
469 { |
484 { |
470 QString seed = slValue[3]; |
485 QString seed = slValue[4]; |
471 |
486 |
472 pMapContainer->setAllMapParameters( |
487 pMapContainer->setAllMapParameters( |
473 slValue[0], |
488 slValue[1], |
474 (MapGenerator)slValue[1].toUInt(), |
489 (MapGenerator)slValue[2].toUInt(), |
475 slValue[2].toUInt(), |
490 slValue[3].toUInt(), |
476 seed, |
491 seed, |
477 slValue[4].toUInt() |
492 slValue[5].toUInt(), |
|
493 slValue[0].toUInt() |
478 ); |
494 ); |
479 return; |
495 return; |
480 } |
496 } |
481 } |
497 } |
482 |
498 |
510 { |
526 { |
511 GameSchemes->setEnabled(true); |
527 GameSchemes->setEnabled(true); |
512 int num = GameSchemes->findText(pMapContainer->getCurrentScheme()); |
528 int num = GameSchemes->findText(pMapContainer->getCurrentScheme()); |
513 if (num != -1) |
529 if (num != -1) |
514 GameSchemes->setCurrentIndex(num); |
530 GameSchemes->setCurrentIndex(num); |
515 else |
531 //else |
516 GameSchemes->setCurrentIndex(GameSchemes->findText("Default")); |
532 // GameSchemes->setCurrentIndex(GameSchemes->findText("Default")); |
517 } |
533 } |
518 |
534 |
519 if (pMapContainer->getCurrentWeapons() == "locked") |
535 if (pMapContainer->getCurrentWeapons() == "locked") |
520 { |
536 { |
521 WeaponsName->setEnabled(false); |
537 WeaponsName->setEnabled(false); |
525 { |
541 { |
526 WeaponsName->setEnabled(true); |
542 WeaponsName->setEnabled(true); |
527 int num = WeaponsName->findText(pMapContainer->getCurrentWeapons()); |
543 int num = WeaponsName->findText(pMapContainer->getCurrentWeapons()); |
528 if (num != -1) |
544 if (num != -1) |
529 WeaponsName->setCurrentIndex(num); |
545 WeaponsName->setCurrentIndex(num); |
530 else |
546 //else |
531 WeaponsName->setCurrentIndex(WeaponsName->findText("Default")); |
547 // WeaponsName->setCurrentIndex(WeaponsName->findText("Default")); |
532 } |
548 } |
533 |
549 |
534 if (pMapContainer->getCurrentScheme() != "locked" && pMapContainer->getCurrentWeapons() != "locked") |
550 if (pMapContainer->getCurrentScheme() != "locked" && pMapContainer->getCurrentWeapons() != "locked") |
535 bindEntries->setEnabled(true); |
551 bindEntries->setEnabled(true); |
536 else |
552 else |
567 |
583 |
568 int size = GameSchemes->model()->columnCount(); |
584 int size = GameSchemes->model()->columnCount(); |
569 for(int i = 0; i < size; ++i) |
585 for(int i = 0; i < size; ++i) |
570 sl << schemeData(i).toString(); |
586 sl << schemeData(i).toString(); |
571 |
587 |
572 if (sl.size()!=1) emit paramChanged("SCHEME", sl); // this is a stupid hack for the fact that SCHEME is being sent once, empty. Still need to find out why. |
588 if (sl.size() >= 42) |
|
589 { |
|
590 sl[sl.size()-1].prepend('!'); |
|
591 emit paramChanged("SCHEME", sl); // this is a stupid hack for the fact that SCHEME is being sent once, empty. Still need to find out why. |
|
592 } |
573 |
593 |
574 if (isEnabled() && bindEntries->isEnabled() && bindEntries->isChecked()) |
594 if (isEnabled() && bindEntries->isEnabled() && bindEntries->isChecked()) |
575 { |
595 { |
576 QString schemeName = GameSchemes->itemText(index); |
596 QString schemeName = GameSchemes->itemText(index); |
577 for (int i = 0; i < WeaponsName->count(); i++) |
597 for (int i = 0; i < WeaponsName->count(); i++) |
607 { |
628 { |
608 GameSchemes->setEnabled(true); |
629 GameSchemes->setEnabled(true); |
609 int num = GameSchemes->findText(scheme); |
630 int num = GameSchemes->findText(scheme); |
610 if (num != -1) |
631 if (num != -1) |
611 GameSchemes->setCurrentIndex(num); |
632 GameSchemes->setCurrentIndex(num); |
612 else |
633 //else |
613 GameSchemes->setCurrentIndex(GameSchemes->findText("Default")); |
634 // GameSchemes->setCurrentIndex(GameSchemes->findText("Default")); |
614 } |
635 } |
615 |
636 |
616 if (weapons == "locked") |
637 if (weapons == "locked") |
617 { |
638 { |
618 WeaponsName->setEnabled(false); |
639 WeaponsName->setEnabled(false); |
622 { |
643 { |
623 WeaponsName->setEnabled(true); |
644 WeaponsName->setEnabled(true); |
624 int num = WeaponsName->findText(weapons); |
645 int num = WeaponsName->findText(weapons); |
625 if (num != -1) |
646 if (num != -1) |
626 WeaponsName->setCurrentIndex(num); |
647 WeaponsName->setCurrentIndex(num); |
627 else |
648 //else |
628 WeaponsName->setCurrentIndex(WeaponsName->findText("Default")); |
649 // WeaponsName->setCurrentIndex(WeaponsName->findText("Default")); |
629 } |
650 } |
630 |
651 |
631 if (scheme != "locked" && weapons != "locked") |
652 if (scheme != "locked" && weapons != "locked") |
632 bindEntries->setEnabled(true); |
653 bindEntries->setEnabled(true); |
633 else |
654 else |
637 { |
658 { |
638 GameSchemes->setEnabled(true); |
659 GameSchemes->setEnabled(true); |
639 WeaponsName->setEnabled(true); |
660 WeaponsName->setEnabled(true); |
640 bindEntries->setEnabled(true); |
661 bindEntries->setEnabled(true); |
641 } |
662 } |
|
663 if (!index) |
|
664 { |
|
665 pMapContainer->setScript(QString(""), QString("")); |
|
666 } |
|
667 else |
|
668 { |
|
669 pMapContainer->setScript(Scripts->itemData(index, GameStyleModel::ScriptRole).toString().toUtf8(), schemeData(43).toString()); |
|
670 } |
642 emit paramChanged("SCRIPT", QStringList(name)); |
671 emit paramChanged("SCRIPT", QStringList(name)); |
643 } |
672 } |
644 |
673 |
645 void GameCFGWidget::mapgenChanged(MapGenerator m) |
674 void GameCFGWidget::mapgenChanged(MapGenerator m) |
646 { |
675 { |
648 } |
677 } |
649 |
678 |
650 void GameCFGWidget::maze_sizeChanged(int s) |
679 void GameCFGWidget::maze_sizeChanged(int s) |
651 { |
680 { |
652 emit paramChanged("MAZE_SIZE", QStringList(QString::number(s))); |
681 emit paramChanged("MAZE_SIZE", QStringList(QString::number(s))); |
|
682 } |
|
683 |
|
684 void GameCFGWidget::slMapFeatureSizeChanged(int s) |
|
685 { |
|
686 emit paramChanged("FEATURE_SIZE", QStringList(QString::number(s))); |
653 } |
687 } |
654 |
688 |
655 void GameCFGWidget::resendSchemeData() |
689 void GameCFGWidget::resendSchemeData() |
656 { |
690 { |
657 schemeChanged(GameSchemes->currentIndex()); |
691 schemeChanged(GameSchemes->currentIndex()); |