diff options
| author | manuel <manuel@mausz.at> | 2011-04-11 02:11:10 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-11 02:11:10 +0200 |
| commit | 57e3e48eb558b73077c2b5b4e531ee1cd75b0fbf (patch) | |
| tree | b71c6cf7b777cbf87875940f1b283779c1d2e0db /pacman-c++/mainwidget.cpp | |
| parent | 817dcc4e4493fb89c6d52b5e5ce1548b6a047d08 (diff) | |
| download | foop-57e3e48eb558b73077c2b5b4e531ee1cd75b0fbf.tar.gz foop-57e3e48eb558b73077c2b5b4e531ee1cd75b0fbf.tar.bz2 foop-57e3e48eb558b73077c2b5b4e531ee1cd75b0fbf.zip | |
- second cleanup: move game/round points inside array
- order is defined by Color::order[] used by server and client (gui too)
Diffstat (limited to 'pacman-c++/mainwidget.cpp')
| -rw-r--r-- | pacman-c++/mainwidget.cpp | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp index f5d4b7f..9c53513 100644 --- a/pacman-c++/mainwidget.cpp +++ b/pacman-c++/mainwidget.cpp | |||
| @@ -41,10 +41,10 @@ void MainWidget::createGui() | |||
| 41 | QVBoxLayout *layout = new QVBoxLayout(this); | 41 | QVBoxLayout *layout = new QVBoxLayout(this); |
| 42 | QHBoxLayout *scoreLayout = new QHBoxLayout(); | 42 | QHBoxLayout *scoreLayout = new QHBoxLayout(); |
| 43 | 43 | ||
| 44 | for (unsigned int i = 1; i < 4; ++i) | 44 | for (unsigned int i = 0; Color::order[i] != Color::none ; ++i) |
| 45 | { | 45 | { |
| 46 | QGroupBox *scoreBox = new QGroupBox(QString("Spieler %1").arg(i), this); | 46 | QGroupBox *scoreBox = new QGroupBox(QString("Spieler %1").arg(i + 1), this); |
| 47 | scoreBox->setObjectName(QString("actor%1").arg(i)); | 47 | scoreBox->setObjectName(QString("actor%1").arg(i + 1)); |
| 48 | scoreBox->setCheckable(true); | 48 | scoreBox->setCheckable(true); |
| 49 | connect(scoreBox, SIGNAL(clicked()), this, SLOT(playerScoreClicked())); | 49 | connect(scoreBox, SIGNAL(clicked()), this, SLOT(playerScoreClicked())); |
| 50 | scoreLayout->addWidget(scoreBox); | 50 | scoreLayout->addWidget(scoreBox); |
| @@ -80,24 +80,15 @@ void MainWidget::createGui() | |||
| 80 | 80 | ||
| 81 | void MainWidget::updateScore(const ProtoBuf::MapUpdate& packet) | 81 | void MainWidget::updateScore(const ProtoBuf::MapUpdate& packet) |
| 82 | { | 82 | { |
| 83 | QLabel *turnPointsLbl; | 83 | for(unsigned i = 0; Color::order[i] != Color::none; ++i) |
| 84 | QLabel *allPointsLbl; | 84 | { |
| 85 | 85 | QGridLayout *score = m_playerScoreLayouts.at(i); | |
| 86 | //TODO: change proto and move that inside an array | 86 | QLabel *turnPointsLbl = dynamic_cast<QLabel*>(score->itemAtPosition(0, 1)->widget()); |
| 87 | turnPointsLbl = dynamic_cast<QLabel*>(m_playerScoreLayouts.at(0)->itemAtPosition(0,1)->widget()); | 87 | turnPointsLbl->setText(QString::number(packet.round_points(i))); |
| 88 | allPointsLbl = dynamic_cast<QLabel*>(m_playerScoreLayouts.at(0)->itemAtPosition(1,1)->widget()); | 88 | |
| 89 | turnPointsLbl->setText(QString::number(packet.round_points_red())); | 89 | QLabel *allPointsLbl = dynamic_cast<QLabel*>(score->itemAtPosition(1, 1)->widget()); |
| 90 | allPointsLbl->setText(QString::number(packet.game_points_red())); | 90 | allPointsLbl->setText(QString::number(packet.round_points(i))); |
| 91 | 91 | } | |
| 92 | turnPointsLbl = dynamic_cast<QLabel*>(m_playerScoreLayouts.at(1)->itemAtPosition(0,1)->widget()); | ||
| 93 | allPointsLbl = dynamic_cast<QLabel*>(m_playerScoreLayouts.at(1)->itemAtPosition(1,1)->widget()); | ||
| 94 | turnPointsLbl->setText(QString::number(packet.round_points_blue())); | ||
| 95 | allPointsLbl->setText(QString::number(packet.game_points_blue())); | ||
| 96 | |||
| 97 | turnPointsLbl = dynamic_cast<QLabel*>(m_playerScoreLayouts.at(2)->itemAtPosition(0,1)->widget()); | ||
| 98 | allPointsLbl = dynamic_cast<QLabel*>(m_playerScoreLayouts.at(2)->itemAtPosition(1,1)->widget()); | ||
| 99 | turnPointsLbl->setText(QString::number(packet.round_points_green())); | ||
| 100 | allPointsLbl->setText(QString::number(packet.game_points_green())); | ||
| 101 | } | 92 | } |
| 102 | 93 | ||
| 103 | Transmission::field_t MainWidget::translateKey(int key) | 94 | Transmission::field_t MainWidget::translateKey(int key) |
