--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/AbstractPage.h Mon May 09 18:00:39 2011 +0200
@@ -0,0 +1,123 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef ABSTRACTPAGE_H
+#define ABSTRACTPAGE_H
+
+#include <QWidget>
+#include <QPushButton>
+#include <QFont>
+#include <QGridLayout>
+#include <QComboBox>
+#include <QSignalMapper>
+
+class QPushButton;
+class QGroupBox;
+class QComboBox;
+class QLabel;
+class QToolBox;
+class QLineEdit;
+class QListWidget;
+class QCheckBox;
+class QSpinBox;
+class QTextEdit;
+class QRadioButton;
+class QTableView;
+class QTextBrowser;
+class QTableWidget;
+class QAction;
+class QDataWidgetMapper;
+class QAbstractItemModel;
+class QSettings;
+class QSlider;
+
+class AbstractPage : public QWidget
+{
+ Q_OBJECT
+
+ public:
+
+ protected:
+ AbstractPage(QWidget* parent = 0) {
+ Q_UNUSED(parent);
+
+ font14 = new QFont("MS Shell Dlg", 14);
+ //setFocusPolicy(Qt::StrongFocus);
+ }
+ virtual ~AbstractPage() {};
+
+ QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, bool iconed = false) {
+ QPushButton* butt = new QPushButton(this);
+ if (!iconed) {
+ butt->setFont(*font14);
+ butt->setText(btname);
+ //butt->setStyleSheet("background-color: #0d0544");
+ } else {
+ const QIcon& lp=QIcon(btname);
+ QSize sz = lp.actualSize(QSize(65535, 65535));
+ butt->setIcon(lp);
+ butt->setFixedSize(sz);
+ butt->setIconSize(sz);
+ butt->setFlat(true);
+ butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ }
+ grid->addWidget(butt, wy, wx);
+ return butt;
+ };
+
+ QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool iconed = false) {
+ QPushButton* butt = new QPushButton(this);
+ if (!iconed) {
+ butt->setFont(*font14);
+ butt->setText(btname);
+ } else {
+ const QIcon& lp=QIcon(btname);
+ QSize sz = lp.actualSize(QSize(65535, 65535));
+ butt->setIcon(lp);
+ butt->setFixedSize(sz);
+ butt->setIconSize(sz);
+ butt->setFlat(true);
+ butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ }
+ grid->addWidget(butt, wy, wx, rowSpan, columnSpan);
+ return butt;
+ };
+
+ QPushButton* addButton(QString btname, QBoxLayout* box, int where, bool iconed = false) {
+ QPushButton* butt = new QPushButton(this);
+ if (!iconed) {
+ butt->setFont(*font14);
+ butt->setText(btname);
+ } else {
+ const QIcon& lp=QIcon(btname);
+ QSize sz = lp.actualSize(QSize(65535, 65535));
+ butt->setIcon(lp);
+ butt->setFixedSize(sz);
+ butt->setIconSize(sz);
+ butt->setFlat(true);
+ butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ }
+ box->addWidget(butt, where);
+ return butt;
+ };
+
+ QFont * font14;
+};
+
+#endif
+
--- a/QTfrontend/CMakeLists.txt Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/CMakeLists.txt Mon May 09 18:00:39 2011 +0200
@@ -74,6 +74,8 @@
pageroomslist.cpp
pageconnecting.cpp
pagescheme.cpp
+ pagegamestats.cpp
+ pageplayrecord.cpp
pageadmin.cpp
pagenettype.cpp
pagedrawmap.cpp
@@ -95,14 +97,12 @@
chatwidget.cpp
binds.cpp
SDLs.cpp
- playrecordpage.cpp
${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp
selectWeapon.cpp
itemNum.cpp
input_ip.cpp
igbox.cpp
weaponItem.cpp
- statsPage.cpp
misc.cpp
ammoSchemeModel.cpp
togglebutton.cpp
@@ -139,7 +139,7 @@
vertScrollArea.h
gameuiconfig.h
gamecfgwidget.h
- pages.h
+ AbstractPage.h
pagenet.h
pagemultiplayer.h
pagenetserver.h
@@ -157,9 +157,11 @@
pagenetgame.h
pageeditteam.h
pageroomslist.h
+ pagegamestats.h
pageadmin.h
pagescheme.h
pageselectweapon.h
+ pageplayrecord.h
SquareLabel.h
hedgehogerWidget.h
hwmap.h
@@ -176,13 +178,11 @@
netserverslist.h
chatwidget.h
SDLs.h
- playrecordpage.h
selectWeapon.h
itemNum.h
input_ip.h
igbox.h
weaponItem.h
- statsPage.h
misc.h
ammoSchemeModel.h
togglebutton.h
--- a/QTfrontend/hwform.cpp Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/hwform.cpp Mon May 09 18:00:39 2011 +0200
@@ -63,14 +63,14 @@
#include "pagenetserver.h"
#include "pagedrawmap.h"
#include "pagenettype.h"
-#include "statsPage.h"
+#include "pagegamestats.h"
#include "hwconsts.h"
#include "newnetclient.h"
#include "gamecfgwidget.h"
#include "netserverslist.h"
#include "netudpserver.h"
#include "chatwidget.h"
-#include "playrecordpage.h"
+#include "pageplayrecord.h"
#include "input_ip.h"
#include "ammoSchemeModel.h"
#include "bgwidget.h"
--- a/QTfrontend/pageadmin.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pageadmin.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_ADMIN_H
#define PAGE_ADMIN_H
-#include "pages.h"
+#include "AbstractPage.h"
class PageAdmin : public AbstractPage
{
--- a/QTfrontend/pagecampaign.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagecampaign.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_CAMPAIGN_H
#define PAGE_CAMPAIGN_H
-#include "pages.h"
+#include "AbstractPage.h"
class PageCampaign : public AbstractPage
{
--- a/QTfrontend/pageconnecting.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pageconnecting.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_CONNECTING_H
#define PAGE_CONNECTING_H
-#include "pages.h"
+#include "AbstractPage.h"
class PageConnecting : public AbstractPage
{
--- a/QTfrontend/pagedrawmap.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagedrawmap.h Mon May 09 18:00:39 2011 +0200
@@ -16,11 +16,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-
#ifndef PAGE_DRAWMAP_H
#define PAGE_DRAWMAP_H
-#include "pages.h"
+#include "AbstractPage.h"
class DrawMapWidget;
--- a/QTfrontend/pageeditteam.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pageeditteam.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,9 @@
#ifndef PAGE_EDITTEAM_H
#define PAGE_EDITTEAM_H
-#include "pages.h"
+#include "AbstractPage.h"
+#include "binds.h"
+#include "SDLs.h"
class SquareLabel;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/pagegamestats.cpp Mon May 09 18:00:39 2011 +0200
@@ -0,0 +1,252 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2010-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <QLabel>
+#include <QGridLayout>
+#include <QGraphicsScene>
+#include <QGroupBox>
+#include <QSizePolicy>
+
+#include "pagegamestats.h"
+#include "team.h"
+
+FitGraphicsView::FitGraphicsView(QWidget* parent) : QGraphicsView(parent)
+{
+
+}
+
+void FitGraphicsView::resizeEvent(QResizeEvent * event)
+{
+ Q_UNUSED(event);
+
+ fitInView(sceneRect());
+}
+
+PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent)
+{
+ QGridLayout * pageLayout = new QGridLayout(this);
+ pageLayout->setSpacing(20);
+ pageLayout->setColumnStretch(0, 1);
+ pageLayout->setColumnStretch(1, 1);
+
+ BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true);
+ BtnBack->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+
+ 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("<h1><img src=\":/res/StatsD.png\"> " + PageGameStats::tr("Details") + "</h1>");
+ l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ labelGameStats->setTextFormat(Qt::RichText);
+ labelGameStats->setAlignment(Qt::AlignTop);
+ labelGameStats->setWordWrap(true);
+ 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("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>");
+ l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ gbl->addWidget(l);
+ gbl->addWidget(graphic);
+ graphic->scale(1.0, -1.0);
+ graphic->setBackgroundBrush(QBrush(Qt::black));
+
+ 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("<h1><img src=\":/res/StatsR.png\"> " + PageGameStats::tr("Ranking") + "</h1>");
+ 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)
+{
+ labelGameStats->setText(labelGameStats->text() + msg);
+}
+
+void PageGameStats::clear()
+{
+ labelGameStats->setText("");
+ healthPoints.clear();
+ labelGameRank->setText("");
+ playerPosition = 0;
+ lastColor = 0;
+}
+
+void PageGameStats::renderStats()
+{
+ QGraphicsScene * scene = new QGraphicsScene();
+
+ QMap<quint32, QVector<quint32> >::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<quint32> 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)
+{
+ switch(type) {
+ case 'r' : {
+ labelGameWin->setText(QString("<h1 align=\"center\">%1</h1>").arg(info));
+ break;
+ }
+ case 'D' : {
+ int i = info.indexOf(' ');
+ 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>";
+ AddStatText(message);
+ break;
+ }
+ case 'k' : {
+ int i = info.indexOf(' ');
+ int num = info.left(i).toInt();
+ 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>";
+ AddStatText(message);
+ break;
+ }
+ case 'K' : {
+ int num = info.toInt();
+ 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>";
+ 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;
+ }
+ case 'T': { // local team stats
+ //AddStatText("<p>local team: " + info + "</p>");
+ QStringList infol = info.split(":");
+ HWTeam team(infol[0]);
+ if(team.FileExists()) // do some better test to avoid influence from scripted/predefined teams?
+ {
+ team.LoadFromFile();
+ team.Rounds++;
+ if(infol[1].toInt() > 0) // might require some better test for winning condition (or changed flag) ... WIP!
+ 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(' ');
+
+ int kills = playerinfo.left(i).toInt();
+ QString playername = playerinfo.mid(i + 1);
+ QString image;
+
+ if (lastColor == c) playerPosition--;
+ lastColor = c;
+
+ switch (playerPosition)
+ {
+ case 1:
+ image = "<img src=\":/res/StatsMedal1.png\">";
+ break;
+ case 2:
+ image = "<img src=\":/res/StatsMedal2.png\">";
+ break;
+ case 3:
+ image = "<img src=\":/res/StatsMedal3.png\">";
+ break;
+ default:
+ image = "<img src=\":/res/StatsMedal4.png\">";
+ break;
+ }
+
+ QString message;
+ QString killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills);
+
+ message = QString("<p><h2>%1 %2. <font color=\"%4\">%3</font> ").arg(image, QString::number(playerPosition), playername, clanColor.name()) + killstring + "</h2></p>";
+
+ labelGameRank->setText(labelGameRank->text() + message);
+ break;
+ }
+ case 's' : {
+ int i = info.indexOf(' ');
+ int num = info.left(i).toInt();
+ 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>";
+ AddStatText(message);
+ break;
+ }
+ case 'S' : {
+ int i = info.indexOf(' ');
+ int num = info.left(i).toInt();
+ 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>";
+ AddStatText(message);
+ break;
+ }
+ case 'B' : {
+ int i = info.indexOf(' ');
+ int num = info.left(i).toInt();
+ 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>";
+ AddStatText(message);
+ break;
+ }
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/pagegamestats.h Mon May 09 18:00:39 2011 +0200
@@ -0,0 +1,65 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2010-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef STATSPAGE_H
+#define STATSPAGE_H
+
+#include <QVector>
+#include <QMap>
+#include <QGraphicsView>
+
+#include "AbstractPage.h"
+
+class FitGraphicsView : public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ FitGraphicsView(QWidget* parent = 0);
+
+protected:
+ void resizeEvent(QResizeEvent * event);
+};
+
+class PageGameStats : public AbstractPage
+{
+ Q_OBJECT
+
+public:
+ PageGameStats(QWidget* parent = 0);
+
+ QPushButton *BtnBack;
+ QLabel *labelGameStats;
+ QLabel *labelGameWin;
+ QLabel *labelGameRank;
+ FitGraphicsView * graphic;
+
+public slots:
+ void GameStats(char type, const QString & info);
+ void clear();
+ void renderStats();
+
+private:
+ void AddStatText(const QString & msg);
+
+ QMap<quint32, QVector<quint32> > healthPoints;
+ unsigned int playerPosition;
+ quint32 lastColor;
+};
+
+#endif // STATSPAGE_H
--- a/QTfrontend/pageinfo.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pageinfo.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_INFO_H
#define PAGE_INFO_H
-#include "pages.h"
+#include "AbstractPage.h"
class About;
--- a/QTfrontend/pageingame.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pageingame.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_INGAME_H
#define PAGE_INGAME_H
-#include "pages.h"
+#include "AbstractPage.h"
class PageInGame : public AbstractPage
{
--- a/QTfrontend/pagemain.cpp Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagemain.cpp Mon May 09 18:00:39 2011 +0200
@@ -23,6 +23,7 @@
#include "pagemain.h"
#include "hwconsts.h"
+#include "hwform.h"
PageMain::PageMain(QWidget* parent) :
AbstractPage(parent)
--- a/QTfrontend/pagemain.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagemain.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_MAIN_H
#define PAGE_MAIN_H
-#include "pages.h"
+#include "AbstractPage.h"
class PageMain : public AbstractPage
{
--- a/QTfrontend/pagemultiplayer.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagemultiplayer.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_MULTIPLAYER_H
#define PAGE_MULTIPLAYER_H
-#include "pages.h"
+#include "AbstractPage.h"
class GameCFGWidget;
class TeamSelWidget;
--- a/QTfrontend/pagenet.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagenet.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_NET_H
#define PAGE_NET_H
-#include "pages.h"
+#include "AbstractPage.h"
class PageNet : public AbstractPage
{
--- a/QTfrontend/pagenetgame.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagenetgame.h Mon May 09 18:00:39 2011 +0200
@@ -19,8 +19,12 @@
#ifndef PAGE_NETGAME_H
#define PAGE_NETGAME_H
-#include "pages.h"
+#include "AbstractPage.h"
+#include "SDLs.h"
+
class HWChatWidget;
+class TeamSelWidget;
+class GameCFGWidget;
class PageNetGame : public AbstractPage
{
--- a/QTfrontend/pagenetserver.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagenetserver.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_NETSERVER_H
#define PAGE_NETSERVER_H
-#include "pages.h"
+#include "AbstractPage.h"
class PageNetServer : public AbstractPage
{
--- a/QTfrontend/pagenettype.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagenettype.h Mon May 09 18:00:39 2011 +0200
@@ -19,8 +19,7 @@
#ifndef PAGE_NETTYPE_H
#define PAGE_NETTYPE_H
-#include "pages.h"
-
+#include "AbstractPage.h"
class PageNetType : public AbstractPage
{
--- a/QTfrontend/pageoptions.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pageoptions.h Mon May 09 18:00:39 2011 +0200
@@ -19,9 +19,10 @@
#ifndef PAGE_OPTIONS_H
#define PAGE_OPTIONS_H
-#include "pages.h"
+#include "AbstractPage.h"
class FPSEdit;
+class IconedGroupBox;
class PageOptions : public AbstractPage
{
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/pageplayrecord.cpp Mon May 09 18:00:39 2011 +0200
@@ -0,0 +1,152 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <QFont>
+#include <QGridLayout>
+#include <QPushButton>
+#include <QListWidget>
+#include <QListWidgetItem>
+#include <QFileInfo>
+#include <QMessageBox>
+#include <QInputDialog>
+
+#include "hwconsts.h"
+#include "pageplayrecord.h"
+
+PagePlayDemo::PagePlayDemo(QWidget* parent) : AbstractPage(parent)
+{
+ QFont * font14 = new QFont("MS Shell Dlg", 14);
+ QGridLayout * pageLayout = new QGridLayout(this);
+ pageLayout->setColumnStretch(0, 1);
+ pageLayout->setColumnStretch(1, 2);
+ pageLayout->setColumnStretch(2, 1);
+ pageLayout->setRowStretch(2, 100);
+
+ BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true);
+
+ BtnPlayDemo = new QPushButton(this);
+ BtnPlayDemo->setFont(*font14);
+ BtnPlayDemo->setText(QPushButton::tr("Play demo"));
+ pageLayout->addWidget(BtnPlayDemo, 3, 2);
+
+ BtnRenameRecord = new QPushButton(this);
+ BtnRenameRecord->setText(QPushButton::tr("Rename"));
+ pageLayout->addWidget(BtnRenameRecord, 0, 2);
+
+ BtnRemoveRecord = new QPushButton(this);
+ BtnRemoveRecord->setText(QPushButton::tr("Delete"));
+ pageLayout->addWidget(BtnRemoveRecord, 1, 2);
+
+ DemosList = new QListWidget(this);
+ DemosList->setGeometry(QRect(170, 10, 311, 311));
+ pageLayout->addWidget(DemosList, 0, 1, 3, 1);
+
+ connect(BtnRenameRecord, SIGNAL(clicked()), this, SLOT(renameRecord()));
+ connect(BtnRemoveRecord, SIGNAL(clicked()), this, SLOT(removeRecord()));
+}
+
+void PagePlayDemo::FillFromDir(RecordType rectype)
+{
+ QDir dir;
+ QString extension;
+
+ recType = rectype;
+
+ dir.cd(cfgdir->absolutePath());
+ if (rectype == RT_Demo)
+ {
+ dir.cd("Demos");
+ extension = "hwd";
+ BtnPlayDemo->setText(QPushButton::tr("Play demo"));
+ } else
+ {
+ dir.cd("Saves");
+ extension = "hws";
+ BtnPlayDemo->setText(QPushButton::tr("Load"));
+ }
+ dir.setFilter(QDir::Files);
+
+ QStringList sl = dir.entryList(QStringList(QString("*.%2.%1").arg(extension, *cProtoVer)));
+ sl.replaceInStrings(QRegExp(QString("^(.*)\\.%2\\.%1$").arg(extension, *cProtoVer)), "\\1");
+
+ DemosList->clear();
+ DemosList->addItems(sl);
+
+ for (int i = 0; i < DemosList->count(); ++i)
+ {
+ DemosList->item(i)->setData(Qt::UserRole, dir.absoluteFilePath(QString("%1.%3.%2").arg(sl[i], extension, *cProtoVer)));
+ DemosList->item(i)->setIcon(recType == RT_Demo ? QIcon(":/res/file_demo.png") : QIcon(":/res/file_save.png"));
+ }
+}
+
+void PagePlayDemo::renameRecord()
+{
+ QListWidgetItem * curritem = DemosList->currentItem();
+ if (!curritem)
+ {
+ QMessageBox::critical(this,
+ tr("Error"),
+ tr("Please select record from the list"),
+ tr("OK"));
+ return ;
+ }
+ QFile rfile(curritem->data(Qt::UserRole).toString());
+
+ QFileInfo finfo(rfile);
+
+ bool ok;
+
+ QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok);
+
+ if(ok && newname.size())
+ {
+ QString newfullname = QString("%1/%2.%3.%4")
+ .arg(finfo.absolutePath())
+ .arg(newname)
+ .arg(*cProtoVer)
+ .arg(finfo.suffix());
+
+ ok = rfile.rename(newfullname);
+ if(!ok)
+ QMessageBox::critical(this, tr("Error"), tr("Cannot rename to") + newfullname);
+ else
+ FillFromDir(recType);
+ }
+}
+
+void PagePlayDemo::removeRecord()
+{
+ QListWidgetItem * curritem = DemosList->currentItem();
+ if (!curritem)
+ {
+ QMessageBox::critical(this,
+ tr("Error"),
+ tr("Please select record from the list"),
+ tr("OK"));
+ return ;
+ }
+ QFile rfile(curritem->data(Qt::UserRole).toString());
+
+ bool ok;
+
+ ok = rfile.remove();
+ if(!ok)
+ QMessageBox::critical(this, tr("Error"), tr("Cannot delete file"));
+ else
+ FillFromDir(recType);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/pageplayrecord.h Mon May 09 18:00:39 2011 +0200
@@ -0,0 +1,58 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef PLAYRECORDPAGE_H
+#define PLAYRECORDPAGE_H
+
+#include <QDir>
+
+#include "AbstractPage.h"
+
+class QPushButton;
+class QListWidget;
+
+class PagePlayDemo : public AbstractPage
+{
+ Q_OBJECT
+
+public:
+ enum RecordType {
+ RT_Demo,
+ RT_Save
+ };
+
+ PagePlayDemo(QWidget* parent = 0);
+
+ void FillFromDir(RecordType rectype);
+
+ QPushButton *BtnBack;
+ QPushButton *BtnPlayDemo;
+ QPushButton *BtnRenameRecord;
+ QPushButton *BtnRemoveRecord;
+ QListWidget *DemosList;
+
+private:
+ RecordType recType;
+
+private slots:
+ void renameRecord();
+ void removeRecord();
+};
+
+
+#endif // PLAYRECORDPAGE_H
--- a/QTfrontend/pageroomslist.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pageroomslist.h Mon May 09 18:00:39 2011 +0200
@@ -1,10 +1,29 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
#ifndef PAGE_ROOMLIST_H
#define PAGE_ROOMLIST_H
-#include "pages.h"
+#include "AbstractPage.h"
+#include "SDLs.h"
class HWChatWidget;
+class AmmoSchemeModel;
class PageRoomsList : public AbstractPage
{
--- a/QTfrontend/pages.h Mon May 09 16:56:29 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef PAGES_H
-#define PAGES_H
-
-#include <QWidget>
-#include <QPushButton>
-#include <QFont>
-#include <QGridLayout>
-#include <QSignalMapper>
-
-#include "binds.h"
-#include "hwform.h"
-#include "mapContainer.h"
-#include "togglebutton.h"
-
-class QPushButton;
-class QGroupBox;
-class QComboBox;
-class QLabel;
-class QToolBox;
-class QLineEdit;
-class QListWidget;
-class QCheckBox;
-class QSpinBox;
-class QTextEdit;
-class QRadioButton;
-class QTableView;
-class QTextBrowser;
-class QTableWidget;
-class QAction;
-class QDataWidgetMapper;
-class QAbstractItemModel;
-class QSettings;
-class QSlider;
-
-class AbstractPage : public QWidget
-{
- Q_OBJECT
-
- public:
-
- protected:
- AbstractPage(QWidget* parent = 0) {
- Q_UNUSED(parent);
-
- font14 = new QFont("MS Shell Dlg", 14);
- //setFocusPolicy(Qt::StrongFocus);
- }
- virtual ~AbstractPage() {};
-
- QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, bool iconed = false) {
- QPushButton* butt = new QPushButton(this);
- if (!iconed) {
- butt->setFont(*font14);
- butt->setText(btname);
- //butt->setStyleSheet("background-color: #0d0544");
- } else {
- const QIcon& lp=QIcon(btname);
- QSize sz = lp.actualSize(QSize(65535, 65535));
- butt->setIcon(lp);
- butt->setFixedSize(sz);
- butt->setIconSize(sz);
- butt->setFlat(true);
- butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- }
- grid->addWidget(butt, wy, wx);
- return butt;
- };
-
- QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool iconed = false) {
- QPushButton* butt = new QPushButton(this);
- if (!iconed) {
- butt->setFont(*font14);
- butt->setText(btname);
- } else {
- const QIcon& lp=QIcon(btname);
- QSize sz = lp.actualSize(QSize(65535, 65535));
- butt->setIcon(lp);
- butt->setFixedSize(sz);
- butt->setIconSize(sz);
- butt->setFlat(true);
- butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- }
- grid->addWidget(butt, wy, wx, rowSpan, columnSpan);
- return butt;
- };
-
- QPushButton* addButton(QString btname, QBoxLayout* box, int where, bool iconed = false) {
- QPushButton* butt = new QPushButton(this);
- if (!iconed) {
- butt->setFont(*font14);
- butt->setText(btname);
- } else {
- const QIcon& lp=QIcon(btname);
- QSize sz = lp.actualSize(QSize(65535, 65535));
- butt->setIcon(lp);
- butt->setFixedSize(sz);
- butt->setIconSize(sz);
- butt->setFlat(true);
- butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- }
- box->addWidget(butt, where);
- return butt;
- };
-
- QFont * font14;
-};
-
-#endif // PAGES_H
--- a/QTfrontend/pagescheme.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagescheme.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,8 @@
#ifndef PAGE_SCHEME_H
#define PAGE_SCHEME_H
-#include "pages.h"
+#include "AbstractPage.h"
+#include "togglebutton.h"
class FreqSpinBox;
--- a/QTfrontend/pageselectweapon.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pageselectweapon.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_SELECTWEAPON_H
#define PAGE_SELECTWEAPON_H
-#include "pages.h"
+#include "AbstractPage.h"
class SelWeaponWidget;
--- a/QTfrontend/pagesingleplayer.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagesingleplayer.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_SINGLE_PLAYER_H
#define PAGE_SINGLE_PLAYER_H
-#include "pages.h"
+#include "AbstractPage.h"
class GameCFGWidget;
--- a/QTfrontend/pagetraining.h Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/pagetraining.h Mon May 09 18:00:39 2011 +0200
@@ -19,7 +19,7 @@
#ifndef PAGE_TRAINING_H
#define PAGE_TRAINING_H
-#include "pages.h"
+#include "AbstractPage.h"
class PageTraining : public AbstractPage
{
--- a/QTfrontend/playrecordpage.cpp Mon May 09 16:56:29 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QFont>
-#include <QGridLayout>
-#include <QPushButton>
-#include <QListWidget>
-#include <QListWidgetItem>
-#include <QFileInfo>
-#include <QMessageBox>
-#include <QInputDialog>
-
-#include "hwconsts.h"
-#include "playrecordpage.h"
-
-PagePlayDemo::PagePlayDemo(QWidget* parent) : AbstractPage(parent)
-{
- QFont * font14 = new QFont("MS Shell Dlg", 14);
- QGridLayout * pageLayout = new QGridLayout(this);
- pageLayout->setColumnStretch(0, 1);
- pageLayout->setColumnStretch(1, 2);
- pageLayout->setColumnStretch(2, 1);
- pageLayout->setRowStretch(2, 100);
-
- BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true);
-
- BtnPlayDemo = new QPushButton(this);
- BtnPlayDemo->setFont(*font14);
- BtnPlayDemo->setText(QPushButton::tr("Play demo"));
- pageLayout->addWidget(BtnPlayDemo, 3, 2);
-
- BtnRenameRecord = new QPushButton(this);
- BtnRenameRecord->setText(QPushButton::tr("Rename"));
- pageLayout->addWidget(BtnRenameRecord, 0, 2);
-
- BtnRemoveRecord = new QPushButton(this);
- BtnRemoveRecord->setText(QPushButton::tr("Delete"));
- pageLayout->addWidget(BtnRemoveRecord, 1, 2);
-
- DemosList = new QListWidget(this);
- DemosList->setGeometry(QRect(170, 10, 311, 311));
- pageLayout->addWidget(DemosList, 0, 1, 3, 1);
-
- connect(BtnRenameRecord, SIGNAL(clicked()), this, SLOT(renameRecord()));
- connect(BtnRemoveRecord, SIGNAL(clicked()), this, SLOT(removeRecord()));
-}
-
-void PagePlayDemo::FillFromDir(RecordType rectype)
-{
- QDir dir;
- QString extension;
-
- recType = rectype;
-
- dir.cd(cfgdir->absolutePath());
- if (rectype == RT_Demo)
- {
- dir.cd("Demos");
- extension = "hwd";
- BtnPlayDemo->setText(QPushButton::tr("Play demo"));
- } else
- {
- dir.cd("Saves");
- extension = "hws";
- BtnPlayDemo->setText(QPushButton::tr("Load"));
- }
- dir.setFilter(QDir::Files);
-
- QStringList sl = dir.entryList(QStringList(QString("*.%2.%1").arg(extension, *cProtoVer)));
- sl.replaceInStrings(QRegExp(QString("^(.*)\\.%2\\.%1$").arg(extension, *cProtoVer)), "\\1");
-
- DemosList->clear();
- DemosList->addItems(sl);
-
- for (int i = 0; i < DemosList->count(); ++i)
- {
- DemosList->item(i)->setData(Qt::UserRole, dir.absoluteFilePath(QString("%1.%3.%2").arg(sl[i], extension, *cProtoVer)));
- DemosList->item(i)->setIcon(recType == RT_Demo ? QIcon(":/res/file_demo.png") : QIcon(":/res/file_save.png"));
- }
-}
-
-void PagePlayDemo::renameRecord()
-{
- QListWidgetItem * curritem = DemosList->currentItem();
- if (!curritem)
- {
- QMessageBox::critical(this,
- tr("Error"),
- tr("Please select record from the list"),
- tr("OK"));
- return ;
- }
- QFile rfile(curritem->data(Qt::UserRole).toString());
-
- QFileInfo finfo(rfile);
-
- bool ok;
-
- QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok);
-
- if(ok && newname.size())
- {
- QString newfullname = QString("%1/%2.%3.%4")
- .arg(finfo.absolutePath())
- .arg(newname)
- .arg(*cProtoVer)
- .arg(finfo.suffix());
-
- ok = rfile.rename(newfullname);
- if(!ok)
- QMessageBox::critical(this, tr("Error"), tr("Cannot rename to") + newfullname);
- else
- FillFromDir(recType);
- }
-}
-
-void PagePlayDemo::removeRecord()
-{
- QListWidgetItem * curritem = DemosList->currentItem();
- if (!curritem)
- {
- QMessageBox::critical(this,
- tr("Error"),
- tr("Please select record from the list"),
- tr("OK"));
- return ;
- }
- QFile rfile(curritem->data(Qt::UserRole).toString());
-
- bool ok;
-
- ok = rfile.remove();
- if(!ok)
- QMessageBox::critical(this, tr("Error"), tr("Cannot delete file"));
- else
- FillFromDir(recType);
-}
--- a/QTfrontend/playrecordpage.h Mon May 09 16:56:29 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef PLAYRECORDPAGE_H
-#define PLAYRECORDPAGE_H
-
-#include <QDir>
-
-#include "pages.h"
-
-class QPushButton;
-class QListWidget;
-
-class PagePlayDemo : public AbstractPage
-{
- Q_OBJECT
-
-public:
- enum RecordType {
- RT_Demo,
- RT_Save
- };
-
- PagePlayDemo(QWidget* parent = 0);
-
- void FillFromDir(RecordType rectype);
-
- QPushButton *BtnBack;
- QPushButton *BtnPlayDemo;
- QPushButton *BtnRenameRecord;
- QPushButton *BtnRemoveRecord;
- QListWidget *DemosList;
-
-private:
- RecordType recType;
-
-private slots:
- void renameRecord();
- void removeRecord();
-};
-
-
-#endif // PLAYRECORDPAGE_H
--- a/QTfrontend/statsPage.cpp Mon May 09 16:56:29 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2010-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QLabel>
-#include <QGridLayout>
-#include <QGraphicsScene>
-#include <QGroupBox>
-#include <QSizePolicy>
-#include "statsPage.h"
-#include "team.h"
-
-FitGraphicsView::FitGraphicsView(QWidget* parent) : QGraphicsView(parent)
-{
-
-}
-
-void FitGraphicsView::resizeEvent(QResizeEvent * event)
-{
- Q_UNUSED(event);
-
- fitInView(sceneRect());
-}
-
-PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent)
-{
- QGridLayout * pageLayout = new QGridLayout(this);
- pageLayout->setSpacing(20);
- pageLayout->setColumnStretch(0, 1);
- pageLayout->setColumnStretch(1, 1);
-
- BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true);
- BtnBack->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-
- 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("<h1><img src=\":/res/StatsD.png\"> " + PageGameStats::tr("Details") + "</h1>");
- l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- labelGameStats->setTextFormat(Qt::RichText);
- labelGameStats->setAlignment(Qt::AlignTop);
- labelGameStats->setWordWrap(true);
- 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("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>");
- l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- gbl->addWidget(l);
- gbl->addWidget(graphic);
- graphic->scale(1.0, -1.0);
- graphic->setBackgroundBrush(QBrush(Qt::black));
-
- 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("<h1><img src=\":/res/StatsR.png\"> " + PageGameStats::tr("Ranking") + "</h1>");
- 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)
-{
- labelGameStats->setText(labelGameStats->text() + msg);
-}
-
-void PageGameStats::clear()
-{
- labelGameStats->setText("");
- healthPoints.clear();
- labelGameRank->setText("");
- playerPosition = 0;
- lastColor = 0;
-}
-
-void PageGameStats::renderStats()
-{
- QGraphicsScene * scene = new QGraphicsScene();
-
- QMap<quint32, QVector<quint32> >::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<quint32> 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)
-{
- switch(type) {
- case 'r' : {
- labelGameWin->setText(QString("<h1 align=\"center\">%1</h1>").arg(info));
- break;
- }
- case 'D' : {
- int i = info.indexOf(' ');
- 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>";
- AddStatText(message);
- break;
- }
- case 'k' : {
- int i = info.indexOf(' ');
- int num = info.left(i).toInt();
- 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>";
- AddStatText(message);
- break;
- }
- case 'K' : {
- int num = info.toInt();
- 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>";
- 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;
- }
- case 'T': { // local team stats
- //AddStatText("<p>local team: " + info + "</p>");
- QStringList infol = info.split(":");
- HWTeam team(infol[0]);
- if(team.FileExists()) // do some better test to avoid influence from scripted/predefined teams?
- {
- team.LoadFromFile();
- team.Rounds++;
- if(infol[1].toInt() > 0) // might require some better test for winning condition (or changed flag) ... WIP!
- 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(' ');
-
- int kills = playerinfo.left(i).toInt();
- QString playername = playerinfo.mid(i + 1);
- QString image;
-
- if (lastColor == c) playerPosition--;
- lastColor = c;
-
- switch (playerPosition)
- {
- case 1:
- image = "<img src=\":/res/StatsMedal1.png\">";
- break;
- case 2:
- image = "<img src=\":/res/StatsMedal2.png\">";
- break;
- case 3:
- image = "<img src=\":/res/StatsMedal3.png\">";
- break;
- default:
- image = "<img src=\":/res/StatsMedal4.png\">";
- break;
- }
-
- QString message;
- QString killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills);
-
- message = QString("<p><h2>%1 %2. <font color=\"%4\">%3</font> ").arg(image, QString::number(playerPosition), playername, clanColor.name()) + killstring + "</h2></p>";
-
- labelGameRank->setText(labelGameRank->text() + message);
- break;
- }
- case 's' : {
- int i = info.indexOf(' ');
- int num = info.left(i).toInt();
- 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>";
- AddStatText(message);
- break;
- }
- case 'S' : {
- int i = info.indexOf(' ');
- int num = info.left(i).toInt();
- 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>";
- AddStatText(message);
- break;
- }
- case 'B' : {
- int i = info.indexOf(' ');
- int num = info.left(i).toInt();
- 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>";
- AddStatText(message);
- break;
- }
-
- }
-}
--- a/QTfrontend/statsPage.h Mon May 09 16:56:29 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2010-2011 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef STATSPAGE_H
-#define STATSPAGE_H
-
-#include <QVector>
-#include <QMap>
-#include <QGraphicsView>
-#include "pages.h"
-
-class FitGraphicsView : public QGraphicsView
-{
- Q_OBJECT
-
-public:
- FitGraphicsView(QWidget* parent = 0);
-
-protected:
- void resizeEvent(QResizeEvent * event);
-};
-
-class PageGameStats : public AbstractPage
-{
- Q_OBJECT
-
-public:
- PageGameStats(QWidget* parent = 0);
-
- QPushButton *BtnBack;
- QLabel *labelGameStats;
- QLabel *labelGameWin;
- QLabel *labelGameRank;
- FitGraphicsView * graphic;
-
-public slots:
- void GameStats(char type, const QString & info);
- void clear();
- void renderStats();
-
-private:
- void AddStatText(const QString & msg);
-
- QMap<quint32, QVector<quint32> > healthPoints;
- unsigned int playerPosition;
- quint32 lastColor;
-};
-
-#endif // STATSPAGE_H
--- a/QTfrontend/ui_hwform.cpp Mon May 09 16:56:29 2011 +0200
+++ b/QTfrontend/ui_hwform.cpp Mon May 09 18:00:39 2011 +0200
@@ -42,8 +42,8 @@
#include "pageselectweapon.h"
#include "pagecampaign.h"
#include "pagemain.h"
-#include "statsPage.h"
-#include "playrecordpage.h"
+#include "pagegamestats.h"
+#include "pageplayrecord.h"
#include "hwconsts.h"
void Ui_HWForm::setupUi(HWForm *HWForm)