aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2010-03-21 10:51:11 +0000
committerPaul Gilbert2010-03-21 10:51:11 +0000
commit05922881cb2e7f8b0766587b20ed496bd83653bc (patch)
treec75a784ce503330e116d1294f0ecbeea4328ae30
parente6619b579299ecefcf9cf6daf0e272cb86136aa4 (diff)
downloadscummvm-rg350-05922881cb2e7f8b0766587b20ed496bd83653bc.tar.gz
scummvm-rg350-05922881cb2e7f8b0766587b20ed496bd83653bc.tar.bz2
scummvm-rg350-05922881cb2e7f8b0766587b20ed496bd83653bc.zip
Added framework for displaying game dialogs
svn-id: r48353
-rw-r--r--engines/engines.mk10
-rw-r--r--engines/m4/globals.cpp4
-rw-r--r--engines/m4/globals.h12
-rw-r--r--engines/m4/graphics.h1
-rw-r--r--engines/m4/m4.cpp20
-rw-r--r--engines/m4/m4.h2
-rw-r--r--engines/m4/mads_menus.cpp131
-rw-r--r--engines/m4/mads_menus.h51
-rw-r--r--engines/m4/mads_scene.cpp19
-rw-r--r--engines/m4/mads_scene.h1
-rw-r--r--engines/m4/mads_views.cpp75
-rw-r--r--engines/m4/mads_views.h1
-rw-r--r--engines/m4/scene.cpp11
-rw-r--r--engines/m4/staticres.cpp3
-rw-r--r--engines/m4/staticres.h3
15 files changed, 325 insertions, 19 deletions
diff --git a/engines/engines.mk b/engines/engines.mk
index 2c1378290c..697043d128 100644
--- a/engines/engines.mk
+++ b/engines/engines.mk
@@ -46,6 +46,11 @@ DEFINES += -DENABLE_DRASCULA=$(ENABLE_DRASCULA)
MODULES += engines/drascula
endif
+ifdef ENABLE_GARGOYLE
+DEFINES += -DENABLE_GARGOYLE=$(ENABLE_GARGOYLE)
+MODULES += engines/gargoyle
+endif
+
ifdef ENABLE_GOB
DEFINES += -DENABLE_GOB=$(ENABLE_GOB)
MODULES += engines/gob
@@ -151,6 +156,11 @@ DEFINES += -DENABLE_TOUCHE=$(ENABLE_TOUCHE)
MODULES += engines/touche
endif
+ifdef ENABLE_TSAGE
+DEFINES += -DENABLE_TSAGE=$(ENABLE_TSAGE)
+MODULES += engines/tsage
+endif
+
ifdef ENABLE_TUCKER
DEFINES += -DENABLE_TUCKER=$(ENABLE_TUCKER)
MODULES += engines/tucker
diff --git a/engines/m4/globals.cpp b/engines/m4/globals.cpp
index a46fe810ae..87d3fd7f42 100644
--- a/engines/m4/globals.cpp
+++ b/engines/m4/globals.cpp
@@ -280,6 +280,8 @@ MadsGlobals::MadsGlobals(MadsEngine *vm): Globals(vm) {
_vm = vm;
playerSpriteChanged = false;
+ dialogType = DIALOG_NONE;
+ sceneNumber = -1;
}
MadsGlobals::~MadsGlobals() {
@@ -319,7 +321,7 @@ void MadsGlobals::loadMadsVocab() {
_vm->res()->toss("vocab.dat");
}
-void MadsGlobals::loadMadsQuotes() {
+void MadsGlobals::loadQuotes() {
Common::SeekableReadStream *quoteS = _vm->res()->get("quotes.dat");
int curPos = 0;
diff --git a/engines/m4/globals.h b/engines/m4/globals.h
index 34d11c10ac..0a591d131f 100644
--- a/engines/m4/globals.h
+++ b/engines/m4/globals.h
@@ -210,6 +210,9 @@ public:
enum RexPlayerSex { SEX_MALE = 0, SEX_FEMALE = 2, SEX_UNKNOWN = 1};
+enum MadsDialogType { DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3, DIALOG_OPTIONS = 4,
+ DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6};
+
class MadsGlobals : public Globals {
private:
struct MessageItem {
@@ -236,6 +239,9 @@ public:
bool textWindowStill;
int storyMode;
bool playerSpriteChanged;
+ MadsDialogType dialogType;
+ int sceneNumber;
+ int previousScene;
void loadMadsVocab();
uint32 getVocabSize() { return _madsVocab.size(); }
@@ -245,9 +251,13 @@ public:
return _madsVocab[index - 1];
}
- void loadMadsQuotes();
+ void loadQuotes();
uint32 getQuotesSize() { return _madsQuotes.size(); }
const char *getQuote(uint32 index) { return _madsQuotes[index]; }
+ // DEPRECATED: ScummVM re-implementation keeps all the quotes loaded, so the methods below are stubs
+ void clearQuotes() {};
+ void loadQuoteRange(int startNum, int endNum) {};
+ void loadQuote(int quoteNum) {};
void loadMadsMessagesInfo();
uint32 getMessagesSize() { return _madsMessages.size(); }
diff --git a/engines/m4/graphics.h b/engines/m4/graphics.h
index 14c27c5f2d..4c89c50b8a 100644
--- a/engines/m4/graphics.h
+++ b/engines/m4/graphics.h
@@ -128,6 +128,7 @@ public:
void drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &clipRect);
// Surface methods
+ inline Common::Rect bounds() const { return Common::Rect(0, 0, width(), height()); }
inline int width() const { return w; }
inline int height() const { return h; }
void setSize(int sizeX, int sizeY) { create(sizeX, sizeY, 1); }
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp
index 48a0cb7116..624c83e842 100644
--- a/engines/m4/m4.cpp
+++ b/engines/m4/m4.cpp
@@ -519,7 +519,7 @@ Common::Error MadsEngine::run() {
// Load MADS data files
MadsGlobals *globs = (MadsGlobals *)_globals;
globs->loadMadsVocab(); // vocab.dat
- globs->loadMadsQuotes(); // quotes.dat
+ globs->loadQuotes(); // quotes.dat
globs->loadMadsMessagesInfo(); // messages.dat
globs->loadMadsObjects();
@@ -580,16 +580,32 @@ Common::Error MadsEngine::run() {
_viewManager->updateState();
if (g_system->getMillis() >= nextFrame) {
-
_viewManager->refreshAll();
nextFrame = g_system->getMillis();// + GAME_FRAME_DELAY;
}
g_system->delayMillis(10);
+
+ if (globals()->dialogType != DIALOG_NONE)
+ showDialog();
}
return Common::kNoError;
}
+void MadsEngine::showDialog() {
+ // Switch to showing the given dialog
+ RexDialogView *dlg = NULL;
+ switch (globals()->dialogType) {
+ case DIALOG_GAME_MENU:
+ dlg = new RexGameMenuDialog();
+ break;
+ default:
+ error("Unknown dialog type");
+ };
+
+ globals()->dialogType = DIALOG_NONE;
+ _viewManager->addView(dlg);
+}
} // End of namespace M4
diff --git a/engines/m4/m4.h b/engines/m4/m4.h
index 7987535c69..cadf03b944 100644
--- a/engines/m4/m4.h
+++ b/engines/m4/m4.h
@@ -206,6 +206,8 @@ public:
};
class MadsEngine : public MadsM4Engine {
+private:
+ void showDialog();
public:
MadsConversation _converse;
public:
diff --git a/engines/m4/mads_menus.cpp b/engines/m4/mads_menus.cpp
index 2411e47cb4..353b41c9a9 100644
--- a/engines/m4/mads_menus.cpp
+++ b/engines/m4/mads_menus.cpp
@@ -579,4 +579,135 @@ void DragonMainMenuView::handleAction(MadsGameAction action) {
}
}
+
+/*--------------------------------------------------------------------------
+ * RexDialogView is the base class for the different full-screen dialogs
+ * in at least Rex Nebular
+ *--------------------------------------------------------------------------
+ */
+
+RexDialogView::RexDialogView(): View(_madsVm, Common::Rect(0, 0, _madsVm->_screen->width(), _madsVm->_screen->height())) {
+ _screenType = VIEWID_MENU;
+ _initialised = false;
+
+ // Set up a list of blank entries for use in the various dialogs
+ for (int i = 0; i < DIALOG_LINES_SIZE; ++i) {
+ DialogTextEntry rec;
+ _dialogText.push_back(rec);
+ }
+ _totalTextEntries = 0;
+
+ // Store the previously active scene
+ _priorSceneId = _madsVm->_scene->getCurrentScene();
+
+ // Load necessary quotes
+ _madsVm->globals()->loadQuoteRange(1, 48);
+}
+
+void RexDialogView::initialiseGraphics() {
+ // Set needed palette entries
+ _madsVm->_palette->blockRange(0, 16);
+ _madsVm->_palette->setEntry(10, 0, 255, 0);
+ _madsVm->_palette->setEntry(11, 0, 180, 0);
+ _madsVm->_palette->setEntry(12, 255, 255, 0);
+ _madsVm->_palette->setEntry(13, 180, 180, 0);
+ _madsVm->_palette->setEntry(14, 255, 255, 180);
+ _madsVm->_palette->setEntry(15, 180, 180, 180);
+
+ // Load an appropriate background and menu sprites
+ loadBackground();
+ loadMenuSprites();
+
+ // Set the current cursor
+ _madsVm->_mouse->setCursorNum(CURSOR_ARROW);
+
+ _initialised = true;
+}
+
+
+RexDialogView::~RexDialogView() {
+ if (_initialised) {
+ _madsVm->_palette->deleteRange(_bgPalData);
+ delete _bgPalData;
+ delete _backgroundSurface;
+ _madsVm->_palette->deleteRange(_spritesPalData);
+ delete _spritesPalData;
+ delete _menuSprites;
+ }
+}
+
+void RexDialogView::loadBackground() {
+ int bgIndex = _madsVm->globals()->sceneNumber / 100;
+ int screenId = 0;
+
+ switch (bgIndex) {
+ case 1:
+ case 2:
+ screenId = 921;
+ break;
+ case 3:
+ case 4:
+ screenId = 922;
+ break;
+ case 5:
+ case 6:
+ case 7:
+ screenId = 923;
+ break;
+ case 8:
+ screenId = 924;
+ case 9:
+ screenId = 920;
+ default:
+ error("Unknown scene number");
+ }
+
+ _backgroundSurface = new M4Surface(width(), MADS_SURFACE_HEIGHT);
+ _backgroundSurface->loadBackground(screenId, &_bgPalData);
+ _vm->_palette->addRange(_bgPalData);
+ _backgroundSurface->translate(_bgPalData);
+}
+
+void RexDialogView::loadMenuSprites() {
+ const char *SPRITES_NAME = "*MENU.SS";
+
+ Common::SeekableReadStream *data = _vm->res()->get(SPRITES_NAME);
+ _menuSprites = new SpriteAsset(_vm, data, data->size(), SPRITES_NAME);
+ _vm->res()->toss(SPRITES_NAME);
+
+ // Slot it into available palette space
+ _spritesPalData = _menuSprites->getRgbList();
+ _vm->_palette->addRange(_spritesPalData);
+ _menuSprites->translate(_spritesPalData, true);
+}
+
+
+void RexDialogView::updateState() {
+ if (!_initialised) {
+ initialiseGraphics();
+ }
+}
+
+void RexDialogView::onRefresh(RectList *rects, M4Surface *destSurface) {
+ // Draw the framed base area
+ fillRect(this->bounds(), _madsVm->_palette->BLACK);
+ setColour(2);
+ hLine(0, width(), 0);
+ hLine(0, width(), height() - 1);
+
+ // Add in the loaded background vertically centred
+ _backgroundSurface->copyTo(this, 0, (height() - MADS_SURFACE_HEIGHT) / 2);
+
+ View::onRefresh(rects, destSurface);
+}
+
+/*--------------------------------------------------------------------------
+ * RexDialogView is the Rex Nebular Game Menu dialog
+ *--------------------------------------------------------------------------
+ */
+
+void RexGameMenuDialog::onRefresh(RectList *rects, M4Surface *destSurface) {
+ RexDialogView::onRefresh(rects, destSurface);
+}
+
}
diff --git a/engines/m4/mads_menus.h b/engines/m4/mads_menus.h
index aced1d907b..0fad0cfb76 100644
--- a/engines/m4/mads_menus.h
+++ b/engines/m4/mads_menus.h
@@ -26,7 +26,9 @@
#ifndef M4_MADS_MENUS_H
#define M4_MADS_MENUS_H
+#include "common/str-array.h"
#include "m4/viewmgr.h"
+#include "m4/font.h"
namespace M4 {
@@ -86,6 +88,55 @@ public:
void updateState();
};
+class DialogTextEntry {
+public:
+ bool in_use;
+ int16 field_2;
+ Common::Point pos;
+ char text[80];
+ Font *font;
+ int widthAdjust;
+
+ int textDisplay_index;
+
+ DialogTextEntry() { in_use = false; };
+};
+
+#define DIALOG_LINES_SIZE 20
+
+class RexDialogView: public View {
+private:
+ int _priorSceneId;
+ bool _initialised;
+
+ void initialiseGraphics();
+ void loadBackground();
+ void loadMenuSprites();
+protected:
+ M4Surface *_backgroundSurface;
+ RGBList *_bgPalData;
+ SpriteAsset *_menuSprites;
+ RGBList *_spritesPalData;
+
+ Common::Array<DialogTextEntry> _dialogText;
+ int _totalTextEntries;
+ int _dialogSelectedLine;
+ Common::StringArray _saveList;
+public:
+ RexDialogView();
+ ~RexDialogView();
+
+ virtual void updateState();
+ virtual void onRefresh(RectList *rects, M4Surface *destSurface);
+};
+
+class RexGameMenuDialog: public RexDialogView {
+public:
+ RexGameMenuDialog(): RexDialogView() {};
+
+ virtual void onRefresh(RectList *rects, M4Surface *destSurface);
+};
+
}
#endif
diff --git a/engines/m4/mads_scene.cpp b/engines/m4/mads_scene.cpp
index 194aaa1317..df5e6ba220 100644
--- a/engines/m4/mads_scene.cpp
+++ b/engines/m4/mads_scene.cpp
@@ -49,6 +49,11 @@ MadsScene::MadsScene(MadsEngine *vm): _sceneResources(), Scene(vm, &_sceneResour
actionNouns[i] = 0;
}
+MadsScene::~MadsScene() {
+ leaveScene();
+ _vm->_viewManager->deleteView(_interfaceSurface);
+}
+
/**
* Secondary scene loading code
*/
@@ -76,10 +81,6 @@ void MadsScene::loadSceneTemporary() {
_backgroundSurface->translate(_palData);
if (_currentScene < 900) {
- /*_backgroundSurface->fillRect(Common::Rect(0, MADS_SURFACE_HEIGHT,
- _backgroundSurface->width(), _backgroundSurface->height()),
- _vm->_palette->BLACK);*/
- // TODO: interface palette
_interfaceSurface->madsloadInterface(0, &_interfacePal);
_vm->_palette->addRange(_interfacePal);
_interfaceSurface->translate(_interfacePal);
@@ -107,6 +108,12 @@ void MadsScene::loadScene(int sceneNumber) {
// Handle common scene setting
Scene::loadScene(sceneNumber);
+ _madsVm->globals()->previousScene = _madsVm->globals()->sceneNumber;
+ _madsVm->globals()->sceneNumber = sceneNumber;
+
+ // Existing ScummVM code that needs to be eventually replaced with MADS code
+ loadSceneTemporary();
+
// Signal the script engine what scene is to be active
_sceneLogic.selectScene(sceneNumber);
_sceneLogic.setupScene();
@@ -120,9 +127,6 @@ void MadsScene::loadScene(int sceneNumber) {
// Do any scene specific setup
_sceneLogic.enterScene();
- // Existing ScummVM code that needs to be eventually replaced with MADS code
- loadSceneTemporary();
-
// Purge resources
_vm->res()->purge();
}
@@ -159,7 +163,6 @@ void MadsScene::leaveScene() {
for (uint i = 0; i <_sceneSprites.size(); ++i) delete _sceneSprites[i];
_sceneSprites.clear();
- delete _backgroundSurface;
delete _walkSurface;
Scene::leaveScene();
diff --git a/engines/m4/mads_scene.h b/engines/m4/mads_scene.h
index 4a157409c1..0ed0d7cace 100644
--- a/engines/m4/mads_scene.h
+++ b/engines/m4/mads_scene.h
@@ -189,6 +189,7 @@ public:
uint16 actionNouns[3];
public:
MadsScene(MadsEngine *vm);
+ virtual ~MadsScene();
// Methods that differ between engines
virtual void loadScene(int sceneNumber);
diff --git a/engines/m4/mads_views.cpp b/engines/m4/mads_views.cpp
index 66d1a5e767..7aff856792 100644
--- a/engines/m4/mads_views.cpp
+++ b/engines/m4/mads_views.cpp
@@ -28,6 +28,7 @@
#include "m4/events.h"
#include "m4/font.h"
#include "m4/globals.h"
+#include "m4/mads_menus.h"
#include "m4/m4.h"
#include "m4/staticres.h"
@@ -384,7 +385,81 @@ bool MadsInterfaceView::handleKeypress(int32 keycode) {
}
}
+ // Handle the various keys
+ if ((keycode == Common::KEYCODE_ESCAPE) || (keycode == Common::KEYCODE_F1)) {
+ // Game menu
+ _madsVm->globals()->dialogType = DIALOG_GAME_MENU;
+ leaveScene();
+ return false;
+ } else if (flags & Common::KBD_CTRL) {
+ // Handling of the different control key combinations
+ switch (kc) {
+ case Common::KEYCODE_i:
+ // Mouse to inventory
+ warning("TODO: Mouse to inventory");
+ break;
+
+ case Common::KEYCODE_k:
+ // Toggle hotspots
+ warning("TODO: Toggle hotspots");
+ break;
+
+ case Common::KEYCODE_p:
+ // Player stats
+ warning("TODO: Player stats");
+ break;
+
+ case Common::KEYCODE_q:
+ // Quit game
+ break;
+
+ case Common::KEYCODE_s:
+ // Activate sound
+ warning("TODO: Activate sound");
+ break;
+
+ case Common::KEYCODE_u:
+ // Rotate player
+ warning("TODO: Rotate player");
+ break;
+
+ case Common::KEYCODE_v: {
+ // Release version
+ Dialog *dlg = new Dialog(_vm, GameReleaseInfoStr, GameReleaseTitleStr);
+ _vm->_viewManager->addView(dlg);
+ _vm->_viewManager->moveToFront(dlg);
+ return false;
+ }
+
+ default:
+ break;
+ }
+ } else if ((flags & Common::KBD_ALT) && (kc == Common::KEYCODE_q)) {
+ // Quit Game
+
+ } else {
+ // Standard keypresses
+ switch (kc) {
+ case Common::KEYCODE_F2:
+ // Save game
+ _madsVm->globals()->dialogType = DIALOG_SAVE;
+ leaveScene();
+ break;
+ case Common::KEYCODE_F3:
+ // Restore game
+ _madsVm->globals()->dialogType = DIALOG_RESTORE;
+ leaveScene();
+ break;
+ }
+ }
+//DIALOG_OPTIONS
return false;
}
+void MadsInterfaceView::leaveScene() {
+ // Close the scene
+ View *view = _madsVm->_viewManager->getView(VIEWID_SCENE);
+ _madsVm->_viewManager->deleteView(view);
+}
+
} // End of namespace M4
diff --git a/engines/m4/mads_views.h b/engines/m4/mads_views.h
index 8a936c1759..4a80671ddc 100644
--- a/engines/m4/mads_views.h
+++ b/engines/m4/mads_views.h
@@ -69,6 +69,7 @@ private:
void setFontMode(InterfaceFontMode newMode);
bool handleCheatKey(int32 keycode);
bool handleKeypress(int32 keycode);
+ void leaveScene();
public:
MadsInterfaceView(MadsM4Engine *vm);
~MadsInterfaceView();
diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp
index e9480ff9a6..15c68f276c 100644
--- a/engines/m4/scene.cpp
+++ b/engines/m4/scene.cpp
@@ -60,24 +60,21 @@ Scene::~Scene() {
void Scene::loadScene(int sceneNumber) {
_previousScene = _currentScene;
_currentScene = sceneNumber;
+}
- // Load scene background and set palette
+void Scene::leaveScene() {
if (_palData) {
_vm->_palette->deleteRange(_palData);
delete _palData;
+ _palData = NULL;
}
-
if (_interfacePal) {
_vm->_palette->deleteRange(_interfacePal);
delete _interfacePal;
+ _interfacePal = NULL;
}
}
-void Scene::leaveScene() {
- delete _palData;
- delete _interfacePal;
-}
-
void Scene::show() {
_vm->_viewManager->addView(this);
}
diff --git a/engines/m4/staticres.cpp b/engines/m4/staticres.cpp
index fbcd78de3f..fc49998adb 100644
--- a/engines/m4/staticres.cpp
+++ b/engines/m4/staticres.cpp
@@ -45,6 +45,9 @@ const char *walkToStr = "Walk to ";
const char *fenceStr = "fence";
const char *overStr = "over";
+const char *GameReleaseInfoStr = "ScummVM rev: 8.43 14-Sept-92";
+const char *GameReleaseTitleStr = "GAME RELASE VERSION INFO";
+
VerbInit verbList[10] = {
{kVerbLook, 2, 0},
{kVerbTake, 2, 0},
diff --git a/engines/m4/staticres.h b/engines/m4/staticres.h
index 2680965304..80fc69fc80 100644
--- a/engines/m4/staticres.h
+++ b/engines/m4/staticres.h
@@ -43,6 +43,9 @@ extern const char *walkToStr;
extern const char *fenceStr;
extern const char *overStr;
+extern const char *GameReleaseInfoStr;
+extern const char *GameReleaseTitleStr;
+
struct VerbInit {
int verb;
int8 flag1;