[Scummvm-cvs-logs] SF.net SVN: scummvm:[48353] scummvm/trunk/engines

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sun Mar 21 11:51:11 CET 2010


Revision: 48353
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48353&view=rev
Author:   dreammaster
Date:     2010-03-21 10:51:11 +0000 (Sun, 21 Mar 2010)

Log Message:
-----------
Added framework for displaying game dialogs

Modified Paths:
--------------
    scummvm/trunk/engines/engines.mk
    scummvm/trunk/engines/m4/globals.cpp
    scummvm/trunk/engines/m4/globals.h
    scummvm/trunk/engines/m4/graphics.h
    scummvm/trunk/engines/m4/m4.cpp
    scummvm/trunk/engines/m4/m4.h
    scummvm/trunk/engines/m4/mads_menus.cpp
    scummvm/trunk/engines/m4/mads_menus.h
    scummvm/trunk/engines/m4/mads_scene.cpp
    scummvm/trunk/engines/m4/mads_scene.h
    scummvm/trunk/engines/m4/mads_views.cpp
    scummvm/trunk/engines/m4/mads_views.h
    scummvm/trunk/engines/m4/scene.cpp
    scummvm/trunk/engines/m4/staticres.cpp
    scummvm/trunk/engines/m4/staticres.h

Modified: scummvm/trunk/engines/engines.mk
===================================================================
--- scummvm/trunk/engines/engines.mk	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/engines.mk	2010-03-21 10:51:11 UTC (rev 48353)
@@ -46,6 +46,11 @@
 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 @@
 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

Modified: scummvm/trunk/engines/m4/globals.cpp
===================================================================
--- scummvm/trunk/engines/m4/globals.cpp	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/globals.cpp	2010-03-21 10:51:11 UTC (rev 48353)
@@ -280,6 +280,8 @@
 	_vm = vm;
 
 	playerSpriteChanged = false;
+	dialogType = DIALOG_NONE;
+	sceneNumber = -1;
 }
 
 MadsGlobals::~MadsGlobals() {
@@ -319,7 +321,7 @@
 	_vm->res()->toss("vocab.dat");
 }
 
-void MadsGlobals::loadMadsQuotes() {
+void MadsGlobals::loadQuotes() {
 	Common::SeekableReadStream *quoteS = _vm->res()->get("quotes.dat");
 	int curPos = 0;
 

Modified: scummvm/trunk/engines/m4/globals.h
===================================================================
--- scummvm/trunk/engines/m4/globals.h	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/globals.h	2010-03-21 10:51:11 UTC (rev 48353)
@@ -210,6 +210,9 @@
 
 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 @@
 	bool textWindowStill;
 	int storyMode;
 	bool playerSpriteChanged;
+	MadsDialogType dialogType;
+	int sceneNumber;
+	int previousScene;
 
 	void loadMadsVocab();
 	uint32 getVocabSize() { return _madsVocab.size(); }
@@ -245,9 +251,13 @@
 		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(); }

Modified: scummvm/trunk/engines/m4/graphics.h
===================================================================
--- scummvm/trunk/engines/m4/graphics.h	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/graphics.h	2010-03-21 10:51:11 UTC (rev 48353)
@@ -128,6 +128,7 @@
 	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); }

Modified: scummvm/trunk/engines/m4/m4.cpp
===================================================================
--- scummvm/trunk/engines/m4/m4.cpp	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/m4.cpp	2010-03-21 10:51:11 UTC (rev 48353)
@@ -519,7 +519,7 @@
 	// 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 @@
 		_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

Modified: scummvm/trunk/engines/m4/m4.h
===================================================================
--- scummvm/trunk/engines/m4/m4.h	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/m4.h	2010-03-21 10:51:11 UTC (rev 48353)
@@ -206,6 +206,8 @@
 };
 
 class MadsEngine : public MadsM4Engine {
+private:
+	void showDialog();
 public:
 	MadsConversation _converse;
 public:

Modified: scummvm/trunk/engines/m4/mads_menus.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_menus.cpp	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/mads_menus.cpp	2010-03-21 10:51:11 UTC (rev 48353)
@@ -579,4 +579,135 @@
 	}
 }
 
+
+/*--------------------------------------------------------------------------
+ * 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);
+}
+
+}

Modified: scummvm/trunk/engines/m4/mads_menus.h
===================================================================
--- scummvm/trunk/engines/m4/mads_menus.h	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/mads_menus.h	2010-03-21 10:51:11 UTC (rev 48353)
@@ -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 @@
 	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

Modified: scummvm/trunk/engines/m4/mads_scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_scene.cpp	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/mads_scene.cpp	2010-03-21 10:51:11 UTC (rev 48353)
@@ -49,6 +49,11 @@
 		actionNouns[i] = 0;
 }
 
+MadsScene::~MadsScene() {
+	leaveScene();
+	_vm->_viewManager->deleteView(_interfaceSurface);
+}
+
 /**
  * Secondary scene loading code
  */
@@ -76,10 +81,6 @@
 	_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 @@
 	// 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 @@
 	// 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 @@
 	for (uint i = 0; i <_sceneSprites.size(); ++i) delete _sceneSprites[i];
 	_sceneSprites.clear();
 
-	delete _backgroundSurface;
 	delete _walkSurface;
 
 	Scene::leaveScene();

Modified: scummvm/trunk/engines/m4/mads_scene.h
===================================================================
--- scummvm/trunk/engines/m4/mads_scene.h	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/mads_scene.h	2010-03-21 10:51:11 UTC (rev 48353)
@@ -189,6 +189,7 @@
 	uint16 actionNouns[3];
 public:
 	MadsScene(MadsEngine *vm);
+	virtual ~MadsScene();
 
 	// Methods that differ between engines
 	virtual void loadScene(int sceneNumber);

Modified: scummvm/trunk/engines/m4/mads_views.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_views.cpp	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/mads_views.cpp	2010-03-21 10:51:11 UTC (rev 48353)
@@ -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 @@
 		}
 	}
 
+	// 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

Modified: scummvm/trunk/engines/m4/mads_views.h
===================================================================
--- scummvm/trunk/engines/m4/mads_views.h	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/mads_views.h	2010-03-21 10:51:11 UTC (rev 48353)
@@ -69,6 +69,7 @@
 	void setFontMode(InterfaceFontMode newMode);
 	bool handleCheatKey(int32 keycode);
 	bool handleKeypress(int32 keycode);
+	void leaveScene();
 public:
 	MadsInterfaceView(MadsM4Engine *vm);
 	~MadsInterfaceView();

Modified: scummvm/trunk/engines/m4/scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/scene.cpp	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/scene.cpp	2010-03-21 10:51:11 UTC (rev 48353)
@@ -60,24 +60,21 @@
 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);
 }

Modified: scummvm/trunk/engines/m4/staticres.cpp
===================================================================
--- scummvm/trunk/engines/m4/staticres.cpp	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/staticres.cpp	2010-03-21 10:51:11 UTC (rev 48353)
@@ -45,6 +45,9 @@
 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},

Modified: scummvm/trunk/engines/m4/staticres.h
===================================================================
--- scummvm/trunk/engines/m4/staticres.h	2010-03-21 10:35:15 UTC (rev 48352)
+++ scummvm/trunk/engines/m4/staticres.h	2010-03-21 10:51:11 UTC (rev 48353)
@@ -43,6 +43,9 @@
 extern const char *fenceStr;
 extern const char *overStr;
 
+extern const char *GameReleaseInfoStr;
+extern const char *GameReleaseTitleStr;
+
 struct VerbInit {
 	int verb;
 	int8 flag1;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list