export LC_ALL=C # dont do unicode stuff in egrep
while true; do
- sort -R "$WORDSFILE" | sed 's/\/.*//' | egrep '^[A-Za-z]{5,}$' | head -n "$WORDSTOPLAY" | tr [:upper:] [:lower:] | qt/multypo
+ sort -R "$WORDSFILE" | sed 's/\/.*//' | egrep '^[A-Za-z]{5,}$' | head -n "$WORDSTOPLAY" | tr [:upper:] [:lower:] | qt/multypo
echo "Press Ctrl-C to quit"
sleep 3
done
#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);
void nextWord();
bool allPlayersWaiting();
int typingPlayers();
+ void setLabel(QString text, QString color);
State state; // naming iff (no players or any player is naming)
QString currentWord; // defined iff state == Playing
#include <QLayout>
#include <QDebug>
+#include <QTextDocument>
Player::Player(QWidget* parent) : score(0), state(Naming) {
theLabel = new QLabel (parent);
+ theLabel->setTextFormat(Qt::RichText);
parent->layout()->addWidget(theLabel);
qDebug() << "Player created";
}
// see if this does anything useful
switch (state) {
case Naming:
- theLabel->setText(currentWord);
+ setLabel(currentWord, BASE_COLOR);
if (str == "Return") {
name = currentWord;
state = Waiting;
- theLabel->setText("<READY>");
+ setLabel(name, READY_COLOR);
}
break;
case Waiting:
break;
case Typing:
- theLabel->setText(currentWord);
+ setLabel(currentWord, BASE_COLOR, name+":");
break;
}
}
+void Player::setLabel(QString body, QString color, QString header)
+{
+ QString text = QString("<font color=%1>").arg(color);
+ if (!header.isEmpty()) {
+ text += QString("<font size=-3>%1</font><br>").arg(Qt::escape(header));
+ }
+ text += Qt::escape(body);
+ theLabel->setText(text);
+}
+
void Player::wordComplete(int points)
{
score += points;
state = Waiting;
- theLabel->setText("<COMPLETE>");
+ setLabel(currentWord, READY_COLOR, name+":");
}
QString Player::getCurrentWord() {
}
void Player::nextWord() {
+ Q_ASSERT(state == Waiting);
currentWord = "";
- theLabel->setText(currentWord);
+ setLabel("<Eingabe erscheint hier>", BASE_COLOR, name+":");
state = Typing;
}
void Player::showScore() {
Q_ASSERT(state == Waiting);
- theLabel->setText(QString ("Spieler %1 hat %2 Punkte.").arg(name).arg(score));
+ setLabel(QString ("Spieler %1 hat %2 Punkte.").arg(name).arg(score), READY_COLOR);
}
#include <QString>
#include <QLabel>
+#define BASE_COLOR "green"
+#define READY_COLOR "orange"
+#define BASE_SIZE "45pt"
+#define SMALL_SIZE "25pt"
+
class Player
{
public:
State state;
- void updateLabel();
+ void setLabel(QString body, QString color, QString header = "");
};
#endif // PLAYER_H
garden
-tree
-dddddddddddddddddddddddddd
+trees
+tests
chamber