author | sheepluva |
Wed, 28 Sep 2011 19:27:56 +0200 | |
changeset 6060 | fdfc01419815 |
parent 6059 | QTfrontend/pagetraining.cpp@ddf020d0941a |
child 6073 | e6ce1a337e0f |
permissions | -rw-r--r-- |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
1 |
/* |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
3 |
* Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com> |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
4 |
* |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
8 |
* |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
13 |
* |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
17 |
*/ |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
18 |
|
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
19 |
#include <QGridLayout> |
6052 | 20 |
#include <QVBoxLayout> |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
21 |
#include <QLabel> |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
22 |
#include <QListWidget> |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
23 |
#include <QListWidgetItem> |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
24 |
#include <QPushButton> |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
25 |
|
6059 | 26 |
#include <QFile> |
27 |
#include <QLocale> |
|
6058
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
28 |
#include <QSettings> |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
29 |
|
5204 | 30 |
#include "pagetraining.h" |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
31 |
#include "hwconsts.h" |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
32 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
33 |
QLayout * PageTraining::bodyLayoutDefinition() |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
34 |
{ |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
35 |
QGridLayout * pageLayout = new QGridLayout(); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
36 |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
37 |
// left column |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
38 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
39 |
// declare start button, caption and description |
6052 | 40 |
btnPreview = formattedButton(":/res/Trainings.png", true); |
41 |
btnPreview->setToolTip(QPushButton::tr("Go!")); |
|
42 |
||
43 |
// make both rows equal height |
|
44 |
pageLayout->setRowStretch(0, 1); |
|
45 |
pageLayout->setRowStretch(1, 1); |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
46 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
47 |
// add start button, caption and description to 3 different rows |
6052 | 48 |
pageLayout->addWidget(btnPreview, 0, 0); |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
49 |
|
6052 | 50 |
// center preview |
51 |
pageLayout->setAlignment(btnPreview, Qt::AlignRight | Qt::AlignVCenter); |
|
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
52 |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
53 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
54 |
// right column |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
55 |
|
6052 | 56 |
// info area (caption on top, description below) |
57 |
QVBoxLayout * infoLayout = new QVBoxLayout(); |
|
58 |
||
59 |
lblCaption = new QLabel(); |
|
60 |
lblCaption->setMinimumWidth(360); |
|
61 |
lblCaption->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); |
|
62 |
lblCaption->setWordWrap(true); |
|
63 |
lblDescription = new QLabel(); |
|
64 |
lblDescription->setMinimumWidth(360); |
|
65 |
lblDescription->setAlignment(Qt::AlignHCenter | Qt::AlignTop); |
|
66 |
lblDescription->setWordWrap(true); |
|
67 |
||
68 |
infoLayout->addWidget(lblCaption); |
|
69 |
infoLayout->addWidget(lblDescription); |
|
70 |
||
71 |
pageLayout->addLayout(infoLayout, 0, 1); |
|
72 |
pageLayout->setAlignment(infoLayout, Qt::AlignLeft); |
|
73 |
||
74 |
||
75 |
// mission list |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
76 |
lstMissions = new QListWidget(this); |
6052 | 77 |
pageLayout->addWidget(lstMissions, 1, 0, 1, 2); // span 2 columns |
78 |
||
79 |
// let's not make the list use more space than needed |
|
80 |
lstMissions->setFixedWidth(360); |
|
81 |
pageLayout->setAlignment(lstMissions, Qt::AlignHCenter); |
|
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
82 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
83 |
return pageLayout; |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
84 |
} |
6009 | 85 |
|
6052 | 86 |
QLayout * PageTraining::footerLayoutDefinition() |
87 |
{ |
|
88 |
QBoxLayout * bottomLayout = new QVBoxLayout(); |
|
89 |
||
90 |
btnStart = formattedButton(QPushButton::tr("Go!")); |
|
91 |
btnStart->setFixedWidth(140); |
|
92 |
||
93 |
bottomLayout->addWidget(btnStart); |
|
94 |
||
95 |
bottomLayout->setAlignment(btnStart, Qt::AlignRight | Qt::AlignVCenter); |
|
96 |
||
97 |
return bottomLayout; |
|
98 |
} |
|
99 |
||
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
100 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
101 |
void PageTraining::connectSignals() |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
102 |
{ |
6054
d3751a18cecb
use currentItemChanged signal instead of itemSelectionChanged - since the latter is always one item behind if you hold down the mousebutton and move the cursor through the list
sheepluva
parents:
6052
diff
changeset
|
103 |
connect(lstMissions, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(updateInfo())); |
d3751a18cecb
use currentItemChanged signal instead of itemSelectionChanged - since the latter is always one item behind if you hold down the mousebutton and move the cursor through the list
sheepluva
parents:
6052
diff
changeset
|
104 |
connect(lstMissions, SIGNAL(clicked()), this, SLOT(updateInfo())); |
d3751a18cecb
use currentItemChanged signal instead of itemSelectionChanged - since the latter is always one item behind if you hold down the mousebutton and move the cursor through the list
sheepluva
parents:
6052
diff
changeset
|
105 |
connect(lstMissions, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(startSelected())); |
6052 | 106 |
connect(btnPreview, SIGNAL(clicked()), this, SLOT(startSelected())); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
107 |
connect(btnStart, SIGNAL(clicked()), this, SLOT(startSelected())); |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
108 |
} |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
109 |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
110 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
111 |
PageTraining::PageTraining(QWidget* parent) : AbstractPage(parent) |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
112 |
{ |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
113 |
initPage(); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
114 |
|
6059 | 115 |
// get locale |
116 |
QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", |
|
117 |
QSettings::IniFormat); |
|
118 |
||
119 |
QString loc = settings.value("misc/locale", "").toString(); |
|
120 |
if (loc.isEmpty()) |
|
121 |
loc = QLocale::system().name(); |
|
122 |
||
123 |
QString infoFile = |
|
124 |
datadir->absolutePath() + "/Locale/missions_" + loc + ".txt"; |
|
125 |
||
126 |
// if file is non-existant try with language only |
|
127 |
if (!QFile::exists(infoFile)) |
|
128 |
infoFile = datadir->absolutePath() + "/Locale/missions_" + |
|
129 |
loc.replace(QRegExp("_.*$"),"") + ".txt"; |
|
130 |
||
131 |
// fallback if file for current locale is non-existant |
|
132 |
if (!QFile::exists(infoFile)) |
|
133 |
infoFile = datadir->absolutePath() + "/Locale/missions_en.txt"; |
|
134 |
||
135 |
// preload mission info for current locale |
|
136 |
m_info = new QSettings(infoFile, QSettings::IniFormat, this); |
|
6058
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
137 |
|
6052 | 138 |
// TODO -> this should be done in a tool "DataDir" class |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
139 |
QDir tmpdir; |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
140 |
tmpdir.cd(cfgdir->absolutePath()); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
141 |
tmpdir.cd("Data/Missions/Training"); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
142 |
QStringList missionList = scriptList(tmpdir); |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
143 |
missionList.sort(); |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
144 |
|
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
145 |
tmpdir.cd(datadir->absolutePath()); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
146 |
tmpdir.cd("Missions/Training"); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
147 |
QStringList defaultList = scriptList(tmpdir); |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
148 |
defaultList.sort(); |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
149 |
|
6052 | 150 |
// add non-duplicate default scripts to the list |
151 |
foreach (const QString & mission, defaultList) |
|
152 |
{ |
|
153 |
if (!missionList.contains(mission)) |
|
154 |
missionList.append(mission); |
|
155 |
} |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
156 |
|
6058
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
157 |
// add default scripts that have names different from detected user scripts |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
158 |
foreach (const QString & mission, missionList) |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
159 |
{ |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
160 |
QListWidgetItem * item = new QListWidgetItem(mission); |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
161 |
|
6059 | 162 |
// fallback name: replace underscores in mission name with spaces |
163 |
QString name = item->text().replace("_", " "); |
|
164 |
||
165 |
// see if we can get a prettier/translated name |
|
166 |
name = m_info->value(mission + ".name", name).toString(); |
|
167 |
||
168 |
item->setText(name); |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
169 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
170 |
// store original name in data |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
171 |
item->setData(Qt::UserRole, mission); |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
172 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
173 |
lstMissions->addItem(item); |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
174 |
} |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
175 |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
176 |
updateInfo(); |
6052 | 177 |
|
178 |
// pre-select first mission |
|
179 |
if (lstMissions->count() > 0) |
|
180 |
lstMissions->setCurrentRow(0); |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
181 |
} |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
182 |
|
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
183 |
QStringList PageTraining::scriptList(const QDir & scriptDir) const |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
184 |
{ |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
185 |
QDir dir = scriptDir; |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
186 |
dir.setFilter(QDir::Files); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
187 |
return dir.entryList(QStringList("*.lua")).replaceInStrings(QRegExp("^(.*)\\.lua"), "\\1"); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
188 |
} |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
189 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
190 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
191 |
void PageTraining::startSelected() |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
192 |
{ |
6050
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
193 |
QListWidgetItem * curItem = lstMissions->currentItem(); |
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
194 |
|
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
195 |
if (curItem != NULL) |
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
196 |
emit startMission(curItem->data(Qt::UserRole).toString()); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
197 |
} |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
198 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
199 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
200 |
void PageTraining::updateInfo() |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
201 |
{ |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
202 |
if (lstMissions->currentItem()) |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
203 |
{ |
6050
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
204 |
// TODO also use .pngs in userdata folder |
6058
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
205 |
QString thumbFile = datadir->absolutePath() + |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
206 |
"/Graphics/Missions/Training/" + |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
207 |
lstMissions->currentItem()->data(Qt::UserRole).toString() + |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
208 |
".png"; |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
209 |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
210 |
if (QFile::exists(thumbFile)) |
6052 | 211 |
btnPreview->setIcon(QIcon(thumbFile)); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
212 |
else |
6052 | 213 |
btnPreview->setIcon(QIcon(":/res/Trainings.png")); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
214 |
|
6058
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
215 |
QString realName = lstMissions->currentItem()->data( |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
216 |
Qt::UserRole).toString(); |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
217 |
|
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
218 |
QString caption = m_info->value(realName + ".name", |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
219 |
lstMissions->currentItem()->text()).toString(); |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
220 |
|
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
221 |
QString description = m_info->value(realName + ".desc", |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
222 |
tr("No description available")).toString(); |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
223 |
|
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
224 |
lblCaption->setText("<h2>" + caption +"</h2>"); |
ae8684864a6e
load mission caption and description from localization file (WIP)
sheepluva
parents:
6054
diff
changeset
|
225 |
lblDescription->setText(description); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
226 |
} |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
227 |
else |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
228 |
{ |
6052 | 229 |
btnPreview->setIcon(QIcon(":/res/Trainings.png")); |
230 |
lblCaption->setText(tr("Select a mission!")); |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
231 |
// TODO better text and tr() |
6052 | 232 |
lblDescription->setText(""); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
233 |
} |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
234 |
} |