blob: 266f3297baa2d4f83d8e77a293faf074a0c20315 (
plain)
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
|
#ifndef MAINWIDGET_H
#define MAINWIDGET_H
#include "sceneholder.h"
#include "constants.h"
#include "pixmapitem.h"
#include <QtGui>
#include <QtCore>
#include <QTcpSocket>
class Actor;
class MainWidget
: public SceneHolder
{
Q_OBJECT
public:
MainWidget(QWidget *parent = 0);
protected:
// handling of current key
virtual void keyPressEvent(QKeyEvent* );
virtual void keyReleaseEvent(QKeyEvent* );
virtual void updateMap(const Transmission::map_t& map);
private:
void createGui();
void createMenu();
void updateScore();
bool isRunning();
Color::Color connectToServer();
private slots:
void startGame();
void playerScoreClicked();
void tick();
private:
// GUI elements needed in the progress of the game
QList<QGridLayout*> m_playerScoreLayouts;
// key currently pressed by user
Transmission::field_t m_currentKey;
// translate Qt::Key to our key format
Transmission::field_t translateKey(int key, int def=0);
// game running
bool m_running;
QTcpSocket *m_socket;
};
#endif // MAINWIDGET_H
|