diff options
author | Eugene Sandulenko | 2005-09-02 20:17:52 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2005-09-02 20:17:52 +0000 |
commit | c8a2de6e6edb3e21ede70e44a9c39cc0c00a63a6 (patch) | |
tree | e7899395fc870140f1ca15d87901f47e87117c0d /saga | |
parent | a861226f203b9cdff448a3cd5642d776837fed7c (diff) | |
download | scummvm-rg350-c8a2de6e6edb3e21ede70e44a9c39cc0c00a63a6.tar.gz scummvm-rg350-c8a2de6e6edb3e21ede70e44a9c39cc0c00a63a6.tar.bz2 scummvm-rg350-c8a2de6e6edb3e21ede70e44a9c39cc0c00a63a6.zip |
Implement option buttons functionality. This fixes bug #1259518 "ITE: Buttons
in Options Dialog not fully functional"
svn-id: r18738
Diffstat (limited to 'saga')
-rw-r--r-- | saga/actor.cpp | 23 | ||||
-rw-r--r-- | saga/game.cpp | 3 | ||||
-rw-r--r-- | saga/interface.cpp | 106 | ||||
-rw-r--r-- | saga/music.cpp | 5 | ||||
-rw-r--r-- | saga/saga.cpp | 19 | ||||
-rw-r--r-- | saga/saga.h | 7 | ||||
-rw-r--r-- | saga/sound.cpp | 11 | ||||
-rw-r--r-- | saga/sound.h | 5 |
8 files changed, 118 insertions, 61 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp index 416f3d1aa6..b8e84ec979 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -918,7 +918,6 @@ void Actor::handleSpeech(int msec) { int sampleLength; bool removeFirst; int i; - int talkspeed; ActorData *actor; int width, height, height2; Point posPoint; @@ -976,20 +975,29 @@ void Actor::handleSpeech(int msec) { 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::drawActors() { } void Actor::drawSpeech(void) { - if (!isSpeaking() || !_activeSpeech.playing || _vm->_script->_skipSpeeches) + if (!isSpeaking() || !_activeSpeech.playing || _vm->_script->_skipSpeeches + || !_vm->_subtitlesEnabled) return; int i; diff --git a/saga/game.cpp b/saga/game.cpp index ea9f3515ed..2e413d8192 100644 --- a/saga/game.cpp +++ b/saga/game.cpp @@ -95,7 +95,8 @@ static PanelButton ITE_OptionPanelButtons[] = { {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 }; diff --git a/saga/interface.cpp b/saga/interface.cpp index e7026f45da..d26456c12b 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -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 @@ void Interface::drawPanelText(Surface *ds, InterfacePanel *panel, PanelButton *p 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 @@ void Interface::setOption(PanelButton *panelButton) { 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 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo 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 @@ void Interface::drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelBut 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); diff --git a/saga/music.cpp b/saga/music.cpp index 028af66141..2bc49f0ba0 100644 --- a/saga/music.cpp +++ b/saga/music.cpp @@ -322,10 +322,11 @@ void Music::setVolume(int volume, int time) { _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 @@ void Music::play(uint32 resourceId, MusicFlags flags) { 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); diff --git a/saga/saga.cpp b/saga/saga.cpp index 0d6b73b12e..6536ffa951 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -138,8 +138,6 @@ SagaEngine::SagaEngine(GameDetector *detector, OSystem *syst) warning("Sound initialization failed."); } - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); - _displayClip.left = _displayClip.top = 0; } @@ -176,8 +174,13 @@ void SagaEngine::errorString(const char *buf1, char *buf2) { } 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 @@ int SagaEngine::init(GameDetector &detector) { } 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 @@ int SagaEngine::init(GameDetector &detector) { } // Initialize system specific sound - _sound = new Sound(this, _mixer, _soundEnabled); - if (!_soundEnabled) { + _sound = new Sound(this, _mixer, _soundVolume); + if (!_soundVolume) { debug(1, "Sound disabled."); } diff --git a/saga/saga.h b/saga/saga.h index 1ffb0e6697..603ccff171 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -569,9 +569,10 @@ public: return isSaveListFull() ? _saveFilesCount : _saveFilesCount + 1; } - int _soundEnabled; - int _musicEnabled; - + int _soundVolume; + int _musicVolume; + bool _subtitlesEnabled; + int _readingSpeed; SndRes *_sndRes; Sound *_sound; diff --git a/saga/sound.cpp b/saga/sound.cpp index a115947fcd..26249abcea 100644 --- a/saga/sound.cpp +++ b/saga/sound.cpp @@ -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 @@ void Sound::stopAll() { stopSound(); } +void Sound::setVolume(int volume) { + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume); +} + } // End of namespace Saga diff --git a/saga/sound.h b/saga/sound.h index 9cb7584067..7ddeef4c22 100644 --- a/saga/sound.h +++ b/saga/sound.h @@ -61,7 +61,7 @@ struct SndHandle { 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 @@ public: 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; |