#include <QVBoxLayout>
#include <QLabel>
#include <QMap>
+#include <QTextDocument>
#include <X11/Xlib.h>
#include <X11/extensions/XInput2.h>
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 */
{
}
+void MultypoWindow::setLabel(QString text, QString color)
+{
+ mainLabel->setText(QString("<font color=%1>%2</span>").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<int, Player*>::Iterator it = players.begin(); it != players.end(); ++it) {
it.value()->showScore();
}
for (QMap<int, Player*>::Iterator it = players.begin(); it != players.end(); ++it) {
it.value()->nextWord();
}
- mainLabel->setText(currentWord);
+ setLabel(currentWord, BASE_COLOR);
state = Playing;
}
}
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);