X-Git-Url: https://git.ralfj.de/multypo.git/blobdiff_plain/036922ba5e90ae7f6f6abe3f99b1783dec5132fc..e8b07da1c5251e412f80fdeb94fb327b641fc956:/qt/multypo.cpp?ds=sidebyside diff --git a/qt/multypo.cpp b/qt/multypo.cpp index 0c5451e..e6befe2 100644 --- a/qt/multypo.cpp +++ b/qt/multypo.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -25,12 +26,26 @@ MultypoWindow::MultypoWindow(QWidget *parent) : /* Fullscreen, no cursor */ setWindowState(Qt::WindowFullScreen); setCursor(QCursor(Qt::BlankCursor)); + + words.open(stdin,QIODevice::ReadOnly); } MultypoWindow::~MultypoWindow() { } +void MultypoWindow::resetPlayerText() { + for (QMap::Iterator it = players.begin(); it != players.end(); ++it) { + it.value()->resetText(); + } +} + +void MultypoWindow::nextWord() { + QByteArray tmp = words.readLine(); + QString word = QString::fromUtf8(tmp); + mainLabel->setText(word); +} + void MultypoWindow::handleKeyPress(int device, QString string) { qDebug() << "Device" << device << "String" << string; @@ -44,6 +59,22 @@ void MultypoWindow::handleKeyPress(int device, QString string) players[device] = new Player(this); } players[device]->handleKey(string); + + if (gameStarted) { // ingame + + } else { // name entering phase + bool allHaveNames = true; + for (QMap::Iterator it = players.begin(); it != players.end(); ++it) { + if (! it.value()->hasName()) { + allHaveNames = false; + break; + } + } + if (!players.empty() && allHaveNames) { + gameStarted = true; + nextWord(); + } + } } bool MultypoWindow::handleX11Event(XEvent *event)