diff options
author | Paul Gilbert | 2014-03-05 21:50:12 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-03-05 21:50:12 -0500 |
commit | c35271f20c82d35e613246779ada14fc79ee6c0a (patch) | |
tree | 2d4ea7e763cb12c3865a8fc23d4b242631032835 | |
parent | 73a7140be775693533db183f353fc9c82c14fa53 (diff) | |
download | scummvm-rg350-c35271f20c82d35e613246779ada14fc79ee6c0a.tar.gz scummvm-rg350-c35271f20c82d35e613246779ada14fc79ee6c0a.tar.bz2 scummvm-rg350-c35271f20c82d35e613246779ada14fc79ee6c0a.zip |
MADS: Moved hotspot code to a separate file
-rw-r--r-- | engines/mads/hotspots.cpp | 128 | ||||
-rw-r--r-- | engines/mads/hotspots.h | 88 | ||||
-rw-r--r-- | engines/mads/module.mk | 1 | ||||
-rw-r--r-- | engines/mads/scene.h | 1 | ||||
-rw-r--r-- | engines/mads/scene_data.cpp | 102 | ||||
-rw-r--r-- | engines/mads/scene_data.h | 51 |
6 files changed, 218 insertions, 153 deletions
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp new file mode 100644 index 0000000000..340ad7ddf1 --- /dev/null +++ b/engines/mads/hotspots.cpp @@ -0,0 +1,128 @@ +/* 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; + _facing = 0; + _descId = 0; + _field14 = 0; + _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; +} + +int DynamicHotspots::add(int descId, int field14, int seqIndex, const Common::Rect &bounds) { + // 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; + _entries[idx]._facing = 5; + _entries[idx]._field14 = field14; + _entries[idx]._articleNumber = 6; + _entries[idx]._cursor = CURSOR_NONE; + + ++_count; + _changed = true; + + if (seqIndex >= 0) + _vm->_game->_scene._sequences[seqIndex]._dynamicHotspotIndex = idx; + + return idx; +} + +int DynamicHotspots::setPosition(int index, int xp, int yp, int facing) { + if (index >= 0) { + _entries[index]._feetPos.x = xp; + _entries[index]._feetPos.y = yp; + _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() { + error("DynamicHotspots::refresh"); +} + +} // End of namespace MADS diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h new file mode 100644 index 0000000000..acbc72d60d --- /dev/null +++ b/engines/mads/hotspots.h @@ -0,0 +1,88 @@ +/* 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. + * + */ + +#ifndef MADS_HOTSPOTS_H +#define MADS_HOTSPOTS_H + +#include "common/scummsys.h" +#include "mads/events.h" + +namespace MADS { + +class MADSEngine; + + +class DynamicHotspot { +public: + bool _active; + int _seqIndex; + Common::Rect _bounds; + Common::Point _feetPos; + int _facing; + int _descId; + int _field14; + int _articleNumber; + CursorType _cursor; + + DynamicHotspot(); +}; + +#define DYNAMIC_HOTSPOTS_SIZE 8 + +class DynamicHotspots { +private: + MADSEngine *_vm; + Common::Array<DynamicHotspot> _entries; + int _count; +public: + bool _changed; +public: + DynamicHotspots(MADSEngine *vm); + + DynamicHotspot &operator[](uint idx) { return _entries[idx]; } + int add(int descId, int field14, 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); + void clear(); + void reset(); + void refresh(); +}; + +class Hotspot { +public: + Common::Rect _bounds; + Common::Point _feetPos; + int _facing; + int _articleNumber; + CursorType _cursor; + int _vocabId; + int _verbId; + + Hotspot(); + Hotspot(Common::SeekableReadStream &f); +}; + + +} // End of namespace MADS + +#endif /* MADS_HOTSPOTS_H */ diff --git a/engines/mads/module.mk b/engines/mads/module.mk index 6a44621283..7197a60955 100644 --- a/engines/mads/module.mk +++ b/engines/mads/module.mk @@ -18,6 +18,7 @@ MODULE_OBJS := \ game.o \ game_data.o \ graphics.o \ + hotspots.o \ interface.o \ mads.o \ messages.o \ diff --git a/engines/mads/scene.h b/engines/mads/scene.h index d9bc15add1..f31927d877 100644 --- a/engines/mads/scene.h +++ b/engines/mads/scene.h @@ -27,6 +27,7 @@ #include "common/array.h" #include "common/rect.h" #include "mads/assets.h" +#include "mads/hotspots.h" #include "mads/messages.h" #include "mads/msurface.h" #include "mads/scene_data.h" diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index 58fa36e037..813e9062cf 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -294,108 +294,6 @@ void DirtyAreas::reset() { /*------------------------------------------------------------------------*/ -DynamicHotspot::DynamicHotspot() { - _seqIndex = 0; - _facing = 0; - _descId = 0; - _field14 = 0; - _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; -} - -int DynamicHotspots::add(int descId, int field14, int seqIndex, const Common::Rect &bounds) { - // 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; - _entries[idx]._facing = 5; - _entries[idx]._field14 = field14; - _entries[idx]._articleNumber = 6; - _entries[idx]._cursor = CURSOR_NONE; - - ++_count; - _changed = true; - - if (seqIndex >= 0) - _vm->_game->_scene._sequences[seqIndex]._dynamicHotspotIndex = idx; - - return idx; -} - -int DynamicHotspots::setPosition(int index, int xp, int yp, int facing) { - if (index >= 0) { - _entries[index]._feetPos.x = xp; - _entries[index]._feetPos.y = yp; - _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() { - error("DynamicHotspots::refresh"); -} - -/*------------------------------------------------------------------------*/ - KernelMessage::KernelMessage() { _flags = 0; _sequenceIndex = 0; diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h index c4b6610e85..4d8cfc72cf 100644 --- a/engines/mads/scene_data.h +++ b/engines/mads/scene_data.h @@ -113,57 +113,6 @@ public: void check(bool scanFlag); }; -class DynamicHotspot { -public: - bool _active; - int _seqIndex; - Common::Rect _bounds; - Common::Point _feetPos; - int _facing; - int _descId; - int _field14; - int _articleNumber; - CursorType _cursor; - - DynamicHotspot(); -}; - -#define DYNAMIC_HOTSPOTS_SIZE 8 - -class DynamicHotspots { -private: - MADSEngine *_vm; - Common::Array<DynamicHotspot> _entries; - int _count; -public: - bool _changed; -public: - DynamicHotspots(MADSEngine *vm); - - DynamicHotspot &operator[](uint idx) { return _entries[idx]; } - int add(int descId, int field14, 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); - void clear(); - void reset(); - void refresh(); -}; - -class Hotspot { -public: - Common::Rect _bounds; - Common::Point _feetPos; - int _facing; - int _articleNumber; - CursorType _cursor; - int _vocabId; - int _verbId; - - Hotspot(); - Hotspot(Common::SeekableReadStream &f); -}; - class DirtyArea { private: static MADSEngine *_vm; |