2014-03-06 02:50:12 +00: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 "mads/mads.h"
|
|
|
|
#include "mads/hotspots.h"
|
|
|
|
|
|
|
|
namespace MADS {
|
|
|
|
|
|
|
|
DynamicHotspot::DynamicHotspot() {
|
|
|
|
_seqIndex = 0;
|
2014-03-26 02:07:33 +00:00
|
|
|
_facing = FACING_NONE;
|
2014-03-06 02:50:12 +00:00
|
|
|
_descId = 0;
|
2014-03-20 12:34:56 +00:00
|
|
|
_vocabId = 0;
|
2014-03-06 02:50:12 +00:00
|
|
|
_articleNumber = 0;
|
|
|
|
_cursor = CURSOR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DynamicHotspots::DynamicHotspots(MADSEngine *vm) : _vm(vm) {
|
|
|
|
for (int i = 0; i < DYNAMIC_HOTSPOTS_SIZE; ++i) {
|
|
|
|
DynamicHotspot rec;
|
|
|
|
rec._active = false;
|
|
|
|
_entries.push_back(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
_changed = true;
|
|
|
|
_count = 0;
|
|
|
|
}
|
|
|
|
|
2014-03-20 12:34:56 +00:00
|
|
|
int DynamicHotspots::add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds) {
|
2014-03-06 02:50:12 +00:00
|
|
|
// Find a free slot
|
|
|
|
uint idx = 0;
|
|
|
|
while ((idx < _entries.size()) && _entries[idx]._active)
|
|
|
|
++idx;
|
|
|
|
if (idx == _entries.size())
|
|
|
|
error("DynamicHotspots overflow");
|
|
|
|
|
|
|
|
_entries[idx]._active = true;
|
|
|
|
_entries[idx]._descId = descId;
|
|
|
|
_entries[idx]._seqIndex = seqIndex;
|
|
|
|
_entries[idx]._bounds = bounds;
|
|
|
|
_entries[idx]._feetPos.x = -3;
|
|
|
|
_entries[idx]._feetPos.y = 0;
|
2014-03-26 02:07:33 +00:00
|
|
|
_entries[idx]._facing = FACING_NONE;
|
2014-03-20 12:34:56 +00:00
|
|
|
_entries[idx]._vocabId = vocabId;
|
2014-03-06 02:50:12 +00:00
|
|
|
_entries[idx]._articleNumber = 6;
|
|
|
|
_entries[idx]._cursor = CURSOR_NONE;
|
|
|
|
|
|
|
|
++_count;
|
|
|
|
_changed = true;
|
|
|
|
|
|
|
|
if (seqIndex >= 0)
|
|
|
|
_vm->_game->_scene._sequences[seqIndex]._dynamicHotspotIndex = idx;
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2014-04-08 08:36:12 +00:00
|
|
|
int DynamicHotspots::setPosition(int index, const Common::Point &pos, Facing facing) {
|
2014-03-06 02:50:12 +00:00
|
|
|
if (index >= 0) {
|
2014-04-08 08:36:12 +00:00
|
|
|
_entries[index]._feetPos = pos;
|
2014-03-06 02:50:12 +00:00
|
|
|
_entries[index]._facing = facing;
|
|
|
|
}
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DynamicHotspots::setCursor(int index, CursorType cursor) {
|
|
|
|
if (index >= 0)
|
|
|
|
_entries[index]._cursor = cursor;
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicHotspots::remove(int index) {
|
|
|
|
Scene &scene = _vm->_game->_scene;
|
|
|
|
|
|
|
|
if (_entries[index]._active) {
|
|
|
|
if (_entries[index]._seqIndex >= 0)
|
|
|
|
scene._sequences[_entries[index]._seqIndex]._dynamicHotspotIndex = -1;
|
|
|
|
_entries[index]._active = false;
|
|
|
|
|
|
|
|
--_count;
|
|
|
|
_changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicHotspots::clear() {
|
|
|
|
for (uint i = 0; i < _entries.size(); ++i)
|
|
|
|
_entries[i]._active = false;
|
|
|
|
|
|
|
|
_changed = false;
|
|
|
|
_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicHotspots::reset() {
|
|
|
|
for (uint i = 0; i < _entries.size(); ++i)
|
|
|
|
remove(i);
|
|
|
|
|
|
|
|
_count = 0;
|
|
|
|
_changed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DynamicHotspots::refresh() {
|
2014-03-20 03:33:18 +00:00
|
|
|
// Reset the screen objects back to only contain UI elements
|
|
|
|
ScreenObjects &scrObjects = _vm->_game->_screenObjects;
|
|
|
|
scrObjects.resize(scrObjects._uiCount);
|
|
|
|
|
|
|
|
// Loop through adding hotspots
|
2014-03-06 02:57:38 +00:00
|
|
|
for (uint i = 0; i < _entries.size(); ++i) {
|
|
|
|
DynamicHotspot &dh = (*this)[i];
|
|
|
|
|
|
|
|
if ((*this)[i]._active) {
|
2014-04-04 02:02:12 +00:00
|
|
|
switch (scrObjects._inputMode) {
|
|
|
|
case kInputBuildingSentences:
|
|
|
|
case kInputLimitedSentences:
|
2014-03-20 03:33:18 +00:00
|
|
|
scrObjects.add(dh._bounds, _vm->_game->_scene._layer, CAT_12, dh._descId);
|
2014-04-06 01:30:42 +00:00
|
|
|
scrObjects._forceRescan = true;
|
2014-03-06 02:57:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-06 02:50:12 +00:00
|
|
|
}
|
|
|
|
|
2014-03-15 21:38:44 +00:00
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
2014-03-23 01:55:36 +00:00
|
|
|
Hotspot::Hotspot() {
|
2014-03-26 02:07:33 +00:00
|
|
|
_facing = FACING_NONE;
|
2014-03-23 01:55:36 +00:00
|
|
|
_articleNumber = 0;
|
|
|
|
_cursor = CURSOR_NONE;
|
|
|
|
_vocabId = 0;
|
|
|
|
_verbId = 0;
|
|
|
|
_active = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Hotspot::Hotspot(Common::SeekableReadStream &f) {
|
|
|
|
_bounds.left = f.readSint16LE();
|
|
|
|
_bounds.top = f.readSint16LE();
|
|
|
|
_bounds.right = f.readSint16LE();
|
|
|
|
_bounds.bottom = f.readSint16LE();
|
|
|
|
_feetPos.x = f.readSint16LE();
|
|
|
|
_feetPos.y = f.readSint16LE();
|
2014-03-26 02:07:33 +00:00
|
|
|
_facing = (Facing)f.readByte();
|
2014-03-23 01:55:36 +00:00
|
|
|
_articleNumber = f.readByte();
|
|
|
|
_active = f.readByte() != 0;
|
|
|
|
_cursor = (CursorType)f.readByte();
|
|
|
|
_vocabId = f.readUint16LE();
|
|
|
|
_verbId = f.readUint16LE();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
void Hotspots::activate(int vocabId, bool active) {
|
|
|
|
for (uint idx = 0; idx < size(); ++idx) {
|
|
|
|
Hotspot &hotspot = (*this)[idx];
|
|
|
|
if (hotspot._vocabId == vocabId) {
|
|
|
|
hotspot._active = active;
|
|
|
|
_vm->_game->_screenObjects.setActive(CAT_HOTSPOT, idx, active);
|
|
|
|
}
|
|
|
|
}
|
2014-03-15 21:38:44 +00:00
|
|
|
}
|
|
|
|
|
2014-03-06 02:50:12 +00:00
|
|
|
} // End of namespace MADS
|