-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboardwidget.h
executable file
·43 lines (34 loc) · 1.09 KB
/
boardwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef BOARDWIDGET_H
#define BOARDWIDGET_H
#include <QWidget>
#include <vector>
#include <queue>
#include "chinese_chess.h"
#include "gamestate.h"
#include "cellwidget.h"
#include "itemdispencer.h"
namespace ChineseChess
{
class BoardWidget : public QWidget, public Printer, public MouseClickReporter
{
Q_OBJECT
public:
explicit BoardWidget(QWidget *parent = 0);
void Print(const Mat &matrix);
void SetCommandExecutor(CommandExecutor *executor);
~BoardWidget();
private:
void updateCellPositions();
void paintEvent(QPaintEvent *);
void moveEvent(QMoveEvent *);
void resizeEvent(QResizeEvent *);
void onClick(int cell_id);
std::vector<CellWidget::ptr> cells_;
CommandExecutor *state_;
// нажатие ячейки помещает ее координаты в очередь.
// когда нажаты 2 ячейки (в очереди 2 элемента)
// из них формируется команда и отправляется в ядро игры.
std::queue<std::pair<int, int> > clicked_cells_;
};
}
#endif // BOARDWIDGET_H