author | unc0rr |
Mon, 26 Sep 2011 21:45:33 +0400 | |
changeset 6040 | a740069c21e3 |
parent 6015 | daffc14a518a |
child 6042 | 8b5345758f62 |
permissions | -rw-r--r-- |
1621 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
4976 | 3 |
* Copyright (c) 2010-2011 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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QLabel> |
|
20 |
#include <QGridLayout> |
|
1625 | 21 |
#include <QGraphicsScene> |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
22 |
#include <QGroupBox> |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
23 |
#include <QSizePolicy> |
5205
78138ae93820
some headers cleanup and rename of stats and playrecord pages for consistency
koda
parents:
5028
diff
changeset
|
24 |
|
78138ae93820
some headers cleanup and rename of stats and playrecord pages for consistency
koda
parents:
5028
diff
changeset
|
25 |
#include "pagegamestats.h" |
3381 | 26 |
#include "team.h" |
1621 | 27 |
|
1636 | 28 |
FitGraphicsView::FitGraphicsView(QWidget* parent) : QGraphicsView(parent) |
29 |
{ |
|
30 |
||
31 |
} |
|
32 |
||
33 |
void FitGraphicsView::resizeEvent(QResizeEvent * event) |
|
34 |
{ |
|
4560
5d6c7f88db73
- Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents:
4217
diff
changeset
|
35 |
Q_UNUSED(event); |
5d6c7f88db73
- Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents:
4217
diff
changeset
|
36 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
37 |
fitInView(sceneRect()); |
1636 | 38 |
} |
39 |
||
1621 | 40 |
PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent) |
41 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
42 |
QGridLayout * pageLayout = new QGridLayout(this); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
43 |
pageLayout->setSpacing(20); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
44 |
pageLayout->setColumnStretch(0, 1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
45 |
pageLayout->setColumnStretch(1, 1); |
5916
c76212c34192
fix back button location in post-game stats screen
sheepluva
parents:
5734
diff
changeset
|
46 |
pageLayout->setContentsMargins(7, 7, 7, 0); |
c76212c34192
fix back button location in post-game stats screen
sheepluva
parents:
5734
diff
changeset
|
47 |
|
c76212c34192
fix back button location in post-game stats screen
sheepluva
parents:
5734
diff
changeset
|
48 |
BtnSave = addButton(":/res/Save.png", pageLayout, 3, 2, true); |
c76212c34192
fix back button location in post-game stats screen
sheepluva
parents:
5734
diff
changeset
|
49 |
BtnSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); |
c76212c34192
fix back button location in post-game stats screen
sheepluva
parents:
5734
diff
changeset
|
50 |
connect(BtnSave, SIGNAL(clicked()), this, SIGNAL(saveDemoRequested())); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
51 |
|
6009 | 52 |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
53 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true); |
5916
c76212c34192
fix back button location in post-game stats screen
sheepluva
parents:
5734
diff
changeset
|
54 |
BtnBack->setFixedHeight(BtnSave->height()); |
c76212c34192
fix back button location in post-game stats screen
sheepluva
parents:
5734
diff
changeset
|
55 |
BtnBack->setFixedWidth(BtnBack->width()+2); |
c76212c34192
fix back button location in post-game stats screen
sheepluva
parents:
5734
diff
changeset
|
56 |
BtnBack->setStyleSheet("QPushButton{margin: 22px 0 9px 2px;}"); |
6009 | 57 |
connect(BtnBack, SIGNAL(clicked()), this, SIGNAL(goBack())); |
58 |
||
5734 | 59 |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
60 |
QGroupBox * gb = new QGroupBox(this); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
61 |
QVBoxLayout * gbl = new QVBoxLayout; |
1621 | 62 |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
63 |
// details |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
64 |
labelGameStats = new QLabel(this); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
65 |
QLabel * l = new QLabel(this); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
66 |
l->setTextFormat(Qt::RichText); |
3815
8754f7874395
Frontend: improve statsPage (clean up translation strings)
TheXception
parents:
3788
diff
changeset
|
67 |
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
|
68 |
l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
69 |
labelGameStats->setTextFormat(Qt::RichText); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
70 |
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
|
71 |
labelGameStats->setWordWrap(true); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
72 |
gbl->addWidget(l); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
73 |
gbl->addWidget(labelGameStats); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
74 |
gb->setLayout(gbl); |
5734 | 75 |
pageLayout->addWidget(gb, 1, 1, 1, 2); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
76 |
|
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
77 |
// graph |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
78 |
graphic = new FitGraphicsView(gb); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
79 |
l = new QLabel(this); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
80 |
l->setTextFormat(Qt::RichText); |
3815
8754f7874395
Frontend: improve statsPage (clean up translation strings)
TheXception
parents:
3788
diff
changeset
|
81 |
l->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>"); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
82 |
l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
83 |
gbl->addWidget(l); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
84 |
gbl->addWidget(graphic); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
85 |
graphic->scale(1.0, -1.0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
86 |
graphic->setBackgroundBrush(QBrush(Qt::black)); |
3788
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 |
labelGameWin = new QLabel(this); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
89 |
labelGameWin->setTextFormat(Qt::RichText); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
90 |
pageLayout->addWidget(labelGameWin, 0, 0, 1, 2); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
91 |
|
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
92 |
// ranking box |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
93 |
gb = new QGroupBox(this); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
94 |
gbl = new QVBoxLayout; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
95 |
labelGameRank = new QLabel(gb); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
96 |
l = new QLabel(this); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
97 |
l->setTextFormat(Qt::RichText); |
3815
8754f7874395
Frontend: improve statsPage (clean up translation strings)
TheXception
parents:
3788
diff
changeset
|
98 |
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
|
99 |
l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
100 |
gbl->addWidget(l); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
101 |
gbl->addWidget(labelGameRank); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
102 |
gb->setLayout(gbl); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
103 |
|
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
104 |
labelGameRank->setTextFormat(Qt::RichText); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
105 |
labelGameRank->setAlignment(Qt::AlignTop); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
106 |
pageLayout->addWidget(gb, 1, 0); |
1621 | 107 |
} |
1622 | 108 |
|
109 |
void PageGameStats::AddStatText(const QString & msg) |
|
110 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
111 |
labelGameStats->setText(labelGameStats->text() + msg); |
1622 | 112 |
} |
113 |
||
114 |
void PageGameStats::clear() |
|
115 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
116 |
labelGameStats->setText(""); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
117 |
healthPoints.clear(); |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
118 |
labelGameRank->setText(""); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
119 |
playerPosition = 0; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
120 |
lastColor = 0; |
1625 | 121 |
} |
122 |
||
123 |
void PageGameStats::renderStats() |
|
124 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
125 |
QGraphicsScene * scene = new QGraphicsScene(); |
1625 | 126 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
127 |
QMap<quint32, QVector<quint32> >::const_iterator i = healthPoints.constBegin(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
128 |
while (i != healthPoints.constEnd()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
129 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
130 |
quint32 c = i.key(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
131 |
QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
132 |
QVector<quint32> hps = i.value(); |
1625 | 133 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
134 |
QPainterPath path; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
135 |
if (hps.size()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
136 |
path.moveTo(0, hps[0]); |
2377 | 137 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
138 |
for(int t = 1; t < hps.size(); ++t) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
139 |
path.lineTo(t, hps[t]); |
1625 | 140 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
141 |
scene->addPath(path, QPen(c)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
142 |
++i; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
143 |
} |
1625 | 144 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
145 |
graphic->setScene(scene); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
146 |
graphic->fitInView(graphic->sceneRect()); |
1622 | 147 |
} |
148 |
||
149 |
void PageGameStats::GameStats(char type, const QString & info) |
|
150 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
151 |
switch(type) { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
152 |
case 'r' : { |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
153 |
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
|
154 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
155 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
156 |
case 'D' : { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
157 |
int i = info.indexOf(' '); |
3815
8754f7874395
Frontend: improve statsPage (clean up translation strings)
TheXception
parents:
3788
diff
changeset
|
158 |
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.").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
|
159 |
AddStatText(message); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
160 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
161 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
162 |
case 'k' : { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
163 |
int i = info.indexOf(' '); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
164 |
int num = info.left(i).toInt(); |
3815
8754f7874395
Frontend: improve statsPage (clean up translation strings)
TheXception
parents:
3788
diff
changeset
|
165 |
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
|
166 |
AddStatText(message); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
167 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
168 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
169 |
case 'K' : { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
170 |
int num = info.toInt(); |
3815
8754f7874395
Frontend: improve statsPage (clean up translation strings)
TheXception
parents:
3788
diff
changeset
|
171 |
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
|
172 |
AddStatText(message); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
173 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
174 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
175 |
case 'H' : { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
176 |
int i = info.indexOf(' '); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
177 |
quint32 clan = info.left(i).toInt(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
178 |
quint32 hp = info.mid(i + 1).toUInt(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
179 |
healthPoints[clan].append(hp); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
180 |
break; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
181 |
} |
3381 | 182 |
case 'T': { // local team stats |
183 |
//AddStatText("<p>local team: " + info + "</p>"); |
|
184 |
QStringList infol = info.split(":"); |
|
185 |
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
|
186 |
if(team.fileExists()) // do some better test to avoid influence from scripted/predefined teams? |
3381 | 187 |
{ |
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
|
188 |
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
|
189 |
team.incRounds(); |
3381 | 190 |
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
|
191 |
team.incWins(); // should draws count as wins? |
3381 | 192 |
//team.SaveToFile(); // don't save yet |
193 |
} |
|
4176 | 194 |
break; |
195 |
} |
|
196 |
||
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
197 |
case 'P' : { |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
198 |
int i = info.indexOf(' '); |
4176 | 199 |
playerPosition++; |
200 |
QString color = info.left(i); |
|
201 |
quint32 c = color.toInt(); |
|
202 |
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
|
203 |
|
4176 | 204 |
QString playerinfo = info.mid(i + 1); |
205 |
||
206 |
i = playerinfo.indexOf(' '); |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
207 |
|
4176 | 208 |
int kills = playerinfo.left(i).toInt(); |
209 |
QString playername = playerinfo.mid(i + 1); |
|
210 |
QString image; |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
211 |
|
4217
721bfa5f4f31
Fix wrong order in results screen when players team up
TheException
parents:
4192
diff
changeset
|
212 |
if (lastColor == c) playerPosition--; |
4176 | 213 |
lastColor = c; |
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
214 |
|
4176 | 215 |
switch (playerPosition) |
216 |
{ |
|
217 |
case 1: |
|
218 |
image = "<img src=\":/res/StatsMedal1.png\">"; |
|
219 |
break; |
|
220 |
case 2: |
|
221 |
image = "<img src=\":/res/StatsMedal2.png\">"; |
|
222 |
break; |
|
223 |
case 3: |
|
224 |
image = "<img src=\":/res/StatsMedal3.png\">"; |
|
225 |
break; |
|
226 |
default: |
|
227 |
image = "<img src=\":/res/StatsMedal4.png\">"; |
|
228 |
break; |
|
229 |
} |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
230 |
|
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
231 |
QString message; |
4176 | 232 |
QString killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills); |
233 |
||
234 |
message = QString("<p><h2>%1 %2. <font color=\"%4\">%3</font> ").arg(image, QString::number(playerPosition), playername, clanColor.name()) + killstring + "</h2></p>"; |
|
235 |
||
236 |
labelGameRank->setText(labelGameRank->text() + message); |
|
237 |
break; |
|
238 |
} |
|
3788
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
239 |
case 's' : { |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
240 |
int i = info.indexOf(' '); |
4177 | 241 |
int num = info.left(i).toInt(); |
4192 | 242 |
QString message = "<p><img src=\":/res/StatsMostSelfDamage.png\"> " + PageGameStats::tr("<b>%1</b> thought it's good to shoot his own hedgehogs with <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
|
243 |
AddStatText(message); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
244 |
break; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
245 |
} |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
246 |
case 'S' : { |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
247 |
int i = info.indexOf(' '); |
4177 | 248 |
int num = info.left(i).toInt(); |
4192 | 249 |
QString message = "<p><img src=\":/res/StatsSelfKilled.png\"> " + PageGameStats::tr("<b>%1</b> killed <b>%2</b> of his 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
|
250 |
AddStatText(message); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
251 |
break; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
252 |
} |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
253 |
case 'B' : { |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
254 |
int i = info.indexOf(' '); |
4177 | 255 |
int num = info.left(i).toInt(); |
4192 | 256 |
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
|
257 |
AddStatText(message); |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
258 |
break; |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
259 |
} |
9aa8a832e296
adds prettier after-game statistics page with more stats
TheXception
parents:
3381
diff
changeset
|
260 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
261 |
} |
1622 | 262 |
} |