# HG changeset patch
# User TheXception
# Date 1283198553 -7200
# Node ID 9aa8a832e29684fffaaa9e2b33522c4f9ac8544a
# Parent 0907b0fd57149bc3f9002d96718bf3e1c171e50d
adds prettier after-game statistics page with more stats
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/hedgewars.qrc
--- a/QTfrontend/hedgewars.qrc Mon Aug 30 15:24:49 2010 +0200
+++ b/QTfrontend/hedgewars.qrc Mon Aug 30 22:02:33 2010 +0200
@@ -96,5 +96,18 @@
res/follow.png
res/info.png
res/kick.png
+ res/StatsMedal1.png
+ res/StatsMedal2.png
+ res/StatsMedal3.png
+ res/StatsMedal4.png
+ res/StatsR.png
+ res/StatsH.png
+ res/StatsD.png
+ res/StatsBestKiller.png
+ res/StatsBestShot.png
+ res/StatsHedgehogsKilled.png
+ res/StatsMostSelfDamage.png
+ res/StatsSelfKilled.png
+ res/StatsSkipped.png
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsBestKiller.png
Binary file QTfrontend/res/StatsBestKiller.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsBestShot.png
Binary file QTfrontend/res/StatsBestShot.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsD.png
Binary file QTfrontend/res/StatsD.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsH.png
Binary file QTfrontend/res/StatsH.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsHedgehogsKilled.png
Binary file QTfrontend/res/StatsHedgehogsKilled.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsMedal1.png
Binary file QTfrontend/res/StatsMedal1.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsMedal2.png
Binary file QTfrontend/res/StatsMedal2.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsMedal3.png
Binary file QTfrontend/res/StatsMedal3.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsMedal4.png
Binary file QTfrontend/res/StatsMedal4.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsMostSelfDamage.png
Binary file QTfrontend/res/StatsMostSelfDamage.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsR.png
Binary file QTfrontend/res/StatsR.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsSelfKilled.png
Binary file QTfrontend/res/StatsSelfKilled.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/res/StatsSkipped.png
Binary file QTfrontend/res/StatsSkipped.png has changed
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/statsPage.cpp
--- a/QTfrontend/statsPage.cpp Mon Aug 30 15:24:49 2010 +0200
+++ b/QTfrontend/statsPage.cpp Mon Aug 30 22:02:33 2010 +0200
@@ -19,7 +19,8 @@
#include
#include
#include
-
+#include
+#include
#include "statsPage.h"
#include "team.h"
@@ -36,20 +37,59 @@
PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent)
{
QGridLayout * pageLayout = new QGridLayout(this);
+ pageLayout->setSpacing(20);
pageLayout->setColumnStretch(0, 1);
pageLayout->setColumnStretch(1, 1);
- pageLayout->setColumnStretch(2, 1);
+
+ BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true);
+ BtnBack->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true);
+ QGroupBox * gb = new QGroupBox(this);
+ QVBoxLayout * gbl = new QVBoxLayout;
+ // details
labelGameStats = new QLabel(this);
+ QLabel * l = new QLabel(this);
+ l->setTextFormat(Qt::RichText);
+ l->setText(PageGameStats::tr(" Details
"));
+ l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
labelGameStats->setTextFormat(Qt::RichText);
- pageLayout->addWidget(labelGameStats, 0, 0, 1, 3);
-
- graphic = new FitGraphicsView(this);
+ labelGameStats->setAlignment(Qt::AlignTop);
+ gbl->addWidget(l);
+ gbl->addWidget(labelGameStats);
+ gb->setLayout(gbl);
+ pageLayout->addWidget(gb, 1, 1);
+
+ // graph
+ graphic = new FitGraphicsView(gb);
+ l = new QLabel(this);
+ l->setTextFormat(Qt::RichText);
+ l->setText(PageGameStats::tr("
Health graph
"));
+ l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ gbl->addWidget(l);
+ gbl->addWidget(graphic);
graphic->scale(1.0, -1.0);
graphic->setBackgroundBrush(QBrush(Qt::black));
- pageLayout->addWidget(graphic, 1, 0, 1, 3);
+
+ labelGameWin = new QLabel(this);
+ labelGameWin->setTextFormat(Qt::RichText);
+ pageLayout->addWidget(labelGameWin, 0, 0, 1, 2);
+
+ // ranking box
+ gb = new QGroupBox(this);
+ gbl = new QVBoxLayout;
+ labelGameRank = new QLabel(gb);
+ l = new QLabel(this);
+ l->setTextFormat(Qt::RichText);
+ l->setText(PageGameStats::tr(" Ranking
"));
+ l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ gbl->addWidget(l);
+ gbl->addWidget(labelGameRank);
+ gb->setLayout(gbl);
+
+ labelGameRank->setTextFormat(Qt::RichText);
+ labelGameRank->setAlignment(Qt::AlignTop);
+ pageLayout->addWidget(gb, 1, 0);
}
void PageGameStats::AddStatText(const QString & msg)
@@ -61,6 +101,9 @@
{
labelGameStats->setText("");
healthPoints.clear();
+ labelGameRank->setText("");
+ playerPosition = 0;
+ lastColor = 0;
}
void PageGameStats::renderStats()
@@ -93,12 +136,12 @@
{
switch(type) {
case 'r' : {
- AddStatText(QString("%1
").arg(info));
+ labelGameWin->setText(QString("%1
").arg(info));
break;
}
case 'D' : {
int i = info.indexOf(' ');
- QString message = PageGameStats::tr("The best shot award was won by %1 with %2 pts.
")
+ QString message = PageGameStats::tr(" The best shot award was won by %1 with %2 pts.
")
.arg(info.mid(i + 1), info.left(i));
AddStatText(message);
break;
@@ -106,14 +149,14 @@
case 'k' : {
int i = info.indexOf(' ');
int num = info.left(i).toInt();
- QString message = PageGameStats::tr("The best killer is %1 with %2 kills in a turn.
", "", num)
+ QString message = PageGameStats::tr(" The best killer is %1 with %2 kills in a turn.
", "", num)
.arg(info.mid(i + 1), info.left(i));
AddStatText(message);
break;
}
case 'K' : {
int num = info.toInt();
- QString message = PageGameStats::tr("A total of %1 hedgehog(s) were killed during this round.
", "", num).arg(num);
+ QString message = PageGameStats::tr(" A total of %1 hedgehog(s) were killed during this round.
", "", num).arg(num);
AddStatText(message);
break;
}
@@ -136,6 +179,74 @@
team.Wins++; // should draws count as wins?
//team.SaveToFile(); // don't save yet
}
+ break;
}
+
+ case 'P' : {
+ int i = info.indexOf(' ');
+ playerPosition++;
+ QString color = info.left(i);
+ quint32 c = color.toInt();
+ QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255));
+
+ QString playerinfo = info.mid(i + 1);
+
+ i = playerinfo.indexOf(' ');
+
+ QString kills = playerinfo.left(i);
+ QString playername = playerinfo.mid(i + 1);
+ QString image;
+
+ if (lastColor == c && playerPosition <= 2) playerPosition = 1;
+ lastColor = c;
+
+ switch (playerPosition)
+ {
+ case 1:
+ image = "";
+ break;
+ case 2:
+ image = "";
+ break;
+ case 3:
+ image = "";
+ break;
+ default:
+ image = "";
+ break;
+ }
+
+ QString message;
+ if (kills.toInt() == 1)
+ {
+ message = PageGameStats::tr("%1 %2. %3 (%4 kill).
").arg(image, QString::number(playerPosition), playername, kills, clanColor.name());
+ } else {
+ message = PageGameStats::tr("%1 %2. %3 (%4 kills).
").arg(image, QString::number(playerPosition), playername, kills, clanColor.name());
+ }
+ labelGameRank->setText(labelGameRank->text() + message);
+ break;
+ }
+ case 's' : {
+ int i = info.indexOf(' ');
+ QString message = PageGameStats::tr(" %1 thought it's good to shoot his own hedgehogs with %2 pts.
")
+ .arg(info.mid(i + 1), info.left(i));
+ AddStatText(message);
+ break;
+ }
+ case 'S' : {
+ int i = info.indexOf(' ');
+ QString message = PageGameStats::tr(" %1 killed %2 of his own hedgehogs.
")
+ .arg(info.mid(i + 1), info.left(i));
+ AddStatText(message);
+ break;
+ }
+ case 'B' : {
+ int i = info.indexOf(' ');
+ QString message = PageGameStats::tr(" %1 was scared and skipped turn %2 times.
")
+ .arg(info.mid(i + 1), info.left(i));
+ AddStatText(message);
+ break;
+ }
+
}
}
diff -r 0907b0fd5714 -r 9aa8a832e296 QTfrontend/statsPage.h
--- a/QTfrontend/statsPage.h Mon Aug 30 15:24:49 2010 +0200
+++ b/QTfrontend/statsPage.h Mon Aug 30 22:02:33 2010 +0200
@@ -44,6 +44,8 @@
QPushButton *BtnBack;
QLabel *labelGameStats;
+ QLabel *labelGameWin;
+ QLabel *labelGameRank;
FitGraphicsView * graphic;
public slots:
@@ -55,6 +57,8 @@
void AddStatText(const QString & msg);
QMap > healthPoints;
+ unsigned int playerPosition;
+ quint32 lastColor;
};
#endif // STATSPAGE_H