571 << QVariant(100) // get away time 41 |
573 << QVariant(100) // get away time 41 |
572 << QVariant(0) // world edge 42 |
574 << QVariant(0) // world edge 42 |
573 << QVariant() // scriptparam 43 |
575 << QVariant() // scriptparam 43 |
574 ; |
576 ; |
575 |
577 |
|
578 QList<QVariant> mutant; |
|
579 mutant |
|
580 << predefSchemesNames[10] // name 0 |
|
581 << QVariant(false) // switchhog 1 |
|
582 << QVariant(false) // team divide 2 |
|
583 << QVariant(false) // solid land 3 |
|
584 << QVariant(false) // border 4 |
|
585 << QVariant(false) // low gravity 5 |
|
586 << QVariant(false) // laser sight 6 |
|
587 << QVariant(false) // invulnerable 7 |
|
588 << QVariant(false) // reset health 8 |
|
589 << QVariant(false) // vampiric 9 |
|
590 << QVariant(false) // karma 10 |
|
591 << QVariant(false) // artillery 11 |
|
592 << QVariant(true) // random order 12 |
|
593 << QVariant(false) // king 13 |
|
594 << QVariant(false) // place hog 14 |
|
595 << QVariant(false) // shared ammo 15 |
|
596 << QVariant(false) // disable girders 16 |
|
597 << QVariant(false) // disable land objects 17 |
|
598 << QVariant(false) // AI survival 18 |
|
599 << QVariant(false) // inf. attack 19 |
|
600 << QVariant(true) // reset weps 20 |
|
601 << QVariant(false) // per hog ammo 21 |
|
602 << QVariant(false) // no wind 22 |
|
603 << QVariant(false) // more wind 23 |
|
604 << QVariant(false) // tag team 24 |
|
605 << QVariant(false) // bottom border 25 |
|
606 << QVariant(100) // damage modfier 26 |
|
607 << QVariant(20) // turn time 27 |
|
608 << QVariant(100) // init health 28 |
|
609 << QVariant(15) // sudden death 29 |
|
610 << QVariant(2) // case prob 30 |
|
611 << QVariant(1) // mines time 31 |
|
612 << QVariant(4) // mines number 32 |
|
613 << QVariant(0) // mine dud pct 33 |
|
614 << QVariant(2) // explosives 34 |
|
615 << QVariant(0) // air mines 35 |
|
616 << QVariant(0) // health case pct 36 |
|
617 << QVariant(25) // health case amt 37 |
|
618 << QVariant(0) // water rise amt 38 |
|
619 << QVariant(0) // health dec amt 39 |
|
620 << QVariant(100) // rope modfier 40 |
|
621 << QVariant(100) // get away time 41 |
|
622 << QVariant(0) // world edge 42 |
|
623 << QVariant() // scriptparam 43 |
|
624 ; |
|
625 |
576 QList<QVariant> construction; |
626 QList<QVariant> construction; |
577 construction |
627 construction |
578 << predefSchemesNames[10] // name 0 |
628 << predefSchemesNames[11] // name 0 |
579 << QVariant(false) // switchhog 1 |
629 << QVariant(false) // switchhog 1 |
580 << QVariant(false) // team divide 2 |
630 << QVariant(false) // team divide 2 |
581 << QVariant(false) // solid land 3 |
631 << QVariant(false) // solid land 3 |
582 << QVariant(false) // border 4 |
632 << QVariant(false) // border 4 |
583 << QVariant(false) // low gravity 5 |
633 << QVariant(false) // low gravity 5 |
620 << QVariant(0) // world edge 42 |
670 << QVariant(0) // world edge 42 |
621 // NOTE: If you change this, also change the defaults in the Construction Mode script |
671 // NOTE: If you change this, also change the defaults in the Construction Mode script |
622 << QVariant("initialenergy=550, energyperround=50, maxenergy=1000, cratesperround=5") // scriptparam 43 |
672 << QVariant("initialenergy=550, energyperround=50, maxenergy=1000, cratesperround=5") // scriptparam 43 |
623 ; |
673 ; |
624 |
674 |
|
675 QList<QVariant> specialists; |
|
676 specialists |
|
677 << predefSchemesNames[12] // name 0 |
|
678 << QVariant(true) // switchhog 1 |
|
679 << QVariant(false) // team divide 2 |
|
680 << QVariant(false) // solid land 3 |
|
681 << QVariant(false) // border 4 |
|
682 << QVariant(false) // low gravity 5 |
|
683 << QVariant(false) // laser sight 6 |
|
684 << QVariant(false) // invulnerable 7 |
|
685 << QVariant(false) // reset health 8 |
|
686 << QVariant(false) // vampiric 9 |
|
687 << QVariant(false) // karma 10 |
|
688 << QVariant(false) // artillery 11 |
|
689 << QVariant(false) // random order 12 |
|
690 << QVariant(false) // king 13 |
|
691 << QVariant(true) // place hog 14 |
|
692 << QVariant(false) // shared ammo 15 |
|
693 << QVariant(false) // disable girders 16 |
|
694 << QVariant(false) // disable land objects 17 |
|
695 << QVariant(false) // AI survival 18 |
|
696 << QVariant(true) // inf. attack 19 |
|
697 << QVariant(true) // reset weps 20 |
|
698 << QVariant(true) // per hog ammo 21 |
|
699 << QVariant(false) // no wind 22 |
|
700 << QVariant(false) // more wind 23 |
|
701 << QVariant(false) // tag team 24 |
|
702 << QVariant(false) // bottom border 25 |
|
703 << QVariant(100) // damage modfier 26 |
|
704 << QVariant(45) // turn time 27 |
|
705 << QVariant(100) // init health 28 |
|
706 << QVariant(15) // sudden death 29 |
|
707 << QVariant(5) // case prob 30 |
|
708 << QVariant(3) // mines time 31 |
|
709 << QVariant(0) // mines number 32 |
|
710 << QVariant(0) // mine dud pct 33 |
|
711 << QVariant(0) // explosives 34 |
|
712 << QVariant(0) // air mines 35 |
|
713 << QVariant(100) // health case pct 36 |
|
714 << QVariant(25) // health case amt 37 |
|
715 << QVariant(47) // water rise amt 38 |
|
716 << QVariant(5) // health dec amt 39 |
|
717 << QVariant(100) // rope modfier 40 |
|
718 << QVariant(100) // get away time 41 |
|
719 << QVariant(0) // world edge 42 |
|
720 // NOTE: If you change this, also change the defaults in the The Specialists script |
|
721 << QVariant("t=SENDXHPL") // scriptparam 43 |
|
722 ; |
|
723 |
625 QList<QVariant> spaceinvasion; |
724 QList<QVariant> spaceinvasion; |
626 spaceinvasion |
725 spaceinvasion |
627 << predefSchemesNames[11] // name 0 |
726 << predefSchemesNames[13] // name 0 |
628 << QVariant(false) // switchhog 1 |
727 << QVariant(false) // switchhog 1 |
629 << QVariant(false) // team divide 2 |
728 << QVariant(false) // team divide 2 |
630 << QVariant(false) // solid land 3 |
729 << QVariant(false) // solid land 3 |
631 << QVariant(false) // border 4 |
730 << QVariant(false) // border 4 |
632 << QVariant(false) // low gravity 5 |
731 << QVariant(false) // low gravity 5 |
671 << QVariant("rounds=3, shield=30, barrels=5, pings=2, barrelbonus=3, shieldbonus=30, timebonus=4") // scriptparam 43 |
770 << QVariant("rounds=3, shield=30, barrels=5, pings=2, barrelbonus=3, shieldbonus=30, timebonus=4") // scriptparam 43 |
672 ; |
771 ; |
673 |
772 |
674 QList<QVariant> hedgeeditor; |
773 QList<QVariant> hedgeeditor; |
675 hedgeeditor |
774 hedgeeditor |
676 << predefSchemesNames[12] // name 0 |
775 << predefSchemesNames[14] // name 0 |
677 << QVariant(false) // switchhog 1 |
776 << QVariant(false) // switchhog 1 |
678 << QVariant(false) // team divide 2 |
777 << QVariant(false) // team divide 2 |
679 << QVariant(false) // solid land 3 |
778 << QVariant(false) // solid land 3 |
680 << QVariant(false) // border 4 |
779 << QVariant(false) // border 4 |
681 << QVariant(false) // low gravity 5 |
780 << QVariant(false) // low gravity 5 |
729 schemes.append(barrelmayhem); |
828 schemes.append(barrelmayhem); |
730 schemes.append(tunnelhogs); |
829 schemes.append(tunnelhogs); |
731 schemes.append(timeless); |
830 schemes.append(timeless); |
732 schemes.append(thinkingportals); |
831 schemes.append(thinkingportals); |
733 schemes.append(kingmode); |
832 schemes.append(kingmode); |
|
833 schemes.append(mutant); |
734 schemes.append(construction); |
834 schemes.append(construction); |
|
835 schemes.append(specialists); |
735 schemes.append(spaceinvasion); |
836 schemes.append(spaceinvasion); |
736 schemes.append(hedgeeditor); |
837 schemes.append(hedgeeditor); |
737 |
838 |
738 if (!QDir(cfgdir->absolutePath() + "/Schemes").exists()) { |
839 if (!QDir(cfgdir->absolutePath() + "/Schemes").exists()) { |
739 QDir().mkdir(cfgdir->absolutePath() + "/Schemes"); |
840 QDir().mkdir(cfgdir->absolutePath() + "/Schemes"); |
|
841 } |
|
842 QStringList predefSchemesNamesLower; |
|
843 for (int i = 0; i < predefSchemesNames.size(); ++i) |
|
844 { |
|
845 predefSchemesNamesLower.append(predefSchemesNames[i].toLower()); |
740 } |
846 } |
741 if (!QDir(directory).exists()) { |
847 if (!QDir(directory).exists()) { |
742 QDir().mkdir(directory); |
848 QDir().mkdir(directory); |
743 |
849 |
744 qDebug("No /Schemes/Game directory found. Trying to import game schemes from schemes.ini."); |
850 qDebug("No /Schemes/Game directory found. Trying to import game schemes from schemes.ini."); |
749 for (int i = 0; i < size; ++i) |
855 for (int i = 0; i < size; ++i) |
750 { |
856 { |
751 legacyFileConfig.setArrayIndex(i); |
857 legacyFileConfig.setArrayIndex(i); |
752 |
858 |
753 QString schemeName = legacyFileConfig.value(spNames[0]).toString(); |
859 QString schemeName = legacyFileConfig.value(spNames[0]).toString(); |
754 if (!schemeName.isNull() && !predefSchemesNames.contains(schemeName)) |
860 if (!schemeName.isNull() && !predefSchemesNamesLower.contains(schemeName.toLower())) |
755 { |
861 { |
756 QList<QVariant> scheme; |
862 QList<QVariant> scheme; |
757 QFile file(directory + "/" + schemeName + ".hwg"); |
863 QFile file(directory + "/" + schemeName + ".hwg"); |
758 |
864 |
759 // Add keys to scheme info and create file |
865 // Add keys to scheme info and create file |
791 |
897 |
792 // Chop off file name suffix |
898 // Chop off file name suffix |
793 QString schemeName = scheme_dir[i]; |
899 QString schemeName = scheme_dir[i]; |
794 if (schemeName.endsWith(".hwg", Qt::CaseInsensitive)) { |
900 if (schemeName.endsWith(".hwg", Qt::CaseInsensitive)) { |
795 schemeName.chop(4); |
901 schemeName.chop(4); |
|
902 } |
|
903 // Don't load scheme if name collides with default scheme |
|
904 if (predefSchemesNamesLower.contains(schemeName.toLower())) { |
|
905 qWarning("Game scheme \"%s\" not loaded from file, name collides with a default scheme!", qPrintable(schemeName)); |
|
906 continue; |
796 } |
907 } |
797 // Parse game scheme file |
908 // Parse game scheme file |
798 if (file.open(QIODevice::ReadOnly)) { |
909 if (file.open(QIODevice::ReadOnly)) { |
799 QTextStream stream(&file); |
910 QTextStream stream(&file); |
800 QString line, key, value; |
911 QString line, key, value; |
854 return defaultScheme.size(); |
965 return defaultScheme.size(); |
855 } |
966 } |
856 |
967 |
857 bool GameSchemeModel::hasScheme(QString name) |
968 bool GameSchemeModel::hasScheme(QString name) |
858 { |
969 { |
|
970 return hasScheme(name, -1); |
|
971 } |
|
972 |
|
973 bool GameSchemeModel::hasScheme(QString name, int ignoreID) |
|
974 { |
|
975 QString nameLower = name.toLower(); |
859 for(int i=0; i<schemes.size(); i++) |
976 for(int i=0; i<schemes.size(); i++) |
860 { |
977 { |
861 if(schemes[i][0] == name) |
978 if(((ignoreID == -1) || (i != ignoreID)) && (schemes[i][0].toString().toLower() == nameLower)) |
862 { |
979 { |
863 return true; |
980 return true; |
864 } |
981 } |
865 } |
982 } |
866 return false; |
983 return false; |
|
984 } |
|
985 |
|
986 bool GameSchemeModel::renameScheme(int index, QString newName) |
|
987 { |
|
988 return setData(QAbstractItemModel::createIndex(index, 0), QVariant(newName)); |
867 } |
989 } |
868 |
990 |
869 Qt::ItemFlags GameSchemeModel::flags(const QModelIndex & index) const |
991 Qt::ItemFlags GameSchemeModel::flags(const QModelIndex & index) const |
870 { |
992 { |
871 Q_UNUSED(index); |
993 Q_UNUSED(index); |