2014-03-02 19:29:54 -05:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
2014-03-02 20:06:21 -05:00
|
|
|
#include "mads/mads.h"
|
2014-03-02 19:29:54 -05:00
|
|
|
#include "mads/action.h"
|
2014-03-20 08:34:56 -04:00
|
|
|
#include "mads/inventory.h"
|
2014-03-02 19:29:54 -05:00
|
|
|
#include "mads/scene.h"
|
2014-03-20 08:34:56 -04:00
|
|
|
#include "mads/staticres.h"
|
2014-03-02 19:29:54 -05:00
|
|
|
|
|
|
|
namespace MADS {
|
|
|
|
|
2014-03-02 20:06:21 -05:00
|
|
|
MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
|
2014-03-02 19:29:54 -05:00
|
|
|
clear();
|
|
|
|
_statusTextIndex = -1;
|
|
|
|
_selectedAction = 0;
|
|
|
|
_inProgress = false;
|
2014-03-23 18:48:00 -04:00
|
|
|
|
2014-04-03 22:02:12 -04:00
|
|
|
_savedFields._commandSource = 0;
|
|
|
|
_savedFields._mainObjectSource = 0;
|
|
|
|
_savedFields._command = -1;
|
|
|
|
_savedFields._mainObject = 0;
|
|
|
|
_savedFields._secondObject = 0;
|
|
|
|
_savedFields._secondObjectSource = 0;
|
2014-03-23 18:48:00 -04:00
|
|
|
_savedFields._articleNumber = 0;
|
|
|
|
_savedFields._lookFlag = false;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-03-02 20:06:21 -05:00
|
|
|
void MADSAction::clear() {
|
2014-03-27 22:38:28 -04:00
|
|
|
_interAwaiting = AWAITING_COMMAND;
|
2014-04-03 22:02:12 -04:00
|
|
|
_commandSource = ACTIONMODE_NONE;
|
|
|
|
_mainObjectSource = ACTIONMODE2_0;
|
|
|
|
_secondObjectSource = 0;
|
2014-04-02 22:27:11 -04:00
|
|
|
_recentCommandSource = 0;
|
2014-03-02 19:29:54 -05:00
|
|
|
_articleNumber = 0;
|
|
|
|
_lookFlag = false;
|
|
|
|
_v86F4A = 0;
|
|
|
|
_selectedRow = -1;
|
|
|
|
_hotspotId = -1;
|
2014-04-03 22:02:12 -04:00
|
|
|
_secondObject = -1;
|
2014-04-02 22:27:11 -04:00
|
|
|
_recentCommand = -1;
|
2014-03-29 22:47:21 +01:00
|
|
|
_action._verbId = VERB_NONE;
|
2014-03-03 00:42:41 -05:00
|
|
|
_action._objectNameId = -1;
|
|
|
|
_action._indirectObjectId = -1;
|
2014-03-02 19:29:54 -05:00
|
|
|
_textChanged = true;
|
2014-04-02 22:27:11 -04:00
|
|
|
_pickedWord = 0;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-03-02 20:06:21 -05:00
|
|
|
void MADSAction::appendVocab(int vocabId, bool capitalise) {
|
2014-03-20 08:34:56 -04:00
|
|
|
Common::String vocabStr = _vm->_game->_scene.getVocab(vocabId);
|
2014-03-02 19:29:54 -05:00
|
|
|
if (capitalise)
|
2014-03-20 08:34:56 -04:00
|
|
|
vocabStr.setChar(toupper(vocabStr[0]), 0);
|
2014-03-02 19:29:54 -05:00
|
|
|
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText += vocabStr;
|
|
|
|
_statusText += " ";
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-03-23 17:31:33 -04:00
|
|
|
void MADSAction::checkCustomDest(int v) {
|
|
|
|
Scene &scene = _vm->_game->_scene;
|
2014-03-28 23:07:22 -04:00
|
|
|
Player &player = _vm->_game->_player;
|
2014-03-23 17:31:33 -04:00
|
|
|
|
2014-04-03 22:02:12 -04:00
|
|
|
if (_v86F4A && (v == -3 || _savedFields._command < 0)) {
|
2014-03-29 13:38:52 -04:00
|
|
|
player._needToWalk = true;
|
2014-03-28 23:07:22 -04:00
|
|
|
player._prepareWalkPos = scene._customDest;
|
2014-03-23 17:31:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-02 20:06:21 -05:00
|
|
|
void MADSAction::set() {
|
2014-03-20 08:34:56 -04:00
|
|
|
Scene &scene = _vm->_game->_scene;
|
|
|
|
UserInterface &userInterface = scene._userInterface;
|
|
|
|
bool flag = false;
|
|
|
|
_statusText = "";
|
2014-03-02 19:29:54 -05:00
|
|
|
|
2014-03-29 22:47:21 +01:00
|
|
|
_action._verbId = VERB_NONE;
|
2014-03-20 08:34:56 -04:00
|
|
|
_action._objectNameId = -1;
|
|
|
|
_action._indirectObjectId = -1;
|
2014-03-02 19:29:54 -05:00
|
|
|
|
2014-04-03 22:02:12 -04:00
|
|
|
if (_commandSource == ACTIONMODE_TALK) {
|
2014-03-02 19:29:54 -05:00
|
|
|
// Handle showing the conversation selection. Rex at least doesn't actually seem to use this
|
|
|
|
if (_selectedRow >= 0) {
|
2014-03-20 08:34:56 -04:00
|
|
|
Common::String desc = userInterface._talkStrings[userInterface._talkIds[_selectedRow]];
|
|
|
|
if (!desc.empty())
|
|
|
|
_statusText = desc;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
} else if (_lookFlag && (_selectedRow == 0)) {
|
|
|
|
// Two 'look' actions in succession, so the action becomes 'Look around'
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText = kLookAroundStr;
|
2014-03-02 19:29:54 -05:00
|
|
|
} else {
|
2014-04-03 22:02:12 -04:00
|
|
|
if ((_commandSource == ACTIONMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) {
|
2014-03-02 19:29:54 -05:00
|
|
|
// Use/to action
|
2014-03-20 08:34:56 -04:00
|
|
|
int invIndex = userInterface._selectedInvIndex;
|
|
|
|
InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex);
|
2014-03-02 19:29:54 -05:00
|
|
|
|
2014-03-20 08:34:56 -04:00
|
|
|
_action._objectNameId = objEntry._descId;
|
|
|
|
_action._verbId = objEntry._vocabList[_selectedRow]._vocabId;
|
2014-03-02 19:29:54 -05:00
|
|
|
|
|
|
|
// Set up the status text stirng
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText = kUseStr;
|
|
|
|
appendVocab(_action._objectNameId);
|
|
|
|
_statusText += kToStr;
|
|
|
|
appendVocab(_action._verbId);
|
2014-03-02 19:29:54 -05:00
|
|
|
} else {
|
|
|
|
// Handling for if an action has been selected
|
|
|
|
if (_selectedRow >= 0) {
|
2014-04-03 22:02:12 -04:00
|
|
|
if (_commandSource == ACTIONMODE_VERB) {
|
2014-03-02 19:29:54 -05:00
|
|
|
// Standard verb action
|
2014-03-26 22:22:50 -04:00
|
|
|
_action._verbId = scene._verbList[_selectedRow]._id;
|
2014-03-02 19:29:54 -05:00
|
|
|
} else {
|
|
|
|
// Selected action on an inventory object
|
2014-03-20 08:34:56 -04:00
|
|
|
int invIndex = userInterface._selectedInvIndex;
|
|
|
|
InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex);
|
2014-03-02 19:29:54 -05:00
|
|
|
|
2014-03-26 22:22:50 -04:00
|
|
|
_action._verbId = objEntry._vocabList[_selectedRow]._vocabId;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-03-20 08:34:56 -04:00
|
|
|
appendVocab(_action._verbId, true);
|
2014-03-02 19:29:54 -05:00
|
|
|
|
2014-03-26 22:22:50 -04:00
|
|
|
if (_action._verbId == VERB_LOOK) {
|
2014-03-02 19:29:54 -05:00
|
|
|
// Add in the word 'add'
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText += kAtStr;
|
|
|
|
_statusText += " ";
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handling for if a hotspot has been selected/highlighted
|
|
|
|
if ((_hotspotId >= 0) && (_selectedRow >= 0) && (_articleNumber > 0) && (_flags1 == 2)) {
|
|
|
|
flag = true;
|
|
|
|
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText += kArticleList[_articleNumber];
|
|
|
|
_statusText += " ";
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_hotspotId >= 0) {
|
|
|
|
if (_selectedRow < 0) {
|
|
|
|
int verbId;
|
|
|
|
|
2014-03-20 08:34:56 -04:00
|
|
|
if (_hotspotId < (int)scene._hotspots.size()) {
|
2014-03-02 19:29:54 -05:00
|
|
|
// Get the verb Id from the hotspot
|
2014-03-20 08:34:56 -04:00
|
|
|
verbId = scene._hotspots[_hotspotId]._verbId;
|
2014-03-02 19:29:54 -05:00
|
|
|
} else {
|
|
|
|
// Get the verb Id from the scene object
|
2014-03-20 08:34:56 -04:00
|
|
|
verbId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._vocabId;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (verbId > 0) {
|
|
|
|
// Set the specified action
|
2014-03-26 22:22:50 -04:00
|
|
|
_action._verbId = verbId;
|
|
|
|
appendVocab(_action._verbId, true);
|
2014-03-02 19:29:54 -05:00
|
|
|
} else {
|
|
|
|
// Default to a standard 'walk to'
|
2014-03-26 22:22:50 -04:00
|
|
|
_action._verbId = VERB_WALKTO;
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText += kWalkToStr;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-03 22:02:12 -04:00
|
|
|
if ((_mainObjectSource == ACTIONMODE2_2) || (_mainObjectSource == ACTIONMODE2_5)) {
|
2014-03-02 19:29:54 -05:00
|
|
|
// Get name from given inventory object
|
2014-03-20 08:34:56 -04:00
|
|
|
InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
|
|
|
|
_action._objectNameId = invObject._descId;
|
|
|
|
} else if (_hotspotId < (int)scene._hotspots.size()) {
|
2014-03-02 19:29:54 -05:00
|
|
|
// Get name from scene hotspot
|
2014-03-20 08:34:56 -04:00
|
|
|
_action._objectNameId = scene._hotspots[_hotspotId]._vocabId;
|
2014-03-02 19:29:54 -05:00
|
|
|
} else {
|
|
|
|
// Get name from temporary scene hotspot
|
2014-03-20 08:34:56 -04:00
|
|
|
_action._objectNameId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._vocabId;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
2014-03-20 08:34:56 -04:00
|
|
|
appendVocab(_action._objectNameId);
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((_hotspotId >= 0) && (_articleNumber > 0) && !flag) {
|
|
|
|
if (_articleNumber == -1) {
|
2014-04-03 22:02:12 -04:00
|
|
|
if (_secondObject >= 0) {
|
2014-03-02 19:29:54 -05:00
|
|
|
int articleNum = 0;
|
|
|
|
|
2014-04-03 22:02:12 -04:00
|
|
|
if ((_secondObjectSource == 2) || (_secondObjectSource == 5)) {
|
2014-03-20 08:34:56 -04:00
|
|
|
InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
|
|
|
|
articleNum = invObject._article;
|
2014-04-03 22:02:12 -04:00
|
|
|
} else if (_secondObject < (int)scene._hotspots.size()) {
|
2014-03-20 08:34:56 -04:00
|
|
|
articleNum = scene._hotspots[_hotspotId]._articleNumber;
|
2014-03-02 19:29:54 -05:00
|
|
|
} else {
|
2014-03-20 08:34:56 -04:00
|
|
|
articleNum = scene._hotspots[_hotspotId - scene._hotspots.size()]._articleNumber;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText += kArticleList[articleNum];
|
|
|
|
_statusText += " ";
|
|
|
|
}
|
|
|
|
} else if ((_articleNumber == VERB_LOOK) || (_vm->getGameID() != GType_RexNebular) ||
|
|
|
|
(scene._vocabStrings[_action._indirectObjectId] != kFenceStr)) {
|
2014-03-02 19:29:54 -05:00
|
|
|
// Write out the article
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText += kArticleList[_articleNumber];
|
2014-03-02 19:29:54 -05:00
|
|
|
} else {
|
|
|
|
// Special case for a 'fence' entry in Rex Nebular
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText += kOverStr;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusText += " ";
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Append object description if necessary
|
2014-04-03 22:02:12 -04:00
|
|
|
if (_secondObject >= 0)
|
2014-03-20 08:34:56 -04:00
|
|
|
appendVocab(_action._indirectObjectId);
|
2014-03-02 19:29:54 -05:00
|
|
|
|
|
|
|
// Remove any trailing space character
|
2014-03-20 08:34:56 -04:00
|
|
|
if (_statusText.hasSuffix(" "))
|
|
|
|
_statusText.deleteLastChar();
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_textChanged = true;
|
|
|
|
}
|
|
|
|
|
2014-03-02 20:06:21 -05:00
|
|
|
void MADSAction::refresh() {
|
2014-03-20 08:34:56 -04:00
|
|
|
Scene &scene = _vm->_game->_scene;
|
|
|
|
|
2014-03-02 19:29:54 -05:00
|
|
|
// Exit immediately if nothing has changed
|
|
|
|
if (!_textChanged)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Remove any old copy of the status text
|
|
|
|
if (_statusTextIndex >= 0) {
|
2014-03-20 08:34:56 -04:00
|
|
|
scene._textDisplay.expire(_statusTextIndex);
|
2014-03-02 19:29:54 -05:00
|
|
|
_statusTextIndex = -1;
|
|
|
|
}
|
|
|
|
|
2014-03-20 08:34:56 -04:00
|
|
|
if (!_statusText.empty()) {
|
2014-04-03 22:02:12 -04:00
|
|
|
if ((_vm->_game->_screenObjects._inputMode == kInputBuildingSentences) ||
|
|
|
|
(_vm->_game->_screenObjects._inputMode == kInputLimitedSentences)) {
|
2014-03-20 08:34:56 -04:00
|
|
|
Font *font = _vm->_font->getFont(FONT_MAIN);
|
2014-03-02 19:29:54 -05:00
|
|
|
int textSpacing = -1;
|
|
|
|
|
|
|
|
int strWidth = font->getWidth(_statusText);
|
2014-03-20 08:34:56 -04:00
|
|
|
if (strWidth > MADS_SCREEN_WIDTH) {
|
2014-03-02 19:29:54 -05:00
|
|
|
// Too large to fit, so fall back on interface font
|
2014-03-20 08:34:56 -04:00
|
|
|
font = _vm->_font->getFont(FONT_INTERFACE);
|
2014-03-02 19:29:54 -05:00
|
|
|
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
|
2014-03-20 08:34:56 -04:00
|
|
|
_statusTextIndex = scene._textDisplay.add(160 - (strWidth / 2),
|
|
|
|
MADS_SCENE_HEIGHT + scene._posAdjust.y - 13, 3, textSpacing, _statusText, font);
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_textChanged = false;
|
|
|
|
}
|
|
|
|
|
2014-03-02 20:06:21 -05:00
|
|
|
void MADSAction::startAction() {
|
2014-03-23 17:31:33 -04:00
|
|
|
Game &game = *_vm->_game;
|
2014-03-28 23:07:22 -04:00
|
|
|
Player &player = game._player;
|
2014-03-23 17:31:33 -04:00
|
|
|
Scene &scene = _vm->_game->_scene;
|
|
|
|
DynamicHotspots &dynHotspots = scene._dynamicHotspots;
|
|
|
|
Hotspots &hotspots = scene._hotspots;
|
|
|
|
|
2014-03-28 23:07:22 -04:00
|
|
|
player.cancelCommand();
|
2014-03-02 19:29:54 -05:00
|
|
|
|
|
|
|
_inProgress = true;
|
2014-04-03 22:02:12 -04:00
|
|
|
_savedFields._commandError = false;
|
|
|
|
_savedFields._command = _selectedRow;
|
|
|
|
_savedFields._mainObject = _hotspotId;
|
|
|
|
_savedFields._secondObject = _secondObject;
|
2014-03-23 17:31:33 -04:00
|
|
|
_savedFields._articleNumber = _articleNumber;
|
2014-04-03 22:02:12 -04:00
|
|
|
_savedFields._commandSource = _commandSource;
|
|
|
|
_savedFields._mainObjectSource = _mainObjectSource;
|
|
|
|
_savedFields._secondObjectSource = _secondObjectSource;
|
2014-03-23 17:31:33 -04:00
|
|
|
_savedFields._lookFlag = _lookFlag;
|
|
|
|
_activeAction = _action;
|
2014-03-02 19:29:54 -05:00
|
|
|
|
|
|
|
// Copy the action to be active
|
|
|
|
_activeAction = _action;
|
2014-03-30 21:10:07 -04:00
|
|
|
_sentence = _statusText;
|
2014-03-02 19:29:54 -05:00
|
|
|
|
2014-04-03 22:50:47 -04:00
|
|
|
if ((_mainObjectSource == ACTIONMODE2_4) && (_secondObjectSource == 4))
|
2014-04-03 22:02:12 -04:00
|
|
|
_savedFields._commandError = true;
|
2014-03-02 19:29:54 -05:00
|
|
|
|
2014-03-28 23:07:22 -04:00
|
|
|
player._needToWalk = false;
|
2014-03-02 19:29:54 -05:00
|
|
|
int hotspotId = -1;
|
|
|
|
|
2014-04-03 22:02:12 -04:00
|
|
|
if (!_savedFields._lookFlag && (_vm->_game->_screenObjects._inputMode != kInputConversation)) {
|
|
|
|
if (_savedFields._mainObjectSource == ACTIONMODE2_4)
|
|
|
|
hotspotId = _savedFields._mainObject;
|
|
|
|
else if (_secondObjectSource == 4)
|
|
|
|
hotspotId = _savedFields._secondObject;
|
2014-03-02 19:29:54 -05:00
|
|
|
|
2014-03-23 18:48:00 -04:00
|
|
|
if (hotspotId >= (int)hotspots.size()) {
|
2014-03-23 17:31:33 -04:00
|
|
|
DynamicHotspot &hs = dynHotspots[hotspotId - hotspots.size()];
|
|
|
|
if ((hs._feetPos.x == -1) || (hs._feetPos.x == -3)) {
|
2014-03-23 18:48:00 -04:00
|
|
|
checkCustomDest(hs._feetPos.x);
|
|
|
|
} else if (hs._feetPos.x == 0) {
|
2014-03-28 23:07:22 -04:00
|
|
|
player._prepareWalkFacing = hs._facing;
|
2014-04-03 22:02:12 -04:00
|
|
|
} else if (_savedFields._commandSource == ACTIONMODE_NONE || hs._cursor >= CURSOR_WAIT) {
|
2014-03-28 23:07:22 -04:00
|
|
|
player._needToWalk = true;
|
|
|
|
player._prepareWalkPos = hs._feetPos;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
2014-03-23 18:48:00 -04:00
|
|
|
|
2014-03-28 23:07:22 -04:00
|
|
|
player._prepareWalkFacing = hs._facing;
|
2014-03-02 19:29:54 -05:00
|
|
|
hotspotId = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-23 18:48:00 -04:00
|
|
|
if (hotspotId >= 0 && hotspotId < (int)hotspots.size()) {
|
2014-03-23 17:31:33 -04:00
|
|
|
Hotspot &hs = hotspots[hotspotId];
|
2014-03-23 18:48:00 -04:00
|
|
|
|
2014-04-05 12:43:50 -04:00
|
|
|
if (hs._feetPos.x == -1 || hs._feetPos.x == -3) {
|
2014-03-23 18:48:00 -04:00
|
|
|
checkCustomDest(hs._feetPos.x);
|
|
|
|
} else if (hs._feetPos.x >= 0) {
|
2014-04-03 22:02:12 -04:00
|
|
|
if (_savedFields._commandSource == ACTIONMODE_NONE || hs._cursor < CURSOR_WAIT) {
|
2014-03-28 23:07:22 -04:00
|
|
|
player._needToWalk = true;
|
|
|
|
player._prepareWalkPos = hs._feetPos;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
}
|
2014-03-23 18:48:00 -04:00
|
|
|
|
2014-03-28 23:07:22 -04:00
|
|
|
player._prepareWalkFacing = hs._facing;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-03-28 23:07:22 -04:00
|
|
|
player._readyToWalk = player._needToWalk;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-03-02 20:06:21 -05:00
|
|
|
void MADSAction::checkAction() {
|
2014-03-23 18:48:00 -04:00
|
|
|
if (isAction(VERB_LOOK) || isAction(VERB_THROW))
|
2014-03-28 23:07:22 -04:00
|
|
|
_vm->_game->_player._needToWalk = false;
|
2014-03-02 19:29:54 -05:00
|
|
|
}
|
|
|
|
|
2014-03-02 20:06:21 -05:00
|
|
|
bool MADSAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
|
2014-03-23 18:48:00 -04:00
|
|
|
if (_activeAction._verbId != verbId)
|
2014-03-02 19:29:54 -05:00
|
|
|
return false;
|
2014-03-23 18:48:00 -04:00
|
|
|
if ((objectNameId != 0) && (_activeAction._objectNameId != objectNameId))
|
2014-03-02 19:29:54 -05:00
|
|
|
return false;
|
2014-03-23 18:48:00 -04:00
|
|
|
if ((indirectObjectId != 0) && (_activeAction._indirectObjectId != indirectObjectId))
|
2014-03-02 19:29:54 -05:00
|
|
|
return false;
|
2014-03-23 18:48:00 -04:00
|
|
|
|
2014-03-02 19:29:54 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-02 23:09:17 -05:00
|
|
|
void MADSAction::checkActionAtMousePos() {
|
2014-03-19 23:33:18 -04:00
|
|
|
Scene &scene = _vm->_game->_scene;
|
|
|
|
UserInterface &userInterface = scene._userInterface;
|
|
|
|
|
2014-03-27 22:38:28 -04:00
|
|
|
if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) &&
|
2014-04-02 22:27:11 -04:00
|
|
|
_interAwaiting != AWAITING_COMMAND && _pickedWord >= 0) {
|
|
|
|
if (_recentCommandSource == userInterface._category || _recentCommand != _pickedWord ||
|
|
|
|
(_interAwaiting != AWAITING_THIS && _interAwaiting != 3))
|
2014-03-19 23:33:18 -04:00
|
|
|
clear();
|
2014-03-27 22:38:28 -04:00
|
|
|
else if (_selectedRow != 0 || userInterface._category != CAT_COMMAND)
|
2014-03-19 23:33:18 -04:00
|
|
|
scene._lookFlag = false;
|
|
|
|
else
|
|
|
|
scene._lookFlag = true;
|
|
|
|
}
|
|
|
|
|
2014-04-02 22:41:25 -04:00
|
|
|
if (_vm->_events->_anyStroke && _vm->_events->_mouseButtons) {
|
2014-03-19 23:33:18 -04:00
|
|
|
switch (userInterface._category) {
|
2014-03-27 22:38:28 -04:00
|
|
|
case CAT_COMMAND:
|
2014-03-19 23:33:18 -04:00
|
|
|
case CAT_INV_VOCAB:
|
|
|
|
return;
|
|
|
|
|
|
|
|
case CAT_INV_LIST:
|
2014-04-03 20:38:18 -04:00
|
|
|
case CAT_HOTSPOT:
|
|
|
|
case CAT_INV_ANIM:
|
|
|
|
if (_interAwaiting != AWAITING_THAT) {
|
2014-03-19 23:33:18 -04:00
|
|
|
if (userInterface._selectedActionIndex >= 0) {
|
2014-04-03 22:02:12 -04:00
|
|
|
_commandSource = ACTIONMODE_VERB;
|
2014-03-19 23:33:18 -04:00
|
|
|
_selectedRow = userInterface._selectedActionIndex;
|
|
|
|
_flags1 = scene._verbList[_selectedRow]._action1;
|
|
|
|
_flags2 = scene._verbList[_selectedRow]._action2;
|
2014-03-27 22:38:28 -04:00
|
|
|
_interAwaiting = AWAITING_THIS;
|
2014-03-19 23:33:18 -04:00
|
|
|
} else if (userInterface._selectedItemVocabIdx >= 0) {
|
2014-04-03 22:02:12 -04:00
|
|
|
_commandSource = ACTIONMODE_OBJECT;
|
2014-03-19 23:33:18 -04:00
|
|
|
_selectedRow = userInterface._selectedItemVocabIdx;
|
|
|
|
int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
|
|
|
|
InventoryObject &invObject = _vm->_game->_objects[objectId];
|
|
|
|
|
|
|
|
_flags1 = invObject._vocabList[_selectedRow - 1]._actionFlags1;
|
|
|
|
_flags2 = invObject._vocabList[_selectedRow - 1]._actionFlags2;
|
2014-04-03 22:02:12 -04:00
|
|
|
_mainObjectSource = ACTIONMODE2_2;
|
2014-03-19 23:33:18 -04:00
|
|
|
_hotspotId = userInterface._selectedInvIndex;
|
|
|
|
_articleNumber = _flags2;
|
|
|
|
|
|
|
|
if ((_flags1 == 1 && _flags2 == 0) || (_flags1 == 2 && _flags2 != 0))
|
2014-03-27 22:38:28 -04:00
|
|
|
_interAwaiting = AWAITING_RIGHT_MOUSE;
|
2014-03-19 23:33:18 -04:00
|
|
|
else
|
2014-03-27 22:38:28 -04:00
|
|
|
_interAwaiting = AWAITING_THAT;
|
2014-03-19 23:33:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-27 22:38:28 -04:00
|
|
|
switch (_interAwaiting) {
|
2014-04-03 20:38:18 -04:00
|
|
|
case AWAITING_COMMAND:
|
2014-03-19 23:33:18 -04:00
|
|
|
_articleNumber = 0;
|
|
|
|
switch (userInterface._category) {
|
2014-03-27 22:38:28 -04:00
|
|
|
case CAT_COMMAND:
|
2014-04-03 22:02:12 -04:00
|
|
|
_commandSource = ACTIONMODE_VERB;
|
2014-04-02 22:27:11 -04:00
|
|
|
_selectedRow = _pickedWord;
|
2014-03-19 23:33:18 -04:00
|
|
|
if (_selectedRow >= 0) {
|
|
|
|
_flags1 = scene._verbList[_selectedRow]._action1;
|
|
|
|
_flags2 = scene._verbList[_selectedRow]._action2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CAT_INV_VOCAB:
|
2014-04-03 22:02:12 -04:00
|
|
|
_commandSource = ACTIONMODE_OBJECT;
|
2014-04-02 22:27:11 -04:00
|
|
|
_selectedRow = _pickedWord;
|
2014-03-19 23:33:18 -04:00
|
|
|
if (_selectedRow < 0) {
|
|
|
|
_hotspotId = -1;
|
2014-04-03 22:02:12 -04:00
|
|
|
_mainObjectSource = ACTIONMODE2_0;
|
2014-03-19 23:33:18 -04:00
|
|
|
} else {
|
|
|
|
int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
|
|
|
|
InventoryObject &invObject = _vm->_game->_objects[objectId];
|
|
|
|
|
|
|
|
_flags1 = invObject._vocabList[_selectedRow - 2]._actionFlags1;
|
|
|
|
_flags2 = invObject._vocabList[_selectedRow - 2]._actionFlags2;
|
|
|
|
_hotspotId = userInterface._selectedInvIndex;
|
2014-04-03 22:02:12 -04:00
|
|
|
_mainObjectSource = ACTIONMODE2_2;
|
2014-03-19 23:33:18 -04:00
|
|
|
|
|
|
|
if (_flags1 == 2)
|
|
|
|
_articleNumber = _flags2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CAT_HOTSPOT:
|
|
|
|
_selectedRow = -1;
|
2014-04-03 22:02:12 -04:00
|
|
|
_commandSource = ACTIONMODE_NONE;
|
|
|
|
_mainObjectSource = ACTIONMODE2_4;
|
2014-04-02 22:27:11 -04:00
|
|
|
_hotspotId = _pickedWord;
|
2014-03-19 23:33:18 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CAT_TALK_ENTRY:
|
2014-04-03 22:02:12 -04:00
|
|
|
_commandSource = ACTIONMODE_TALK;
|
2014-04-02 22:27:11 -04:00
|
|
|
_selectedRow = _pickedWord;
|
2014-03-19 23:33:18 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-04-03 20:38:18 -04:00
|
|
|
case AWAITING_THIS:
|
2014-03-19 23:33:18 -04:00
|
|
|
_articleNumber = 0;
|
|
|
|
switch (userInterface._category) {
|
|
|
|
case CAT_INV_LIST:
|
|
|
|
case CAT_HOTSPOT:
|
|
|
|
case CAT_INV_ANIM:
|
|
|
|
// TODO: We may not need a separate ActionMode2 enum
|
2014-04-03 22:02:12 -04:00
|
|
|
_mainObjectSource = userInterface._category;
|
2014-04-02 22:27:11 -04:00
|
|
|
_hotspotId = _pickedWord;
|
2014-03-19 23:33:18 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-04-03 20:38:18 -04:00
|
|
|
case AWAITING_THAT:
|
2014-03-19 23:33:18 -04:00
|
|
|
switch (userInterface._category) {
|
|
|
|
case CAT_INV_LIST:
|
|
|
|
case CAT_HOTSPOT:
|
|
|
|
case CAT_INV_ANIM:
|
2014-04-03 22:02:12 -04:00
|
|
|
_secondObjectSource = userInterface._category;
|
|
|
|
_secondObject = _pickedWord;
|
2014-03-19 23:33:18 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MADSAction::leftClick() {
|
|
|
|
Scene &scene = _vm->_game->_scene;
|
|
|
|
UserInterface &userInterface = scene._userInterface;
|
|
|
|
bool abortFlag = false;
|
|
|
|
|
2014-03-27 22:38:28 -04:00
|
|
|
if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) &&
|
2014-04-02 22:27:11 -04:00
|
|
|
_interAwaiting != 1 && _pickedWord >= 0 &&
|
|
|
|
_recentCommandSource == userInterface._category && _recentCommand == _pickedWord &&
|
2014-03-27 22:38:28 -04:00
|
|
|
(_interAwaiting == 2 || userInterface._category == CAT_INV_VOCAB)) {
|
2014-03-19 23:33:18 -04:00
|
|
|
abortFlag = true;
|
2014-03-27 22:38:28 -04:00
|
|
|
if (_selectedRow == 0 && userInterface._category == CAT_COMMAND) {
|
|
|
|
_selectedAction = CAT_COMMAND;
|
2014-03-19 23:33:18 -04:00
|
|
|
scene._lookFlag = true;
|
|
|
|
} else {
|
|
|
|
_selectedAction = CAT_NONE;
|
|
|
|
scene._lookFlag = false;
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-02 22:41:25 -04:00
|
|
|
if (abortFlag || (_vm->_events->_anyStroke && (userInterface._category == CAT_COMMAND ||
|
2014-03-19 23:33:18 -04:00
|
|
|
userInterface._category == CAT_INV_VOCAB)))
|
|
|
|
return;
|
|
|
|
|
2014-03-27 22:38:28 -04:00
|
|
|
switch (_interAwaiting) {
|
|
|
|
case AWAITING_COMMAND:
|
2014-03-19 23:33:18 -04:00
|
|
|
switch (userInterface._category) {
|
2014-03-27 22:38:28 -04:00
|
|
|
case CAT_COMMAND:
|
2014-03-19 23:33:18 -04:00
|
|
|
if (_selectedRow >= 0) {
|
|
|
|
if (!_flags1) {
|
|
|
|
_selectedAction = -1;
|
|
|
|
}
|
|
|
|
else {
|
2014-04-02 22:27:11 -04:00
|
|
|
_recentCommand = _selectedRow;
|
2014-04-03 22:02:12 -04:00
|
|
|
_recentCommandSource = _commandSource;
|
2014-03-27 22:38:28 -04:00
|
|
|
_interAwaiting = AWAITING_THIS;
|
2014-03-19 23:33:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CAT_INV_LIST:
|
2014-04-02 22:27:11 -04:00
|
|
|
if (_pickedWord >= 0) {
|
|
|
|
userInterface.selectObject(_pickedWord);
|
2014-03-19 23:33:18 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CAT_INV_VOCAB:
|
|
|
|
if (_selectedRow >= 0) {
|
|
|
|
if (_flags1 != 1 || _flags2 != 0) {
|
|
|
|
if (_flags1 != 2 || _flags2 == 0) {
|
2014-03-27 22:38:28 -04:00
|
|
|
_interAwaiting = AWAITING_THAT;
|
2014-03-19 23:33:18 -04:00
|
|
|
_articleNumber = _flags2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_articleNumber = _flags2;
|
|
|
|
_selectedAction = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_selectedAction = -1;
|
|
|
|
}
|
|
|
|
|
2014-04-02 22:27:11 -04:00
|
|
|
_recentCommand = _selectedRow;
|
2014-04-03 22:02:12 -04:00
|
|
|
_recentCommandSource = _commandSource;
|
2014-03-19 23:33:18 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CAT_HOTSPOT:
|
2014-04-02 22:27:11 -04:00
|
|
|
_recentCommand = -1;
|
|
|
|
_recentCommandSource = 0;
|
2014-03-19 23:33:18 -04:00
|
|
|
|
2014-03-26 22:58:24 -04:00
|
|
|
if (_vm->_events->currentPos().y < MADS_SCENE_HEIGHT) {
|
2014-03-19 23:33:18 -04:00
|
|
|
scene._customDest = _vm->_events->currentPos() + scene._posAdjust;
|
2014-03-26 22:58:24 -04:00
|
|
|
_selectedAction = -1;
|
2014-03-27 22:38:28 -04:00
|
|
|
_v86F4A = true;
|
2014-03-26 22:58:24 -04:00
|
|
|
}
|
2014-03-19 23:33:18 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CAT_TALK_ENTRY:
|
|
|
|
if (_selectedRow >= 0)
|
|
|
|
_selectedAction = -1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-03-27 22:38:28 -04:00
|
|
|
case AWAITING_THIS:
|
2014-03-19 23:33:18 -04:00
|
|
|
switch (userInterface._category) {
|
|
|
|
case CAT_INV_LIST:
|
|
|
|
case CAT_HOTSPOT:
|
|
|
|
case CAT_INV_ANIM:
|
|
|
|
if (_hotspotId >= 0) {
|
|
|
|
if (_flags2) {
|
|
|
|
_articleNumber = _flags2;
|
2014-03-27 22:38:28 -04:00
|
|
|
_interAwaiting = AWAITING_THAT;
|
2014-03-19 23:33:18 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
_selectedAction = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (userInterface._category == CAT_HOTSPOT) {
|
|
|
|
scene._customDest = _vm->_events->mousePos() + scene._posAdjust;
|
|
|
|
_v86F4A = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-03-27 22:38:28 -04:00
|
|
|
case AWAITING_THAT:
|
2014-03-19 23:33:18 -04:00
|
|
|
switch (userInterface._category) {
|
|
|
|
case CAT_INV_LIST:
|
|
|
|
case CAT_HOTSPOT:
|
|
|
|
case CAT_INV_ANIM:
|
2014-04-03 22:02:12 -04:00
|
|
|
if (_secondObject >= 0) {
|
2014-03-19 23:33:18 -04:00
|
|
|
_selectedAction = -1;
|
|
|
|
|
|
|
|
if (userInterface._category == CAT_HOTSPOT) {
|
|
|
|
if (!_v86F4A) {
|
|
|
|
scene._customDest = _vm->_events->mousePos() + scene._posAdjust;
|
|
|
|
_v86F4A = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-03-02 23:09:17 -05:00
|
|
|
}
|
|
|
|
|
2014-03-02 19:29:54 -05:00
|
|
|
} // End of namespace MADS
|