From: Ralf Jung Date: Thu, 17 Jul 2014 14:49:46 +0000 (+0200) Subject: more consistent display of player name X-Git-Url: https://git.ralfj.de/multypo.git/commitdiff_plain/4978fd909202554270ec12c87d78a990001b17e4?hp=7a18f439db0b8a7d55ffd0368bb0159afa79ab62 more consistent display of player name --- diff --git a/qt/player.cpp b/qt/player.cpp index c75bb46..036d547 100644 --- a/qt/player.cpp +++ b/qt/player.cpp @@ -27,22 +27,22 @@ void Player::handleKey(QString str) if (str == "Return") { name = currentWord; state = Waiting; - setLabel(name, READY_COLOR); + setLabel("", READY_COLOR); } break; case Waiting: break; case Typing: - setLabel(currentWord, BASE_COLOR, name+":"); + setLabel(currentWord, BASE_COLOR); break; } } -void Player::setLabel(QString body, QString color, QString header) +void Player::setLabel(QString body, QString color) { QString text = QString("").arg(color); - if (!header.isEmpty()) { - text += QString("%1
").arg(Qt::escape(header)); + if (state >= Waiting) { + text += QString("%1:
").arg(Qt::escape(name)); } text += Qt::escape(body); theLabel->setText(text); @@ -52,7 +52,7 @@ void Player::wordComplete(int points) { score += points; state = Waiting; - setLabel(currentWord, READY_COLOR, name+":"); + setLabel(currentWord, READY_COLOR); } QString Player::getCurrentWord() { @@ -63,11 +63,11 @@ QString Player::getCurrentWord() { void Player::nextWord() { Q_ASSERT(state == Waiting); currentWord = ""; - setLabel("", BASE_COLOR, name+":"); + setLabel("", BASE_COLOR); state = Typing; } void Player::showScore() { Q_ASSERT(state == Waiting); - setLabel(QString ("Spieler %1 hat %2 Punkte.").arg(name).arg(score), READY_COLOR); + setLabel(QString ("%1 Punkte").arg(score), READY_COLOR); } diff --git a/qt/player.h b/qt/player.h index f28028f..cb628cc 100644 --- a/qt/player.h +++ b/qt/player.h @@ -36,7 +36,7 @@ private: State state; - void setLabel(QString body, QString color, QString header = ""); + void setLabel(QString body, QString color); }; #endif // PLAYER_H