summaryrefslogtreecommitdiffstats
path: root/src/Radar.h
blob: 9e687e2431cfb39371dcc25f9ba2c260da1ac54d (plain) (blame)
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
#pragma once
#include "Sprite2d.h"

enum eBlipType
{
	BLIP_NONE,
	BLIP_CAR,
	BLIP_CHAR,
	BLIP_OBJECT,
	BLIP_COORD,
	BLIP_CONTACT_POINT
};

enum eBlipDisplay
{
	BLIP_DISPLAY_NEITHER = 0,
	BLIP_DISPLAY_MARKER_ONLY = 1,
	BLIP_DISPLAY_BLIP_ONLY = 2,
	BLIP_DISPLAY_BOTH = 3,
};

enum eRadarSprite
{
	RADAR_SPRITE_NONE = 0,
	RADAR_SPRITE_ASUKA = 1,
	RADAR_SPRITE_BOMB = 2,
	RADAR_SPRITE_CAT = 3,
	RADAR_SPRITE_CENTRE = 4,
	RADAR_SPRITE_COPCAR = 5,
	RADAR_SPRITE_DON = 6,
	RADAR_SPRITE_EIGHT = 7,
	RADAR_SPRITE_EL = 8,
	RADAR_SPRITE_ICE = 9,
	RADAR_SPRITE_JOEY = 10,
	RADAR_SPRITE_KENJI = 11,
	RADAR_SPRITE_LIZ = 12,
	RADAR_SPRITE_LUIGI = 13,
	RADAR_SPRITE_NORTH = 14,
	RADAR_SPRITE_RAY = 15,
	RADAR_SPRITE_SAL = 16,
	RADAR_SPRITE_SAVE = 17,
	RADAR_SPRITE_SPRAY = 18,
	RADAR_SPRITE_TONY = 19,
	RADAR_SPRITE_WEAPON = 20,
	RADAR_SPRITE_COUNT = 21,
};

struct CBlip
{
	int32 m_nColor;
	int16 m_eBlipType; // eBlipType
	int32 m_nEntityHandle;
	CVector2D m_vec2DPos;
	CVector m_vecPos;
	int16 m_BlipIndex;
	bool m_bDim;
	bool m_bInUse;
	float m_Radius;
	int16 m_wScale;
	int16 m_eBlipDisplay; // eBlipDisplay
	int16 m_IconID; // eRadarSprite
};
static_assert(sizeof(CBlip) == 0x30, "CBlip: error");

// Values for screen space
#define RADAR_LEFT (40.0f)
#define RADAR_BOTTOM (47.0f)
#define RADAR_WIDTH (94.0f)
#define RADAR_HEIGHT (76.0f)

class CRadar
{
public:
	static float &m_RadarRange;
	static CBlip *ms_RadarTrace;	//[NUMRADARBLIPS]
	static CSprite2d *AsukaSprite;
	static CSprite2d *BombSprite;
	static CSprite2d *CatSprite;
	static CSprite2d *CentreSprite;
	static CSprite2d *CopcarSprite;
	static CSprite2d *DonSprite;
	static CSprite2d *EightSprite;
	static CSprite2d *ElSprite;
	static CSprite2d *IceSprite;
	static CSprite2d *JoeySprite;
	static CSprite2d *KenjiSprite;
	static CSprite2d *LizSprite;
	static CSprite2d *LuigiSprite;
	static CSprite2d *NorthSprite;
	static CSprite2d *RaySprite;
	static CSprite2d *SalSprite;
	static CSprite2d *SaveSprite;
	static CSprite2d *SpraySprite;
	static CSprite2d *TonySprite;
	static CSprite2d *WeaponSprite;
	static CSprite2d *RadarSprites[21];

public:
	static void ClearBlipForEntity(eBlipType type, int32 id);
	static void Draw3dMarkers();
	static void DrawMap();
	static void StreamRadarSections(int x, int y);
	static int ClipRadarPoly(CVector2D *out, CVector2D *in);
	static void DrawRadarSection(int x, int y);
	static void RequestMapSection(int x, int y);
	static void RemoveMapSection(int x, int y);
	static void DrawBlips();
	static int CalculateBlipAlpha(float dist);
	static CRGBA GetRadarTraceColour(uint32 color, bool bright);
	static void DrawRadarMap();
	static void DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int alpha);
	static float LimitRadarPoint(CVector2D &point);
	static void DrawRadarSprite(int sprite, float x, float y, int alpha);
	static void ShowRadarMarker(CVector pos, CRGBA color, float radius);
	static void ShowRadarTrace(float x, float y, uint32 size, uint32 red, uint32 green, uint32 blue, uint32 alpha);
	static void DrawRadarMask();
	static void SetRadarMarkerState(int counter, int flag);
	static bool DisplayThisBlip(int counter);
	static void GetTextureCorners(int x, int y, CVector2D * out);
	static void ClipRadarTileCoords(int *x, int *y);
	static void TransformRealWorldToTexCoordSpace(CVector2D &out, const CVector2D &in, int x, int y);
	static void TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D &in);
	static void TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in);
	static void TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D &in);
};