X-Git-Url: https://git.ralfj.de/multypo.git/blobdiff_plain/318e322c3cd72e6a7f692c6f7c7770c0e15720c8..7a18f439db0b8a7d55ffd0368bb0159afa79ab62:/qt/multypo.cpp diff --git a/qt/multypo.cpp b/qt/multypo.cpp index d58d247..fff1da7 100644 --- a/qt/multypo.cpp +++ b/qt/multypo.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -16,12 +17,13 @@ MultypoWindow::MultypoWindow(QWidget *parent) : xiInited(false) { /* Prepare colors */ - setStyleSheet("background-color: black; color: green; font-size: 45pt"); + setStyleSheet("background-color: black; font-size: 45pt"); /* Prepare conents */ setLayout(new QVBoxLayout(this)); - - mainLabel = new QLabel("Namen eingeben, dann Return", this); + mainLabel = new QLabel(this); + mainLabel->setTextFormat(Qt::RichText); + setLabel("Namen eingeben, dann Return", BASE_COLOR); layout()->addWidget(mainLabel); /* Fullscreen, no cursor */ @@ -35,12 +37,17 @@ MultypoWindow::~MultypoWindow() { } +void MultypoWindow::setLabel(QString text, QString color) +{ + mainLabel->setText(QString("%2").arg(color).arg(Qt::escape(text))); +} + void MultypoWindow::nextWord() { QByteArray tmp = words.readLine().trimmed(); currentWord = QString::fromUtf8(tmp); - qDebug() << "New word" << currentWord; + qDebug() << "New word:" << currentWord; if (currentWord.isEmpty()) { // game over - mainLabel->setText("GAME OVER"); + setLabel("GAME OVER", READY_COLOR); for (QMap::Iterator it = players.begin(); it != players.end(); ++it) { it.value()->showScore(); } @@ -49,7 +56,7 @@ void MultypoWindow::nextWord() { for (QMap::Iterator it = players.begin(); it != players.end(); ++it) { it.value()->nextWord(); } - mainLabel->setText(currentWord); + setLabel(currentWord, BASE_COLOR); state = Playing; } } @@ -90,14 +97,12 @@ void MultypoWindow::handleKeyPress(int device, QString string) if (state == Naming) { // someone's still naming (or nobody's there yet) - qDebug() << "checking for game started"; if (!players.empty() && allPlayersWaiting()) { + qDebug() << "Game starting"; nextWord(); } } else if (state == Playing) { // all players are waiting or typing - qDebug() << "current player line" << player->getCurrentWord(); - qDebug() << "current word" << currentWord; if (player->getState() == Player::Typing && player->getCurrentWord() == currentWord) { int points = typingPlayers()+1; player->wordComplete(points);