Esempio n. 1
0
void MADSAction::set() {
	Scene &scene = _vm->_game->_scene;
	UserInterface &userInterface = scene._userInterface;
	_statusText = "";

	_action._verbId = VERB_NONE;
	_action._objectNameId = -1;
	_action._indirectObjectId = -1;

	if (_commandSource == CAT_TALK_ENTRY) {
		// Handle showing the conversation selection. Rex at least doesn't actually seem to use this
		if (_selectedRow >= 0) {
			_action._verbId = userInterface._talkIds[_selectedRow];
			Common::String desc = userInterface._talkStrings[_selectedRow];
			if (!desc.empty())
				_statusText = desc;
		}
	} else if (_lookFlag && (_selectedRow == 0)) {
		// Two 'look' actions in succession, so the action becomes 'Look around'
		_statusText = kLookAroundStr;
	} else {
		bool flag = false;
		if ((_commandSource == CAT_INV_VOCAB) && (_selectedRow >= 0)
				&& (_verbType == VERB_THAT) && (_prepType == PREP_NONE)) {
			// Use/to action
			int invIndex = userInterface._selectedInvIndex;
			InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex);

			_action._objectNameId = objEntry._descId;
			_action._verbId = objEntry._vocabList[_selectedRow]._vocabId;

			// Set up the status text string
			_statusText = kUseStr;
			appendVocab(_action._objectNameId);
			_statusText += kToStr;
			appendVocab(_action._verbId);
		} else {
			// Handling for if an action has been selected
			if (_selectedRow >= 0) {
				if (_commandSource == CAT_COMMAND) {
					// Standard verb action
					_action._verbId = scene._verbList[_selectedRow]._id;
				} else {
					// Selected action on an inventory object
					int invIndex = userInterface._selectedInvIndex;
					InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex);

					_action._verbId = objEntry._vocabList[_selectedRow]._vocabId;
				}

				appendVocab(_action._verbId, true);

				if (_action._verbId == VERB_LOOK) {
					// Add in the word 'add'
					_statusText += kArticleList[PREP_AT];
					_statusText += " ";
				}
			}

			// Add in any necessary article if necessary
			if ((_hotspotId >= 0) && (_selectedRow >= 0) && (_articleNumber > 0) && (_verbType == VERB_THAT)) {
				flag = true;

				_statusText += kArticleList[_articleNumber];
				_statusText += " ";
			}

			// Handling for hotspot
			if (_hotspotId >= 0) {
				if (_selectedRow < 0) {
					int verbId;

					if (_hotspotId < (int)scene._hotspots.size()) {
						// Get the verb Id from the hotspot
						verbId = scene._hotspots[_hotspotId]._verbId;
					} else {
						// Get the verb Id from the scene object
						verbId = scene._dynamicHotspots.get(_hotspotId - scene._hotspots.size())._verbId;
					}

					if (verbId > 0) {
						// Set the specified action
						_action._verbId = verbId;
						appendVocab(_action._verbId, true);
					} else {
						// Default to a standard 'walk to'
						_action._verbId = VERB_WALKTO;
						_statusText += kWalkToStr;
					}
				}

				if ((_mainObjectSource == CAT_INV_LIST) || (_mainObjectSource == CAT_INV_ANIM)) {
					// Get name from given inventory object
					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 = scene._hotspots[_hotspotId]._vocabId;
				} else {
					// Get name from temporary scene hotspot
					_action._objectNameId = scene._dynamicHotspots.get(_hotspotId - scene._hotspots.size())._descId;
				}
				appendVocab(_action._objectNameId);
			}
		}

		if (_secondObject >= 0) {
			if (_secondObjectSource == CAT_INV_LIST || _secondObjectSource == CAT_INV_ANIM) {
				InventoryObject &invObject = _vm->_game->_objects.getItem(_secondObject);
				_action._indirectObjectId = invObject._descId;
			} else if (_secondObject < (int)scene._hotspots.size()) {
				_action._indirectObjectId = scene._hotspots[_secondObject]._vocabId;
			} else {
				_action._indirectObjectId = scene._dynamicHotspots.get(_secondObject - scene._hotspots.size())._descId;
			}
		}

		if ((_hotspotId >= 0) && (_articleNumber > 0) && !flag) {
			if (_articleNumber == PREP_RELATIONAL) {
				if (_secondObject >= 0) {
					int articleNum = 0;

					if ((_secondObjectSource == 2) || (_secondObjectSource == 5)) {
						InventoryObject &invObject = _vm->_game->_objects.getItem(_secondObject);
						articleNum = invObject._article;
					} else if (_secondObject < (int)scene._hotspots.size()) {
						articleNum = scene._hotspots[_secondObject]._articleNumber;
					} else {
						articleNum = scene._dynamicHotspots.get(_secondObject - scene._hotspots.size())._articleNumber;
					}

					_statusText += kArticleList[articleNum];
				}
			} else if ((_articleNumber != VERB_LOOK) || (_vm->getGameID() != GType_RexNebular) ||
				(_action._indirectObjectId >= 0 && scene.getVocab(_action._indirectObjectId) != kFenceStr)) {
				// Write out the article
				_statusText += kArticleList[_articleNumber];
			} else {
				// Special case for a 'fence' entry in Rex Nebular
				_statusText += kOverStr;
			}

			_statusText += " ";
		}

		// Append object description if necessary
		if (_secondObject >= 0)
			appendVocab(_action._indirectObjectId);

		// Remove any trailing space character
		if (_statusText.hasSuffix(" "))
			_statusText.deleteLastChar();
	}

	_textChanged = true;
}
Esempio n. 2
0
void MadsAction::set() {
	int hotspotCount = _madsVm->scene()->getSceneResources().hotspots->size();
	bool flag = false;
	strcpy(_statusText, "");

	_currentAction = -1;
	_action.objectNameId = -1;
	_action.indirectObjectId = -1;

	if (_actionMode == ACTMODE_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);
		}
	} else if (_lookFlag && (_selectedRow == 0)) {
		// Two 'look' actions in succession, so the action becomes 'Look around'
		strcpy(_statusText, lookAroundStr);
	} else {
		if ((_actionMode == ACTMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) {
			// Use/to action
			int selectedObject = _madsVm->scene()->getInterface()->getSelectedObject();
			MadsObject *objEntry = _madsVm->globals()->getObject(selectedObject);
			
			_action.objectNameId = objEntry->_descId;
			_currentAction = objEntry->_vocabList[_selectedRow].vocabId;

			// Set up the status text stirng
			strcpy(_statusText, useStr);
			appendVocab(_action.objectNameId);
			strcpy(_statusText, toStr);
			appendVocab(_currentAction);
		} else {
			// Handling for if an action has been selected
			if (_selectedRow >= 0) {
				if (_actionMode == ACTMODE_VERB) {
					// Standard verb action
					_currentAction = verbList[_selectedRow].verb;
				} else {
					// Selected action on an inventory object
					int selectedObject = _madsVm->scene()->getInterface()->getSelectedObject();
					MadsObject *objEntry = _madsVm->globals()->getObject(selectedObject);

					_currentAction = objEntry->_vocabList[_selectedRow].vocabId;
				}

				appendVocab(_currentAction, true);

				if (_currentAction == kVerbLook) {
					// Add in the word 'add'
					strcat(_statusText, atStr);
					strcat(_statusText, " ");
				}
			}

			// Handling for if a hotspot has been selected/highlighted
			if ((_hotspotId >= 0) && (_selectedRow >= 0) && (_articleNumber > 0) && (_flags1 == 2)) {
				flag = true;

				strcat(_statusText, englishMADSArticleList[_articleNumber]);
				strcat(_statusText, " ");
			}

			if (_hotspotId >= 0) {
				if (_selectedRow < 0) {
					int verbId;

					if (_hotspotId < hotspotCount) {
						// Get the verb Id from the hotspot
						verbId = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getVerbID();
					} else {
						// Get the verb Id from the scene object
						verbId = (*_madsVm->scene()->getSceneResources().dynamicHotspots)[_hotspotId - hotspotCount].getVerbID();
					}

					if (verbId > 0) {
						// Set the specified action
						_currentAction = verbId;
						appendVocab(_currentAction, true);
					} else {
						// Default to a standard 'walk to'
						_currentAction = kVerbWalkTo;
						strcat(_statusText, walkToStr);
					}
				}

				if ((_actionMode2 == ACTMODE2_2) || (_actionMode2 == ACTMODE2_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) {
					// Get name from scene hotspot
					_action.objectNameId = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getVocabID();
				} else {
					// Get name from temporary scene hotspot
					_action.objectNameId = (*_madsVm->scene()->getSceneResources().dynamicHotspots)[_hotspotId].getVocabID();
				}
				appendVocab(_action.objectNameId);
			}
		}

		if ((_hotspotId >= 0) && (_articleNumber > 0) && !flag) {
			if (_articleNumber == -1) {
				if (_v86F3A >= 0) {
					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();
					} else {

					}
				}

			} else if ((_articleNumber == kVerbLook) || (_vm->getGameType() != GType_RexNebular) ||
				(strcmp(_madsVm->globals()->getVocab(_action.indirectObjectId), fenceStr) != 0)) {
				// Write out the article
				strcat(_statusText, englishMADSArticleList[_articleNumber]);
			} else {
				// Special case for a 'fence' entry in Rex Nebular
				strcat(_statusText, overStr);
			}

			strcat(_statusText, " ");
		}

		// Append object description if necessary
		if (_v86F3A >= 0)
			appendVocab(_action.indirectObjectId);

		// Remove any trailing space character
		int statusLen = strlen(_statusText);
		if ((statusLen > 0) && (_statusText[statusLen - 1] == ' '))
			_statusText[statusLen - 1] = '\0';
	}

	_textChanged = true;
}