QTfrontend/ui/page/pagegamestats.cpp
author unc0rr
Sun, 14 Oct 2018 23:17:47 +0200
changeset 13922 a83ba9ba1566
parent 13773 c084bd440009
child 14583 50f511588635
permissions -rw-r--r--
Start land2d library implementation: draw_line() method
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1621
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
     1
/*
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10393
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
1621
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
     4
 *
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
     8
 *
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    12
 * GNU General Public License for more details.
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    13
 *
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
d1ded2532d3f - svn maintenance
unc0rr
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: 10017
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1621
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    17
 */
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    18
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    19
#include <QLabel>
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    20
#include <QGridLayout>
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: 6015
diff changeset
    21
#include <QHBoxLayout>
1625
37aae47943ce Initial health graphic implementation
unc0rr
parents: 1623
diff changeset
    22
#include <QGraphicsScene>
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    23
#include <QGroupBox>
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    24
#include <QSizePolicy>
5205
78138ae93820 some headers cleanup and rename of stats and playrecord pages for consistency
koda
parents: 5028
diff changeset
    25
78138ae93820 some headers cleanup and rename of stats and playrecord pages for consistency
koda
parents: 5028
diff changeset
    26
#include "pagegamestats.h"
3381
f8800c44b3de Engine:
smxx
parents: 3236
diff changeset
    27
#include "team.h"
1621
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    28
1636
e528696f2177 Resize health graphic when form is resized
unc0rr
parents: 1625
diff changeset
    29
FitGraphicsView::FitGraphicsView(QWidget* parent) : QGraphicsView(parent)
e528696f2177 Resize health graphic when form is resized
unc0rr
parents: 1625
diff changeset
    30
{
e528696f2177 Resize health graphic when form is resized
unc0rr
parents: 1625
diff changeset
    31
e528696f2177 Resize health graphic when form is resized
unc0rr
parents: 1625
diff changeset
    32
}
e528696f2177 Resize health graphic when form is resized
unc0rr
parents: 1625
diff changeset
    33
e528696f2177 Resize health graphic when form is resized
unc0rr
parents: 1625
diff changeset
    34
void FitGraphicsView::resizeEvent(QResizeEvent * event)
e528696f2177 Resize health graphic when form is resized
unc0rr
parents: 1625
diff changeset
    35
{
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4217
diff changeset
    36
    Q_UNUSED(event);
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4217
diff changeset
    37
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    38
    fitInView(sceneRect());
1636
e528696f2177 Resize health graphic when form is resized
unc0rr
parents: 1625
diff changeset
    39
}
e528696f2177 Resize health graphic when form is resized
unc0rr
parents: 1625
diff changeset
    40
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: 6015
diff changeset
    41
