Skip to content

Commit

Permalink
User interfaced, enjoy the game
Browse files Browse the repository at this point in the history
  • Loading branch information
akhtyamovpavel committed Nov 24, 2014
1 parent cf2a3c2 commit 7eee759
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
40 changes: 36 additions & 4 deletions interface/graphicboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,36 @@ GraphicBoard::GraphicBoard(QWidget *parent) :
tableLayout->addWidget(buttons[i][j], i, j);
}
}
gamePanel = new QVBoxLayout;
gamePanel->addLayout(tableLayout);
gamePanel = new QHBoxLayout(this);
gameBoardPanel = new QVBoxLayout;
gameBoardPanel->addLayout(tableLayout);
wordPanel = new QHBoxLayout;
currentWord = new QLabel("");
commitButton = new QPushButton("Enter!");
wordPanel->addWidget(currentWord);
wordPanel->addWidget(commitButton);
gamePanel->addLayout(wordPanel);
gameBoardPanel->addLayout(wordPanel);



firstPlayerScore = new QLabel(tr("0"), this);
firstPlayerWords = new QListWidget(this);
firstPlayerPanel = new QVBoxLayout(this);
firstPlayerPanel->addWidget(firstPlayerScore);
firstPlayerPanel->addWidget(firstPlayerWords);

secondPlayerScore = new QLabel(tr("0"), this);
secondPlayerWords = new QListWidget(this);
secondPlayerPanel = new QVBoxLayout(this);
secondPlayerPanel->addWidget(secondPlayerScore);
secondPlayerPanel->addWidget(secondPlayerWords);

gamePanel->addLayout(secondPlayerPanel);
gamePanel->addLayout(gameBoardPanel);
gamePanel->addLayout(firstPlayerPanel);

setLayout(gamePanel);
//WsetLayout(tableLayout);

int players = QInputDialog::getInt(this, tr("Enter number of players"), tr("Введите число игроков"), 1, 1, 2);
Logger l;
l.printLog(DEBUG, players);
Expand Down Expand Up @@ -112,6 +132,18 @@ void GraphicBoard::afterCellChoosen(QPair<QPair<int, int>, QChar> coordinates)

void GraphicBoard::afterWordCommited(QString word) {
currentWord->setText(NULL);
if (sender() == gameManager->getFirstPlayer()) {
firstPlayerWords->addItem(word);
} else {
secondPlayerWords->addItem(word);
}
if (sender() == gameManager->getFirstPlayer()) {
int score = gameManager->getFirstPlayer()->getScore();
firstPlayerScore->setText(QString::number(score));
} else {
int score = gameManager->getSecondPlayer()->getScore();
secondPlayerScore->setText(QString::number(score));
}
}

void GraphicBoard::onPlayerResetWord(const QPair<int, int> &coordinates)
Expand Down
11 changes: 10 additions & 1 deletion interface/graphicboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QLabel>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QListWidget>

#include "buttoncell.h"
#include "gamemanager.h"
Expand All @@ -21,10 +22,18 @@ class GraphicBoard : public QWidget
QVector<QVector<ButtonCell*> > buttons;
QGridLayout* tableLayout;
GameManager* gameManager;
QVBoxLayout* gamePanel;
QVBoxLayout* gameBoardPanel;
QHBoxLayout* wordPanel;
QHBoxLayout* gamePanel;
QPushButton* commitButton;
QLabel* currentWord;
QListWidget* firstPlayerWords;
QListWidget* secondPlayerWords;
QLabel* firstPlayerScore;
QLabel* secondPlayerScore;
QVBoxLayout* firstPlayerPanel;
QVBoxLayout* secondPlayerPanel;

public:
explicit GraphicBoard(QWidget *parent = 0);

Expand Down

0 comments on commit 7eee759

Please sign in to comment.