aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/kyra/gui.cpp10
-rw-r--r--engines/kyra/gui_v2.cpp138
-rw-r--r--engines/kyra/gui_v2.h14
-rw-r--r--engines/kyra/kyra.cpp51
-rw-r--r--engines/kyra/kyra.h10
-rw-r--r--engines/kyra/staticres.cpp29
6 files changed, 244 insertions, 8 deletions
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
index 366e1d8432..f851bcf066 100644
--- a/engines/kyra/gui.cpp
+++ b/engines/kyra/gui.cpp
@@ -136,11 +136,13 @@ void GUI::initMenu(Menu &menu) {
_text->printText(getMenuItemTitle(menu.item[i]), textX, textY, menu.item[i].highlightColor, 0, 0);
else
_text->printText(getMenuItemTitle(menu.item[i]), textX, textY, menu.item[i].textColor, 0, 0);
+ }
+ }
- if (getMenuItemLabel(menu.item[i])) {
- _text->printText(getMenuItemLabel(menu.item[i]), menu.x + menu.item[i].labelX - 1, menu.y + menu.item[i].labelY + 1, defaultColor1(), 0, 0);
- _text->printText(getMenuItemLabel(menu.item[i]), menu.x + menu.item[i].labelX, menu.y + menu.item[i].labelY, menu.item[i].textColor, 0, 0);
- }
+ for (int i = 0; i < menu.numberOfItems; ++i) {
+ if (getMenuItemLabel(menu.item[i])) {
+ _text->printText(getMenuItemLabel(menu.item[i]), menu.x + menu.item[i].labelX - 1, menu.y + menu.item[i].labelY + 1, defaultColor1(), 0, 0);
+ _text->printText(getMenuItemLabel(menu.item[i]), menu.x + menu.item[i].labelX, menu.y + menu.item[i].labelY, menu.item[i].textColor, 0, 0);
}
}
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp
index 39753ba40a..d7c6909cd0 100644
--- a/engines/kyra/gui_v2.cpp
+++ b/engines/kyra/gui_v2.cpp
@@ -281,6 +281,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) {
@@ -1192,6 +1193,7 @@ void GUI_v2::getInput() {
_displayMenu = false;
_isLoadMenu = false;
_isSaveMenu = false;
+ _isOptionsMenu = false;
}
}
@@ -1223,7 +1225,8 @@ int GUI_v2::optionsButton(Button *button) {
_displayMenu = true;
if (!_vm->gameFlags().isTalkie) {
- //XXX
+ _gameOptions.item[3].enabled = false;
+ _audioOptions.item[3].enabled = false;
}
for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i) {
@@ -1234,7 +1237,7 @@ int GUI_v2::optionsButton(Button *button) {
initMenuLayout(_mainMenu);
initMenuLayout(_gameOptions);
- //XXX
+ initMenuLayout(_audioOptions);
initMenuLayout(_choiceMenu);
_loadMenu.numberOfItems = 6;
initMenuLayout(_loadMenu);
@@ -1593,6 +1596,137 @@ void GUI_v2::setupOptionsButtons() {
}
}
+int GUI_v2::audioOptions(Button *caller) {
+ updateMenuButton(caller);
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ 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->_buttonShapes[16], x, y, 0, 0);
+ drawSliderBar(i, _vm->_buttonShapes[17]);
+ _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;
+ _vm->setVolume(KyraEngine::kVolumeSpeech, 75);
+ choiceDialog(0x1D, 0);
+ }
+
+ _vm->writeSettings();
+
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
+ return 0;
+}
+
+int GUI_v2::sliderHandler(Button *caller) {
+ int button = 0;
+ if (caller->index >= 25 && caller->index <= 28)
+ button = caller->index - 25;
+ else if (caller->index >= 29 && caller->index <= 32)
+ button = caller->index - 29;
+ else
+ button = caller->index - 33;
+
+ assert(button >= 0 && button <= 2);
+
+ int oldVolume = _vm->getVolume(KyraEngine::kVolumeEntry(button));
+ int newVolume = oldVolume;
+
+ if (caller->index >= 25 && caller->index <= 28)
+ newVolume -= 10;
+ else if (caller->index >= 29 && caller->index <= 32)
+ 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->_buttonShapes[18]);
+
+ 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:
+ _vm->playVoice(90, 28);
+ break;
+
+ default:
+ return 0;
+ }
+
+ drawSliderBar(button, _vm->_buttonShapes[17]);
+ if (playSoundEffect)
+ _vm->snd_playSoundEffect(0x18);
+ else if (lastMusicCommand >= 0)
+ _vm->snd_playWanderScoreViaMap(lastMusicCommand, 1);
+
+ _screen->updateScreen();
+ return 0;
+}
+
+void GUI_v2::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);
+}
+
int GUI_v2::loadMenu(Button *caller) {
if (!_vm->_menuDirectlyToLoad) {
updateMenuButton(caller);
diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h
index e8a22bc617..a10f47faba 100644
--- a/engines/kyra/gui_v2.h
+++ b/engines/kyra/gui_v2.h
@@ -111,7 +111,7 @@ private:
Button _menuButtons[7];
Button _scrollUpButton;
Button _scrollDownButton;
- Menu _mainMenu, _gameOptions, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu;
+ Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu;
void initStaticData();
const char *getMenuTitle(const Menu &menu);
@@ -130,6 +130,8 @@ private:
Button::Callback getScrollUpButtonHandler() const { return _scrollUpFunctor; }
Button::Callback getScrollDownButtonHandler() const { return _scrollDownFunctor; }
+ Button _sliderButtons[3][3];
+
uint8 defaultColor1() const { return 0xCF; }
uint8 defaultColor2() const { return 0xF8; }
@@ -179,6 +181,16 @@ private:
void setupOptionsButtons();
+ // audio menu
+ int audioOptions(Button *caller);
+
+ Button::Callback _sliderHandlerFunctor;
+ int sliderHandler(Button *caller);
+
+ void drawSliderBar(int slider, const uint8 *shape);
+
+ static const int _sliderBarsPosition[];
+
// load menu
bool _noLoadProcess;
int loadMenu(Button *caller);
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index 8a377c231d..302f7277ae 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -322,5 +322,56 @@ bool KyraEngine::textEnabled() {
return !_flags.isTalkie || (_configVoice == 0 || _configVoice == 2);
}
+inline int convertValueToMixer(int value) {
+ value -= 2;
+ return (value * Audio::Mixer::kMaxMixerVolume) / 95;
+}
+
+inline int convertValueFromMixer(int value) {
+ return (value * 95) / Audio::Mixer::kMaxMixerVolume + 2;
+}
+
+void KyraEngine::setVolume(kVolumeEntry vol, uint8 value) {
+ switch (vol) {
+ case kVolumeMusic:
+ ConfMan.setInt("music_volume", convertValueToMixer(value));
+ break;
+
+ case kVolumeSfx:
+ ConfMan.setInt("sfx_volume", convertValueToMixer(value));
+ break;
+
+ case kVolumeSpeech:
+ ConfMan.setInt("speech_volume", convertValueToMixer(value));
+ break;
+ }
+
+ // Resetup mixer
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
+}
+
+uint8 KyraEngine::getVolume(kVolumeEntry vol) {
+ switch (vol) {
+ case kVolumeMusic:
+ return convertValueFromMixer(ConfMan.getInt("music_volume"));
+ break;
+
+ case kVolumeSfx:
+ return convertValueFromMixer(ConfMan.getInt("sfx_volume"));
+ break;
+
+ case kVolumeSpeech:
+ if (speechEnabled())
+ return convertValueFromMixer(ConfMan.getInt("speech_volume"));
+ else
+ return 2;
+ break;
+ }
+
+ return 2;
+}
+
} // End of namespace Kyra
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index 07c7cddf42..03aaf2915c 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -132,6 +132,16 @@ public:
bool speechEnabled();
bool textEnabled();
+ enum kVolumeEntry {
+ kVolumeMusic = 0,
+ kVolumeSfx = 1,
+ kVolumeSpeech = 2
+ };
+
+ // volume reaches from 2 to 97
+ void setVolume(kVolumeEntry vol, uint8 value);
+ uint8 getVolume(kVolumeEntry vol);
+
// quit handling
virtual void quitGame();
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index d5c893afc7..5ee30b8df1 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -1479,6 +1479,16 @@ void GUI_v2::initStaticData() {
GUI_V2_BUTTON(_scrollUpButton, 0x17, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x18, 0x0F, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
GUI_V2_BUTTON(_scrollDownButton, 0x18, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x18, 0x0F, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
+ for (int i = 0; i < 3; ++i) {
+ GUI_V2_BUTTON(_sliderButtons[0][i], 0x19+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x0A, 0x0E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
+ }
+ for (int i = 0; i < 3; ++i) {
+ GUI_V2_BUTTON(_sliderButtons[1][i], 0x1D+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x0A, 0x0E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
+ }
+ for (int i = 0; i < 3; ++i) {
+ GUI_V2_BUTTON(_sliderButtons[2][i], 0x21+i, 0, 0, 0, 0, 0, 0x2200, 0, 0, 0, 0x6E, 0x0E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
+ }
+
for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i) {
GUI_V2_BUTTON(_menuButtons[i], 0x10+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0, 0, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
}
@@ -1487,6 +1497,7 @@ void GUI_v2::initStaticData() {
Button::Callback clickSaveSlotFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::clickSaveSlot);
Button::Callback clickLoadMenuFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::loadMenu);
Button::Callback clickQuitGameFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::quitGame);
+ Button::Callback clickQuitOptionsFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::quitOptionsMenu);
const uint16 *menuStr = _vm->gameFlags().isTalkie ? _menuStringsTalkie : _menuStringsOther;
@@ -1499,6 +1510,7 @@ void GUI_v2::initStaticData() {
GUI_V2_MENU_ITEM(_mainMenu.item[3], 1, 0x04, -1, 0x51, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
_mainMenu.item[3].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::gameOptions);
GUI_V2_MENU_ITEM(_mainMenu.item[4], 1, 0x25, -1, 0x62, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+ _mainMenu.item[4].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::audioOptions);
GUI_V2_MENU_ITEM(_mainMenu.item[5], 1, 0x05, -1, 0x73, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
_mainMenu.item[5].callback = clickQuitGameFunctor;
GUI_V2_MENU_ITEM(_mainMenu.item[6], 1, 0x06, -1, 0x90, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
@@ -1514,12 +1526,23 @@ void GUI_v2::initStaticData() {
GUI_V2_MENU_ITEM(_gameOptions.item[2], 1, 0, 0xA0, 0x40, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x16, 8, 0x42, 0);
_gameOptions.item[2].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::toggleText);
GUI_V2_MENU_ITEM(_gameOptions.item[3], 1, 0x10, -1, 0x6E, 0x6C, 0x0F, 0xFD, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
- _gameOptions.item[3].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::quitOptionsMenu);
+ _gameOptions.item[3].callback = clickQuitOptionsFunctor;
for (int i = 4; i <= 6; ++i)
_gameOptions.item[i].enabled = false;
for (int i = 0; i < 7; ++i)
_gameOptions.item[i].itemId = menuStr[1 * 8 + i + 1];
+ GUI_V2_MENU(_audioOptions, -1, -1, 0x120, 0x88, 0xF8, 0xF9, 0xFA, menuStr[2 * 8], 0xFB, -1, 8, 3, 4, -1, -1, -1, -1);
+ GUI_V2_MENU_ITEM(_audioOptions.item[0], 0, 0, 0xA0, 0x1E, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x17, 8, 0x20, 0);
+ GUI_V2_MENU_ITEM(_audioOptions.item[1], 0, 0, 0xA0, 0x2F, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x18, 8, 0x31, 0);
+ GUI_V2_MENU_ITEM(_audioOptions.item[2], 0, 0, 0xA0, 0x40, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x27, 8, 0x42, 0);
+ GUI_V2_MENU_ITEM(_audioOptions.item[3], 1, 0x10, -1, 0x6E, 0x5C, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+ _audioOptions.item[3].callback = clickQuitOptionsFunctor;
+ for (int i = 4; i <= 6; ++i)
+ _audioOptions.item[i].enabled = false;
+ for (int i = 0; i < 7; ++i)
+ _audioOptions.item[i].itemId = menuStr[2 * 8 + i + 1];
+
GUI_V2_MENU(_choiceMenu, -1, -1, 0x140, 0x38, 0xF8, 0xF9, 0xFA, 0, 0xFE, -1, 8, 0, 2, -1, -1, -1, -1);
GUI_V2_MENU_ITEM(_choiceMenu.item[0], 1, 0x14, 0x18, 0x1E, 0x48, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
_choiceMenu.item[0].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::choiceYes);
@@ -1601,6 +1624,10 @@ const uint16 GUI_v2::_menuStringsOther[] = {
0x016, 0x00A, 0x00D, 0x000, 0x000, 0x000, 0x000, 0x000 // Death Menu String IDs
};
+const int GUI_v2::_sliderBarsPosition[] = {
+ 0x92, 0x1F, 0x92, 0x30, 0x92, 0x41
+};
+
const uint16 KyraEngine_v2::_itemMagicTable[] = {
0x0D, 0x0A, 0x0B, 0,
0x0D, 0x0B, 0x0A, 0,