[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.180,1.181 game.cpp,1.97,1.98 interface.cpp,1.136,1.137 music.cpp,1.64,1.65 saga.cpp,1.131,1.132 saga.h,1.120,1.121 sound.cpp,1.34,1.35 sound.h,1.26,1.27

Eugene Sandulenko sev at users.sourceforge.net
Fri Sep 2 13:19:01 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12312

Modified Files:
	actor.cpp game.cpp interface.cpp music.cpp saga.cpp saga.h 
	sound.cpp sound.h 
Log Message:
Implement option buttons functionality. This fixes bug #1259518 "ITE: Buttons
in Options Dialog not fully functional"


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -d -r1.180 -r1.181
--- actor.cpp	2 Sep 2005 11:47:47 -0000	1.180
+++ actor.cpp	2 Sep 2005 20:17:51 -0000	1.181
@@ -918,7 +918,6 @@
 	int sampleLength;
 	bool removeFirst;
 	int i;
-	int talkspeed;
 	ActorData *actor;
 	int width, height, height2;
 	Point posPoint;
@@ -976,20 +975,29 @@
 
 	stringLength = strlen(_activeSpeech.strings[0]);
 
-	talkspeed = ConfMan.getInt("talkspeed");
 	if (_activeSpeech.speechFlags & kSpeakSlow) {
 		if (_activeSpeech.slowModeCharIndex >= stringLength)
 			error("Wrong string index");
 
 		warning("Slow string encountered!");
-		_activeSpeech.playingTime = 10 * talkspeed;
-		// 10 - fix it
+		_activeSpeech.playingTime = stringLength * 1000 / 4;
 
 	} else {
-		sampleLength = _vm->_sndRes->getVoiceLength(_activeSpeech.sampleResourceId); //fixme - too fast
+		sampleLength = _vm->_sndRes->getVoiceLength(_activeSpeech.sampleResourceId);
 
 		if (sampleLength < 0) {
-			_activeSpeech.playingTime = stringLength * talkspeed;
+			_activeSpeech.playingTime = stringLength * 1000 / 22;
+			switch (_vm->_readingSpeed) {
+			case 1:
+				_activeSpeech.playingTime *= 2;
+				break;
+			case 2:
+				_activeSpeech.playingTime *= 4;
+				break;
+			case 3:
+				_activeSpeech.playingTime = 0x7fffff;
+				break;
+			}
 		} else {
 			_activeSpeech.playingTime = sampleLength;
 		}
@@ -1599,7 +1607,8 @@
 }
 
 void Actor::drawSpeech(void) {
-	if (!isSpeaking() || !_activeSpeech.playing || _vm->_script->_skipSpeeches)
+	if (!isSpeaking() || !_activeSpeech.playing || _vm->_script->_skipSpeeches
+		|| !_vm->_subtitlesEnabled)
 		return;
 
 	int i;

Index: game.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/game.cpp,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- game.cpp	15 Aug 2005 15:53:47 -0000	1.97
+++ game.cpp	2 Sep 2005 20:17:52 -0000	1.98
@@ -95,7 +95,8 @@
 	{kPanelButtonOptionSaveFiles,	166,20, 112,74,	0,'-',0,	0,0,0},	//savefiles
 
 	{kPanelButtonOptionText,106,4, 0,0,	kTextGameOptions,'-',0,	0,0,0},	// text: game options
-	{kPanelButtonOptionText,10,22, 0,0,	kTextReadingSpeed,'-',0, 0,0,0},	// text: read speed
+	{kPanelButtonOptionText,11,22, 0,0,	kTextReadingSpeed,'-',0, 0,0,0},	// text: read speed
+	{kPanelButtonOptionText,28,22, 0,0,	kTextShowDialog,'-',0, 0,0,0},	// text: read speed
 	{kPanelButtonOptionText,73,41, 0,0,	kTextMusic,'-',0, 0,0,0},	// text: music
 	{kPanelButtonOptionText,69,60, 0,0,	kTextSound,'-',0, 0,0,0},	// text: noise
 };

Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -d -r1.136 -r1.137
--- interface.cpp	16 Aug 2005 19:04:51 -0000	1.136
+++ interface.cpp	2 Sep 2005 20:17:52 -0000	1.137
@@ -32,16 +32,19 @@
 #include "saga/objectmap.h"
 #include "saga/isomap.h"
 #include "saga/itedata.h"
+#include "saga/music.h"
 #include "saga/puzzle.h"
 #include "saga/render.h"
 #include "saga/scene.h"
 #include "saga/script.h"
+#include "saga/sound.h"
 #include "saga/sprite.h"
 #include "saga/rscfile.h"
 #include "saga/resnames.h"
 
 #include "saga/interface.h"
 
+#include "common/config-manager.h"
 #include "common/system.h"
 #include "common/timer.h"
 
@@ -650,15 +653,14 @@
 	int textWidth;
 	Rect rect;
 	Point textPoint;
-	int textId = panelButton->id;
 
-	switch (panelButton->id) {
-	case kTextReadingSpeed:
-		if (_vm->getFeatures() & GF_CD_FX)
-			textId = kTextShowDialog;
-		break;
-	}
-	text = _vm->getTextString(textId);
+	// Button differs for CD version
+	if (panelButton->id == kTextReadingSpeed && _vm->getFeatures() & GF_CD_FX)
+		return;
+	if (panelButton->id == kTextShowDialog && !(_vm->getFeatures() & GF_CD_FX))
+		return;
+
+	text = _vm->getTextString(panelButton->id);
 	panel->calcPanelButtonRect(panelButton, rect);
 	if (panelButton->xOffset < 0) {
 		textWidth = _vm->_font->getStringWidth(kMediumFont, text, 0, kFontNormal);
@@ -1234,29 +1236,49 @@
 	char * fileName;
 	_optionPanel.currentButton = NULL;
 	switch (panelButton->id) {
-		case kTextContinuePlaying:
-			setMode(kPanelMain);
-			break;
-		case kTextQuitGame:
-			setMode(kPanelQuit);
-			break;
-		case kTextLoad:
-			if (_vm->getSaveFilesCount() > 0) {
-				if (_vm->isSaveListFull() || (_optionSaveFileTitleNumber > 0)) {
-					fileName = _vm->calcSaveFileName(_vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber);
-					setMode(kPanelMain);
-					_vm->load(fileName);
-				}
-			}
-			break;
-		case kTextSave:
-			if (!_vm->isSaveListFull() && (_optionSaveFileTitleNumber == 0)) {
-				_textInputString[0] = 0;
-			} else {
-				strcpy(_textInputString, _vm->getSaveFile(_optionSaveFileTitleNumber)->name);
+	case kTextContinuePlaying:
+		ConfMan.flushToDisk();
+		setMode(kPanelMain);
+		break;
+	case kTextQuitGame:
+		setMode(kPanelQuit);
+		break;
+	case kTextLoad:
+		if (_vm->getSaveFilesCount() > 0) {
+			if (_vm->isSaveListFull() || (_optionSaveFileTitleNumber > 0)) {
+				fileName = _vm->calcSaveFileName(_vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber);
+				setMode(kPanelMain);
+				_vm->load(fileName);
 			}
-			setMode(kPanelSave);
-			break;
+		}
+		break;
+	case kTextSave:
+		if (!_vm->isSaveListFull() && (_optionSaveFileTitleNumber == 0)) {
+			_textInputString[0] = 0;
+		} else {
+			strcpy(_textInputString, _vm->getSaveFile(_optionSaveFileTitleNumber)->name);
+		}
+		setMode(kPanelSave);
+		break;
+	case kTextReadingSpeed:
+		if (_vm->getFeatures() & GF_CD_FX) {
+			_vm->_subtitlesEnabled = !_vm->_subtitlesEnabled;
+			ConfMan.set("subtitles", _vm->_subtitlesEnabled);
+		} else {
+			_vm->_readingSpeed = (_vm->_readingSpeed + 1) % 4;
+			ConfMan.set("talkspeed", _vm->_readingSpeed);
+		}
+		break;
+	case kTextMusic:
+		_vm->_musicVolume = (_vm->_musicVolume + 1) % 11;
+		_vm->_music->setVolume(_vm->_musicVolume == 10 ? -1 : _vm->_musicVolume * 25, 1);
+		ConfMan.set("music_volume", _vm->_musicVolume * 25);
+		break;
+	case kTextSound:
+		_vm->_soundVolume = (_vm->_soundVolume + 1) % 11;
+		_vm->_sound->setVolume(_vm->_soundVolume == 10 ? 255 : _vm->_soundVolume * 25);
+		ConfMan.set("sfx_volume", _vm->_soundVolume * 25);
+		break;
 	}
 }
 
@@ -1766,6 +1788,8 @@
 	ds->fillRect(fill, solidColor);
 }
 
+static const int readingSpeeds[] = { kTextFast, kTextMid, kTextSlow, kTextClick };
+
 void Interface::drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) {
 	const char *text;
 	int textId;
@@ -1778,16 +1802,26 @@
 	textId = panelButton->id;
 	switch(panelButton->id) {
 	case kTextReadingSpeed:
-		if (_vm->getFeatures() & GF_CD_FX)
-			textId = kTextOn;
-		else
-			textId = kTextFast;
+		if (_vm->getFeatures() & GF_CD_FX) {
+			if (_vm->_subtitlesEnabled)
+				textId = kTextOn;
+			else
+				textId = kTextOff;
+		} else {
+			textId = readingSpeeds[_vm->_readingSpeed];
+		}
 		break;
 	case kTextMusic:
-		textId = kTextOn;
+		if (_vm->_musicVolume)
+			textId = kText10Percent + _vm->_musicVolume - 1;
+		else
+			textId = kTextOff;
 		break;
 	case kTextSound:
-		textId = kTextOn;
+		if (_vm->_soundVolume)
+			textId = kText10Percent + _vm->_soundVolume - 1;
+		else
+			textId = kTextOff;
 		break;
 	}
 	text = _vm->getTextString(textId);

Index: music.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/music.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- music.cpp	30 Aug 2005 11:16:11 -0000	1.64
+++ music.cpp	2 Sep 2005 20:17:52 -0000	1.65
@@ -322,10 +322,11 @@
 	_currentVolumePercent = 0;
 
 	if (volume == -1) // Set Full volume
-		volume = ConfMan.getInt("music_volume");
+		volume = 255;
 
 	if (time == 1) {
 		_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume);
+		_player->setVolume(volume);
 		Common::g_timer->removeTimerProc(&musicVolumeGaugeCallback);
 		_currentVolume = volume;
 		return;
@@ -447,7 +448,7 @@
 	parser->setTimerRate(_player->getBaseTempo());
 
 	_player->_parser = parser;
-	_player->setVolume(ConfMan.getInt("music_volume"));
+	_player->setVolume(_vm->_musicVolume == 10 ? 255 : _vm->_musicVolume * 25);
 
 	if (flags & MUSIC_LOOP)
 		_player->setLoop(true);

Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- saga.cpp	26 Aug 2005 12:07:31 -0000	1.131
+++ saga.cpp	2 Sep 2005 20:17:52 -0000	1.132
@@ -138,8 +138,6 @@
 		warning("Sound initialization failed.");
 	}
 
