#ifndef MULTIKBD_H
#define MULTIKBD_H

#include <QWidget>
#include <QMap>
#include <QFile>

#include "player.h"

class MultypoWindow : public QWidget
{
	Q_OBJECT
	
public:
    enum State {
        Naming,
        Playing,
        Scoring
    };
    
	explicit MultypoWindow(QWidget *parent = 0);
	~MultypoWindow();

	bool handleX11Event(XEvent *event);

private:
	void handleKeyPress(int device, QString string);
	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
    QMap<int, Player*> players;
    
	bool xiInited;
	int xiOpcode;
	QLabel *mainLabel;
	QFile words;
};

#endif // MULTIKBD_H
