QTfrontend/ui/page/pagetraining.cpp
author Wuzzy <Wuzzy2@mail.ru>
Thu, 16 May 2019 02:07:29 +0200
changeset 14964 bcecb3349948
parent 14646 e3e6b0c6543f
child 15248 7d957886170f
permissions -rw-r--r--
Display current health in top right corner
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
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10108
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
5078
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
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 9998
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
5078
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
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    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
13087
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
    26
#include <QTextStream>
6059
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
    27
#include <QFile>
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
    28
#include <QLocale>
6058
ae8684864a6e load mission caption and description from localization file (WIP)
sheepluva
parents: 6054
diff changeset
    29
#include <QSettings>
ae8684864a6e load mission caption and description from localization file (WIP)
sheepluva
parents: 6054
diff changeset
    30
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
    31
#include "mission.h"
6159
c780b8cf4d75 introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents: 6073
diff changeset
    32
#include "hwconsts.h"
6930
d187ea93fc4f renaming HWDataManager -> DataManager
sheepluva
parents: 6700
diff changeset
    33
#include "DataManager.h"
6159
c780b8cf4d75 introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents: 6073
diff changeset
    34
5204
e1a5f4d5d86a split pages.h into several header files
koda
parents: 5078
diff changeset
    35
#include "pagetraining.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    36
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
    37
