[Scummvm-cvs-logs] SF.net SVN: scummvm:[45002] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Tue Oct 13 07:38:45 CEST 2009


Revision: 45002
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45002&view=rev
Author:   spalek
Date:     2009-10-13 05:38:45 +0000 (Tue, 13 Oct 2009)

Log Message:
-----------
Set all sound/subtitle-related parameters from ConfMan.

Made it intelligent so that when, for example, the dubbing file doesn't exist,
we don't fail, but instead always show subtitles even if the GUI settings
says dubbing only, etc.

Modified Paths:
--------------
    scummvm/trunk/engines/draci/draci.cpp
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/game.h
    scummvm/trunk/engines/draci/script.cpp
    scummvm/trunk/engines/draci/sound.cpp
    scummvm/trunk/engines/draci/sound.h

Modified: scummvm/trunk/engines/draci/draci.cpp
===================================================================
--- scummvm/trunk/engines/draci/draci.cpp	2009-10-13 04:44:22 UTC (rev 45001)
+++ scummvm/trunk/engines/draci/draci.cpp	2009-10-13 05:38:45 UTC (rev 45002)
@@ -173,8 +173,7 @@
 	}
 
 	if (!_dubbingArchive->isOpen()) {
-		debugC(2, kDraciGeneralDebugLevel, "ERROR - Opening dubbing archive failed");
-		return Common::kUnknownError;
+		debugC(2, kDraciGeneralDebugLevel, "WARNING - Opening dubbing archive failed");
 	}
 
 	_showWalkingMap = false;
@@ -331,11 +330,17 @@
 		_pauseStartTime = _system->getMillis();
 
 		_anims->pauseAnimations();
+		_sound->pauseSound();
+		_sound->pauseVoice();
 	} else {
 		_anims->unpauseAnimations();
+		_sound->resumeSound();
+		_sound->resumeVoice();
 
 		// Adjust engine start time
-		_engineStartTime += (_system->getMillis() - _pauseStartTime) / 1000;
+		const int delta = _system->getMillis() - _pauseStartTime;
+		_engineStartTime += delta / 1000;
+		_game->shiftSpeechTick(delta);
 		_pauseStartTime = 0;
 	}
 }

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-10-13 04:44:22 UTC (rev 45001)
+++ scummvm/trunk/engines/draci/game.cpp	2009-10-13 05:38:45 UTC (rev 45002)
@@ -1506,6 +1506,10 @@
 	_speechDuration = duration;
 }
 
+void Game::shiftSpeechTick(int delta) {
+	_speechTick += delta;
+}
+
 int Game::getEscRoom() const {
 	return _currentRoom._escRoom;
 }

Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h	2009-10-13 04:44:22 UTC (rev 45001)
+++ scummvm/trunk/engines/draci/game.h	2009-10-13 05:38:45 UTC (rev 45002)
@@ -79,9 +79,12 @@
 	kBlackPalette = -1
 };
 
+// Constants tuned such that with ScummVM's default talkspeed 60, the speed
+// computed by equation (kBaseSpeechDuration + kSpeechTimeUnit * #characters) /
+// talkspeed is equal to the original game.
 enum SpeechConstants {
-	kBaseSpeechDuration = 200,
-	kSpeechTimeUnit = 400
+	kBaseSpeechDuration = 12000,
+	kSpeechTimeUnit = 2640
 };
 
 /** Inventory related magical constants */
@@ -325,6 +328,7 @@
 	void setExitLoop(int exit) { _shouldExitLoop = exit; }
 
 	void setSpeechTiming(uint tick, uint duration);
+	void shiftSpeechTick(int delta);
 
 	void updateTitle();
 	void updateCursor();

Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp	2009-10-13 04:44:22 UTC (rev 45001)
+++ scummvm/trunk/engines/draci/script.cpp	2009-10-13 05:38:45 UTC (rev 45002)
@@ -697,9 +697,17 @@
 	// Fetch person info
 	const Person *person = _vm->_game->getPerson(personID);
 
+	// Fetch the dubbing
+	SoundSample *sample = _vm->_sound->isMutedVoice()
+		? NULL : _vm->_dubbingArchive->getSample(sentenceID, 0);
+
 	// Set the string and text colour
 	surface->markDirtyRect(speechFrame->getRect());
-	speechFrame->setText(Common::String((const char *)f->_data+1, f->_length-1));
+	if (_vm->_sound->showSubtitles() || !sample) {
+		speechFrame->setText(Common::String((const char *)f->_data+1, f->_length-1));
+	} else {
+		speechFrame->setText("");
+	}
 	speechFrame->setColour(person->_fontColour);
 
 	// HACK: Some strings in the English data files are too long to fit the screen
