blob: 99ff7d7ac181fa95ce3cde0a0c59e976bc9b6f83 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#ifndef MAINWIDGET_H
#define MAINWIDGET_H
#include "sceneholder.h"
#include "constants.h"
#include "audio.h"
#include "pacman.pb.h"
#include <QtGui>
#include <QtCore>
extern "C" {
#include "enet/enet.h"
}
class Actor;
class MainWidget
: public QWidget
{
Q_OBJECT
public:
MainWidget(QWidget *parent = 0);
~MainWidget();
bool connected();
void setAmbientMuted(bool muted);
public slots:
void doConnect(QString srv = "127.0.0.1", unsigned int port = Constants::Networking::port);
void doDisconnect();
protected:
/* handling of current key */
virtual void keyPressEvent(QKeyEvent *);
virtual void keyReleaseEvent(QKeyEvent *);
signals:
void connected(bool connected);
private slots:
void startGame();
void stopGame();
void playerScoreClicked();
void tick();
void tick(ENetEvent *event);
void sendKeyUpdate();
private:
void createGui();
void createMenu();
void updateScore(const ProtoBuf::MapUpdate&);
bool isRunning();
Color::Color connectToServer(QString srv = "127.0.0.1", unsigned int port = Constants::Networking::port);
void closeENetPeer();
void deleteLayout(QLayout *layout);
/* 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);
/* game running */
bool m_running;
GaplessAudioPlayer *m_ambientPlayer;
ENetHost *m_host;
ENetPeer *m_peer;
SceneHolder *m_scene;
unsigned int m_maxplayers;
QTimer *m_recvTimer;
/* allocate as member variable as this packet is large and used often */
ProtoBuf::MapUpdate m_updatepacket;
};
#endif // MAINWIDGET_H
|