diff options
| -rw-r--r-- | engines/mads/action.cpp | 155 | ||||
| -rw-r--r-- | engines/mads/hotspots.cpp | 6 | ||||
| -rw-r--r-- | engines/mads/hotspots.h | 4 | ||||
| -rw-r--r-- | engines/mads/module.mk | 1 | ||||
| -rw-r--r-- | engines/mads/scene.cpp | 7 | ||||
| -rw-r--r-- | engines/mads/user_interface.h | 2 | 
6 files changed, 87 insertions, 88 deletions
diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp index 65abc9454d..40ece8eb2b 100644 --- a/engines/mads/action.cpp +++ b/engines/mads/action.cpp @@ -23,7 +23,9 @@  #include "common/scummsys.h"  #include "mads/mads.h"  #include "mads/action.h" +#include "mads/inventory.h"  #include "mads/scene.h" +#include "mads/staticres.h"  namespace MADS { @@ -58,71 +60,68 @@ void MADSAction::clear() {  }  void MADSAction::appendVocab(int vocabId, bool capitalise) { -	/* -	char *s = _statusText + strlen(_statusText); -	vocabStr = _madsVm->globals()->getVocab(vocabId); -	strcpy(s, vocabStr); +	Common::String vocabStr = _vm->_game->_scene.getVocab(vocabId);  	if (capitalise) -		*s = toupper(*s); +		vocabStr.setChar(toupper(vocabStr[0]), 0); -	strcat(s, " "); -	*/ +	_statusText += vocabStr; +	_statusText += " ";  }  void MADSAction::set() { -	/* -	int hotspotCount = _madsVm->scene()->getSceneResources().hotspots->size(); -	bool flag = false; // FIXME: unused -	strcpy(_statusText, ""); +	Scene &scene = _vm->_game->_scene; +	UserInterface &userInterface = scene._userInterface; +	bool flag = false; +	_statusText = ""; -	_currentAction = -1; -	_action.objectNameId = -1; -	_action.indirectObjectId = -1; +	_action._verbId = -1; +	_action._objectNameId = -1; +	_action._indirectObjectId = -1; -	if (_actionMode == ACTMODE_TALK) { +	if (_actionMode == ACTIONMODE_TALK) {  		// Handle showing the conversation selection. Rex at least doesn't actually seem to use this  		if (_selectedRow >= 0) { -			const char *desc = _madsVm->_converse[_selectedRow].desc; -			if (desc) -				strcpy(_statusText, desc); +			Common::String desc = userInterface._talkStrings[userInterface._talkIds[_selectedRow]]; +			if (!desc.empty()) +				_statusText = desc;  		}  	} else if (_lookFlag && (_selectedRow == 0)) {  		// Two 'look' actions in succession, so the action becomes 'Look around' -		strcpy(_statusText, lookAroundStr); +		_statusText = kLookAroundStr;  	} else { -		if ((_actionMode == ACTMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) { +		if ((_actionMode == ACTIONMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) {  			// Use/to action -			int selectedObject = _madsVm->scene()->getInterface()->getSelectedObject(); -			MadsObject *objEntry = _madsVm->globals()->getObject(selectedObject); +			int invIndex = userInterface._selectedInvIndex; +			InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex); -			_action.objectNameId = objEntry->_descId; -			_currentAction = objEntry->_vocabList[_selectedRow].vocabId; +			_action._objectNameId = objEntry._descId; +			_action._verbId = objEntry._vocabList[_selectedRow]._vocabId;  			// Set up the status text stirng -			strcpy(_statusText, useStr); -			appendVocab(_action.objectNameId); -			strcpy(_statusText, toStr); -			appendVocab(_currentAction); +			_statusText = kUseStr; +			appendVocab(_action._objectNameId); +			_statusText += kToStr; +			appendVocab(_action._verbId);  		} else {  			// Handling for if an action has been selected  			if (_selectedRow >= 0) { -				if (_actionMode == ACTMODE_VERB) { +				if (_actionMode == ACTIONMODE_VERB) {  					// Standard verb action -					_currentAction = verbList[_selectedRow].verb; +					_currentAction = scene._verbList[_selectedRow]._id;  				} else {  					// Selected action on an inventory object -					int selectedObject = _madsVm->scene()->getInterface()->getSelectedObject(); -					MadsObject *objEntry = _madsVm->globals()->getObject(selectedObject); +					int invIndex = userInterface._selectedInvIndex; +					InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex); -					_currentAction = objEntry->_vocabList[_selectedRow].vocabId; +					_currentAction = objEntry._vocabList[_selectedRow]._vocabId;  				} -				appendVocab(_currentAction, true); +				appendVocab(_action._verbId, true); -				if (_currentAction == kVerbLook) { +				if (_currentAction == VERB_LOOK) {  					// Add in the word 'add' -					strcat(_statusText, atStr); -					strcat(_statusText, " "); +					_statusText += kAtStr; +					_statusText += " ";  				}  			} @@ -130,20 +129,20 @@ void MADSAction::set() {  			if ((_hotspotId >= 0) && (_selectedRow >= 0) && (_articleNumber > 0) && (_flags1 == 2)) {  				flag = true; -				strcat(_statusText, englishMADSArticleList[_articleNumber]); -				strcat(_statusText, " "); +				_statusText += kArticleList[_articleNumber]; +				_statusText += " ";  			}  			if (_hotspotId >= 0) {  				if (_selectedRow < 0) {  					int verbId; -					if (_hotspotId < hotspotCount) { +					if (_hotspotId < (int)scene._hotspots.size()) {  						// Get the verb Id from the hotspot -						verbId = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getVerbID(); +						verbId = scene._hotspots[_hotspotId]._verbId;  					} else {  						// Get the verb Id from the scene object -						verbId = (*_madsVm->scene()->getSceneResources().dynamicHotspots)[_hotspotId - hotspotCount].getVerbID(); +						verbId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._vocabId;  					}  					if (verbId > 0) { @@ -152,23 +151,23 @@ void MADSAction::set() {  						appendVocab(_currentAction, true);  					} else {  						// Default to a standard 'walk to' -						_currentAction = kVerbWalkTo; -						strcat(_statusText, walkToStr); +						_currentAction = VERB_WALKTO; +						_statusText += kWalkToStr;  					}  				} -				if ((_actionMode2 == ACTMODE2_2) || (_actionMode2 == ACTMODE2_5)) { +				if ((_actionMode2 == ACTIONMODE2_2) || (_actionMode2 == ACTIONMODE2_5)) {  					// Get name from given inventory object -					int objectId = _madsVm->scene()->getInterface()->getInventoryObject(_hotspotId); -					_action.objectNameId = _madsVm->globals()->getObject(objectId)->_descId; -				} else if (_hotspotId < hotspotCount) { +					InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId); +					_action._objectNameId = invObject._descId; +				} else if (_hotspotId < (int)scene._hotspots.size()) {  					// Get name from scene hotspot -					_action.objectNameId = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getVocabID(); +					_action._objectNameId = scene._hotspots[_hotspotId]._vocabId;  				} else {  					// Get name from temporary scene hotspot -					_action.objectNameId = (*_madsVm->scene()->getSceneResources().dynamicHotspots)[_hotspotId].getVocabID(); +					_action._objectNameId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._vocabId;  				} -				appendVocab(_action.objectNameId); +				appendVocab(_action._objectNameId);  			}  		} @@ -178,76 +177,74 @@ void MADSAction::set() {  					int articleNum = 0;  					if ((_v86F42 == 2) || (_v86F42 == 5)) { -						int objectId = _madsVm->scene()->getInterface()->getInventoryObject(_hotspotId); -						articleNum = _madsVm->globals()->getObject(objectId)->_article; -					} else if (_v86F3A < hotspotCount) { -						articleNum = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getArticle(); +						InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId); +						articleNum = invObject._article; +					} else if (_v86F3A < (int)scene._hotspots.size()) { +						articleNum = scene._hotspots[_hotspotId]._articleNumber;  					} else { - +						articleNum = scene._hotspots[_hotspotId - scene._hotspots.size()]._articleNumber;  					} -				} -			} else if ((_articleNumber == kVerbLook) || (_vm->getGameType() != GType_RexNebular) || -				(strcmp(_madsVm->globals()->getVocab(_action.indirectObjectId), fenceStr) != 0)) { +					_statusText += kArticleList[articleNum]; +					_statusText += " "; +				} +			} else if ((_articleNumber == VERB_LOOK) || (_vm->getGameID() != GType_RexNebular) || +				(scene._vocabStrings[_action._indirectObjectId] != kFenceStr)) {  				// Write out the article -				strcat(_statusText, englishMADSArticleList[_articleNumber]); +				_statusText += kArticleList[_articleNumber];  			} else {  				// Special case for a 'fence' entry in Rex Nebular -				strcat(_statusText, overStr); +				_statusText += kOverStr;  			} -			strcat(_statusText, " "); +			_statusText += " ";  		}  		// Append object description if necessary  		if (_v86F3A >= 0) -			appendVocab(_action.indirectObjectId); +			appendVocab(_action._indirectObjectId);  		// Remove any trailing space character -		int statusLen = strlen(_statusText); -		if ((statusLen > 0) && (_statusText[statusLen - 1] == ' ')) -			_statusText[statusLen - 1] = '\0'; +		if (_statusText.hasSuffix(" ")) +			_statusText.deleteLastChar();  	}  	_textChanged = true; -	*/  }  void MADSAction::refresh() { -	/* +	Scene &scene = _vm->_game->_scene; +  	// Exit immediately if nothing has changed  	if (!_textChanged)  		return;  	// Remove any old copy of the status text  	if (_statusTextIndex >= 0) { -		_owner._textDisplay.expire(_statusTextIndex); +		scene._textDisplay.expire(_statusTextIndex);  		_statusTextIndex = -1;  	} -	if (_statusText[0] != '\0') { -		if ((_owner._screenObjects._v832EC == 0) || (_owner._screenObjects._v832EC == 2)) { -			Font *font = _madsVm->_font->getFont(FONT_MAIN_MADS); +	if (!_statusText.empty()) { +		if ((_vm->_game->_screenObjects._v832EC == 0) || (_vm->_game->_screenObjects._v832EC == 2)) { +			Font *font = _vm->_font->getFont(FONT_MAIN);  			int textSpacing = -1;  			int strWidth = font->getWidth(_statusText); -			if (strWidth > 320) { +			if (strWidth > MADS_SCREEN_WIDTH) {  				// Too large to fit, so fall back on interface font -				font = _madsVm->_font->getFont(FONT_INTERFACE_MADS); +				font = _vm->_font->getFont(FONT_INTERFACE);  				strWidth = font->getWidth(_statusText, 0);  				textSpacing = 0;  			}  			// Add a new text display entry to display the status text at the bottom of the screen area -			uint colors = (_vm->getGameType() == GType_DragonSphere) ? 0x0300 : 0x0003; - -			_statusTextIndex = _owner._textDisplay.add(160 - (strWidth / 2), -				MADS_SURFACE_HEIGHT + _owner._posAdjust.y - 13, colors, textSpacing, _statusText, font); +			_statusTextIndex = scene._textDisplay.add(160 - (strWidth / 2), +				MADS_SCENE_HEIGHT + scene._posAdjust.y - 13, 3, textSpacing, _statusText, font);  		}  	}  	_textChanged = false; -	*/  }  void MADSAction::startAction() { diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp index 91b8127d92..4356e787d6 100644 --- a/engines/mads/hotspots.cpp +++ b/engines/mads/hotspots.cpp @@ -29,7 +29,7 @@ DynamicHotspot::DynamicHotspot() {  	_seqIndex = 0;  	_facing = 0;  	_descId = 0; -	_field14 = 0; +	_vocabId = 0;  	_articleNumber = 0;  	_cursor = CURSOR_NONE;  } @@ -47,7 +47,7 @@ DynamicHotspots::DynamicHotspots(MADSEngine *vm) : _vm(vm) {  	_count = 0;  } -int DynamicHotspots::add(int descId, int field14, int seqIndex, const Common::Rect &bounds) { +int DynamicHotspots::add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds) {  	// Find a free slot  	uint idx = 0;  	while ((idx < _entries.size()) && _entries[idx]._active) @@ -62,7 +62,7 @@ int DynamicHotspots::add(int descId, int field14, int seqIndex, const Common::Re  	_entries[idx]._feetPos.x = -3;  	_entries[idx]._feetPos.y = 0;  	_entries[idx]._facing = 5; -	_entries[idx]._field14 = field14; +	_entries[idx]._vocabId = vocabId;  	_entries[idx]._articleNumber = 6;  	_entries[idx]._cursor = CURSOR_NONE; diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h index 0dcde1d14b..ed18fbf252 100644 --- a/engines/mads/hotspots.h +++ b/engines/mads/hotspots.h @@ -39,7 +39,7 @@ public:  	Common::Point _feetPos;  	int _facing;  	int _descId; -	int _field14; +	int _vocabId;  	int _articleNumber;  	CursorType _cursor; @@ -59,7 +59,7 @@ public:  	DynamicHotspots(MADSEngine *vm);  	DynamicHotspot &operator[](uint idx) { return _entries[idx]; } -	int add(int descId, int field14, int seqIndex, const Common::Rect &bounds); +	int add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds);  	int setPosition(int index, int xp, int yp, int facing);  	int setCursor(int index, CursorType cursor);  	void remove(int index); diff --git a/engines/mads/module.mk b/engines/mads/module.mk index c2e269e8c1..54126b1b06 100644 --- a/engines/mads/module.mk +++ b/engines/mads/module.mk @@ -34,6 +34,7 @@ MODULE_OBJS := \  	sequence.o \  	sound.o \  	sprites.o \ +	staticres.o \  	user_interface.o  # This module can be built as a plugin diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index baf51fea12..154e4c38bd 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -425,13 +425,13 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {  	// Draw any sprites  	_spriteSlots.drawBackground(); -	// Process dirty areas +	// Set up dirty areas for any text display  	_textDisplay.setDirtyAreas();  	// Merge any identified dirty areas  	_dirtyAreas.merge(1, DIRTY_AREAS_SIZE); -	// Copy dirty areas to the main display surface +	// Copy background for the dirty areas to the screen  	_dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust);  	// Handle dirty areas for foreground objects @@ -439,14 +439,13 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {  	_textDisplay.setDirtyAreas2();  	_dirtyAreas.merge(1, DIRTY_AREAS_SIZE); -  	// Draw foreground sprites  	_spriteSlots.drawForeground(&_vm->_screen);  	// Draw text elements onto the view  	_textDisplay.draw(&_vm->_screen); -	// +	//   	_vm->_screen.setPointer(&_vm->_screen);  	_userInterface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y,  		_vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h)); diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h index 4a26d3450f..80038e80e3 100644 --- a/engines/mads/user_interface.h +++ b/engines/mads/user_interface.h @@ -144,6 +144,8 @@ public:  	int _v1C;  	int _v1E;  	bool _inventoryChanged; +	Common::StringArray _talkStrings; +	Common::Array<int> _talkIds;  public:  	/**  	* Constructor  | 
