TITANIC: Fix method names in CMusicRoomInstrument

This commit is contained in:
Paul Gilbert 2017-02-12 13:05:37 -05:00
parent a542104f3c
commit e00fb13809
4 changed files with 81 additions and 69 deletions

View File

@ -108,7 +108,7 @@ void CMusicRoomHandler::stop() {
}
for (int idx = 0; idx < 4; ++idx) {
_instruments[idx]->reset();
_instruments[idx]->clear();
if (_active && _instruments[idx])
_instruments[idx]->stop();
}
@ -171,10 +171,10 @@ void CMusicRoomHandler::setMuteControl(MusicInstrument instrument, bool value) {
_array1[instrument]._muteControl = value;
}
void CMusicRoomHandler::trigger() {
void CMusicRoomHandler::start() {
if (_active) {
for (int idx = 0; idx < 4; ++idx)
_instruments[idx]->trigger();
_instruments[idx]->start();
}
}
@ -182,7 +182,7 @@ bool CMusicRoomHandler::update() {
uint currentTicks = g_vm->_events->getTicksCount();
if (!_startTicks) {
trigger();
start();
_startTicks = currentTicks;
} else if (!_soundStartTicks && currentTicks >= (_startTicks + 3000)) {
if (_waveFile) {
@ -260,7 +260,7 @@ void CMusicRoomHandler::fn1() {
const CValuePair &vp = (*_musicObjs[instrument])[_position[instrument]];
if (vp._field0 != 0x7FFFFFFF) {
int amount = getPitch(instrument, _position[instrument]);
_instruments[instrument]->start(amount);
_instruments[instrument]->update(amount);
}
if (ins1._directionControl == ins2._directionControl) {
@ -276,14 +276,14 @@ void CMusicRoomHandler::fn1() {
bool CMusicRoomHandler::updateInstrument(MusicInstrument instrument) {
int &arrIndex = _startPos[instrument];
if (arrIndex < 0) {
_instruments[instrument]->reset();
_instruments[instrument]->clear();
return false;
}
const CMusicObject &mObj = *_musicObjs[instrument];
if (arrIndex >= mObj.size()) {
arrIndex = -1;
_instruments[instrument]->reset();
_instruments[instrument]->clear();
return false;
}
@ -291,7 +291,7 @@ bool CMusicRoomHandler::updateInstrument(MusicInstrument instrument) {
int size = static_cast<int>(fn3(instrument, arrIndex) * 44100.0) & ~1;
if (vp._field0 == 0x7FFFFFFF || _array1[instrument]._muteControl)
_instruments[instrument]->setSize(size);
_instruments[instrument]->reset(size);
else
_instruments[instrument]->chooseWaveFile(getPitch(instrument, arrIndex), size);

View File

@ -67,7 +67,10 @@ private:
uint _startTicks;
int _volume;
private:
void trigger();
/**
* Starts music room instruments animation
*/
void start();
void updateAudio();
void fn1();

View File

@ -104,7 +104,58 @@ CWaveFile *CMusicRoomInstrument::createWaveFile(const CString &name) {
return _soundManager->loadSound(name);
}
void CMusicRoomInstrument::start(int val) {
void CMusicRoomInstrument::start() {
if (_gameObjects[0]) {
switch (_instrument) {
case MV_PIANO:
_gameObjects[0]->playMovie(0, 29, MOVIE_STOP_PREVIOUS);
_gameObjects[2]->loadFrame(14);
_gameObjects[3]->loadFrame(22);
break;
case MV_BELLS:
_gameObjects[0]->loadFrame(0);
_gameObjects[0]->movieSetAudioTiming(true);
break;
case MV_SNAKE:
_field4C = 22;
_gameObjects[1]->playMovie(0, 22, 0);
_gameObjects[2]->playMovie(0, 35, MOVIE_STOP_PREVIOUS);
_gameObjects[0]->playMovie(0, 1, MOVIE_STOP_PREVIOUS);
_gameObjects[0]->playMovie(0, 1, 0);
_gameObjects[0]->playMovie(0, 1, 0);
_gameObjects[0]->playMovie(0, 1, 0);
_gameObjects[0]->playMovie(0, 1, 0);
break;
default:
break;
}
}
}
void CMusicRoomInstrument::stop() {
if (_gameObjects[0]) {
switch (_instrument) {
case MV_PIANO:
_gameObjects[1]->setVisible(false);
_gameObjects[2]->setVisible(false);
_gameObjects[3]->setVisible(false);
_gameObjects[0]->playMovie(29, 58, MOVIE_STOP_PREVIOUS);
break;
case MV_BELLS:
_gameObjects[0]->stopMovie();
break;
default:
break;
}
}
}
void CMusicRoomInstrument::update(int val) {
if (_gameObjects[0]) {
switch (_instrument) {
case MV_PIANO:
@ -202,58 +253,7 @@ void CMusicRoomInstrument::start(int val) {
}
}
void CMusicRoomInstrument::stop() {
if (_gameObjects[0]) {
switch (_instrument) {
case MV_PIANO:
_gameObjects[1]->setVisible(false);
_gameObjects[2]->setVisible(false);
_gameObjects[3]->setVisible(false);
_gameObjects[0]->playMovie(29, 58, MOVIE_STOP_PREVIOUS);
break;
case MV_BELLS:
_gameObjects[0]->stopMovie();
break;
default:
break;
}
}
}
void CMusicRoomInstrument::trigger() {
if (_gameObjects[0]) {
switch (_instrument) {
case MV_PIANO:
_gameObjects[0]->playMovie(0, 29, MOVIE_STOP_PREVIOUS);
_gameObjects[2]->loadFrame(14);
_gameObjects[3]->loadFrame(22);
break;
case MV_BELLS:
_gameObjects[0]->loadFrame(0);
_gameObjects[0]->movieSetAudioTiming(true);
break;
case MV_SNAKE:
_field4C = 22;
_gameObjects[1]->playMovie(0, 22, 0);
_gameObjects[2]->playMovie(0, 35, MOVIE_STOP_PREVIOUS);
_gameObjects[0]->playMovie(0, 1, MOVIE_STOP_PREVIOUS);
_gameObjects[0]->playMovie(0, 1, 0);
_gameObjects[0]->playMovie(0, 1, 0);
_gameObjects[0]->playMovie(0, 1, 0);
_gameObjects[0]->playMovie(0, 1, 0);
break;
default:
break;
}
}
}
void CMusicRoomInstrument::reset() {
void CMusicRoomInstrument::clear() {
_waveIndex = 0;
_readPos = 0;
_readIncrement = 0;
@ -261,7 +261,7 @@ void CMusicRoomInstrument::reset() {
_count = 0;
}
void CMusicRoomInstrument::setSize(uint total) {
void CMusicRoomInstrument::reset(uint total) {
_waveIndex = -1;
_readPos = 0;
_readIncrement = 0;

View File

@ -97,10 +97,11 @@ public:
*/
void load(int index, const CString &filename, int v3);
/**
* Starts the music and associated animations
*/
void start(int val);
void start();
/**
* Stops the music and associated animations
@ -108,13 +109,21 @@ public:
void stop();
/**
* Called regularly to handle triggering the animation of the
* musical instrument associated with the instance
* Handles regular updates of the instrument, allowing associated
* objects to start animations as the music is played
*/
void trigger();
void update(int val);
void reset();
void setSize(uint total);
/**
* Clear the instrument
*/
void clear();
/**
* Resets the instrument, and sets the maximum for how much data can
* be read from the wave files during each read action
*/
void reset(uint total);
/**
* If there is any wave file currently specified, reads it in