Files
Goober5000 a047be61d5 add capability (plus sexps) to set navpoint color
This is useful because certain backgrounds (such as a nebula) will make it hard to see the default navpoint color.  Also this means that different navpoints can now have different colors.
2022-03-07 03:32:50 -05:00

53 lines
1.5 KiB
C++

// HUDNavigation.cpp
// Derek Meek
// 4-30-2004
#include "autopilot/autopilot.h"
#include "hud/hud.h"
#include "hud/hudbrackets.h"
#include "hud/hudnavigation.h"
#include "hud/hudtarget.h"
#include "hud/hudtargetbox.h"
#include "object/object.h"
#include "render/3d.h"
#include "ship/ship.h"
extern void hud_target_show_dist_on_bracket(int x, int y, float distance, int font_num);
extern void draw_brackets_square_quick(int x1, int y1, int x2, int y2, int thick);
/**
* Draws the Navigation stuff on the HUD
*/
void hud_draw_navigation()
{
if (CurrentNav != -1 && Navs[CurrentNav].flags & NP_VALIDTYPE && !(Navs[CurrentNav].flags & NP_NOSELECT))
{
int in_cockpit;
if (!(Viewer_mode & (VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY)) )
in_cockpit = 1;
else
in_cockpit = 0;
vertex target_point; // temp vertex used to find screen position for 3-D object;
auto target_pos = Navs[CurrentNav].GetPosition();
color NavColor;
memset(&target_point, 0, sizeof(target_point));
unsigned int alpha = HUD_COLOR_ALPHA_MAX * 16;
auto rgb = (Navs[CurrentNav].flags & NP_VISITED) ? Navs[CurrentNav].visited_color : Navs[CurrentNav].normal_color;
gr_init_alphacolor( &NavColor, rgb[0], rgb[1], rgb[2], alpha );
g3_rotate_vertex(&target_point, target_pos);
g3_project_vertex(&target_point);
if ( in_cockpit )
hud_target_add_display_list(NULL, &target_point, target_pos, 0, &NavColor, Navs[CurrentNav].m_NavName, TARGET_DISPLAY_DIST);
}
}