diff options
| author | manuel <manuel@mausz.at> | 2011-04-12 14:45:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-12 14:45:24 +0200 |
| commit | dbeba838ea813b620ec571265c8ea417403fc81c (patch) | |
| tree | cf085b766ba8dad8146190dc7f438160b839feb4 /pacman-c++/mainwidget.cpp | |
| parent | b695f67ef718724144a3a5c4be42be373b0f691f (diff) | |
| download | foop-dbeba838ea813b620ec571265c8ea417403fc81c.tar.gz foop-dbeba838ea813b620ec571265c8ea417403fc81c.tar.bz2 foop-dbeba838ea813b620ec571265c8ea417403fc81c.zip | |
make the server a non gui application
this required a lot of reorganization:
- don't create ANY pixmaps. that requires QtGui
- don't create and QtWidgets
- thus SceneHolder is now a QGraphisScene itself
- and MainWidgets is a QWidget having SceneHolder as member variable
Diffstat (limited to 'pacman-c++/mainwidget.cpp')
| -rw-r--r-- | pacman-c++/mainwidget.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp index 518692c..028bfad 100644 --- a/pacman-c++/mainwidget.cpp +++ b/pacman-c++/mainwidget.cpp | |||
| @@ -7,19 +7,23 @@ | |||
| 7 | #include "pacman.pb.h" | 7 | #include "pacman.pb.h" |
| 8 | 8 | ||
| 9 | MainWidget::MainWidget(QWidget *parent) | 9 | MainWidget::MainWidget(QWidget *parent) |
| 10 | : SceneHolder(parent), m_currentKey(Transmission::none), m_running(false) | 10 | : QWidget(parent), m_currentKey(Transmission::none), m_running(false) |
| 11 | { | 11 | { |
| 12 | m_color = connectToServer(); | 12 | Color::Color color = connectToServer(); |
| 13 | if (m_color == Color::none) | 13 | if (color == Color::none) |
| 14 | { | 14 | { |
| 15 | QMessageBox::critical(this, "Error", "Failed to connect to server, falling back to local test mode"); | 15 | QMessageBox::critical(this, "Error", "Failed to connect to server, falling back to local test mode"); |
| 16 | // TODO: quit application here or sth | 16 | // TODO: quit application here or sth |
| 17 | return; | 17 | return; |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | /* create our scene */ | ||
| 21 | m_scene = new SceneHolder(this); | ||
| 22 | m_scene->setColor(color); | ||
| 23 | |||
| 20 | /* call updateMap after m_color ist set! */ | 24 | /* call updateMap after m_color ist set! */ |
| 21 | createGui(); | 25 | createGui(); |
| 22 | updateMap(Util::createDemoMap()); | 26 | m_scene->updateMap(Util::createDemoMap()); |
| 23 | 27 | ||
| 24 | connect(m_socket, SIGNAL(readyRead()), this, SLOT(tick())); | 28 | connect(m_socket, SIGNAL(readyRead()), this, SLOT(tick())); |
| 25 | 29 | ||
| @@ -27,7 +31,7 @@ MainWidget::MainWidget(QWidget *parent) | |||
| 27 | connect(sendTimer, SIGNAL(timeout()), this, SLOT(sendKeyUpdate())); | 31 | connect(sendTimer, SIGNAL(timeout()), this, SLOT(sendKeyUpdate())); |
| 28 | sendTimer->start(Constants::tick); | 32 | sendTimer->start(Constants::tick); |
| 29 | 33 | ||
| 30 | qDebug() << "mycolor=" << m_color; | 34 | qDebug() << "mycolor=" << m_scene->color(); |
| 31 | 35 | ||
| 32 | //TODO: play intro as soon as there are enough players | 36 | //TODO: play intro as soon as there are enough players |
| 33 | //connect(AudioPlayer::self(), SIGNAL(finished()), this, SLOT(startGame())); | 37 | //connect(AudioPlayer::self(), SIGNAL(finished()), this, SLOT(startGame())); |
| @@ -62,7 +66,7 @@ void MainWidget::createGui() | |||
| 62 | playerLayout->addWidget(new QLabel("", this), 0, 1); | 66 | playerLayout->addWidget(new QLabel("", this), 0, 1); |
| 63 | playerLayout->addWidget(new QLabel("", this), 1, 1); | 67 | playerLayout->addWidget(new QLabel("", this), 1, 1); |
| 64 | 68 | ||
| 65 | if (Color::order[i] == m_color) | 69 | if (Color::order[i] == m_scene->color()) |
| 66 | scoreLayout->insertWidget(0, scoreBox); | 70 | scoreLayout->insertWidget(0, scoreBox); |
| 67 | else | 71 | else |
| 68 | scoreLayout->addWidget(scoreBox); | 72 | scoreLayout->addWidget(scoreBox); |
| @@ -145,7 +149,7 @@ void MainWidget::tick() | |||
| 145 | ++i; | 149 | ++i; |
| 146 | } | 150 | } |
| 147 | } | 151 | } |
| 148 | updateMap(map); | 152 | m_scene->updateMap(map); |
| 149 | updateScore(packet); | 153 | updateScore(packet); |
| 150 | } | 154 | } |
| 151 | 155 | ||