QLayout * PageGameStats::bodyLayoutDefinition()
1621
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    42
{
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
    43
    kindOfPoints = QString("");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
    44
    defaultGraphTitle = true;
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: 6015
diff changeset
    45
    QGridLayout * pageLayout = new QGridLayout();
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    46
    pageLayout->setSpacing(20);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    47
    pageLayout->setColumnStretch(0, 1);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    48
    pageLayout->setColumnStretch(1, 1);
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
    49
    pageLayout->setRowStretch(0, 1);
9175
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
    50
    pageLayout->setRowStretch(1, 20);
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
    51
    //pageLayout->setRowStretch(1, -1); this should work but there is unnecessary empty space betwin lines if used
5916
c76212c34192 fix back button location in post-game stats screen
sheepluva
parents: 5734
diff changeset
    52
    pageLayout->setContentsMargins(7, 7, 7, 0);
c76212c34192 fix back button location in post-game stats screen
sheepluva
parents: 5734
diff changeset
    53
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    54
    QGroupBox * gb = new QGroupBox(this);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    55
    QVBoxLayout * gbl = new QVBoxLayout;
1621
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
    56
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    57
    // details
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    58
    labelGameStats = new QLabel(this);
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    59
    QLabel * l = new QLabel(this);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    60
    l->setTextFormat(Qt::RichText);
3815
8754f7874395 Frontend: improve statsPage (clean up translation strings)
TheXception
parents: 3788
diff changeset
    61
    l->setText("<h1><img src=\":/res/StatsD.png\"> " + PageGameStats::tr("Details") + "</h1>");
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    62
    l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    63
    labelGameStats->setTextFormat(Qt::RichText);
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    64
    labelGameStats->setAlignment(Qt::AlignTop);
5028
3c43f00b0743 This should fix http://code.google.com/p/hedgewars/issues/detail?id=153
shreyasbp@gmail.com
parents: 4976
diff changeset
    65
    labelGameStats->setWordWrap(true);
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    66
    gbl->addWidget(l);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    67
    gbl->addWidget(labelGameStats);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    68
    gb->setLayout(gbl);
9175
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
    69
    pageLayout->addWidget(gb, 1, 1);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    70
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    71
    // graph
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    72
    graphic = new FitGraphicsView(gb);
13236
6193503c4727 Various minor frontend CSS tweaks
Wuzzy <Wuzzy2@mail.ru>
parents: 13223
diff changeset
    73
    graphic->setObjectName("gameStatsView");
9175
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
    74
    labelGraphTitle = new QLabel(this);
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
    75
    labelGraphTitle->setTextFormat(Qt::RichText);
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
    76
    labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>");
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
    77
    labelGraphTitle->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
    78
    gbl->addWidget(labelGraphTitle);
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    79
    gbl->addWidget(graphic);
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    80
    graphic->scale(1.0, -1.0);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    81
    graphic->setBackgroundBrush(QBrush(Qt::black));
13163
99dd144f0a54 - Fix insane width of lines in health graphic
unc0rr
parents: 12479
diff changeset
    82
    graphic->setRenderHint(QPainter::Antialiasing, true);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    83
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    84
    labelGameWin = new QLabel(this);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    85
    labelGameWin->setTextFormat(Qt::RichText);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    86
    pageLayout->addWidget(labelGameWin, 0, 0, 1, 2);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    87
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    88
    // ranking box
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    89
    gb = new QGroupBox(this);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    90
    gbl = new QVBoxLayout;
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    91
    labelGameRank = new QLabel(gb);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    92
    l = new QLabel(this);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    93
    l->setTextFormat(Qt::RichText);
3815
8754f7874395 Frontend: improve statsPage (clean up translation strings)
TheXception
parents: 3788
diff changeset
    94
    l->setText("<h1><img src=\":/res/StatsR.png\"> " + PageGameStats::tr("Ranking") + "</h1>");
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    95
    l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    96
    gbl->addWidget(l);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    97
    gbl->addWidget(labelGameRank);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    98
    gb->setLayout(gbl);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
    99
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   100
    labelGameRank->setTextFormat(Qt::RichText);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   101
    labelGameRank->setAlignment(Qt::AlignTop);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   102
    pageLayout->addWidget(gb, 1, 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: 6015
diff changeset
   103
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: 6015
diff changeset
   104
    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: 6015
diff changeset
   105
}
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: 6015
diff changeset
   106
8901
505307b9735d implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents: 8384
diff changeset
   107
//TODO button placement, image etc
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: 6015
diff changeset
   108
QLayout * PageGameStats::footerLayoutDefinition()
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: 6015
diff changeset
   109
{
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6015
diff changeset
   110
    QHBoxLayout * bottomLayout = new QHBoxLayout();
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   111
9039
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   112
    mainNote = new QLabel(this);
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   113
    mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   114
    mainNote->setWordWrap(true);
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   115
9039
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   116
    bottomLayout->addWidget(mainNote, 0);
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   117
    bottomLayout->setStretch(0,1);
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: 6015
diff changeset
   118
9039
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   119
    btnRestart = addButton(":/res/Start.png", bottomLayout, 1, true);
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   120
    btnRestart->setWhatsThis(tr("Play again"));
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   121
    btnRestart->setFixedWidth(58);
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   122
    btnRestart->setFixedHeight(81);
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   123
    btnRestart->setStyleSheet("QPushButton{margin-top:24px}");
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   124
    btnSave = addButton(":/res/Save.png", bottomLayout, 2, true);
24e1ccd9326f place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents: 8901
diff changeset
   125
    btnSave->setWhatsThis(tr("Save"));
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: 6015
diff changeset
   126
    btnSave->setStyleSheet("QPushButton{margin: 24px 0 0 0;}");
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: 6015
diff changeset
   127
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: 6015
diff changeset
   128
    return bottomLayout;
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: 6015
diff changeset
   129
}
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: 6015
diff changeset
   130
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: 6015
diff changeset
   131
void PageGameStats::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: 6015
diff changeset
   132
{
8384
a6e7a95f3b2e GCI2012: Abstract Page Load
dag10
parents: 7842
diff changeset
   133
    connect(this, SIGNAL(pageEnter()), this, SLOT(renderStats()));
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: 6015
diff changeset
   134
    connect(btnSave, SIGNAL(clicked()), this, SIGNAL(saveDemoRequested()));
8901
505307b9735d implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents: 8384
diff changeset
   135
    connect(btnRestart, SIGNAL(clicked()), this, SIGNAL(restartGameRequested()));
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: 6015
diff changeset
   136
}
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: 6015
diff changeset
   137
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: 6015
diff changeset
   138
PageGameStats::PageGameStats(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: 6015
diff changeset
   139
{
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: 6015
diff changeset
   140
    initPage();
1621
d1ded2532d3f - svn maintenance
unc0rr
parents:
diff changeset
   141
}
1622
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   142
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   143
void PageGameStats::AddStatText(const QString & msg)
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   144
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   145
    labelGameStats->setText(labelGameStats->text() + msg);
1622
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   146
}
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   147
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   148
void PageGameStats::clear()
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   149
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   150
    labelGameStats->setText("");
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   151
    healthPoints.clear();
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   152
    labelGameRank->setText("");
12336
6707ee1d2430 Fix caption of stats screen not being reset on clear()
Wuzzy <almikes@aol.com>
parents: 11046
diff changeset
   153
    labelGameWin->setText("");
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   154
    playerPosition = 0;
13762
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   155
    scriptPlayerPosition = 0;
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   156
    lastColor = 0;
1625
37aae47943ce Initial health graphic implementation
unc0rr
parents: 1623
diff changeset
   157
}
37aae47943ce Initial health graphic implementation
unc0rr
parents: 1623
diff changeset
   158
