--- a/QTfrontend/CMakeLists.txt Wed Sep 28 19:27:56 2011 +0200
+++ b/QTfrontend/CMakeLists.txt Wed Sep 28 19:48:02 2011 +0200
@@ -28,11 +28,11 @@
find_package(SDL_mixer REQUIRED)
include_directories(.)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/model)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/net)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/dialog)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/page)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/model)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/widget)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util)
include_directories(${SDL_INCLUDE_DIR})
@@ -64,11 +64,13 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp)
-file(GLOB NetCpp ${CMAKE_CURRENT_SOURCE_DIR} net/*.cpp)
-file(GLOB_RECURSE UIcpp ${CMAKE_CURRENT_SOURCE_DIR} ui/*.cpp)
-file(GLOB UtilCpp ${CMAKE_CURRENT_SOURCE_DIR} util/*.cpp)
+file(GLOB NetCpp net/*.cpp)
+file(GLOB ModelCpp model/*.cpp)
+file(GLOB_RECURSE UIcpp ui/*.cpp)
+file(GLOB UtilCpp util/*.cpp)
set(hwfr_src
+ ${ModelCpp}
${NetCpp}
${UIcpp}
${UtilCpp}
@@ -104,12 +106,14 @@
set(hwfr_src ${hwfr_src} hedgewars.rc)
endif(MINGW)
-file(GLOB NetHdr ${CMAKE_CURRENT_SOURCE_DIR} net/*.h)
-file(GLOB_RECURSE UIhdr ${CMAKE_CURRENT_SOURCE_DIR} ui/*.h)
-file(GLOB UtilHdr ${CMAKE_CURRENT_SOURCE_DIR} util/*.h)
+file(GLOB ModelHdr model/*.h)
+file(GLOB NetHdr net/*.h)
+file(GLOB_RECURSE UIhdr ui/*.h)
+file(GLOB UtilHdr util/*.h)
set(hwfr_moc_hdrs
+ ${ModelHdr}
${NetHdr}
${UIhdr}
AbstractPage.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/ammoSchemeModel.cpp Wed Sep 28 19:48:02 2011 +0200
@@ -0,0 +1,786 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <QDebug>
+#include <QModelIndex>
+
+#include "ammoSchemeModel.h"
+#include "hwconsts.h"
+
+QList<QVariant> defaultScheme = QList<QVariant>()
+ << QVariant("Default") // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(4) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
+ QAbstractTableModel(parent),
+ fileConfig(fileName, QSettings::IniFormat)
+{
+ predefSchemesNames = QStringList()
+ << "Default"
+ << "Pro Mode"
+ << "Shoppa"
+ << "Clean Slate"
+ << "Minefield"
+ << "Barrel Mayhem"
+ << "Tunnel Hogs"
+ << "Fort Mode"
+ << "Timeless"
+ << "Thinking with Portals"
+ << "King Mode"
+ ;
+
+ numberOfDefaultSchemes = predefSchemesNames.size();
+
+ spNames = QStringList()
+ << "name" // 0
+ << "fortsmode" // 1
+ << "divteams" // 2
+ << "solidland" // 3
+ << "border" // 4
+ << "lowgrav" // 5
+ << "laser" // 6
+ << "invulnerability" // 7
+ << "resethealth" // 8
+ << "vampiric" // 9
+ << "karma" // 10
+ << "artillery" // 11
+ << "randomorder" // 12
+ << "king" // 13
+ << "placehog" // 14
+ << "sharedammo" // 15
+ << "disablegirders" // 16
+ << "disablelandobjects" // 17
+ << "aisurvival" // 18
+ << "infattack" // 19
+ << "resetweps" // 20
+ << "perhogammo" // 21
+ << "disablewind" // 22
+ << "morewind" // 23
+ << "tagteam" // 24
+ << "bottomborder" // 25
+ << "damagefactor" // 26
+ << "turntime" // 27
+ << "health" // 28
+ << "suddendeath" // 29
+ << "caseprobability" // 30
+ << "minestime" // 31
+ << "minesnum" // 32
+ << "minedudpct" // 33
+ << "explosives" // 34
+ << "healthprobability" // 35
+ << "healthcaseamount" // 36
+ << "waterrise" // 37
+ << "healthdecrease" // 38
+ << "ropepct" // 39
+ << "getawaytime" // 40
+ ;
+
+ QList<QVariant> proMode;
+ proMode
+ << predefSchemesNames[1] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(15) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(0) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(0) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList<QVariant> shoppa;
+ shoppa
+ << predefSchemesNames[2] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(true) // solid land 3
+ << QVariant(true) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(true) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(true) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(30) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(50) // sudden death 29
+ << QVariant(1) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(0) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(0) // explosives 34
+ << QVariant(0) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList<QVariant> cleanslate;
+ cleanslate
+ << predefSchemesNames[3] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(true) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(true) // inf. attack 19
+ << QVariant(true) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(4) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList<QVariant> minefield;
+ minefield
+ << predefSchemesNames[4] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(true) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(30) // turn time 27
+ << QVariant(50) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(0) // case prob 30
+ << QVariant(0) // mines time 31
+ << QVariant(80) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(0) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList<QVariant> barrelmayhem;
+ barrelmayhem
+ << predefSchemesNames[5] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(30) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(0) // case prob 30
+ << QVariant(0) // mines time 31
+ << QVariant(0) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(80) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList<QVariant> tunnelhogs;
+ tunnelhogs
+ << predefSchemesNames[6] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(true) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(true) // disable girders 16
+ << QVariant(true) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(30) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(10) // mines number 32
+ << QVariant(10) // mine dud pct 33
+ << QVariant(10) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList<QVariant> forts;
+ forts
+ << predefSchemesNames[7] // name 0
+ << QVariant(true) // fortsmode 1
+ << QVariant(true) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(true) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(0) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(0) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList<QVariant> timeless;
+ timeless
+ << predefSchemesNames[8] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(true) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(9999) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(5) // mines number 32
+ << QVariant(10) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(30) // health case amt 36
+ << QVariant(0) // water rise amt 37
+ << QVariant(0) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList<QVariant> thinkingportals;
+ thinkingportals
+ << predefSchemesNames[9] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(true) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(2) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(5) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(5) // explosives 34
+ << QVariant(25) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList<QVariant> kingmode;
+ kingmode
+ << predefSchemesNames[10] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(true) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(4) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+
+ schemes.append(defaultScheme);
+ schemes.append(proMode);
+ schemes.append(shoppa);
+ schemes.append(cleanslate);
+ schemes.append(minefield);
+ schemes.append(barrelmayhem);
+ schemes.append(tunnelhogs);
+ schemes.append(forts);
+ schemes.append(timeless);
+ schemes.append(thinkingportals);
+ schemes.append(kingmode);
+
+
+ int size = fileConfig.beginReadArray("schemes");
+ for (int i = 0; i < size; ++i) {
+ fileConfig.setArrayIndex(i);
+
+ if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString()))
+ {
+ QList<QVariant> scheme;
+
+ for (int k = 0; k < spNames.size(); ++k)
+ scheme << fileConfig.value(spNames[k], defaultScheme[k]);
+
+ schemes.append(scheme);
+ }
+ }
+ fileConfig.endArray();
+}
+
+QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ Q_UNUSED(section);
+ Q_UNUSED(orientation);
+ Q_UNUSED(role);
+
+ return QVariant();
+}
+
+int AmmoSchemeModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return schemes.size();
+}
+
+int AmmoSchemeModel::columnCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return defaultScheme.size();
+}
+
+Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
+{
+ Q_UNUSED(index);
+
+ return
+ Qt::ItemIsEnabled
+ | Qt::ItemIsSelectable
+ | Qt::ItemIsEditable;
+}
+
+bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role)
+{
+ if (!index.isValid() || index.row() < numberOfDefaultSchemes
+ || index.row() >= schemes.size()
+ || index.column() >= defaultScheme.size()
+ || role != Qt::EditRole)
+ return false;
+
+ schemes[index.row()][index.column()] = value;
+
+ emit dataChanged(index, index);
+ return true;
+}
+
+bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
+{
+ Q_UNUSED(count);
+
+ beginInsertRows(parent, schemes.size(), schemes.size());
+
+ if (row == -1)
+ {
+ QList<QVariant> newScheme = defaultScheme;
+ newScheme[0] = QVariant(tr("new"));
+ schemes.insert(schemes.size(), newScheme);
+ }
+ else
+ {
+ QList<QVariant> newScheme = schemes[row];
+ newScheme[0] = QVariant(tr("copy of") + " " + newScheme[0].toString());
+ schemes.insert(schemes.size(), newScheme);
+ }
+
+ endInsertRows();
+
+ return true;
+}
+
+bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent)
+{
+ if(count != 1
+ || row < numberOfDefaultSchemes
+ || row >= schemes.size())
+ return false;
+
+ beginRemoveRows(parent, row, row);
+
+ schemes.removeAt(row);
+
+ endRemoveRows();
+
+ return true;
+}
+
+QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || index.row() < 0
+ || index.row() >= schemes.size()
+ || index.column() >= defaultScheme.size()
+ || (role != Qt::EditRole && role != Qt::DisplayRole)
+ )
+ return QVariant();
+
+ return schemes[index.row()][index.column()];
+}
+
+void AmmoSchemeModel::Save()
+{
+ fileConfig.beginWriteArray("schemes", schemes.size() - numberOfDefaultSchemes);
+
+ for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i) {
+ fileConfig.setArrayIndex(i);
+
+ QList<QVariant> scheme = schemes[i + numberOfDefaultSchemes];
+
+ for (int k = 0; k < scheme.size(); ++k)
+ fileConfig.setValue(spNames[k], scheme[k]);
+ }
+ fileConfig.endArray();
+}
+
+
+NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) :
+ QAbstractTableModel(parent)
+{
+ netScheme = defaultScheme;
+}
+
+QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ Q_UNUSED(section);
+ Q_UNUSED(orientation);
+ Q_UNUSED(role);
+
+ return QVariant();
+}
+
+int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return 1;
+}
+
+int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return defaultScheme.size();
+}
+
+QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || index.row() < 0
+ || index.row() > 1
+ || index.column() >= defaultScheme.size()
+ || (role != Qt::EditRole && role != Qt::DisplayRole)
+ )
+ return QVariant();
+
+ return netScheme[index.column()];
+}
+
+void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg)
+{
+ if(cfg.size() != netScheme.size())
+ {
+ qWarning("Incorrect scheme cfg size");
+ return;
+ }
+
+ for(int i = 0; i < cfg.size(); ++i)
+ netScheme[i] = QVariant(cfg[i]);
+
+ reset();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/ammoSchemeModel.h Wed Sep 28 19:48:02 2011 +0200
@@ -0,0 +1,79 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef _AMMO_SCHEME_MODEL_INCLUDED
+#define _AMMO_SCHEME_MODEL_INCLUDED
+
+#include <QSettings>
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QList>
+
+class AmmoSchemeModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ AmmoSchemeModel(QObject * parent, const QString & fileName);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex & parent) const;
+ int columnCount(const QModelIndex & parent) const;
+ Qt::ItemFlags flags(const QModelIndex & index) const;
+ bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
+ bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
+ bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
+ QVariant data(const QModelIndex &index, int role) const;
+
+ int numberOfDefaultSchemes;
+ QStringList predefSchemesNames;
+ QStringList spNames;
+
+public slots:
+ void Save();
+
+signals:
+ void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
+
+protected:
+ QList< QList<QVariant> > schemes;
+
+private:
+ QSettings fileConfig;
+};
+
+class NetAmmoSchemeModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ NetAmmoSchemeModel(QObject * parent);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex & parent) const;
+ int columnCount(const QModelIndex & parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+
+public slots:
+ void setNetSchemeConfig(QStringList & cfg);
+
+private:
+ QList<QVariant> netScheme;
+};
+
+#endif // _AMMO_SCHEME_MODEL_INCLUDED
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/hats.cpp Wed Sep 28 19:48:02 2011 +0200
@@ -0,0 +1,142 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2008-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <QDir>
+#include <QPixmap>
+#include <QPainter>
+#include "hwconsts.h"
+#include "hwform.h"
+#include "hats.h"
+
+HatsModel::HatsModel(QObject* parent) :
+ QAbstractListModel(parent)
+{
+ QFile hhfile;
+ hhfile.setFileName(cfgdir->absolutePath() + "/Data/Graphics/Hedgehog/Idle.png");
+ if (!hhfile.exists()) hhfile.setFileName(datadir->absolutePath() + "/Graphics/Hedgehog/Idle.png");
+ QPixmap hhpix = QPixmap(QFileInfo(hhfile).absoluteFilePath()).copy(0, 0, 32, 32);
+
+ QDir tmpdir;
+ tmpdir.cd(cfgdir->absolutePath());
+ tmpdir.cd("Data");
+ tmpdir.cd("Graphics");
+ tmpdir.cd("Hats");
+
+ tmpdir.setFilter(QDir::Files);
+
+ QStringList userhatsList = tmpdir.entryList(QStringList("*.png"));
+ for (QStringList::Iterator it = userhatsList.begin(); it != userhatsList.end(); ++it )
+ {
+ QString str = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1");
+ QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Hats/" + str + ".png");
+
+ QPixmap tmppix(32, 37);
+ tmppix.fill(QColor(Qt::transparent));
+
+ QPainter painter(&tmppix);
+ painter.drawPixmap(QPoint(0, 5), hhpix);
+ painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
+ if(pix.width() > 32)
+ painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32));
+ painter.end();
+
+ hats.append(qMakePair(str, QIcon(tmppix)));
+ }
+
+ tmpdir.cd(datadir->absolutePath());
+ tmpdir.cd("Graphics");
+ tmpdir.cd("Hats");
+
+ QStringList hatsList = tmpdir.entryList(QStringList("*.png"));
+ for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it )
+ {
+ if (userhatsList.contains(*it,Qt::CaseInsensitive)) continue;
+ QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1");
+ QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/" + str + ".png");
+
+ QPixmap tmppix(32, 37);
+ tmppix.fill(QColor(Qt::transparent));
+
+ QPainter painter(&tmppix);
+ painter.drawPixmap(QPoint(0, 5), hhpix);
+ painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
+ if(pix.width() > 32)
+ painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32));
+ painter.end();
+
+ hats.append(qMakePair(str, QIcon(tmppix)));
+ }
+ // Reserved hats
+ tmpdir.cd("Reserved");
+ hatsList = tmpdir.entryList(QStringList(playerHash+"*.png"));
+ for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it )
+ {
+ QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1");
+ QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/Reserved/" + str + ".png");
+
+ QPixmap tmppix(32, 37);
+ tmppix.fill(QColor(Qt::transparent));
+
+ QPainter painter(&tmppix);
+ painter.drawPixmap(QPoint(0, 5), hhpix);
+ painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
+ painter.end();
+
+ hats.append(qMakePair("Reserved "+str.remove(0,32), QIcon(tmppix)));
+ }
+}
+
+QVariant HatsModel::headerData(int section,
+ Qt::Orientation orientation, int role) const
+{
+ Q_UNUSED(section);
+ Q_UNUSED(orientation);
+ Q_UNUSED(role);
+
+ return QVariant();
+}
+
+int HatsModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return hats.size();
+}
+
+/*int HatsModel::columnCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return 2;
+}
+*/
+QVariant HatsModel::data(const QModelIndex &index,
+ int role) const
+{
+ if (!index.isValid() || index.row() < 0
+ || index.row() >= hats.size()
+ || (role != Qt::DisplayRole && role != Qt::DecorationRole))
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return hats.at(index.row()).first;
+ else // role == Qt::DecorationRole
+ return hats.at(index.row()).second;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/hats.h Wed Sep 28 19:48:02 2011 +0200
@@ -0,0 +1,44 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2008-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef _HATS_INCLUDED
+#define _HATS_INCLUDED
+
+#include <QAbstractListModel>
+#include <QStringList>
+#include <QVector>
+#include <QPair>
+#include <QIcon>
+
+class HatsModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ HatsModel(QObject *parent = 0);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex & parent) const;
+ //int columnCount(const QModelIndex & parent) const;
+
+ QVariant data(const QModelIndex &index, int role) const;
+protected:
+ QVector<QPair<QString, QIcon> > hats;
+};
+
+#endif // _HATS_INCLUDED
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/netserverslist.cpp Wed Sep 28 19:48:02 2011 +0200
@@ -0,0 +1,68 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2007-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <QUdpSocket>
+#include <QListWidget>
+
+#include "netserverslist.h"
+
+HWNetServersModel::HWNetServersModel(QObject* parent) :
+ QAbstractTableModel(parent)
+{
+
+}
+
+void HWNetServersModel::updateList()
+{
+
+}
+
+QVariant HWNetServersModel::headerData(int section,
+ Qt::Orientation orientation, int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ {
+ switch (section)
+ {
+ case 0: return tr("Title");
+ case 1: return tr("IP");
+ case 2: return tr("Port");
+ default: return QVariant();
+ }
+ } else
+ return QString("%1").arg(section + 1);
+}
+
+int HWNetServersModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return games.size();
+}
+
+int HWNetServersModel::columnCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return 3;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/netserverslist.h Wed Sep 28 19:48:02 2011 +0200
@@ -0,0 +1,43 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2007-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef _NET_SERVERSLIST_INCLUDED
+#define _NET_SERVERSLIST_INCLUDED
+
+#include <QAbstractTableModel>
+#include <QStringList>
+
+class HWNetServersModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ HWNetServersModel(QObject *parent = 0);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex & parent) const;
+ int columnCount(const QModelIndex & parent) const;
+
+public slots:
+ virtual void updateList();
+
+protected:
+ QList<QStringList> games;
+};
+
+#endif // _NET_SERVERSLIST_INCLUDED
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/themesmodel.cpp Wed Sep 28 19:48:02 2011 +0200
@@ -0,0 +1,49 @@
+
+#include "themesmodel.h"
+
+ThemesModel::ThemesModel(QStringList themes, QObject *parent) :
+ QAbstractListModel(parent)
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ m_data.reserve(themes.size());
+#endif
+
+ foreach(QString theme, themes)
+ {
+ m_data.append(QHash<int, QVariant>());
+ m_data.last().insert(Qt::DisplayRole, theme);
+ }
+}
+
+int ThemesModel::rowCount(const QModelIndex &parent) const
+{
+ if(parent.isValid())
+ return 0;
+ else
+ return m_data.size();
+}
+
+QVariant ThemesModel::data(const QModelIndex &index, int role) const
+{
+ if(index.column() > 0 || index.row() >= m_data.size())
+ return QVariant();
+ else
+ return m_data.at(index.row()).value(role);
+}
+
+bool ThemesModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if(index.column() > 0 || index.row() >= m_data.size())
+ return false;
+ else
+ {
+ m_data[index.row()].insert(role, value);
+
+ return true;
+ }
+
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/themesmodel.h Wed Sep 28 19:48:02 2011 +0200
@@ -0,0 +1,28 @@
+#ifndef THEMESMODEL_H
+#define THEMESMODEL_H
+
+#include <QAbstractListModel>
+#include <QStringList>
+#include <QHash>
+
+class ThemesModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ explicit ThemesModel(QStringList themes, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+signals:
+
+public slots:
+
+private:
+
+ QList<QHash<int, QVariant> > m_data;
+};
+
+#endif // THEMESMODEL_H
--- a/QTfrontend/ui/model/ammoSchemeModel.cpp Wed Sep 28 19:27:56 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,786 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QDebug>
-#include <QModelIndex>
-
-#include "ammoSchemeModel.h"
-#include "hwconsts.h"
-
-QList<QVariant> defaultScheme = QList<QVariant>()
- << QVariant("Default") // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(4) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
-AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
- QAbstractTableModel(parent),
- fileConfig(fileName, QSettings::IniFormat)
-{
- predefSchemesNames = QStringList()
- << "Default"
- << "Pro Mode"
- << "Shoppa"
- << "Clean Slate"
- << "Minefield"
- << "Barrel Mayhem"
- << "Tunnel Hogs"
- << "Fort Mode"
- << "Timeless"
- << "Thinking with Portals"
- << "King Mode"
- ;
-
- numberOfDefaultSchemes = predefSchemesNames.size();
-
- spNames = QStringList()
- << "name" // 0
- << "fortsmode" // 1
- << "divteams" // 2
- << "solidland" // 3
- << "border" // 4
- << "lowgrav" // 5
- << "laser" // 6
- << "invulnerability" // 7
- << "resethealth" // 8
- << "vampiric" // 9
- << "karma" // 10
- << "artillery" // 11
- << "randomorder" // 12
- << "king" // 13
- << "placehog" // 14
- << "sharedammo" // 15
- << "disablegirders" // 16
- << "disablelandobjects" // 17
- << "aisurvival" // 18
- << "infattack" // 19
- << "resetweps" // 20
- << "perhogammo" // 21
- << "disablewind" // 22
- << "morewind" // 23
- << "tagteam" // 24
- << "bottomborder" // 25
- << "damagefactor" // 26
- << "turntime" // 27
- << "health" // 28
- << "suddendeath" // 29
- << "caseprobability" // 30
- << "minestime" // 31
- << "minesnum" // 32
- << "minedudpct" // 33
- << "explosives" // 34
- << "healthprobability" // 35
- << "healthcaseamount" // 36
- << "waterrise" // 37
- << "healthdecrease" // 38
- << "ropepct" // 39
- << "getawaytime" // 40
- ;
-
- QList<QVariant> proMode;
- proMode
- << predefSchemesNames[1] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(15) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(0) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(0) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList<QVariant> shoppa;
- shoppa
- << predefSchemesNames[2] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(true) // solid land 3
- << QVariant(true) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(true) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(true) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(30) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(50) // sudden death 29
- << QVariant(1) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(0) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(0) // explosives 34
- << QVariant(0) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList<QVariant> cleanslate;
- cleanslate
- << predefSchemesNames[3] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(true) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(true) // inf. attack 19
- << QVariant(true) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(4) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList<QVariant> minefield;
- minefield
- << predefSchemesNames[4] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(true) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(30) // turn time 27
- << QVariant(50) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(0) // case prob 30
- << QVariant(0) // mines time 31
- << QVariant(80) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(0) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList<QVariant> barrelmayhem;
- barrelmayhem
- << predefSchemesNames[5] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(30) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(0) // case prob 30
- << QVariant(0) // mines time 31
- << QVariant(0) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(80) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList<QVariant> tunnelhogs;
- tunnelhogs
- << predefSchemesNames[6] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(true) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(true) // disable girders 16
- << QVariant(true) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(30) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(10) // mines number 32
- << QVariant(10) // mine dud pct 33
- << QVariant(10) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList<QVariant> forts;
- forts
- << predefSchemesNames[7] // name 0
- << QVariant(true) // fortsmode 1
- << QVariant(true) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(true) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(0) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(0) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList<QVariant> timeless;
- timeless
- << predefSchemesNames[8] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(true) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(9999) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(5) // mines number 32
- << QVariant(10) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(30) // health case amt 36
- << QVariant(0) // water rise amt 37
- << QVariant(0) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList<QVariant> thinkingportals;
- thinkingportals
- << predefSchemesNames[9] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(true) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(2) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(5) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(5) // explosives 34
- << QVariant(25) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList<QVariant> kingmode;
- kingmode
- << predefSchemesNames[10] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(true) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(4) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
-
- schemes.append(defaultScheme);
- schemes.append(proMode);
- schemes.append(shoppa);
- schemes.append(cleanslate);
- schemes.append(minefield);
- schemes.append(barrelmayhem);
- schemes.append(tunnelhogs);
- schemes.append(forts);
- schemes.append(timeless);
- schemes.append(thinkingportals);
- schemes.append(kingmode);
-
-
- int size = fileConfig.beginReadArray("schemes");
- for (int i = 0; i < size; ++i) {
- fileConfig.setArrayIndex(i);
-
- if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString()))
- {
- QList<QVariant> scheme;
-
- for (int k = 0; k < spNames.size(); ++k)
- scheme << fileConfig.value(spNames[k], defaultScheme[k]);
-
- schemes.append(scheme);
- }
- }
- fileConfig.endArray();
-}
-
-QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- Q_UNUSED(section);
- Q_UNUSED(orientation);
- Q_UNUSED(role);
-
- return QVariant();
-}
-
-int AmmoSchemeModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return schemes.size();
-}
-
-int AmmoSchemeModel::columnCount(const QModelIndex & parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return defaultScheme.size();
-}
-
-Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
-{
- Q_UNUSED(index);
-
- return
- Qt::ItemIsEnabled
- | Qt::ItemIsSelectable
- | Qt::ItemIsEditable;
-}
-
-bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role)
-{
- if (!index.isValid() || index.row() < numberOfDefaultSchemes
- || index.row() >= schemes.size()
- || index.column() >= defaultScheme.size()
- || role != Qt::EditRole)
- return false;
-
- schemes[index.row()][index.column()] = value;
-
- emit dataChanged(index, index);
- return true;
-}
-
-bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
-{
- Q_UNUSED(count);
-
- beginInsertRows(parent, schemes.size(), schemes.size());
-
- if (row == -1)
- {
- QList<QVariant> newScheme = defaultScheme;
- newScheme[0] = QVariant(tr("new"));
- schemes.insert(schemes.size(), newScheme);
- }
- else
- {
- QList<QVariant> newScheme = schemes[row];
- newScheme[0] = QVariant(tr("copy of") + " " + newScheme[0].toString());
- schemes.insert(schemes.size(), newScheme);
- }
-
- endInsertRows();
-
- return true;
-}
-
-bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent)
-{
- if(count != 1
- || row < numberOfDefaultSchemes
- || row >= schemes.size())
- return false;
-
- beginRemoveRows(parent, row, row);
-
- schemes.removeAt(row);
-
- endRemoveRows();
-
- return true;
-}
-
-QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid() || index.row() < 0
- || index.row() >= schemes.size()
- || index.column() >= defaultScheme.size()
- || (role != Qt::EditRole && role != Qt::DisplayRole)
- )
- return QVariant();
-
- return schemes[index.row()][index.column()];
-}
-
-void AmmoSchemeModel::Save()
-{
- fileConfig.beginWriteArray("schemes", schemes.size() - numberOfDefaultSchemes);
-
- for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i) {
- fileConfig.setArrayIndex(i);
-
- QList<QVariant> scheme = schemes[i + numberOfDefaultSchemes];
-
- for (int k = 0; k < scheme.size(); ++k)
- fileConfig.setValue(spNames[k], scheme[k]);
- }
- fileConfig.endArray();
-}
-
-
-NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) :
- QAbstractTableModel(parent)
-{
- netScheme = defaultScheme;
-}
-
-QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- Q_UNUSED(section);
- Q_UNUSED(orientation);
- Q_UNUSED(role);
-
- return QVariant();
-}
-
-int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return 1;
-}
-
-int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return defaultScheme.size();
-}
-
-QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid() || index.row() < 0
- || index.row() > 1
- || index.column() >= defaultScheme.size()
- || (role != Qt::EditRole && role != Qt::DisplayRole)
- )
- return QVariant();
-
- return netScheme[index.column()];
-}
-
-void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg)
-{
- if(cfg.size() != netScheme.size())
- {
- qWarning("Incorrect scheme cfg size");
- return;
- }
-
- for(int i = 0; i < cfg.size(); ++i)
- netScheme[i] = QVariant(cfg[i]);
-
- reset();
-}
--- a/QTfrontend/ui/model/ammoSchemeModel.h Wed Sep 28 19:27:56 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2005-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef _AMMO_SCHEME_MODEL_INCLUDED
-#define _AMMO_SCHEME_MODEL_INCLUDED
-
-#include <QSettings>
-#include <QAbstractTableModel>
-#include <QStringList>
-#include <QList>
-
-class AmmoSchemeModel : public QAbstractTableModel
-{
- Q_OBJECT
-
-public:
- AmmoSchemeModel(QObject * parent, const QString & fileName);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- int rowCount(const QModelIndex & parent) const;
- int columnCount(const QModelIndex & parent) const;
- Qt::ItemFlags flags(const QModelIndex & index) const;
- bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
- bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
- bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
- QVariant data(const QModelIndex &index, int role) const;
-
- int numberOfDefaultSchemes;
- QStringList predefSchemesNames;
- QStringList spNames;
-
-public slots:
- void Save();
-
-signals:
- void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
-
-protected:
- QList< QList<QVariant> > schemes;
-
-private:
- QSettings fileConfig;
-};
-
-class NetAmmoSchemeModel : public QAbstractTableModel
-{
- Q_OBJECT
-
-public:
- NetAmmoSchemeModel(QObject * parent);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- int rowCount(const QModelIndex & parent) const;
- int columnCount(const QModelIndex & parent) const;
- QVariant data(const QModelIndex &index, int role) const;
-
-public slots:
- void setNetSchemeConfig(QStringList & cfg);
-
-private:
- QList<QVariant> netScheme;
-};
-
-#endif // _AMMO_SCHEME_MODEL_INCLUDED
--- a/QTfrontend/ui/model/hats.cpp Wed Sep 28 19:27:56 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2008-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QDir>
-#include <QPixmap>
-#include <QPainter>
-#include "hwconsts.h"
-#include "hwform.h"
-#include "hats.h"
-
-HatsModel::HatsModel(QObject* parent) :
- QAbstractListModel(parent)
-{
- QFile hhfile;
- hhfile.setFileName(cfgdir->absolutePath() + "/Data/Graphics/Hedgehog/Idle.png");
- if (!hhfile.exists()) hhfile.setFileName(datadir->absolutePath() + "/Graphics/Hedgehog/Idle.png");
- QPixmap hhpix = QPixmap(QFileInfo(hhfile).absoluteFilePath()).copy(0, 0, 32, 32);
-
- QDir tmpdir;
- tmpdir.cd(cfgdir->absolutePath());
- tmpdir.cd("Data");
- tmpdir.cd("Graphics");
- tmpdir.cd("Hats");
-
- tmpdir.setFilter(QDir::Files);
-
- QStringList userhatsList = tmpdir.entryList(QStringList("*.png"));
- for (QStringList::Iterator it = userhatsList.begin(); it != userhatsList.end(); ++it )
- {
- QString str = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1");
- QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Hats/" + str + ".png");
-
- QPixmap tmppix(32, 37);
- tmppix.fill(QColor(Qt::transparent));
-
- QPainter painter(&tmppix);
- painter.drawPixmap(QPoint(0, 5), hhpix);
- painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
- if(pix.width() > 32)
- painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32));
- painter.end();
-
- hats.append(qMakePair(str, QIcon(tmppix)));
- }
-
- tmpdir.cd(datadir->absolutePath());
- tmpdir.cd("Graphics");
- tmpdir.cd("Hats");
-
- QStringList hatsList = tmpdir.entryList(QStringList("*.png"));
- for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it )
- {
- if (userhatsList.contains(*it,Qt::CaseInsensitive)) continue;
- QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1");
- QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/" + str + ".png");
-
- QPixmap tmppix(32, 37);
- tmppix.fill(QColor(Qt::transparent));
-
- QPainter painter(&tmppix);
- painter.drawPixmap(QPoint(0, 5), hhpix);
- painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
- if(pix.width() > 32)
- painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32));
- painter.end();
-
- hats.append(qMakePair(str, QIcon(tmppix)));
- }
- // Reserved hats
- tmpdir.cd("Reserved");
- hatsList = tmpdir.entryList(QStringList(playerHash+"*.png"));
- for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it )
- {
- QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1");
- QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/Reserved/" + str + ".png");
-
- QPixmap tmppix(32, 37);
- tmppix.fill(QColor(Qt::transparent));
-
- QPainter painter(&tmppix);
- painter.drawPixmap(QPoint(0, 5), hhpix);
- painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
- painter.end();
-
- hats.append(qMakePair("Reserved "+str.remove(0,32), QIcon(tmppix)));
- }
-}
-
-QVariant HatsModel::headerData(int section,
- Qt::Orientation orientation, int role) const
-{
- Q_UNUSED(section);
- Q_UNUSED(orientation);
- Q_UNUSED(role);
-
- return QVariant();
-}
-
-int HatsModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return hats.size();
-}
-
-/*int HatsModel::columnCount(const QModelIndex & parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return 2;
-}
-*/
-QVariant HatsModel::data(const QModelIndex &index,
- int role) const
-{
- if (!index.isValid() || index.row() < 0
- || index.row() >= hats.size()
- || (role != Qt::DisplayRole && role != Qt::DecorationRole))
- return QVariant();
-
- if (role == Qt::DisplayRole)
- return hats.at(index.row()).first;
- else // role == Qt::DecorationRole
- return hats.at(index.row()).second;
-}
--- a/QTfrontend/ui/model/hats.h Wed Sep 28 19:27:56 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2008-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef _HATS_INCLUDED
-#define _HATS_INCLUDED
-
-#include <QAbstractListModel>
-#include <QStringList>
-#include <QVector>
-#include <QPair>
-#include <QIcon>
-
-class HatsModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- HatsModel(QObject *parent = 0);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- int rowCount(const QModelIndex & parent) const;
- //int columnCount(const QModelIndex & parent) const;
-
- QVariant data(const QModelIndex &index, int role) const;
-protected:
- QVector<QPair<QString, QIcon> > hats;
-};
-
-#endif // _HATS_INCLUDED
--- a/QTfrontend/ui/model/netserverslist.cpp Wed Sep 28 19:27:56 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QUdpSocket>
-#include <QListWidget>
-
-#include "netserverslist.h"
-
-HWNetServersModel::HWNetServersModel(QObject* parent) :
- QAbstractTableModel(parent)
-{
-
-}
-
-void HWNetServersModel::updateList()
-{
-
-}
-
-QVariant HWNetServersModel::headerData(int section,
- Qt::Orientation orientation, int role) const
-{
- if (role != Qt::DisplayRole)
- return QVariant();
-
- if (orientation == Qt::Horizontal)
- {
- switch (section)
- {
- case 0: return tr("Title");
- case 1: return tr("IP");
- case 2: return tr("Port");
- default: return QVariant();
- }
- } else
- return QString("%1").arg(section + 1);
-}
-
-int HWNetServersModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return games.size();
-}
-
-int HWNetServersModel::columnCount(const QModelIndex & parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return 3;
-}
--- a/QTfrontend/ui/model/netserverslist.h Wed Sep 28 19:27:56 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef _NET_SERVERSLIST_INCLUDED
-#define _NET_SERVERSLIST_INCLUDED
-
-#include <QAbstractTableModel>
-#include <QStringList>
-
-class HWNetServersModel : public QAbstractTableModel
-{
- Q_OBJECT
-
-public:
- HWNetServersModel(QObject *parent = 0);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- int rowCount(const QModelIndex & parent) const;
- int columnCount(const QModelIndex & parent) const;
-
-public slots:
- virtual void updateList();
-
-protected:
- QList<QStringList> games;
-};
-
-#endif // _NET_SERVERSLIST_INCLUDED
--- a/QTfrontend/ui/model/themesmodel.cpp Wed Sep 28 19:27:56 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-
-#include "themesmodel.h"
-
-ThemesModel::ThemesModel(QStringList themes, QObject *parent) :
- QAbstractListModel(parent)
-{
-#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
- m_data.reserve(themes.size());
-#endif
-
- foreach(QString theme, themes)
- {
- m_data.append(QHash<int, QVariant>());
- m_data.last().insert(Qt::DisplayRole, theme);
- }
-}
-
-int ThemesModel::rowCount(const QModelIndex &parent) const
-{
- if(parent.isValid())
- return 0;
- else
- return m_data.size();
-}
-
-QVariant ThemesModel::data(const QModelIndex &index, int role) const
-{
- if(index.column() > 0 || index.row() >= m_data.size())
- return QVariant();
- else
- return m_data.at(index.row()).value(role);
-}
-
-bool ThemesModel::setData(const QModelIndex &index, const QVariant &value, int role)
-{
- if(index.column() > 0 || index.row() >= m_data.size())
- return false;
- else
- {
- m_data[index.row()].insert(role, value);
-
- return true;
- }
-
-}
-
-
-
-
--- a/QTfrontend/ui/model/themesmodel.h Wed Sep 28 19:27:56 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#ifndef THEMESMODEL_H
-#define THEMESMODEL_H
-
-#include <QAbstractListModel>
-#include <QStringList>
-#include <QHash>
-
-class ThemesModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- explicit ThemesModel(QStringList themes, QObject *parent = 0);
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role) const;
- bool setData(const QModelIndex &index, const QVariant &value,
- int role = Qt::EditRole);
-
-signals:
-
-public slots:
-
-private:
-
- QList<QHash<int, QVariant> > m_data;
-};
-
-#endif // THEMESMODEL_H