-	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
-
 	_displayClip.left = _displayClip.top = 0;
 }
 
@@ -176,8 +174,13 @@
 }
 
 int SagaEngine::init(GameDetector &detector) {
-	_soundEnabled = 1;
-	_musicEnabled = 1;
+	_soundVolume = ConfMan.getInt("sfx_volume") / 25;
+	_musicVolume = ConfMan.getInt("music_volume") / 25;
+	_subtitlesEnabled = ConfMan.getBool("subtitles");
+	_readingSpeed = ConfMan.getInt("talkspeed");
+
+	if (_readingSpeed > 3)
+		_readingSpeed = 0;
 
 	_resource = new Resource(this);
 
@@ -237,11 +240,11 @@
 	} else if (native_mt32)
 		driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
 
-	_music = new Music(this, _mixer, driver, _musicEnabled);
+	_music = new Music(this, _mixer, driver, _musicVolume);
 	_music->setNativeMT32(native_mt32);
 	_music->setAdlib(adlib);
 
-	if (!_musicEnabled) {
+	if (!_musicVolume) {
 		debug(1, "Music disabled.");
 	}
 
@@ -252,8 +255,8 @@
 	}
 
 	// Initialize system specific sound
-	_sound = new Sound(this, _mixer, _soundEnabled);
-	if (!_soundEnabled) {
+	_sound = new Sound(this, _mixer, _soundVolume);
+	if (!_soundVolume) {
 		debug(1, "Sound disabled.");
 	}
 

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- saga.h	16 Aug 2005 19:04:51 -0000	1.120
+++ saga.h	2 Sep 2005 20:17:52 -0000	1.121
@@ -569,9 +569,10 @@
 		return isSaveListFull() ? _saveFilesCount : _saveFilesCount + 1;
 	}
 
