QTfrontend/pagetraining.cpp
author sheepluva
Tue, 27 Sep 2011 05:08:23 +0200
changeset 6050 07561ade87ca
parent 6048 ae213ef7030a
child 6052 5e3e7d19bdb5
permissions -rw-r--r--
oops, I forgot I wanted to fix that before committing xD
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    20
#include <QLabel>
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    21
#include <QListWidget>
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    22
#include <QListWidgetItem>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
#include <QPushButton>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    24
5204
e1a5f4d5d86a split pages.h into several header files
koda
parents: 5078
diff changeset
    25
#include "pagetraining.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    26
#include "hwconsts.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    27
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
    28
QLayout * PageTraining::bodyLayoutDefinition()
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    29
{
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
    30
    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
    31
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    32
// left column
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    33
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    34
    // declare start button, caption and description
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    35
    btnStart = formattedButton(":/res/Trainings.png", true);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    36
    btnStart->setToolTip(QPushButton::tr("Go!"));
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    37
    lblCaption = new QLabel(this);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    38
    lblDescription = new QLabel(this);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    39
    lblDescription->setWordWrap(true);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    40
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    41
    // add start button, caption and description to 3 different rows
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    42
    pageLayout->addWidget(btnStart, 0, 0);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    43
    pageLayout->addWidget(lblCaption, 1, 0);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    44
    pageLayout->addWidget(lblDescription, 2, 0);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    45
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    46
    // make first and last row stretch vertically
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    47
    pageLayout->setRowStretch(0, 1);
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    48
    pageLayout->setRowStretch(1, 0);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    49
    pageLayout->setRowStretch(2, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    50
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    51
    // make both columns equal width
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    52
    pageLayout->setColumnStretch(0, 1);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    53
    pageLayout->setColumnStretch(1, 1);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    54
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    55
    // center widgets within their grid cells
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    56
    pageLayout->setAlignment(btnStart, Qt::AlignHCenter | Qt::AlignVCenter);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    57
    pageLayout->setAlignment(lblCaption, Qt::AlignHCenter | Qt::AlignVCenter);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    58
    pageLayout->setAlignment(lblDescription, Qt::AlignHCenter | Qt::AlignVCenter);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    59
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    60
// right column
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    61
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    62
    lstMissions = new QListWidget(this);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    63
    pageLayout->addWidget(lstMissions, 0, 1, 3, 1); // spans over 3 rows
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    64
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
    65
    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
    66
}
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5238
diff changeset
    67
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    68
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
    69
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
    70
{
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    71
    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
    72
    connect(lstMissions, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(startSelected()));
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    73
    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
    74
}
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
    75
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    76
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
    77
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
    78
{
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
    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
    80
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
    81
    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
    82
    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
    83
    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
    84
    QStringList missionList = scriptList(tmpdir);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    85
    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
    86
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
    87
    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
    88
    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
    89
    QStringList defaultList = scriptList(tmpdir);
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    90
    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
    91
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    92
    missionList << defaultList;
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
    93
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
    94
    // 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
    95
    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
    96
    {
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    97
        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
    98
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    99
        // 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
   100
        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
   101
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   102
        // 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
   103
        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
   104
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   105
        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
   106
    }
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
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   108
    updateInfo();
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
}
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
   110
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
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
   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
    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
   114
    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
   115
    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
   116
}
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   117
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   118
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   119
void PageTraining::startSelected()
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   120
{
6050
07561ade87ca oops, I forgot I wanted to fix that before committing xD
sheepluva
parents: 6048
diff changeset
   121
    QListWidgetItem * curItem = lstMissions->currentItem();
07561ade87ca oops, I forgot I wanted to fix that before committing xD
sheepluva
parents: 6048
diff changeset
   122
07561ade87ca oops, I forgot I wanted to fix that before committing xD
sheepluva
parents: 6048
diff changeset
   123
    if (curItem != NULL)
07561ade87ca oops, I forgot I wanted to fix that before committing xD
sheepluva
parents: 6048
diff changeset
   124
        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
   125
}
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   126
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   127
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   128
void PageTraining::updateInfo()
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   129
{
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   130
    if (lstMissions->currentItem())
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   131
    {
6050
07561ade87ca oops, I forgot I wanted to fix that before committing xD
sheepluva
parents: 6048
diff changeset
   132
        // 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
   133
        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
   134
        if (QFile::exists(thumbFile))
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   135
            btnStart->setIcon(QIcon(thumbFile));
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   136
        else
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   137
            btnStart->setIcon(QIcon(":/res/Trainings.png"));
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   138
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   139
        lblCaption->setText(lstMissions->currentItem()->text());
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   140
        // TODO load mission description from file
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   141
        lblDescription->setText("< Imagine\nMission\nDescription\nhere >\n\nThank you.");
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   142
    }
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   143
    else
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   144
    {
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   145
        btnStart->setIcon(QIcon(":/res/Trainings.png"));
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   146
        lblCaption->setText(tr("Select a mission on the right -->"));
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   147
        // TODO better text and tr()
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   148
        lblDescription->setText("Welcome to the Training screen.\n\n\n...\nWHAT?\nIt's not finished yet...");
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   149
    }
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   150
}