[Scummvm-cvs-logs] SF.net SVN: scummvm: [31881] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon May 5 19:56:39 CEST 2008


Revision: 31881
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31881&view=rev
Author:   lordhoto
Date:     2008-05-05 10:56:39 -0700 (Mon, 05 May 2008)

Log Message:
-----------
- Implemented Kyra3 audio options menu, Helium mode still missing.
- Fixed unitialized variable

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/gui_hof.cpp
    scummvm/trunk/engines/kyra/gui_hof.h
    scummvm/trunk/engines/kyra/gui_mr.cpp
    scummvm/trunk/engines/kyra/gui_mr.h
    scummvm/trunk/engines/kyra/gui_v2.cpp
    scummvm/trunk/engines/kyra/gui_v2.h
    scummvm/trunk/engines/kyra/kyra_mr.cpp
    scummvm/trunk/engines/kyra/sound_digital.cpp
    scummvm/trunk/engines/kyra/staticres.cpp

Modified: scummvm/trunk/engines/kyra/gui_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_hof.cpp	2008-05-05 17:18:11 UTC (rev 31880)
+++ scummvm/trunk/engines/kyra/gui_hof.cpp	2008-05-05 17:56:39 UTC (rev 31881)
@@ -81,7 +81,6 @@
 }
 
 GUI_HoF::GUI_HoF(KyraEngine_HoF *vm) : GUI_v2(vm), _vm(vm), _screen(_vm->_screen) {
-	_sliderHandlerFunctor = BUTTON_FUNCTOR(GUI_HoF, this, &GUI_HoF::sliderHandler);
 }
 
 const char *GUI_HoF::getMenuTitle(const Menu &menu) {
@@ -900,7 +899,6 @@
 	backUpPage1(_vm->_screenBuffer);
 	if (speechEnabled && !_vm->textEnabled() && (!_vm->speechEnabled() || _vm->getVolume(KyraEngine::kVolumeSpeech) == 2)) {
 		_vm->_configVoice = 0;
-		_vm->setVolume(KyraEngine::kVolumeSpeech, 75);
 		choiceDialog(0x1D, 0);
 	}
 

Modified: scummvm/trunk/engines/kyra/gui_hof.h
===================================================================
--- scummvm/trunk/engines/kyra/gui_hof.h	2008-05-05 17:18:11 UTC (rev 31880)
+++ scummvm/trunk/engines/kyra/gui_hof.h	2008-05-05 17:56:39 UTC (rev 31881)
@@ -73,7 +73,6 @@
 
 	void setupOptionsButtons();
 
-	Button::Callback _sliderHandlerFunctor;
 	int sliderHandler(Button *caller);
 	void drawSliderBar(int slider, const uint8 *shape);
 

Modified: scummvm/trunk/engines/kyra/gui_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_mr.cpp	2008-05-05 17:18:11 UTC (rev 31880)
+++ scummvm/trunk/engines/kyra/gui_mr.cpp	2008-05-05 17:56:39 UTC (rev 31881)
@@ -1077,5 +1077,147 @@
 	return 0;
 }
 
