summaryrefslogtreecommitdiffstats
path: root/pacman-c++
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2011-04-09 17:36:08 +0200
committermanuel <manuel@mausz.at>2011-04-09 17:36:08 +0200
commitc13a773ef924f7edaa93ab2d2b9f461324d0d447 (patch)
tree81b6d4d09af17185bc20bbdce753c9fd84e50154 /pacman-c++
parentd5d691acfb99257d0f02d296bc8ba8522cce5bda (diff)
downloadfoop-c13a773ef924f7edaa93ab2d2b9f461324d0d447.tar.gz
foop-c13a773ef924f7edaa93ab2d2b9f461324d0d447.tar.bz2
foop-c13a773ef924f7edaa93ab2d2b9f461324d0d447.zip
make audioplayer an empty object in server context
Diffstat (limited to 'pacman-c++')
-rw-r--r--pacman-c++/actor.cpp2
-rw-r--r--pacman-c++/animationmanager.cpp2
-rw-r--r--pacman-c++/audioplayer.cpp26
-rw-r--r--pacman-c++/client.cpp3
4 files changed, 21 insertions, 12 deletions
diff --git a/pacman-c++/actor.cpp b/pacman-c++/actor.cpp
index 011fbeb..51d3818 100644
--- a/pacman-c++/actor.cpp
+++ b/pacman-c++/actor.cpp
@@ -81,7 +81,7 @@ QSequentialAnimationGroup *Actor::setupEatingAnimation(Actor::Movement direction
81 fadeout->setEndValue(false); 81 fadeout->setEndValue(false);
82 82
83 QPropertyAnimation *move = new QPropertyAnimation(img, "pos", m_moving); 83 QPropertyAnimation *move = new QPropertyAnimation(img, "pos", m_moving);
84 move->setDuration(Constants::tick - 50); 84 move->setDuration(Constants::tick - 20); //TODO
85 move->setEndValue(QPoint(0, 0)); 85 move->setEndValue(QPoint(0, 0));
86 } 86 }
87 87
diff --git a/pacman-c++/animationmanager.cpp b/pacman-c++/animationmanager.cpp
index f4ddef7..3880b08 100644
--- a/pacman-c++/animationmanager.cpp
+++ b/pacman-c++/animationmanager.cpp
@@ -3,7 +3,7 @@
3#include <QtCore/QDebug> 3#include <QtCore/QDebug>
4 4
5// the universe's only animation manager 5// the universe's only animation manager
6AnimationManager *AnimationManager::instance = 0; 6AnimationManager *AnimationManager::instance = NULL;
7 7
8AnimationManager::AnimationManager() 8AnimationManager::AnimationManager()
9{ 9{
diff --git a/pacman-c++/audioplayer.cpp b/pacman-c++/audioplayer.cpp
index 238e05d..c360a23 100644
--- a/pacman-c++/audioplayer.cpp
+++ b/pacman-c++/audioplayer.cpp
@@ -29,11 +29,12 @@ public:
29}; 29};
30 30
31// the universe's only audio player 31// the universe's only audio player
32AudioPlayer *AudioPlayer::m_instance = 0; 32AudioPlayer *AudioPlayer::m_instance = NULL;
33 33
34AudioPlayer::AudioPlayer() 34AudioPlayer::AudioPlayer()
35 : m_working(false) 35 : m_working(false)
36{ 36{
37#ifndef SERVER
37 m_player = new Phonon::MediaObject(this); 38 m_player = new Phonon::MediaObject(this);
38 connect(m_player, SIGNAL(finished()), this, SLOT(finished_p())); 39 connect(m_player, SIGNAL(finished()), this, SLOT(finished_p()));
39 connect(m_player, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish_p())); 40 connect(m_player, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish_p()));
@@ -44,7 +45,6 @@ AudioPlayer::AudioPlayer()
44 Phonon::createPath(m_player, m_output); 45 Phonon::createPath(m_player, m_output);
45 46
46 preload(); 47 preload();
47#ifndef SERVER
48 test(); 48 test();
49#endif // SERVER 49#endif // SERVER
50} 50}
@@ -63,26 +63,32 @@ bool AudioPlayer::isWorking() const
63 63
64void AudioPlayer::stop() 64void AudioPlayer::stop()
65{ 65{
66 if (!isWorking())
67 return;
66 m_player->stop(); 68 m_player->stop();
67} 69}
68 70
69void AudioPlayer::setMuted(bool mute) 71void AudioPlayer::setMuted(bool mute)
70{ 72{
73 if (!isWorking())
74 return;
71 m_output->setMuted(mute); 75 m_output->setMuted(mute);
72} 76}
73 77
74bool AudioPlayer::isMuted() const 78bool AudioPlayer::isMuted() const
75{ 79{
80 if (!isWorking())
81 return true;
76 return m_output->isMuted(); 82 return m_output->isMuted();
77} 83}
78 84
79void AudioPlayer::play(AudioPlayer::Sound sound) 85void AudioPlayer::play(AudioPlayer::Sound sound)
80{ 86{
81#ifdef SERVER 87 if (!isWorking())
82 return; 88 {
83#endif // SERVER
84 if (!m_working)
85 emit finished_p(); 89 emit finished_p();
90 return;
91 }
86 92
87 m_player->stop(); 93 m_player->stop();
88 m_player->setCurrentSource(Phonon::MediaSource(m_sounds[sound])); 94 m_player->setCurrentSource(Phonon::MediaSource(m_sounds[sound]));
@@ -91,27 +97,29 @@ void AudioPlayer::play(AudioPlayer::Sound sound)
91 97
92void AudioPlayer::clear() 98void AudioPlayer::clear()
93{ 99{
94 if (!m_working) 100 if (!isWorking())
95 return; 101 return;
96 m_player->clear(); 102 m_player->clear();
97} 103}
98 104
99void AudioPlayer::enqueue(AudioPlayer::Sound sound) 105void AudioPlayer::enqueue(AudioPlayer::Sound sound)
100{ 106{
101 if (!m_working) 107 if (!isWorking())
102 return; 108 return;
103 m_player->enqueue(Phonon::MediaSource(m_sounds[sound])); 109 m_player->enqueue(Phonon::MediaSource(m_sounds[sound]));
104} 110}
105 111
106void AudioPlayer::clearQueue() const 112void AudioPlayer::clearQueue() const
107{ 113{
108 if (!m_working) 114 if (!isWorking())
109 return; 115 return;
110 m_player->clearQueue(); 116 m_player->clearQueue();
111} 117}
112 118
113Phonon::State AudioPlayer::state() 119Phonon::State AudioPlayer::state()
114{ 120{
121 if (!isWorking())
122 return Phonon::ErrorState;
115 return m_player->state(); 123 return m_player->state();
116} 124}
117 125
diff --git a/pacman-c++/client.cpp b/pacman-c++/client.cpp
index d4324b7..fbcde6d 100644
--- a/pacman-c++/client.cpp
+++ b/pacman-c++/client.cpp
@@ -19,12 +19,13 @@ void Client::createMenu()
19 fileMenu->addAction(quitAction); 19 fileMenu->addAction(quitAction);
20 20
21 ClickLabel *toggleSound = new ClickLabel("Toggle Sound", this); 21 ClickLabel *toggleSound = new ClickLabel("Toggle Sound", this);
22 toggleSound->setToolTip("Toggle Sound");
22 toggleSound->setFixedWidth(20); 23 toggleSound->setFixedWidth(20);
23 toggleSound->setFixedHeight(16); 24 toggleSound->setFixedHeight(16);
24 toggleSound->setAlignment(Qt::AlignBottom); 25 toggleSound->setAlignment(Qt::AlignBottom);
25 26
26 bool sound = AudioPlayer::self()->isWorking(); 27 bool sound = AudioPlayer::self()->isWorking();
27 bool muted = sound && m_settings->value("muted", false).toBool(); 28 bool muted = !(sound && m_settings->value("muted", false).toBool());
28 AudioPlayer::self()->setMuted(muted); 29 AudioPlayer::self()->setMuted(muted);
29 30
30 QImage img(muted ? ":/soundoff" : ":/soundon"); 31 QImage img(muted ? ":/soundoff" : ":/soundon");