QTfrontend/model/ammoSchemeModel.cpp
branchios-develop
changeset 13413 ba39a1d396c0
parent 13411 6e8b807bda4b
parent 13412 236cc4cf2448
equal deleted inserted replaced
13411:6e8b807bda4b 13413:ba39a1d396c0
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
       
     4  *
       
     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
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    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
       
    16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
       
    17  */
       
    18 
       
    19 #include <QDebug>
       
    20 #include <QModelIndex>
       
    21 
       
    22 #include "ammoSchemeModel.h"
       
    23 #include "hwconsts.h"
       
    24 
       
    25 QList<QVariant> defaultScheme = QList<QVariant>()
       
    26                                 << QVariant("Default")     // name           0
       
    27                                 << QVariant(false)         // fortsmode      1
       
    28                                 << QVariant(false)         // team divide    2
       
    29                                 << QVariant(false)         // solid land     3
       
    30                                 << QVariant(false)         // border         4
       
    31                                 << QVariant(false)         // low gravity    5
       
    32                                 << QVariant(false)         // laser sight    6
       
    33                                 << QVariant(false)         // invulnerable   7
       
    34                                 << QVariant(false)         // reset health   8
       
    35                                 << QVariant(false)         // vampiric       9
       
    36                                 << QVariant(false)         // karma          10
       
    37                                 << QVariant(false)         // artillery      11
       
    38                                 << QVariant(true)          // random order   12
       
    39                                 << QVariant(false)         // king           13
       
    40                                 << QVariant(false)         // place hog      14
       
    41                                 << QVariant(false)         // shared ammo    15
       
    42                                 << QVariant(false)         // disable girders 16
       
    43                                 << QVariant(false)         // disable land objects 17
       
    44                                 << QVariant(false)         // AI survival    18
       
    45                                 << QVariant(false)         // inf. attack    19
       
    46                                 << QVariant(false)         // reset weps     20
       
    47                                 << QVariant(false)         // per hog ammo   21
       
    48                                 << QVariant(false)         // no wind        22
       
    49                                 << QVariant(false)         // more wind      23
       
    50                                 << QVariant(false)         // tag team       24
       
    51                                 << QVariant(false)         // bottom border  25
       
    52                                 << QVariant(100)           // damage modfier 26
       
    53                                 << QVariant(45)            // turn time      27
       
    54                                 << QVariant(100)           // init health    28
       
    55                                 << QVariant(15)            // sudden death   29
       
    56                                 << QVariant(5)             // case prob      30
       
    57                                 << QVariant(3)             // mines time     31
       
    58                                 << QVariant(4)             // mines number   32
       
    59                                 << QVariant(0)             // mine dud pct   33
       
    60                                 << QVariant(2)             // explosives     34
       
    61                                 << QVariant(0)             // air mines      35
       
    62                                 << QVariant(35)            // health case pct 36
       
    63                                 << QVariant(25)            // health case amt 37
       
    64                                 << QVariant(47)            // water rise amt 38
       
    65                                 << QVariant(5)             // health dec amt 39
       
    66                                 << QVariant(100)           // rope modfier   40
       
    67                                 << QVariant(100)           // get away time  41
       
    68                                 << QVariant(0)             // world edge     42
       
    69                                 << QVariant()              // scriptparam    43
       
    70                                 ;
       
    71 
       
    72 AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
       
    73     QAbstractTableModel(parent),
       
    74     fileConfig(fileName, QSettings::IniFormat)
       
    75 {
       
    76     predefSchemesNames = QStringList()
       
    77                          << "Default"
       
    78                          << "Pro Mode"
       
    79                          << "Shoppa"
       
    80                          << "Clean Slate"
       
    81                          << "Minefield"
       
    82                          << "Barrel Mayhem"
       
    83                          << "Tunnel Hogs"
       
    84                          << "Timeless"
       
    85                          << "Thinking with Portals"
       
    86                          << "King Mode"
       
    87                          << "Construction Mode"
       
    88                          << "HedgeEditor"
       
    89                          ;
       
    90 
       
    91     numberOfDefaultSchemes = predefSchemesNames.size();
       
    92 
       
    93     spNames = QStringList()
       
    94               << "name"                //  0
       
    95               << "fortsmode"           //  1
       
    96               << "divteams"            //  2
       
    97               << "solidland"           //  3
       
    98               << "border"              //  4
       
    99               << "lowgrav"             //  5
       
   100               << "laser"               //  6
       
   101               << "invulnerability"     //  7
       
   102               << "resethealth"         //  8
       
   103               << "vampiric"            //  9
       
   104               << "karma"               // 10
       
   105               << "artillery"           // 11
       
   106               << "randomorder"         // 12
       
   107               << "king"                // 13
       
   108               << "placehog"            // 14
       
   109               << "sharedammo"          // 15
       
   110               << "disablegirders"      // 16
       
   111               << "disablelandobjects"  // 17
       
   112               << "aisurvival"          // 18
       
   113               << "infattack"           // 19
       
   114               << "resetweps"           // 20
       
   115               << "perhogammo"          // 21
       
   116               << "disablewind"         // 22
       
   117               << "morewind"            // 23
       
   118               << "tagteam"             // 24
       
   119               << "bottomborder"        // 25
       
   120               << "damagefactor"        // 26
       
   121               << "turntime"            // 27
       
   122               << "health"              // 28
       
   123               << "suddendeath"         // 29
       
   124               << "caseprobability"     // 30
       
   125               << "minestime"           // 31
       
   126               << "minesnum"            // 32
       
   127               << "minedudpct"          // 33
       
   128               << "explosives"          // 34
       
   129               << "airmines"            // 35
       
   130               << "healthprobability"   // 36
       
   131               << "healthcaseamount"    // 37
       
   132               << "waterrise"           // 38
       
   133               << "healthdecrease"      // 39
       
   134               << "ropepct"             // 40
       
   135               << "getawaytime"         // 41
       
   136               << "worldedge"           // 42
       
   137               << "scriptparam"         // scriptparam    43
       
   138               ;
       
   139 
       
   140     QList<QVariant> proMode;
       
   141     proMode
       
   142             << predefSchemesNames[1]   // name           0
       
   143             << QVariant(false)         // fortsmode      1
       
   144             << QVariant(false)         // team divide    2
       
   145             << QVariant(false)         // solid land     3
       
   146             << QVariant(false)         // border         4
       
   147             << QVariant(false)         // low gravity    5
       
   148             << QVariant(false)         // laser sight    6
       
   149             << QVariant(false)         // invulnerable   7
       
   150             << QVariant(false)         // reset health   8
       
   151             << QVariant(false)         // vampiric       9
       
   152             << QVariant(false)         // karma          10
       
   153             << QVariant(false)         // artillery      11
       
   154             << QVariant(true)          // random order   12
       
   155             << QVariant(false)         // king           13
       
   156             << QVariant(false)         // place hog      14
       
   157             << QVariant(true)          // shared ammo    15
       
   158             << QVariant(false)         // disable girders 16
       
   159             << QVariant(false)         // disable land objects 17
       
   160             << QVariant(false)         // AI survival    18
       
   161             << QVariant(false)         // inf. attack    19
       
   162             << QVariant(false)         // reset weps     20
       
   163             << QVariant(false)         // per hog ammo   21
       
   164             << QVariant(false)         // no wind        22
       
   165             << QVariant(false)         // more wind      23
       
   166             << QVariant(false)         // tag team       24
       
   167             << QVariant(false)         // bottom border  25
       
   168             << QVariant(100)           // damage modfier 26
       
   169             << QVariant(15)            // turn time      27
       
   170             << QVariant(100)           // init health    28
       
   171             << QVariant(15)            // sudden death   29
       
   172             << QVariant(0)             // case prob      30
       
   173             << QVariant(3)             // mines time     31
       
   174             << QVariant(0)             // mines number   32
       
   175             << QVariant(0)             // mine dud pct   33
       
   176             << QVariant(2)             // explosives     34
       
   177             << QVariant(0)             // air mines      35
       
   178             << QVariant(35)            // health case pct 36
       
   179             << QVariant(25)            // health case amt 37
       
   180             << QVariant(47)            // water rise amt 38
       
   181             << QVariant(5)             // health dec amt 39
       
   182             << QVariant(100)           // rope modfier   40
       
   183             << QVariant(100)           // get away time  41
       
   184             << QVariant(0)             // world edge     42
       
   185             << QVariant()              // scriptparam    43
       
   186             ;
       
   187 
       
   188     QList<QVariant> shoppa;
       
   189     shoppa
       
   190             << predefSchemesNames[2]   // name           0
       
   191             << QVariant(false)         // fortsmode      1
       
   192             << QVariant(false)         // team divide    2
       
   193             << QVariant(true)          // solid land     3
       
   194             << QVariant(true)          // border         4
       
   195             << QVariant(false)         // low gravity    5
       
   196             << QVariant(false)         // laser sight    6
       
   197             << QVariant(false)         // invulnerable   7
       
   198             << QVariant(false)         // reset health   8
       
   199             << QVariant(false)         // vampiric       9
       
   200             << QVariant(false)         // karma          10
       
   201             << QVariant(false)         // artillery      11
       
   202             << QVariant(true)          // random order   12
       
   203             << QVariant(false)         // king           13
       
   204             << QVariant(false)         // place hog      14
       
   205             << QVariant(true)          // shared ammo    15
       
   206             << QVariant(true)          // disable girders 16
       
   207             << QVariant(true)         // disable land objects 17
       
   208             << QVariant(false)         // AI survival    18
       
   209             << QVariant(false)         // inf. attack    19
       
   210             << QVariant(true)          // reset weps     20
       
   211             << QVariant(false)         // per hog ammo   21
       
   212             << QVariant(false)         // no wind        22
       
   213             << QVariant(false)         // more wind      23
       
   214             << QVariant(false)         // tag team       24
       
   215             << QVariant(false)         // bottom border  25
       
   216             << QVariant(100)           // damage modfier 26
       
   217             << QVariant(30)            // turn time      27
       
   218             << QVariant(100)           // init health    28
       
   219             << QVariant(50)            // sudden death   29
       
   220             << QVariant(1)             // case prob      30
       
   221             << QVariant(0)             // mines time     31
       
   222             << QVariant(0)             // mines number   32
       
   223             << QVariant(0)             // mine dud pct   33
       
   224             << QVariant(0)             // explosives     34
       
   225             << QVariant(0)             // air mines      35
       
   226             << QVariant(0)             // health case pct 36
       
   227             << QVariant(25)            // health case amt 37
       
   228             << QVariant(0)             // water rise amt 38
       
   229             << QVariant(0)             // health dec amt 39
       
   230             << QVariant(100)           // rope modfier   40
       
   231             << QVariant(100)           // get away time  41
       
   232             << QVariant(0)             // world edge     42
       
   233             << QVariant()              // scriptparam    43
       
   234             ;
       
   235 
       
   236     QList<QVariant> cleanslate;
       
   237     cleanslate
       
   238             << predefSchemesNames[3]   // name           0
       
   239             << QVariant(false)         // fortsmode      1
       
   240             << QVariant(false)         // team divide    2
       
   241             << QVariant(false)         // solid land     3
       
   242             << QVariant(false)         // border         4
       
   243             << QVariant(false)         // low gravity    5
       
   244             << QVariant(false)         // laser sight    6
       
   245             << QVariant(false)         // invulnerable   7
       
   246             << QVariant(true)          // reset health   8
       
   247             << QVariant(false)         // vampiric       9
       
   248             << QVariant(false)         // karma          10
       
   249             << QVariant(false)         // artillery      11
       
   250             << QVariant(true)          // random order   12
       
   251             << QVariant(false)         // king           13
       
   252             << QVariant(false)         // place hog      14
       
   253             << QVariant(false)         // shared ammo    15
       
   254             << QVariant(false)         // disable girders 16
       
   255             << QVariant(false)         // disable land objects 17
       
   256             << QVariant(false)         // AI survival    18
       
   257             << QVariant(true)          // inf. attack    19
       
   258             << QVariant(true)          // reset weps     20
       
   259             << QVariant(false)         // per hog ammo   21
       
   260             << QVariant(false)         // no wind        22
       
   261             << QVariant(false)         // more wind      23
       
   262             << QVariant(false)         // tag team       24
       
   263             << QVariant(false)         // bottom border  25
       
   264             << QVariant(100)           // damage modfier 26
       
   265             << QVariant(45)            // turn time      27
       
   266             << QVariant(100)           // init health    28
       
   267             << QVariant(15)            // sudden death   29
       
   268             << QVariant(5)             // case prob      30
       
   269             << QVariant(3)             // mines time     31
       
   270             << QVariant(4)             // mines number   32
       
   271             << QVariant(0)             // mine dud pct   33
       
   272             << QVariant(2)             // explosives     34
       
   273             << QVariant(0)             // air mines      35
       
   274             << QVariant(35)            // health case pct 36
       
   275             << QVariant(25)            // health case amt 37
       
   276             << QVariant(47)            // water rise amt 38
       
   277             << QVariant(5)             // health dec amt 39
       
   278             << QVariant(100)           // rope modfier   40
       
   279             << QVariant(100)           // get away time  41
       
   280             << QVariant(0)             // world edge     42
       
   281             << QVariant()              // scriptparam    43
       
   282             ;
       
   283 
       
   284     QList<QVariant> minefield;
       
   285     minefield
       
   286             << predefSchemesNames[4]   // name           0
       
   287             << QVariant(false)         // fortsmode      1
       
   288             << QVariant(false)         // team divide    2
       
   289             << QVariant(false)         // solid land     3
       
   290             << QVariant(false)         // border         4
       
   291             << QVariant(false)         // low gravity    5
       
   292             << QVariant(false)         // laser sight    6
       
   293             << QVariant(false)         // invulnerable   7
       
   294             << QVariant(false)         // reset health   8
       
   295             << QVariant(false)         // vampiric       9
       
   296             << QVariant(false)         // karma          10
       
   297             << QVariant(false)         // artillery      11
       
   298             << QVariant(true)          // random order   12
       
   299             << QVariant(false)         // king           13
       
   300             << QVariant(false)         // place hog      14
       
   301             << QVariant(true)          // shared ammo    15
       
   302             << QVariant(true)          // disable girders 16
       
   303             << QVariant(false)         // disable land objects 17
       
   304             << QVariant(false)         // AI survival    18
       
   305             << QVariant(false)         // inf. attack    19
       
   306             << QVariant(false)         // reset weps     20
       
   307             << QVariant(false)         // per hog ammo   21
       
   308             << QVariant(false)         // no wind        22
       
   309             << QVariant(false)         // more wind      23
       
   310             << QVariant(false)         // tag team       24
       
   311             << QVariant(false)         // bottom border  25
       
   312             << QVariant(100)           // damage modfier 26
       
   313             << QVariant(30)            // turn time      27
       
   314             << QVariant(50)            // init health    28
       
   315             << QVariant(15)            // sudden death   29
       
   316             << QVariant(0)             // case prob      30
       
   317             << QVariant(0)             // mines time     31
       
   318             << QVariant(200)           // mines number   32
       
   319             << QVariant(0)             // mine dud pct   33
       
   320             << QVariant(0)             // explosives     34
       
   321             << QVariant(0)             // air mines      35
       
   322             << QVariant(35)            // health case pct 36
       
   323             << QVariant(25)            // health case amt 37
       
   324             << QVariant(47)            // water rise amt 38
       
   325             << QVariant(5)             // health dec amt 39
       
   326             << QVariant(100)           // rope modfier   40
       
   327             << QVariant(100)           // get away time  41
       
   328             << QVariant(0)             // world edge     42
       
   329             << QVariant()              // scriptparam    43
       
   330             ;
       
   331 
       
   332     QList<QVariant> barrelmayhem;
       
   333     barrelmayhem
       
   334             << predefSchemesNames[5]   // name           0
       
   335             << QVariant(false)         // fortsmode      1
       
   336             << QVariant(false)         // team divide    2
       
   337             << QVariant(false)         // solid land     3
       
   338             << QVariant(false)         // border         4
       
   339             << QVariant(false)         // low gravity    5
       
   340             << QVariant(false)         // laser sight    6
       
   341             << QVariant(false)         // invulnerable   7
       
   342             << QVariant(false)         // reset health   8
       
   343             << QVariant(false)         // vampiric       9
       
   344             << QVariant(false)         // karma          10
       
   345             << QVariant(false)         // artillery      11
       
   346             << QVariant(true)          // random order   12
       
   347             << QVariant(false)         // king           13
       
   348             << QVariant(false)         // place hog      14
       
   349             << QVariant(true)          // shared ammo    15
       
   350             << QVariant(false)         // disable girders 16
       
   351             << QVariant(false)         // disable land objects 17
       
   352             << QVariant(false)         // AI survival    18
       
   353             << QVariant(false)         // inf. attack    19
       
   354             << QVariant(false)         // reset weps     20
       
   355             << QVariant(false)         // per hog ammo   21
       
   356             << QVariant(false)         // no wind        22
       
   357             << QVariant(false)         // more wind      23
       
   358             << QVariant(false)         // tag team       24
       
   359             << QVariant(false)         // bottom border  25
       
   360             << QVariant(100)           // damage modfier 26
       
   361             << QVariant(30)            // turn time      27
       
   362             << QVariant(100)           // init health    28
       
   363             << QVariant(15)            // sudden death   29
       
   364             << QVariant(0)             // case prob      30
       
   365             << QVariant(0)             // mines time     31
       
   366             << QVariant(0)             // mines number   32
       
   367             << QVariant(0)             // mine dud pct   33
       
   368             << QVariant(200)           // explosives     34
       
   369             << QVariant(0)             // air mines      35
       
   370             << QVariant(35)            // health case pct 36
       
   371             << QVariant(25)            // health case amt 37
       
   372             << QVariant(47)            // water rise amt 38
       
   373             << QVariant(5)             // health dec amt 39
       
   374             << QVariant(100)           // rope modfier   40
       
   375             << QVariant(100)           // get away time  41
       
   376             << QVariant(0)             // world edge     42
       
   377             << QVariant()              // scriptparam    43
       
   378             ;
       
   379 
       
   380     QList<QVariant> tunnelhogs;
       
   381     tunnelhogs
       
   382             << predefSchemesNames[6]   // name           0
       
   383             << QVariant(false)         // fortsmode      1
       
   384             << QVariant(false)         // team divide    2
       
   385             << QVariant(false)         // solid land     3
       
   386             << QVariant(true)          // border         4
       
   387             << QVariant(false)         // low gravity    5
       
   388             << QVariant(false)         // laser sight    6
       
   389             << QVariant(false)         // invulnerable   7
       
   390             << QVariant(false)         // reset health   8
       
   391             << QVariant(false)         // vampiric       9
       
   392             << QVariant(false)         // karma          10
       
   393             << QVariant(false)         // artillery      11
       
   394             << QVariant(true)          // random order   12
       
   395             << QVariant(false)         // king           13
       
   396             << QVariant(false)         // place hog      14
       
   397             << QVariant(true)          // shared ammo    15
       
   398             << QVariant(true)          // disable girders 16
       
   399             << QVariant(true)          // disable land objects 17
       
   400             << QVariant(false)         // AI survival    18
       
   401             << QVariant(false)         // inf. attack    19
       
   402             << QVariant(false)         // reset weps     20
       
   403             << QVariant(false)         // per hog ammo   21
       
   404             << QVariant(false)         // no wind        22
       
   405             << QVariant(false)         // more wind      23
       
   406             << QVariant(false)         // tag team       24
       
   407             << QVariant(false)         // bottom border  25
       
   408             << QVariant(100)           // damage modfier 26
       
   409             << QVariant(30)            // turn time      27
       
   410             << QVariant(100)           // init health    28
       
   411             << QVariant(15)            // sudden death   29
       
   412             << QVariant(5)             // case prob      30
       
   413             << QVariant(3)             // mines time     31
       
   414             << QVariant(10)            // mines number   32
       
   415             << QVariant(10)            // mine dud pct   33
       
   416             << QVariant(10)            // explosives     34
       
   417             << QVariant(4)             // air mines      35
       
   418             << QVariant(35)            // health case pct 36
       
   419             << QVariant(25)            // health case amt 37
       
   420             << QVariant(47)            // water rise amt 38
       
   421             << QVariant(5)             // health dec amt 39
       
   422             << QVariant(100)           // rope modfier   40
       
   423             << QVariant(100)           // get away time  41
       
   424             << QVariant(0)             // world edge     42
       
   425             << QVariant()              // scriptparam    43
       
   426             ;
       
   427 
       
   428     QList<QVariant> timeless;
       
   429     timeless
       
   430             << predefSchemesNames[7]   // name           0
       
   431             << QVariant(false)         // fortsmode      1
       
   432             << QVariant(false)         // team divide    2
       
   433             << QVariant(false)         // solid land     3
       
   434             << QVariant(false)         // border         4
       
   435             << QVariant(false)         // low gravity    5
       
   436             << QVariant(false)         // laser sight    6
       
   437             << QVariant(false)         // invulnerable   7
       
   438             << QVariant(false)         // reset health   8
       
   439             << QVariant(false)         // vampiric       9
       
   440             << QVariant(false)         // karma          10
       
   441             << QVariant(false)         // artillery      11
       
   442             << QVariant(true)          // random order   12
       
   443             << QVariant(false)         // king           13
       
   444             << QVariant(false)         // place hog      14
       
   445             << QVariant(false)         // shared ammo    15
       
   446             << QVariant(false)         // disable girders 16
       
   447             << QVariant(false)         // disable land objects 17
       
   448             << QVariant(false)         // AI survival    18
       
   449             << QVariant(false)         // inf. attack    19
       
   450             << QVariant(false)         // reset weps     20
       
   451             << QVariant(true)          // per hog ammo   21
       
   452             << QVariant(false)         // no wind        22
       
   453             << QVariant(false)         // more wind      23
       
   454             << QVariant(false)         // tag team       24
       
   455             << QVariant(false)         // bottom border  25
       
   456             << QVariant(100)           // damage modfier 26
       
   457             << QVariant(9999)          // turn time      27
       
   458             << QVariant(100)           // init health    28
       
   459             << QVariant(15)            // sudden death   29
       
   460             << QVariant(5)             // case prob      30
       
   461             << QVariant(3)             // mines time     31
       
   462             << QVariant(5)             // mines number   32
       
   463             << QVariant(10)            // mine dud pct   33
       
   464             << QVariant(2)             // explosives     34
       
   465             << QVariant(0)             // air mines      35
       
   466             << QVariant(35)            // health case pct 36
       
   467             << QVariant(30)            // health case amt 37
       
   468             << QVariant(0)             // water rise amt 38
       
   469             << QVariant(0)             // health dec amt 39
       
   470             << QVariant(100)           // rope modfier   40
       
   471             << QVariant(100)           // get away time  41
       
   472             << QVariant(0)             // world edge     42
       
   473             << QVariant()              // scriptparam    43
       
   474             ;
       
   475 
       
   476     QList<QVariant> thinkingportals;
       
   477     thinkingportals
       
   478             << predefSchemesNames[8]   // name           0
       
   479             << QVariant(false)         // fortsmode      1
       
   480             << QVariant(false)         // team divide    2
       
   481             << QVariant(false)         // solid land     3
       
   482             << QVariant(false)         // border         4
       
   483             << QVariant(false)         // low gravity    5
       
   484             << QVariant(false)         // laser sight    6
       
   485             << QVariant(false)         // invulnerable   7
       
   486             << QVariant(false)         // reset health   8
       
   487             << QVariant(false)         // vampiric       9
       
   488             << QVariant(false)         // karma          10
       
   489             << QVariant(true)          // artillery      11
       
   490             << QVariant(true)          // random order   12
       
   491             << QVariant(false)         // king           13
       
   492             << QVariant(false)         // place hog      14
       
   493             << QVariant(false)         // shared ammo    15
       
   494             << QVariant(false)         // disable girders 16
       
   495             << QVariant(false)         // disable land objects 17
       
   496             << QVariant(false)         // AI survival    18
       
   497             << QVariant(false)         // inf. attack    19
       
   498             << QVariant(false)         // reset weps     20
       
   499             << QVariant(false)         // per hog ammo   21
       
   500             << QVariant(false)         // no wind        22
       
   501             << QVariant(false)         // more wind      23
       
   502             << QVariant(false)         // tag team       24
       
   503             << QVariant(false)         // bottom border  25
       
   504             << QVariant(100)           // damage modfier 26
       
   505             << QVariant(45)            // turn time      27
       
   506             << QVariant(100)           // init health    28
       
   507             << QVariant(15)            // sudden death   29
       
   508             << QVariant(2)             // case prob      30
       
   509             << QVariant(3)             // mines time     31
       
   510             << QVariant(5)             // mines number   32
       
   511             << QVariant(0)             // mine dud pct   33
       
   512             << QVariant(5)             // explosives     34
       
   513             << QVariant(4)             // air mines      35
       
   514             << QVariant(25)            // health case pct 36
       
   515             << QVariant(25)            // health case amt 37
       
   516             << QVariant(47)            // water rise amt 38
       
   517             << QVariant(5)             // health dec amt 39
       
   518             << QVariant(100)           // rope modfier   40
       
   519             << QVariant(100)           // get away time  41
       
   520             << QVariant(0)             // world edge     42
       
   521             << QVariant()              // scriptparam    43
       
   522             ;
       
   523 
       
   524     QList<QVariant> kingmode;
       
   525     kingmode
       
   526             << predefSchemesNames[9]  // name           0
       
   527             << QVariant(false)         // fortsmode      1
       
   528             << QVariant(false)         // team divide    2
       
   529             << QVariant(false)         // solid land     3
       
   530             << QVariant(false)         // border         4
       
   531             << QVariant(false)         // low gravity    5
       
   532             << QVariant(false)         // laser sight    6
       
   533             << QVariant(false)         // invulnerable   7
       
   534             << QVariant(false)         // reset health   8
       
   535             << QVariant(false)         // vampiric       9
       
   536             << QVariant(false)         // karma          10
       
   537             << QVariant(false)         // artillery      11
       
   538             << QVariant(true)          // random order   12
       
   539             << QVariant(true)          // king           13
       
   540             << QVariant(false)         // place hog      14
       
   541             << QVariant(false)         // shared ammo    15
       
   542             << QVariant(false)         // disable girders 16
       
   543             << QVariant(false)         // disable land objects 17
       
   544             << QVariant(false)         // AI survival    18
       
   545             << QVariant(false)         // inf. attack    19
       
   546             << QVariant(false)         // reset weps     20
       
   547             << QVariant(false)         // per hog ammo   21
       
   548             << QVariant(false)         // no wind        22
       
   549             << QVariant(false)         // more wind      23
       
   550             << QVariant(false)         // tag team       24
       
   551             << QVariant(false)         // bottom border  25
       
   552             << QVariant(100)           // damage modfier 26
       
   553             << QVariant(45)            // turn time      27
       
   554             << QVariant(100)           // init health    28
       
   555             << QVariant(15)            // sudden death   29
       
   556             << QVariant(5)             // case prob      30
       
   557             << QVariant(3)             // mines time     31
       
   558             << QVariant(4)             // mines number   32
       
   559             << QVariant(0)             // mine dud pct   33
       
   560             << QVariant(2)             // explosives     34
       
   561             << QVariant(0)             // air mines      35
       
   562             << QVariant(35)            // health case pct 36
       
   563             << QVariant(25)            // health case amt 37
       
   564             << QVariant(47)            // water rise amt 38
       
   565             << QVariant(5)             // health dec amt 39
       
   566             << QVariant(100)           // rope modfier   40
       
   567             << QVariant(100)           // get away time  41
       
   568             << QVariant(0)             // world edge     42
       
   569             << QVariant()              // scriptparam    43
       
   570             ;
       
   571 
       
   572 	QList<QVariant> construction;
       
   573     construction
       
   574             << predefSchemesNames[10]  // name           0
       
   575             << QVariant(false)         // fortsmode      1
       
   576             << QVariant(false)         // team divide    2
       
   577             << QVariant(false)         // solid land     3
       
   578             << QVariant(false)         // border         4
       
   579             << QVariant(false)         // low gravity    5
       
   580             << QVariant(false)         // laser sight    6
       
   581             << QVariant(false)         // invulnerable   7
       
   582             << QVariant(false)         // reset health   8
       
   583             << QVariant(false)         // vampiric       9
       
   584             << QVariant(false)         // karma          10
       
   585             << QVariant(false)         // artillery      11
       
   586             << QVariant(true)          // random order   12
       
   587             << QVariant(false)          // king           13
       
   588             << QVariant(false)         // place hog      14
       
   589             << QVariant(false)         // shared ammo    15
       
   590             << QVariant(true)         // disable girders 16
       
   591             << QVariant(true)         // disable land objects 17
       
   592             << QVariant(false)         // AI survival    18
       
   593             << QVariant(true)         // inf. attack    19
       
   594             << QVariant(false)         // reset weps     20
       
   595             << QVariant(true)         // per hog ammo   21
       
   596             << QVariant(false)         // no wind        22
       
   597             << QVariant(false)         // more wind      23
       
   598             << QVariant(false)         // tag team       24
       
   599             << QVariant(false)         // bottom border  25
       
   600             << QVariant(100)           // damage modfier 26
       
   601             << QVariant(45)            // turn time      27
       
   602             << QVariant(100)           // init health    28
       
   603             << QVariant(15)            // sudden death   29
       
   604             << QVariant(5)             // case prob      30
       
   605             << QVariant(3)             // mines time     31
       
   606             << QVariant(0)             // mines number   32
       
   607             << QVariant(0)             // mine dud pct   33
       
   608             << QVariant(0)             // explosives     34
       
   609             << QVariant(0)             // air mines      35
       
   610             << QVariant(35)            // health case pct 36
       
   611             << QVariant(25)            // health case amt 37
       
   612             << QVariant(47)            // water rise amt 38
       
   613             << QVariant(5)             // health dec amt 39
       
   614             << QVariant(100)           // rope modfier   40
       
   615             << QVariant(100)           // get away time  41
       
   616             << QVariant(0)             // world edge     42
       
   617             << QVariant()              // scriptparam    43
       
   618             ;
       
   619 
       
   620 	QList<QVariant> hedgeeditor;
       
   621     hedgeeditor
       
   622             << predefSchemesNames[11]  // name           0
       
   623             << QVariant(false)         // fortsmode      1
       
   624             << QVariant(false)         // team divide    2
       
   625             << QVariant(false)         // solid land     3
       
   626             << QVariant(false)         // border         4
       
   627             << QVariant(false)         // low gravity    5
       
   628             << QVariant(false)         // laser sight    6
       
   629             << QVariant(false)         // invulnerable   7
       
   630             << QVariant(false)         // reset health   8
       
   631             << QVariant(false)         // vampiric       9
       
   632             << QVariant(false)         // karma          10
       
   633             << QVariant(false)         // artillery      11
       
   634             << QVariant(false)         // random order   12
       
   635             << QVariant(false)         // king           13
       
   636             << QVariant(false)         // place hog      14
       
   637             << QVariant(false)         // shared ammo    15
       
   638             << QVariant(false)         // disable girders 16
       
   639             << QVariant(false)         // disable land objects 17
       
   640             << QVariant(false)         // AI survival    18
       
   641             << QVariant(false)         // inf. attack    19
       
   642             << QVariant(false)         // reset weps     20
       
   643             << QVariant(true)          // per hog ammo   21
       
   644             << QVariant(false)         // no wind        22
       
   645             << QVariant(false)         // more wind      23
       
   646             << QVariant(false)         // tag team       24
       
   647             << QVariant(false)         // bottom border  25
       
   648             << QVariant(100)           // damage modfier 26
       
   649             << QVariant(9999)          // turn time      27
       
   650             << QVariant(100)           // init health    28
       
   651             << QVariant(50)            // sudden death   29
       
   652             << QVariant(5)             // case prob      30
       
   653             << QVariant(3)             // mines time     31
       
   654             << QVariant(0)             // mines number   32
       
   655             << QVariant(0)             // mine dud pct   33
       
   656             << QVariant(0)             // explosives     34
       
   657             << QVariant(0)             // air mines      35
       
   658             << QVariant(35)            // health case pct 36
       
   659             << QVariant(25)            // health case amt 37
       
   660             << QVariant(0)            // water rise amt 38
       
   661             << QVariant(0)             // health dec amt 39
       
   662             << QVariant(100)           // rope modfier   40
       
   663             << QVariant(100)           // get away time  41
       
   664             << QVariant(0)             // world edge     42
       
   665             << QVariant()              // scriptparam    43
       
   666             ;
       
   667 			
       
   668  
       
   669 			
       
   670     schemes.append(defaultScheme);
       
   671     schemes.append(proMode);
       
   672     schemes.append(shoppa);
       
   673     schemes.append(cleanslate);
       
   674     schemes.append(minefield);
       
   675     schemes.append(barrelmayhem);
       
   676     schemes.append(tunnelhogs);
       
   677     schemes.append(timeless);
       
   678     schemes.append(thinkingportals);
       
   679     schemes.append(kingmode);
       
   680     schemes.append(construction);
       
   681     schemes.append(hedgeeditor);
       
   682 
       
   683 
       
   684     int size = fileConfig.beginReadArray("schemes");
       
   685     for (int i = 0; i < size; ++i)
       
   686     {
       
   687         fileConfig.setArrayIndex(i);
       
   688 
       
   689         if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString()))
       
   690         {
       
   691             QList<QVariant> scheme;
       
   692 
       
   693             for (int k = 0; k < spNames.size(); ++k)
       
   694                 scheme << fileConfig.value(spNames[k], defaultScheme[k]);
       
   695 
       
   696             schemes.append(scheme);
       
   697         }
       
   698     }
       
   699     fileConfig.endArray();
       
   700 }
       
   701 
       
   702 QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
       
   703 {
       
   704     Q_UNUSED(section);
       
   705     Q_UNUSED(orientation);
       
   706     Q_UNUSED(role);
       
   707 
       
   708     return QVariant();
       
   709 }
       
   710 
       
   711 int AmmoSchemeModel::rowCount(const QModelIndex &parent) const
       
   712 {
       
   713     if (parent.isValid())
       
   714         return 0;
       
   715     else
       
   716         return schemes.size();
       
   717 }
       
   718 
       
   719 int AmmoSchemeModel::columnCount(const QModelIndex & parent) const
       
   720 {
       
   721     if (parent.isValid())
       
   722         return 0;
       
   723     else
       
   724         return defaultScheme.size();
       
   725 }
       
   726 
       
   727 bool AmmoSchemeModel::hasScheme(QString name)
       
   728 {
       
   729     for(int i=0; i<schemes.size(); i++)
       
   730     {
       
   731         if(schemes[i][0] == name)
       
   732         {
       
   733             return true;
       
   734         }
       
   735     }
       
   736     return false;
       
   737 }
       
   738 
       
   739 Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
       
   740 {
       
   741     Q_UNUSED(index);
       
   742 
       
   743     return
       
   744         Qt::ItemIsEnabled
       
   745         | Qt::ItemIsSelectable
       
   746         | Qt::ItemIsEditable;
       
   747 }
       
   748 
       
   749 bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role)
       
   750 {
       
   751     if (!index.isValid() || index.row() < numberOfDefaultSchemes
       
   752             || index.row() >= schemes.size()
       
   753             || index.column() >= defaultScheme.size()
       
   754             || role != Qt::EditRole)
       
   755         return false;
       
   756 
       
   757     schemes[index.row()][index.column()] = value;
       
   758 
       
   759     emit dataChanged(index, index);
       
   760     return true;
       
   761 }
       
   762 
       
   763 bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
       
   764 {
       
   765     Q_UNUSED(count);
       
   766 
       
   767     beginInsertRows(parent, schemes.size(), schemes.size());
       
   768 
       
   769     if (row == -1)
       
   770     {
       
   771         QList<QVariant> newScheme = defaultScheme;
       
   772 
       
   773         QString newName = tr("New");
       
   774         if(hasScheme(newName))
       
   775         {
       
   776             //name already used -> look for an appropriate name:
       
   777             int i=2;
       
   778             while(hasScheme(newName = tr("New (%1)").arg(i++))) ;
       
   779         }
       
   780         newScheme[0] = QVariant(newName);
       
   781         schemes.insert(schemes.size(), newScheme);
       
   782     }
       
   783     else
       
   784     {
       
   785         QList<QVariant> newScheme = schemes[row];
       
   786         QString oldName = newScheme[0].toString();
       
   787         QString newName = tr("Copy of %1").arg(oldName);
       
   788         if(hasScheme(newName))
       
   789         {
       
   790             //name already used -> look for an appropriate name:
       
   791             int i=2;
       
   792             while(hasScheme(newName = tr("Copy of %1 (%2)").arg(oldName).arg(i++)));
       
   793         }
       
   794         newScheme[0] = QVariant(newName);
       
   795         schemes.insert(schemes.size(), newScheme);
       
   796     }
       
   797 
       
   798     endInsertRows();
       
   799 
       
   800     return true;
       
   801 }
       
   802 
       
   803 bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent)
       
   804 {
       
   805     if(count != 1
       
   806             || row < numberOfDefaultSchemes
       
   807             || row >= schemes.size())
       
   808         return false;
       
   809 
       
   810     beginRemoveRows(parent, row, row);
       
   811 
       
   812     schemes.removeAt(row);
       
   813 
       
   814     endRemoveRows();
       
   815 
       
   816     return true;
       
   817 }
       
   818 
       
   819 QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const
       
   820 {
       
   821     if (!index.isValid() || index.row() < 0
       
   822             || index.row() >= schemes.size()
       
   823             || index.column() >= defaultScheme.size()
       
   824             || (role != Qt::EditRole && role != Qt::DisplayRole)
       
   825        )
       
   826         return QVariant();
       
   827 
       
   828     return schemes[index.row()][index.column()];
       
   829 }
       
   830 
       
   831 void AmmoSchemeModel::Save()
       
   832 {
       
   833     fileConfig.beginWriteArray("schemes", schemes.size() - numberOfDefaultSchemes);
       
   834 
       
   835     for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i)
       
   836     {
       
   837         fileConfig.setArrayIndex(i);
       
   838 
       
   839         QList<QVariant> scheme = schemes[i + numberOfDefaultSchemes];
       
   840 
       
   841         for (int k = 0; k < scheme.size(); ++k)
       
   842             fileConfig.setValue(spNames[k], scheme[k]);
       
   843     }
       
   844     fileConfig.endArray();
       
   845 }
       
   846 
       
   847 
       
   848 NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) :
       
   849     QAbstractTableModel(parent)
       
   850 {
       
   851     netScheme = defaultScheme;
       
   852 }
       
   853 
       
   854 QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
       
   855 {
       
   856     Q_UNUSED(section);
       
   857     Q_UNUSED(orientation);
       
   858     Q_UNUSED(role);
       
   859 
       
   860     return QVariant();
       
   861 }
       
   862 
       
   863 int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
       
   864 {
       
   865     if (parent.isValid())
       
   866         return 0;
       
   867     else
       
   868         return 1;
       
   869 }
       
   870 
       
   871 int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const
       
   872 {
       
   873     if (parent.isValid())
       
   874         return 0;
       
   875     else
       
   876         return defaultScheme.size();
       
   877 }
       
   878 
       
   879 QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const
       
   880 {
       
   881     if (!index.isValid() || index.row() < 0
       
   882             || index.row() > 1
       
   883             || index.column() >= defaultScheme.size()
       
   884             || (role != Qt::EditRole && role != Qt::DisplayRole)
       
   885        )
       
   886         return QVariant();
       
   887 
       
   888     return netScheme[index.column()];
       
   889 }
       
   890 
       
   891 void NetAmmoSchemeModel::setNetSchemeConfig(QStringList cfg)
       
   892 {
       
   893     if(cfg.size() != netScheme.size())
       
   894     {
       
   895         qWarning("Incorrect scheme cfg size");
       
   896         return;
       
   897     }
       
   898 
       
   899     cfg[cfg.size()-1] = cfg[cfg.size()-1].mid(1);
       
   900 
       
   901     for(int i = 0; i < cfg.size(); ++i)
       
   902         netScheme[i] = QVariant(cfg[i]);
       
   903 
       
   904     reset();
       
   905 }