8901
505307b9735d implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents: 8384
diff changeset
   159
void PageGameStats::restartBtnVisible(bool visible)
505307b9735d implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents: 8384
diff changeset
   160
{
505307b9735d implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents: 8384
diff changeset
   161
    btnRestart->setVisible(visible);
505307b9735d implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents: 8384
diff changeset
   162
}
505307b9735d implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents: 8384
diff changeset
   163
1625
37aae47943ce Initial health graphic implementation
unc0rr
parents: 1623
diff changeset
   164
void PageGameStats::renderStats()
37aae47943ce Initial health graphic implementation
unc0rr
parents: 1623
diff changeset
   165
{
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   166
    if(defaultGraphTitle) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   167
        labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   168
    } else {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   169
        defaultGraphTitle = true;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   170
    }
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   171
    // if not health data sent
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   172
    if(healthPoints.size() == 0) {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   173
        labelGraphTitle->hide();
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   174
        graphic->hide();
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   175
    } else {
13163
99dd144f0a54 - Fix insane width of lines in health graphic
unc0rr
parents: 12479
diff changeset
   176
        graphic->setScene(Q_NULLPTR);
99dd144f0a54 - Fix insane width of lines in health graphic
unc0rr
parents: 12479
diff changeset
   177
        m_scene.reset(new QGraphicsScene(this));
1625
37aae47943ce Initial health graphic implementation
unc0rr
parents: 1623
diff changeset
   178
13223
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   179
        // min and max value across the entire chart
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   180
        qint32 minValue = 0;
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   181
        qint32 maxValue = 0;
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   182
        bool minMaxValuesInitialized = false;
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   183
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   184
        // max data points per clan
13222
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   185
        int maxDataPoints = 0;
13223
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   186
        for(QMap<qint32, QVector<qint32> >::const_iterator i = healthPoints.constBegin(); i != healthPoints.constEnd(); ++i)
13191
07c93d864bc2 Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior
unc0rr
parents: 13163
diff changeset
   187
        {
13222
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   188
            maxDataPoints = qMax(maxDataPoints, i.value().size());
13191
07c93d864bc2 Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior
unc0rr
parents: 13163
diff changeset
   189
        }
07c93d864bc2 Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior
unc0rr
parents: 13163
diff changeset
   190
13222
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   191
        /* There must be at least 2 data points for any clan,
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   192
           otherwise there's not much to look at. ;-) */
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   193
        if(maxDataPoints < 2) {
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   194
            labelGraphTitle->hide();
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   195
            graphic->hide();
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   196
            return;
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   197
        }
13191
07c93d864bc2 Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior
unc0rr
parents: 13163
diff changeset
   198
13223
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   199
        QMap<qint32, QVector<qint32> >::const_iterator i = healthPoints.constBegin();
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   200
        while (i != healthPoints.constEnd())
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   201
        {
13223
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   202
            qint32 c = i.key();
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   203
            const QVector<qint32>& hps = i.value();
2377
f3fab2b09e0c And in frontend
nemo
parents: 1904
diff changeset
   204
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   205
            QPainterPath path;
13222
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   206
13223
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   207
            if (hps.size()) {
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   208
                path.moveTo(0, hps[0]);
13223
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   209
                if(minMaxValuesInitialized) {
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   210
                    minValue = qMin(minValue, hps[0]);
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   211
                    maxValue = qMax(maxValue, hps[0]);
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   212
                } else {
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   213
                    minValue = hps[0];
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   214
                    maxValue = hps[0];
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   215
                    minMaxValuesInitialized = true;
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   216
                }
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   217
            }
1625
37aae47943ce Initial health graphic implementation
unc0rr
parents: 1623
diff changeset
   218
13222
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   219
            for(int t = 0; t < hps.size(); ++t) {
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   220
                path.lineTo(t, hps[t]);
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   221
                maxValue = qMax(maxValue, hps[t]);
13223
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   222
                minValue = qMin(minValue, hps[t]);
13222
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   223
            }
1625
37aae47943ce Initial health graphic implementation
unc0rr
parents: 1623
diff changeset
   224
13163
99dd144f0a54 - Fix insane width of lines in health graphic
unc0rr
parents: 12479
diff changeset
   225
            QPen pen(c);
99dd144f0a54 - Fix insane width of lines in health graphic
unc0rr
parents: 12479
diff changeset
   226
            pen.setWidth(2);
99dd144f0a54 - Fix insane width of lines in health graphic
unc0rr
parents: 12479
diff changeset
   227
            pen.setCosmetic(true);
99dd144f0a54 - Fix insane width of lines in health graphic
unc0rr
parents: 12479
diff changeset
   228
99dd144f0a54 - Fix insane width of lines in health graphic
unc0rr
parents: 12479
diff changeset
   229
            m_scene->addPath(path, pen);
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   230
            ++i;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   231
        }
9175
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
   232
13163
99dd144f0a54 - Fix insane width of lines in health graphic
unc0rr
parents: 12479
diff changeset
   233
        graphic->setScene(m_scene.data());
13223
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   234
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   235
        // Calculate the bounding box of the final chart
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   236
        qint32 sceneMinY = minValue;
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   237
        qint32 sceneMaxY = maxValue;
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   238
        // If all values are 0 or greater, make sure to include 0 at the bottom.
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   239
        if(sceneMinY >= 0 && sceneMaxY >= 0)
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   240
            sceneMinY = 0;
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   241
        // If all values are equal, we must increase sceneMaxY, otherwise the scene rect
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   242
        // would have a height of 0 and will screw up
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   243
        if(sceneMinY == sceneMaxY)
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   244
            sceneMaxY++;
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   245
        graphic->setSceneRect(0, sceneMinY, maxDataPoints-1, sceneMaxY - sceneMinY);
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   246
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   247
        graphic->fitInView(graphic->sceneRect());
13222
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   248
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   249
        graphic->show();
1357dfbfa29c Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents: 13191
diff changeset
   250
        labelGraphTitle->show();
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   251
    }
