From 35d4ce0ed75b2575067007a85d5c211d292ebada Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 31 Mar 2013 20:16:39 +0300 Subject: Rename SoundManager sigleton from sound to soundManager. --- src/actionmanager.cpp | 2 +- src/actorsprite.cpp | 2 +- src/being.cpp | 33 +++++++++++++++++++++------------ src/client.cpp | 19 ++++++++++--------- src/effectmanager.cpp | 6 +++--- src/game.cpp | 4 ++-- src/gui/confirmdialog.cpp | 2 +- src/gui/npcdialog.cpp | 2 +- src/gui/okdialog.cpp | 4 ++-- src/gui/quitdialog.cpp | 4 ++-- src/gui/setup_audio.cpp | 12 ++++++------ src/gui/shopwindow.cpp | 2 +- src/gui/widgets/chattab.cpp | 8 ++++---- src/gui/widgets/guildchattab.cpp | 2 +- src/gui/widgets/setupitem.cpp | 2 +- src/gui/widgets/window.cpp | 4 ++-- src/localplayer.cpp | 19 ++++++++++--------- src/net/ea/gui/guildtab.cpp | 2 +- src/net/ea/gui/partytab.cpp | 2 +- src/soundmanager.h | 2 +- src/statuseffect.cpp | 2 +- src/test/testlauncher.cpp | 8 ++++---- 22 files changed, 77 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index f98449459..fbdca92b1 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -565,7 +565,7 @@ impHandler0(changeGameModifier) impHandler0(changeAudio) { - sound.changeAudio(); + soundManager.changeAudio(); return true; } diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index ac2d6bf7b..af98a0fbc 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -282,7 +282,7 @@ void ActorSprite::internalTriggerEffect(const int effectId, const bool sfx, controlParticle(particleEngine->addEffect(ed->mGFXEffect, 0, 0)); if (sfx && !ed->mSFXEffect.empty()) - sound.playSfx(ed->mSFXEffect); + soundManager.playSfx(ed->mSFXEffect); } void ActorSprite::updateStunMode(const int oldMode, const int newMode) diff --git a/src/being.cpp b/src/being.cpp index feb0cfbbc..bb2a6e95e 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -629,7 +629,7 @@ void Being::takeDamage(Being *const attacker, const int amount, mDamageTaken += amount; if (mInfo) { - sound.playSfx(mInfo->getSound(SOUND_EVENT_HURT), + soundManager.playSfx(mInfo->getSound(SOUND_EVENT_HURT), getTileX(), getTileY()); if (!mInfo->isStaticMaxHP()) @@ -798,11 +798,11 @@ void Being::handleAttack(Being *const victim, const int damage, } if (!soundFile.empty()) { - sound.playSfx(soundFile, mX, mY); + soundManager.playSfx(soundFile, mX, mY); } else { - sound.playSfx(paths.getValue((damage > 0) + soundManager.playSfx(paths.getValue((damage > 0) ? "attackSfxFile" : "missSfxFile", "fist-swish.ogg"), mX, mY); } @@ -810,7 +810,7 @@ void Being::handleAttack(Being *const victim, const int damage, } else { - sound.playSfx(mInfo->getSound((damage > 0) ? + soundManager.playSfx(mInfo->getSound((damage > 0) ? SOUND_EVENT_HIT : SOUND_EVENT_MISS), mX, mY); } } @@ -851,13 +851,13 @@ void Being::handleSkill(Being *const victim, const int damage, if (data) { if (damage > 0) - sound.playSfx(data->soundHit, mX, mY); + soundManager.playSfx(data->soundHit, mX, mY); else - sound.playSfx(data->soundMiss, mX, mY); + soundManager.playSfx(data->soundMiss, mX, mY); } else { - sound.playSfx(mInfo->getSound((damage > 0) ? + soundManager.playSfx(mInfo->getSound((damage > 0) ? SOUND_EVENT_HIT : SOUND_EVENT_MISS), mX, mY); } } @@ -1093,7 +1093,10 @@ void Being::setAction(const Action &action, const int attackId) { case MOVE: if (mInfo) - sound.playSfx(mInfo->getSound(SOUND_EVENT_MOVE), mX, mY); + { + soundManager.playSfx(mInfo->getSound( + SOUND_EVENT_MOVE), mX, mY); + } currentAction = SpriteAction::MOVE; // Note: When adding a run action, // Differentiate walk and run with action name, @@ -1108,7 +1111,7 @@ void Being::setAction(const Action &action, const int attackId) event = SOUND_EVENT_SITTOP; else event = SOUND_EVENT_SIT; - sound.playSfx(mInfo->getSound(event), mX, mY); + soundManager.playSfx(mInfo->getSound(event), mX, mY); } break; case ATTACK: @@ -1155,7 +1158,10 @@ void Being::setAction(const Action &action, const int attackId) break; case HURT: if (mInfo) - sound.playSfx(mInfo->getSound(SOUND_EVENT_HURT), mX, mY); + { + soundManager.playSfx(mInfo->getSound( + SOUND_EVENT_HURT), mX, mY); + } //currentAction = SpriteAction::HURT;// Buggy: makes the player stop // attacking and unable to attack // again until he moves. @@ -1165,7 +1171,7 @@ void Being::setAction(const Action &action, const int attackId) currentAction = SpriteAction::DEAD; if (mInfo) { - sound.playSfx(mInfo->getSound(SOUND_EVENT_DIE), mX, mY); + soundManager.playSfx(mInfo->getSound(SOUND_EVENT_DIE), mX, mY); if (mType == MONSTER || mType == NPC) mYDiff = mInfo->getDeadSortOffsetY(); } @@ -1175,7 +1181,10 @@ void Being::setAction(const Action &action, const int attackId) break; case SPAWN: if (mInfo) - sound.playSfx(mInfo->getSound(SOUND_EVENT_SPAWN), mX, mY); + { + soundManager.playSfx(mInfo->getSound( + SOUND_EVENT_SPAWN), mX, mY); + } currentAction = SpriteAction::SPAWN; break; default: diff --git a/src/client.cpp b/src/client.cpp index 05efccd92..f79baf7df 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -150,7 +150,7 @@ KeyboardConfig keyboard; UserPalette *userPalette = nullptr; Graphics *mainGraphics = nullptr; -SoundManager sound; +SoundManager soundManager; int openGLMode = 0; static uint32_t nextTick(uint32_t interval, void *param A_UNUSED); @@ -594,10 +594,10 @@ void Client::gameInit() try { if (config.getBoolValue("sound")) - sound.init(); + soundManager.init(); - sound.setSfxVolume(config.getIntValue("sfxVolume")); - sound.setMusicVolume(config.getIntValue("musicVolume")); + soundManager.setSfxVolume(config.getIntValue("sfxVolume")); + soundManager.setMusicVolume(config.getIntValue("musicVolume")); } catch (const char *const err) { @@ -618,7 +618,8 @@ void Client::gameInit() userPalette = new UserPalette; setupWindow = new Setup; - sound.playMusic(branding.getValue("loginMusic", "Magick - Real.ogg")); + soundManager.playMusic(branding.getValue( + "loginMusic", "Magick - Real.ogg")); // Initialize default server mCurrentServer.hostname = mOptions.serverName; @@ -794,7 +795,7 @@ void Client::gameClear() BeingInfo::clear(); // Shutdown sound - sound.close(); + soundManager.close(); if (logger) logger->log1("Quitting6"); @@ -823,7 +824,7 @@ void Client::gameClear() if (logger) logger->log1("Quitting10"); - sound.shutdown(); + soundManager.shutdown(); touchManager.shutdown(); #ifdef DEBUG_CONFIG @@ -1009,7 +1010,7 @@ int Client::gameExec() ++lastTickTime; k ++; } - sound.logic(); + soundManager.logic(); logic_count += k; if (gui) @@ -1465,7 +1466,7 @@ int Client::gameExec() // Fade out logon-music here too to give the desired effect // of "flowing" into the game. - sound.fadeOutMusic(1000); + soundManager.fadeOutMusic(1000); // Allow any alpha opacity Theme::instance()->setMinimumOpacity(-1.0f); diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 5901e21ea..2d235bbfe 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -79,7 +79,7 @@ bool EffectManager::trigger(const int id, Being *const being, being->controlParticle(selfFX); } if (!(*i).SFX.empty()) - sound.playSfx((*i).SFX); + soundManager.playSfx((*i).SFX); break; } } @@ -104,7 +104,7 @@ Particle *EffectManager::triggerReturn(const int id, Being *const being, being->controlParticle(rValue); } if (!(*i).SFX.empty()) - sound.playSfx((*i).SFX); + soundManager.playSfx((*i).SFX); break; } } @@ -126,7 +126,7 @@ bool EffectManager::trigger(const int id, const int x, const int y, if (!(*i).GFX.empty() && particleEngine) particleEngine->addEffect((*i).GFX, x, y, rotation); if (!(*i).SFX.empty()) - sound.playSfx((*i).SFX); + soundManager.playSfx((*i).SFX); break; } } diff --git a/src/game.cpp b/src/game.cpp index 1ab3cb10e..7effc2e53 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1069,9 +1069,9 @@ void Game::changeMap(const std::string &mapPath) if (newMusic != oldMusic) { if (newMusic.empty()) - sound.fadeOutMusic(); + soundManager.fadeOutMusic(); else - sound.fadeOutAndPlayMusic(newMusic); + soundManager.fadeOutAndPlayMusic(newMusic); } if (mCurrentMap) diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp index e78be195c..3fef0d5bc 100644 --- a/src/gui/confirmdialog.cpp +++ b/src/gui/confirmdialog.cpp @@ -99,7 +99,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, } setVisible(true); yesButton->requestFocus(); - sound.playGuiSound(SOUND_REQUEST); + soundManager.playGuiSound(SOUND_REQUEST); } void ConfirmDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index c2de9b1ad..32f17ecbd 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -154,7 +154,7 @@ NpcDialog::NpcDialog(const int npcId) : setVisible(true); requestFocus(); enableVisibleSound(true); - sound.playGuiSound(SOUND_SHOW_WINDOW); + soundManager.playGuiSound(SOUND_SHOW_WINDOW); if (actorSpriteManager) { diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp index ae0c4ca4a..243805538 100644 --- a/src/gui/okdialog.cpp +++ b/src/gui/okdialog.cpp @@ -77,9 +77,9 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, okButton->requestFocus(); if (soundEvent == DIALOG_OK) - sound.playGuiSound(SOUND_INFO); + soundManager.playGuiSound(SOUND_INFO); else if (soundEvent == DIALOG_ERROR) - sound.playGuiSound(SOUND_ERROR); + soundManager.playGuiSound(SOUND_ERROR); } void OkDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 3bf63c9a1..76937b936 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -114,7 +114,7 @@ QuitDialog::QuitDialog(QuitDialog **const pointerToMe): reflowLayout(200, 0); setLocationRelativeTo(getParent()); setVisible(true); - sound.playGuiSound(SOUND_SHOW_WINDOW); + soundManager.playGuiSound(SOUND_SHOW_WINDOW); // enableVisibleSound(true); requestModalFocus(); mOkButton->requestFocus(); @@ -144,7 +144,7 @@ void QuitDialog::placeOption(ContainerPlacer &placer, void QuitDialog::action(const gcn::ActionEvent &event) { - sound.playGuiSound(SOUND_HIDE_WINDOW); + soundManager.playGuiSound(SOUND_HIDE_WINDOW); if (event.getId() == "ok") { if (viewport) diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index ea3a46a86..9209bc731 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -77,10 +77,10 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : "playGuiSound", this, "playGuiSoundEvent"); new SetupItemSlider(_("Sfx volume"), "", "sfxVolume", - this, "sfxVolumeEvent", 0, sound.getMaxVolume(), 150, true); + this, "sfxVolumeEvent", 0, soundManager.getMaxVolume(), 150, true); new SetupItemSlider(_("Music volume"), "", "musicVolume", - this, "musicVolumeEvent", 0, sound.getMaxVolume(), 150, true); + this, "musicVolumeEvent", 0, soundManager.getMaxVolume(), 150, true); new SetupItemCheckBox(_("Enable music fade out"), "", "fadeoutmusic", this, "fadeoutmusicEvent"); @@ -156,20 +156,20 @@ void Setup_Audio::apply() SetupTabScroll::apply(); if (config.getBoolValue("sound")) { - sound.init(); + soundManager.init(); if (viewport && config.getBoolValue("playMusic")) { const Map *const map = viewport->getMap(); if (map) - sound.playMusic(map->getMusicFile()); + soundManager.playMusic(map->getMusicFile()); } else { - sound.stopMusic(); + soundManager.stopMusic(); } } else { - sound.close(); + soundManager.close(); } } diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 17f9edc5b..0119bc68b 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -756,7 +756,7 @@ void ShopWindow::processRequest(std::string nick, std::string data, if (config.getBoolValue("autoShop")) { - sound.playGuiSound(SOUND_TRADE); + soundManager.playGuiSound(SOUND_TRADE); startTrade(); } else diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index f219bb661..31ae6a84b 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -289,7 +289,7 @@ void ChatTab::chatLog(std::string line, Own own, if (chatWindow && chatWindow->findHighlight(tmp.text)) { setFlash(2); - sound.playGuiSound(SOUND_HIGHLIGHT); + soundManager.playGuiSound(SOUND_HIGHLIGHT); } else { @@ -299,7 +299,7 @@ void ChatTab::chatLog(std::string line, Own own, else if (getFlash() == 2) { if (chatWindow && chatWindow->findHighlight(tmp.text)) - sound.playGuiSound(SOUND_HIGHLIGHT); + soundManager.playGuiSound(SOUND_HIGHLIGHT); } } @@ -312,7 +312,7 @@ void ChatTab::chatLog(std::string line, Own own, { if (chatWindow) chatWindow->unHideWindow(); - sound.playGuiSound(SOUND_GLOBAL); + soundManager.playGuiSound(SOUND_GLOBAL); } else if (own != BY_SERVER) { @@ -510,7 +510,7 @@ void ChatTab::addNewRow(std::string &line) void ChatTab::playNewMessageSound() { - sound.playGuiSound(SOUND_WHISPER); + soundManager.playGuiSound(SOUND_WHISPER); } void ChatTab::showOnline(const std::string &nick, diff --git a/src/gui/widgets/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp index 5917fbda4..bb85e1a5b 100644 --- a/src/gui/widgets/guildchattab.cpp +++ b/src/gui/widgets/guildchattab.cpp @@ -134,7 +134,7 @@ void GuildChatTab::saveToLogFile(std::string &msg) void GuildChatTab::playNewMessageSound() { - sound.playGuiSound(SOUND_GUILD); + soundManager.playGuiSound(SOUND_GUILD); } void GuildChatTab::optionChanged(const std::string &value) diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index fbb24d2b6..54e1102a6 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -1037,7 +1037,7 @@ void SetupItemSound::action(const gcn::ActionEvent &event) { if (mSlider->getSelected()) { - sound.playGuiSfx(branding.getStringValue("systemsounds") + soundManager.playGuiSfx(branding.getStringValue("systemsounds") .append(mSlider->getSelectedString()).append(".ogg")); } } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 54ed4764f..63c5b6629 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -578,7 +578,7 @@ void Window::setVisible(bool visible, bool forceSticky) if (visible) { if (mPlayVisibleSound) - sound.playGuiSound(SOUND_SHOW_WINDOW); + soundManager.playGuiSound(SOUND_SHOW_WINDOW); if (gui) { gcn::MouseEvent *event = reinterpret_cast( @@ -599,7 +599,7 @@ void Window::setVisible(bool visible, bool forceSticky) else { if (mPlayVisibleSound) - sound.playGuiSound(SOUND_HIDE_WINDOW); + soundManager.playGuiSound(SOUND_HIDE_WINDOW); } } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 3d2af40c6..c1d3b9c5f 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -202,7 +202,7 @@ LocalPlayer::~LocalPlayer() if (mAwayDialog) { - sound.volumeRestore(); + soundManager.volumeRestore(); delete mAwayDialog; mAwayDialog = nullptr; } @@ -1307,11 +1307,12 @@ void LocalPlayer::attack(Being *const target, const bool keep, std::string soundFile = mEquippedWeapon->getSound( EQUIP_EVENT_STRIKE); if (!soundFile.empty()) - sound.playSfx(soundFile); + soundManager.playSfx(soundFile); } else { - sound.playSfx(paths.getValue("attackSfxFile", "fist-swish.ogg")); + soundManager.playSfx(paths.getValue( + "attackSfxFile", "fist-swish.ogg")); } */ if (!Client::limitPackets(PACKET_ATTACK)) @@ -2160,13 +2161,13 @@ void LocalPlayer::changeAwayMode() config.getStringValue("afkMessage"), DIALOG_SILENCE, true, false); mAwayDialog->addActionListener(mAwayListener); - sound.volumeOff(); + soundManager.volumeOff(); addAfkEffect(); } else { mAwayDialog = nullptr; - sound.volumeRestore(); + soundManager.volumeRestore(); if (chatWindow) { chatWindow->displayAwayLog(); @@ -3591,12 +3592,12 @@ void LocalPlayer::updateCoords() MapItem::MUSIC); if (str.empty()) str = mMap->getMusicFile(); - if (str != sound.getCurrentMusicFile()) + if (str != soundManager.getCurrentMusicFile()) { if (str.empty()) - sound.fadeOutMusic(); + soundManager.fadeOutMusic(); else - sound.fadeOutAndPlayMusic(str); + soundManager.fadeOutAndPlayMusic(str); } } } @@ -4129,7 +4130,7 @@ void LocalPlayer::checkNewName(Being *const being) if (!mWaitFor.empty() && mWaitFor == nick) { debugMsg(strprintf(_("You see %s"), mWaitFor.c_str())); - sound.playGuiSound(SOUND_INFO); + soundManager.playGuiSound(SOUND_INFO); mWaitFor.clear(); } } diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index 6dd53745e..909cdb8c2 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -156,7 +156,7 @@ void GuildTab::saveToLogFile(std::string &msg) void GuildTab::playNewMessageSound() { - sound.playGuiSound(SOUND_GUILD); + soundManager.playGuiSound(SOUND_GUILD); } void GuildTab::optionChanged(const std::string &value) diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index da26591a5..e8689d7d0 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -245,6 +245,6 @@ void PartyTab::saveToLogFile(std::string &msg) void PartyTab::playNewMessageSound() { - sound.playGuiSound(SOUND_GUILD); + soundManager.playGuiSound(SOUND_GUILD); } } // namespace Ea diff --git a/src/soundmanager.h b/src/soundmanager.h index 32fe27fbc..444c81771 100644 --- a/src/soundmanager.h +++ b/src/soundmanager.h @@ -174,6 +174,6 @@ class SoundManager final : public ConfigListener int mGuiChannel; }; -extern SoundManager sound; +extern SoundManager soundManager; #endif diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 04e94a0f8..f567d9ff5 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -51,7 +51,7 @@ StatusEffect::~StatusEffect() void StatusEffect::playSFX() const { if (!mSFXEffect.empty()) - sound.playSfx(mSFXEffect); + soundManager.playSfx(mSFXEffect); } void StatusEffect::deliverMessage() const diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 215793243..b4db8da78 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -99,12 +99,12 @@ int TestLauncher::testBackend() const int TestLauncher::testSound() const { - sound.playGuiSfx("system/newmessage.ogg"); + soundManager.playGuiSfx("system/newmessage.ogg"); sleep(1); - sound.playSfx("system/newmessage.ogg", 0, 0); - sound.playMusic("sfx/system/newmessage.ogg"); + soundManager.playSfx("system/newmessage.ogg", 0, 0); + soundManager.playMusic("sfx/system/newmessage.ogg"); sleep(3); - sound.stopMusic(); + soundManager.stopMusic(); return 0; } -- cgit v1.2.3-60-g2f50