- Enabled missing calls to _sound->playSong, now it should *really* play all SFX

- Moved sound/music related toggle variables to Sound class
- Changed "Couldn't find file.." warning() to debug(7, ..)

svn-id: r11303
This commit is contained in:
Joost Peters 2003-11-15 21:33:04 +00:00
parent b938b63ddf
commit f979f185af
8 changed files with 41 additions and 25 deletions

View File

@ -25,6 +25,7 @@
#include "queen/input.h"
#include "queen/graphics.h"
#include "queen/logic.h"
#include "queen/sound.h"
#include "queen/talk.h"
#include "queen/walk.h"
@ -125,8 +126,8 @@ void SelectedCmdState::init() {
}
Command::Command(Logic *l, Graphics *g, Input *i, Walk *w)
: _logic(l), _graphics(g), _input(i), _walk(w) {
Command::Command(Logic *l, Graphics *g, Input *i, Walk *w, Sound *s)
: _logic(l), _graphics(g), _input(i), _walk(w), _sound(s) {
_cmdText._graphics = _graphics;
_cmdText._logic = _logic;
}
@ -365,7 +366,7 @@ void Command::executeCurrentAction(bool walk) {
if (_selCmd.action.value() != VERB_OPEN && _selCmd.action.value() != VERB_CLOSE) {
// only play song if it's a PLAY BEFORE type
if (com->song > 0) {
// XXX playsong(com->song);
_sound->playSong(com->song);
}
}
@ -423,7 +424,7 @@ void Command::executeCurrentAction(bool walk) {
// only play song if it's a PLAY AFTER type
if (com->song > 0) {
// XXX playsong(com->song);
_sound->playSong(com->song);
}
clear(true);
@ -1045,7 +1046,7 @@ void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool
// play music if it exists... (or SFX for open/close door)
if (song != 0) {
// XXX playsong(abs(song));
_sound->playSong(abs(song));
}
if (objData->entryObj != 0) {
@ -1067,7 +1068,7 @@ void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool
// play music if it exists... (or SFX for open/close door)
if (song != 0) {
// XXX playsong(abs(song));
_sound->playSong(abs(song));
}
if (objData->entryObj != 0) {

View File

@ -87,7 +87,7 @@ struct SelectedCmdState {
class Command {
public:
Command(Logic*, Graphics*, Input*, Walk*);
Command(Logic*, Graphics*, Input*, Walk*, Sound*);
//! initialise command construction
void clear(bool clearTexts);
@ -188,6 +188,7 @@ private:
Logic *_logic;
Graphics *_graphics;
Input *_input;
Sound *_sound;
Walk *_walk;
};

View File

@ -1072,7 +1072,7 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) {
return NULL;
if (objAnim[i].song > 0)
/* XXX playsong(objAnim[i].song) */ ;
_sound->playSong(objAnim[i].song);
// Load but don't play
if(objAnim[i].song < 0) {
@ -1396,9 +1396,9 @@ void Cutaway::run(char *nextFilename) {
_input->cutawayQuitReset();
if (_songBeforeComic > 0)
/* XXX playsong(_songBeforeComic) */ ;
_sound->playSong(_songBeforeComic);
else if (_lastSong > 0)
/* XXX playsong(_lastSong) */ ;
_sound->playSong(_lastSong);
}
void Cutaway::stop() {

View File

@ -28,6 +28,7 @@
#include "queen/display.h"
#include "queen/graphics.h"
#include "queen/input.h"
#include "queen/sound.h"
#include "queen/talk.h"
#include "queen/walk.h"
@ -183,7 +184,7 @@ Logic::Logic(Resource *theResource, Graphics *graphics, Display *theDisplay, Inp
_joe.x = _joe.y = 0;
_joe.scale = 100;
_walk = new Walk(this, _graphics);
_cmd = new Command(this, _graphics, _input, _walk);
_cmd = new Command(this, _graphics, _input, _walk, _sound);
_dbg = new Debug(_input, this, _graphics);
memset(_gameState, 0, sizeof(_gameState));
memset(_talkSelected, 0, sizeof(_talkSelected));
@ -380,9 +381,9 @@ void Logic::initialise() {
_settings.textToggle = true;
if (_resource->isFloppy())
_settings.speechToggle = false;
_sound->speechToggle(false);
else
_settings.speechToggle = true;
_sound->speechToggle(true);
_cmd->clear(false);
_scene = 0;
@ -2376,9 +2377,9 @@ bool Logic::gameSave(uint16 slot, const char *desc) {
WRITE_BE_UINT16(ptr, _settings.talkSpeed); ptr += 2;
WRITE_BE_UINT16(ptr, _settings.musicVolume); ptr += 2;
WRITE_BE_UINT16(ptr, _settings.sfxToggle ? 1 : 0); ptr += 2;
WRITE_BE_UINT16(ptr, _settings.speechToggle ? 1 : 0); ptr += 2;
WRITE_BE_UINT16(ptr, _settings.musicToggle ? 1 : 0); ptr += 2;
WRITE_BE_UINT16(ptr, _sound->sfxOn() ? 1 : 0); ptr += 2;
WRITE_BE_UINT16(ptr, _sound->speechOn() ? 1 : 0); ptr += 2;
WRITE_BE_UINT16(ptr, _sound->musicOn() ? 1 : 0); ptr += 2;
WRITE_BE_UINT16(ptr, _settings.textToggle ? 1 : 0); ptr += 2;
for (i = 0; i < 4; i++) {
@ -2443,9 +2444,9 @@ bool Logic::gameLoad(uint16 slot) {
ptr += 32; //skip description
_settings.talkSpeed = (int16)READ_BE_UINT16(ptr); ptr += 2;
_settings.musicVolume = (int16)READ_BE_UINT16(ptr); ptr += 2;
_settings.sfxToggle = READ_BE_UINT16(ptr) != 0; ptr += 2;
_settings.speechToggle = READ_BE_UINT16(ptr) != 0; ptr += 2;
_settings.musicToggle = READ_BE_UINT16(ptr) != 0; ptr += 2;
_sound->sfxToggle(READ_BE_UINT16(ptr) != 0); ptr += 2;
_sound->speechToggle(READ_BE_UINT16(ptr) != 0); ptr += 2;
_sound->musicToggle(READ_BE_UINT16(ptr) != 0); ptr += 2;
_settings.textToggle = READ_BE_UINT16(ptr) != 0; ptr += 2;
for (i = 0; i < 4; i++) {

View File

@ -43,10 +43,7 @@ struct ZoneSlot {
struct GameConfig {
int musicVolume;
bool musicToggle;
bool sfxToggle;
bool textToggle;
bool speechToggle;
int talkSpeed;
};

View File

@ -124,7 +124,7 @@ int32 Resource::resourceIndex(const char *filename) {
high = cur;
}
warning("Couldn't find file '%s'", entryName);
debug(7, "Couldn't find file '%s'", entryName);
return -1;
}

View File

@ -95,7 +95,7 @@ static ov_callbacks g_File_wrap = {
#endif
Sound::Sound(SoundMixer *mixer, Input *input, Resource *resource) :
_mixer(mixer), _input(input), _resource(resource), _lastOverride(0), _currentSong(0), _sfxHandle(0) {
_mixer(mixer), _input(input), _resource(resource), _lastOverride(0), _currentSong(0), _sfxHandle(0), _sfxToggle(true), _speechToggle(true), _musicToggle(true) {
}
Sound::~Sound() {
@ -137,7 +137,7 @@ void Sound::waitSfxFinished() {
void Sound::playSong(int16 songNum) {
int16 newTune = _song[songNum - 1].tuneList[0];
if (_tune[newTune - 1].sfx[0] /* && _sfxToggle */ )
if (_tune[newTune - 1].sfx[0] && sfxOn())
sfxPlay(_sfxName[_tune[newTune - 1].sfx[0] - 1]);
}

View File

@ -56,6 +56,18 @@ public:
void waitSfxFinished();
void playSong(int16 songNum);
bool sfxOn() { return _sfxToggle; }
void sfxToggle(bool val) { _sfxToggle = val; }
void toggleSfx() { _sfxToggle ^= true; }
bool speechOn() { return _speechToggle; }
void speechToggle(bool val) { _speechToggle = val; }
void toggleSpeech() { _speechToggle ^= true; }
bool musicOn() { return _musicToggle; }
void musicToggle(bool val) { _musicToggle = val; }
void toggleMusic() { _musicToggle ^= true; }
protected:
SoundMixer *_mixer;
Input *_input;
@ -64,6 +76,10 @@ protected:
static const songData _song[];
static const tuneData _tune[];
static const char *_sfxName[];
bool _sfxToggle;
bool _speechToggle;
bool _musicToggle;
int16 _lastOverride;
int16 _lastMerge;