+int GUI_MR::audioOptions(Button *caller) {
+	updateMenuButton(caller);
+
+	restorePage1(_vm->_screenBuffer);
+	backUpPage1(_vm->_screenBuffer);
+
+	//if (_configHelium)
+	//	_audioOptions.item[3].itemId = 18;
+	//else
+		_audioOptions.item[3].itemId = 17;
+
+	initMenu(_audioOptions);
+
+	const int menuX = _audioOptions.x;
+	const int menuY = _audioOptions.y;
+
+	const int maxButton = 3;	// 2 if voc is disabled
+
+	for (int i = 0; i < maxButton; ++i) {
+		int x = menuX + _sliderBarsPosition[i*2+0];
+		int y = menuY + _sliderBarsPosition[i*2+1];
+		_screen->drawShape(0, _vm->getShapePtr(0x1CF), x, y, 0, 0);
+		drawSliderBar(i, _vm->getShapePtr(0x1D0));
+		_sliderButtons[0][i].buttonCallback = _sliderHandlerFunctor;
+		_sliderButtons[0][i].x = x;
+		_sliderButtons[0][i].y = y;
+		_menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[0][i]);
+		_sliderButtons[2][i].buttonCallback = _sliderHandlerFunctor;
+		_sliderButtons[2][i].x = x + 10;
+		_sliderButtons[2][i].y = y;
+		_menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[2][i]);
+		_sliderButtons[1][i].buttonCallback = _sliderHandlerFunctor;
+		_sliderButtons[1][i].x = x + 120;
+		_sliderButtons[1][i].y = y;
+		_menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[1][i]);
+	}
+
+	_isOptionsMenu = true;
+	updateAllMenuButtons();
+	bool speechEnabled = _vm->speechEnabled();
+	while (_isOptionsMenu) {
+		processHighlights(_audioOptions, _vm->_mouseX, _vm->_mouseY);
+		getInput();
+	}
+
+	restorePage1(_vm->_screenBuffer);
+	backUpPage1(_vm->_screenBuffer);
+	if (speechEnabled && !_vm->textEnabled() && (!_vm->speechEnabled() || _vm->getVolume(KyraEngine::kVolumeSpeech) == 2)) {
+		_vm->_configVoice = 0;
+		choiceDialog(0x1D, 0);
+	}
+
+	_vm->writeSettings();
+
+	initMenu(*_currentMenu);
+	updateAllMenuButtons();
+	return 0;
+}
+
+int GUI_MR::sliderHandler(Button *caller) {
+	int button = 0;
+	if (caller->index >= 24 && caller->index <= 27)
+		button = caller->index - 24;
+	else if (caller->index >= 28 && caller->index <= 31)
+		button = caller->index - 28;
+	else
+		button = caller->index - 32;
+
+	assert(button >= 0 && button <= 3);
+
+	int oldVolume = _vm->getVolume(KyraEngine::kVolumeEntry(button));
+	int newVolume = oldVolume;
+
+	if (caller->index >= 24 && caller->index <= 27)
+		newVolume -= 10;
+	else if (caller->index >= 28 && caller->index <= 31)
+		newVolume += 10;
+	else
+		newVolume = _vm->_mouseX - caller->x - 7;
+
+	newVolume = MAX(2, newVolume);
+	newVolume = MIN(97, newVolume);
+
+	if (newVolume == oldVolume)
+		return 0;
+
+	int lastMusicCommand = -1;
+	bool playSoundEffect = false;
+
+	drawSliderBar(button, _vm->getShapePtr(0x1D1));
+
+	if (button == 2) {
+		if (_vm->textEnabled())
+			_vm->_configVoice = 2;
+		else
+			_vm->_configVoice = 1;
+	}
+
+	_vm->setVolume(KyraEngine::kVolumeEntry(button), newVolume);
+
+	switch (button) {
+	case 0:
+		lastMusicCommand = _vm->_lastMusicCommand;
+		break;
+
+	case 1:
+		playSoundEffect = true;
+		break;
+
+	case 2:
+		if (_vm->_voiceSoundChannel != _vm->_musicSoundChannel)
+			_vm->_soundDigital->stopSound(_vm->_voiceSoundChannel);
+		_vm->playVoice(200, 943);
+		break;
+
+	default:
+		return 0;
+	}
+
+	drawSliderBar(button, _vm->getShapePtr(0x1D0));
+	if (playSoundEffect)
+		_vm->snd_playSoundEffect(0x18, 0xC8);
+	else if (lastMusicCommand >= 0)
+		_vm->snd_playWanderScoreViaMap(lastMusicCommand, 1);
+
+	_screen->updateScreen();
+	return 0;
+}
+
+void GUI_MR::drawSliderBar(int slider, const uint8 *shape) {
+	const int menuX = _audioOptions.x;
+	const int menuY = _audioOptions.y;
+	int x = menuX + _sliderBarsPosition[slider*2+0] + 10;
+	int y = menuY + _sliderBarsPosition[slider*2+1];
+
+	int position = _vm->getVolume(KyraEngine::kVolumeEntry(slider));
+
+	position = MAX(2, position);
+	position = MIN(97, position);
+	_screen->drawShape(0, shape, x+position, y, 0, 0);
+}
+
 } // end of namespace Kyra
 

