1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * Additional copyright for this file: 8 * Copyright (C) 1995-1997 Presto Studios, Inc. 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License 12 * as published by the Free Software Foundation; either version 2 13 * of the License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 23 * 24 */ 25 26 #ifndef PEGASUS_HOTSPOT_H 27 #define PEGASUS_HOTSPOT_H 28 29 #include "common/list.h" 30 #include "common/rect.h" 31 32 #include "pegasus/constants.h" 33 #include "pegasus/types.h" 34 #include "pegasus/util.h" 35 36 /* 37 38 Hot spots combine a pixel area, an ID value and an active flag. 39 40 A point is considered in a hot spot if the point is in the hot spot's pixel area and 41 the active flag is set. 42 43 In addition, hot spots have a 32 bit word of bit flags for filtering use. 44 45 */ 46 47 namespace Common { 48 class ReadStream; 49 } 50 51 namespace Pegasus { 52 53 // Our implementation of QuickDraw regions 54 class Region { 55 public: Region()56 Region() {} 57 Region(Common::ReadStream *stream); 58 Region(const Common::Rect &rect); 59 getBoundingBox()60 Common::Rect getBoundingBox() const { return _bounds; } 61 62 bool pointInRegion(const Common::Point &point) const; 63 64 void moveTo(CoordType h, CoordType v); 65 void moveTo(const Common::Point &point); 66 void translate(CoordType h, CoordType v); 67 void translate(const Common::Point &point); 68 void getCenter(CoordType &h, CoordType &v) const; 69 void getCenter(Common::Point &point) const; 70 71 private: 72 Common::Rect _bounds; 73 74 struct Run { 75 uint16 start, end; 76 }; 77 78 class Vector : public Common::List<Run> { 79 public: 80 uint16 y; 81 }; 82 83 Common::List<Vector> _vectors; 84 }; 85 86 class Hotspot : public IDObject { 87 public: 88 Hotspot(const HotSpotID); 89 virtual ~Hotspot(); 90 setArea(const Region & region)91 void setArea(const Region ®ion) { _spotArea = region; } 92 void setArea(const Common::Rect &); 93 void setArea(const CoordType, const CoordType, const CoordType, const CoordType); 94 void getBoundingBox(Common::Rect &) const; 95 void getArea(Region &) const; 96 void getCenter(Common::Point&) const; 97 void getCenter(CoordType&, CoordType&) const; 98 99 void moveSpotTo(const CoordType, const CoordType); 100 void moveSpotTo(const Common::Point); 101 void moveSpot(const CoordType, const CoordType); 102 void moveSpot(const Common::Point); 103 104 bool pointInSpot(const Common::Point) const; 105 106 void setActive(); 107 void setInactive(); 108 bool isSpotActive() const; 109 110 HotSpotFlags getHotspotFlags() const; 111 void setHotspotFlags(const HotSpotFlags); 112 void setMaskedHotspotFlags(const HotSpotFlags flags, const HotSpotFlags mask); 113 114 protected: 115 Region _spotArea; 116 HotSpotFlags _spotFlags; 117 bool _spotActive; 118 }; 119 120 class HotspotList : public Common::List<Hotspot *> { 121 public: 122 HotspotList(); 123 virtual ~HotspotList(); 124 125 void deleteHotspots(); 126 127 Hotspot *findHotspot(const Common::Point); 128 HotSpotID findHotspotID(const Common::Point); 129 Hotspot *findHotspotByID(const HotSpotID); 130 Hotspot *findHotspotByMask(const HotSpotFlags); 131 132 void activateMaskedHotspots(const HotSpotFlags = kNoHotSpotFlags); 133 void deactivateAllHotspots(); 134 void deactivateMaskedHotspots(const HotSpotFlags); 135 136 void activateOneHotspot(const HotSpotID); 137 void deactivateOneHotspot(const HotSpotID); 138 139 void removeOneHotspot(const HotSpotID); 140 void removeMaskedHotspots(const HotSpotFlags = kNoHotSpotFlags); 141 142 void setHotspotRect(const HotSpotID, const Common::Rect&); 143 void getHotspotRect(const HotSpotID, Common::Rect&); 144 }; 145 146 typedef HotspotList::iterator HotspotIterator; 147 148 #define g_allHotspots (((PegasusEngine *)g_engine)->getAllHotspots()) 149 150 } // End of namespace Pegasus 151 152 #endif 153