Disable voices when voice files do not exist (like the original interpreter does), instead of exiting with an error. This is necessary for devices with little space

svn-id: r29956
This commit is contained in:
Filippos Karapetis 2007-12-23 02:33:58 +00:00
parent 275c91be33
commit 5b74b676ce
5 changed files with 41 additions and 22 deletions

View File

@ -1597,15 +1597,20 @@ void Interface::setOption(PanelButton *panelButton) {
ConfMan.setInt("sfx_volume", _vm->_soundVolume * 25);
break;
case kTextVoices:
if (_vm->_subtitlesEnabled && _vm->_voicesEnabled) { // Both
_vm->_subtitlesEnabled = false; // Set it to "Audio"
_vm->_voicesEnabled = true; // Not necessary, just for completeness
} else if (!_vm->_subtitlesEnabled && _vm->_voicesEnabled) {
_vm->_subtitlesEnabled = true; // Set it to "Text"
if (_vm->_voiceFilesExist) {
if (_vm->_subtitlesEnabled && _vm->_voicesEnabled) { // Both
_vm->_subtitlesEnabled = false; // Set it to "Audio"
_vm->_voicesEnabled = true; // Not necessary, just for completeness
} else if (!_vm->_subtitlesEnabled && _vm->_voicesEnabled) {
_vm->_subtitlesEnabled = true; // Set it to "Text"
_vm->_voicesEnabled = false;
} else if (_vm->_subtitlesEnabled && !_vm->_voicesEnabled) {
_vm->_subtitlesEnabled = true; // Set it to "Both"
_vm->_voicesEnabled = true;
}
} else {
_vm->_subtitlesEnabled = true; // Set it to "Text"
_vm->_voicesEnabled = false;
} else if (_vm->_subtitlesEnabled && !_vm->_voicesEnabled) {
_vm->_subtitlesEnabled = true; // Set it to "Both"
_vm->_voicesEnabled = true;
}
ConfMan.setBool("subtitles", _vm->_subtitlesEnabled);

View File

@ -360,6 +360,8 @@ bool Resource::createContexts() {
bool censoredVersion = false;
uint16 voiceFileType = GAME_VOICEFILE;
_vm->_voiceFilesExist = true;
// If the Wyrmkeep credits file is found, set the Wyrmkeep version flag to true
if (Common::File::exists("graphics/credit3n.dlt")) {
_vm->_gf_wyrmkeep = true;
@ -459,6 +461,10 @@ bool Resource::createContexts() {
} else {
// No voice file found, don't add any file to the array
voicesFileInArray = true;
warning("No voice file found, voices will be disabled");
_vm->_voicesEnabled = false;
_vm->_subtitlesEnabled = true;
_vm->_voiceFilesExist = false;
}
} else {
// If the voices file is not specified in the detector table, add it here
@ -494,6 +500,10 @@ bool Resource::createContexts() {
} else {
// No voice file found, don't add any file to the array
voicesFileInArray = true;
warning("No voice file found, voices will be disabled");
_vm->_voicesEnabled = false;
_vm->_subtitlesEnabled = true;
_vm->_voiceFilesExist = false;
}
}
}
@ -554,9 +564,9 @@ bool Resource::createContexts() {
}
context->serial = 0;
// IHNM has serveral different voice files, so we need to allow
// IHNM has several different voice files, so we need to allow
// multiple resource contexts of the same type. We tell them
// apart by assigning each of the duplicates an unique serial
// apart by assigning each of the duplicates a unique serial
// number. The default behaviour when requesting a context will
// be to look for serial number 0.

View File

@ -224,15 +224,17 @@ int SagaEngine::init() {
_gfx->initPalette();
if (getGameType() == GType_IHNM) {
if (!ConfMan.hasKey("voices")) {
_voicesEnabled = true;
ConfMan.setBool("voices", true);
if (_voiceFilesExist) {
if (getGameType() == GType_IHNM) {
if (!ConfMan.hasKey("voices")) {
_voicesEnabled = true;
ConfMan.setBool("voices", true);
} else {
_voicesEnabled = ConfMan.getBool("voices");
}
} else {
_voicesEnabled = ConfMan.getBool("voices");
_voicesEnabled = true;
}
} else {
_voicesEnabled = true;
}
// FIXME: This is the ugly way of reducing redraw overhead. It works

View File

@ -522,6 +522,7 @@ public:
int _musicVolume;
bool _subtitlesEnabled;
bool _voicesEnabled;
bool _voiceFilesExist;
int _readingSpeed;
bool _copyProtection;

View File

@ -106,11 +106,6 @@ void SndRes::setVoiceBank(int serial) {
_voiceSerial = serial;
_voiceContext = _vm->_resource->getContext(GAME_VOICEFILE, _voiceSerial);
if (_voiceContext == NULL) {
error("SndRes::SndRes resource context not found");
}
}
void SndRes::playSound(uint32 resourceId, int volume, bool loop) {
@ -129,6 +124,9 @@ void SndRes::playSound(uint32 resourceId, int volume, bool loop) {
void SndRes::playVoice(uint32 resourceId) {
SoundBuffer buffer;
if (!(_vm->_voiceFilesExist))
return;
if (_vm->getGameType() == GType_IHNM && !(_vm->_voicesEnabled))
return;
@ -330,6 +328,9 @@ int SndRes::getVoiceLength(uint32 resourceId) {
double msDouble;
SoundBuffer buffer;
if (!(_vm->_voiceFilesExist))
return -1;
if (!load(_voiceContext, resourceId, buffer, true)) {
return -1;
}