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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sat Dec 5 12:32:19 CET 2009


Revision: 46268
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46268&view=rev
Author:   dreammaster
Date:     2009-12-05 11:32:19 +0000 (Sat, 05 Dec 2009)

Log Message:
-----------
Hooked up the actions list and object-specific actions to change the status text

Modified Paths:
--------------
    scummvm/trunk/engines/m4/scene.cpp
    scummvm/trunk/engines/m4/scene.h

Modified: scummvm/trunk/engines/m4/scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/scene.cpp	2009-12-05 07:47:01 UTC (rev 46267)
+++ scummvm/trunk/engines/m4/scene.cpp	2009-12-05 11:32:19 UTC (rev 46268)
@@ -57,6 +57,7 @@
 	_inverseColorTable = NULL;
 	strcpy(_statusText, "");
 	_vm->_rails->setCodeSurface(_codeSurface);
+	_currentAction = kVerbNone;
 }
 
 Scene::~Scene() {
@@ -393,12 +394,14 @@
 		// This is the "easy" interface, which updates the status text when the mouse is moved
 		// TODO: toggle this code for easy/normal interface mode
 		char statusText[50];
-		if (currentHotSpot->getVerbID() != 0) {
-			sprintf(statusText, "%s %s\n", currentHotSpot->getVerb(), currentHotSpot->getVocab());
-		} else {
-			sprintf(statusText, "%s %s\n", _vm->_globals->getVocab(kVerbWalkTo), currentHotSpot->getVocab());
-		}
+		int verbId = _currentAction;
+		if (verbId == kVerbNone)
+			verbId = currentHotSpot->getVerbID();
+		if (verbId == kVerbNone)
+			verbId = kVerbWalkTo;
 
+		sprintf(statusText, "%s %s\n", _vm->_globals->getVocab(verbId), currentHotSpot->getVocab());
+
 		statusText[0] = toupper(statusText[0]);	// capitalize first letter
 		setMADSStatusText(statusText);
 	} else {
@@ -688,80 +691,29 @@
 	boxSprites->getFrame(bottomRight)->copyTo(_backgroundSurface, curX, curY + 1);
 }
 
-/*--------------------------------------------------------------------------*/
+void Scene::setAction(int action, int objectId) {
+	VALIDATE_MADS;
+	char statusText[50];
 
-/*
- * TODO: decide if this should be kept centralised like it is in the original, or separated for the different
- * visual elements
-void Scene::getInterfaceObjectRect(int xv, int yv, Common::Rect &bounds) {
-	// TODO: Implement these later as proper fields of the interface when I understand them better
-	const int interfaceObjY = 0;
-	const int interfaceObjX = 0;
+	// TODO: Actually executing actions directly for objects. Also, some object actions are special in that
+	// a second object can be selected, as in 'use gun to shoot person', with requires a target
 
-	int16 height = 8, width = 0;
-	bounds.top = 0; bounds.left = 0;
-
-	// Handle X position and width
-	switch (xv) {
-	case 1:
-		bounds.left = ((yv / 5) << 3) + 3;
-		width = ((yv / 5) << 6) + 2;
-		break;
-
-	case 2:
-		if ((yv < interfaceObjX) || (yv > (interfaceObjX + 5))) return;
-		bounds.left = ((yv - interfaceObjX) << 3) + 3;
-		width = yv * 69 + 90;
-		break;
-
-	case 6:
-		bounds.left = (yv << 3) + 3;
-		width = yv * 318 + 2;
-		break;
-
-	case 7:
-		bounds.left = 0;
-		width = (yv == 4) ? 75 : 73;
-		break;
-
-	default:
-		bounds.left = (yv << 3) + 3;
-		width = yv * 80 + 240;
-		break;
+	// Set up the new action
+	strcpy(statusText, _vm->_globals->getVocab(action));
+	statusText[0] = toupper(statusText[0]);	// capitalize first letter
+	
+	if (objectId != -1) {
+		MadsObject *obj = _vm->_globals->getObject(objectId);
+		sprintf(statusText + strlen(statusText), " %s", _vm->_globals->getVocab(obj->descId));
+	} else {
+		_currentAction = action;
 	}
 
-	// Handle Y position and height
-	if (xv ==  7) {
-		switch (yv) {
-		case 1:
-			bounds.top = 4;
-			height = 7;
-			break;
-		case 2:
-			bounds.top = 35;
-			height = 7;
-			break;
-		case 3:
-			bounds.top = 12;
-			height = 22;
-			break;
-		case 4:
-			bounds.top = interfaceObjY + 14;
-			height = 1;
-			break;
-		default:
-			break;
-		}
-	}
-
-	// Set the right and bottom bounds based on the specified size
-	bounds.right = bounds.left + width;
-	bounds.bottom = bounds.top + height;
+	setMADSStatusText(statusText);
 }
-*/
 
-/**
- *--------------------------------------------------------------------------
+
+/*--------------------------------------------------------------------------
  * MadsInterfaceView handles the user interface section at the bottom of
  * game screens in MADS games
  *--------------------------------------------------------------------------
@@ -997,7 +949,15 @@
 				// Set the selected object
 				setSelectedObject(_inventoryList[_topIndex + idx]);
 			}
-			return true;
+		} else if ((_highlightedElement >= ACTIONS_START) && (_highlightedElement < (ACTIONS_START + 10))) {
+			// A standard action was selected
+			_vm->_scene->setAction(kVerbLook + (_highlightedElement - ACTIONS_START));
+		} else if ((_highlightedElement >= VOCAB_START) && (_highlightedElement < (VOCAB_START + 5))) {
+			// A vocab action was selected
+			MadsObject *obj = _vm->_globals->getObject(_selectedObject);
+			int vocabIndex = MIN(_highlightedElement - VOCAB_START, obj->vocabCount - 1);
+			if (vocabIndex >= 0)
+				_vm->_scene->setAction(obj->vocabList[vocabIndex].vocabId, _selectedObject);
 		}
 
 		return true;

Modified: scummvm/trunk/engines/m4/scene.h
===================================================================
--- scummvm/trunk/engines/m4/scene.h	2009-12-05 07:47:01 UTC (rev 46267)
+++ scummvm/trunk/engines/m4/scene.h	2009-12-05 11:32:19 UTC (rev 46268)
@@ -44,6 +44,7 @@
 #define MADS_SURFACE_HEIGHT 156
 
 enum MADSVerbs {
+	kVerbNone   = 0,
 	kVerbLook	= 3,
 	kVerbTake	= 4,
 	kVerbPush	= 5,
@@ -99,6 +100,7 @@
 	M4Surface *getBackgroundSurface() const { return _backgroundSurface; }
 	byte *getInverseColorTable() const { return _inverseColorTable; }
 	MadsInterfaceView *getMadsInterface() { return _madsInterfaceSurface; }
+	void setAction(int action, int objectId = -1);
 	void update();
 	void setMADSStatusText(const char *text) { strcpy(_statusText, text); }
 	void showMADSV2TextBox(char *text, int x, int y, char *faceName);
@@ -118,6 +120,7 @@
 	HotSpotList _sceneHotspots;
 	SpriteAsset *_sceneSprites;
 	SpriteAsset *_walkerSprite;
+	int _currentAction;
 	char _statusText[100];
 
 	void nextCommonCursor();


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