[Scummvm-cvs-logs] scummvm master -> 783aa9977c544c7e63aef3dac4fff85abcb682ce

bluegr bluegr at gmail.com
Tue Sep 17 02:27:47 CEST 2013


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c1226b7d4a NEVERHOOD: Split the code that stops all music and sound effects
783aa9977c NEVERHOOD: Implement the music toggle menu button


Commit: c1226b7d4a305dba7b62b046be4d3fe728a8209d
    https://github.com/scummvm/scummvm/commit/c1226b7d4a305dba7b62b046be4d3fe728a8209d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-09-16T17:27:11-07:00

Commit Message:
NEVERHOOD: Split the code that stops all music and sound effects

Changed paths:
    engines/neverhood/gamemodule.cpp
    engines/neverhood/sound.cpp
    engines/neverhood/sound.h



diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index 47cc818..50c7c50 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -411,7 +411,9 @@ void GameModule::checkRequests() {
 	}
 	if (_restoreGameRequested) {
 		_restoreGameRequested = false;
+		_vm->_audioResourceMan->stopAllMusic();
 		_vm->_audioResourceMan->stopAllSounds();
+		_vm->_soundMan->stopAllMusic();
 		_vm->_soundMan->stopAllSounds();
 		delete _childObject;
 		delete _prevChildObject;
diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp
index c3bc350..1fd0967 100644
--- a/engines/neverhood/sound.cpp
+++ b/engines/neverhood/sound.cpp
@@ -254,9 +254,20 @@ SoundMan::SoundMan(NeverhoodEngine *vm)
 }
 
 SoundMan::~SoundMan() {
+	stopAllMusic();
 	stopAllSounds();
 }
 
+void SoundMan::stopAllMusic() {
+	for (uint i = 0; i < _musicItems.size(); ++i) {
+		if (_musicItems[i]) {
+			_musicItems[i]->stopMusic(0, 0);
+			delete _musicItems[i];
+			_musicItems[i] = NULL;
+		}
+	}
+}
+
 void SoundMan::stopAllSounds() {
 	for (uint i = 0; i < _soundItems.size(); ++i) {
 		if (_soundItems[i]) {
@@ -265,13 +276,6 @@ void SoundMan::stopAllSounds() {
 			_soundItems[i] = NULL;
 		}
 	}
-	for (uint i = 0; i < _musicItems.size(); ++i) {
-		if (_musicItems[i]) {
-			_musicItems[i]->stopMusic(0, 0);
-			delete _musicItems[i];
-			_musicItems[i] = NULL;
-		}
-	}
 
 	_soundIndex1 = _soundIndex2 = _soundIndex3 = -1;
 }
@@ -724,6 +728,16 @@ AudioResourceMan::AudioResourceMan(NeverhoodEngine *vm)
 	: _vm(vm) {
 }
 
+void AudioResourceMan::stopAllMusic() {
+	for (uint i = 0; i < _musicItems.size(); ++i) {
+		if (_musicItems[i]) {
+			_musicItems[i]->stopMusic(0);
+			delete _musicItems[i];
+			_musicItems[i] = NULL;
+		}
+	}
+}
+
 void AudioResourceMan::stopAllSounds() {
 	for (uint i = 0; i < _soundItems.size(); ++i) {
 		if (_soundItems[i]) {
@@ -732,16 +746,10 @@ void AudioResourceMan::stopAllSounds() {
 			_soundItems[i] = NULL;
 		}
 	}
-	for (uint i = 0; i < _musicItems.size(); ++i) {
-		if (_musicItems[i]) {
-			_musicItems[i]->stopMusic(0);
-			delete _musicItems[i];
-			_musicItems[i] = NULL;
-		}
-	}
 }
 
 AudioResourceMan::~AudioResourceMan() {
+	stopAllMusic();
 	stopAllSounds();
 }
 
diff --git a/engines/neverhood/sound.h b/engines/neverhood/sound.h
index 0733346..548fe88 100644
--- a/engines/neverhood/sound.h
+++ b/engines/neverhood/sound.h
@@ -129,6 +129,7 @@ public:
 	SoundMan(NeverhoodEngine *vm);
 	~SoundMan();
 
+	void stopAllMusic();
 	void stopAllSounds();
 
 	// Music
@@ -264,6 +265,7 @@ public:
 	AudioResourceMan(NeverhoodEngine *vm);
 	~AudioResourceMan();
 
+	void stopAllMusic();
 	void stopAllSounds();
 
 	int16 addSound(uint32 fileHash);


Commit: 783aa9977c544c7e63aef3dac4fff85abcb682ce
    https://github.com/scummvm/scummvm/commit/783aa9977c544c7e63aef3dac4fff85abcb682ce
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-09-16T17:27:12-07:00

Commit Message:
NEVERHOOD: Implement the music toggle menu button

Changed paths:
    engines/neverhood/menumodule.cpp
    engines/neverhood/menumodule.h
    engines/neverhood/neverhood.cpp
    engines/neverhood/neverhood.h



diff --git a/engines/neverhood/menumodule.cpp b/engines/neverhood/menumodule.cpp
index 7bf64a4..8643445 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<MenuButton>(this, buttonIndex,
diff --git a/engines/neverhood/menumodule.h b/engines/neverhood/menumodule.h
index f201654..9da9c84 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 &param, Entity *sender);
 };
 
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index 061e6d1..1fb32a1 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 5643e34..9b65f67 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;
 
 };
 






More information about the Scummvm-git-logs mailing list