From 783aa9977c544c7e63aef3dac4fff85abcb682ce Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 17 Sep 2013 03:26:12 +0300 Subject: NEVERHOOD: Implement the music toggle menu button --- engines/neverhood/menumodule.cpp | 7 ++++--- engines/neverhood/menumodule.h | 1 - engines/neverhood/neverhood.cpp | 1 + engines/neverhood/neverhood.h | 3 +++ 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/neverhood/menumodule.cpp b/engines/neverhood/menumodule.cpp index 7bf64a4602..86434452f5 100644 --- a/engines/neverhood/menumodule.cpp +++ b/engines/neverhood/menumodule.cpp @@ -160,7 +160,8 @@ void MenuModule::updateScene() { createScene(MAKING_OF, -1); break; case kMainMenuToggleMusic: - // TODO Toggle music 0048A367 + _vm->toggleMusic(!_vm->musicIsEnabled()); + _vm->_mixer->muteSoundType(Audio::Mixer::kMusicSoundType, !_vm->musicIsEnabled()); createScene(MAIN_MENU, -1); break; case kMainMenuDeleteGame: @@ -356,8 +357,8 @@ MainMenu::MainMenu(NeverhoodEngine *vm, Module *parentModule) insertStaticSprite(0x41137051, 100); insertStaticSprite(0xC10B2015, 100); - // TODO Only if music is enabled - _musicOnButton = insertStaticSprite(0x0C24C0EE, 100); + if (!_vm->musicIsEnabled()) + insertStaticSprite(0x0C24C0EE, 100); // "Music is off" button for (uint buttonIndex = 0; buttonIndex < 9; ++buttonIndex) { Sprite *menuButton = insertSprite(this, buttonIndex, diff --git a/engines/neverhood/menumodule.h b/engines/neverhood/menumodule.h index f201654ceb..9da9c849a9 100644 --- a/engines/neverhood/menumodule.h +++ b/engines/neverhood/menumodule.h @@ -79,7 +79,6 @@ class MainMenu : public Scene { public: MainMenu(NeverhoodEngine *vm, Module *parentModule); protected: - Sprite *_musicOnButton; uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); }; diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp index 061e6d1279..1fb32a1834 100644 --- a/engines/neverhood/neverhood.cpp +++ b/engines/neverhood/neverhood.cpp @@ -109,6 +109,7 @@ Common::Error NeverhoodEngine::run() { _isSaveAllowed = true; _updateSound = true; + _enableMusic = !_mixer->isSoundTypeMuted(Audio::Mixer::kMusicSoundType); if (isDemo()) { // Adjust this navigation list for the demo version diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h index 5643e345ad..9b65f6740e 100644 --- a/engines/neverhood/neverhood.h +++ b/engines/neverhood/neverhood.h @@ -135,9 +135,12 @@ public: NPoint getMousePos(); void toggleSoundUpdate(bool state) { _updateSound = state; } + void toggleMusic(bool state) { _enableMusic = state; } + bool musicIsEnabled() { return _enableMusic; } private: bool _updateSound; + bool _enableMusic; }; -- cgit v1.2.3