ScummVM API documentation
polygons.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  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  * Definition of POLYGON structure and functions in POLYGONS.C
21  */
22 
23 #ifndef TINSEL_POLYGONS_H // prevent multiple includes
24 #define TINSEL_POLYGONS_H
25 
26 #include "tinsel/dw.h" // for SCNHANDLE
27 #include "tinsel/scene.h" // for PPOLY and REEL
28 
29 namespace Tinsel {
30 
31 
32 // Polygon Types
33 enum PTYPE {
34  // Tinsel 2 Polygon type list
35  TEST,
36  BLOCK, EFFECT, PATH, REFER, TAG,
37  EX_BLOCK, EX_EFFECT, EX_PATH, EX_REFER, EX_TAG,
38  // Extra polygon types from Tinsel v1
39  EXIT, EX_EXIT,
40  // Extra polygon types from Tinsel v3
41  SCALE, EX_SCALE, SHAPE
42 };
43 
44 // subtype
45 enum {
46  NORMAL = 0,
47  NODE = 1 // For paths
48 };
49 
50 // tagFlags
51 enum {
52  POINTING = 0x01,
53  TAGWANTED = 0x02,
54  FOLLOWCURSOR = 0x04
55 };
56 
57 // tagState
58 enum TSTATE {
59  TAG_OFF, TAG_ON
60 };
61 
62 // pointState
63 enum PSTATE {
64  PS_NO_POINT, PS_NOT_POINTING, PS_POINTING
65 };
66 
67 
68 enum {
69  NOPOLY = -1
70 };
71 
72 struct POLY_VOLATILE {
73  bool bDead;
74  short xoff, yoff; // Polygon offset
75 };
76 
77 /*-------------------------------------------------------------------------*/
78 
79 bool IsInPolygon(int xt, int yt, HPOLYGON p);
80 HPOLYGON InPolygon(int xt, int yt, PTYPE type);
81 void BlockingCorner(HPOLYGON poly, int *x, int *y, int tarx, int tary);
82 void FindBestPoint(HPOLYGON path, int *x, int *y, int *line);
83 bool IsAdjacentPath(HPOLYGON path1, HPOLYGON path2);
84 HPOLYGON GetPathOnTheWay(HPOLYGON from, HPOLYGON to);
85 int NearestEndNode(HPOLYGON path, int x, int y);
86 int NearEndNode(HPOLYGON spath, HPOLYGON dpath);
87 int NearestNodeWithin(HPOLYGON npath, int x, int y);
88 void NearestCorner(int *x, int *y, HPOLYGON spath, HPOLYGON dpath);
89 bool IsPolyCorner(HPOLYGON hPath, int x, int y);
90 int GetScale(HPOLYGON path, int y);
91 int GetBrightness(HPOLYGON hPath, int y);
92 void getNpathNode(HPOLYGON npath, int node, int *px, int *py);
93 SCNHANDLE GetPolyFilm(HPOLYGON p);
94 void GetPolyNode(HPOLYGON hp, int *pNodeX, int *pNodeY);
95 SCNHANDLE GetPolyScript(HPOLYGON p);
96 REEL GetPolyReelType(HPOLYGON p);
97 int32 GetPolyZfactor(HPOLYGON p);
98 int numNodes(HPOLYGON pp);
99 void RebootDeadTags();
100 void DisableBlock(int block);
101 void EnableBlock(int block);
102 void DisableEffect(int effect);
103 void EnableEffect(int effect);
104 void DisablePath(int path);
105 void EnablePath(int path);
106 void DisableRefer(int refer);
107 void EnableRefer(int refer);
108 HPOLYGON GetTagHandle(int tagno);
109 void DisableTag(CORO_PARAM, int tag);
110 void EnableTag(CORO_PARAM, int tag);
111 void DisableExit(int exitno);
112 void EnableExit(int exitno);
113 HPOLYGON FirstPathPoly();
114 HPOLYGON GetPolyHandle(int i);
115 void InitPolygons(SCNHANDLE ph, int numPoly, bool bRestart);
116 void DropPolygons();
117 
118 
119 void SaveDeadPolys(bool *sdp);
120 void RestoreDeadPolys(bool *sdp);
121 void SavePolygonStuff(POLY_VOLATILE *sps);
122 void RestorePolygonStuff(POLY_VOLATILE *sps);
123 
124 /*-------------------------------------------------------------------------*/
125 
126 PTYPE PolyType(HPOLYGON hp); // ->type
127 int PolySubtype(HPOLYGON hp); // ->subtype
128 int PolyCenterX(HPOLYGON hp); // ->pcenterx
129 int PolyCenterY(HPOLYGON hp); // ->pcentery
130 int PolyCornerX(HPOLYGON hp, int n); // ->cx[n]
131 int PolyCornerY(HPOLYGON hp, int n); // ->cy[n]
132 PSTATE PolyPointState(HPOLYGON hp); // ->pointState
133 TSTATE PolyTagState(HPOLYGON hp); // ->tagState
134 
135 void SetPolyPointState(HPOLYGON hp, PSTATE ps); // ->pointState
136 void SetPolyTagState(HPOLYGON hp, TSTATE ts); // ->tagState
137 void SetPolyTagHandle(HPOLYGON hp, SCNHANDLE th);// ->oTagHandle
138 
139 void MaxPolygons(int maxPolys);
140 
141 int GetTagPolyId(HPOLYGON hp);
142 void GetTagTag(HPOLYGON hp, SCNHANDLE *hTagText, int *tagX, int *tagY);
143 void SetPolyPointedTo(HPOLYGON hp, bool bPointedTo);
144 bool PolyIsPointedTo(HPOLYGON hp);
145 void SetPolyTagWanted(HPOLYGON hp, bool bTagWanted, bool bCursor, SCNHANDLE hOverrideTag);
146 bool PolyTagIsWanted(HPOLYGON hp);
147 bool PolyTagFollowsCursor(HPOLYGON hp);
148 SCNHANDLE GetPolyTagHandle(HPOLYGON hp);
149 bool IsTagPolygon(int tagno);
150 void GetPolyMidBottom(HPOLYGON hp, int *pX, int *pY);
151 int PathCount();
152 void MovePolygon(PTYPE ptype, int id, int x, int y);
153 void MovePolygonTo(PTYPE ptype, int id, int x, int y);
154 
155 void NotebookPolyEntry(Common::Point c0, Common::Point c1, Common::Point c2, Common::Point c3);
156 void NotebookPolyNextPage(Common::Point c0, Common::Point c1, Common::Point c2, Common::Point c3);
157 void NotebookPolyPrevPage(Common::Point c0, Common::Point c1, Common::Point c2, Common::Point c3);
158 
159 /*-------------------------------------------------------------------------*/
160 
161 void UpdateGroundPlane();
162 
163 enum class NoteBookPoly {
164  CLUE_0 = 0,
165  CLUE_1 = 1,
166  CLUE_2 = 2,
167  CLUE_3 = 3,
168  CLUE_4 = 4,
169  CLUE_5 = 5,
170  CLUE_6 = 6,
171  CLUE_7 = 7,
172  MAIN,
173  NEXT,
174  PREV,
175  NONE
176 };
177 
179 public:
180  virtual ~NoteBookPolygons() {}
181  virtual void setPolygon(NoteBookPoly polyKind, const Common::Point &c0, const Common::Point &c1, const Common::Point &c2, const Common::Point &c3) = 0;
182  virtual void pushPolygon(const Common::Point &c0, const Common::Point &c1, const Common::Point &c2, const Common::Point &c3) = 0;
183 
184  virtual NoteBookPoly mostSpecificHit(const Common::Point &point) const = 0;
185  virtual int lineHit(const Common::Point &point) const = 0;
186  virtual bool isInsideNotebook(const Common::Point &point) const = 0;
187 };
188 
189 NoteBookPolygons *instantiateNoteBookPolygons();
190 
191 } // End of namespace Tinsel
192 
193 #endif /* TINSEL_POLYGONS_H */
REEL
Definition: scene.h:70
uint32 SCNHANDLE
Definition: dw.h:31
#define CORO_PARAM
Definition: coroutines.h:107
Definition: actors.h:36
Definition: rect.h:45
Definition: polygons.h:178
SCALE
Definition: scene.h:62
Definition: polygons.h:72
int HPOLYGON
Definition: dw.h:34