38 fitInView(sceneRect()); |
38 fitInView(sceneRect()); |
39 } |
39 } |
40 |
40 |
41 QLayout * PageGameStats::bodyLayoutDefinition() |
41 QLayout * PageGameStats::bodyLayoutDefinition() |
42 { |
42 { |
43 kindOfPoints = QString(""); |
43 kindOfPoints = QString(""); |
44 defaultGraphTitle = true; |
44 defaultGraphTitle = true; |
45 QGridLayout * pageLayout = new QGridLayout(); |
45 QGridLayout * pageLayout = new QGridLayout(); |
46 pageLayout->setSpacing(20); |
46 pageLayout->setSpacing(20); |
47 pageLayout->setColumnStretch(0, 1); |
47 pageLayout->setColumnStretch(0, 1); |
48 pageLayout->setColumnStretch(1, 1); |
48 pageLayout->setColumnStretch(1, 1); |
49 pageLayout->setRowStretch(0, 1); |
49 pageLayout->setRowStretch(0, 1); |
50 pageLayout->setRowStretch(1, 20); |
50 pageLayout->setRowStretch(1, 20); |
51 //pageLayout->setRowStretch(1, -1); this should work but there is unnecessary empty space betwin lines if used |
51 //pageLayout->setRowStretch(1, -1); this should work but there is unnecessary empty space betwin lines if used |
52 pageLayout->setContentsMargins(7, 7, 7, 0); |
52 pageLayout->setContentsMargins(7, 7, 7, 0); |
53 |
53 |
54 QGroupBox * gb = new QGroupBox(this); |
54 QGroupBox * gb = new QGroupBox(this); |
104 |
104 |
105 //TODO button placement, image etc |
105 //TODO button placement, image etc |
106 QLayout * PageGameStats::footerLayoutDefinition() |
106 QLayout * PageGameStats::footerLayoutDefinition() |
107 { |
107 { |
108 QHBoxLayout * bottomLayout = new QHBoxLayout(); |
108 QHBoxLayout * bottomLayout = new QHBoxLayout(); |
109 |
109 |
110 mainNote = new QLabel(this); |
110 mainNote = new QLabel(this); |
111 mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); |
111 mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); |
112 mainNote->setWordWrap(true); |
112 mainNote->setWordWrap(true); |
113 |
113 |
114 bottomLayout->addWidget(mainNote, 0); |
114 bottomLayout->addWidget(mainNote, 0); |
115 bottomLayout->setStretch(0,1); |
115 bottomLayout->setStretch(0,1); |
116 |
116 |
117 btnRestart = addButton(":/res/Start.png", bottomLayout, 1, true); |
117 btnRestart = addButton(":/res/Start.png", bottomLayout, 1, true); |
118 btnRestart->setWhatsThis(tr("Play again")); |
118 btnRestart->setWhatsThis(tr("Play again")); |
157 btnRestart->setVisible(visible); |
157 btnRestart->setVisible(visible); |
158 } |
158 } |
159 |
159 |
160 void PageGameStats::renderStats() |
160 void PageGameStats::renderStats() |
161 { |
161 { |
162 graphic->show(); |
162 graphic->show(); |
163 labelGraphTitle-> show(); |
163 labelGraphTitle-> show(); |
164 if(defaultGraphTitle) { |
164 if(defaultGraphTitle) { |
165 labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>"); |
165 labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>"); |
166 } else { |
166 } else { |
167 defaultGraphTitle = true; |
167 defaultGraphTitle = true; |
168 } |
168 } |
169 // if not health data sent |
169 // if not health data sent |
170 if(healthPoints.size() == 0) { |
170 if(healthPoints.size() == 0) { |
171 labelGraphTitle->hide(); |
171 labelGraphTitle->hide(); |
172 graphic->hide(); |
172 graphic->hide(); |
173 } else { |
173 } else { |
174 QGraphicsScene * scene = new QGraphicsScene(); |
174 QGraphicsScene * scene = new QGraphicsScene(); |
175 |
175 |
176 QMap<quint32, QVector<quint32> >::const_iterator i = healthPoints.constBegin(); |
176 QMap<quint32, QVector<quint32> >::const_iterator i = healthPoints.constBegin(); |
177 while (i != healthPoints.constEnd()) |
177 while (i != healthPoints.constEnd()) |
178 { |
178 { |
179 quint32 c = i.key(); |
179 quint32 c = i.key(); |
180 //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); |
180 //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); |
181 QVector<quint32> hps = i.value(); |
181 QVector<quint32> hps = i.value(); |
182 |
182 |
183 QPainterPath path; |
183 QPainterPath path; |
184 if (hps.size()) |
184 if (hps.size()) |
185 path.moveTo(0, hps[0]); |
185 path.moveTo(0, hps[0]); |
186 |
186 |
187 for(int t = 1; t < hps.size(); ++t) |
187 for(int t = 1; t < hps.size(); ++t) |
188 path.lineTo(t, hps[t]); |
188 path.lineTo(t, hps[t]); |
189 |
189 |
190 scene->addPath(path, QPen(c)); |
190 scene->addPath(path, QPen(c)); |
191 ++i; |
191 ++i; |
192 } |
192 } |
193 |
193 |
194 graphic->setScene(scene); |
194 graphic->setScene(scene); |
195 graphic->fitInView(graphic->sceneRect()); |
195 graphic->fitInView(graphic->sceneRect()); |
196 } |
196 } |
197 } |
197 } |
198 |
198 |
199 void PageGameStats::GameStats(char type, const QString & info) |
199 void PageGameStats::GameStats(char type, const QString & info) |
200 { |
200 { |
201 switch(type) |
201 switch(type) |
235 healthPoints[clan].append(hp); |
235 healthPoints[clan].append(hp); |
236 break; |
236 break; |
237 } |
237 } |
238 case 'g' : |
238 case 'g' : |
239 { |
239 { |
240 // TODO: change default picture or add change pic capability |
240 // TODO: change default picture or add change pic capability |
241 defaultGraphTitle = false; |
241 defaultGraphTitle = false; |
242 labelGraphTitle->setText("<br><h1><img src=\":/res/StatsR.png\"> " + info + "</h1>"); |
242 labelGraphTitle->setText("<br><h1><img src=\":/res/StatsR.png\"> " + info + "</h1>"); |
243 break; |
243 break; |
244 } |
244 } |
245 case 'T': // local team stats |
245 case 'T': // local team stats |
246 { |
246 { |
247 //AddStatText("<p>local team: " + info + "</p>"); |
247 //AddStatText("<p>local team: " + info + "</p>"); |
298 } |
298 } |
299 |
299 |
300 QString message; |
300 QString message; |
301 QString killstring; |
301 QString killstring; |
302 if(kindOfPoints.compare("") == 0) { |
302 if(kindOfPoints.compare("") == 0) { |
303 killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills); |
303 killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills); |
304 } else { |
304 } else { |
305 killstring = PageGameStats::tr("(%1 %2)", "", kills).arg(kills).arg(kindOfPoints); |
305 killstring = PageGameStats::tr("(%1 %2)", "", kills).arg(kills).arg(kindOfPoints); |
306 kindOfPoints = QString(""); |
306 kindOfPoints = QString(""); |
307 } |
307 } |
308 |
308 |
309 message = QString("<p><h2>%1 %2. <font color=\"%4\">%3</font> ").arg(image, QString::number(playerPosition), playername, clanColor.name()) + killstring + "</h2></p>"; |
309 message = QString("<p><h2>%1 %2. <font color=\"%4\">%3</font> ").arg(image, QString::number(playerPosition), playername, clanColor.name()) + killstring + "</h2></p>"; |
310 |
310 |
311 labelGameRank->setText(labelGameRank->text() + message); |
311 labelGameRank->setText(labelGameRank->text() + message); |
312 break; |
312 break; |