File: radarsetup.h

package info (click to toggle)
freespace2 3.7.0%2Brepack-2
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd
  • size: 22,848 kB
  • ctags: 41,897
  • sloc: cpp: 369,931; makefile: 1,060; xml: 129; sh: 112
file content (146 lines) | stat: -rw-r--r-- 3,869 bytes parent folder | download
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
/*
 * Copyright (C) Volition, Inc. 1999.  All rights reserved.
 *
 * All source code herein is the property of Volition, Inc. You may not sell 
 * or otherwise commercially exploit the source or things you created based on the 
 * source.
 *
*/



#ifndef _FS2OPEN_RADARSETUP_H
#define _FS2OPEN_RADARSETUP_H

#include "hud/hudconfig.h"
#include "hud/hud.h"

#define SMALL_BLIP_CHAR (Lcl_special_chars + 5)
#define LARGE_BLIP_CHAR (Lcl_special_chars + 6)

//which radar type are we using
//to add another radar type, begin by adding a RADAR_MODE_* define and increment MAX_RADAR_MODES
#define RADAR_MODE_STANDARD 0
#define RADAR_MODE_ORB 1
#define MAX_RADAR_MODES 2

//structures
#define NUM_FLICKER_TIMERS	2

struct object;

typedef struct rcol {
	ubyte	r, g, b;
} rcol;

typedef struct blip	{
	blip	*prev, *next;
	int	rad;
	int	flags;
	color *blip_color;
	vec3d position;
	int radar_image_2d;
	int radar_color_image_2d;
	int radar_image_size;
	float radar_projection_size;

	float   dist;
	object* objp;
} blip;


#define MAX_BLIPS 150

#define	MAX_RADAR_COLORS		5
#define MAX_RADAR_LEVELS		2		// bright and dim radar dots are allowed

#define RCOL_BOMB				0
#define RCOL_NAVBUOY_CARGO		1
#define RCOL_WARPING_SHIP		2
#define RCOL_JUMP_NODE			3
#define RCOL_TAGGED				4

extern rcol Radar_color_rgb[MAX_RADAR_COLORS][MAX_RADAR_LEVELS];

#define BLIP_TYPE_JUMP_NODE			0
#define BLIP_TYPE_NAVBUOY_CARGO		1
#define BLIP_TYPE_BOMB				2
#define BLIP_TYPE_WARPING_SHIP		3
#define BLIP_TYPE_TAGGED_SHIP		4
#define BLIP_TYPE_NORMAL_SHIP		5

#define MAX_BLIP_TYPES	6

extern blip	Blip_bright_list[MAX_BLIP_TYPES];		// linked list of bright blips
extern blip	Blip_dim_list[MAX_BLIP_TYPES];			// linked list of dim blips

extern blip	Blips[MAX_BLIPS];								// blips pool
extern int	N_blips;										// next blip index to take from pool

// blip flags
#define BLIP_CURRENT_TARGET	(1<<0)
#define BLIP_DRAW_DIM		(1<<1)	// object is farther than Radar_bright_range units away
#define BLIP_DRAW_DISTORTED	(1<<2)	// object is resistant to sensors, so draw distorted

extern float	Radar_bright_range;				// range within which the radar blips are bright
extern int		Radar_calc_bright_dist_timer;	// timestamp at which we recalc Radar_bright_range

extern int See_all;

enum RadarVisibility
{
	NOT_VISIBLE, //!< Not visible on the radar
	VISIBLE, //!< Fully visible on the radar
	DISTORTED //!< Visible but not fully
};

void radar_frame_init();
void radar_mission_init();
void radar_plot_object( object *objp );
RadarVisibility radar_is_visible( object *objp );

extern int Radar_static_looping;

class HudGaugeRadar: public HudGauge
{
protected:
	// user defined members
	int Radar_radius[2];
	int Radar_dist_offsets[RR_MAX_RANGES][2];

	// color Radar_colors[MAX_RADAR_COLORS][MAX_RADAR_LEVELS];

	int Radar_blip_radius_normal;
	int Radar_blip_radius_target;

	int Radar_static_playing;			// is static currently playing on the radar?
	int Radar_static_next;				// next time to toggle static on radar
	int Radar_avail_prev_frame;		// was radar active last frame?
	int Radar_death_timer;				// timestamp used to play static on radar

	int		Radar_flicker_timer[NUM_FLICKER_TIMERS];					// timestamp used to flicker blips on and off
	int		Radar_flicker_on[NUM_FLICKER_TIMERS];	

	int Small_blip_offset_x;
	int Small_blip_offset_y;
	int Large_blip_offset_x;
	int Large_blip_offset_y;

	char Small_blip_string[2];
	char Large_blip_string[2];
public:
	HudGaugeRadar();
	HudGaugeRadar(int _gauge_object, int r, int g, int b);
	void initRadius(int w, int h);
	void initBlipRadius(int normal, int target);
	void initDistanceShortOffsets(int x, int y);
	void initDistanceLongOffsets(int x, int y);
	void initDistanceInfinityOffsets(int x, int y);

	void drawRange();
	virtual void render(float frametime);
	virtual void initialize();
	virtual void pageIn();
};

#endif //_FS2OPEN_RADARSETUP_H