[Scummvm-git-logs] scummvm master -> 319b2c29d5e68973917556798e86dd846c7d719c

dreammaster dreammaster at scummvm.org
Sun Jan 28 17:53:19 CET 2018


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

Summary:
319b2c29d5 XEEN: Added logic for music/sound toggling


Commit: 319b2c29d5e68973917556798e86dd846c7d719c
    https://github.com/scummvm/scummvm/commit/319b2c29d5e68973917556798e86dd846c7d719c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-01-28T11:53:11-05:00

Commit Message:
XEEN: Added logic for music/sound toggling

Changed paths:
    engines/xeen/dialogs_control_panel.cpp
    engines/xeen/music.cpp
    engines/xeen/music.h
    engines/xeen/sound.cpp
    engines/xeen/sound.h
    engines/xeen/xeen.cpp
    engines/xeen/xeen.h


diff --git a/engines/xeen/dialogs_control_panel.cpp b/engines/xeen/dialogs_control_panel.cpp
index 3783d45..9eec117 100644
--- a/engines/xeen/dialogs_control_panel.cpp
+++ b/engines/xeen/dialogs_control_panel.cpp
@@ -132,11 +132,11 @@ int ControlPanel::execute() {
 			break;
 
 		case Common::KEYCODE_e:
-			// TODO: Toggle sound effects
+			sound.setEffectsOn(!sound._soundOn);
 			break;
 
 		case Common::KEYCODE_m:
-			// TODO: Toggle music
+			sound.setMusicOn(!sound._musicOn);
 			break;
 
 		case Common::KEYCODE_ESCAPE:
@@ -180,7 +180,7 @@ int ControlPanel::execute() {
 void ControlPanel::loadButtons() {
 	_iconSprites.load("cpanel.icn");
 
-	addButton(Common::Rect(214, 56, 244, 69), Common::KEYCODE_f, 0, &_iconSprites);
+	addButton(Common::Rect(214, 56, 244, 69), Common::KEYCODE_e, 0, &_iconSprites);
 	addButton(Common::Rect(214, 75, 244, 88), Common::KEYCODE_m, 0, &_iconSprites);
 	addButton(Common::Rect(135, 56, 165, 69), Common::KEYCODE_l, 0, &_iconSprites);
 	addButton(Common::Rect(135, 75, 165, 88), Common::KEYCODE_s, 0, &_iconSprites);
diff --git a/engines/xeen/music.cpp b/engines/xeen/music.cpp
index 1e9f6e2..c9a62d5 100644
--- a/engines/xeen/music.cpp
+++ b/engines/xeen/music.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "common/md5.h"
+#include "common/config-manager.h"
 #include "xeen/music.h"
 #include "xeen/xeen.h"
 #include "xeen/files.h"
@@ -725,6 +726,8 @@ int Music::songCommand(uint commandId, byte volume) {
 
 void Music::playSong(Common::SeekableReadStream &stream) {
 	stopSong();
+	if (!_musicOn)
+		return;
 
 	byte *songData = new byte[stream.size()];
 	stream.seek(0);
@@ -742,4 +745,18 @@ void Music::playSong(const Common::String &name, int param) {
 	playSong(f);
 }
 
+void Music::setMusicOn(bool isOn) {
+	ConfMan.setBool("music_mute", !isOn);
+	if (isOn)
+		ConfMan.setBool("mute", false);
+
+	g_vm->syncSoundSettings();
+}
+
+void Music::updateSoundSettings() {
+	_musicOn = !ConfMan.getBool("music_mute");
+	if (!_musicOn)
+		stopSong();
+}
+
 } // End of namespace Xeen
diff --git a/engines/xeen/music.h b/engines/xeen/music.h
index 126b079..5bc6eb0 100644
--- a/engines/xeen/music.h
+++ b/engines/xeen/music.h
@@ -369,6 +369,16 @@ public:
 	void playSong(const byte *data) {
 		_musicDriver->playSong(data);
 	}
+
+	/**
+	 * Sets whether music is on
+	 */
+	void setMusicOn(bool isOn);
+
+	/**
+	 * Called to reload sound settings
+	 */
+	virtual void updateSoundSettings();
 };
 
 } // End of namespace Xeen
diff --git a/engines/xeen/sound.cpp b/engines/xeen/sound.cpp
index 1da8798..65a3e95 100644
--- a/engines/xeen/sound.cpp
+++ b/engines/xeen/sound.cpp
@@ -22,6 +22,7 @@
 
 #include "audio/decoders/raw.h"
 #include "audio/decoders/voc.h"
+#include "common/config-manager.h"
 #include "xeen/sound.h"
 #include "xeen/xeen.h"
 
@@ -39,6 +40,8 @@ Sound::~Sound() {
 
 void Sound::playSound(Common::SeekableReadStream &s, int unused) {
 	stopSound();
+	if (!_soundOn)
+		return;
 
 	s.seek(0);
 	Common::SeekableReadStream *srcStream = s.readStream(s.size());
@@ -69,4 +72,20 @@ void Sound::stopAllAudio() {
 	stopSound();
 }
 
+void Sound::setEffectsOn(bool isOn) {
+	ConfMan.setBool("sfx_mute", !isOn);
+	if (isOn)
+		ConfMan.setBool("mute", false);
+
+	g_vm->syncSoundSettings();
+}
+
+void Sound::updateSoundSettings() {
+	_soundOn = !ConfMan.getBool("sfx_mute");
+	if (!_soundOn)
+		stopFX();
+
+	Music::updateSoundSettings();
+}
+
 } // End of namespace Xeen
diff --git a/engines/xeen/sound.h b/engines/xeen/sound.h
index 41342df..a79885a 100644
--- a/engines/xeen/sound.h
+++ b/engines/xeen/sound.h
@@ -68,6 +68,17 @@ public:
 	 * Stops all playing music, FX, and sound samples
 	 */
 	void stopAllAudio();
+
+	/**
+	 * Sets whether sound effects is on
+	 */
+	void setEffectsOn(bool isOn);
+
+	/**
+	 * Called to reload sound settings
+	 */
+	virtual void updateSoundSettings();
+
 };
 
 } // End of namespace Xeen
diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp
index cac44d4..49862a7 100644
--- a/engines/xeen/xeen.cpp
+++ b/engines/xeen/xeen.cpp
@@ -246,4 +246,9 @@ Common::String XeenEngine::printK2(uint value) {
 		Common::String::format("%u", value);
 }
 
+void XeenEngine::syncSoundSettings() {
+	if (_sound)
+		_sound->updateSoundSettings();
+}
+
 } // End of namespace Xeen
diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h
index 610fe8b..00f3901 100644
--- a/engines/xeen/xeen.h
+++ b/engines/xeen/xeen.h
@@ -186,6 +186,11 @@ public:
 	virtual Common::Error saveGameState(int slot, const Common::String &desc);
 
 	/**
+	 * Updates sound settings
+	 */
+	virtual void syncSoundSettings();
+
+	/**
 	 * Returns true if a savegame can currently be loaded
 	 */
 	bool canLoadGameStateCurrently();





More information about the Scummvm-git-logs mailing list