ScummVM API documentation
hotspot.h
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 modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (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, see <http://www.gnu.org/licenses/>.
22  *
23  */
24 
25 #ifndef PEGASUS_HOTSPOT_H
26 #define PEGASUS_HOTSPOT_H
27 
28 #include "common/list.h"
29 #include "common/rect.h"
30 
31 #include "pegasus/constants.h"
32 #include "pegasus/types.h"
33 #include "pegasus/util.h"
34 
35 /*
36 
37  Hot spots combine a pixel area, an ID value and an active flag.
38 
39  A point is considered in a hot spot if the point is in the hot spot's pixel area and
40  the active flag is set.
41 
42  In addition, hot spots have a 32 bit word of bit flags for filtering use.
43 
44 */
45 
46 namespace Common {
47  class ReadStream;
48 }
49 
50 namespace Pegasus {
51 
52 // Our implementation of QuickDraw regions
53 class Region {
54 public:
55  Region() {}
56  Region(Common::ReadStream *stream);
57  Region(const Common::Rect &rect);
58 
59  Common::Rect getBoundingBox() const { return _bounds; }
60 
61  bool pointInRegion(const Common::Point &point) const;
62 
63  void moveTo(CoordType h, CoordType v);
64  void moveTo(const Common::Point &point);
65  void translate(CoordType h, CoordType v);
66  void translate(const Common::Point &point);
67  void getCenter(CoordType &h, CoordType &v) const;
68  void getCenter(Common::Point &point) const;
69 
70 private:
71  Common::Rect _bounds;
72 
73  struct Run {
74  uint16 start, end;
75  };
76 
77  class Vector : public Common::List<Run> {
78  public:
79  uint16 y;
80  };
81 
82  Common::List<Vector> _vectors;
83 };
84 
85 class Hotspot : public IDObject {
86 public:
87  Hotspot(const HotSpotID);
88  virtual ~Hotspot();
89 
90  void setArea(const Region &region) { _spotArea = region; }
91  void setArea(const Common::Rect &);
92  void setArea(const CoordType, const CoordType, const CoordType, const CoordType);
93  void getBoundingBox(Common::Rect &) const;
94  void getArea(Region &) const;
95  void getCenter(Common::Point&) const;
96  void getCenter(CoordType&, CoordType&) const;
97 
98  void moveSpotTo(const CoordType, const CoordType);
99  void moveSpotTo(const Common::Point);
100  void moveSpot(const CoordType, const CoordType);
101  void moveSpot(const Common::Point);
102 
103  bool pointInSpot(const Common::Point) const;
104 
105  void setActive();
106  void setInactive();
107  bool isSpotActive() const;
108 
109  HotSpotFlags getHotspotFlags() const;
110  void setHotspotFlags(const HotSpotFlags);
111  void setMaskedHotspotFlags(const HotSpotFlags flags, const HotSpotFlags mask);
112 
113 protected:
114  Region _spotArea;
115  HotSpotFlags _spotFlags;
116  bool _spotActive;
117 };
118 
119 class HotspotList : public Common::List<Hotspot *> {
120 public:
121  HotspotList();
122  virtual ~HotspotList();
123 
124  void deleteHotspots();
125 
126  Hotspot *findHotspot(const Common::Point);
127  HotSpotID findHotspotID(const Common::Point);
128  Hotspot *findHotspotByID(const HotSpotID);
129  Hotspot *findHotspotByMask(const HotSpotFlags);
130 
131  void activateMaskedHotspots(const HotSpotFlags = kNoHotSpotFlags);
132  void deactivateAllHotspots();
133  void deactivateMaskedHotspots(const HotSpotFlags);
134 
135  void activateOneHotspot(const HotSpotID);
136  void deactivateOneHotspot(const HotSpotID);
137 
138  void removeOneHotspot(const HotSpotID);
139  void removeMaskedHotspots(const HotSpotFlags = kNoHotSpotFlags);
140 
141  void setHotspotRect(const HotSpotID, const Common::Rect&);
142  void getHotspotRect(const HotSpotID, Common::Rect&);
143 };
144 
146 
147 #define g_allHotspots g_vm->getAllHotspots()
148 
149 } // End of namespace Pegasus
150 
151 #endif
Definition: list.h:44
Definition: rect.h:144
Definition: hotspot.h:85
Definition: util.h:38
Definition: algorithm.h:29
Definition: hotspot.h:53
Definition: rect.h:45
Definition: hotspot.h:119
Definition: stream.h:385
Definition: list_intern.h:51
Definition: ai_action.h:33