21 #include <QStringList> |
21 #include <QStringList> |
22 #include <QLineEdit> |
22 #include <QLineEdit> |
23 #include <QCryptographicHash> |
23 #include <QCryptographicHash> |
24 #include <QSettings> |
24 #include <QSettings> |
25 #include <QStandardItemModel> |
25 #include <QStandardItemModel> |
|
26 #include <QDebug> |
26 |
27 |
27 #include "team.h" |
28 #include "team.h" |
28 #include "hwform.h" |
29 #include "hwform.h" |
29 #include "DataManager.h" |
30 #include "DataManager.h" |
30 |
31 |
31 HWTeam::HWTeam(const QString & teamname) : |
32 HWTeam::HWTeam(const QString & teamname) : |
32 QObject(0) |
33 QObject(0) |
33 , m_difficulty(0) |
34 , m_difficulty(0) |
34 , m_numHedgehogs(4) |
35 , m_numHedgehogs(4) |
35 , m_isNetTeam(false) |
36 , m_isNetTeam(false) |
|
37 , m_team(NULL) |
36 { |
38 { |
37 m_name = teamname; |
39 m_name = teamname; |
38 OldTeamName = m_name; |
40 OldTeamName = m_name; |
39 for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
41 for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
40 { |
42 { |
127 , m_flag(other.m_flag) |
131 , m_flag(other.m_flag) |
128 , m_voicepack(other.m_voicepack) |
132 , m_voicepack(other.m_voicepack) |
129 , m_hedgehogs(other.m_hedgehogs) |
133 , m_hedgehogs(other.m_hedgehogs) |
130 , m_difficulty(other.m_difficulty) |
134 , m_difficulty(other.m_difficulty) |
131 , m_binds(other.m_binds) |
135 , m_binds(other.m_binds) |
|
136 , m_team(flib_team_copy(other.m_team)) |
132 , m_numHedgehogs(other.m_numHedgehogs) |
137 , m_numHedgehogs(other.m_numHedgehogs) |
133 , m_color(other.m_color) |
138 , m_color(other.m_color) |
134 , m_isNetTeam(other.m_isNetTeam) |
139 , m_isNetTeam(other.m_isNetTeam) |
135 , m_owner(other.m_owner) |
140 , m_owner(other.m_owner) |
136 , m_campaignProgress(other.m_campaignProgress) |
141 , m_campaignProgress(other.m_campaignProgress) |
165 } |
170 } |
166 |
171 |
167 return *this; |
172 return *this; |
168 } |
173 } |
169 |
174 |
|
175 HWTeam::~HWTeam() |
|
176 { |
|
177 if(m_team) |
|
178 flib_team_destroy(m_team); |
|
179 } |
|
180 |
170 bool HWTeam::loadFromFile() |
181 bool HWTeam::loadFromFile() |
171 { |
182 { |
|
183 if(m_team) |
|
184 flib_team_destroy(m_team); |
|
185 |
|
186 m_team = flib_team_from_ini(QString("/config/Teams/%1.hwt").arg(m_name).toUtf8().constData()); |
|
187 |
|
188 /* |
172 QSettings teamfile(QString("physfs://config/Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0); |
189 QSettings teamfile(QString("physfs://config/Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0); |
173 teamfile.setIniCodec("UTF-8"); |
190 teamfile.setIniCodec("UTF-8"); |
174 m_name = teamfile.value("Team/Name", m_name).toString(); |
191 m_name = teamfile.value("Team/Name", m_name).toString(); |
175 m_grave = teamfile.value("Team/Grave", "Statue").toString(); |
192 m_grave = teamfile.value("Team/Grave", "Statue").toString(); |
176 m_fort = teamfile.value("Team/Fort", "Plane").toString(); |
193 m_fort = teamfile.value("Team/Fort", "Plane").toString(); |
194 m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), cbinds[i].strbind).toString(); |
211 m_binds[i].strbind = teamfile.value(QString("Binds/%1").arg(m_binds[i].action), cbinds[i].strbind).toString(); |
195 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
212 for(int i = 0; i < MAX_ACHIEVEMENTS; i++) |
196 if(achievements[i][0][0]) |
213 if(achievements[i][0][0]) |
197 AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt(); |
214 AchievementProgress[i] = teamfile.value(QString("Achievements/%1").arg(achievements[i][0]), 0).toUInt(); |
198 else |
215 else |
199 break; |
216 break;*/ |
200 return true; |
217 return m_team != NULL; |
201 } |
218 } |
202 |
219 |
203 bool HWTeam::fileExists() |
220 bool HWTeam::fileExists() |
204 { |
221 { |
205 QFile f(QString("physfs://config/Teams/%1.hwt").arg(m_name)); |
222 QFile f(QString("physfs://config/Teams/%1.hwt").arg(m_name)); |