# HG changeset patch # User unc0rr # Date 1231500472 0 # Node ID 8e0d62727f01b40a7be40367d5801ff164943397 # Parent d1ded2532d3fc46a7fa5c052319774fb4538a9c6 Fully separate statistics code from main form code diff -r d1ded2532d3f -r 8e0d62727f01 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Fri Jan 09 11:22:46 2009 +0000 +++ b/QTfrontend/hwform.cpp Fri Jan 09 11:27:52 2009 +0000 @@ -643,7 +643,7 @@ case gsStarted: { Music(false); GoToPage(ID_PAGE_INGAME); - ui.pageGameStats->labelGameStats->setText(""); + ui.pageGameStats->clear(); if (pRegisterServer) { pRegisterServer->unregister(); @@ -669,46 +669,11 @@ } } -void HWForm::AddStatText(const QString & msg) -{ - ui.pageGameStats->labelGameStats->setText( - ui.pageGameStats->labelGameStats->text() + msg); -} - -void HWForm::GameStats(char type, const QString & info) -{ - switch(type) { - case 'r' : { - AddStatText(QString("
The best shot award was won by %1 with %2 pts.
") - .arg(info.mid(i + 1), info.left(i)); - AddStatText(message); - break; - } - case 'k' : { - int i = info.indexOf(' '); - QString message = QLabel::tr("The best shot award was won by %1 with %2 kills.
") - .arg(info.mid(i + 1), info.left(i)); - AddStatText(message); - break; - } - case 'K' : { - QString message = QLabel::tr("A total of %1 Hedgehog(s) were killed during this round.
").arg(info); - AddStatText(message); - break; - } - } -} - void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo) { game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); - connect(game, SIGNAL(GameStats(char, const QString &)), this, SLOT(GameStats(char, const QString &))); + connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); } diff -r d1ded2532d3f -r 8e0d62727f01 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Fri Jan 09 11:22:46 2009 +0000 +++ b/QTfrontend/hwform.h Fri Jan 09 11:27:52 2009 +0000 @@ -78,7 +78,6 @@ void AddNetTeam(const HWTeam& team); void StartMPGame(); void GameStateChanged(GameState gameState); - void GameStats(char type, const QString & info); void ForcedDisconnect(); void ShowErrorMessage(const QString &); void GetRecord(bool isDemo, const QByteArray & record); @@ -124,7 +123,6 @@ HWNetRegisterServer* pRegisterServer; QTime eggTimer; SDLInteraction sdli; - void AddStatText(const QString & msg); void OnPageShown(quint8 id, quint8 lastid=0); }; diff -r d1ded2532d3f -r 8e0d62727f01 QTfrontend/statsPage.cpp --- a/QTfrontend/statsPage.cpp Fri Jan 09 11:22:46 2009 +0000 +++ b/QTfrontend/statsPage.cpp Fri Jan 09 11:27:52 2009 +0000 @@ -35,3 +35,42 @@ labelGameStats->setTextFormat(Qt::RichText); pageLayout->addWidget(labelGameStats, 0, 0, 1, 3); } + +void PageGameStats::AddStatText(const QString & msg) +{ + labelGameStats->setText(labelGameStats->text() + msg); +} + +void PageGameStats::clear() +{ + labelGameStats->setText(""); +} + +void PageGameStats::GameStats(char type, const QString & info) +{ + switch(type) { + case 'r' : { + AddStatText(QString("The best shot award was won by %1 with %2 pts.
") + .arg(info.mid(i + 1), info.left(i)); + AddStatText(message); + break; + } + case 'k' : { + int i = info.indexOf(' '); + QString message = tr("The best shot award was won by %1 with %2 kills.
") + .arg(info.mid(i + 1), info.left(i)); + AddStatText(message); + break; + } + case 'K' : { + QString message = tr("A total of %1 Hedgehog(s) were killed during this round.
").arg(info); + AddStatText(message); + break; + } + } +} diff -r d1ded2532d3f -r 8e0d62727f01 QTfrontend/statsPage.h --- a/QTfrontend/statsPage.h Fri Jan 09 11:22:46 2009 +0000 +++ b/QTfrontend/statsPage.h Fri Jan 09 11:27:52 2009 +0000 @@ -30,6 +30,13 @@ QPushButton *BtnBack; QLabel *labelGameStats; + +public slots: + void GameStats(char type, const QString & info); + void clear(); + +private: + void AddStatText(const QString & msg); }; #endif // STATSPAGE_H