aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorPaul Gilbert2014-07-27 22:23:49 -0400
committerPaul Gilbert2014-07-27 22:23:49 -0400
commit7416a4f4b2eb66af6e9472618973abc93eeb94de (patch)
tree11f63dd401b8bcd7750a9f26f6d843a87e72e377 /engines/mads
parent6e27b523c0a633e7a4c9458bfed64b1c24666a65 (diff)
downloadscummvm-rg350-7416a4f4b2eb66af6e9472618973abc93eeb94de.tar.gz
scummvm-rg350-7416a4f4b2eb66af6e9472618973abc93eeb94de.tar.bz2
scummvm-rg350-7416a4f4b2eb66af6e9472618973abc93eeb94de.zip
MADS: Beginnings of exit advert view
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp8
-rw-r--r--engines/mads/nebular/menu_nebular.cpp70
-rw-r--r--engines/mads/nebular/menu_nebular.h31
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);