-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClientMainWindow.h
69 lines (52 loc) · 1.66 KB
/
ClientMainWindow.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef CLIENTMAINWINDOW_H
#define CLIENTMAINWINDOW_H
#include <QMainWindow>
#include "AI.h"
#include "TcpClient.h"
#include "widgets/WelcomeWidget.h"
#include "widgets/SelectDifficultyWidget.h"
#include "widgets/GamePlayWidget.h"
namespace Ui {
class ClientMainWindow;
}
class ClientMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit ClientMainWindow(QWidget *parent = nullptr);
~ClientMainWindow();
private slots:
void onWelcomeWidgetClickedSinglePlayer();
void onWelcomeWidgetClickedMultiPlayer();
void onSelectDifficultyWidgetClickedOk();
void onSelectDifficultyWidgetClickedCancel();
void onGamePlayWidgetClickedLeave();
void onGamePlayWidgetClickedValidCell(Cell cell);
void onTcpClientReport(QString msg);
void onTcpClientReceivedData(QByteArray data);
void onTcpClientConnected();
void onTcpClientDisconnected();
void onTcpClientError(QAbstractSocket::SocketError err);
protected:
void closeEvent(QCloseEvent *event) override;
private:
Ui::ClientMainWindow *ui;
enum GameMode { GAME_MODE_INIT,
GAME_MODE_SINGLE,
GAME_MODE_MULTI_CONNECTING,
GAME_MODE_MULTI_WAITING,
GAME_MODE_MULTI_PLAYING };
GameMode gameMode_;
WelcomeWidget *welcomeWidget_;
SelectDifficultyWidget *selectDifficultyWidget_;
GamePlayWidget *gamePlayWidget_;
AI ai_;
TcpClient tcp_client;
QString messageStream;
PieceType multiPlayerPiece_;
void singlePlayerLogic(Cell cell);
void endGame(PieceType winner);
void report(QString str);
void processMessage(Message msg);
};
#endif // CLIENTMAINWINDOW_H