Modified: scummvm/trunk/engines/kyra/gui_mr.h
===================================================================
--- scummvm/trunk/engines/kyra/gui_mr.h	2008-05-05 17:18:11 UTC (rev 31880)
+++ scummvm/trunk/engines/kyra/gui_mr.h	2008-05-05 17:56:39 UTC (rev 31881)
@@ -69,6 +69,11 @@
 	int gameOptions(Button *button);
 	void setupOptionsButtons();
 
+	int audioOptions(Button *button);
+
+	int sliderHandler(Button *caller);
+	void drawSliderBar(int slider, const uint8 *shape);
+
 	int changeLanguage(Button *caller);
 	int toggleStudioSFX(Button *caller);
 	int toggleSkipSupport(Button *caller);

Modified: scummvm/trunk/engines/kyra/gui_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_v2.cpp	2008-05-05 17:18:11 UTC (rev 31880)
+++ scummvm/trunk/engines/kyra/gui_v2.cpp	2008-05-05 17:56:39 UTC (rev 31881)
@@ -42,6 +42,7 @@
 	_isLoadMenu = false;
 	_scrollUpFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::scrollUpButton);
 	_scrollDownFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::scrollDownButton);
+	_sliderHandlerFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::sliderHandler);
 }
 
 Button *GUI_v2::addButtonToList(Button *list, Button *newButton) {

Modified: scummvm/trunk/engines/kyra/gui_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/gui_v2.h	2008-05-05 17:18:11 UTC (rev 31880)
+++ scummvm/trunk/engines/kyra/gui_v2.h	2008-05-05 17:56:39 UTC (rev 31881)
@@ -199,6 +199,10 @@
 
 	virtual void setupOptionsButtons() = 0;
 
+	// audio options
+	Button::Callback _sliderHandlerFunctor;
+	virtual int sliderHandler(Button *caller) = 0;
+
 	// savename menu
 	bool _finishNameInput, _cancelNameInput;
 	Common::KeyState _keyPressed;

Modified: scummvm/trunk/engines/kyra/kyra_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-05 17:18:11 UTC (rev 31880)
+++ scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-05 17:56:39 UTC (rev 31881)
@@ -139,6 +139,7 @@
 	_goodConsciencePosition = false;
 	_menuDirectlyToLoad = false;
 	_optionsFile = 0;
+	_actorFile = 0;
 }
 
 KyraEngine_MR::~KyraEngine_MR() {

Modified: scummvm/trunk/engines/kyra/sound_digital.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_digital.cpp	2008-05-05 17:18:11 UTC (rev 31880)
+++ scummvm/trunk/engines/kyra/sound_digital.cpp	2008-05-05 17:56:39 UTC (rev 31881)
@@ -403,6 +403,9 @@
 }
 
 void SoundDigital::stopSound(int channel) {
+	if (channel == -1)
+		return;
+
 	assert(channel >= 0 && channel < ARRAYSIZE(_sounds));
 	_mixer->stopHandle(_sounds[channel].handle);
 	_sounds[channel].stream = 0;

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-05-05 17:18:11 UTC (rev 31880)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-05-05 17:56:39 UTC (rev 31881)
@@ -2512,6 +2512,7 @@
 	GUI_V2_MENU_ITEM(_mainMenu.item[3], 1, 4, -1, 81, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
 	_mainMenu.item[3].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::gameOptions);
 	GUI_V2_MENU_ITEM(_mainMenu.item[4], 1, 37, -1, 98, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+	_mainMenu.item[4].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::audioOptions);
 	GUI_V2_MENU_ITEM(_mainMenu.item[5], 1, 5, -1, 115, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
 	_mainMenu.item[5].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::quitGame);
 	GUI_V2_MENU_ITEM(_mainMenu.item[6], 1, 6, -1, 144, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);


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