diff options
-rw-r--r-- | engines/mads/dialogs.h | 3 | ||||
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.cpp | 25 | ||||
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.h | 5 | ||||
-rw-r--r-- | engines/mads/nebular/menu_nebular.cpp | 66 | ||||
-rw-r--r-- | engines/mads/nebular/menu_nebular.h | 8 | ||||
-rw-r--r-- | engines/mads/scene.cpp | 27 |
6 files changed, 74 insertions, 60 deletions
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h index aad29f6551..c2d5bba8ed 100644 --- a/engines/mads/dialogs.h +++ b/engines/mads/dialogs.h @@ -201,7 +201,8 @@ public: enum DialogId { DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3, - DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6 + DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6, + DIALOG_MAIN_MENU = 7 }; class Dialogs { diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 4e237ea52d..63b16d87e2 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -33,6 +33,7 @@ #include "mads/staticres.h" #include "mads/nebular/dialogs_nebular.h" #include "mads/nebular/game_nebular.h" +#include "mads/nebular/menu_nebular.h" namespace MADS { @@ -270,6 +271,12 @@ bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr, void DialogsNebular::showDialog() { switch (_pendingDialog) { + case DIALOG_MAIN_MENU: { + MainMenu *menu = new MainMenu(_vm); + menu->show(); + delete menu; + break; + } case DIALOG_DIFFICULTY: { DifficultyDialog *dlg = new DifficultyDialog(_vm); dlg->show(); @@ -526,6 +533,7 @@ void PictureDialog::restore() { FullScreenDialog::FullScreenDialog(MADSEngine *vm) : _vm(vm) { _screenId = 990; + _palFlag = true; } FullScreenDialog::~FullScreenDialog() { @@ -540,12 +548,7 @@ void FullScreenDialog::display() { int currentSceneId = scene._currentSceneId; int priorSceneId = scene._priorSceneId; - if (_vm->_dialogs->_pendingDialog) { - palFlag = true; - } else { - _vm->_palette->initPalette(); - } - scene.loadScene(_screenId, game._aaName, palFlag); + scene.loadScene(_screenId, game._aaName, _palFlag); scene._priorSceneId = priorSceneId; scene._currentSceneId = currentSceneId; @@ -567,11 +570,7 @@ void FullScreenDialog::display() { _vm->_screen.empty(); _vm->_screen.hLine(0, 20, MADS_SCREEN_WIDTH, 2); _vm->_screen.hLine(0, 179, MADS_SCREEN_WIDTH, 2); - - _vm->_screen.copyRectToScreen(Common::Rect(0, _vm->_screen._offset.y, - MADS_SCREEN_WIDTH, _vm->_screen._offset.y + 1)); - _vm->_screen.copyRectToScreen(Common::Rect(0, _vm->_screen._offset.y + 157, - MADS_SCREEN_WIDTH, _vm->_screen._offset.y + 157)); + game._scene._spriteSlots.fullRefresh(); game._fx = _vm->_screenFade == SCREEN_FADE_SMOOTH ? kTransitionFadeIn : kCenterVertTransition; game._trigger = 0; @@ -582,8 +581,6 @@ void FullScreenDialog::display() { _vm->_palette->setEntry(13, 45, 45, 0); _vm->_palette->setEntry(14, 63, 63, 63); _vm->_palette->setEntry(15, 45, 45, 45); - - _vm->_events->setCursor(CURSOR_ARROW); } /*------------------------------------------------------------------------*/ @@ -641,6 +638,8 @@ void GameDialog::display() { _lineIndex = -1; setClickableLines(); + + _vm->_events->setCursor(CURSOR_ARROW); } GameDialog::~GameDialog() { diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h index f4003a8a98..fe7e656b0d 100644 --- a/engines/mads/nebular/dialogs_nebular.h +++ b/engines/mads/nebular/dialogs_nebular.h @@ -120,6 +120,11 @@ protected: int _screenId; /** + * Flag for palette initialization + */ + bool _palFlag; + + /** * Handles displaying the screen background and dialog */ virtual void display(); diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index c47272624c..f6ca990952 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -37,29 +37,44 @@ namespace Nebular { MenuView::MenuView(MADSEngine *vm) : FullScreenDialog(vm) { _breakFlag = false; + _redrawFlag = true; + _palFlag = false; } -void MenuView::execute() { - Common::Event event; +void MenuView::show() { + Scene &scene = _vm->_game->_scene; + EventsManager &events = *_vm->_events; + display(); - // Main event loop to show the view - while (!_breakFlag) { - // Handle events - while (g_system->getEventManager()->pollEvent(event)) { - onEvent(event); - } + events.hideCursor(); + + while (!_breakFlag && !_vm->shouldQuit()) { + handleEvents(); - if (_vm->_events->checkForNextFrameCounter()) { - // Next frame drawn, so allow view to prepare for following one - doFrame(); + if (_redrawFlag) { + scene.drawElements(_vm->_game->_fx, _vm->_game->_fx); + _redrawFlag = false; } - // Slight delay - g_system->delayMillis(10); - _breakFlag = _vm->shouldQuit(); + _vm->_events->waitForNextFrame(); + _vm->_game->_fx = kTransitionNone; + doFrame(); } } +void MenuView::display() { + _vm->_palette->resetGamePalette(4, 8); + + FullScreenDialog::display(); +} + +void MenuView::handleEvents() { + Common::Event event; + + while (g_system->getEventManager()->pollEvent(event)) + onEvent(event); +} + /*------------------------------------------------------------------------*/ MainMenu::MainMenu(MADSEngine *vm): MenuView(vm) { @@ -182,23 +197,23 @@ bool MainMenu::onEvent(Common::Event &event) { void MainMenu::doFrame() { int itemSize; + // Delay between animation frames on the menu uint32 currTime = g_system->getMillis(); if (currTime < _delayTimeout) return; _delayTimeout = currTime + MADS_MENU_ANIM_DELAY; - // Rex Nebular handling to cycle through the animated display of the menu items + // If we've alerady reached the end of the menuitem animation, exit immediately if (_menuItemIndex == 7) return; - // If the user has chosen to skip the menu animation, show the menu immediately + // If the user has chosen to skip the animation, show the full menu immediately if (_skipFlag && !_vm->_events->isCursorVisible()) { // Clear any pending animation // _savedSurface.copyTo(&_vm->_screen, Common::Point(0, MADS_MENU_Y)); - // Quickly loop through all the menuitems to display each's final frame + // Quickly loop through all the menu items to display each's final frame while (_menuItemIndex < 7) { - if (_menuItem) { // Draw the final frame of the menuitem MSprite *spr = _menuItem->getFrame(0); @@ -241,20 +256,7 @@ void MainMenu::doFrame() { // Get the next menuitem resource Common::String spritesName = Resources::formatName(NEBULAR_MENUSCREEN, 'A', ++_menuItemIndex, EXT_SS, ""); - - /* - //sprintf(resName, "RM%dA%d.SS", REX_MENUSCREEN, ++_menuItemIndex); - data = _vm->res()->get(resName); - _menuItem = new SpriteAsset(_vm, data, data->size(), resName); - _vm->res()->toss(resName); - */ - // Slot it into available palette space - /* - RGBList *palData = _menuItem->getRgbList(); - _vm->_palette->addRange(palData); - _menuItem->translate(palData, true); - _itemPalData.push_back(palData); - */ + _menuItem = new SpriteAsset(_vm, spritesName, 0); _frameIndex = _menuItem->getCount() - 1; // If the final resource is now loaded, which contains the highlighted versions of diff --git a/engines/mads/nebular/menu_nebular.h b/engines/mads/nebular/menu_nebular.h index 4cd6f37430..e960da494d 100644 --- a/engines/mads/nebular/menu_nebular.h +++ b/engines/mads/nebular/menu_nebular.h @@ -37,19 +37,23 @@ namespace Nebular { enum MADSGameAction { START_GAME, RESUME_GAME, SHOW_INTRO, CREDITS, QUOTES, EXIT }; class MenuView: public FullScreenDialog { +private: + void handleEvents(); protected: - MADSEngine *_vm; bool _breakFlag; + bool _redrawFlag; virtual void doFrame() = 0; virtual bool onEvent(Common::Event &event) = 0; + + virtual void display(); public: MenuView(MADSEngine *vm); virtual ~MenuView() {} - void execute(); + virtual void show(); }; class MainMenu: public MenuView { diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 639f297f86..1f95749fd8 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -196,21 +196,24 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { } void Scene::loadHotspots() { - File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH")); - MadsPack madsPack(&f); - bool isV2 = (_vm->getGameID() != GType_RexNebular); + _hotspots.clear(); - Common::SeekableReadStream *stream = madsPack.getItemStream(0); - int count = stream->readUint16LE(); - delete stream; + Common::File f; + if (f.open(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"))) { + MadsPack madsPack(&f); + bool isV2 = (_vm->getGameID() != GType_RexNebular); - stream = madsPack.getItemStream(1); - _hotspots.clear(); - for (int i = 0; i < count; ++i) - _hotspots.push_back(Hotspot(*stream, isV2)); + Common::SeekableReadStream *stream = madsPack.getItemStream(0); + int count = stream->readUint16LE(); + delete stream; - delete stream; - f.close(); + stream = madsPack.getItemStream(1); + for (int i = 0; i < count; ++i) + _hotspots.push_back(Hotspot(*stream, isV2)); + + delete stream; + f.close(); + } } void Scene::loadVocab() { |