diff options
Diffstat (limited to 'engines/mortevielle/mortevielle.cpp')
-rw-r--r-- | engines/mortevielle/mortevielle.cpp | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index d434150977..34372ba32a 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -47,17 +47,16 @@ 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.setParent(this); - _text.setParent(this); - _soundManager.setParent(this); - _savegameManager.setParent(this); - _menu.setParent(this); + _debugger = new Debugger(this); + _dialogManager = new DialogManager(this); + _screenSurface = new ScreenSurface(this); + _mouse = new MouseHandler(this); + _text = new TextHandler(this); + _soundManager = new SoundManager(this, _mixer); + _savegameManager = new SavegameManager(this); + _menu = new Menu(this); _lastGameFrame = 0; _mouseClick = false; @@ -105,6 +104,15 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const MortevielleGameDescr } MortevielleEngine::~MortevielleEngine() { + delete _menu; + delete _savegameManager; + delete _soundManager; + delete _text; + delete _mouse; + delete _screenSurface; + delete _dialogManager; + delete _debugger; + free(_curPict); free(_curAnim); free(_rightFramePict); @@ -140,7 +148,7 @@ bool MortevielleEngine::canSaveGameStateCurrently() { * Load in a savegame at the specified slot number */ Common::Error MortevielleEngine::loadGameState(int slot) { - return _savegameManager.loadGame(slot); + return _savegameManager->loadGame(slot); } /** @@ -150,7 +158,7 @@ Common::Error MortevielleEngine::saveGameState(int slot, const Common::String &d if (slot == 0) return Common::kWritingFailed; - return _savegameManager.saveGame(slot, desc); + return _savegameManager->saveGame(slot, desc); } /** @@ -196,7 +204,7 @@ Common::ErrorCode MortevielleEngine::initialize() { DebugMan.addDebugChannel(kMortevielleGraphics, "graphics", "Graphics debugging"); // Set up an intermediate screen surface - _screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT, Graphics::PixelFormat::createFormatCLUT8()); + _screenSurface->create(SCREEN_WIDTH, SCREEN_HEIGHT, Graphics::PixelFormat::createFormatCLUT8()); _txxFileFl = false; // Load texts from TXX files @@ -205,7 +213,7 @@ Common::ErrorCode MortevielleEngine::initialize() { // Load the mort.dat resource Common::ErrorCode result = loadMortDat(); if (result != Common::kNoError) { - _screenSurface.free(); + _screenSurface->free(); return result; } @@ -235,8 +243,8 @@ Common::ErrorCode MortevielleEngine::initialize() { testKeyboard(); clearScreen(); - _soundManager.loadNoise(); - _soundManager.loadAmbiantSounds(); + _soundManager->loadNoise(); + _soundManager->loadAmbiantSounds(); return Common::kNoError; } @@ -278,13 +286,13 @@ Common::ErrorCode MortevielleEngine::loadMortDat() { if (!strncmp(dataType, "FONT", 4)) { // Font resource - _screenSurface.readFontData(f, dataSize); + _screenSurface->readFontData(f, dataSize); } else if (!strncmp(dataType, "SSTR", 4)) { readStaticStrings(f, dataSize, kStaticStrings); } else if ((!strncmp(dataType, "GSTR", 4)) && (!_txxFileFl)) { readStaticStrings(f, dataSize, kGameStrings); } else if (!strncmp(dataType, "VERB", 4)) { - _menu.readVerbNums(f, dataSize); + _menu->readVerbNums(f, dataSize); } else { // Unknown section f.skip(dataSize); @@ -369,21 +377,21 @@ Common::Error MortevielleEngine::run() { showIntroduction(); else { _caff = 51; - _text.taffich(); + _text->taffich(); } // Either load the initial game state savegame, or the specified savegame number adzon(); resetVariables(); if (loadSlot != 0) - _savegameManager.loadSavegame(generateSaveFilename(loadSlot)); + _savegameManager->loadSavegame(generateSaveFilename(loadSlot)); // Run the main game loop mainGame(); // Cleanup (allocated in initialize()) - _screenSurface.free(); - free(_soundManager._cfiphBuffer); + _screenSurface->free(); + free(_soundManager->_cfiphBuffer); free(_cfiecBuffer); return Common::kNoError; @@ -393,13 +401,13 @@ Common::Error MortevielleEngine::run() { * Show the game introduction */ void MortevielleEngine::showIntroduction() { - _dialogManager.displayIntroScreen(false); - _dialogManager.checkForF8(142, false); + _dialogManager->displayIntroScreen(false); + _dialogManager->checkForF8(142, false); if (shouldQuit()) return; - _dialogManager.displayIntroFrame2(); - _dialogManager.checkForF8(143, true); + _dialogManager->displayIntroFrame2(); + _dialogManager->checkForF8(143, true); if (shouldQuit()) return; @@ -419,13 +427,13 @@ void MortevielleEngine::mainGame() { for (_crep = 1; _crep <= _x26KeyCount; ++_crep) decodeNumber(&_cfiecBuffer[161 * 16], (_cfiecBufferSize - (161 * 16)) / 64); - _menu.initMenu(); + _menu->initMenu(); charToHour(); initGame(); clearScreen(); drawRightFrame(); - _mouse.showMouse(); + _mouse->showMouse(); // Loop to play the game do { |