summaryrefslogtreecommitdiffstats
path: root/pacman-c++/client/mainwidget.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-05-05 00:57:07 +0200
committermanuel <manuel@mausz.at>2011-05-05 00:57:07 +0200
commitce48af53646cd9e7ec762fc1ac176b3aa620b11d (patch)
treef8fbf2cae8c7d0cbac2696a8f4cf94410bfb4928 /pacman-c++/client/mainwidget.h
parente54ccad07e256ba877bd41d70bd358bd0085bd1e (diff)
downloadfoop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.tar.gz
foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.tar.bz2
foop-ce48af53646cd9e7ec762fc1ac176b3aa620b11d.zip
- refactorized the whole project and made a few subprojects
- replaced tcp with enet - added connect dialog - some smaller bugfixes
Diffstat (limited to 'pacman-c++/client/mainwidget.h')
-rw-r--r--pacman-c++/client/mainwidget.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/pacman-c++/client/mainwidget.h b/pacman-c++/client/mainwidget.h
new file mode 100644
index 0000000..99ff7d7
--- /dev/null
+++ b/pacman-c++/client/mainwidget.h
@@ -0,0 +1,80 @@
1#ifndef MAINWIDGET_H
2#define MAINWIDGET_H
3
4#include "sceneholder.h"
5#include "constants.h"
6#include "audio.h"
7#include "pacman.pb.h"
8#include <QtGui>
9#include <QtCore>
10
11extern "C" {
12#include "enet/enet.h"
13}
14
15class Actor;
16
17class MainWidget
18 : public QWidget
19{
20 Q_OBJECT
21
22public:
23 MainWidget(QWidget *parent = 0);
24 ~MainWidget();
25 bool connected();
26 void setAmbientMuted(bool muted);
27
28public slots:
29 void doConnect(QString srv = "127.0.0.1", unsigned int port = Constants::Networking::port);
30 void doDisconnect();
31
32protected:
33 /* handling of current key */
34 virtual void keyPressEvent(QKeyEvent *);
35 virtual void keyReleaseEvent(QKeyEvent *);
36
37signals:
38 void connected(bool connected);
39
40private slots:
41 void startGame();
42 void stopGame();
43 void playerScoreClicked();
44 void tick();
45 void tick(ENetEvent *event);
46 void sendKeyUpdate();
47
48private:
49 void createGui();
50 void createMenu();
51 void updateScore(const ProtoBuf::MapUpdate&);
52 bool isRunning();
53 Color::Color connectToServer(QString srv = "127.0.0.1", unsigned int port = Constants::Networking::port);
54 void closeENetPeer();
55 void deleteLayout(QLayout *layout);
56
57 /* GUI elements needed in the progress of the game */
58 QList<QGridLayout*> m_playerScoreLayouts;
59
60 /* key currently pressed by user */
61 Transmission::field_t m_currentKey;
62
63 /* translate Qt::Key to our key format */
64 Transmission::field_t translateKey(int key);
65
66 /* game running */
67 bool m_running;
68 GaplessAudioPlayer *m_ambientPlayer;
69
70 ENetHost *m_host;
71 ENetPeer *m_peer;
72 SceneHolder *m_scene;
73 unsigned int m_maxplayers;
74 QTimer *m_recvTimer;
75
76 /* allocate as member variable as this packet is large and used often */
77 ProtoBuf::MapUpdate m_updatepacket;
78};
79
80#endif // MAINWIDGET_H