QLayout * PageTraining::bodyLayoutDefinition()
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    38
{
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
    39
    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
    40
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    41
    // declare start button, caption and description
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    42
    btnPreview = formattedButton(":/res/Trainings.png", true);
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    43
14471
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    44
    // tweak widget spacing
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    45
    pageLayout->setRowStretch(0, 1);
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    46
    pageLayout->setRowStretch(1, 1);
14471
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    47
    pageLayout->setRowStretch(2, 1);
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    48
    pageLayout->setColumnStretch(0, 5);
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    49
    pageLayout->setColumnStretch(1, 1);
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    50
    pageLayout->setColumnStretch(2, 9);
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    51
    pageLayout->setColumnStretch(3, 5);
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    52
14471
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    53
    QWidget * infoWidget = new QWidget();
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    54
    QHBoxLayout * infoLayout = new QHBoxLayout();
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    55
    // add preview, caption and description
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    56
    infoWidget->setLayout(infoLayout);
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    57
    infoLayout->addWidget(btnPreview);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    58
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    59
    // center preview
14471
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    60
    infoLayout->setAlignment(btnPreview, Qt::AlignRight | Qt::AlignVCenter);
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
    61
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    62
    // info area (caption on top, description below)
14471
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    63
    QWidget * infoTextWidget = new QWidget();
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    64
    QVBoxLayout * infoTextLayout = new QVBoxLayout();
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    65
    infoTextWidget->setObjectName("trainingInfo");
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    66
    infoTextWidget->setLayout(infoTextLayout);
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    67
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    68
    lblCaption = new QLabel();
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    69
    lblCaption->setMinimumWidth(360);
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    70
    lblCaption->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    71
    lblCaption->setWordWrap(true);
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    72
    lblDescription = new QLabel();
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    73
    lblDescription->setMinimumWidth(360);
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    74
    lblDescription->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    75
    lblDescription->setWordWrap(true);
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
    76
    lblHighscores = new QLabel();
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
    77
    lblHighscores->setMinimumWidth(360);
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
    78
    lblHighscores->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    79
14471
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    80
    infoTextLayout->addWidget(lblCaption);
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    81
    infoTextLayout->addWidget(lblDescription);
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
    82
    infoTextLayout->addWidget(lblHighscores);
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    83
14471
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    84
    infoLayout->addWidget(infoTextWidget);
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    85
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    86
    pageLayout->addWidget(infoWidget, 0, 1, 1, 2); // span 2 columns
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    87
    pageLayout->setAlignment(infoTextWidget, Qt::AlignLeft);
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    88
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
    89
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    90
    // tab widget containing all lists
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    91
    tbw = new QTabWidget(this);
14471
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
    92
    pageLayout->addWidget(tbw, 1, 0, 1, 4); // span 4 columns
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    93
    // let's not make the tab widget use more space than needed
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    94
    tbw->setFixedWidth(400);
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    95
    pageLayout->setAlignment(tbw, Qt::AlignHCenter);
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
    96
 
11970
f6fc7e9bef3d Make tab of mission list tab header blend into mission list
Wuzzy <almikes@aol.com>
parents: 11968
diff changeset
    97
    tbw->setStyleSheet("QListWidget { border-style: none; padding-top: 6px; }");
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    98
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    99
    // training/challenge/scenario lists
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   100
    lstTrainings = new QListWidget(this);
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   101
    lstTrainings ->setWhatsThis(tr("Pick the training to play"));
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   102
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   103
    lstChallenges = new QListWidget(this);
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   104
    lstChallenges ->setWhatsThis(tr("Pick the challenge to play"));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   105
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   106
    lstScenarios= new QListWidget(this);
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   107
    lstScenarios->setWhatsThis(tr("Pick the scenario to play"));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   108
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   109
    tbw->addTab(lstTrainings, tr("Trainings"));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   110
    tbw->addTab(lstChallenges, tr("Challenges"));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   111
    tbw->addTab(lstScenarios, tr("Scenarios"));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   112
    tbw->setCurrentWidget(lstTrainings);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   113
14462
4c743ef80b1b Add team selection in training page and basic check mark support
Wuzzy <Wuzzy2@mail.ru>
parents: 13645
diff changeset
   114
    QLabel* lblteam = new QLabel(tr("Team"));
4c743ef80b1b Add team selection in training page and basic check mark support
Wuzzy <Wuzzy2@mail.ru>
parents: 13645
diff changeset
   115
    CBTeam = new QComboBox(this);
4c743ef80b1b Add team selection in training page and basic check mark support
Wuzzy <Wuzzy2@mail.ru>
parents: 13645
diff changeset
   116
    CBTeam->setMaxVisibleItems(30);
14471
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
   117
    pageLayout->addWidget(lblteam, 2, 1);
c5033a95fd7b Tweak training menu spacing
Wuzzy <Wuzzy2@mail.ru>
parents: 14462
diff changeset
   118
    pageLayout->addWidget(CBTeam, 2, 2);
14462
4c743ef80b1b Add team selection in training page and basic check mark support
Wuzzy <Wuzzy2@mail.ru>
parents: 13645
diff changeset
   119
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
   120
    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
   121
}
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5238
diff changeset
   122
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   123
QLayout * PageTraining::footerLayoutDefinition()
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   124
{
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   125
    QBoxLayout * bottomLayout = new QVBoxLayout();
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   126
11973
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   127
    const QIcon& lp = QIcon(":/res/Start.png");
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   128
    QSize sz = lp.actualSize(QSize(65535, 65535));
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   129
    btnStart = new QPushButton();
12236
a0ed4caa6d35 Apply minimal padding to all text buttons in frontend
Wuzzy <almikes@aol.com>
parents: 11973
diff changeset
   130
    btnStart->setStyleSheet("padding: 5px 10px");
11973
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   131
    btnStart->setText(QPushButton::tr("Start"));
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   132
    btnStart->setWhatsThis(tr("Start fighting"));
11973
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   133
    btnStart->setMinimumWidth(sz.width() + 60);
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   134
    btnStart->setIcon(lp);
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   135
    btnStart->setFixedHeight(50);
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   136
    btnStart->setIconSize(sz);
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   137
    btnStart->setFlat(true);
de1b616fd5e6 Use proper start button in training menu
Wuzzy <almikes@aol.com>
parents: 11970
diff changeset
   138
    btnStart->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   139
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   140
    bottomLayout->addWidget(btnStart);
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   141
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   142
    bottomLayout->setAlignment(btnStart, Qt::AlignRight | Qt::AlignVCenter);
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   143
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   144
    return bottomLayout;
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   145
}
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   146
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   147
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
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
   149
{
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   150
    connect(lstTrainings, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(updateInfo()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   151
    connect(lstTrainings, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateInfo()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   152
    connect(lstTrainings, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(startSelected()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   153
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   154
    connect(lstChallenges, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(updateInfo()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   155
    connect(lstChallenges, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateInfo()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   156
    connect(lstChallenges, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(startSelected()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   157
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   158
    connect(lstScenarios, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(updateInfo()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   159
    connect(lstScenarios, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(updateInfo()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   160
    connect(lstScenarios, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(startSelected()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   161
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   162
    connect(tbw, SIGNAL(currentChanged(int)), this, SLOT(updateInfo()));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   163
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   164
    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
   165
    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
   166
}
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
   167
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   168
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
   169
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
   170
{
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
   171
    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
   172
6930
d187ea93fc4f renaming HWDataManager -> DataManager
sheepluva
parents: 6700
diff changeset
   173
    DataManager & dataMgr = DataManager::instance();
6196
c16e84558f71 minor cleanups, mostly in own code
sheepluva
parents: 6183
diff changeset
   174
6059
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   175
    // get locale
8918
512753ea4b1b Switch to 'settings.ini'. Copies old ini file if necessary on startup.
unc0rr
parents: 8098
diff changeset
   176
    QSettings settings(dataMgr.settingsFileName(),
6059
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   177
                       QSettings::IniFormat);
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   178
13274
e381f5260b45 Change how locale is loaded in frontend, and fix some bugs
Wuzzy <Wuzzy2@mail.ru>
parents: 13087
diff changeset
   179
    QString loc = QLocale().name();
6059
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   180
8049
133e22b5c410 Get rid of DataManager::findFileForRead
unc0rr
parents: 6952
diff changeset
   181
    QString infoFile = QString("physfs://Locale/missions_" + loc + ".txt");
6059
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   182
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   183
    // if file is non-existant try with language only
6167
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6160
diff changeset
   184
    if (!QFile::exists(infoFile))
8049
133e22b5c410 Get rid of DataManager::findFileForRead
unc0rr
parents: 6952
diff changeset
   185
        infoFile = QString("physfs://Locale/missions_" + loc.remove(QRegExp("_.*$")) + ".txt");
6059
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   186
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   187
    // fallback if file for current locale is non-existant
6167
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6160
diff changeset
   188
    if (!QFile::exists(infoFile))
8049
133e22b5c410 Get rid of DataManager::findFileForRead
unc0rr
parents: 6952
diff changeset
   189
        infoFile = QString("physfs://Locale/missions_en.txt");
6159
c780b8cf4d75 introduce HWDataManager util for transparent access to [user-]data files
sheepluva
parents: 6073
diff changeset
   190
6059
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   191
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   192
    // preload mission info for current locale
6167
728cabee2c9f simplified some stuff I wrote
sheepluva
parents: 6160
diff changeset
   193
    m_info = new QSettings(infoFile, QSettings::IniFormat, this);
6257
e6690d3a8a44 mission locale -> UTF-8
sheepluva
parents: 6196
diff changeset
   194
    m_info->setIniCodec("UTF-8");
6058
ae8684864a6e load mission caption and description from localization file (WIP)
sheepluva
parents: 6054
diff changeset
   195
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   196
    QStringList m_list;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   197
    QListWidget * m_widget;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   198
    QString subFolder;
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   199
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   200
    for(int i=1; i<=3; i++) {
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   201
        switch(i) {
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   202
            case 1:
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   203
                subFolder = "Training";
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   204
                m_widget = lstTrainings;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   205
                break;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   206
            case 2:
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   207
                subFolder = "Challenge";
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   208
                m_widget = lstChallenges;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   209
                break;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   210
            case 3:
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   211
                subFolder = "Scenario";
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   212
                m_widget = lstScenarios;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   213
                break;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   214
        }
13087
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   215
        // scripts to load
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   216
        // first, load scripts in order specified in order.cfg (if present)
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   217
        QFile orderFile(QString("physfs://Missions/%1/order.cfg").arg(subFolder));
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   218
        QStringList orderedMissions;
14462
4c743ef80b1b Add team selection in training page and basic check mark support
Wuzzy <Wuzzy2@mail.ru>
parents: 13645
diff changeset
   219
13087
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   220
        if (orderFile.open(QFile::ReadOnly))
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   221
        {
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   222
            QString m_id;
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   223
            QTextStream input(&orderFile);
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   224
            while(true)
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   225
            {
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   226
                m_id = input.readLine();
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   227
                if(m_id.isNull() || m_id.isEmpty())
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   228
                {
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   229
                    break;
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   230
                }
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   231
                QListWidgetItem * item = new QListWidgetItem(m_id);
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   232
                QString name = item->text().replace("_", " ");
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   233
                name = m_info->value(m_id + ".name", name).toString();
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   234
                item->setText(name);
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   235
                item->setData(Qt::UserRole, m_id);
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   236
                m_widget->addItem(item);
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   237
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   238
                orderedMissions << m_id;
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   239
            }
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   240
        }
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   241
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   242
        // then, just load anything else in no particular order
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   243
        m_list = dataMgr.entryList(
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   244
                    "Missions/" + subFolder,
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   245
                    QDir::Files, QStringList("*.lua")).
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   246
               replaceInStrings(QRegExp("\\.lua$"), "");
6059
ddf020d0941a training screen localization works now
sheepluva
parents: 6058
diff changeset
   247
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   248
        foreach (const QString & m_id, m_list)
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   249
        {
13087
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   250
            // Disallow duplicates from order.cfg
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   251
            if (orderedMissions.contains(m_id))
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   252
            {
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   253
                continue;
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   254
            }
b6df6283e2ba Sort all core missions in training menu more logically
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
   255
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   256
            QListWidgetItem * item = new QListWidgetItem(m_id);
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   257
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   258
            // fallback name: replace underscores in mission name with spaces
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   259
            QString name = item->text().replace("_", " ");
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   260
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   261
            // see if we can get a prettier/translated name
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   262
            name = m_info->value(m_id + ".name", name).toString();
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   263
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   264
            item->setText(name);
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   265
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   266
            // store original name in data
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   267
            item->setData(Qt::UserRole, m_id);
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   268
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   269
            m_widget->addItem(item);
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   270
        }
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
   271
    }
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
   272
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   273
    updateInfo();
6052
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   274
5e3e7d19bdb5 stuffToBeAvoidedInFuture->append("layouting");
sheepluva
parents: 6050
diff changeset
   275
    // pre-select first mission
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   276
    if (lstTrainings->count() > 0)
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   277
        lstTrainings->setCurrentRow(0);
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   278
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   279
    if (lstChallenges->count() > 0)
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   280
        lstChallenges->setCurrentRow(0);
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   281
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   282
    if (lstScenarios->count() > 0)
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   283
        lstScenarios->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
   284
}
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
   285
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   286
QString PageTraining::getSubFolderOfSelected()
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   287
{
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   288
    QString subFolder;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   289
    if (tbw->currentWidget() == lstTrainings) {
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   290
        subFolder = "Training";
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   291
    } else if (tbw->currentWidget() == lstChallenges) {
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   292
        subFolder = "Challenge";
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   293
    } else if (tbw->currentWidget() == lstScenarios) {
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   294
        subFolder = "Scenario";
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   295
    } else {
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   296
        subFolder = "Training";
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   297
    }
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   298
    return subFolder;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   299
}
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   300
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   301
void PageTraining::startSelected()
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   302
{
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   303
    QListWidget *list;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   304
    list = (QListWidget*) tbw->currentWidget();
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   305
    QListWidgetItem * curItem = list->currentItem();
6050
07561ade87ca oops, I forgot I wanted to fix that before committing xD
sheepluva
parents: 6048
diff changeset
   306
14646
e3e6b0c6543f Frontend: Gray out campaign/training start buttons when no human team available
Wuzzy <Wuzzy2@mail.ru>
parents: 14591
diff changeset
   307
    if ((curItem != NULL) && (CBTeam->currentIndex() != -1))
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   308
        emit startMission(curItem->data(Qt::UserRole).toString(), getSubFolderOfSelected());
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   309
}
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   310
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   311
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   312
void PageTraining::updateInfo()
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   313
{
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   314
    if (tbw->currentWidget())
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   315
    {
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   316
        QString subFolder;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   317
        QListWidget *list;
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   318
        subFolder = getSubFolderOfSelected();
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   319
        list = (QListWidget*) tbw->currentWidget();
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   320
        if (list->currentItem())
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   321
        {
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   322
            QString missionName = list->currentItem()->data(Qt::UserRole).toString();
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   323
            QString thumbFile =     "physfs://Graphics/Missions/" +
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   324
                                    subFolder + "/" +
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   325
                                    missionName +
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   326
                                    "@2x.png";
6058
ae8684864a6e load mission caption and description from localization file (WIP)
sheepluva
parents: 6054
diff changeset
   327
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   328
            if (QFile::exists(thumbFile))
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   329
                btnPreview->setIcon(QIcon(thumbFile));
14473
afa4f2140252 Add image for challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14471
diff changeset
   330
            else if (tbw->currentWidget() == lstChallenges)
afa4f2140252 Add image for challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14471
diff changeset
   331
                btnPreview->setIcon(QIcon(":/res/Challenges.png"));
14474
2c3fb87ad1c5 Add fallback preview image for scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14473
diff changeset
   332
            else if (tbw->currentWidget() == lstScenarios)
2c3fb87ad1c5 Add fallback preview image for scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14473
diff changeset
   333
                // TODO: Prettier scenario fallback image
2c3fb87ad1c5 Add fallback preview image for scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14473
diff changeset
   334
                btnPreview->setIcon(QIcon(":/res/Scenarios.png"));
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   335
            else
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   336
                btnPreview->setIcon(QIcon(":/res/Trainings.png"));
6058
ae8684864a6e load mission caption and description from localization file (WIP)
sheepluva
parents: 6054
diff changeset
   337
12240
88b31fdc760b Add a few WhatsThis texts in frontend, rename “Stereo rendering” to “Stereoscopy”
Wuzzy <almikes@aol.com>
parents: 12236
diff changeset
   338
            btnPreview->setWhatsThis(tr("Start fighting"));
88b31fdc760b Add a few WhatsThis texts in frontend, rename “Stereo rendering” to “Stereoscopy”
Wuzzy <almikes@aol.com>
parents: 12236
diff changeset
   339
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   340
            QString caption = m_info->value(missionName + ".name",
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   341
                                            list->currentItem()->text()).toString();
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   342
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   343
            QString description = m_info->value(missionName + ".desc",
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   344
                                                tr("No description available")).toString();
6058
ae8684864a6e load mission caption and description from localization file (WIP)
sheepluva
parents: 6054
diff changeset
   345
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   346
            lblCaption->setText("<h2>" + caption +"</h2>");
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   347
            lblDescription->setText(description);
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   348
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   349
            // Challenge highscores
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   350
            QString highscoreText = QString("");
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   351
            QString teamName = CBTeam->currentText();
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   352
            if (missionValueExists(missionName, teamName, "Highscore"))
14527
0fc9560be9cc Pagetraining: Make sure the translator comment will be collected
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   353
                highscoreText = highscoreText +
0fc9560be9cc Pagetraining: Make sure the translator comment will be collected
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   354
                    //: Highest score of a team
0fc9560be9cc Pagetraining: Make sure the translator comment will be collected
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   355
                    tr("Team highscore: %1")
0fc9560be9cc Pagetraining: Make sure the translator comment will be collected
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   356
                    .arg(getMissionValue(missionName, teamName, "Highscore").toString()) + "\n";
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   357
            if (missionValueExists(missionName, teamName, "Lowscore"))
14527
0fc9560be9cc Pagetraining: Make sure the translator comment will be collected
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   358
                highscoreText = highscoreText +
0fc9560be9cc Pagetraining: Make sure the translator comment will be collected
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   359
                    //: Lowest score of a team
0fc9560be9cc Pagetraining: Make sure the translator comment will be collected
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   360
                    tr("Team lowscore: %1")
0fc9560be9cc Pagetraining: Make sure the translator comment will be collected
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   361
                    .arg(getMissionValue(missionName, teamName, "Lowscore").toString()) + "\n";
14591
b4089fa16b34 Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14527
diff changeset
   362
            if (missionValueExists(missionName, teamName, "AccuracyRecord"))
b4089fa16b34 Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14527
diff changeset
   363
                highscoreText = highscoreText +
b4089fa16b34 Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14527
diff changeset
   364
                    //: Best accuracy of a team (in a challenge)
b4089fa16b34 Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14527
diff changeset
   365
                    tr("Team's top accuracy: %1%")
b4089fa16b34 Keep track of accuracy record in target practice challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14527
diff changeset
   366
                    .arg(getMissionValue(missionName, teamName, "AccuracyRecord").toString()) + "\n";
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   367
            if (missionValueExists(missionName, teamName, "TimeRecord"))
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   368
            {
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   369
                double time = ((double) getMissionValue(missionName, teamName, "TimeRecord").toInt()) / 1000.0;
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   370
                highscoreText = highscoreText + tr("Team's best time: %L1 s").arg(time, 0, 'f', 3) + "\n";
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   371
            }
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   372
            if (missionValueExists(missionName, teamName, "TimeRecordHigh"))
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   373
            {
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   374
                double time = ((double) getMissionValue(missionName, teamName, "TimeRecordHigh").toInt()) / 1000.0;
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   375
                highscoreText = highscoreText + tr("Team's longest time: %L1 s").arg(time, 0, 'f', 3) + "\n";
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   376
            }
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   377
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   378
            lblHighscores->setText(highscoreText);
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   379
        }
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   380
        else
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   381
        {
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   382
            btnPreview->setIcon(QIcon(":/res/Trainings.png"));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   383
            lblCaption->setText(tr("Select a mission!"));
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   384
            lblDescription->setText("");
14525
029f40c609b4 Display team records in training menu
Wuzzy <Wuzzy2@mail.ru>
parents: 14474
diff changeset
   385
            lblHighscores->setText("");
11968
1de4d6b35748 Mission recategorization into trainings, challenges and scenarios.
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   386
        }
6048
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   387
    }
ae213ef7030a PIMP'ed up training screen. special thanks to mikade for supplying the pics <3
sheepluva
parents: 6042
diff changeset
   388
}