projects
/
multypo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e6207dc
)
works now, only game over screen missing
author
Constantin
<constantin@exxxtremesys.lu>
Fri, 19 Jul 2013 15:20:52 +0000
(17:20 +0200)
committer
Constantin
<constantin@exxxtremesys.lu>
Fri, 19 Jul 2013 15:20:52 +0000
(17:20 +0200)
qt/multypo.cpp
patch
|
blob
|
history
diff --git
a/qt/multypo.cpp
b/qt/multypo.cpp
index 973686bf411edb33d7fc3e1aaa2c5ddfb9225628..1667c0fcd87e1107e54018714bee1b0490f53ca9 100644
(file)
--- a/
qt/multypo.cpp
+++ b/
qt/multypo.cpp
@@
-43,8
+43,14
@@
void MultypoWindow::resetPlayerText() {
void MultypoWindow::nextWord() {
QByteArray tmp = words.readLine().trimmed();
QString word = QString::fromUtf8(tmp);
void MultypoWindow::nextWord() {
QByteArray tmp = words.readLine().trimmed();
QString word = QString::fromUtf8(tmp);
- mainLabel->setText(word);
- typingPlayers = players.size();
+ if (word.isEmpty()) { // game over
+ qDebug() << "TODO: implement gameover";
+ exit (0);
+ } else {
+ resetPlayerText();
+ mainLabel->setText(word);
+ typingPlayers = players.size();
+ }
}
void MultypoWindow::handleKeyPress(int device, QString string)
}
void MultypoWindow::handleKeyPress(int device, QString string)
@@
-68,6
+74,12
@@
void MultypoWindow::handleKeyPress(int device, QString string)
players[device]->score += typingPlayers;
QString readyString = QString("READY: %1 points").arg(typingPlayers);
players[device]->setWaiting(readyString);
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;
}
} else { // name entering phase
bool allHaveNames = true;
@@
-120,7
+132,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;
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);
}
XIFreeDeviceInfo(devices);