aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel/polygons.h
blob: 4be1dabf988f3d202052b3e3a365cef1641d01dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* 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.
 *
 * $URL$
 * $Id$
 *
 * Definition of POLYGON structure and functions in POLYGONS.C
 */

#ifndef TINSEL_POLYGONS_H     // prevent multiple includes
#define TINSEL_POLYGONS_H

#include "tinsel/dw.h"	// for SCNHANDLE
#include "tinsel/scene.h"	// for PPOLY and REEL

namespace Tinsel {


// Polygon Types
enum PTYPE {
	// Tinsel 2 Polygon type list
	TEST,
	BLOCK, EFFECT, PATH, REFER, TAG,
	EX_BLOCK, EX_EFFECT, EX_PATH, EX_REFER, EX_TAG,
	// Extra polygon types from Tinsel v1
	EXIT, EX_EXIT
};

// subtype
enum {
	NORMAL = 0,
	NODE   = 1       // For paths
};

// tagFlags
enum {
	POINTING = 0x01,
	TAGWANTED = 0x02,
	FOLLOWCURSOR = 0x04
};

// tagState
enum TSTATE {
	TAG_OFF, TAG_ON
};

// pointState
enum PSTATE {
	PS_NO_POINT, PS_NOT_POINTING, PS_POINTING
};


enum {
	NOPOLY = -1
};

struct POLY_VOLATILE {
	bool bDead;
	short xoff, yoff;	// Polygon offset
};

/*-------------------------------------------------------------------------*/

bool IsInPolygon(int xt, int yt, HPOLYGON p);
HPOLYGON InPolygon(int xt, int yt, PTYPE type);
void BlockingCorner(HPOLYGON poly, int *x, int *y, int tarx, int tary);
void FindBestPoint(HPOLYGON path, int *x, int *y, int *line);
bool IsAdjacentPath(HPOLYGON path1, HPOLYGON path2);
HPOLYGON GetPathOnTheWay(HPOLYGON from, HPOLYGON to);
int NearestEndNode(HPOLYGON path, int x, int y);
int NearEndNode(HPOLYGON spath, HPOLYGON dpath);
int NearestNodeWithin(HPOLYGON npath, int x, int y);
void NearestCorner(int *x, int *y, HPOLYGON spath, HPOLYGON dpath);
bool IsPolyCorner(HPOLYGON hPath, int x, int y);
int GetScale(HPOLYGON path, int y);
int GetBrightness(HPOLYGON hPath, int y);
void getNpathNode(HPOLYGON npath, int node, int *px, int *py);
SCNHANDLE GetPolyFilm(HPOLYGON p);
void GetPolyNode(HPOLYGON hp, int *pNodeX, int *pNodeY);
SCNHANDLE GetPolyScript(HPOLYGON p);
REEL GetPolyReelType(HPOLYGON p);
int32 GetPolyZfactor(HPOLYGON p);
int numNodes(HPOLYGON pp);
void RebootDeadTags();
void DisableBlock(int block);
void EnableBlock(int block);
void DisableEffect(int effect);
void EnableEffect(int effect);
void DisablePath(int path);
void EnablePath(int path);
void DisableRefer(int refer);
void EnableRefer(int refer);
HPOLYGON GetTagHandle(int tagno);
void DisableTag(CORO_PARAM, int tag);
void EnableTag(CORO_PARAM, int tag);
void DisableExit(int exitno);
void EnableExit(int exitno);
HPOLYGON FirstPathPoly();
HPOLYGON GetPolyHandle(int i);
void InitPolygons(SCNHANDLE ph, int numPoly, bool bRestart);
void DropPolygons();


void SaveDeadPolys(bool *sdp);
void RestoreDeadPolys(bool *sdp);
void SavePolygonStuff(POLY_VOLATILE *sps);
void RestorePolygonStuff(POLY_VOLATILE *sps);

/*-------------------------------------------------------------------------*/

PTYPE PolyType(HPOLYGON hp);		// ->type
int PolySubtype(HPOLYGON hp);		// ->subtype
int PolyCentreX(HPOLYGON hp);		// ->pcentrex
int PolyCentreY(HPOLYGON hp);		// ->pcentrey
int PolyCornerX(HPOLYGON hp, int n);	// ->cx[n]
int PolyCornerY(HPOLYGON hp, int n);	// ->cy[n]
PSTATE PolyPointState(HPOLYGON hp);	// ->pointState
TSTATE PolyTagState(HPOLYGON hp);	// ->tagState

void SetPolyPointState(HPOLYGON hp, PSTATE ps);	// ->pointState
void SetPolyTagState(HPOLYGON hp, TSTATE ts);	// ->tagState
void SetPolyTagHandle(HPOLYGON hp, SCNHANDLE th);// ->oTagHandle

void MaxPolygons(int maxPolys);

int GetTagPolyId(HPOLYGON hp);
void GetTagTag(HPOLYGON hp, SCNHANDLE *hTagText, int *tagX, int *tagY);
void SetPolyPointedTo(HPOLYGON hp, bool bPointedTo);
bool PolyIsPointedTo(HPOLYGON hp);
void SetPolyTagWanted(HPOLYGON hp, bool bTagWanted, bool bCursor, SCNHANDLE hOverrideTag);
bool PolyTagIsWanted(HPOLYGON hp);
bool PolyTagFollowsCursor(HPOLYGON hp);
SCNHANDLE GetPolyTagHandle(HPOLYGON hp);
bool IsTagPolygon(int tagno);
void GetPolyMidBottom(HPOLYGON hp, int *pX, int *pY);
int PathCount();
void MovePolygon(PTYPE ptype, int id, int x, int y);
void MovePolygonTo(PTYPE ptype, int id, int x, int y);

/*-------------------------------------------------------------------------*/

} // End of namespace Tinsel

#endif		/* TINSEL_POLYGONS_H */