Skip to content

Commit

Permalink
MORTEVIELLE: Get rid of setParent() in TextHandler and SoundManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Jan 9, 2014
1 parent d8d4a2c commit d19af62
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 67 deletions.
22 changes: 11 additions & 11 deletions engines/mortevielle/actions.cpp
Expand Up @@ -663,11 +663,11 @@ void MortevielleEngine::fctOpen() {
|| (_coreVar._currPlace == PURPLE_ROOM)
|| (_coreVar._currPlace == BLUE_ROOM)) {
if (getRandomNumber(1, 4) == 3)
_soundManager.startSpeech(7, 9, 1);
_soundManager->startSpeech(7, 9, 1);
}
_openObjects[i] = _num;
displayAnimFrame(1, _num);
_soundManager.waitSpeech();
_soundManager->waitSpeech();
}
int tmpPlace = _coreVar._currPlace;
if (_coreVar._currPlace == CRYPT)
Expand Down Expand Up @@ -731,7 +731,7 @@ void MortevielleEngine::fctPlace() {
displayAnimFrame(1, 1);
handleDescriptionText(2, 165);
displayEmptyHand();
_soundManager.startSpeech(6, -9, 1);
_soundManager->startSpeech(6, -9, 1);

// Do you want to enter the hidden passage?
int answer = _dialogManager.show(getEngineString(S_YES_NO));
Expand Down Expand Up @@ -832,7 +832,7 @@ void MortevielleEngine::fctTurn() {
_crep = 997;
if ((_coreVar._currPlace == ATTIC) && (_coreVar._atticRodHoleObjectId == 159) && (_coreVar._atticBallHoleObjectId == 141)) {
handleDescriptionText(2, 167);
_soundManager.startSpeech(7, 9, 1);
_soundManager->startSpeech(7, 9, 1);
int answer = _dialogManager.show(getEngineString(S_YES_NO));
if (answer == 1)
_endGame = true;
Expand All @@ -842,7 +842,7 @@ void MortevielleEngine::fctTurn() {
if ((_coreVar._currPlace == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId == 143)) {
handleDescriptionText(2, 175);
clearVerbBar();
_soundManager.startSpeech(6, -9, 1);
_soundManager->startSpeech(6, -9, 1);
int answer = _dialogManager.show(getEngineString(S_YES_NO));
if (answer == 1) {
_coreVar._currPlace = CRYPT;
Expand Down Expand Up @@ -967,7 +967,7 @@ void MortevielleEngine::fctKnock() {

if (_coreVar._currPlace == ROOM26) {
int rand = (getRandomNumber(0, 8)) - 4;
_soundManager.startSpeech(11, rand, 1);
_soundManager->startSpeech(11, rand, 1);
int pres = getPresenceStats(rand, _coreVar._faithScore, _roomDoorId);
if (_roomDoorId != OWN_ROOM) {
if (pres != -500) {
Expand Down Expand Up @@ -1185,9 +1185,9 @@ void MortevielleEngine::fctEnter() {
_crep = 179;
else {
int randVal = (getRandomNumber(0, 10)) - 5;
_soundManager.startSpeech(7, randVal, 1);
_soundManager->startSpeech(7, randVal, 1);
displayAnimFrame(1, 1);
_soundManager.waitSpeech();
_soundManager->waitSpeech();

int charIndex = convertBitIndexToCharacterIndex(pres);
++_coreVar._faithScore;
Expand All @@ -1207,9 +1207,9 @@ void MortevielleEngine::fctEnter() {
}
} else {
int randVal = (getRandomNumber(0, 10)) - 5;
_soundManager.startSpeech(7, randVal, 1);
_soundManager->startSpeech(7, randVal, 1);
displayAnimFrame(1, 1);
_soundManager.waitSpeech();
_soundManager->waitSpeech();

_coreVar._currPlace = _roomDoorId;
prepareDisplayText();
Expand Down Expand Up @@ -1627,7 +1627,7 @@ void MortevielleEngine::endGame() {
testKey(false);
_mouse->hideMouse();
_caff = 70;
_text.taffich();
_text->taffich();
clearScreen();
drawDiscussionBox();
startDialog(141);
Expand Down
14 changes: 7 additions & 7 deletions engines/mortevielle/dialogs.cpp
Expand Up @@ -298,7 +298,7 @@ bool DialogManager::showKnowledgeCheck() {
int dialogHeight = 23;
_vm->_screenSurface.fillRect(15, Common::Rect(0, 14, 630, dialogHeight));
Common::String tmpStr = _vm->getString(textIndexArr[indx]);
_vm->_text.displayStr(tmpStr, 20, 15, 100, 2, 0);
_vm->_text->displayStr(tmpStr, 20, 15, 100, 2, 0);

int firstOption;
int lastOption;
Expand All @@ -318,7 +318,7 @@ bool DialogManager::showKnowledgeCheck() {
tmpStr = _vm->getString(j);
if ((int) tmpStr.size() > maxLength)
maxLength = tmpStr.size();
_vm->_text.displayStr(tmpStr, 100, optionPosY, 100, 1, 0);
_vm->_text->displayStr(tmpStr, 100, optionPosY, 100, 1, 0);
choiceArray[prevChoice] = tmpStr;
optionPosY += 8;
}
Expand Down Expand Up @@ -352,16 +352,16 @@ bool DialogManager::showKnowledgeCheck() {
if (coor[currChoice]._enabled) {
if ((prevChoice != 0) && (prevChoice != currChoice)) {
tmpStr = choiceArray[prevChoice] + '$';
_vm->_text.displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0);
_vm->_text->displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0);
}
if (prevChoice != currChoice) {
tmpStr = choiceArray[currChoice] + '$';
_vm->_text.displayStr(tmpStr, 100, 27 + (currChoice * 8), 100, 1, 1);
_vm->_text->displayStr(tmpStr, 100, 27 + (currChoice * 8), 100, 1, 1);
prevChoice = currChoice;
}
} else if (prevChoice != 0) {
tmpStr = choiceArray[prevChoice] + '$';
_vm->_text.displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0);
_vm->_text->displayStr(tmpStr, 100, 27 + (prevChoice * 8), 100, 1, 0);
prevChoice = 0;
}
} while (!((prevChoice != 0) && _vm->getMouseClick()));
Expand Down Expand Up @@ -412,7 +412,7 @@ void DialogManager::drawF3F8() {
void DialogManager::checkForF8(int SpeechNum, bool drawFrame2Fl) {
_vm->testKeyboard();
do {
_vm->_soundManager.startSpeech(SpeechNum, 0, 0);
_vm->_soundManager->startSpeech(SpeechNum, 0, 0);
_vm->_key = waitForF3F8();
if (_vm->shouldQuit())
return;
Expand Down Expand Up @@ -442,7 +442,7 @@ int DialogManager::waitForF3F8() {
void DialogManager::displayIntroScreen(bool drawFrame2Fl) {
_vm->_caff = 50;
_vm->_maff = 0;
_vm->_text.taffich();
_vm->_text->taffich();
_vm->draw(63, 12);
if (drawFrame2Fl)
displayIntroFrame2();
Expand Down
17 changes: 9 additions & 8 deletions engines/mortevielle/mortevielle.cpp
Expand Up @@ -47,15 +47,14 @@ namespace Mortevielle {
MortevielleEngine *g_vm;

MortevielleEngine::MortevielleEngine(OSystem *system, const MortevielleGameDescription *gameDesc):
Engine(system), _gameDescription(gameDesc), _randomSource("mortevielle"),
_soundManager(_mixer) {
Engine(system), _gameDescription(gameDesc), _randomSource("mortevielle") {
g_vm = this;
_debugger.setParent(this);
_dialogManager.setParent(this);
_screenSurface.setParent(this);
_mouse = new MouseHandler(this);
_text.setParent(this);
_soundManager.setParent(this);
_text = new TextHandler(this);
_soundManager = new SoundManager(this, _mixer);
_savegameManager.setParent(this);
_menu = new Menu(this);

Expand Down Expand Up @@ -106,6 +105,8 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const MortevielleGameDescr

MortevielleEngine::~MortevielleEngine() {
delete _menu;
delete _soundManager;
delete _text;
delete _mouse;

free(_curPict);
Expand Down Expand Up @@ -238,8 +239,8 @@ Common::ErrorCode MortevielleEngine::initialize() {
testKeyboard();
clearScreen();

_soundManager.loadNoise();
_soundManager.loadAmbiantSounds();
_soundManager->loadNoise();
_soundManager->loadAmbiantSounds();

return Common::kNoError;
}
Expand Down Expand Up @@ -372,7 +373,7 @@ Common::Error MortevielleEngine::run() {
showIntroduction();
else {
_caff = 51;
_text.taffich();
_text->taffich();
}

// Either load the initial game state savegame, or the specified savegame number
Expand All @@ -386,7 +387,7 @@ Common::Error MortevielleEngine::run() {

// Cleanup (allocated in initialize())
_screenSurface.free();
free(_soundManager._cfiphBuffer);
free(_soundManager->_cfiphBuffer);
free(_cfiecBuffer);

return Common::kNoError;
Expand Down
4 changes: 2 additions & 2 deletions engines/mortevielle/mortevielle.h
Expand Up @@ -432,11 +432,11 @@ class MortevielleEngine : public Engine {
PaletteManager _paletteManager;
GfxSurface _backgroundSurface;
Common::RandomSource _randomSource;
SoundManager _soundManager;
SoundManager *_soundManager;
SavegameManager _savegameManager;
Menu *_menu;
MouseHandler *_mouse;
TextHandler _text;
TextHandler *_text;
DialogManager _dialogManager;

MortevielleEngine(OSystem *system, const MortevielleGameDescription *gameDesc);
Expand Down
8 changes: 4 additions & 4 deletions engines/mortevielle/outtext.cpp
Expand Up @@ -35,6 +35,10 @@

namespace Mortevielle {

TextHandler::TextHandler(MortevielleEngine *vm) {
_vm = vm;
}

/**
* Next word
* @remarks Originally called 'l_motsuiv'
Expand Down Expand Up @@ -301,8 +305,4 @@ void TextHandler::taffich() {
}
}

void TextHandler::setParent(MortevielleEngine *vm) {
_vm = vm;
}

} // End of namespace Mortevielle
3 changes: 2 additions & 1 deletion engines/mortevielle/outtext.h
Expand Up @@ -38,7 +38,8 @@ class TextHandler {
MortevielleEngine *_vm;
int nextWord(int p, const char *ch, int &tab);
public:
void setParent(MortevielleEngine *vm);
TextHandler (MortevielleEngine *vm);

void displayStr(Common::String inputStr, int x, int y, int dx, int dy, int typ);
void loadPictureFile(Common::String filename, Common::String altFilename, int32 skipSize, int length);
void loadAniFile(Common::String filename, int32 skipSize, int length);
Expand Down
7 changes: 2 additions & 5 deletions engines/mortevielle/sound.cpp
Expand Up @@ -55,7 +55,8 @@ namespace Mortevielle {
const byte _tabdph[16] = {0, 10, 2, 0, 2, 10, 3, 0, 3, 7, 5, 0, 6, 7, 7, 10};
const byte _tabdbc[18] = {7, 23, 7, 14, 13, 9, 14, 9, 5, 12, 6, 12, 13, 4, 0, 4, 5, 9};

SoundManager::SoundManager(Audio::Mixer *mixer) {
SoundManager::SoundManager(MortevielleEngine *vm, Audio::Mixer *mixer) {
_vm = vm;
_mixer = mixer;
_audioStream = nullptr;
_ambiantNoiseBuf = nullptr;
Expand Down Expand Up @@ -281,10 +282,6 @@ void SoundManager::playSong(const byte* buf, uint size, uint loops) {
_mixer->stopHandle(songHandle);
}

void SoundManager::setParent(MortevielleEngine *vm) {
_vm = vm;
}

void SoundManager::spfrac(int wor) {
_queue[2]._rep = (uint)wor >> 12;
if ((_soundType == 0) && (_queue[2]._code != 9)) {
Expand Down
4 changes: 1 addition & 3 deletions engines/mortevielle/sound.h
Expand Up @@ -84,15 +84,13 @@ class SoundManager {
void litph(tablint &t, int typ, int tempo);

public:
SoundManager(Audio::Mixer *mixer);
SoundManager(MortevielleEngine *vm, Audio::Mixer *mixer);
~SoundManager();

Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
uint16 *_cfiphBuffer;

void setParent(MortevielleEngine *vm);

int decodeMusic(const byte *PSrc, byte *PDest, int size);
void playSong(const byte *buf, uint usize, uint loops);
void loadAmbiantSounds();
Expand Down

0 comments on commit d19af62

Please sign in to comment.