author | Wuzzy <Wuzzy2@mail.ru> |
Thu, 15 Mar 2018 15:34:29 +0100 | |
changeset 13218 | d0647647a697 |
parent 13217 | 1357dfbfa29c |
child 13231 | 6193503c4727 |
permissions | -rw-r--r-- |
1621 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
1621 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
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 | 17 |
*/ |
18 |
||
19 |
#include <QLabel> |
|
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 | 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 | 27 |
#include "team.h" |
1621 | 28 |
|
1636 | 29 |
FitGraphicsView::FitGraphicsView(QWidget* parent) : QGraphicsView(parent) |
30 |
{ |
|
31 |
||
32 |
} |
|
33 |
||
34 |
void FitGraphicsView::resizeEvent(QResizeEvent * event) |
|
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 | 39 |
} |
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 | 42 |
{ |
10017 | 43 |
kindOfPoints = QString(""); |
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 | 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 | 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); |
9175
dc3c0e44f7f3
added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9172
diff
changeset
|
73 |
labelGraphTitle = new QLabel(this); |
dc3c0e44f7f3
added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9172
diff
changeset
|
74 |
labelGraphTitle->setTextFormat(Qt::RichText); |
dc3c0e44f7f3
added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9172
diff
changeset
|
75 |
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
|
76 |
labelGraphTitle->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
dc3c0e44f7f3
added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9172
diff
changeset
|
77 |
gbl->addWidget(labelGraphTitle); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
78 |
gbl->addWidget(graphic); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
79 |
graphic->scale(1.0, -1.0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
80 |
graphic->setBackgroundBrush(QBrush(Qt::black)); |
13158 | 81 |
graphic->setRenderHint(QPainter::Antialiasing, true); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
82 |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
83 |
labelGameWin = new QLabel(this); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
84 |
labelGameWin->setTextFormat(Qt::RichText); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
85 |
pageLayout->addWidget(labelGameWin, 0, 0, 1, 2); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
86 |
|
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
87 |
// ranking box |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
88 |
gb = new QGroupBox(this); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
89 |
gbl = new QVBoxLayout; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
90 |
labelGameRank = new QLabel(gb); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
91 |
l = new QLabel(this); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
92 |
l->setTextFormat(Qt::RichText); |
3815
8754f7874395
Frontend: improve statsPage (clean up translation strings)
TheXception
parents:
3788
diff
changeset
|
93 |
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
|
94 |
l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
95 |
gbl->addWidget(l); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
96 |
gbl->addWidget(labelGameRank); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
97 |
gb->setLayout(gbl); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
98 |
|
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
99 |
labelGameRank->setTextFormat(Qt::RichText); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
100 |
labelGameRank->setAlignment(Qt::AlignTop); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
101 |
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
|
102 |
|
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 |
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
|
104 |
} |
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 |
|
8901
505307b9735d
implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents:
8384
diff
changeset
|
106 |
//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
|
107 |
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
|
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:
6015
diff
changeset
|
109 |
QHBoxLayout * bottomLayout = new QHBoxLayout(); |
10017 | 110 |
|
9039
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
111 |
mainNote = new QLabel(this); |
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
112 |
mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); |
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
113 |
mainNote->setWordWrap(true); |
10017 | 114 |
|
9039
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
115 |
bottomLayout->addWidget(mainNote, 0); |
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
116 |
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
|
117 |
|
9039
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
118 |
btnRestart = addButton(":/res/Start.png", bottomLayout, 1, true); |
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
119 |
btnRestart->setWhatsThis(tr("Play again")); |
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
120 |
btnRestart->setFixedWidth(58); |
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
121 |
btnRestart->setFixedHeight(81); |
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
122 |
btnRestart->setStyleSheet("QPushButton{margin-top:24px}"); |
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
123 |
btnSave = addButton(":/res/Save.png", bottomLayout, 2, true); |
24e1ccd9326f
place better the current replay button
Periklis Ntanasis <pntanasis@gmail.com>
parents:
8901
diff
changeset
|
124 |
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
|
125 |
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
|
126 |
|
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 |
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
|
128 |
} |
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 |
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
|
131 |
{ |
8384 | 132 |
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
|
133 |
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
|
134 |
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
|
135 |
} |
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 |
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
|
138 |
{ |
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 |
initPage(); |
1621 | 140 |
} |
1622 | 141 |
|
142 |
void PageGameStats::AddStatText(const QString & msg) |
|
143 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
144 |
labelGameStats->setText(labelGameStats->text() + msg); |
1622 | 145 |
} |
146 |
||
147 |
void PageGameStats::clear() |
|
148 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
149 |
labelGameStats->setText(""); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
150 |
healthPoints.clear(); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
151 |
labelGameRank->setText(""); |
12331
6707ee1d2430
Fix caption of stats screen not being reset on clear()
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
152 |
labelGameWin->setText(""); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
153 |
playerPosition = 0; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
154 |
lastColor = 0; |
1625 | 155 |
} |
156 |
||
8901
505307b9735d
implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents:
8384
diff
changeset
|
157 |
void PageGameStats::restartBtnVisible(bool visible) |
505307b9735d
implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents:
8384
diff
changeset
|
158 |
{ |
505307b9735d
implementation of a restart-game button. location and appearance is not final :P
thunderstruck
parents:
8384
diff
changeset
|
159 |
btnRestart->setVisible(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 |
|
1625 | 162 |
void PageGameStats::renderStats() |
163 |
{ |
|
10017 | 164 |
if(defaultGraphTitle) { |
165 |
labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>"); |
|
166 |
} else { |
|
167 |
defaultGraphTitle = true; |
|
168 |
} |
|
169 |
// if not health data sent |
|
170 |
if(healthPoints.size() == 0) { |
|
171 |
labelGraphTitle->hide(); |
|
172 |
graphic->hide(); |
|
173 |
} else { |
|
13158 | 174 |
graphic->setScene(Q_NULLPTR); |
175 |
m_scene.reset(new QGraphicsScene(this)); |
|
1625 | 176 |
|
13218
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
177 |
// 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:
13217
diff
changeset
|
178 |
qint32 minValue = 0; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
179 |
qint32 maxValue = 0; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
180 |
bool minMaxValuesInitialized = false; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
181 |
|
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
182 |
// max data points per clan |
13217
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
183 |
int maxDataPoints = 0; |
13218
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
184 |
for(QMap<qint32, QVector<qint32> >::const_iterator i = healthPoints.constBegin(); i != healthPoints.constEnd(); ++i) |
13186
07c93d864bc2
Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior
unc0rr
parents:
13158
diff
changeset
|
185 |
{ |
13217
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
186 |
maxDataPoints = qMax(maxDataPoints, i.value().size()); |
13186
07c93d864bc2
Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior
unc0rr
parents:
13158
diff
changeset
|
187 |
} |
07c93d864bc2
Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior
unc0rr
parents:
13158
diff
changeset
|
188 |
|
13217
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
189 |
/* There must be at least 2 data points for any clan, |
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
190 |
otherwise there's not much to look at. ;-) */ |
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
191 |
if(maxDataPoints < 2) { |
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
192 |
labelGraphTitle->hide(); |
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
193 |
graphic->hide(); |
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
194 |
return; |
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
195 |
} |
13186
07c93d864bc2
Workaround for the weird new qgraphicsview/qgraphicsscene fitInView behavior
unc0rr
parents:
13158
diff
changeset
|
196 |
|
13218
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
197 |
QMap<qint32, QVector<qint32> >::const_iterator i = healthPoints.constBegin(); |
10017 | 198 |
while (i != healthPoints.constEnd()) |
199 |
{ |
|
13218
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
200 |
qint32 c = i.key(); |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
201 |
const QVector<qint32>& hps = i.value(); |
2377 | 202 |
|
10017 | 203 |
QPainterPath path; |
13217
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
204 |
|
13218
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
205 |
if (hps.size()) { |
10017 | 206 |
path.moveTo(0, hps[0]); |
13218
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
207 |
if(minMaxValuesInitialized) { |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
208 |
minValue = qMin(minValue, hps[0]); |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
209 |
maxValue = qMax(maxValue, hps[0]); |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
210 |
} else { |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
211 |
minValue = hps[0]; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
212 |
maxValue = hps[0]; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
213 |
minMaxValuesInitialized = true; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
214 |
} |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
215 |
} |
1625 | 216 |
|
13217
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
217 |
for(int t = 0; t < hps.size(); ++t) { |
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
218 |
path.lineTo(t, hps[t]); |
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
219 |
maxValue = qMax(maxValue, hps[t]); |
13218
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
220 |
minValue = qMin(minValue, hps[t]); |
13217
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
221 |
} |
1625 | 222 |
|
13158 | 223 |
QPen pen(c); |
224 |
pen.setWidth(2); |
|
225 |
pen.setCosmetic(true); |
|
226 |
||
227 |
m_scene->addPath(path, pen); |
|
10017 | 228 |
++i; |
229 |
} |
|
9175
dc3c0e44f7f3
added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9172
diff
changeset
|
230 |
|
13158 | 231 |
graphic->setScene(m_scene.data()); |
13218
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
232 |
|
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
233 |
// 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:
13217
diff
changeset
|
234 |
qint32 sceneMinY = minValue; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
235 |
qint32 sceneMaxY = maxValue; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
236 |
// 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:
13217
diff
changeset
|
237 |
if(sceneMinY >= 0 && sceneMaxY >= 0) |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
238 |
sceneMinY = 0; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
239 |
// 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:
13217
diff
changeset
|
240 |
// 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:
13217
diff
changeset
|
241 |
if(sceneMinY == sceneMaxY) |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
242 |
sceneMaxY++; |
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
243 |
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:
13217
diff
changeset
|
244 |
|
10017 | 245 |
graphic->fitInView(graphic->sceneRect()); |
13217
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
246 |
|
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
247 |
graphic->show(); |
1357dfbfa29c
Fix broken stats chart bounding box
Wuzzy <Wuzzy2@mail.ru>
parents:
13186
diff
changeset
|
248 |
labelGraphTitle->show(); |
10017 | 249 |
} |
1622 | 250 |
} |
251 |
||
252 |
void PageGameStats::GameStats(char type, const QString & info) |
|
253 |
{ |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
254 |
switch(type) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
255 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
256 |
case 'r' : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
257 |
{ |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
258 |
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
|
259 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
260 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
261 |
case 'D' : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
262 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
263 |
int i = info.indexOf(' '); |
10393 | 264 |
int num = info.left(i).toInt(); |
265 |
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
|
266 |
AddStatText(message); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
267 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
268 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
269 |
case 'k' : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
270 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
271 |
int i = info.indexOf(' '); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
272 |
int num = info.left(i).toInt(); |
3815
8754f7874395
Frontend: improve statsPage (clean up translation strings)
TheXception
parents:
3788
diff
changeset
|
273 |
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
|
274 |
AddStatText(message); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
275 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
276 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
277 |
case 'K' : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
278 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
279 |
int num = info.toInt(); |
3815
8754f7874395
Frontend: improve statsPage (clean up translation strings)
TheXception
parents:
3788
diff
changeset
|
280 |
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
|
281 |
AddStatText(message); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
282 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
283 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
284 |
case 'H' : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
285 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
286 |
int i = info.indexOf(' '); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
287 |
quint32 clan = info.left(i).toInt(); |
13218
d0647647a697
Make chart in stats screen support negative numbers. Fixes e.g. Mutant
Wuzzy <Wuzzy2@mail.ru>
parents:
13217
diff
changeset
|
288 |
qint32 hp = info.mid(i + 1).toInt(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
289 |
healthPoints[clan].append(hp); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
290 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
291 |
} |
9175
dc3c0e44f7f3
added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9172
diff
changeset
|
292 |
case 'g' : |
dc3c0e44f7f3
added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9172
diff
changeset
|
293 |
{ |
10017 | 294 |
// TODO: change default picture or add change pic capability |
295 |
defaultGraphTitle = false; |
|
296 |
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
|
297 |
break; |
dc3c0e44f7f3
added option to change stats graph title
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9172
diff
changeset
|
298 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
299 |
case 'T': // local team stats |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
300 |
{ |
3381 | 301 |
//AddStatText("<p>local team: " + info + "</p>"); |
302 |
QStringList infol = info.split(":"); |
|
303 |
HWTeam team(infol[0]); |
|
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
6009
diff
changeset
|
304 |
if(team.fileExists()) // do some better test to avoid influence from scripted/predefined teams? |
3381 | 305 |
{ |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
6009
diff
changeset
|
306 |
team.loadFromFile(); |
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
6009
diff
changeset
|
307 |
team.incRounds(); |
3381 | 308 |
if(infol[1].toInt() > 0) // might require some better test for winning condition (or changed flag) ... WIP! |
6015
daffc14a518a
cleaning up a little bit more, especially team class. we were leaking teams into heap memory on quick game starts btw
sheepluva
parents:
6009
diff
changeset
|
309 |
team.incWins(); // should draws count as wins? |
3381 | 310 |
//team.SaveToFile(); // don't save yet |
311 |
} |
|
4176 | 312 |
break; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
313 |
} |
10017 | 314 |
case 'p' : |
9178
c0902317c823
created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9177
diff
changeset
|
315 |
{ |
c0902317c823
created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9177
diff
changeset
|
316 |
kindOfPoints = info; |
c0902317c823
created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9177
diff
changeset
|
317 |
break; |
c0902317c823
created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9177
diff
changeset
|
318 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
319 |
case 'P' : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
320 |
{ |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
321 |
int i = info.indexOf(' '); |
4176 | 322 |
playerPosition++; |
323 |
QString color = info.left(i); |
|
324 |
quint32 c = color.toInt(); |
|
325 |
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
|
326 |
|
4176 | 327 |
QString playerinfo = info.mid(i + 1); |
328 |
||
329 |
i = playerinfo.indexOf(' '); |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
330 |
|
4176 | 331 |
int kills = playerinfo.left(i).toInt(); |
332 |
QString playername = playerinfo.mid(i + 1); |
|
333 |
QString image; |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
334 |
|
4217
721bfa5f4f31
Fix wrong order in results screen when players team up
TheException
parents:
4192
diff
changeset
|
335 |
if (lastColor == c) playerPosition--; |
4176 | 336 |
lastColor = c; |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
337 |
|
4176 | 338 |
switch (playerPosition) |
339 |
{ |
|
340 |
case 1: |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
341 |
image = "<img src=\":/res/StatsMedal1.png\">"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
342 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
343 |
case 2: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
344 |
image = "<img src=\":/res/StatsMedal2.png\">"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
345 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
346 |
case 3: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
347 |
image = "<img src=\":/res/StatsMedal3.png\">"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
348 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
349 |
default: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
350 |
image = "<img src=\":/res/StatsMedal4.png\">"; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
351 |
break; |
4176 | 352 |
} |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
353 |
|
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
354 |
QString message; |
9178
c0902317c823
created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9177
diff
changeset
|
355 |
QString killstring; |
c0902317c823
created a new sendstat type for changing the kills label
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9177
diff
changeset
|
356 |
if(kindOfPoints.compare("") == 0) { |
12474
42da9d8d82ab
Provide translator context for a few less obvious engine strings
Wuzzy <almikes@aol.com>
parents:
12444
diff
changeset
|
357 |
//: Number of kills in stats screen, written after the team name |
10017 | 358 |
killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills); |
359 |
} else { |
|
12474
42da9d8d82ab
Provide translator context for a few less obvious engine strings
Wuzzy <almikes@aol.com>
parents:
12444
diff
changeset
|
360 |
//: 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 | 361 |
killstring = PageGameStats::tr("(%1 %2)", "", kills).arg(kills).arg(kindOfPoints); |
362 |
kindOfPoints = QString(""); |
|
363 |
} |
|
4176 | 364 |
|
365 |
message = QString("<p><h2>%1 %2. <font color=\"%4\">%3</font> ").arg(image, QString::number(playerPosition), playername, clanColor.name()) + killstring + "</h2></p>"; |
|
366 |
||
367 |
labelGameRank->setText(labelGameRank->text() + message); |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
368 |
break; |
4176 | 369 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
370 |
case 's' : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
371 |
{ |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
372 |
int i = info.indexOf(' '); |
4177 | 373 |
int num = info.left(i).toInt(); |
12444
832b969ea00c
while we're tweaking this phrase, "with" feels awkward
nemo
parents:
12441
diff
changeset
|
374 |
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
|
375 |
AddStatText(message); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
376 |
break; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
377 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
378 |
case 'S' : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
379 |
{ |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
380 |
int i = info.indexOf(' '); |
4177 | 381 |
int num = info.left(i).toInt(); |
12441 | 382 |
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
|
383 |
AddStatText(message); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
384 |
break; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
385 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
386 |
case 'B' : |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
387 |
{ |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
388 |
int i = info.indexOf(' '); |
4177 | 389 |
int num = info.left(i).toInt(); |
4192 | 390 |
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
|
391 |
AddStatText(message); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
392 |
break; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
393 |
} |
9172
72bfa6a3e8e2
added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
394 |
case 'c' : |
72bfa6a3e8e2
added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
395 |
{ |
72bfa6a3e8e2
added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
396 |
QString message = "<p><img src=\":/res/StatsCustomAchievement.png\"> "+info+" </p>"; |
72bfa6a3e8e2
added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
397 |
AddStatText(message); |
72bfa6a3e8e2
added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
398 |
break; |
72bfa6a3e8e2
added custom stats message
Periklis Ntanasis <pntanasis@gmail.com>
parents:
9080
diff
changeset
|
399 |
} |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
400 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
401 |
} |
1622 | 402 |
} |