-	int _soundEnabled;
-	int _musicEnabled;
-
+	int _soundVolume;
+	int _musicVolume;
+	bool _subtitlesEnabled;
+	int _readingSpeed;
 
 	SndRes *_sndRes;
 	Sound *_sound;

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sound.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- sound.cpp	15 Aug 2005 23:26:50 -0000	1.34
+++ sound.cpp	2 Sep 2005 20:17:52 -0000	1.35
@@ -30,11 +30,13 @@
 
 namespace Saga {
 
-Sound::Sound(SagaEngine *vm, Audio::Mixer *mixer, int enabled) :
-	_vm(vm), _mixer(mixer), _enabled(enabled), _voxStream(0) {
+Sound::Sound(SagaEngine *vm, Audio::Mixer *mixer, int volume) :
+	_vm(vm), _mixer(mixer), _voxStream(0) {
 
 	for (int i = 0; i < SOUND_HANDLES; i++)
 		_handles[i].type = kFreeHandle;
+
+	setVolume(volume == 10 ? 255 : volume * 25);
 }
 
 Sound::~Sound() {
@@ -138,4 +140,9 @@
 	stopSound();
 }
 
+void Sound::setVolume(int volume) {
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume);
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume);
+}
+
 } // End of namespace Saga

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sound.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- sound.h	15 Aug 2005 23:26:50 -0000	1.26
+++ sound.h	2 Sep 2005 20:17:52 -0000	1.27
@@ -61,7 +61,7 @@
 class Sound {
 public:
 
-	Sound(SagaEngine *vm, Audio::Mixer *mixer, int enabled);
+	Sound(SagaEngine *vm, Audio::Mixer *mixer, int volume);
 	~Sound();
 
 	void playSound(SoundBuffer &buffer, int volume, bool loop);
@@ -76,12 +76,13 @@
 
 	void stopAll();
 
+	void setVolume(int volume);
+
  private:
 
 	void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop);
 
 	SndHandle *getHandle();
-	int _enabled;
 
 	SagaEngine *_vm;
 	Audio::Mixer *_mixer;





More information about the Scummvm-git-logs mailing list