1622
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   252
}
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   253
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   254
void PageGameStats::GameStats(char type, const QString & info)
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   255
{
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   256
    switch(type)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   257
    {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   258
        case 'r' :
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   259
        {
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   260
            labelGameWin->setText(QString("<h1 align=\"center\">%1</h1>").arg(info));
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   261
            break;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   262
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   263
        case 'D' :
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   264
        {
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   265
            int i = info.indexOf(' ');
10393
c3daae6fd723 Fix issue 813
unc0rr
parents: 10108
diff changeset
   266
            int num = info.left(i).toInt();
c3daae6fd723 Fix issue 813
unc0rr
parents: 10108
diff changeset
   267
            QString message = "<p><img src=\":/res/StatsBestShot.png\"> " + PageGameStats::tr("The best shot award was won by <b>%1</b> with <b>%2</b> pts.", "", num).arg(info.mid(i + 1), info.left(i)) + "</p>";
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   268
            AddStatText(message);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   269
            break;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   270
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   271
        case 'k' :
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   272
        {
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   273
            int i = info.indexOf(' ');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   274
            int num = info.left(i).toInt();
3815
8754f7874395 Frontend: improve statsPage (clean up translation strings)
TheXception
parents: 3788
diff changeset
   275
            QString message = "<p><img src=\":/res/StatsBestKiller.png\"> " + PageGameStats::tr("The best killer is <b>%1</b> with <b>%2</b> kills in a turn.", "", num).arg(info.mid(i + 1), info.left(i)) + "</p>";
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   276
            AddStatText(message);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   277
            break;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   278
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   279
        case 'K' :
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   280
        {
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   281
            int num = info.toInt();
3815
8754f7874395 Frontend: improve statsPage (clean up translation strings)
TheXception
parents: 3788
diff changeset
   282
            QString message = "<p><img src=\":/res/StatsHedgehogsKilled.png\"> " +  PageGameStats::tr("A total of <b>%1</b> hedgehog(s) were killed during this round.", "", num).arg(num) + "</p>";
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   283
            AddStatText(message);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   284
            break;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   285
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   286
        case 'H' :
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   287
        {
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   288
            int i = info.indexOf(' ');
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   289
            quint32 clan = info.left(i).toInt();
13223
d0647647a697 Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 13222
diff changeset
   290
            qint32 hp = info.mid(i + 1).toInt();
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   291
            healthPoints[clan].append(hp);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   292
            break;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   293
        }
9175
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
   294
        case 'g' :
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
   295
        {
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   296
            // TODO: change default picture or add change pic capability
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   297
            defaultGraphTitle = false;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   298
            labelGraphTitle->setText("<br><h1><img src=\":/res/StatsR.png\"> " + info + "</h1>");
9175
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
   299
            break;
dc3c0e44f7f3 added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9172
diff changeset
   300
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   301
        case 'T':   // local team stats
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   302
        {
13713
3264a26bbf8b Remove frontend code dealing with unused team variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13236
diff changeset
   303
            // unused
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   304
            break;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   305
        }
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   306
        case 'p' :
9178
c0902317c823 created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9177
diff changeset
   307
        {
c0902317c823 created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9177
diff changeset
   308
            kindOfPoints = info;
c0902317c823 created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9177
diff changeset
   309
            break;
c0902317c823 created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9177
diff changeset
   310
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   311
        case 'P' :
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   312
        {
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   313
            int i = info.indexOf(' ');
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   314
            playerPosition++;
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   315
            QString color = info.left(i);
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   316
            quint32 c = color.toInt();
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   317
            QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255));
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   318
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   319
            QString playerinfo = info.mid(i + 1);
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   320
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   321
            i = playerinfo.indexOf(' ');
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   322
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   323
            int kills = playerinfo.left(i).toInt();
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   324
            QString playername = playerinfo.mid(i + 1);
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   325
            QString image;
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   326
4217
721bfa5f4f31 Fix wrong order in results screen when players team up
TheException
parents: 4192
diff changeset
   327
            if (lastColor == c) playerPosition--;
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   328
            lastColor = c;
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   329
13762
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   330
            unsigned int realPlayerPosition;
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   331
            if(scriptPlayerPosition == 0)
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   332
                realPlayerPosition = playerPosition;
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   333
            else
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   334
                realPlayerPosition = scriptPlayerPosition;
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   335
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   336
            switch (realPlayerPosition)
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   337
            {
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   338
                case 1:
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   339
                    image = "<img src=\":/res/StatsMedal1.png\">";
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   340
                    break;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   341
                case 2:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   342
                    image = "<img src=\":/res/StatsMedal2.png\">";
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   343
                    break;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   344
                case 3:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   345
                    image = "<img src=\":/res/StatsMedal3.png\">";
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   346
                    break;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   347
                default:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   348
                    image = "<img src=\":/res/StatsMedal4.png\">";
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   349
                    break;
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   350
            }
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   351
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   352
            QString message;
9178
c0902317c823 created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9177
diff changeset
   353
            QString killstring;
c0902317c823 created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9177
diff changeset
   354
            if(kindOfPoints.compare("") == 0) {
12479
42da9d8d82ab Provide translator context for a few less obvious engine strings
Wuzzy <almikes@aol.com>
parents: 12449
diff changeset
   355
                //: Number of kills in stats screen, written after the team name
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   356
                killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   357
            } else {
12479
42da9d8d82ab Provide translator context for a few less obvious engine strings
Wuzzy <almikes@aol.com>
parents: 12449
diff changeset
   358
                //: For custom number of points in the stats screen, written after the team name. %1 is the number, %2 is the word. Example: “4 points”
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   359
                killstring = PageGameStats::tr("(%1 %2)", "", kills).arg(kills).arg(kindOfPoints);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   360
                kindOfPoints = QString("");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 9998
diff changeset
   361
            }
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   362
13762
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   363
            message = QString("<p><h2>%1 %2. <font color=\"%4\">%3</font> ").arg(image, QString::number(realPlayerPosition), playername, clanColor.name()) + killstring + "</h2></p>";
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   364
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   365
            labelGameRank->setText(labelGameRank->text() + message);
13762
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   366
            scriptPlayerPosition = 0;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   367
            break;
4176
4e3942f5827c Fix i18n of plural forms
unc0rr
parents: 3815
diff changeset
   368
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   369
        case 's' :
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   370
        {
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   371
            int i = info.indexOf(' ');
4177
6acd599eee52 Fix some more messages
unc0rr
parents: 4176
diff changeset
   372
            int num = info.left(i).toInt();
12449
832b969ea00c while we're tweaking this phrase, "with" feels awkward
nemo
parents: 12446
diff changeset
   373
            QString message = "<p><img src=\":/res/StatsMostSelfDamage.png\"> " + PageGameStats::tr("<b>%1</b> thought it's good to shoot their own hedgehogs for <b>%2</b> pts.", "", num).arg(info.mid(i + 1)).arg(num) + "</p>";
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   374
            AddStatText(message);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   375
            break;
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   376
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   377
        case 'S' :
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   378
        {
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   379
            int i = info.indexOf(' ');
4177
6acd599eee52 Fix some more messages
unc0rr
parents: 4176
diff changeset
   380
            int num = info.left(i).toInt();
12446
fdaafc48dce4 use gender neutral language
Worldblender
parents: 12336
diff changeset
   381
            QString message = "<p><img src=\":/res/StatsSelfKilled.png\"> " + PageGameStats::tr("<b>%1</b> killed <b>%2</b> of their own hedgehogs.", "", num).arg(info.mid(i + 1)).arg(num) + "</p>";
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   382
            AddStatText(message);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   383
            break;
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   384
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   385
        case 'B' :
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
   386
        {
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   387
            int i = info.indexOf(' ');
4177
6acd599eee52 Fix some more messages
unc0rr
parents: 4176
diff changeset
   388
            int num = info.left(i).toInt();
4192
67e1a683e9b3 Fix stats messages
unc0rr
parents: 4177
diff changeset
   389
            QString message = "<p><img src=\":/res/StatsSkipped.png\"> " + PageGameStats::tr("<b>%1</b> was scared and skipped turn <b>%2</b> times.", "", num).arg(info.mid(i + 1)).arg(num) + "</p>";
3788
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   390
            AddStatText(message);
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   391
            break;
9aa8a832e296 adds prettier after-game statistics page with more stats
TheXception
parents: 3381
diff changeset
   392
        }
9172
72bfa6a3e8e2 added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
   393
        case 'c' :
72bfa6a3e8e2 added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
   394
        {
72bfa6a3e8e2 added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
   395
            QString message = "<p><img src=\":/res/StatsCustomAchievement.png\"> "+info+" </p>";
72bfa6a3e8e2 added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
   396
            AddStatText(message);
72bfa6a3e8e2 added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
   397
            break;
72bfa6a3e8e2 added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents: 9080
diff changeset
   398
        }
13762
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   399
        case 'R' :
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   400
        {
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   401
            scriptPlayerPosition = info.toInt();
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   402
            break;
f0cb47f0bfaf Fix player rankings on round draw: Clans that die in the same turn now have the same rank
Wuzzy <Wuzzy2@mail.ru>
parents: 13713
diff changeset
   403
        }
13773
c084bd440009 Add funny message in stats screen when everyone wins
Wuzzy <Wuzzy2@mail.ru>
parents: 13762
diff changeset
   404
        case 'h' :
c084bd440009 Add funny message in stats screen when everyone wins
Wuzzy <Wuzzy2@mail.ru>
parents: 13762
diff changeset
   405
        {
c084bd440009 Add funny message in stats screen when everyone wins
Wuzzy <Wuzzy2@mail.ru>
parents: 13762
diff changeset
   406
            QString message = "<p><img src=\":/res/StatsEverAfter.png\"> " + PageGameStats::tr("With everyone having the same clan color, there was no reason to fight. And so the hedgehogs happily lived in peace ever after.") + "</p>";
c084bd440009 Add funny message in stats screen when everyone wins
Wuzzy <Wuzzy2@mail.ru>
parents: 13762
diff changeset
   407
            AddStatText(message);
c084bd440009 Add funny message in stats screen when everyone wins
Wuzzy <Wuzzy2@mail.ru>
parents: 13762
diff changeset
   408
            break;
c084bd440009 Add funny message in stats screen when everyone wins
Wuzzy <Wuzzy2@mail.ru>
parents: 13762
diff changeset
   409
        }
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
   410
    }
1622
8e0d62727f01 Fully separate statistics code from main form code
unc0rr
parents: 1621
diff changeset
   411
}