diff -r 3cbf01d31e5c -r 37aae47943ce QTfrontend/statsPage.cpp --- a/QTfrontend/statsPage.cpp Fri Jan 09 11:55:05 2009 +0000 +++ b/QTfrontend/statsPage.cpp Fri Jan 09 14:47:54 2009 +0000 @@ -18,6 +18,8 @@ #include #include +#include +#include #include "statsPage.h" @@ -29,11 +31,15 @@ pageLayout->setColumnStretch(1, 1); pageLayout->setColumnStretch(2, 1); - BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); labelGameStats = new QLabel(this); labelGameStats->setTextFormat(Qt::RichText); pageLayout->addWidget(labelGameStats, 0, 0, 1, 3); + + graphic = new QGraphicsView(this); + graphic->scale(1.0, -1.0); + pageLayout->addWidget(graphic, 1, 0, 1, 3); } void PageGameStats::AddStatText(const QString & msg) @@ -44,6 +50,33 @@ void PageGameStats::clear() { labelGameStats->setText(""); + healthPoints.clear(); +} + +void PageGameStats::renderStats() +{ + QGraphicsScene * scene = new QGraphicsScene(); + + QMap >::const_iterator i = healthPoints.constBegin(); + while (i != healthPoints.constEnd()) + { + quint32 c = i.key(); + QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); + QVector hps = i.value(); + + QPainterPath path; + if (hps.size()) + path.moveTo(0, hps[0]); + + for(int t = 1; t < hps.size(); ++t) + path.lineTo(t, hps[t]); + + scene->addPath(path, QPen(c)); + ++i; + } + + graphic->setScene(scene); + graphic->fitInView(graphic->sceneRect()); } void PageGameStats::GameStats(char type, const QString & info) @@ -72,5 +105,12 @@ AddStatText(message); break; } + case 'H' : { + int i = info.indexOf(' '); + quint32 clan = info.left(i).toInt(); + quint32 hp = info.mid(i + 1).toUInt(); + healthPoints[clan].append(hp); + break; + } } }