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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * Definition of POLYGON structure and functions in POLYGONS.C
22  */
23 
24 #ifndef TINSEL_POLYGONS_H     // prevent multiple includes
25 #define TINSEL_POLYGONS_H
26 
27 #include "tinsel/dw.h"	// for SCNHANDLE
28 #include "tinsel/scene.h"	// for PPOLY and REEL
29 
30 namespace Tinsel {
31 
32 
33 // Polygon Types
34 enum PTYPE {
35 	// Tinsel 2 Polygon type list
36 	TEST,
37 	BLOCK, EFFECT, PATH, REFER, TAG,
38 	EX_BLOCK, EX_EFFECT, EX_PATH, EX_REFER, EX_TAG,
39 	// Extra polygon types from Tinsel v1
40 	EXIT, EX_EXIT
41 };
42 
43 // subtype
44 enum {
45 	NORMAL = 0,
46 	NODE   = 1       // For paths
47 };
48 
49 // tagFlags
50 enum {
51 	POINTING = 0x01,
52 	TAGWANTED = 0x02,
53 	FOLLOWCURSOR = 0x04
54 };
55 
56 // tagState
57 enum TSTATE {
58 	TAG_OFF, TAG_ON
59 };
60 
61 // pointState
62 enum PSTATE {
63 	PS_NO_POINT, PS_NOT_POINTING, PS_POINTING
64 };
65 
66 
67 enum {
68 	NOPOLY = -1
69 };
70 
71 struct POLY_VOLATILE {
72 	bool bDead;
73 	short xoff, yoff;	// Polygon offset
74 };
75 
76 /*-------------------------------------------------------------------------*/
77 
78 bool IsInPolygon(int xt, int yt, HPOLYGON p);
79 HPOLYGON InPolygon(int xt, int yt, PTYPE type);
80 void BlockingCorner(HPOLYGON poly, int *x, int *y, int tarx, int tary);
81 void FindBestPoint(HPOLYGON path, int *x, int *y, int *line);
82 bool IsAdjacentPath(HPOLYGON path1, HPOLYGON path2);
83 HPOLYGON GetPathOnTheWay(HPOLYGON from, HPOLYGON to);
84 int NearestEndNode(HPOLYGON path, int x, int y);
85 int NearEndNode(HPOLYGON spath, HPOLYGON dpath);
86 int NearestNodeWithin(HPOLYGON npath, int x, int y);
87 void NearestCorner(int *x, int *y, HPOLYGON spath, HPOLYGON dpath);
88 bool IsPolyCorner(HPOLYGON hPath, int x, int y);
89 int GetScale(HPOLYGON path, int y);
90 int GetBrightness(HPOLYGON hPath, int y);
91 void getNpathNode(HPOLYGON npath, int node, int *px, int *py);
92 SCNHANDLE GetPolyFilm(HPOLYGON p);
93 void GetPolyNode(HPOLYGON hp, int *pNodeX, int *pNodeY);
94 SCNHANDLE GetPolyScript(HPOLYGON p);
95 REEL GetPolyReelType(HPOLYGON p);
96 int32 GetPolyZfactor(HPOLYGON p);
97 int numNodes(HPOLYGON pp);
98 void RebootDeadTags();
99 void DisableBlock(int block);
100 void EnableBlock(int block);
101 void DisableEffect(int effect);
102 void EnableEffect(int effect);
103 void DisablePath(int path);
104 void EnablePath(int path);
105 void DisableRefer(int refer);
106 void EnableRefer(int refer);
107 HPOLYGON GetTagHandle(int tagno);
108 void DisableTag(CORO_PARAM, int tag);
109 void EnableTag(CORO_PARAM, int tag);
110 void DisableExit(int exitno);
111 void EnableExit(int exitno);
112 HPOLYGON FirstPathPoly();
113 HPOLYGON GetPolyHandle(int i);
114 void InitPolygons(SCNHANDLE ph, int numPoly, bool bRestart);
115 void DropPolygons();
116 
117 
118 void SaveDeadPolys(bool *sdp);
119 void RestoreDeadPolys(bool *sdp);
120 void SavePolygonStuff(POLY_VOLATILE *sps);
121 void RestorePolygonStuff(POLY_VOLATILE *sps);
122 
123 /*-------------------------------------------------------------------------*/
124 
125 PTYPE PolyType(HPOLYGON hp);		// ->type
126 int PolySubtype(HPOLYGON hp);		// ->subtype
127 int PolyCenterX(HPOLYGON hp);		// ->pcenterx
128 int PolyCenterY(HPOLYGON hp);		// ->pcentery
129 int PolyCornerX(HPOLYGON hp, int n);	// ->cx[n]
130 int PolyCornerY(HPOLYGON hp, int n);	// ->cy[n]
131 PSTATE PolyPointState(HPOLYGON hp);	// ->pointState
132 TSTATE PolyTagState(HPOLYGON hp);	// ->tagState
133 
134 void SetPolyPointState(HPOLYGON hp, PSTATE ps);	// ->pointState
135 void SetPolyTagState(HPOLYGON hp, TSTATE ts);	// ->tagState
136 void SetPolyTagHandle(HPOLYGON hp, SCNHANDLE th);// ->oTagHandle
137 
138 void MaxPolygons(int maxPolys);
139 
140 int GetTagPolyId(HPOLYGON hp);
141 void GetTagTag(HPOLYGON hp, SCNHANDLE *hTagText, int *tagX, int *tagY);
142 void SetPolyPointedTo(HPOLYGON hp, bool bPointedTo);
143 bool PolyIsPointedTo(HPOLYGON hp);
144 void SetPolyTagWanted(HPOLYGON hp, bool bTagWanted, bool bCursor, SCNHANDLE hOverrideTag);
145 bool PolyTagIsWanted(HPOLYGON hp);
146 bool PolyTagFollowsCursor(HPOLYGON hp);
147 SCNHANDLE GetPolyTagHandle(HPOLYGON hp);
148 bool IsTagPolygon(int tagno);
149 void GetPolyMidBottom(HPOLYGON hp, int *pX, int *pY);
150 int PathCount();
151 void MovePolygon(PTYPE ptype, int id, int x, int y);
152 void MovePolygonTo(PTYPE ptype, int id, int x, int y);
153 
154 /*-------------------------------------------------------------------------*/
155 
156 } // End of namespace Tinsel
157 
158 #endif		/* TINSEL_POLYGONS_H */
159