aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2012-03-21 08:22:17 -0400
committerMatthew Hoops2012-03-21 08:22:17 -0400
commit1ec7e516822ae344cabd8a35ef226653514339f1 (patch)
treec97bbb14b84ce9a0faa5f19a316466035055ad33
parent6a786129cf04eb9a5ee693750b7ca7e1f9c40ac5 (diff)
downloadscummvm-rg350-1ec7e516822ae344cabd8a35ef226653514339f1.tar.gz
scummvm-rg350-1ec7e516822ae344cabd8a35ef226653514339f1.tar.bz2
scummvm-rg350-1ec7e516822ae344cabd8a35ef226653514339f1.zip
PEGASUS: Implement the intro timer
-rwxr-xr-xengines/pegasus/menu.cpp2
-rw-r--r--engines/pegasus/pegasus.cpp89
-rw-r--r--engines/pegasus/pegasus.h4
3 files changed, 84 insertions, 11 deletions
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 4f8947b7d7..5d90f62b14 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -1214,6 +1214,8 @@ void PauseMenu::updateDisplay() {
_largeSelect.hide();
break;
}
+
+ ((PegasusEngine *)g_engine)->resetIntroTimer();
}
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 19ebfeac2e..a346af581a 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -89,6 +89,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
_dragType = kDragNoDrag;
_idlerHead = 0;
_currentCD = 1;
+ _introTimer = 0;
}
PegasusEngine::~PegasusEngine() {
@@ -99,11 +100,16 @@ PegasusEngine::~PegasusEngine() {
delete _gameMenu;
delete _neighborhood;
delete _rnd;
+ delete _introTimer;
// NOTE: This must be deleted last!
delete _gfx;
}
+void introTimerExpiredFunction(FunctionPtr *, void *) {
+ ((PegasusEngine *)g_engine)->introTimerExpired();
+}
+
Common::Error PegasusEngine::run() {
_console = new PegasusConsole(this);
_gfx = new GraphicsManager(this);
@@ -169,6 +175,11 @@ Common::Error PegasusEngine::run() {
// Start up the first notification
_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
+ if (!isDemo()) {
+ _introTimer = new FuseFunction();
+ _introTimer->setFunctionPtr(&introTimerExpiredFunction, 0);
+ }
+
while (!shouldQuit()) {
processShell();
_system->delayMillis(10); // Ease off the CPU
@@ -270,6 +281,8 @@ void PegasusEngine::createItem(ItemID itemID, NeighborhoodID neighborhoodID, Roo
}
void PegasusEngine::runIntro() {
+ stopIntroTimer();
+
bool skipped = false;
Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
@@ -601,15 +614,18 @@ void PegasusEngine::receiveNotification(Notification *notification, const Notifi
if (&_shellNotification == notification) {
switch (flags) {
case kGameStartingFlag: {
- if (!isDemo())
+ useMenu(new MainMenu());
+
+ if (!isDemo()) {
runIntro();
- else
+ resetIntroTimer();
+ } else {
showTempScreen("Images/Demo/NGsplashScrn.pict");
+ }
if (shouldQuit())
return;
- useMenu(new MainMenu());
_gfx->invalRect(Common::Rect(0, 0, 640, 480));
_gfx->updateDisplay();
((MainMenu *)_gameMenu)->startMainMenuLoop();
@@ -634,7 +650,54 @@ void PegasusEngine::checkCallBacks() {
}
void PegasusEngine::resetIntroTimer() {
- // TODO
+ if (!isDemo() && _gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
+ _introTimer->stopFuse();
+ _introTimer->primeFuse(kIntroTimeOut);
+ _introTimer->lightFuse();
+ }
+}
+
+void PegasusEngine::introTimerExpired() {
+ if (_gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
+ ((MainMenu *)_gameMenu)->stopMainMenuLoop();
+
+ bool skipped = false;
+
+ Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
+ if (!video->loadFile(_introDirectory + "/LilMovie.movie"))
+ error("Failed to load little movie");
+
+ bool saveAllowed = swapSaveAllowed(false);
+ bool openAllowed = swapLoadAllowed(false);
+
+ skipped = playMovieScaled(video, 0, 0);
+
+ delete video;
+
+ if (shouldQuit())
+ return;
+
+ if (!skipped) {
+ runIntro();
+
+ if (shouldQuit())
+ return;
+ }
+
+ resetIntroTimer();
+ _gfx->invalRect(Common::Rect(0, 0, 640, 480));
+
+ swapSaveAllowed(saveAllowed);
+ swapLoadAllowed(openAllowed);
+
+ _gfx->updateDisplay();
+ ((MainMenu *)_gameMenu)->startMainMenuLoop();
+ }
+}
+
+void PegasusEngine::stopIntroTimer() {
+ if (_introTimer)
+ _introTimer->stopFuse();
}
void PegasusEngine::delayShell(TimeValue time, TimeScale scale) {
@@ -681,6 +744,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
switch (command) {
case kMenuCmdStartAdventure:
+ stopIntroTimer();
GameState.setWalkthroughMode(false);
startNewGame();
break;
@@ -691,7 +755,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
_gfx->updateDisplay();
_gfx->doFadeInSync();
} else {
- // TODO: Stop intro timer
+ stopIntroTimer();
_gfx->doFadeOutSync();
useMenu(new CreditsMenu());
_gfx->updateDisplay();
@@ -705,17 +769,22 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
_system->quit();
break;
case kMenuCmdOverview:
- // TODO: Stop intro timer
+ stopIntroTimer();
doInterfaceOverview();
resetIntroTimer();
break;
case kMenuCmdStartWalkthrough:
+ stopIntroTimer();
GameState.setWalkthroughMode(true);
startNewGame();
break;
case kMenuCmdRestore:
+ stopIntroTimer();
+ // fall through
case kMenuCmdDeathRestore:
- showLoadDialog();
+ result = showLoadDialog();
+ if (command == kMenuCmdRestore && result.getCode() != Common::kNoError)
+ resetIntroTimer();
break;
case kMenuCmdCreditsMainMenu:
_gfx->doFadeOutSync();
@@ -769,8 +838,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
_gfx->updateDisplay();
((MainMenu *)_gameMenu)->startMainMenuLoop();
_gfx->doFadeInSync();
- if (!isDemo())
- resetIntroTimer();
+ resetIntroTimer();
break;
case kMenuCmdPauseSave:
if (showSaveDialog().getCode() != Common::kUserCanceled)
@@ -799,8 +867,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
_gfx->updateDisplay();
((MainMenu *)_gameMenu)->startMainMenuLoop();
_gfx->doFadeInSync();
- if (!isDemo())
- resetIntroTimer();
+ resetIntroTimer();
break;
case kMenuCmdNoCommand:
break;
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index ef05585f4c..c6d4c80b76 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -39,6 +39,7 @@
#include "pegasus/hotspot.h"
#include "pegasus/input.h"
#include "pegasus/notification.h"
+#include "pegasus/timers.h"
#include "pegasus/items/autodragger.h"
#include "pegasus/items/inventory.h"
#include "pegasus/items/itemdragger.h"
@@ -99,6 +100,7 @@ public:
void removeTimeBase(TimeBase *timeBase);
void delayShell(TimeValue time, TimeScale scale);
void resetIntroTimer();
+ void introTimerExpired();
void refreshDisplay();
bool playerAlive();
void processShell();
@@ -210,8 +212,10 @@ private:
// Intro
void runIntro();
+ void stopIntroTimer();
bool detectOpeningClosingDirectory();
Common::String _introDirectory;
+ FuseFunction *_introTimer;
// Idlers
Idler *_idlerHead;