QTfrontend/ui/page/pagecampaign.cpp
author Wuzzy <Wuzzy2@mail.ru>
Sun, 11 Mar 2018 21:38:08 +0100
changeset 13165 89a6b862e692
parent 12240 88b31fdc760b
child 13632 4c49a4944884
permissions -rw-r--r--
Bazooka/Grenade Training: Make weapon selection detection future-proof The old check relied on hardcoded slot IDs for the weapons, which is not good.
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: 10248
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>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    20
#include <QPushButton>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    21
#include <QComboBox>
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    22
#include <QLabel>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
5204
e1a5f4d5d86a split pages.h into several header files
koda
parents: 5078
diff changeset
    24
#include "pagecampaign.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    25
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
    26
QLayout * PageCampaign::bodyLayoutDefinition()
5078
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
    QGridLayout * pageLayout = new QGridLayout();
11953
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    29
    pageLayout->setColumnStretch(0, 5);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    30
    pageLayout->setColumnStretch(1, 1);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    31
    pageLayout->setColumnStretch(2, 9);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    32
    pageLayout->setColumnStretch(3, 5);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    33
    pageLayout->setRowStretch(0, 1);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    34
    pageLayout->setRowStretch(3, 1);
9219
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    35
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    36
    QGridLayout * infoLayout = new QGridLayout();
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    37
    infoLayout->setColumnStretch(0, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    38
    infoLayout->setColumnStretch(1, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    39
    infoLayout->setColumnStretch(2, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    40
    infoLayout->setColumnStretch(3, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    41
    infoLayout->setColumnStretch(4, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    42
    infoLayout->setRowStretch(0, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    43
    infoLayout->setRowStretch(1, 1);
9219
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    44
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    45
    // set this as default image first time page is created, this will change in hwform.cpp
9306
c9978ada9a3d changed mission dir name to use underscores instead of whitespaces
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9219
diff changeset
    46
    btnPreview = formattedButton(":/res/campaign/A_Classic_Fairytale/first_blood.png", true);
12240
88b31fdc760b Add a few WhatsThis texts in frontend, rename “Stereo rendering” to “Stereoscopy”
Wuzzy <almikes@aol.com>
parents: 12236
diff changeset
    47
    btnPreview->setWhatsThis(tr("Start fighting"));
9219
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    48
    infoLayout->setAlignment(btnPreview, Qt::AlignHCenter | Qt::AlignVCenter);
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    49
10248
7b9b44a051f8 Fix some of issues found by coverity
unc0rr
parents: 10108
diff changeset
    50
    lbldescription = new QLabel(this);
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    51
    lbldescription->setAlignment(Qt::AlignHCenter| Qt::AlignTop);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    52
    lbldescription->setWordWrap(true);
9219
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    53
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    54
    lbltitle = new QLabel();
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    55
    lbltitle->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    56
11979
188dc80fafa5 Remove colons in campaign screen for more UI consistency
Wuzzy <almikes@aol.com>
parents: 11953
diff changeset
    57
    QLabel* lblteam = new QLabel(tr("Team"));
188dc80fafa5 Remove colons in campaign screen for more UI consistency
Wuzzy <almikes@aol.com>
parents: 11953
diff changeset
    58
    QLabel* lblcampaign = new QLabel(tr("Campaign"));
188dc80fafa5 Remove colons in campaign screen for more UI consistency
Wuzzy <almikes@aol.com>
parents: 11953
diff changeset
    59
    QLabel* lblmission = new QLabel(tr("Mission"));
11953
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    60
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    61
    CBTeam = new QComboBox(this);
7201
dc17ffdf0702 The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents: 6952
diff changeset
    62
    CBMission = new QComboBox(this);
dc17ffdf0702 The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents: 6952
diff changeset
    63
    CBCampaign = new QComboBox(this);
11674
d59b6f289e30 Increase size of many drop-down lists
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    64
    CBTeam->setMaxVisibleItems(30);
d59b6f289e30 Increase size of many drop-down lists
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    65
    CBMission->setMaxVisibleItems(30);
d59b6f289e30 Increase size of many drop-down lists
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    66
    CBCampaign->setMaxVisibleItems(30);
9219
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    67
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    68
    infoLayout->addWidget(btnPreview,0,1,2,1);
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    69
    infoLayout->addWidget(lbltitle,0,2,1,2);
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    70
    infoLayout->addWidget(lbldescription,1,2,1,2);
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    71
11953
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    72
    pageLayout->addLayout(infoLayout, 0, 0, 2, 4);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    73
    pageLayout->addWidget(lblteam, 2, 1);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    74
    pageLayout->addWidget(lblcampaign, 3, 1);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    75
    pageLayout->addWidget(lblmission, 4, 1);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    76
    pageLayout->addWidget(CBTeam, 2, 2);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    77
    pageLayout->addWidget(CBCampaign, 3, 2);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    78
    pageLayout->addWidget(CBMission, 4, 2);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    79
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    80
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
    81
    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
    82
}
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5204
diff changeset
    83
11953
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    84
QLayout * PageCampaign::footerLayoutDefinition()
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    85
{
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    86
    QHBoxLayout * footerLayout = new QHBoxLayout();
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    87
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    88
    const QIcon& lp = QIcon(":/res/Start.png");
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    89
    QSize sz = lp.actualSize(QSize(65535, 65535));
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    90
    BtnStartCampaign = new QPushButton();
12240
88b31fdc760b Add a few WhatsThis texts in frontend, rename “Stereo rendering” to “Stereoscopy”
Wuzzy <almikes@aol.com>
parents: 12236
diff changeset
    91
    BtnStartCampaign->setWhatsThis(tr("Start fighting"));
12236
a0ed4caa6d35 Apply minimal padding to all text buttons in frontend
Wuzzy <almikes@aol.com>
parents: 11979
diff changeset
    92
    BtnStartCampaign->setStyleSheet("padding: 5px 10px");
11953
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    93
    BtnStartCampaign->setText(QPushButton::tr("Start"));
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    94
    BtnStartCampaign->setMinimumWidth(sz.width() + 60);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    95
    BtnStartCampaign->setIcon(lp);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    96
    BtnStartCampaign->setFixedHeight(50);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    97
    BtnStartCampaign->setIconSize(sz);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    98
    BtnStartCampaign->setFlat(true);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    99
    BtnStartCampaign->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   100
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   101
    footerLayout->addStretch();
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   102
    footerLayout->addWidget(BtnStartCampaign);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   103
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   104
    return footerLayout;
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   105
}
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   106
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
   107
PageCampaign::PageCampaign(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
   108
{
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
    initPage();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   110
}
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   111
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