Added speechEnabled() and textEnabled() to simplify the text/speech config checks a bit, and added checks some more places

svn-id: r22703
This commit is contained in:
Oystein Eftevaag 2006-05-28 06:07:54 +00:00
parent ea05e31330
commit dbaf5206ae
5 changed files with 58 additions and 36 deletions

View File

@ -111,21 +111,21 @@ int KyraEngine::buttonAmuletCallback(Button *caller) {
return 1;
if (_itemInHand != -1) {
assert(_putDownFirst);
if (_features & GF_TALKIE && (_configVoice == 1 || _configVoice == 2)) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(2000);
}
if (_features & GF_FLOPPY || (_configVoice == 0 || _configVoice == 2))
if (textEnabled())
characterSays(_putDownFirst[0], 0, -2);
return 1;
}
if (queryGameFlag(0xF1)) {
assert(_waitForAmulet);
if (_features & GF_TALKIE && (_configVoice == 1 || _configVoice == 2)) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(2001);
}
if (_features & GF_FLOPPY || (_configVoice == 0 || _configVoice == 2))
if (textEnabled())
characterSays(_waitForAmulet[0], 0, -2);
return 1;
}
@ -133,11 +133,11 @@ int KyraEngine::buttonAmuletCallback(Button *caller) {
assert(_blackJewel);
_animator->makeBrandonFaceMouse();
drawJewelPress(jewel, 1);
if (_features & GF_TALKIE && (_configVoice == 1 || _configVoice == 2)) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(2002);
}
if (_features & GF_FLOPPY || (_configVoice == 0 || _configVoice == 2))
if (textEnabled())
characterSays(_blackJewel[0], 0, -2);
return 1;
}
@ -165,11 +165,11 @@ int KyraEngine::buttonAmuletCallback(Button *caller) {
} else if (_brandonStatusBit == 0) {
seq_brandonHealing();
assert(_healingTip);
if (_features & GF_TALKIE && (_configVoice == 1 || _configVoice == 2)) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(2003);
}
if (_features & GF_FLOPPY || (_configVoice == 0 || _configVoice == 2))
if (textEnabled())
characterSays(_healingTip[0], 0, -2);
}
break;
@ -181,11 +181,11 @@ int KyraEngine::buttonAmuletCallback(Button *caller) {
case 2:
if (_brandonStatusBit & 1) {
assert(_wispJewelStrings);
if (_features & GF_TALKIE && (_configVoice == 1 || _configVoice == 2)) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(2004);
}
if (_features & GF_FLOPPY || (_configVoice == 0 || _configVoice == 2))
if (textEnabled())
characterSays(_wispJewelStrings[0], 0, -2);
} else {
if (_brandonStatusBit & 2) {
@ -210,11 +210,11 @@ int KyraEngine::buttonAmuletCallback(Button *caller) {
case 3:
seq_dispelMagicAnimation();
assert(_magicJewelString);
if (_features & GF_TALKIE && (_configVoice == 1 || _configVoice == 2)) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(2007);
}
if (_features & GF_FLOPPY || (_configVoice == 0 || _configVoice == 2))
if (textEnabled())
characterSays(_magicJewelString[0], 0, -2);
break;

View File

@ -301,6 +301,9 @@ public:
void snd_playSoundEffect(int track);
void snd_playWanderScoreViaMap(int command, int restart);
bool speechEnabled();
bool textEnabled();
void drawSentenceCommand(const char *sentence, int unk1);
void updateSentenceCommand(const char *str1, const char *str2, int unk1);
void updateTextFade();

View File

@ -45,11 +45,11 @@ int KyraEngine::cmd_characterSays(ScriptState *script) {
_skipFlag = false;
if (_features & GF_TALKIE) {
debugC(3, kDebugLevelScriptFuncs, "cmd_characterSays(%p) (%d, '%s', %d, %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3));
if (_configVoice == 1 || _configVoice == 2) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(stackPos(0));
}
if (_configVoice == 0 || _configVoice == 2)
if (textEnabled())
characterSays(stackPosString(1), stackPos(2), stackPos(3));
} else {
debugC(3, kDebugLevelScriptFuncs, "cmd_characterSays(%p) ('%s', %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2));
@ -618,12 +618,12 @@ int KyraEngine::cmd_customPrintTalkString(ScriptState *script) {
if (_features & GF_TALKIE) {
debugC(3, kDebugLevelScriptFuncs, "cmd_customPrintTalkString(%p) (%d, '%s', %d, %d, %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3), stackPos(4) & 0xFF);
if (_configVoice == 1 || _configVoice == 2) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(stackPos(0));
}
_skipFlag = false;
if (_configVoice == 0 || _configVoice == 2)
if (textEnabled())
_text->printTalkTextMessage(stackPosString(1), stackPos(2), stackPos(3), stackPos(4) & 0xFF, 0, 2);
} else {
debugC(3, kDebugLevelScriptFuncs, "cmd_customPrintTalkString(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3) & 0xFF);

View File

@ -337,16 +337,18 @@ void KyraEngine::seq_brandonHealing2() {
freeShapes123();
_screen->showMouse();
assert(_poisonGone);
if (_features & GF_TALKIE) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(2010);
}
characterSays(_poisonGone[0], 0, -2);
if (_features & GF_TALKIE) {
if (textEnabled())
characterSays(_poisonGone[0], 0, -2);
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(2011);
}
characterSays(_poisonGone[1], 0, -2);
if (textEnabled())
characterSays(_poisonGone[1], 0, -2);
}
void KyraEngine::seq_poisonDeathNow(int now) {
@ -359,30 +361,34 @@ void KyraEngine::seq_poisonDeathNow(int now) {
if (_poisonDeathCounter >= 2) {
snd_playWanderScoreViaMap(1, 1);
assert(_thePoison);
if (_features & GF_TALKIE) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(7000);
}
characterSays(_thePoison[0], 0, -2);
if (_features & GF_TALKIE) {
if (textEnabled())
characterSays(_thePoison[0], 0, -2);
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(7001);
}
characterSays(_thePoison[1], 0, -2);
if (textEnabled())
characterSays(_thePoison[1], 0, -2);
seq_poisonDeathNowAnim();
_deathHandler = 3;
} else {
assert(_thePoison);
if (_features & GF_TALKIE) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(7002);
}
characterSays(_thePoison[2], 0, -2);
if (_features & GF_TALKIE) {
if (textEnabled())
characterSays(_thePoison[2], 0, -2);
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(7004);
}
characterSays(_thePoison[3], 0, -2);
if (textEnabled())
characterSays(_thePoison[3], 0, -2);
}
}
@ -474,18 +480,20 @@ void KyraEngine::seq_playFluteAnimation() {
if (soundType == 1) {
assert(_fluteString);
if (_features & GF_TALKIE) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(1000);
}
characterSays(_fluteString[0], 0, -2);
if (textEnabled())
characterSays(_fluteString[0], 0, -2);
} else if (soundType == 2) {
assert(_fluteString);
if (_features & GF_TALKIE) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(1001);
}
characterSays(_fluteString[1], 0, -2);
if (textEnabled())
characterSays(_fluteString[1], 0, -2);
}
}
@ -756,11 +764,12 @@ void KyraEngine::seq_fillFlaskWithWater(int item, int type) {
if (item >= 60 && item <= 77) {
assert(_flaskFull);
if (_features & GF_TALKIE) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
snd_playVoiceFile(8006);
}
characterSays(_flaskFull[0], 0, -2);
if (textEnabled())
characterSays(_flaskFull[0], 0, -2);
} else if (item == 78) {
assert(type >= 0 && type < ARRAYSIZE(flaskTable1));
newItem = flaskTable1[type];
@ -778,7 +787,7 @@ void KyraEngine::seq_fillFlaskWithWater(int item, int type) {
_itemInHand = newItem;
assert(_fullFlask);
assert(type < _fullFlask_Size && type >= 0);
if (_features & GF_TALKIE) {
if (speechEnabled()) {
snd_voiceWaitForFinish();
static const uint16 voiceEntries[] = {
0x1F40, 0x1F41, 0x1F42, 0x1F45
@ -786,7 +795,8 @@ void KyraEngine::seq_fillFlaskWithWater(int item, int type) {
assert(type < ARRAYSIZE(voiceEntries));
snd_playVoiceFile(voiceEntries[type]);
}
characterSays(_fullFlask[type], 0, -2);
if (textEnabled())
characterSays(_fullFlask[type], 0, -2);
}
void KyraEngine::seq_playDrinkPotionAnim(int item, int unk2, int flags) {

View File

@ -403,6 +403,15 @@ void SoundMidiPC::beginFadeOut() {
#pragma mark -
bool KyraEngine::speechEnabled() {
return _features & GF_TALKIE && (_configVoice == 1 || _configVoice == 2);
}
bool KyraEngine::textEnabled() {
return _features & GF_FLOPPY || (_configVoice == 0 || _configVoice == 2);
}
void KyraEngine::snd_playTheme(int file, int track) {
debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playTheme(%d)", file);
assert(file < _musicFilesCount);