@@ -714,7 +722,6 @@
 	_vm->_game->setLoopSubstatus(kSubstatusTalk);
 
 	// Speak the dubbing if possible
-	SoundSample *sample = _vm->_dubbingArchive->getSample(sentenceID, 0);
 	uint dubbingDuration = 0;
 	if (sample) {
 		dubbingDuration = (uint) (1000.0 * sample->_length / sample->_frequency + 500.0);
@@ -724,11 +731,9 @@
 	}
 
 	// Record time
-	const uint subtitleDuration = kBaseSpeechDuration +
-		speechFrame->getLength() * kSpeechTimeUnit /
-	  	(128 / 16 + 1);
-	const uint duration = subtitleDuration >= dubbingDuration ?
-		subtitleDuration : dubbingDuration;
+	uint subtitleDuration = (kBaseSpeechDuration + speechFrame->getLength() * kSpeechTimeUnit)
+		/ _vm->_sound->talkSpeed();
+	const uint duration = MAX(subtitleDuration, dubbingDuration);
 	_vm->_game->setSpeechTiming(_vm->_system->getMillis(), duration);
 
 	// TODO: Implement inventory part

Modified: scummvm/trunk/engines/draci/sound.cpp
===================================================================
--- scummvm/trunk/engines/draci/sound.cpp	2009-10-13 04:44:22 UTC (rev 45001)
+++ scummvm/trunk/engines/draci/sound.cpp	2009-10-13 05:38:45 UTC (rev 45002)
@@ -49,6 +49,8 @@
 		debugC(2, kDraciArchiverDebugLevel, "Success");
 	} else {
 		debugC(2, kDraciArchiverDebugLevel, "Error");
+		delete _f;
+		_f = NULL;
 		return;
 	}
 
@@ -159,7 +161,8 @@
 	return _samples + i;
 }
 
-Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer) {
+Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer), _muteSound(false), _muteVoice(false),
+	_showSubtitles(true), _talkSpeed(60) {
 
 	for (int i = 0; i < SOUND_HANDLES; i++)
 		_handles[i].type = kFreeHandle;
@@ -202,7 +205,7 @@
 }
 
 void Sound::playSound(const SoundSample *buffer, int volume, bool loop) {
-	if (!buffer)
+	if (!buffer || _muteSound)
 		return;
 	SndHandle *handle = getHandle();
 
@@ -231,7 +234,7 @@
 }
 
 void Sound::playVoice(const SoundSample *buffer) {
-	if (!buffer)
+	if (!buffer || _muteVoice)
 		return;
 	SndHandle *handle = getHandle();
 
@@ -265,11 +268,15 @@
 }
 
 void Sound::setVolume() {
+	// TODO: how to retrieve "Mute All" ?
+	_muteSound = ConfMan.getBool("sfx_mute");
+	_muteVoice = ConfMan.getBool("speech_mute");
+	_showSubtitles = ConfMan.getBool("subtitles");
+	_talkSpeed = ConfMan.getInt("talkspeed");
 	const int soundVolume = ConfMan.getInt("sfx_volume");
 	const int speechVolume = ConfMan.getInt("speech_volume");
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolume);
 	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, speechVolume);
-	// TODO: make sure this sound settings works
 }
 
 } // End of namespace Draci

Modified: scummvm/trunk/engines/draci/sound.h
===================================================================
--- scummvm/trunk/engines/draci/sound.h	2009-10-13 04:44:22 UTC (rev 45001)
+++ scummvm/trunk/engines/draci/sound.h	2009-10-13 05:38:45 UTC (rev 45002)
@@ -104,16 +104,21 @@
 	void pauseSound();
 	void resumeSound();
 	void stopSound();
+	bool isMutedSound() const { return _muteSound; }
 
 	void playVoice(const SoundSample *buffer);
 	void pauseVoice();
 	void resumeVoice();
 	void stopVoice();
+	bool isMutedVoice() const { return _muteVoice; }
 
 	void stopAll();
 
 	void setVolume();
 
+	bool showSubtitles() const { return _showSubtitles; }
+	int talkSpeed() const { return _talkSpeed; }
+
  private:
 
 	void playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
@@ -123,6 +128,11 @@
 
 	Audio::Mixer *_mixer;
 
+	bool _muteSound;
+	bool _muteVoice;
+	bool _showSubtitles;
+	int _talkSpeed;
+
 	SndHandle _handles[SOUND_HANDLES];
 };
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list