author | sheepluva |
Tue, 27 Sep 2011 16:14:35 +0200 | |
changeset 6052 | 5e3e7d19bdb5 |
parent 6050 | 07561ade87ca |
child 6054 | d3751a18cecb |
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 |
|
5204 | 26 |
#include "pagetraining.h" |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
27 |
#include "hwconsts.h" |
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
28 |
|
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
|
29 |
QLayout * PageTraining::bodyLayoutDefinition() |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
30 |
{ |
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
|
31 |
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
|
32 |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
33 |
// left column |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
34 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
35 |
// declare start button, caption and description |
6052 | 36 |
btnPreview = formattedButton(":/res/Trainings.png", true); |
37 |
btnPreview->setToolTip(QPushButton::tr("Go!")); |
|
38 |
||
39 |
// make both rows equal height |
|
40 |
pageLayout->setRowStretch(0, 1); |
|
41 |
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
|
42 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
43 |
// add start button, caption and description to 3 different rows |
6052 | 44 |
pageLayout->addWidget(btnPreview, 0, 0); |
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
45 |
|
6052 | 46 |
// center preview |
47 |
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
|
48 |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
49 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
50 |
// right column |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
51 |
|
6052 | 52 |
// info area (caption on top, description below) |
53 |
QVBoxLayout * infoLayout = new QVBoxLayout(); |
|
54 |
||
55 |
lblCaption = new QLabel(); |
|
56 |
lblCaption->setMinimumWidth(360); |
|
57 |
lblCaption->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); |
|
58 |
lblCaption->setWordWrap(true); |
|
59 |
lblDescription = new QLabel(); |
|
60 |
lblDescription->setMinimumWidth(360); |
|
61 |
lblDescription->setAlignment(Qt::AlignHCenter | Qt::AlignTop); |
|
62 |
lblDescription->setWordWrap(true); |
|
63 |
||
64 |
infoLayout->addWidget(lblCaption); |
|
65 |
infoLayout->addWidget(lblDescription); |
|
66 |
||
67 |
pageLayout->addLayout(infoLayout, 0, 1); |
|
68 |
pageLayout->setAlignment(infoLayout, Qt::AlignLeft); |
|
69 |
||
70 |
||
71 |
// mission list |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
72 |
lstMissions = new QListWidget(this); |
6052 | 73 |
pageLayout->addWidget(lstMissions, 1, 0, 1, 2); // span 2 columns |
74 |
||
75 |
// let's not make the list use more space than needed |
|
76 |
lstMissions->setFixedWidth(360); |
|
77 |
pageLayout->setAlignment(lstMissions, Qt::AlignHCenter); |
|
5078
3527f0e7bb21
Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff
changeset
|
78 |
|
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
|
79 |
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
|
80 |
} |
6009 | 81 |
|
6052 | 82 |
QLayout * PageTraining::footerLayoutDefinition() |
83 |
{ |
|
84 |
QBoxLayout * bottomLayout = new QVBoxLayout(); |
|
85 |
||
86 |
btnStart = formattedButton(QPushButton::tr("Go!")); |
|
87 |
btnStart->setFixedWidth(140); |
|
88 |
||
89 |
bottomLayout->addWidget(btnStart); |
|
90 |
||
91 |
bottomLayout->setAlignment(btnStart, Qt::AlignRight | Qt::AlignVCenter); |
|
92 |
||
93 |
return bottomLayout; |
|
94 |
} |
|
95 |
||
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
96 |
|
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
|
97 |
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
|
98 |
{ |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
99 |
connect(lstMissions, SIGNAL(itemSelectionChanged()), this, SLOT(updateInfo())); |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
100 |
connect(lstMissions, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(startSelected())); |
6052 | 101 |
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
|
102 |
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
|
103 |
} |
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
|
104 |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
105 |
|
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
|
106 |
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
|
107 |
{ |
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
|
108 |
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
|
109 |
|
6052 | 110 |
// 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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
QStringList missionList = scriptList(tmpdir); |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
115 |
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
|
116 |
|
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
|
117 |
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
|
118 |
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
|
119 |
QStringList defaultList = scriptList(tmpdir); |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
120 |
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
|
121 |
|
6052 | 122 |
// add non-duplicate default scripts to the list |
123 |
foreach (const QString & mission, defaultList) |
|
124 |
{ |
|
125 |
if (!missionList.contains(mission)) |
|
126 |
missionList.append(mission); |
|
127 |
} |
|
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
|
128 |
|
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
|
129 |
// add only 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
|
130 |
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
|
131 |
{ |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
132 |
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
|
133 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
134 |
// replace underscores in mission name with spaces |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
135 |
item->setText(item->text().replace("_", " ")); |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
136 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
137 |
// 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
|
138 |
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
|
139 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
140 |
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
|
141 |
} |
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
|
142 |
|
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
143 |
updateInfo(); |
6052 | 144 |
|
145 |
// pre-select first mission |
|
146 |
if (lstMissions->count() > 0) |
|
147 |
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
|
148 |
} |
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 |
|
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
|
150 |
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
|
151 |
{ |
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
|
152 |
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
|
153 |
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
|
154 |
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
|
155 |
} |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
156 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
157 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
158 |
void PageTraining::startSelected() |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
159 |
{ |
6050
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
160 |
QListWidgetItem * curItem = lstMissions->currentItem(); |
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
161 |
|
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
162 |
if (curItem != NULL) |
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
163 |
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
|
164 |
} |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
165 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
166 |
|
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
167 |
void PageTraining::updateInfo() |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
168 |
{ |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
169 |
if (lstMissions->currentItem()) |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
170 |
{ |
6050
07561ade87ca
oops, I forgot I wanted to fix that before committing xD
sheepluva
parents:
6048
diff
changeset
|
171 |
// TODO also use .pngs in userdata folder |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
172 |
QString thumbFile = datadir->absolutePath() + "/Graphics/Missions/Training/" + lstMissions->currentItem()->data(Qt::UserRole).toString() + ".png"; |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
173 |
if (QFile::exists(thumbFile)) |
6052 | 174 |
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
|
175 |
else |
6052 | 176 |
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
|
177 |
|
6052 | 178 |
lblCaption->setText("<h2>" + lstMissions->currentItem()->text()+"</h2>"); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
179 |
// TODO load mission description from file |
6052 | 180 |
lblDescription->setText("< Imagine Mission Description here >\n\nThank you."); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
181 |
} |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
182 |
else |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
183 |
{ |
6052 | 184 |
btnPreview->setIcon(QIcon(":/res/Trainings.png")); |
185 |
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
|
186 |
// TODO better text and tr() |
6052 | 187 |
lblDescription->setText(""); |
6048
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
188 |
} |
ae213ef7030a
PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents:
6042
diff
changeset
|
189 |
} |