FS2_Open
Open source remastering of the Freespace 2 engine
hudbrackets.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #include "asteroid/asteroid.h"
13 #include "cmdline/cmdline.h"
14 #include "debris/debris.h"
15 #include "hud/hudbrackets.h"
16 #include "hud/hudtarget.h"
17 #include "iff_defs/iff_defs.h"
18 #include "jumpnode/jumpnode.h"
19 #include "mission/missionparse.h"
20 #include "object/object.h"
21 #include "parse/parselo.h"
22 #include "playerman/player.h"
23 #include "render/3d.h"
24 #include "ship/ship.h"
25 #include "weapon/emp.h"
26 #include "weapon/weapon.h"
27 
28 #define FADE_FACTOR 2 // how much the bounding brackets get faded
29 #define LOWEST_RED 50 // lowest r value for bounding bracket
30 #define LOWEST_GREEN 50 // lowest g value for bounding bracket
31 #define LOWEST_BLUE 50 // lowest b value for bounding bracket
32 
34  "attacker",
35  "attacker"
36 };
37 
38 // resolution adjust factors for the above defines
43 
45 {
46 }
47 
48 // Called by draw_bounding_brackets.
49 void draw_brackets_square(int x1, int y1, int x2, int y2, int resize_mode)
50 {
51  int width, height;
52 
53  if(resize_mode != GR_RESIZE_NONE || gr_screen.rendering_to_texture != -1)
54  {
55  gr_resize_screen_pos(&x1, &y1, NULL, NULL, resize_mode);
56  gr_resize_screen_pos(&x2, &y2, NULL, NULL, resize_mode);
57  }
58 
59  width = x2 - x1;
60  Assert( width > 0);
61  height = y2 - y1;
62  Assert( height > 0);
63 
64  // make the brackets extend 25% of the way along the width or height
65  int bracket_width = width/4;
66  int bracket_height = height/4;
67 
68  // horizontal lines
69  if ( (x1 + bracket_width > 0) && (x1 < gr_screen.clip_width) ){
70  gr_gradient(x1,y1,x1+bracket_width-1,y1,GR_RESIZE_NONE); // top left
71  gr_gradient(x1,y2,x1+bracket_width-1,y2,GR_RESIZE_NONE); // bottom left
72  }
73 
74  if ( (x2 - bracket_width < gr_screen.clip_width) && (x2 > 0) ) {
75  gr_gradient(x2, y1, x2-bracket_width+1,y1,GR_RESIZE_NONE); // top right
76  gr_gradient(x2, y2, x2-bracket_width+1,y2,GR_RESIZE_NONE); // bottom right
77  }
78 
79  // vertical lines
80  if ( (y1 + bracket_height > 0) && (y1 < gr_screen.clip_height) ) {
81  gr_gradient(x1,y1,x1,y1+bracket_height-1,GR_RESIZE_NONE); // top left
82  gr_gradient(x2,y1,x2,y1+bracket_height-1,GR_RESIZE_NONE); // top right
83  }
84 
85  if ( (y2 - bracket_height < gr_screen.clip_height) && (y2 > 0) ) {
86  gr_gradient(x1,y2,x1,y2-bracket_height+1,GR_RESIZE_NONE); // bottom left
87  gr_gradient(x2,y2,x2,y2-bracket_height+1,GR_RESIZE_NONE); // bottom right
88  }
89 }
90 
91 // NOTE: all values should be in unscaled range
92 void draw_brackets_square_quick(int x1, int y1, int x2, int y2, int thick)
93 {
94  int width, height;
95 
96  width = x2 - x1;
97  height = y2 - y1;
98 
99  // make the brackets extend 25% of the way along the width or height
100  int bracket_width = width/4;
101  int bracket_height = height/4;
102 
103  // top line
104  gr_line(x1,y1,x1+bracket_width,y1);
105  gr_line(x2,y1,x2-bracket_width,y1);
106  if ( thick ) {
107  gr_line(x1,y1+1,x1+bracket_width,y1+1);
108  gr_line(x2,y1+1,x2-bracket_width,y1+1);
109  }
110 
111  // bottom line
112  gr_line(x1,y2,x1+bracket_width,y2);
113  gr_line(x2,y2,x2-bracket_width,y2);
114  if ( thick ) {
115  gr_line(x1,y2-1,x1+bracket_width,y2-1);
116  gr_line(x2,y2-1,x2-bracket_width,y2-1);
117  }
118 
119  // left line
120  if ( thick ) {
121  gr_line(x1,y1+2,x1,y1+bracket_height);
122  gr_line(x1,y2-2,x1,y2-bracket_height);
123  gr_line(x1+1,y1+2,x1+1,y1+bracket_height);
124  gr_line(x1+1,y2-2,x1+1,y2-bracket_height);
125  } else {
126  gr_line(x1,y1+1,x1,y1+bracket_height);
127  gr_line(x1,y2-1,x1,y2-bracket_height);
128  }
129 
130  // right line
131  if ( thick ) {
132  gr_line(x2,y1+2,x2,y1+bracket_height);
133  gr_line(x2,y2-2,x2,y2-bracket_height);
134  gr_line(x2-1,y1+2,x2-1,y1+bracket_height);
135  gr_line(x2-1,y2-2,x2-1,y2-bracket_height);
136  } else {
137  gr_line(x2,y1+1,x2,y1+bracket_height);
138  gr_line(x2,y2-1,x2,y2-bracket_height);
139  }
140 }
141 
142 
143 #define NUM_DASHES 2
144 void draw_brackets_dashed_square_quick(int x1, int y1, int x2, int y2)
145 {
146  int width, height, i;
147 
148  width = x2 - x1;
149  height = y2 - y1;
150 
151  // make the brackets extend 25% of the way along the width or height
152  float bracket_width = width/4.0f;
153  float bracket_height = height/4.0f;
154 
155  int dash_width;
156  dash_width = fl2i(bracket_width / ( NUM_DASHES*2 - 1 ) + 0.5f);
157 
158  if ( dash_width < 1 ) {
159  draw_brackets_square_quick(x1, y1, x2, y2);
160  return;
161  }
162 
163  int dash_height;
164  dash_height = fl2i(bracket_height / ( NUM_DASHES*2 - 1 ) + 0.5f);
165 
166  if ( dash_height < 1 ) {
167  draw_brackets_square_quick(x1, y1, x2, y2);
168  return;
169  }
170 
171  int dash_x1, dash_x2, dash_y1, dash_y2;
172 
173  dash_x1 = x1;
174  dash_x2 = x2;
175  dash_y1 = y1;
176  dash_y2 = y2;
177 
178  for ( i = 0; i < NUM_DASHES; i++ ) {
179  // top line
180  gr_line(dash_x1, y1, dash_x1+(dash_width-1), y1);
181  gr_line(dash_x2, y1, dash_x2-(dash_width-1), y1);
182 
183  // bottom line
184  gr_line(dash_x1, y2, dash_x1+(dash_width-1), y2);
185  gr_line(dash_x2, y2, dash_x2-(dash_width-1), y2);
186 
187  dash_x1 += dash_width*2;
188  dash_x2 -= dash_width*2;
189 
190  // left line
191  gr_line(x1, dash_y1, x1, dash_y1+(dash_height-1));
192  gr_line(x1, dash_y2, x1, dash_y2-(dash_height-1));
193 
194  // right line
195  gr_line(x2, dash_y1, x2, dash_y1+(dash_height-1));
196  gr_line(x2, dash_y2, x2, dash_y2-(dash_height-1));
197 
198  dash_y1 += dash_height*2;
199  dash_y2 -= dash_height*2;
200  }
201 
202 }
203 
204 
205 
206 // draw_brackets_diamond()
207 // Called by draw_bounding_brackets.
208 
209 void draw_brackets_diamond(int x1, int y1, int x2, int y2)
210 {
211  int width, height, half_width, half_height;
212  int center_x, center_y;
213  int x_delta, y_delta;
214 
215  float side_len, bracket_len;
216 
217  width = x2 - x1;
218  height = y2 - y1;
219 
220  half_width = fl2i( width/2.0f + 0.5f );
221  half_height = fl2i( height/2.0f +0.5f );
222 
223  side_len = (float)_hypot(half_width, half_height);
224  bracket_len = side_len / 8;
225 
226  x_delta = fl2i(bracket_len * width / side_len + 0.5f);
227  y_delta = fl2i(bracket_len * height / side_len + 0.5f);
228 
229 
230  center_x = x1 + half_width;
231  center_y = y1 + half_height;
232 
233  // top left line
234  gr_gradient(center_x - x_delta, y1 + y_delta,center_x, y1);
235  gr_gradient(x1 + x_delta, center_y - y_delta, x1, center_y);
236 
237  // top right line
238  gr_gradient(center_x + x_delta, y1 + y_delta,center_x, y1);
239  gr_gradient(x2 - x_delta, center_y - y_delta, x2, center_y);
240 
241  // bottom left line
242  gr_gradient(x1 + x_delta, center_y + y_delta, x1, center_y);
243  gr_gradient(center_x - x_delta, y2 - y_delta, center_x, y2);
244 
245  // bottom right line
246  gr_gradient(x2 - x_delta, center_y + y_delta, x2, center_y);
247  gr_gradient(center_x + x_delta, y2 - y_delta, center_x, y2);
248 }
249 
250 void draw_brackets_diamond_quick(int x1, int y1, int x2, int y2)
251 {
252  int width, height, half_width, half_height;
253  int center_x, center_y;
254  int x_delta, y_delta;
255 
256  float side_len, bracket_len;
257 
258  width = x2 - x1;
259  height = y2 - y1;
260 
261  half_width = fl2i( width/2.0f + 0.5f);
262  half_height = fl2i( height/2.0f + 0.5f);
263 
264  side_len = (float)_hypot(half_width, half_height);
265  bracket_len = side_len / 8;
266 
267  x_delta = fl2i(bracket_len * width / side_len + 0.5f);
268  y_delta = fl2i(bracket_len * height / side_len + 0.5f);
269 
270  center_x = x1 + half_width;
271  center_y = y1 + half_height;
272 
273  // top left line
274  gr_line(center_x - x_delta, y1 + y_delta,center_x, y1);
275  gr_line(x1 + x_delta, center_y - y_delta, x1, center_y);
276 
277  // top right line
278  gr_line(center_x + x_delta, y1 + y_delta,center_x, y1);
279  gr_line(x2 - x_delta, center_y - y_delta, x2, center_y);
280 
281  // bottom left line
282  gr_line(x1 + x_delta, center_y + y_delta, x1, center_y);
283  gr_line(center_x - x_delta, y2 - y_delta, center_x, y2);
284 
285  // bottom right line
286  gr_line(x2 - x_delta, center_y + y_delta, x2, center_y);
287  gr_line(center_x + x_delta, y2 - y_delta, center_x, y2);
288 
289  // draw an 'X' in the middle of the brackets
290  gr_line(center_x-x_delta, center_y-y_delta, center_x+x_delta, center_y+y_delta);
291  gr_line(center_x-x_delta, center_y+y_delta, center_x+x_delta, center_y-y_delta);
292 }
293 
294 // Draw bounding brackets for a subobject.
295 // unused function, candidate for removal
296 #if 0
297 void draw_bounding_brackets_subobject()
298 {
300  if (Player_ai->targeted_subsys != NULL) {
301  ship_subsys *subsys;
302  int target_objnum;
303  object* targetp;
304  vertex subobj_vertex;
305  vec3d subobj_pos;
306  int x1,x2,y1,y2;
307 
308  subsys = Player_ai->targeted_subsys;
309  target_objnum = Player_ai->target_objnum;
310  Assert(target_objnum != -1);
311  targetp = &Objects[target_objnum];
312  Assert( targetp->type == OBJ_SHIP );
313 
314  get_subsystem_world_pos(targetp, subsys, &subobj_pos);
315 
316  g3_rotate_vertex(&subobj_vertex,&subobj_pos);
317 
318  g3_project_vertex(&subobj_vertex);
319  if (subobj_vertex.flags & PF_OVERFLOW) // if overflow, no point in drawing brackets
320  return;
321 
322  int subobj_x = fl2i(subobj_vertex.screen.xyw.x + 0.5f);
323  int subobj_y = fl2i(subobj_vertex.screen.xyw.y + 0.5f);
324  int hud_subtarget_w, hud_subtarget_h, bound_rc;
325 
326  bound_rc = subobj_find_2d_bound(subsys->system_info->radius, &targetp->orient, &subobj_pos, &x1,&y1,&x2,&y2);
327  if ( bound_rc != 0 )
328  return;
329 
330  hud_subtarget_w = x2-x1+1;
331  if ( hud_subtarget_w > gr_screen.clip_width ) {
332  hud_subtarget_w = gr_screen.clip_width;
333  }
334 
335  hud_subtarget_h = y2-y1+1;
336  if ( hud_subtarget_h > gr_screen.clip_height ) {
337  hud_subtarget_h = gr_screen.clip_height;
338  }
339 
340  if ( hud_subtarget_w > gr_screen.max_w ) {
341  x1 = subobj_x - (gr_screen.max_w>>1);
342  x2 = subobj_x + (gr_screen.max_w>>1);
343  }
344  if ( hud_subtarget_h > gr_screen.max_h ) {
345  y1 = subobj_y - (gr_screen.max_h>>1);
346  y2 = subobj_y + (gr_screen.max_h>>1);
347  }
348 
349  // *** these unsize take care of everything below ***
350  gr_unsize_screen_pos( &hud_subtarget_w, &hud_subtarget_h );
351  gr_unsize_screen_pos( &subobj_x, &subobj_y );
352  gr_unsize_screen_pos( &x1, &y1 );
353  gr_unsize_screen_pos( &x2, &y2 );
354 
355  // determine if subsystem is on far or near side of the ship
356  Player->subsys_in_view = ship_subsystem_in_sight(targetp, subsys, &View_position, &subobj_pos, 0);
357 
358  // AL 29-3-98: If subsystem is destroyed, draw gray brackets
359  // Goober5000: this will now execute for fighterbays if the bay has been given a
360  // percentage subsystem strength in ships.tbl
361  // Goober5000: this will now execute for any subsys that takes damage and will not
362  // execute for any subsys that doesn't take damage
365  } else {
366  hud_set_iff_color( targetp, 1 );
367  }
368 
369  if ( Player->subsys_in_view ) {
370  draw_brackets_square_quick(x1, y1, x2, y2);
371  } else {
372  draw_brackets_diamond_quick(x1, y1, x2, y2);
373  }
374  // mprintf(("Drawing subobject brackets at %4i, %4i\n", sx, sy));
375  }
376 }
377 #endif
378 
380 //Do we want to show the ship & class name?
381 extern int Cmdline_targetinfo;
382 
383 // Display the current target distance, right justified at (x,y)
384 void hud_target_show_dist_on_bracket(int x, int y, float distance, int font_num)
385 {
386  char text_dist[64];
387  int w,h;
388  float displayed_distance;
389 
391  return;
392  }
393 
395  return;
396  }
397 
398  // scale by distance modifier from hud_guages.tbl for display purposes
399  displayed_distance = distance * Hud_unit_multiplier;
400 
401  sprintf(text_dist, "%d", fl2i(displayed_distance+0.5f));
402  hud_num_make_mono(text_dist, font_num);
403  gr_get_string_size(&w,&h,text_dist);
404 
405  int y_delta = 4;
406  if ( HUD_drew_selection_bracket_on_target ) {
407  y += 4;
408  }
409 
410  gr_string(x - w+2, y+y_delta, text_dist);
411 }
412 
413 
415 
416 int num_ships_attacking(int target_objnum);
417 
418 // draw_bounding_brackets() will draw the faded brackets that surround the current target
419 // NOTE: x1, y1, x2 & y2 are assumed to be scaled sizes, w_correction & h_correction are assumed to be unscaled!!
420 // unused function, candidate for removal
421 #if 0
422 void draw_bounding_brackets(int x1, int y1, int x2, int y2, int w_correction, int h_correction, float distance, int target_objnum)
423 {
424  int width, height;
425 
426  if ( ( x1 < 0 && x2 < 0 ) || ( y1 < 0 && y2 < 0 ) )
427  return;
428 
429  if ( ( x1 > gr_screen.clip_width && x2 > gr_screen.clip_width ) ||
430  ( y1 > gr_screen.clip_height && y2 > gr_screen.clip_height ) )
431  return;
432 
433  // *** everything below is taken care of with this unsize ***
434  gr_unsize_screen_pos(&x1, &y1);
435  gr_unsize_screen_pos(&x2, &y2);
436 
437  width = x2-x1;
438  Assert(width>=0);
439 
440  height = y2-y1;
441  Assert(height>=0);
442 
443  if ( (width >= (gr_screen.max_w_unscaled)) && (height >= (gr_screen.max_h_unscaled)) ) {
444  return;
445  }
446 
447  if (width < Min_target_box_width[gr_screen.res]) {
448  x1 = x1 - (Min_target_box_width[gr_screen.res]-width)/2;
449  x2 = x2 + (Min_target_box_width[gr_screen.res]-width)/2;
450  }
451 
452  if (height < Min_target_box_height[gr_screen.res]) {
453  y1 = y1 - (Min_target_box_height[gr_screen.res]-height)/2;
454  y2 = y2 + (Min_target_box_height[gr_screen.res]-height)/2;
455  }
456 
457  draw_brackets_square(x1-w_correction, y1-h_correction, x2+w_correction, y2+h_correction);
458 
459  // draw distance to target in lower right corner of box
460  if ( distance > 0 ) {
461  hud_target_show_dist_on_bracket(x2+w_correction,y2+h_correction,distance);
462  }
463 
464  // Maybe show + for each additional fighter or bomber attacking target.
465  if ( (target_objnum != -1) && hud_gauge_active(HUD_ATTACKING_TARGET_COUNT) ) {
466  int num_attacking = num_ships_attacking(target_objnum);
467 
468  if (Ships_attacking_bitmap == -1){
469  Ships_attacking_bitmap = bm_load(Ships_attack_fname[gr_screen.res]);
470  }
471 
472  if (Ships_attacking_bitmap == -1) {
473  Int3();
474  return;
475  }
476 
477  // If a ship is attacked by player, show one fewer plus
478  int k=0;
479  if (Objects[target_objnum].type == OBJ_SHIP) {
480  if (iff_x_attacks_y(Player_ship->team, Ships[Objects[target_objnum].instance].team)) {
481  k = 1;
482  }
483  } else {
484  k = 1;
485  }
486 
487  if (num_attacking > k) {
488  int i, num_blips;
489 
490  num_blips = num_attacking-k;
491  if (num_blips > 4){
492  num_blips = 4;
493  }
494 
495  if (Ships_attacking_bitmap >= 0) {
496  if (num_blips > 3)
497  y1 -= 3;
498 
499  for (i=0; i<num_blips; i++) {
500  GR_AABITMAP(Ships_attacking_bitmap, x2+3, y1+i*7);
501  }
502  }
503 
504  //Increment for the position of ship name/class.
505  //DEPENDANT ON ATTACKER SIZE (X)
506  x2 += 7;
507  }
508  }
509 
510  if(Cmdline_targetinfo && (target_objnum != -1))
511  {
512  object* t_objp = &Objects[target_objnum];
513  const char* tinfo_name = NULL;
514  const char* tinfo_class = NULL;
515  char temp_name[NAME_LENGTH*2+3];
516  char temp_class[NAME_LENGTH];
518 
519  switch(t_objp->type)
520  {
521  case OBJ_SHIP:
522  hud_stuff_ship_name(temp_name, &Ships[t_objp->instance]);
523  hud_stuff_ship_class(temp_class, &Ships[t_objp->instance]);
524  tinfo_name = temp_name;
525  tinfo_class = temp_class;
526 
527  // maybe concatenate the callsign
528  if (*temp_name)
529  {
530  char temp_callsign[NAME_LENGTH];
531 
532  hud_stuff_ship_callsign(temp_callsign, &Ships[t_objp->instance]);
533  if (*temp_callsign)
534  sprintf(&temp_name[strlen(temp_name)], " (%s)", temp_callsign);
535  }
536  // maybe substitute the callsign
537  else
538  {
539  hud_stuff_ship_callsign(temp_name, &Ships[t_objp->instance]);
540  }
541  break;
542 
543  case OBJ_DEBRIS:
544  tinfo_name = XSTR("Debris", 348);
545  break;
546  case OBJ_WEAPON:
549  tinfo_name = temp_name;
550  break;
551  case OBJ_ASTEROID:
552  switch(Asteroids[t_objp->instance].asteroid_type)
553  {
554  case ASTEROID_TYPE_SMALL:
556  case ASTEROID_TYPE_LARGE:
557  tinfo_name = NOX("Asteroid");
558  break;
559  default:
560  tinfo_name = XSTR("Debris", 348);
561  }
562  break;
563  case OBJ_JUMP_NODE:
564  for (jnp = Jump_nodes.begin(); jnp != Jump_nodes.end(); ++jnp) {
565  if(jnp->GetSCPObject() == t_objp)
566  break;
567  }
568 
569  strcpy_s(temp_name, jnp->GetName());
571  tinfo_name = temp_name;
572  break;
573  }
574 
575  if(tinfo_name)
576  {
577  gr_string(x2+3, y1, tinfo_name);
578  }
579  if(tinfo_class)
580  {
581  gr_string(x2+3, y1+9, tinfo_class);
582  }
583 /*
584  if(tinfo_callsign)
585  {
586  gr_string(x2+3, y1+18, tinfo_callsign);
587  }
588  */
589  }
590 }
591 #endif
592 
593 int draw_subsys_brackets(ship_subsys* subsys, int min_width, int min_height, bool draw, bool set_color, int* draw_coords)
594 {
595  Assertion(subsys != NULL, "Invalid subsystem pointer passed to draw_subsys_brackets!");
596 
597  int target_objnum;
598  object* targetp;
599  vertex subobj_vertex;
600  vec3d subobj_pos;
601  int x1,x2,y1,y2;
602 
603  target_objnum = subsys->parent_objnum;
604  Assert(target_objnum != -1);
605  targetp = &Objects[target_objnum];
606  Assert( targetp->type == OBJ_SHIP );
607 
608  get_subsystem_world_pos(targetp, subsys, &subobj_pos);
609 
610  g3_rotate_vertex(&subobj_vertex,&subobj_pos);
611 
612  g3_project_vertex(&subobj_vertex);
613  if (subobj_vertex.flags & PF_OVERFLOW) // if overflow, no point in drawing brackets
614  return -1;
615 
616  int subobj_x = fl2i(subobj_vertex.screen.xyw.x + 0.5f);
617  int subobj_y = fl2i(subobj_vertex.screen.xyw.y + 0.5f);
618  int hud_subtarget_w, hud_subtarget_h, bound_rc;
619 
620  bound_rc = subobj_find_2d_bound(subsys->system_info->radius, &targetp->orient, &subobj_pos, &x1,&y1,&x2,&y2);
621  if ( bound_rc != 0 )
622  return -1;
623 
624  hud_subtarget_w = x2-x1+1;
625  if ( hud_subtarget_w > gr_screen.clip_width ) {
626  hud_subtarget_w = gr_screen.clip_width;
627  }
628 
629  hud_subtarget_h = y2-y1+1;
630  if ( hud_subtarget_h > gr_screen.clip_height ) {
631  hud_subtarget_h = gr_screen.clip_height;
632  }
633 
634  if ( hud_subtarget_w > gr_screen.max_w ) {
635  x1 = subobj_x - (gr_screen.max_w>>1);
636  x2 = subobj_x + (gr_screen.max_w>>1);
637  }
638  if ( hud_subtarget_h > gr_screen.max_h ) {
639  y1 = subobj_y - (gr_screen.max_h>>1);
640  y2 = subobj_y + (gr_screen.max_h>>1);
641  }
642 
643  // *** these unsize take care of everything below ***
644  gr_unsize_screen_pos( &hud_subtarget_w, &hud_subtarget_h );
645  gr_unsize_screen_pos( &subobj_x, &subobj_y );
646  gr_unsize_screen_pos( &x1, &y1 );
647  gr_unsize_screen_pos( &x2, &y2 );
648 
649  if ( hud_subtarget_w < min_width ) {
650  x1 = subobj_x - (min_width>>1);
651  x2 = subobj_x + (min_width>>1);
652  }
653  if ( hud_subtarget_h < min_height ) {
654  y1 = subobj_y - (min_height>>1);
655  y2 = subobj_y + (min_height>>1);
656  }
657 
658  // determine if subsystem is on far or near side of the ship
659  int in_sight = ship_subsystem_in_sight(targetp, subsys, &View_position, &subobj_pos, 0);
660 
661  if (draw)
662  {
663 
664  if (set_color)
665  {
666  // AL 29-3-98: If subsystem is destroyed, draw gray brackets
667  // Goober5000: this will now execute for fighterbays if the bay has been given a
668  // percentage subsystem strength in ships.tbl
669  // Goober5000: this will now execute for any subsys that takes damage and will not
670  // execute for any subsys that doesn't take damage
671  if ( (subsys->current_hits <= 0) && ( ship_subsys_takes_damage(subsys) ) ) {
673  } else {
674  hud_set_iff_color( targetp, 1 );
675  }
676  }
677 
678  if ( in_sight ) {
679  draw_brackets_square_quick(x1, y1, x2, y2);
680  } else {
681  draw_brackets_diamond_quick(x1, y1, x2, y2);
682  }
683  }
684 
685  if (draw_coords != nullptr)
686  {
687  // Positions are unsized, we need to resize them to get the actual screen coordinates
688  gr_resize_screen_pos(&x1, &y1);
689  gr_resize_screen_pos(&x2, &y2);
690 
691  draw_coords[0] = x1;
692  draw_coords[1] = y1;
693  draw_coords[2] = x2;
694  draw_coords[3] = y2;
695  }
696  // mprintf(("Drawing subobject brackets at %4i, %4i\n", sx, sy));
697 
698  return in_sight;
699 }
700 
703 {
704 }
705 
707 {
710 }
711 
713 {
716 }
717 
719 {
720  attacking_dot = bm_load(fname);
721  if (attacking_dot < 0) {
722  Warning(LOCATION,"Cannot load hud ani: %s\n", fname);
723  }
724 }
725 
726 void HudGaugeBrackets::render(float frametime)
727 {
728  // don't display brackets if we're warping out.
729  if ( Player->control_mode != PCM_NORMAL ) {
730  return;
731  }
732 
733  bool in_frame = g3_in_frame() > 0;
734  if(!in_frame)
735  g3_start_frame(0);
736 
737  for(size_t i = 0; i < target_display_list.size(); i++) {
738  // make sure this point is projected. Otherwise, skip.
739  if( !(target_display_list[i].target_point.flags & PF_OVERFLOW) ) {
740  if ( target_display_list[i].objp ) {
741  renderObjectBrackets(target_display_list[i].objp, &target_display_list[i].bracket_clr, target_display_list[i].correction,
742  target_display_list[i].correction, target_display_list[i].flags);
743  } else {
744  // no corresponding object so this must represent a nav point.
745  renderNavBrackets(&target_display_list[i].target_pos, &target_display_list[i].target_point, &target_display_list[i].bracket_clr,
747  }
748  }
749  }
750 
751  if(!in_frame)
752  g3_end_frame();
753 }
754 
755 void HudGaugeBrackets::renderObjectBrackets(object *targetp, color *clr, int w_correction, int h_correction, int flags)
756 {
757  int x1,x2,y1,y2;
758  bool draw_box = true;
759  int bound_rc;
761 
762  if ( Player->target_is_dying <= 0 ) {
763  int modelnum;
764 
765  switch ( targetp->type ) {
766  case OBJ_SHIP:
767  modelnum = Ship_info[Ships[targetp->instance].ship_info_index].model_num;
768  bound_rc = model_find_2d_bound_min( modelnum, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 );
769  if ( bound_rc != 0 ) {
770  draw_box = false;
771  }
772  break;
773 
774  case OBJ_DEBRIS:
775  modelnum = Debris[targetp->instance].model_num;
776  bound_rc = submodel_find_2d_bound_min( modelnum, Debris[targetp->instance].submodel_num, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 );
777  if ( bound_rc != 0 ) {
778  draw_box = false;
779  }
780  break;
781 
782  case OBJ_WEAPON:
784  if (modelnum != -1)
785  bound_rc = model_find_2d_bound_min( modelnum, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 );
786  else {
787  vertex vtx;
788  g3_rotate_vertex(&vtx,&targetp->pos);
789  g3_project_vertex(&vtx);
790  x1 = x2 = (int) vtx.screen.xyw.x;
791  y1 = y2 = (int) vtx.screen.xyw.y;
792  }
793 
794  break;
795 
796  case OBJ_ASTEROID:
797  {
798  int pof = 0;
799  pof = Asteroids[targetp->instance].asteroid_subtype;
800  modelnum = Asteroid_info[Asteroids[targetp->instance].asteroid_type].model_num[pof];
801  bound_rc = model_find_2d_bound_min( modelnum, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 );
802  }
803  break;
804 
805  case OBJ_JUMP_NODE:
806  for (jnp = Jump_nodes.begin(); jnp != Jump_nodes.end(); ++jnp) {
807  if(jnp->GetSCPObject() == targetp)
808  break;
809  }
810 
811  modelnum = jnp->GetModelNumber();
812  bound_rc = model_find_2d_bound_min( modelnum, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 );
813  break;
814 
815  default:
816  Int3(); // should never happen
817  return;
818  }
819 
820  Hud_target_w = x2-x1+1;
823  }
824 
825  Hud_target_h = y2-y1+1;
828  }
829 
830  if(clr->red && clr->green && clr->blue ) {
831  gr_set_color_fast(clr);
832  } else {
833  // if no specific color defined, use the IFF color.
834  hud_set_iff_color(targetp, 1);
835  }
836 
837  if ( draw_box ) {
838  float distance = 0.0f; // init to 0 if we don't have to display distance
839  int target_objnum = -1;
840 
841  if(flags & TARGET_DISPLAY_DIST) {
842  distance = hud_find_target_distance(targetp, Player_obj);
843  }
844 
845  if(flags & TARGET_DISPLAY_DOTS) {
846  target_objnum = OBJ_INDEX(targetp);
847  }
848 
849  renderBoundingBrackets(x1-5, y1-5, x2+5, y2+5, w_correction, h_correction, distance, target_objnum, flags);
850  }
851 
852  if ( (targetp->type == OBJ_SHIP) && (flags & TARGET_DISPLAY_SUBSYS) ) {
854  }
855  }
856 }
857 
858 void HudGaugeBrackets::renderNavBrackets(vec3d* nav_pos, vertex* nav_point, color* clr, char* string)
859 {
860  float dist;
861  int box_scale = 15;
862  int x, y;
863 
864  x = int(nav_point->screen.xyw.x);
865  y = int(nav_point->screen.xyw.y);
866 
867  // draw this nav bracket based on this gauge's base resolution
869 
870  gr_unsize_screen_pos( &x, &y );
871 
872  dist = vm_vec_dist_quick(&Objects[Player_ship->objnum].pos, nav_pos);
873 
874  if (dist < 1000)
875  box_scale = int(float(dist)/1000.0f * 15);
876  if (box_scale < 4)
877  box_scale=4;
878 
879  gr_set_color_fast(clr);
880  draw_brackets_square(x-box_scale, y-box_scale, x+box_scale, y+box_scale);
881 
882  // draw the nav name
883  if(string) {
884  gr_string(x-(box_scale+10), y-(box_scale+20), string);
885  }
886 
887  // draw distance to target in lower right corner of box
888  hud_target_show_dist_on_bracket(x+(box_scale+10),y+(box_scale+10), dist, font_num);
889 
890  // bring the scale back to normal
892 }
893 
894 void HudGaugeBrackets::renderBoundingBrackets(int x1, int y1, int x2, int y2, int w_correction, int h_correction, float distance, int target_objnum, int flags)
895 {
896  int width, height;
897 
898  if ( ( x1 < 0 && x2 < 0 ) || ( y1 < 0 && y2 < 0 ) )
899  return;
900 
901  if ( ( x1 > gr_screen.clip_width && x2 > gr_screen.clip_width ) ||
902  ( y1 > gr_screen.clip_height && y2 > gr_screen.clip_height ) )
903  return;
904 
905  // draw the all bracket components based on this gauge's screen scale
907 
908  // *** everything below is taken care of with this unsize ***
909  gr_unsize_screen_pos(&x1, &y1);
910  gr_unsize_screen_pos(&x2, &y2);
911 
912  width = x2-x1;
913  Assert(width>=0);
914 
915  height = y2-y1;
916  Assert(height>=0);
917 
918  if ( (width >= (base_w)) && (height >= (base_h)) ) {
919  return;
920  }
921 
922  if (width < Min_target_box_width) {
923  x1 = x1 - (Min_target_box_width-width)/2;
924  x2 = x2 + (Min_target_box_width-width)/2;
925  }
926 
927  if (height < Min_target_box_height) {
928  y1 = y1 - (Min_target_box_height-height)/2;
929  y2 = y2 + (Min_target_box_height-height)/2;
930  }
931 
932  draw_brackets_square(x1-w_correction, y1-h_correction, x2+w_correction, y2+h_correction);
933 
934  // draw distance to target in lower right corner of box
935  if ( distance > 0 ) {
936  hud_target_show_dist_on_bracket(x2+w_correction,y2+h_correction,distance,font_num);
937  }
938 
939  // Maybe show + for each additional fighter or bomber attacking target.
940  if ( (target_objnum != -1) ) {
941  int num_attacking = num_ships_attacking(target_objnum);
942 
943  // If a ship is attacked by player, show one fewer plus
944  int k=0;
945  if (Objects[target_objnum].type == OBJ_SHIP) {
946  if (iff_x_attacks_y(Player_ship->team, Ships[Objects[target_objnum].instance].team)) {
947  k = 1;
948  }
949  } else {
950  k = 1;
951  }
952 
953  if (num_attacking > k) {
954  int i, w, h, num_blips;
955 
956  num_blips = num_attacking-k;
957  if (num_blips > 4) {
958  num_blips = 4;
959  }
960 
961  //int bitmap = get_blip_bitmap();
962 
963  bm_get_info(attacking_dot, &w, &h);
964 
965  if (attacking_dot >= 0) {
966  if (num_blips > 3)
967  y1 -= 3;
968 
969  for (i=0; i<num_blips; i++) {
970  GR_AABITMAP(attacking_dot, x2+3, y1+i*(h+2));
971  }
972  }
973 
974  // Increment for the position of ship name/class.
975  // DEPENDANT ON ATTACKER SIZE (X)
976  x2 += w + 2;
977  }
978  }
979 
980  if( (target_objnum != -1) && (flags & (TARGET_DISPLAY_NAME | TARGET_DISPLAY_CLASS)) ) {
981  object* t_objp = &Objects[target_objnum];
982  const char* tinfo_name = NULL;
983  const char* tinfo_class = NULL;
984  char temp_name[NAME_LENGTH*2+3];
985  char temp_class[NAME_LENGTH];
987 
988  switch(t_objp->type) {
989  case OBJ_SHIP:
990  hud_stuff_ship_name(temp_name, &Ships[t_objp->instance]);
991  hud_stuff_ship_class(temp_class, &Ships[t_objp->instance]);
992  tinfo_name = temp_name;
993  tinfo_class = temp_class;
994 
995  // maybe concatenate the callsign
996  if (*temp_name) {
997  char temp_callsign[NAME_LENGTH];
998 
999  hud_stuff_ship_callsign(temp_callsign, &Ships[t_objp->instance]);
1000  if (*temp_callsign)
1001  sprintf(&temp_name[strlen(temp_name)], " (%s)", temp_callsign);
1002  } else { // maybe substitute the callsign
1003  hud_stuff_ship_callsign(temp_name, &Ships[t_objp->instance]);
1004  }
1005  break;
1006 
1007  case OBJ_DEBRIS:
1008  tinfo_name = XSTR("Debris", 348);
1009  break;
1010  case OBJ_WEAPON:
1013  tinfo_name = temp_name;
1014  break;
1015  case OBJ_ASTEROID:
1016  switch(Asteroids[t_objp->instance].asteroid_type) {
1017  case ASTEROID_TYPE_SMALL:
1018  case ASTEROID_TYPE_MEDIUM:
1019  case ASTEROID_TYPE_LARGE:
1020  tinfo_name = NOX("Asteroid");
1021  break;
1022  default:
1023  tinfo_name = XSTR("Debris", 348);
1024  }
1025  break;
1026  case OBJ_JUMP_NODE:
1027  for (jnp = Jump_nodes.begin(); jnp != Jump_nodes.end(); ++jnp) {
1028  if(jnp->GetSCPObject() == t_objp)
1029  break;
1030  }
1031 
1032  strcpy_s(temp_name, jnp->GetName());
1034  tinfo_name = temp_name;
1035  break;
1036  }
1037 
1038  if(tinfo_name && (flags & TARGET_DISPLAY_NAME)) {
1039  gr_string(x2+3, y1, tinfo_name);
1040  }
1041  if(tinfo_class && (flags & TARGET_DISPLAY_CLASS)) {
1042  gr_string(x2+3, y1+gr_get_font_height(), tinfo_class);
1043  }
1044  }
1045 
1046  // we're done, so bring the scale back to normal
1048 }
1049 
1051 {
1053  if (Player_ai->targeted_subsys != NULL) {
1054  ship_subsys *subsys;
1055  int target_objnum;
1056  object* targetp;
1057  vertex subobj_vertex;
1058  vec3d subobj_pos;
1059  int x1,x2,y1,y2;
1060 
1061  subsys = Player_ai->targeted_subsys;
1062  target_objnum = Player_ai->target_objnum;
1063  Assert(target_objnum != -1);
1064  targetp = &Objects[target_objnum];
1065  Assert( targetp->type == OBJ_SHIP );
1066 
1068 
1069  get_subsystem_world_pos(targetp, subsys, &subobj_pos);
1070 
1071  g3_rotate_vertex(&subobj_vertex,&subobj_pos);
1072 
1073  g3_project_vertex(&subobj_vertex);
1074  if (subobj_vertex.flags & PF_OVERFLOW) // if overflow, no point in drawing brackets
1075  return;
1076 
1077  int subobj_x = fl2i(subobj_vertex.screen.xyw.x + 0.5f);
1078  int subobj_y = fl2i(subobj_vertex.screen.xyw.y + 0.5f);
1079  int hud_subtarget_w, hud_subtarget_h, bound_rc;
1080 
1081  bound_rc = subobj_find_2d_bound(subsys->system_info->radius, &targetp->orient, &subobj_pos, &x1,&y1,&x2,&y2);
1082  if ( bound_rc != 0 )
1083  return;
1084 
1085  hud_subtarget_w = x2-x1+1;
1086  if ( hud_subtarget_w > gr_screen.clip_width ) {
1087  hud_subtarget_w = gr_screen.clip_width;
1088  }
1089 
1090  hud_subtarget_h = y2-y1+1;
1091  if ( hud_subtarget_h > gr_screen.clip_height ) {
1092  hud_subtarget_h = gr_screen.clip_height;
1093  }
1094 
1095  if ( hud_subtarget_w > gr_screen.max_w ) {
1096  x1 = subobj_x - (gr_screen.max_w>>1);
1097  x2 = subobj_x + (gr_screen.max_w>>1);
1098  }
1099  if ( hud_subtarget_h > gr_screen.max_h ) {
1100  y1 = subobj_y - (gr_screen.max_h>>1);
1101  y2 = subobj_y + (gr_screen.max_h>>1);
1102  }
1103 
1104  // *** these unsize take care of everything below ***
1105  gr_unsize_screen_pos( &hud_subtarget_w, &hud_subtarget_h );
1106  gr_unsize_screen_pos( &subobj_x, &subobj_y );
1107  gr_unsize_screen_pos( &x1, &y1 );
1108  gr_unsize_screen_pos( &x2, &y2 );
1109 
1110  if ( hud_subtarget_w < Min_subtarget_box_width ) {
1111  x1 = subobj_x - (Min_subtarget_box_width>>1);
1112  x2 = subobj_x + (Min_subtarget_box_width>>1);
1113  }
1114  if ( hud_subtarget_h < Min_subtarget_box_height ) {
1115  y1 = subobj_y - (Min_subtarget_box_height>>1);
1116  y2 = subobj_y + (Min_subtarget_box_height>>1);
1117  }
1118 
1119  // determine if subsystem is on far or near side of the ship
1120  Player->subsys_in_view = ship_subsystem_in_sight(targetp, subsys, &View_position, &subobj_pos, 0);
1121 
1122  // AL 29-3-98: If subsystem is destroyed, draw gray brackets
1123  // Goober5000: this will now execute for fighterbays if the bay has been given a
1124  // percentage subsystem strength in ships.tbl
1125  // Goober5000: this will now execute for any subsys that takes damage and will not
1126  // execute for any subsys that doesn't take damage
1129  } else {
1130  hud_set_iff_color( targetp, 1 );
1131  }
1132 
1133  if ( Player->subsys_in_view ) {
1134  draw_brackets_square_quick(x1, y1, x2, y2);
1135  } else {
1136  draw_brackets_diamond_quick(x1, y1, x2, y2);
1137  }
1138  // mprintf(("Drawing subobject brackets at %4i, %4i\n", sx, sy));
1139 
1140  // reset the scale to normal
1142  }
1143 }
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
struct screen3d::@234::@236 xyw
void renderObjectBrackets(object *targetp, color *clr, int w_correction, int h_correction, int flags)
int i
Definition: multi_pxo.cpp:466
#define HUD_OFFSCREEN_INDICATOR
Definition: hudgauges.h:42
model_subsystem * system_info
Definition: ship.h:314
weapon Weapons[MAX_WEAPONS]
Definition: weapons.cpp:78
char Ships_attack_fname[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN]
Definition: hudbrackets.cpp:33
ai_info * Player_ai
Definition: ai.cpp:24
int team
Definition: ship.h:606
void hud_target_show_dist_on_bracket(int x, int y, float distance, int font_num)
#define TARGET_DISPLAY_DIST
Definition: hudtarget.h:160
char name[NAME_LENGTH]
Definition: weapon.h:322
vec3d View_position
Definition: 3dsetup.cpp:20
int objnum
Definition: ship.h:537
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
weapon_info Weapon_info[MAX_WEAPON_TYPES]
Definition: weapons.cpp:79
void renderNavBrackets(vec3d *nav_pos, vertex *nav_point, color *clr, char *string)
int Min_target_box_height
Definition: hudbrackets.h:37
void hud_num_make_mono(char *num_str, int font_num)
Convert a number string to use mono-spaced 1 character.
Definition: hud.cpp:2275
asteroid Asteroids[MAX_ASTEROIDS]
Definition: asteroid.cpp:63
int Ships_attacking_bitmap
#define PCM_NORMAL
Definition: player.h:58
int Min_target_box_width
Definition: hudbrackets.h:36
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
Assert(pm!=NULL)
int target_objnum
Definition: ai.h:339
void hud_stuff_ship_name(char *ship_name_text, ship *shipp)
Definition: hudtarget.cpp:5269
Definition: pstypes.h:88
#define ASTEROID_TYPE_SMALL
Definition: asteroid.h:29
#define GR_NUM_RESOLUTIONS
Definition: 2d.h:651
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:769
#define OBJ_ASTEROID
Definition: object.h:44
Definition: 2d.h:95
int subsys_in_view
Definition: player.h:168
int res
Definition: 2d.h:370
int subobj_find_2d_bound(float radius, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
Definition: modelread.cpp:3345
int max_h_unscaled
Definition: 2d.h:361
int bm_get_info(int handle, int *w, int *h, ubyte *flags, int *nframes, int *fps)
Gets info on the bitmap indexed by handle.
Definition: bmpman.cpp:769
#define NUM_DASHES
__inline void gr_gradient(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:808
int hud_gauge_active(int gauge_index)
Determine if the specified HUD gauge should be displayed.
Definition: hud.cpp:3006
void initBitmaps(char *fname)
int base_h
Definition: hud.h:205
int Cmdline_targetinfo
Definition: cmdline.cpp:367
GLclampf f
Definition: Glext.h:7097
int model_find_2d_bound_min(int model_num, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
Definition: modelread.cpp:3168
int ship_subsystem_in_sight(object *objp, ship_subsys *subsys, vec3d *eye_pos, vec3d *subsys_pos, int do_facing_check, float *dot_out, vec3d *vec_out)
Definition: ship.cpp:14881
int model_num
Definition: debris.h:34
#define Assertion(expr, msg,...)
Definition: clang.h:41
ship_subsys * targeted_subsys
Definition: ai.h:472
#define HUD_ATTACKING_TARGET_COUNT
Definition: hudgauges.h:52
void gr_set_screen_scale(int w, int h, int zoom_w, int zoom_h, int max_w, int max_h, int center_w, int center_h, bool force_stretch)
Definition: 2d.cpp:104
SCP_vector< target_display_info > target_display_list
Definition: hudtarget.cpp:72
void gr_set_color_fast(color *dst)
Definition: 2d.cpp:1197
ubyte blue
Definition: 2d.h:102
object * objp
Definition: lua.cpp:3105
int max_w_unscaled
Definition: 2d.h:361
#define Int3()
Definition: pstypes.h:292
#define _hypot(x, y)
Definition: config.h:281
vec3d pos
Definition: object.h:152
#define GR_RESIZE_NONE
Definition: 2d.h:681
int asteroid_subtype
Definition: asteroid.h:103
int clip_height
Definition: 2d.h:378
SCP_list< CJumpNode > Jump_nodes
Definition: jumpnode.cpp:16
GLenum type
Definition: Gl.h:1492
GLint GLsizei width
Definition: Gl.h:1505
Definition: hud.h:201
ubyte green
Definition: 2d.h:101
int weapon_info_index
Definition: weapon.h:164
int Min_subtarget_box_width
Definition: hudbrackets.h:38
int asteroid_type
Definition: asteroid.h:102
int submodel_num
Definition: debris.h:35
int Min_target_box_height[GR_NUM_RESOLUTIONS]
Definition: hudbrackets.cpp:40
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
int instance
Definition: object.h:150
#define PF_OVERFLOW
Definition: 3d.h:22
#define VM_DEAD_VIEW
Definition: systemvars.h:33
int target_is_dying
Definition: player.h:172
screen3d screen
Definition: pstypes.h:173
int font_num
Definition: hud.h:210
#define GR_AABITMAP(a, b, c)
Definition: hud.h:79
void draw_brackets_square_quick(int x1, int y1, int x2, int y2, int thick)
Definition: hudbrackets.cpp:92
#define OBJ_WEAPON
Definition: object.h:33
void initMinSubTargetBoxSizes(int w, int h)
int base_w
Definition: hud.h:205
#define OBJ_DEBRIS
Definition: object.h:37
#define w(p)
Definition: modelsinc.h:68
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
#define IFF_COLOR_MESSAGE
Definition: iff_defs.h:20
ubyte red
Definition: 2d.h:100
ubyte g3_rotate_vertex(vertex *dest, const vec3d *src)
Definition: 3dmath.cpp:97
#define TARGET_DISPLAY_SUBSYS
Definition: hudtarget.h:163
void draw_brackets_dashed_square_quick(int x1, int y1, int x2, int y2)
float current_hits
Definition: ship.h:319
#define TARGET_DISPLAY_DOTS
Definition: hudtarget.h:161
#define TARGET_DISPLAY_CLASS
Definition: hudtarget.h:165
int HUD_drew_selection_bracket_on_target
Definition: hudtarget.cpp:3383
int g3_project_vertex(vertex *point)
Definition: 3dmath.cpp:202
debris Debris[MAX_DEBRIS_PIECES]
Definition: debris.cpp:41
int targeted_subsys_parent
Definition: ai.h:474
int Min_subtarget_box_height[GR_NUM_RESOLUTIONS]
Definition: hudbrackets.cpp:42
int iff_x_attacks_y(int team_x, int team_y)
Definition: iff_defs.cpp:605
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
object Objects[MAX_OBJECTS]
Definition: object.cpp:62
const char * XSTR(const char *str, int index)
Definition: localize.cpp:851
#define OBJ_INDEX(objp)
Definition: object.h:235
ship * Player_ship
Definition: ship.cpp:124
matrix orient
Definition: object.h:153
int max_w
Definition: 2d.h:360
#define NOX(s)
Definition: pstypes.h:473
bool end_string_at_first_hash_symbol(char *src)
Definition: parselo.cpp:3833
#define ASTEROID_TYPE_MEDIUM
Definition: asteroid.h:30
#define OBJ_SHIP
Definition: object.h:32
ubyte flags
Definition: pstypes.h:178
int Hud_target_w
Definition: hudtarget.cpp:52
GLbitfield flags
Definition: Glext.h:6722
void draw_brackets_diamond_quick(int x1, int y1, int x2, int y2)
int control_mode
Definition: player.h:134
GLuint const GLchar * name
Definition: Glext.h:5608
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:791
float radius
Definition: model.h:179
color * iff_get_color(int color_index, int is_bright)
Definition: iff_defs.cpp:636
int num_ships_attacking(int target_objnum)
Definition: aicode.cpp:9346
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
Definition: bmpman.cpp:1119
ship Ships[MAX_SHIPS]
Definition: ship.cpp:122
bool gr_resize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
Definition: 2d.cpp:212
#define HUD_OBJECT_BRACKETS
Definition: hudparse.h:196
int parent_objnum
Definition: ship.h:316
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
GLint GLsizei GLsizei height
Definition: Gl.h:1505
float vm_vec_dist_quick(const vec3d *v0, const vec3d *v1)
Definition: vecmat.cpp:417
#define NAME_LENGTH
Definition: globals.h:15
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
int g3_in_frame()
Definition: 3dsetup.cpp:66
#define fl2i(fl)
Definition: floating.h:33
player * Player
#define g3_end_frame()
Definition: 3d.h:49
#define ASTEROID_TYPE_LARGE
Definition: asteroid.h:31
#define TARGET_DISPLAY_NAME
Definition: hudtarget.h:164
int clip_width
Definition: 2d.h:378
screen gr_screen
Definition: 2d.cpp:46
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
Definition: font.cpp:196
int gr_get_font_height()
Definition: font.cpp:187
int ship_info_index
Definition: ship.h:539
SCP_vector< ship_info > Ship_info
Definition: ship.cpp:164
#define LOCATION
Definition: pstypes.h:245
int max_h
Definition: 2d.h:360
void gr_reset_screen_scale()
Definition: 2d.cpp:176
int submodel_find_2d_bound_min(int model_num, int submodel, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
Definition: modelread.cpp:3232
float Hud_unit_multiplier
Definition: hudparse.cpp:40
vec3d * get_subsystem_world_pos(object *parent_obj, ship_subsys *subsys, vec3d *world_pos)
Definition: hudtarget.cpp:4395
bool gr_unsize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
Definition: 2d.cpp:320
int Min_subtarget_box_height
Definition: hudbrackets.h:39
void hud_stuff_ship_class(char *ship_class_text, ship *shipp)
Definition: hudtarget.cpp:5325
void renderBoundingBrackets(int x1, int y1, int x2, int y2, int w_correction, int h_correction, float distance, int target_objnum, int flags)
int model_num
Definition: weapon.h:329
object * Player_obj
Definition: object.cpp:56
int Hud_target_h
Definition: hudtarget.cpp:52
void draw_brackets_diamond(int x1, int y1, int x2, int y2)
void initMinTargetBoxSizes(int w, int h)
float hud_find_target_distance(object *targetee, object *targeter)
Definition: hudtarget.cpp:2009
false
Definition: lua.cpp:6789
void hud_stuff_ship_callsign(char *ship_callsign_text, ship *shipp)
Definition: hudtarget.cpp:5290
int draw_subsys_brackets(ship_subsys *subsys, int min_width, int min_height, bool draw, bool set_color, int *draw_coords)
int rendering_to_texture
Definition: 2d.h:403
char type
Definition: object.h:146
int Min_target_box_width[GR_NUM_RESOLUTIONS]
Definition: hudbrackets.cpp:39
void hud_init_brackets()
Definition: hudbrackets.cpp:44
void draw_brackets_square(int x1, int y1, int x2, int y2, int resize_mode)
Definition: hudbrackets.cpp:49
SCP_vector< asteroid_info > Asteroid_info
Definition: asteroid.cpp:62
bool ship_subsys_takes_damage(ship_subsys *ss)
Definition: ship.cpp:17545
void hud_set_iff_color(object *objp, int is_bright)
Will set the color to the IFF color based on the team.
Definition: hud.cpp:2950
#define OBJ_JUMP_NODE
Definition: object.h:45
int Min_subtarget_box_width[GR_NUM_RESOLUTIONS]
Definition: hudbrackets.cpp:41
void render(float frametime)
GLint y
Definition: Gl.h:1505
#define g3_start_frame(zbuffer_flag)
Definition: 3d.h:39
#define strcpy_s(...)
Definition: safe_strings.h:67
void renderBoundingBracketsSubobject()