QTfrontend/ui/page/pagecampaign.cpp
author Wuzzy <Wuzzy2@mail.ru>
Thu, 16 May 2019 21:49:33 +0200
changeset 14978 fe8b4f2da9aa
parent 13811 e3fee73c51a0
permissions -rw-r--r--
CTF_Blizzard: Display scores in stats screen
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
13632
4c49a4944884 Fix hard-to-read text on campaign and training page in frontend at October 31
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
    36
    QWidget * infoWidget = new QWidget();
4c49a4944884 Fix hard-to-read text on campaign and training page in frontend at October 31
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
    37
    infoWidget->setObjectName("campaignInfo");
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    38
    QGridLayout * infoLayout = new QGridLayout();
13632
4c49a4944884 Fix hard-to-read text on campaign and training page in frontend at October 31
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
    39
    infoWidget->setLayout(infoLayout);
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    40
    infoLayout->setColumnStretch(0, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    41
    infoLayout->setColumnStretch(1, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    42
    infoLayout->setColumnStretch(2, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    43
    infoLayout->setColumnStretch(3, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    44
    infoLayout->setColumnStretch(4, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    45
    infoLayout->setRowStretch(0, 1);
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    46
    infoLayout->setRowStretch(1, 1);
9219
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    47
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    48
    // set this as default image first time page is created, this will change in hwform.cpp
13811
e3fee73c51a0 Move campaign mission images to share/ instead of hardcoding them into frontend
Wuzzy <Wuzzy2@mail.ru>
parents: 13632
diff changeset
    49
    btnPreview = formattedButton("physfs://Graphics/Missions/Campaign/A_Classic_Fairytale/first_blood@2x.png", true);
12240
88b31fdc760b Add a few WhatsThis texts in frontend, rename “Stereo rendering” to “Stereoscopy”
Wuzzy <almikes@aol.com>
parents: 12236
diff changeset
    50
    btnPreview->setWhatsThis(tr("Start fighting"));
9219
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    51
    infoLayout->setAlignment(btnPreview, Qt::AlignHCenter | Qt::AlignVCenter);
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    52
10248
7b9b44a051f8 Fix some of issues found by coverity
unc0rr
parents: 10108
diff changeset
    53
    lbldescription = new QLabel(this);
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    54
    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
    55
    lbldescription->setWordWrap(true);
9219
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    56
9182
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    57
    lbltitle = new QLabel();
f92e205bc167 issue 562, image and description for the campaign page
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
    58
    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
    59
11979
188dc80fafa5 Remove colons in campaign screen for more UI consistency
Wuzzy <almikes@aol.com>
parents: 11953
diff changeset
    60
    QLabel* lblteam = new QLabel(tr("Team"));
188dc80fafa5 Remove colons in campaign screen for more UI consistency
Wuzzy <almikes@aol.com>
parents: 11953
diff changeset
    61
    QLabel* lblcampaign = new QLabel(tr("Campaign"));
188dc80fafa5 Remove colons in campaign screen for more UI consistency
Wuzzy <almikes@aol.com>
parents: 11953
diff changeset
    62
    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
    63
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    64
    CBTeam = new QComboBox(this);
7201
dc17ffdf0702 The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents: 6952
diff changeset
    65
    CBMission = new QComboBox(this);
dc17ffdf0702 The first campaign commit with a lot of changes...
belphegorr <szabibibi@gmail.com>
parents: 6952
diff changeset
    66
    CBCampaign = new QComboBox(this);
11674
d59b6f289e30 Increase size of many drop-down lists
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    67
    CBTeam->setMaxVisibleItems(30);
d59b6f289e30 Increase size of many drop-down lists
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    68
    CBMission->setMaxVisibleItems(30);
d59b6f289e30 Increase size of many drop-down lists
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
    69
    CBCampaign->setMaxVisibleItems(30);
9219
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    70
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    71
    infoLayout->addWidget(btnPreview,0,1,2,1);
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    72
    infoLayout->addWidget(lbltitle,0,2,1,2);
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    73
    infoLayout->addWidget(lbldescription,1,2,1,2);
0a4b6bb69f99 bring windows fixes from main repo
koda
parents: 9182
diff changeset
    74
13632
4c49a4944884 Fix hard-to-read text on campaign and training page in frontend at October 31
Wuzzy <Wuzzy2@mail.ru>
parents: 12240
diff changeset
    75
    pageLayout->addWidget(infoWidget, 0, 0, 2, 4);
11953
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    76
    pageLayout->addWidget(lblteam, 2, 1);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    77
    pageLayout->addWidget(lblcampaign, 3, 1);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    78
    pageLayout->addWidget(lblmission, 4, 1);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    79
    pageLayout->addWidget(CBTeam, 2, 2);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    80
    pageLayout->addWidget(CBCampaign, 3, 2);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    81
    pageLayout->addWidget(CBMission, 4, 2);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    82
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    83
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
    84
    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
    85
}
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5204
diff changeset
    86
11953
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    87
QLayout * PageCampaign::footerLayoutDefinition()
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    88
{
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    89
    QHBoxLayout * footerLayout = new QHBoxLayout();
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    90
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    91
    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
    92
    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
    93
    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
    94
    BtnStartCampaign->setWhatsThis(tr("Start fighting"));
12236
a0ed4caa6d35 Apply minimal padding to all text buttons in frontend
Wuzzy <almikes@aol.com>
parents: 11979
diff changeset
    95
    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
    96
    BtnStartCampaign->setText(QPushButton::tr("Start"));
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    97
    BtnStartCampaign->setMinimumWidth(sz.width() + 60);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    98
    BtnStartCampaign->setIcon(lp);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
    99
    BtnStartCampaign->setFixedHeight(50);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   100
    BtnStartCampaign->setIconSize(sz);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   101
    BtnStartCampaign->setFlat(true);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   102
    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
   103
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   104
    footerLayout->addStretch();
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   105
    footerLayout->addWidget(BtnStartCampaign);
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   106
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   107
    return footerLayout;
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   108
}
c8457c7f10f4 Campaign page: Add labels and move start button to footer
Wuzzy <almikes@aol.com>
parents: 11674
diff changeset
   109
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
   110
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
   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
    initPage();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   113
}
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
   114
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