diff options
| author | Johannes Schickel | 2008-05-05 17:56:39 +0000 | 
|---|---|---|
| committer | Johannes Schickel | 2008-05-05 17:56:39 +0000 | 
| commit | c26e62e288f7454d47e201216c1cd98ee4cb3607 (patch) | |
| tree | 5f6b5a1bac4ea7511cae1e290fe4f79afa178003 | |
| parent | f42d222069d7ae130c85201e895e7f23d27c88d0 (diff) | |
| download | scummvm-rg350-c26e62e288f7454d47e201216c1cd98ee4cb3607.tar.gz scummvm-rg350-c26e62e288f7454d47e201216c1cd98ee4cb3607.tar.bz2 scummvm-rg350-c26e62e288f7454d47e201216c1cd98ee4cb3607.zip  | |
- Implemented Kyra3 audio options menu, Helium mode still missing.
- Fixed unitialized variable
svn-id: r31881
| -rw-r--r-- | engines/kyra/gui_hof.cpp | 2 | ||||
| -rw-r--r-- | engines/kyra/gui_hof.h | 1 | ||||
| -rw-r--r-- | engines/kyra/gui_mr.cpp | 142 | ||||
| -rw-r--r-- | engines/kyra/gui_mr.h | 5 | ||||
| -rw-r--r-- | engines/kyra/gui_v2.cpp | 1 | ||||
| -rw-r--r-- | engines/kyra/gui_v2.h | 4 | ||||
| -rw-r--r-- | engines/kyra/kyra_mr.cpp | 1 | ||||
| -rw-r--r-- | engines/kyra/sound_digital.cpp | 3 | ||||
| -rw-r--r-- | engines/kyra/staticres.cpp | 1 | 
9 files changed, 157 insertions, 3 deletions
diff --git a/engines/kyra/gui_hof.cpp b/engines/kyra/gui_hof.cpp index 08cfd2a1e9..d1fcaa4712 100644 --- a/engines/kyra/gui_hof.cpp +++ b/engines/kyra/gui_hof.cpp @@ -81,7 +81,6 @@ void KyraEngine_HoF::setupLangButtonShapes() {  }  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 @@ int GUI_HoF::audioOptions(Button *caller) {  	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);  	} diff --git a/engines/kyra/gui_hof.h b/engines/kyra/gui_hof.h index d535fc13ea..f64336a8f6 100644 --- a/engines/kyra/gui_hof.h +++ b/engines/kyra/gui_hof.h @@ -73,7 +73,6 @@ private:  	void setupOptionsButtons(); -	Button::Callback _sliderHandlerFunctor;  	int sliderHandler(Button *caller);  	void drawSliderBar(int slider, const uint8 *shape); diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp index bf04e66a51..8d27938aff 100644 --- a/engines/kyra/gui_mr.cpp +++ b/engines/kyra/gui_mr.cpp @@ -1077,5 +1077,147 @@ int GUI_MR::toggleSkipSupport(Button *caller) {  	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 diff --git a/engines/kyra/gui_mr.h b/engines/kyra/gui_mr.h index d994aa91da..d73b21b73b 100644 --- a/engines/kyra/gui_mr.h +++ b/engines/kyra/gui_mr.h @@ -69,6 +69,11 @@ private:  	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); diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index 4d78c8bb6f..d835c4f8d5 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -42,6 +42,7 @@ GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) {  	_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) { diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h index 764376f969..4e94b58742 100644 --- a/engines/kyra/gui_v2.h +++ b/engines/kyra/gui_v2.h @@ -199,6 +199,10 @@ protected:  	virtual void setupOptionsButtons() = 0; +	// audio options +	Button::Callback _sliderHandlerFunctor; +	virtual int sliderHandler(Button *caller) = 0; +  	// savename menu  	bool _finishNameInput, _cancelNameInput;  	Common::KeyState _keyPressed; diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 1c4396b320..61546fc2e7 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -139,6 +139,7 @@ KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngi  	_goodConsciencePosition = false;  	_menuDirectlyToLoad = false;  	_optionsFile = 0; +	_actorFile = 0;  }  KyraEngine_MR::~KyraEngine_MR() { diff --git a/engines/kyra/sound_digital.cpp b/engines/kyra/sound_digital.cpp index 3a4eeba0f5..f8c6fbdb04 100644 --- a/engines/kyra/sound_digital.cpp +++ b/engines/kyra/sound_digital.cpp @@ -403,6 +403,9 @@ bool SoundDigital::isPlaying(int channel) {  }  void SoundDigital::stopSound(int channel) { +	if (channel == -1) +		return; +  	assert(channel >= 0 && channel < ARRAYSIZE(_sounds));  	_mixer->stopHandle(_sounds[channel].handle);  	_sounds[channel].stream = 0; diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 0695847d7a..16d7ca4d9b 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -2512,6 +2512,7 @@ void GUI_MR::initStaticData() {  	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);  | 
