[Add] Map will draw hyperspace paths. :D

This commit is contained in:
Allanis 2013-03-10 16:40:48 +00:00
parent d31b9dad30
commit dfb57c1775

View File

@ -120,7 +120,7 @@ static void map_update(void) {
// Render the map as a custom widget.
static void map_render(double bx, double by, double w, double h) {
int i;
int i, j;
double x, y, r;
StarSystem* sys;
@ -136,14 +136,36 @@ static void map_render(double bx, double by, double w, double h) {
glVertex2d(bx+w, by);
glEnd();
//COLOUR(cYellow);
// Render the star systems.
for(i = 0; i < systems_nstack; i++) {
if(&systems_stack[i] == cur_system) COLOUR(cRadar_targ);
sys = &systems_stack[i];
// Draw the system.
if(sys == cur_system) COLOUR(cRadar_targ);
else if(sys->nplanets == 0) COLOUR(cInert);
else COLOUR(cYellow);
gl_drawCircleInRect(x + systems_stack[i].pos.x,
y + systems_stack[i].pos.y,
gl_drawCircleInRect(x + sys->pos.x,
y + sys->pos.y,
r, bx, by, w, h);
// Draw the hyperspace paths.
glShadeModel(GL_SMOOTH);
for(j = 0; j < sys->njumps; j++) {
// Cheaply use transparency instead of actually
// calculating from x to y the line must go. :)
glBegin(GL_LINE_STRIP);
COLOUR(cTrans);
glVertex2d(x+sys->pos.x, y+sys->pos.y);
COLOUR(cInert);
glVertex2d(
x+sys->pos.x+(systems_stack[sys->jumps[j]].pos.x-sys->pos.x)/2.,
y+sys->pos.y+(systems_stack[sys->jumps[j]].pos.y-sys->pos.y)/2.);
COLOUR(cTrans);
glVertex2d(x+systems_stack[sys->jumps[j]].pos.x,
y+systems_stack[sys->jumps[j]].pos.y);
glEnd();
}
glShadeModel(GL_FLAT);
}
// Selected planet.
sys = &systems_stack[map_selected];