diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.cpp | 8 | ||||
-rw-r--r-- | engines/mads/nebular/menu_nebular.cpp | 70 | ||||
-rw-r--r-- | engines/mads/nebular/menu_nebular.h | 31 |
3 files changed, 87 insertions, 22 deletions
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index a3cc1b754a..d4b277d856 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -270,7 +270,7 @@ bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr, } void DialogsNebular::showDialog() { - while (_pendingDialog != DIALOG_NONE) { + while (_pendingDialog != DIALOG_NONE && !_vm->shouldQuit()) { DialogId dialogId = _pendingDialog; _pendingDialog = DIALOG_NONE; @@ -307,6 +307,12 @@ void DialogsNebular::showDialog() { delete dlg; break; } + case DIALOG_ADVERT: { + AdvertView *dlg = new AdvertView(_vm); + dlg->show(); + delete dlg; + break; + } default: break; } diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index 11bace3158..cb8f56bd05 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -335,33 +335,19 @@ void MainMenu::handleAction(MADSGameAction action) { return; case SHOW_INTRO: - AnimationView::execute("@rexopen"); + AnimationView::execute(_vm, "@rexopen"); break; case CREDITS: - TextView::execute("credits"); + TextView::execute(_vm, "credits"); return; case QUOTES: - TextView::execute("quotes"); + TextView::execute(_vm, "quotes"); return; case EXIT: _vm->_dialogs->_pendingDialog = DIALOG_ADVERT; - /* - // When the Exit action is done from the menu, show one of two possible advertisements - - // Activate the scene display with the specified scene - bool altAdvert = _vm->_random->getRandomNumber(1000) >= 500; - _vm->_scene->loadScene(altAdvert ? 995 : 996); - _vm->_viewManager->addView(_vm->_scene); - - _vm->_viewManager->refreshAll(); - _vm->delay(10000); - - _vm->_events->quitFlag = true; - return; - */ break; default: break; @@ -370,15 +356,60 @@ void MainMenu::handleAction(MADSGameAction action) { /*------------------------------------------------------------------------*/ +AdvertView::AdvertView(MADSEngine *vm): EventTarget(), _vm(vm) { + _breakFlag = false; +} + +void AdvertView::show() { + bool altAdvert = _vm->getRandomNumber(1000) >= 500; + int screenId = altAdvert ? 995 : 996; + uint32 expiryTime = g_system->getMillis() + 10 * 1000; + + _vm->_palette->resetGamePalette(4, 8); + + // Load the advert background onto the screen + SceneInfo *sceneInfo = SceneInfo::init(_vm); + sceneInfo->load(screenId, 0, Common::String(), 0, _vm->_game->_scene._depthSurface, + _vm->_screen); + _vm->_screen.copyRectToScreen(_vm->_screen.getBounds()); + delete sceneInfo; + + EventsManager &events = *_vm->_events; + events.setEventTarget(this); + events.hideCursor(); + + while (!_breakFlag && !_vm->shouldQuit()) { + _vm->_events->waitForNextFrame(); + _vm->_game->_fx = kTransitionNone; + + _breakFlag |= g_system->getMillis() >= expiryTime; + } + + events.setEventTarget(nullptr); + _vm->quitGame(); +} + +bool AdvertView::onEvent(Common::Event &event) { + if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_LBUTTONDOWN) { + _breakFlag = true; + return true; + } + + return false; +} + +/*------------------------------------------------------------------------*/ + char TextView::_resourceName[100]; #define TEXTVIEW_LINE_SPACING 2 #define TEXT_ANIMATION_DELAY 100 #define TV_NUM_FADE_STEPS 40 #define TV_FADE_DELAY_MILLI 50 -void TextView::execute(const Common::String &resName) { +void TextView::execute(MADSEngine *vm, const Common::String &resName) { assert(resName.size() < 100); strcpy(_resourceName, resName.c_str()); + vm->_dialogs->_pendingDialog = DIALOG_TEXTVIEW; } TextView::TextView(MADSEngine *vm) : MenuView(vm), @@ -598,9 +629,10 @@ void TextView::processText() { char AnimationView::_resourceName[100]; -void AnimationView::execute(const Common::String &resName) { +void AnimationView::execute(MADSEngine *vm, const Common::String &resName) { assert(resName.size() < 100); strcpy(_resourceName, resName.c_str()); + vm->_dialogs->_pendingDialog = DIALOG_ANIMVIEW; } AnimationView::AnimationView(MADSEngine *vm) : MenuView(vm) { diff --git a/engines/mads/nebular/menu_nebular.h b/engines/mads/nebular/menu_nebular.h index e1abbe2c52..6e877a8a24 100644 --- a/engines/mads/nebular/menu_nebular.h +++ b/engines/mads/nebular/menu_nebular.h @@ -116,6 +116,33 @@ public: virtual ~MainMenu(); }; +class AdvertView : public EventTarget { +private: + /** + * Engine reference + */ + MADSEngine *_vm; + + /** + * Signals when to close the dialog + */ + bool _breakFlag; +protected: + /** + * Event handler + */ + virtual bool onEvent(Common::Event &event); +public: + AdvertView(MADSEngine *vm); + + virtual ~AdvertView() {} + + /** + * Show the dialog + */ + void show(); +}; + /** * Scrolling text view */ @@ -165,7 +192,7 @@ public: /** * Queue the given text resource for display */ - static void execute(const Common::String &resName); + static void execute(MADSEngine *vm, const Common::String &resName); TextView(MADSEngine *vm); @@ -200,7 +227,7 @@ public: /** * Queue the given text resource for display */ - static void execute(const Common::String &resName); + static void execute(MADSEngine *vm, const Common::String &resName); AnimationView(MADSEngine *vm); |