X-Git-Url: https://git.ralfj.de/multypo.git/blobdiff_plain/e6207dc52430a9fcbfd7df03f46c2876fc05154b..04ba0d5a99f63208188c4301aa21b743c42141cb:/qt/multypo.cpp diff --git a/qt/multypo.cpp b/qt/multypo.cpp index 973686b..8dea3e0 100644 --- a/qt/multypo.cpp +++ b/qt/multypo.cpp @@ -43,8 +43,17 @@ void MultypoWindow::resetPlayerText() { void MultypoWindow::nextWord() { QByteArray tmp = words.readLine().trimmed(); QString word = QString::fromUtf8(tmp); - mainLabel->setText(word); - typingPlayers = players.size(); + if (word.isEmpty()) { // game over + mainLabel->setText("GAME OVER"); + for (QMap::Iterator it = players.begin(); it != players.end(); ++it) { + QString tmp = QString ("Spieler %1 hat %2 Punkte.").arg(it.value()->getName()).arg(it.value()->score); + it.value()->setWaiting(tmp); + } + } else { + resetPlayerText(); + mainLabel->setText(word); + typingPlayers = players.size(); + } } void MultypoWindow::handleKeyPress(int device, QString string) @@ -68,6 +77,12 @@ void MultypoWindow::handleKeyPress(int device, QString string) players[device]->score += typingPlayers; QString readyString = QString("READY: %1 points").arg(typingPlayers); players[device]->setWaiting(readyString); + qDebug() << "typingPlayers " << typingPlayers; + typingPlayers--; + qDebug() << "typingPlayers " << typingPlayers; + if (typingPlayers <= 0) { + nextWord(); + } } } else { // name entering phase bool allHaveNames = true; @@ -120,7 +135,7 @@ bool MultypoWindow::handleX11Event(XEvent *event) for (int i = 0; i < ndevices; ++i) { if (devices[i].use != XIMasterKeyboard) continue; qDebug() << "Found master keyboard with ID" << devices[i].deviceid; - //XISetFocus(dpy, devices[i].deviceid, winId(), CurrentTime); + XISetFocus(dpy, devices[i].deviceid, winId(), CurrentTime); } XIFreeDeviceInfo(devices);