mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 01:46:42 +00:00
MORTEVIELLE: Get rid of setParent() in TextHandler and SoundManager
This commit is contained in:
parent
d8d4a2c3bb
commit
d19af62e6b
@ -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)
|
||||
@ -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));
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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) {
|
||||
@ -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;
|
||||
@ -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();
|
||||
@ -1627,7 +1627,7 @@ void MortevielleEngine::endGame() {
|
||||
testKey(false);
|
||||
_mouse->hideMouse();
|
||||
_caff = 70;
|
||||
_text.taffich();
|
||||
_text->taffich();
|
||||
clearScreen();
|
||||
drawDiscussionBox();
|
||||
startDialog(141);
|
||||
|
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
@ -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()));
|
||||
@ -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;
|
||||
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
@ -106,6 +105,8 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const MortevielleGameDescr
|
||||
|
||||
MortevielleEngine::~MortevielleEngine() {
|
||||
delete _menu;
|
||||
delete _soundManager;
|
||||
delete _text;
|
||||
delete _mouse;
|
||||
|
||||
free(_curPict);
|
||||
@ -238,8 +239,8 @@ Common::ErrorCode MortevielleEngine::initialize() {
|
||||
testKeyboard();
|
||||
clearScreen();
|
||||
|
||||
_soundManager.loadNoise();
|
||||
_soundManager.loadAmbiantSounds();
|
||||
_soundManager->loadNoise();
|
||||
_soundManager->loadAmbiantSounds();
|
||||
|
||||
return Common::kNoError;
|
||||
}
|
||||
@ -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
|
||||
@ -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;
|
||||
|
@ -432,11 +432,11 @@ public:
|
||||
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);
|
||||
|
@ -35,6 +35,10 @@
|
||||
|
||||
namespace Mortevielle {
|
||||
|
||||
TextHandler::TextHandler(MortevielleEngine *vm) {
|
||||
_vm = vm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next word
|
||||
* @remarks Originally called 'l_motsuiv'
|
||||
@ -301,8 +305,4 @@ void TextHandler::taffich() {
|
||||
}
|
||||
}
|
||||
|
||||
void TextHandler::setParent(MortevielleEngine *vm) {
|
||||
_vm = vm;
|
||||
}
|
||||
|
||||
} // End of namespace Mortevielle
|
||||
|
@ -38,7 +38,8 @@ private:
|
||||
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);
|
||||
|
@ -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;
|
||||
@ -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)) {
|
||||
|
@ -84,15 +84,13 @@ private:
|
||||
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();
|
||||
|
@ -277,7 +277,7 @@ void MortevielleEngine::handleAction() {
|
||||
return;
|
||||
++temps;
|
||||
if (keyPressed() || _mouseClick) {
|
||||
_soundManager._mixer->stopHandle(_soundManager._soundHandle);
|
||||
_soundManager->_mixer->stopHandle(_soundManager->_soundHandle);
|
||||
}
|
||||
} while (!((_menu->_menuSelected) || (temps > lim) || (funct) || (_anyone)));
|
||||
_inMainGameLoop = false;
|
||||
@ -341,7 +341,7 @@ void MortevielleEngine::handleAction() {
|
||||
handleOpcode();
|
||||
|
||||
if ((_controlMenu == 0) && (! _loseGame) && (! _endGame)) {
|
||||
_text.taffich();
|
||||
_text->taffich();
|
||||
if (_destinationOk) {
|
||||
_destinationOk = false;
|
||||
drawPicture();
|
||||
@ -1255,24 +1255,24 @@ void MortevielleEngine::startMusicOrSpeech(int so) {
|
||||
;
|
||||
} else if ((!_introSpeechPlayed) && (!_coreVar._alreadyEnteredManor)) {
|
||||
// Type 1: Speech
|
||||
_soundManager.startSpeech(10, 1, 1);
|
||||
_soundManager->startSpeech(10, 1, 1);
|
||||
_introSpeechPlayed = true;
|
||||
} else {
|
||||
if (((_coreVar._currPlace == MOUNTAIN) || (_coreVar._currPlace == MANOR_FRONT) || (_coreVar._currPlace == MANOR_BACK)) && (getRandomNumber(1, 3) == 2))
|
||||
// Type 1: Speech
|
||||
_soundManager.startSpeech(9, getRandomNumber(2, 4), 1);
|
||||
_soundManager->startSpeech(9, getRandomNumber(2, 4), 1);
|
||||
else if ((_coreVar._currPlace == CHAPEL) && (getRandomNumber(1, 2) == 1))
|
||||
// Type 1: Speech
|
||||
_soundManager.startSpeech(8, 1, 1);
|
||||
_soundManager->startSpeech(8, 1, 1);
|
||||
else if ((_coreVar._currPlace == WELL) && (getRandomNumber(1, 2) == 2))
|
||||
// Type 1: Speech
|
||||
_soundManager.startSpeech(12, 1, 1);
|
||||
_soundManager->startSpeech(12, 1, 1);
|
||||
else if (_coreVar._currPlace == INSIDE_WELL)
|
||||
// Type 1: Speech
|
||||
_soundManager.startSpeech(13, 1, 1);
|
||||
_soundManager->startSpeech(13, 1, 1);
|
||||
else
|
||||
// Type 2 : music
|
||||
_soundManager.startSpeech(getRandomNumber(1, 17), 1, 2);
|
||||
_soundManager->startSpeech(getRandomNumber(1, 17), 1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1335,12 +1335,12 @@ void MortevielleEngine::startDialog(int16 rep) {
|
||||
|
||||
_mouse->hideMouse();
|
||||
Common::String dialogStr = getString(rep + kDialogStringIndex);
|
||||
_text.displayStr(dialogStr, 230, 4, 65, 26, 5);
|
||||
_text->displayStr(dialogStr, 230, 4, 65, 26, 5);
|
||||
_dialogManager.drawF3F8();
|
||||
|
||||
key = 0;
|
||||
do {
|
||||
_soundManager.startSpeech(rep, haut[_caff - 69], 0);
|
||||
_soundManager->startSpeech(rep, haut[_caff - 69], 0);
|
||||
key = _dialogManager.waitForF3F8();
|
||||
if (shouldQuit())
|
||||
return;
|
||||
@ -2074,10 +2074,10 @@ void MortevielleEngine::loadCFIPH() {
|
||||
error("Missing file - *cfiph.mor");
|
||||
}
|
||||
|
||||
_soundManager._cfiphBuffer = (uint16 *)malloc(sizeof(uint16) * (f.size() / 2));
|
||||
_soundManager->_cfiphBuffer = (uint16 *)malloc(sizeof(uint16) * (f.size() / 2));
|
||||
|
||||
for (int i = 0; i < (f.size() / 2); ++i)
|
||||
_soundManager._cfiphBuffer[i] = f.readUint16BE();
|
||||
_soundManager->_cfiphBuffer[i] = f.readUint16BE();
|
||||
|
||||
f.close();
|
||||
}
|
||||
@ -2102,10 +2102,10 @@ void MortevielleEngine::music() {
|
||||
f.read(compMusicBuf, size);
|
||||
f.close();
|
||||
|
||||
int musicSize = _soundManager.decodeMusic(compMusicBuf, musicBuf, size);
|
||||
int musicSize = _soundManager->decodeMusic(compMusicBuf, musicBuf, size);
|
||||
free(compMusicBuf);
|
||||
|
||||
_soundManager.playSong(musicBuf, musicSize, 5);
|
||||
_soundManager->playSong(musicBuf, musicSize, 5);
|
||||
while (keyPressed())
|
||||
getChar();
|
||||
|
||||
@ -2120,7 +2120,7 @@ void MortevielleEngine::showTitleScreen() {
|
||||
clearScreen();
|
||||
handleDescriptionText(7, 2035);
|
||||
_caff = 51;
|
||||
_text.taffich();
|
||||
_text->taffich();
|
||||
testKeyboard();
|
||||
clearScreen();
|
||||
draw(0, 0);
|
||||
@ -2280,8 +2280,8 @@ void MortevielleEngine::prepareRoom() {
|
||||
prepareScreenType2();
|
||||
displayTextInVerbBar(getEngineString(S_HEAR_NOISE));
|
||||
int rand = (getRandomNumber(0, 4)) - 2;
|
||||
_soundManager.startSpeech(1, rand, 1);
|
||||
_soundManager.waitSpeech();
|
||||
_soundManager->startSpeech(1, rand, 1);
|
||||
_soundManager->waitSpeech();
|
||||
clearVerbBar();
|
||||
}
|
||||
}
|
||||
@ -2391,8 +2391,8 @@ void MortevielleEngine::initCaveOrCellar() {
|
||||
prepareScreenType2();
|
||||
displayTextInVerbBar(getEngineString(S_SOMEONE_ENTERS));
|
||||
int rand = (getRandomNumber(0, 4)) - 2;
|
||||
_soundManager.startSpeech(2, rand, 1);
|
||||
_soundManager.waitSpeech();
|
||||
_soundManager->startSpeech(2, rand, 1);
|
||||
_soundManager->waitSpeech();
|
||||
// The original was doing here a useless loop.
|
||||
// It has been removed
|
||||
|
||||
@ -2465,7 +2465,7 @@ void MortevielleEngine::displayTextInDescriptionBar(int x, int y, int nb, int me
|
||||
Common::String tmpStr = getString(mesgId);
|
||||
if ((y == 182) && ((int) tmpStr.size() > nb))
|
||||
y = 176;
|
||||
_text.displayStr(tmpStr, x, y, nb, 20, _textColor);
|
||||
_text->displayStr(tmpStr, x, y, nb, 20, _textColor);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2482,7 +2482,7 @@ void MortevielleEngine::handleDescriptionText(int f, int mesgId) {
|
||||
_largestClearScreen = false;
|
||||
|
||||
clearDescriptionBar();
|
||||
_text.displayStr(tmpStr, 8, 176, 85, 3, 5);
|
||||
_text->displayStr(tmpStr, 8, 176, 85, 3, 5);
|
||||
} else {
|
||||
mapMessageId(mesgId);
|
||||
switch (f) {
|
||||
@ -2511,7 +2511,7 @@ void MortevielleEngine::handleDescriptionText(int f, int mesgId) {
|
||||
i = 5;
|
||||
|
||||
Common::String tmpStr = getString(mesgId);
|
||||
_text.displayStr(tmpStr, 80, 40, 60, 25, i);
|
||||
_text->displayStr(tmpStr, 80, 40, 60, 25, i);
|
||||
|
||||
if (mesgId == 180)
|
||||
_coreVar._pctHintFound[6] = '*';
|
||||
@ -2910,7 +2910,7 @@ void MortevielleEngine::drawPicture() {
|
||||
}
|
||||
|
||||
void MortevielleEngine::drawPictureWithText() {
|
||||
_text.taffich();
|
||||
_text->taffich();
|
||||
drawPicture();
|
||||
_destinationOk = false;
|
||||
}
|
||||
@ -3123,9 +3123,9 @@ L1:
|
||||
_crep = 138;
|
||||
handleDescriptionText(2, _crep);
|
||||
if (_crep == 138)
|
||||
_soundManager.startSpeech(5, 2, 1);
|
||||
_soundManager->startSpeech(5, 2, 1);
|
||||
else
|
||||
_soundManager.startSpeech(4, 4, 1);
|
||||
_soundManager->startSpeech(4, 4, 1);
|
||||
|
||||
if (_openObjCount == 0)
|
||||
_coreVar._faithScore += 2;
|
||||
@ -3150,7 +3150,7 @@ L1:
|
||||
} else {
|
||||
handleDescriptionText(2, 136);
|
||||
int rand = (getRandomNumber(0, 4)) - 2;
|
||||
_soundManager.startSpeech(3, rand, 1);
|
||||
_soundManager->startSpeech(3, rand, 1);
|
||||
clearDescriptionBar();
|
||||
displayAloneText();
|
||||
resetRoomVariables(MANOR_FRONT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user