1 /*
2 ** am_map.h
3 **
4 **---------------------------------------------------------------------------
5 ** Copyright 2013 Braden Obrzut
6 ** All rights reserved.
7 **
8 ** Redistribution and use in source and binary forms, with or without
9 ** modification, are permitted provided that the following conditions
10 ** are met:
11 **
12 ** 1. Redistributions of source code must retain the above copyright
13 **    notice, this list of conditions and the following disclaimer.
14 ** 2. Redistributions in binary form must reproduce the above copyright
15 **    notice, this list of conditions and the following disclaimer in the
16 **    documentation and/or other materials provided with the distribution.
17 ** 3. The name of the author may not be used to endorse or promote products
18 **    derived from this software without specific prior written permission.
19 **
20 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 **---------------------------------------------------------------------------
31 **
32 **
33 */
34 
35 #ifndef __AM_MAP_H__
36 #define __AM_MAP_H__
37 
38 #include "gamemap.h"
39 #include "tarray.h"
40 #include "vectors.h"
41 
42 enum
43 {
44 	AMA_Off,
45 	AMA_Overlay,
46 	AMA_Normal
47 };
48 
49 extern unsigned automap;
50 extern bool am_cheat;
51 extern unsigned am_rotate;
52 extern bool am_overlaytextured;
53 extern bool am_drawtexturedwalls;
54 extern bool am_drawfloors;
55 extern unsigned am_overlay;
56 extern bool am_pause;
57 extern bool am_showratios;
58 
59 void AM_ChangeResolution();
60 void AM_CheckKeys();
61 void AM_UpdateFlags();
62 void AM_Toggle();
63 
64 void BasicOverhead();
65 
66 struct AMVectorPoint;
67 
68 class AutoMap
69 {
70 public:
71 	enum AMFlags
72 	{
73 		AMF_Rotate = 0x1,
74 		AMF_DrawTexturedWalls = 0x2,
75 		AMF_DrawFloor = 0x4,
76 		AMF_Overlay = 0x8,
77 		AMF_DispInfo = 0x10,
78 		AMF_DispRatios = 0x20,
79 		AMF_ShowThings = 0x40
80 	};
81 
82 	struct Color
83 	{
84 		uint32 color;
85 		byte palcolor;
86 
87 		Color &operator=(int rgb);
88 	};
89 
90 	AutoMap(unsigned int flags=0);
91 	~AutoMap();
92 
93 	void CalculateDimensions(unsigned int x, unsigned int y, unsigned int width, unsigned int height);
94 	void Draw();
95 	void SetFlags(unsigned int flags, bool set);
96 	void SetPanning(fixed x, fixed y, bool relative);
97 	void SetScale(fixed scale, bool relative);
98 
99 protected:
100 	void ClipTile(TArray<FVector2> &points) const;
101 	void DrawActor(class AActor *actor, fixed x, fixed y);
102 	void DrawClippedLine(int x0, int y0, int x1, int y1, int palcolor, uint32 realcolor) const;
103 	void DrawStats() const;
104 	void DrawVector(const AMVectorPoint *points, unsigned int numPoints, fixed x, fixed y, angle_t angle, const Color &c) const;
105 	FVector2 GetClipIntersection(const FVector2 &p1, const FVector2 &p2, unsigned edge) const;
106 	bool TransformTile(MapSpot spot, fixed x, fixed y, TArray<FVector2> &points) const;
107 
108 private:
109 	double rottable[2][2];
110 
111 	bool fullRefresh;
112 	unsigned int amFlags;
113 	int amsizex, amsizey, amx, amy;
114 	fixed ampanx, ampany;
115 	fixed amsin, amcos;
116 	fixed scale, absscale;
117 	angle_t amangle;
118 	unsigned short minmaxSel;
119 
120 	Color ArrowColor;
121 	Color BackgroundColor;
122 	Color FloorColor;
123 	Color WallColor;
124 	Color DoorColor;
125 };
126 
127 extern AutoMap AM_Main;
128 
129 #endif
130