From c13a773ef924f7edaa93ab2d2b9f461324d0d447 Mon Sep 17 00:00:00 2001 From: manuel Date: Sat, 9 Apr 2011 17:36:08 +0200 Subject: make audioplayer an empty object in server context --- pacman-c++/actor.cpp | 2 +- pacman-c++/animationmanager.cpp | 2 +- pacman-c++/audioplayer.cpp | 26 +++++++++++++++++--------- pacman-c++/client.cpp | 3 ++- 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 fadeout->setEndValue(false); QPropertyAnimation *move = new QPropertyAnimation(img, "pos", m_moving); - move->setDuration(Constants::tick - 50); + move->setDuration(Constants::tick - 20); //TODO move->setEndValue(QPoint(0, 0)); } 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 @@ #include // the universe's only animation manager -AnimationManager *AnimationManager::instance = 0; +AnimationManager *AnimationManager::instance = NULL; AnimationManager::AnimationManager() { 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: }; // the universe's only audio player -AudioPlayer *AudioPlayer::m_instance = 0; +AudioPlayer *AudioPlayer::m_instance = NULL; AudioPlayer::AudioPlayer() : m_working(false) { +#ifndef SERVER m_player = new Phonon::MediaObject(this); connect(m_player, SIGNAL(finished()), this, SLOT(finished_p())); connect(m_player, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish_p())); @@ -44,7 +45,6 @@ AudioPlayer::AudioPlayer() Phonon::createPath(m_player, m_output); preload(); -#ifndef SERVER test(); #endif // SERVER } @@ -63,26 +63,32 @@ bool AudioPlayer::isWorking() const void AudioPlayer::stop() { + if (!isWorking()) + return; m_player->stop(); } void AudioPlayer::setMuted(bool mute) { + if (!isWorking()) + return; m_output->setMuted(mute); } bool AudioPlayer::isMuted() const { + if (!isWorking()) + return true; return m_output->isMuted(); } void AudioPlayer::play(AudioPlayer::Sound sound) { -#ifdef SERVER - return; -#endif // SERVER - if (!m_working) + if (!isWorking()) + { emit finished_p(); + return; + } m_player->stop(); m_player->setCurrentSource(Phonon::MediaSource(m_sounds[sound])); @@ -91,27 +97,29 @@ void AudioPlayer::play(AudioPlayer::Sound sound) void AudioPlayer::clear() { - if (!m_working) + if (!isWorking()) return; m_player->clear(); } void AudioPlayer::enqueue(AudioPlayer::Sound sound) { - if (!m_working) + if (!isWorking()) return; m_player->enqueue(Phonon::MediaSource(m_sounds[sound])); } void AudioPlayer::clearQueue() const { - if (!m_working) + if (!isWorking()) return; m_player->clearQueue(); } Phonon::State AudioPlayer::state() { + if (!isWorking()) + return Phonon::ErrorState; return m_player->state(); } 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() fileMenu->addAction(quitAction); ClickLabel *toggleSound = new ClickLabel("Toggle Sound", this); + toggleSound->setToolTip("Toggle Sound"); toggleSound->setFixedWidth(20); toggleSound->setFixedHeight(16); toggleSound->setAlignment(Qt::AlignBottom); bool sound = AudioPlayer::self()->isWorking(); - bool muted = sound && m_settings->value("muted", false).toBool(); + bool muted = !(sound && m_settings->value("muted", false).toBool()); AudioPlayer::self()->setMuted(muted); QImage img(muted ? ":/soundoff" : ":/soundon"); -- cgit v1.2.3