author | Periklis Ntanasis <pntanasis@gmail.com> |
Fri, 28 Jun 2013 22:06:57 +0300 | |
branch | spacecampaign |
changeset 9290 | 478aa681e702 |
parent 9286 | c89b992ff5fe |
child 9292 | 187ce630dddc |
permissions | -rw-r--r-- |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
1 |
/* |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
9080 | 3 |
* Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com> |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
4 |
* |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
8 |
* |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
13 |
* |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
17 |
*/ |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
18 |
|
9000
af202eff659c
remove about 45 useless #include statements from campain.* - copypasta ftw, eh? :p
sheepluva
parents:
8434
diff
changeset
|
19 |
#include "campaign.h" |
af202eff659c
remove about 45 useless #include statements from campain.* - copypasta ftw, eh? :p
sheepluva
parents:
8434
diff
changeset
|
20 |
#include "hwconsts.h" |
9278
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
21 |
#include "DataManager.h" |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
22 |
#include <QSettings> |
9275
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
23 |
#include <QMap> |
9272
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
24 |
#include <QDebug> |
9278
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
25 |
#include <QObject> |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
26 |
|
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
27 |
QStringList getCampMissionList(QString & campaign) |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
28 |
{ |
8049 | 29 |
QSettings campfile("physfs://Missions/Campaign/" + campaign + "/campaign.ini", QSettings::IniFormat, 0); |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
30 |
campfile.setIniCodec("UTF-8"); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
31 |
unsigned int mNum = campfile.value("MissionNum", 0).toInt(); |
8434 | 32 |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
33 |
QStringList missionList; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
34 |
for (unsigned int i = 0; i < mNum; i++) |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
35 |
{ |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
36 |
missionList += campfile.value(QString("Mission %1/Name").arg(i + 1)).toString(); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
37 |
} |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
38 |
return missionList; |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
39 |
} |
8434 | 40 |
|
9275
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
41 |
// works ok |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
42 |
QStringList getCampMissionList2(QString & campaignName, QString & teamName) |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
43 |
{ |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
44 |
QStringList missionList; |
9272
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
45 |
QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
46 |
teamfile.setIniCodec("UTF-8"); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
47 |
unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt(); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
48 |
qDebug("HERE is progress : %d",progress); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
49 |
unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt(); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
50 |
qDebug("HERE is unlocked missions : %d",unlockedMissions); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
51 |
|
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
52 |
QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
53 |
campfile.setIniCodec("UTF-8"); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
54 |
unsigned int missionsNumber = campfile.value("MissionNum", 0).toInt(); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
55 |
qDebug("HERE is number of missions : %d",missionsNumber); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
56 |
|
9275
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
57 |
if(progress>=0 and unlockedMissions==0) |
9272
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
58 |
{ |
9275
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
59 |
for(unsigned int i=progress+1;i>0;i--) |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
60 |
{ |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
61 |
missionList += campfile.value(QString("Mission %1/Name").arg(i)).toString(); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
62 |
} |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
63 |
} |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
64 |
else if(unlockedMissions>0) |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
65 |
{ |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
66 |
qDebug("IN HERE !!!"); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
67 |
for(unsigned int i=1;i<=unlockedMissions;i++) |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
68 |
{ |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
69 |
QString missionNum = QString("%1").arg(i); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
70 |
int missionNumber = teamfile.value("Campaign " + campaignName + "/Mission"+missionNum, -1).toInt(); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
71 |
qDebug("Campaign %s Mission %d",campaignName.toUtf8().constData(),i); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
72 |
qDebug("MISSION NUMBER : %d",missionNumber); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
73 |
missionList += campfile.value(QString("Mission %1/Name").arg(missionNumber)).toString(); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
74 |
qDebug(campfile.value(QString("Mission %1/Name").arg(missionNumber)).toString().toUtf8().constData()); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
75 |
} |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
76 |
} |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
77 |
return missionList; |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
78 |
} |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
79 |
|
9290
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
80 |
QList<MissionInfo> getCampMissionList3(QString & campaignName, QString & teamName) |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
81 |
{ |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
82 |
// TODO: add default image if there isn't an available one |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
83 |
QList<MissionInfo> missionInfoList; |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
84 |
QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
85 |
teamfile.setIniCodec("UTF-8"); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
86 |
unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
87 |
qDebug("HERE is progress : %d",progress); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
88 |
unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
89 |
qDebug("HERE is unlocked missions : %d",unlockedMissions); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
90 |
|
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
91 |
QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
92 |
campfile.setIniCodec("UTF-8"); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
93 |
unsigned int missionsNumber = campfile.value("MissionNum", 0).toInt(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
94 |
qDebug("HERE is number of missions : %d",missionsNumber); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
95 |
|
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
96 |
DataManager & dataMgr = DataManager::instance(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
97 |
// get locale |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
98 |
QSettings settings(dataMgr.settingsFileName(), |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
99 |
QSettings::IniFormat); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
100 |
QString loc = settings.value("misc/locale", "").toString(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
101 |
if (loc.isEmpty()) |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
102 |
loc = QLocale::system().name(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
103 |
QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt"); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
104 |
// if file is non-existant try with language only |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
105 |
if (!QFile::exists(campaignDescFile)) |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
106 |
campaignDescFile = QString("physfs://Locale/campaigns_" + loc.remove(QRegExp("_.*$")) + ".txt"); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
107 |
|
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
108 |
// fallback if file for current locale is non-existant |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
109 |
if (!QFile::exists(campaignDescFile)) |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
110 |
campaignDescFile = QString("physfs://Locale/campaigns_en.txt"); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
111 |
|
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
112 |
QSettings m_info(campaignDescFile, QSettings::IniFormat, 0); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
113 |
m_info.setIniCodec("UTF-8"); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
114 |
|
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
115 |
if(progress>=0 and unlockedMissions==0) |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
116 |
{ |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
117 |
for(unsigned int i=progress+1;i>0;i--) |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
118 |
{ |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
119 |
MissionInfo missionInfo; |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
120 |
missionInfo.name = campfile.value(QString("Mission %1/Name").arg(i)).toString(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
121 |
missionInfo.description = m_info.value(campaignName+"-"+ getCampaignMissionName(campaignName,i) + ".desc", |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
122 |
QObject::tr("No description available")).toString(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
123 |
missionInfo.script = campfile.value(QString("Mission %1/Script").arg(i)).toString(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
124 |
missionInfo.image = campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png")); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
125 |
missionInfoList.append(missionInfo); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
126 |
} |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
127 |
} |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
128 |
else if(unlockedMissions>0) |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
129 |
{ |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
130 |
qDebug("IN HERE !!!"); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
131 |
for(unsigned int i=1;i<=unlockedMissions;i++) |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
132 |
{ |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
133 |
QString missionNum = QString("%1").arg(i); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
134 |
int missionNumber = teamfile.value("Campaign " + campaignName + "/Mission"+missionNum, -1).toInt(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
135 |
MissionInfo missionInfo; |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
136 |
missionInfo.name = campfile.value(QString("Mission %1/Name").arg(missionNumber)).toString(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
137 |
missionInfo.description = m_info.value(campaignName+"-"+ getCampaignMissionName(campaignName,missionNumber) + ".desc", |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
138 |
QObject::tr("No description available")).toString(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
139 |
missionInfo.script = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString(); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
140 |
missionInfo.image = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString().replace(QString(".lua"),QString(".png")); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
141 |
missionInfoList.append(missionInfo); |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
142 |
} |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
143 |
} |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
144 |
return missionInfoList; |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
145 |
} |
478aa681e702
this seems to work ok, but I have to clean up the code
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9286
diff
changeset
|
146 |
|
9278
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
147 |
QStringList getDescriptions(QString & campaignName, QString & teamName) |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
148 |
{ |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
149 |
QStringList descriptionList; |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
150 |
QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
151 |
teamfile.setIniCodec("UTF-8"); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
152 |
unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt(); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
153 |
qDebug("HERE is progress : %d",progress); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
154 |
unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt(); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
155 |
qDebug("HERE is unlocked missions : %d",unlockedMissions); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
156 |
|
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
157 |
QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
158 |
campfile.setIniCodec("UTF-8"); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
159 |
unsigned int missionsNumber = campfile.value("MissionNum", 0).toInt(); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
160 |
qDebug("HERE is number of missions : %d",missionsNumber); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
161 |
|
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
162 |
|
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
163 |
DataManager & dataMgr = DataManager::instance(); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
164 |
// get locale |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
165 |
QSettings settings(dataMgr.settingsFileName(), |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
166 |
QSettings::IniFormat); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
167 |
QString loc = settings.value("misc/locale", "").toString(); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
168 |
if (loc.isEmpty()) |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
169 |
loc = QLocale::system().name(); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
170 |
QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt"); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
171 |
// if file is non-existant try with language only |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
172 |
if (!QFile::exists(campaignDescFile)) |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
173 |
campaignDescFile = QString("physfs://Locale/campaigns_" + loc.remove(QRegExp("_.*$")) + ".txt"); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
174 |
|
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
175 |
// fallback if file for current locale is non-existant |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
176 |
if (!QFile::exists(campaignDescFile)) |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
177 |
campaignDescFile = QString("physfs://Locale/campaigns_en.txt"); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
178 |
|
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
179 |
QSettings m_info(campaignDescFile, QSettings::IniFormat, 0); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
180 |
m_info.setIniCodec("UTF-8"); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
181 |
|
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
182 |
if(progress>=0 and unlockedMissions==0) |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
183 |
{ |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
184 |
for(unsigned int i=progress+1;i>0;i--) |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
185 |
{ |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
186 |
//update descruiptions here |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
187 |
descriptionList += m_info.value(campaignName+"-"+ getCampaignMissionName(campaignName,i) + ".desc", |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
188 |
QObject::tr("No description available")).toString(); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
189 |
} |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
190 |
} |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
191 |
else if(unlockedMissions>0) |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
192 |
{ |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
193 |
qDebug("IN HERE !!!"); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
194 |
for(unsigned int i=1;i<=unlockedMissions;i++) |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
195 |
{ |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
196 |
QString missionNum = QString("%1").arg(i); |
9286
c89b992ff5fe
fixed bug about starting campaign page with not descriptions/images and with wrong description/image mathcing
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9284
diff
changeset
|
197 |
int missionNumber = teamfile.value("Campaign " + campaignName + "/Mission"+missionNum, -1).toInt(); |
c89b992ff5fe
fixed bug about starting campaign page with not descriptions/images and with wrong description/image mathcing
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9284
diff
changeset
|
198 |
descriptionList += m_info.value(campaignName+"-"+ getCampaignMissionName(campaignName,missionNumber) + ".desc", |
9278
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
199 |
QObject::tr("No description available")).toString(); |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
200 |
} |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
201 |
} |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
202 |
return descriptionList; |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
203 |
} |
33a30ce9782f
this seems to works, still wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9275
diff
changeset
|
204 |
|
9284
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
205 |
QStringList getImages(QString & campaignName, QString & teamName) |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
206 |
{ |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
207 |
QStringList imageList; |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
208 |
QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
209 |
teamfile.setIniCodec("UTF-8"); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
210 |
unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt(); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
211 |
qDebug("HERE is progress : %d",progress); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
212 |
unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt(); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
213 |
qDebug("HERE is unlocked missions : %d",unlockedMissions); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
214 |
|
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
215 |
QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
216 |
campfile.setIniCodec("UTF-8"); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
217 |
unsigned int missionsNumber = campfile.value("MissionNum", 0).toInt(); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
218 |
qDebug("HERE is number of missions : %d",missionsNumber); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
219 |
|
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
220 |
|
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
221 |
DataManager & dataMgr = DataManager::instance(); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
222 |
// get locale |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
223 |
QSettings settings(dataMgr.settingsFileName(), |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
224 |
QSettings::IniFormat); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
225 |
QString loc = settings.value("misc/locale", "").toString(); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
226 |
if (loc.isEmpty()) |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
227 |
loc = QLocale::system().name(); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
228 |
QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt"); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
229 |
// if file is non-existant try with language only |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
230 |
if (!QFile::exists(campaignDescFile)) |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
231 |
campaignDescFile = QString("physfs://Locale/campaigns_" + loc.remove(QRegExp("_.*$")) + ".txt"); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
232 |
|
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
233 |
// fallback if file for current locale is non-existant |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
234 |
if (!QFile::exists(campaignDescFile)) |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
235 |
campaignDescFile = QString("physfs://Locale/campaigns_en.txt"); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
236 |
|
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
237 |
QSettings m_info(campaignDescFile, QSettings::IniFormat, 0); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
238 |
m_info.setIniCodec("UTF-8"); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
239 |
|
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
240 |
if(progress>=0 and unlockedMissions==0) |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
241 |
{ |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
242 |
for(unsigned int i=progress+1;i>0;i--) |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
243 |
{ |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
244 |
//update descruiptions here |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
245 |
imageList += campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png")); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
246 |
} |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
247 |
} |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
248 |
else if(unlockedMissions>0) |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
249 |
{ |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
250 |
qDebug("IN HERE !!!"); |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
251 |
for(unsigned int i=1;i<=unlockedMissions;i++) |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
252 |
{ |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
253 |
QString missionNum = QString("%1").arg(i); |
9286
c89b992ff5fe
fixed bug about starting campaign page with not descriptions/images and with wrong description/image mathcing
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9284
diff
changeset
|
254 |
int missionNumber = teamfile.value("Campaign " + campaignName + "/Mission"+missionNum, -1).toInt(); |
c89b992ff5fe
fixed bug about starting campaign page with not descriptions/images and with wrong description/image mathcing
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9284
diff
changeset
|
255 |
imageList += campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString().replace(QString(".lua"),QString(".png")); |
9284
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
256 |
} |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
257 |
} |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
258 |
return imageList; |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
259 |
} |
13b76fa362b4
images works, but not description/title displayed first time page is opened
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9278
diff
changeset
|
260 |
|
9275
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
261 |
unsigned int getCampProgress(QString & teamName, QString & campName) |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
262 |
{ |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
263 |
QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
264 |
teamfile.setIniCodec("UTF-8"); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
265 |
return teamfile.value("Campaign " + campName + "/Progress", 0).toInt(); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
266 |
} |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
267 |
|
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
268 |
QMap<QString,QString> getUnlockedMissions2(QString & campaignName, QString & teamName) |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
269 |
{ |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
270 |
QMap<QString,QString> hash; |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
271 |
QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
272 |
teamfile.setIniCodec("UTF-8"); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
273 |
unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt(); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
274 |
qDebug("HERE is progress : %d",progress); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
275 |
unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt(); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
276 |
qDebug("HERE is unlocked missions : %d",unlockedMissions); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
277 |
|
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
278 |
QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
279 |
campfile.setIniCodec("UTF-8"); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
280 |
unsigned int missionsNumber = campfile.value("MissionNum", 0).toInt(); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
281 |
qDebug("HERE is number of missions : %d",missionsNumber); |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
282 |
|
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
283 |
if(progress>=0 and unlockedMissions==0) |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
284 |
{ |
3df990e2ee0e
more on campaign page - wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9272
diff
changeset
|
285 |
for(unsigned int i=1;i<=progress+1;i++) |
9272
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
286 |
{ |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
287 |
hash[getCampaignScript(campaignName,i)] = campfile.value(QString("Mission %1/Name").arg(i)).toString(); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
288 |
} |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
289 |
} |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
290 |
else if(unlockedMissions>0) |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
291 |
{ |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
292 |
for(unsigned int i=1;i<=unlockedMissions;i++) |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
293 |
{ |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
294 |
int missionNumber = teamfile.value("Campaign " + campaignName + "/Mission"+i, -1).toInt(); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
295 |
hash[getCampaignScript(campaignName,missionNumber)] = campfile.value(QString("Mission %1/Name").arg(missionNumber)).toString(); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
296 |
} |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
297 |
} |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
298 |
return hash; |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
299 |
} |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
300 |
|
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
301 |
QStringList getUnlockedMissions(QString & teamName, QString & campName) |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
302 |
{ |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
303 |
QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
304 |
teamfile.setIniCodec("UTF-8"); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
305 |
unsigned int mNum = teamfile.value("UnlockedMissions", 0).toInt(); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
306 |
|
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
307 |
QStringList missionList; |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
308 |
for (unsigned int i = 0; i < mNum; i++) |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
309 |
{ |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
310 |
missionList += teamfile.value(QString("Mission%1").arg(i + 1)).toString(); |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
311 |
} |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
312 |
return missionList; |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
313 |
} |
6fa30e491b37
changes in campaign page - not tested wip
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9219
diff
changeset
|
314 |
|
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
315 |
QString getCampaignScript(QString campaign, unsigned int mNum) |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
316 |
{ |
8049 | 317 |
QSettings campfile("physfs://Missions/Campaign/" + campaign + "/campaign.ini", QSettings::IniFormat, 0); |
7201
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
318 |
campfile.setIniCodec("UTF-8"); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
319 |
return campfile.value(QString("Mission %1/Script").arg(mNum)).toString(); |
dc17ffdf0702
The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents:
diff
changeset
|
320 |
} |
9182
f92e205bc167
issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
321 |
|
f92e205bc167
issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
322 |
QString getCampaignImage(QString campaign, unsigned int mNum) |
f92e205bc167
issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
323 |
{ |
9219 | 324 |
return getCampaignScript(campaign,mNum).replace(QString(".lua"),QString(".png")); |
9182
f92e205bc167
issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
325 |
} |
f92e205bc167
issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
326 |
|
9219 | 327 |
QString getCampaignMissionName(QString campaign, unsigned int mNum) |
9182
f92e205bc167
issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
328 |
{ |
9219 | 329 |
return getCampaignScript(campaign,mNum).replace(QString(".lua"),QString("")); |
9182
f92e205bc167
issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
330 |
} |
f92e205bc167
issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
331 |